Skip to content

fix(engine): preserve discard provenance through recruit choice - #7088

Merged
matthewevans merged 1 commit into
mainfrom
ship/fix-engine-preserve-discard-provenance
Aug 8, 2026
Merged

fix(engine): preserve discard provenance through recruit choice#7088
matthewevans merged 1 commit into
mainfrom
ship/fix-engine-preserve-discard-provenance

Conversation

@matthewevans

@matthewevans matthewevans commented Aug 8, 2026

Copy link
Copy Markdown
Member

Fixes #7087.\n\nReplays the attached persisted game state and fixes terminal discard provenance for the adjacent discard/continuation resolution pair.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed discard choices during ability resolution to use the correct associated discard event.
    • Recruit effects now correctly create tokens based on the discarded card.
    • Improved resolution continuity, graveyard placement, card draws, and priority restoration after discarding.
  • Tests

    • Added coverage for matching and mismatched discard events, nested resolution scenarios, and Recruit discard behavior.

@matthewevans
matthewevans enabled auto-merge August 8, 2026 00:08
@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: fdba2fbb-0411-48b8-8cee-115e8521c6ef

📥 Commits

Reviewing files that changed from the base of the PR and between 55eb99a and 8f5d761.

📒 Files selected for processing (1)
  • crates/engine/tests/integration/main.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/engine/tests/integration/main.rs

📝 Walkthrough

Walkthrough

The change adds positional discard-parent lookup, uses it for discard provenance recording, and adds unit and integration tests for nested, land, and nonland discard cases.

Changes

Discard provenance handling

Layer / File(s) Summary
Adjacent discard parent accessor
crates/engine/src/types/resolution.rs
ResolutionStack now returns the mutable discard frame directly adjacent to the active ability continuation when the discard ID matches. Tests cover matching, mismatched, and buried frames.
Discard pipeline integration
crates/engine/src/game/zone_pipeline.rs, crates/engine/tests/integration/*
Discard result recording uses the continuation’s parent discard frame. Integration tests verify Bifur and Plains discard behavior, graveyard placement, token counts, resolution resumption, and priority restoration.

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

Possibly related PRs

  • phase-rs/phase#7074: Both changes modify discard provenance and resolution-stack parent lookup.
  • phase-rs/phase#6532: Both changes modify resolution-stack handling and ability-continuation parent relationships.

Suggested labels: bug

🚥 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 identifies the engine fix that preserves discard provenance through the Recruit choice.
Linked Issues check ✅ Passed The changes resolve issue #7087 by locating the adjacent discard parent and adding regression tests for the Recruit panic.
Out of Scope Changes check ✅ Passed The code changes, helper tests, integration test, and test registration all support the linked issue and PR objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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-preserve-discard-provenance

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 force-pushed the ship/fix-engine-preserve-discard-provenance branch from 55eb99a to 8f5d761 Compare August 8, 2026 00:20
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Generated for head 8f5d761672ef6115ecd46bcbf4313c9b7c351669.

Parse changes introduced by this PR

✓ No card-parse changes detected.

@matthewevans
matthewevans added this pull request to the merge queue Aug 8, 2026
Merged via the queue into main with commit 7262d7f Aug 8, 2026
13 checks passed
@matthewevans
matthewevans deleted the ship/fix-engine-preserve-discard-provenance branch August 8, 2026 01:02
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.

Non-fatal engine panic: discard provenance must name the active discard frame

1 participant