Skip to content

fix(engine): retain batch delivery on reveal continuation cleanup - #7275

Merged
matthewevans merged 2 commits into
mainfrom
ship/fix-engine-retain-reveal-delivery
Aug 12, 2026
Merged

fix(engine): retain batch delivery on reveal continuation cleanup#7275
matthewevans merged 2 commits into
mainfrom
ship/fix-engine-retain-reveal-delivery

Conversation

@matthewevans

@matthewevans matthewevans commented Aug 12, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Improved optional reveal handling when an ability is being delivered in batches.
    • Ensured the correct continuation is cleared while preserving the active batch-delivery process.
    • Added safeguards so unrelated resolution steps are not removed accidentally.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@matthewevans, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 1 minute

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 50eda242-4090-4818-88b5-9337e07d5818

📥 Commits

Reviewing files that changed from the base of the PR and between a635584 and f9323a4.

📒 Files selected for processing (1)
  • crates/engine/src/types/game_state.rs
📝 Walkthrough

Walkthrough

The resolution stack now removes an active ability continuation directly or beneath an adjacent batch-delivery child. Game-state exposes this behavior, and accepted or declined reveal choices use the new cleanup path.

Changes

Continuation cleanup

Layer / File(s) Summary
Batch-aware resolution stack helper
crates/engine/src/types/resolution.rs
The stack helper consumes direct continuations or adjacent batch-delivery children, preserves the batch frame, and rejects unrelated frames. Tests cover these cases.
Game-state and reveal-choice integration
crates/engine/src/types/game_state.rs, crates/engine/src/game/engine_resolution_choices.rs
Game-state exposes the cleanup method. Accepted and declined reveal choices use it.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: quality

Suggested reviewers: andriypolanski, jacobwoodson, 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 clearly describes the main change: retaining batch delivery during reveal continuation cleanup.
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/fix-engine-retain-reveal-delivery

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.

@matthewevans
matthewevans enabled auto-merge August 12, 2026 03:37
@matthewevans
matthewevans force-pushed the ship/fix-engine-retain-reveal-delivery branch from a635584 to f9323a4 Compare August 12, 2026 04:25

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/engine/src/game/engine_resolution_choices.rs (1)

3705-3712: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Route CastFromZone continuation consumption through the batch-aware helper.

open_private_zone_cast_selection can place the continuation below an active BatchDelivery. The declined and selected CastFromZone branches still call take_active_ability_continuation().expect(...), which can panic when BatchDelivery owns the stack top. Attach does not use this insertion path.

🤖 Prompt for 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.

In `@crates/engine/src/game/engine_resolution_choices.rs` around lines 3705 -
3712, Update both selected and declined CastFromZone branches in
open_private_zone_cast_selection to consume the continuation through
clear_active_ability_continuation_or_batch_delivery_child instead of
take_active_ability_continuation. Preserve the existing expect-based failure
handling while supporting continuations nested beneath an active BatchDelivery.
🧹 Nitpick comments (1)
crates/engine/src/types/resolution.rs (1)

3998-4054: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a test for a BatchDelivery whose parent is not an AbilityContinuation.

The new test covers two cases: the direct batch-child relation succeeds, and an unrelated top frame (ChangeZone, not BatchDelivery) is rejected. It does not cover the case where BatchDelivery owns the stack top but the frame directly below it is something other than AbilityContinuation (for example ChangeZone below BatchDelivery). The implementation's own doc comment states that "missing or unrelated parent relationships return no continuation," so this path needs its own assertion that the stack is left unmodified and Ok(None) is returned.

Based on learnings, CLAUDE.md requires focused unit tests for "stack ordering, frame preservation, direct continuation removal, and rejection of unrelated/non-adjacent frames." The unrelated-parent-below-BatchDelivery case is not yet exercised.

🧪 Proposed additional test case
     let mut unrelated_child = ResolutionStack::default();
     unrelated_child.push_inner(continuation_frame(2));
     unrelated_child.push_inner(change_zone_frame(2));
     assert!(
         matches!(
             unrelated_child.take_active_ability_continuation_or_batch_delivery_child(),
             Err(ResolutionStackError::UnexpectedTop {
                 expected: FrameKind::AbilityContinuation,
                 actual: FrameKind::ChangeZone,
             })
         ),
         "the helper does not search through an arbitrary child frame"
     );
+
+    let mut unrelated_parent = ResolutionStack::default();
+    unrelated_parent.push_inner(change_zone_frame(3));
+    unrelated_parent.push_inner(batch_delivery_frame(3));
+    let before = unrelated_parent.clone();
+    assert_eq!(
+        unrelated_parent.take_active_ability_continuation_or_batch_delivery_child(),
+        Ok(None),
+        "a BatchDelivery child with a non-continuation parent has nothing to consume"
+    );
+    assert_eq!(
+        unrelated_parent, before,
+        "an unrelated parent leaves the stack untouched"
+    );
 }
🤖 Prompt for 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.

In `@crates/engine/src/types/resolution.rs` around lines 3998 - 4054, Extend
take_continuation_preserves_an_active_batch_delivery_child with a case where
BatchDelivery is on top of a ChangeZone frame rather than an
AbilityContinuation. Assert
take_active_ability_continuation_or_batch_delivery_child returns Ok(None),
preserves both frames and their ordering, and does not remove or mutate the
stack.

Source: Path instructions

🤖 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.

Outside diff comments:
In `@crates/engine/src/game/engine_resolution_choices.rs`:
- Around line 3705-3712: Update both selected and declined CastFromZone branches
in open_private_zone_cast_selection to consume the continuation through
clear_active_ability_continuation_or_batch_delivery_child instead of
take_active_ability_continuation. Preserve the existing expect-based failure
handling while supporting continuations nested beneath an active BatchDelivery.

---

Nitpick comments:
In `@crates/engine/src/types/resolution.rs`:
- Around line 3998-4054: Extend
take_continuation_preserves_an_active_batch_delivery_child with a case where
BatchDelivery is on top of a ChangeZone frame rather than an
AbilityContinuation. Assert
take_active_ability_continuation_or_batch_delivery_child returns Ok(None),
preserves both frames and their ordering, and does not remove or mutate the
stack.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 709a558c-5a4e-4a51-8aab-b59893986f93

📥 Commits

Reviewing files that changed from the base of the PR and between 3784828 and a635584.

📒 Files selected for processing (3)
  • crates/engine/src/game/engine_resolution_choices.rs
  • crates/engine/src/types/game_state.rs
  • crates/engine/src/types/resolution.rs

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown

Generated for head f9323a44f388e0857aeaac96f543dc1ecd7d7231.

Parse changes introduced by this PR

✓ No card-parse changes detected.

@matthewevans
matthewevans added this pull request to the merge queue Aug 12, 2026
Merged via the queue into main with commit a54adc6 Aug 12, 2026
15 checks passed
@matthewevans
matthewevans deleted the ship/fix-engine-retain-reveal-delivery branch August 12, 2026 06:56
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