Skip to content

fix(ai): filter target-dependent optional costs - #7110

Merged
matthewevans merged 2 commits into
mainfrom
ship/ai-optional-cost-targets
Aug 8, 2026
Merged

fix(ai): filter target-dependent optional costs#7110
matthewevans merged 2 commits into
mainfrom
ship/ai-optional-cost-targets

Conversation

@matthewevans

@matthewevans matthewevans commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Improved decision validation for effects involving optional costs and deferred targets.
    • Optional payments that enable valid targets are now offered correctly.
    • Optional payments are excluded when declining them would leave no legal targets.
    • Added validation coverage for required casting conditions and target-dependent choices.

@matthewevans
matthewevans enabled auto-merge August 8, 2026 22:33
@coderabbitai

coderabbitai Bot commented Aug 8, 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: 5cd4b382-d170-4bce-a5df-959106b27e69

📥 Commits

Reviewing files that changed from the base of the PR and between 6bfca3f and 252133a.

📒 Files selected for processing (3)
  • crates/engine/src/ai_support/context.rs
  • crates/engine/tests/integration/ai_decision_contract.rs
  • crates/engine/tests/integration/main.rs
💤 Files with no reviewable changes (1)
  • crates/engine/src/ai_support/context.rs

📝 Walkthrough

Walkthrough

AiDecisionContract::issue now validates optional-cost choices that can defer target selection. An integration test verifies that choices leaving no legal targets are excluded.

Changes

Deferred Target Validation

Layer / File(s) Summary
Reducer validation predicate and issuance
crates/engine/src/ai_support/context.rs
AiDecisionContract::issue now validates target-dependent payment changes and deferred target selection during optional-cost decisions.
Deferred optional-cost integration coverage
crates/engine/tests/integration/ai_decision_contract.rs, crates/engine/tests/integration/main.rs
The integration test verifies the rejected non-kicker branch and confirms that the contract exposes only the target-enabling kicker payment choice. The test module is registered in the integration suite.

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

Possibly related PRs

  • phase-rs/phase#6829: This PR extends the same AiDecisionContract::issue reducer-validation logic.
  • phase-rs/phase#7104: Both PRs update AiDecisionContract::issue for target-dependent payment and optional-cost decisions.

Suggested labels: bug

Suggested reviewers: lgray, nishu-builder, invalidcards

🚥 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 clearly and concisely describes the main change: filtering optional costs that depend on target legality.
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/ai-optional-cost-targets

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: 1

🤖 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/engine/src/ai_support/context.rs`:
- Around line 371-494: Move the regression test
decision_contract_filters_optional_cost_that_leaves_no_legal_targets from
context.rs into the appropriate crates/engine/tests/integration/ test module,
preserving both reach-guard assertions and its existing production cast/contract
behavior. Register the new integration test module through
tests/integration/main.rs as required.
🪄 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: 4b51ab31-9b08-4557-a295-d94928e12540

📥 Commits

Reviewing files that changed from the base of the PR and between d46667f and 6bfca3f.

📒 Files selected for processing (1)
  • crates/engine/src/ai_support/context.rs

Comment thread crates/engine/src/ai_support/context.rs Outdated
@matthewevans
matthewevans added this pull request to the merge queue Aug 8, 2026
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Generated for head 252133ae569453efe491e4f06d718107be30fbfe.

Parse changes introduced by this PR

✓ No card-parse changes detected.

Merged via the queue into main with commit bbd2445 Aug 8, 2026
13 checks passed
@matthewevans
matthewevans deleted the ship/ai-optional-cost-targets branch August 8, 2026 23:23
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