Skip to content

fix(ai): align engine-issued action contracts - #7084

Merged
matthewevans merged 2 commits into
mainfrom
ship/fixai-align-engine-issued-action-contracts
Aug 7, 2026
Merged

fix(ai): align engine-issued action contracts#7084
matthewevans merged 2 commits into
mainfrom
ship/fixai-align-engine-issued-action-contracts

Conversation

@matthewevans

@matthewevans matthewevans commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Improved action selection so available actions are handled consistently for individual game objects.
    • Expanded exchange validation across additional cast and activation choices.
    • Updated tactical decision-making to reject plays and activations that would lead to unfavorable exchanges.
    • Refined mana-related decision logic, including situations involving convoke and demanded colors.
    • Removed outdated decision paths to improve the reliability of automated gameplay.

@matthewevans
matthewevans enabled auto-merge August 7, 2026 20:03
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c65c5ae-cf95-4de2-81fe-d47c9cc62dfe

📥 Commits

Reviewing files that changed from the base of the PR and between 36e36f1 and 8a253ae.

📒 Files selected for processing (4)
  • crates/engine/src/ai_support/mod.rs
  • crates/engine/src/ai_support/targeted_exchange.rs
  • crates/phase-ai/src/search.rs
  • crates/phase-ai/src/tactical_gate.rs

📝 Walkthrough

Walkthrough

The client now uses ObjectAction for per-object legal-action collections. The AI recognizes more targeted-exchange roots and uses verdict-based tactical gating instead of demanded-color tap detection.

Changes

Client action typing

Layer / File(s) Summary
Adopt ObjectAction legal-action buckets
client/src/viewmodel/cardActionChoice.ts
Action-choice helpers now consume and return ObjectAction[] collections for per-object legal actions.

AI tactical validation

Layer / File(s) Summary
Recognize targeted-exchange roots
crates/engine/src/ai_support/targeted_exchange.rs, crates/engine/src/ai_support/mod.rs
Direct free, Miracle, Madness, Sneak, and WebSlinging casts are recognized as roots. Synthesized copy-casts are excluded.
Apply targeted-exchange verdicts
crates/phase-ai/src/search.rs, crates/phase-ai/src/tactical_gate.rs
Search and tactical gating use the shared root predicate. Tactical gating rejects roots with a proven Reject verdict.
Remove demanded-color tap helper
crates/phase-ai/src/mana_colors.rs
The unused demanded-color tap helper and related references are removed.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Search
  participant TacticalGate
  participant TargetedExchange
  Search->>TacticalGate: evaluate candidate action
  TacticalGate->>TargetedExchange: classify root and evaluate verdict
  TargetedExchange-->>TacticalGate: verdict
  TacticalGate-->>Search: reject only proven Reject roots
Loading

Possibly related PRs

Suggested labels: bug

Suggested reviewers: andriypolanski, lgray

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the pull request's main changes to align AI action types and engine-issued action handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ship/fixai-align-engine-issued-action-contracts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/phase-ai/src/tactical_gate.rs`:
- Around line 208-225: Restore the demanded-color validation for TapLandForMana
candidates, preferably in mana_payment_actions so each engine-issued candidate
remains rules-correct and composable; otherwise add equivalent rejection in
assess_pre_cast. Ensure a dual U/R source cannot be selected for {R} while {U}
remains pending in a {2}{U} cost, and add a regression test covering that
ManaPayment path and preventing the fallback panic.
- Around line 213-225: Extend the targeted-exchange handling in assess_pre_cast
and targeted_exchange_verdict to recognize every spell-cast root, including
CastSpellForFree, CastSpellAsSneak, CastSpellAsWebSlinging, CastSpellAsMiracle,
and CastSpellAsMadness, while preserving ActivateAbility behavior. Ensure each
variant is bound and dispatched through the same verdict path, and add coverage
for every supported cast family.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: df5210a2-d7c1-4964-8b10-c6a61be79382

📥 Commits

Reviewing files that changed from the base of the PR and between 710c497 and 36e36f1.

⛔ Files ignored due to path filters (1)
  • client/src/wasm/engine_wasm.d.ts is excluded by !client/src/wasm/**, !**/*.d.ts
📒 Files selected for processing (3)
  • client/src/viewmodel/cardActionChoice.ts
  • crates/phase-ai/src/mana_colors.rs
  • crates/phase-ai/src/tactical_gate.rs

Comment thread crates/phase-ai/src/tactical_gate.rs
Comment thread crates/phase-ai/src/tactical_gate.rs
@matthewevans
matthewevans added this pull request to the merge queue Aug 7, 2026
@matthewevans
matthewevans removed this pull request from the merge queue due to a manual request Aug 7, 2026
@matthewevans
matthewevans enabled auto-merge August 7, 2026 20:27
@matthewevans
matthewevans added this pull request to the merge queue Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Generated for head 8a253ae9247af8254f931530a385a95f0e5c1386.

Parse changes introduced by this PR

✓ No card-parse changes detected.

Merged via the queue into main with commit cf8d8e8 Aug 7, 2026
16 of 17 checks passed
@matthewevans
matthewevans deleted the ship/fixai-align-engine-issued-action-contracts branch August 7, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant