fix(engine): preserve mana-spent snapshots across spell ETB (#1156)#3735
Conversation
…#1156) Extend CastLinkSnapshot so creature spells keep mana_spent_source_snapshots and related cast-payment fields when resolving from the stack to the battlefield, letting Coin of Mastery count artifact mana spent to cast. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Code Review
This pull request updates CastLinkSnapshot in crates/engine/src/game/zone_pipeline.rs to include fields for tracking details about the mana spent to cast, such as mana_spent_to_cast, mana_spent_to_cast_amount, colors_spent_to_cast, and mana_spent_source_snapshots. These fields are also correctly copied and restored within the deliver_replaced_zone_change function. As there were no review comments provided, I have no feedback to evaluate.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
matthewevans
left a comment
There was a problem hiding this comment.
[MED] This does not demonstrate a fix for the Coin of Mastery failure, and the added snapshot fields appear to be at the wrong/no-op seam. Evidence: crates/engine/src/game/zone_pipeline.rs:1558 now snapshots/restores the mana-spent fields around zones::move_to_zone, but GameObject::reset_for_battlefield_entry clears cast provenance/kicker/convoke at crates/engine/src/game/game_object.rs:1336-1352 and does not clear mana_spent_to_cast_amount, colors_spent_to_cast, or mana_spent_source_snapshots. The Coin-style ETB counter quantity is resolved before the move in extract_etb_counters_from_effect using QuantityContext { entering: Some(object_id), ... } (crates/engine/src/game/replacement.rs:3988-4018), and source-qualified mana reads the entering object snapshot list at crates/engine/src/game/quantity.rs:789-802; those snapshots are already populated during mana payment at crates/engine/src/game/casting.rs:10188-10220. The PR also changes only zone_pipeline.rs, so there is no fail-on-revert regression for issue #1156. Why it matters: this can merge a no-op while the reported “mana from an artifact source spent to cast it” path remains broken or unproven. Suggested fix: first add a regression that fails on origin/main for Coin of Mastery (or an equivalent Moved replacement using CastManaSpentMetric::FromSource { source_filter: Artifact }) through the real cast/payment/replacement path, then put the fix at the seam that makes that test pass; if the delivery snapshot is genuinely necessary, the test should fail when these four new CastLinkSnapshot fields are removed.
Confidence: high from code inspection; contradictory evidence would be a regression test that fails on origin/main and passes only with this CastLinkSnapshot expansion.
…e-rs#1156) Revert the no-op CastLinkSnapshot mana-spent expansion in zone_pipeline. Coin-style ETB counters resolve before the battlefield move via extract_etb_counters using the entering spell's payment-time source snapshots (casting.rs), not post-delivery snapshot restore. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Thanks for the review — you were right that the What I verified
What changed in 90ebcba
Test plan
These pass on |
|
VERDICT: approve-pending-CI Re-reviewed follow-up head Prior blocker status: ADDRESSED. The wrong-seam Holding formal approval/enqueue until CI is green on the pushed head and the normal repush guard passes. |
matthewevans
left a comment
There was a problem hiding this comment.
Approved after re-review of the current head: the wrong-seam CastLinkSnapshot path was removed, the artifact-mana regression now exercises the real cast/commit/resolve flow, the required category labels are present, and GitHub checks are green at 64a818bb1dee42fc2cbc2abf4f420b9f274d071a.
|
@matthewevans Re: the zone-pipeline snapshot concern — agreed that expanding |
Summary
mana_spent_source_snapshots,colors_spent_to_cast, and related cast-payment fields inCastLinkSnapshotduring stack-to-battlefield delivery.Fixes #1156
Test plan
cargo test -p engine --lib artifact_mana_spent_on_selfMade with Cursor