Skip to content

Fix Emperor of Bones regression coverage - #7243

Merged
matthewevans merged 8 commits into
phase-rs:mainfrom
traemyn:card/emperor-of-bones
Aug 11, 2026
Merged

Fix Emperor of Bones regression coverage#7243
matthewevans merged 8 commits into
phase-rs:mainfrom
traemyn:card/emperor-of-bones

Conversation

@traemyn

@traemyn traemyn commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a reducer-path regression test for Issue #1515 proving that Emperor of Bones remains on the battlefield while the creature it returns receives haste and the delayed sacrifice rider. The production fix is already present on current upstream main; this PR adds the missing real cast-pipeline coverage against the archived bug behavior.

Files changed

  • crates/engine/tests/integration/issue_1515_emperor_of_bones.rs

Track

Developer

LLM

Model: GitHub Copilot (canonical id not exposed)
Tier: Frontier
Thinking: high

Implementation method (required)

Method: /engine-implementer

Note

Any change to crates/engine/ game logic — parser, effects, resolver,
targeting, rules behavior — is expected to go through /engine-implementer.
The "not used" box is for changes that genuinely fall outside that scope.

CR references

  • CR 122.1 — counters are placed on the targeted creature.
  • CR 603.2 — the counter-triggered ability triggers when its event occurs.
  • CR 608.2c — the resolving ability follows its instructions in order, including the anaphoric riders.

Verification

  • Required checks ran clean, or the exact CI-owned alternative is stated below.

  • Gate A output below is for the current committed head.

  • Final review-impl below is clean for the current committed head.

  • Both anchors cite existing analogous code at the same seam.

  • cargo fmt --all — exit 0.

  • cargo test -p phase-engine --test integration issue_1515_emperor_of_bones -- --nocapture — 4 passed.

  • cargo clippy --all-targets -- -D warnings — exit 0.

  • cargo test -p phase-engine — exit 0.

  • cargo coverage — exit 0; 31,775/35,795 cards supported (88.8%).

  • cargo semantic-audit — exit 0; 32,730 cards audited, 266 existing findings; no Emperor of Bones finding reported.

  • git diff --check upstream/main...HEAD — exit 0.

Gate A

Gate A PASS head=74dd287939918ac9cccbb4b1f4889675340e2d9a base=97591656218103d8e8c7315725b24cfe64645dd4

Anchored on

  • crates/engine/tests/integration/issue_1515_emperor_of_bones.rs:59 — existing direct resolution regression verifies the returned creature receives haste and the delayed sacrifice does not target Emperor.
  • crates/engine/tests/integration/issue_1515_emperor_of_bones.rs:230 — existing as-enters continuation regression drives the returned permanent through the scenario runner and verifies its riders resume after choices.

Final review-impl

Final review-impl PASS head=74dd287939918ac9cccbb4b1f4889675340e2d9a

Claimed parse impact

None.

Scope Expansion

None.

Validation Failures

None.

CI Failures

None.

Summary by CodeRabbit

  • Tests

    • Added integration coverage for Emperor of Bones and its counter-placement spell.
    • Verified that the linked creature correctly receives finality and haste, rather than Emperor of Bones.
    • Confirmed the linked creature is captured by the delayed sacrifice effect after the spell resolves.
  • Documentation

    • Added complete Oracle text for Emperor of Bones and the counter-placement spell.

@traemyn
traemyn requested a review from matthewevans as a code owner August 11, 2026 20:20
@coderabbitai

coderabbitai Bot commented Aug 11, 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: e04a6d8b-8229-45e4-b772-8f29bd14deee

📥 Commits

Reviewing files that changed from the base of the PR and between 74dd287 and 8e218b7.

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

📝 Walkthrough

Walkthrough

The integration test adds Oracle text for Emperor of Bones and a counter-placement spell. It verifies linked-creature return, Emperor preservation, finality and haste assignment, and delayed sacrifice through the cast pipeline.

Changes

Emperor of Bones counter regression

Layer / File(s) Summary
Counter trigger pipeline regression
crates/engine/tests/integration/issue_1515_emperor_of_bones.rs
Adds card text constants and a cast-pipeline test for linked-creature return, finality and haste assignment, Emperor preservation, and delayed sacrifice targeting.

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

Possibly related PRs

  • phase-rs/phase#6686: The test exercises the counter-placement and resolution behavior implemented by this PR.
  • phase-rs/phase#6698: The test covers linked-object and departure-trigger behavior addressed by this PR.
  • phase-rs/phase#7200: Both PRs add Emperor of Bones integration coverage for linked-creature finality, haste, and delayed sacrifice.

Suggested reviewers: matthewevans

🚥 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 identifies the added regression coverage for Emperor of Bones.
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 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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/engine/tests/integration/issue_1515_emperor_of_bones.rs`:
- Around line 203-208: Extend the assertions in the test around returned and
state to verify that the returned creature has the required finality counter
using the existing counter accessor. Update the test comment to reference CR
122.1h, ensuring the test fails when enter_with_counters is omitted.
- Around line 29-31: Update the Emperor of Bones fixture text in the affected
test to replace both “this creature” self-references with “Emperor of Bones,”
preserving the authoritative Oracle wording and all other text unchanged.
🪄 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: 00009ad5-b2cd-4daf-830d-0c4bf4c07f7b

📥 Commits

Reviewing files that changed from the base of the PR and between 2f90392 and 74dd287.

📒 Files selected for processing (1)
  • crates/engine/tests/integration/issue_1515_emperor_of_bones.rs

Comment on lines +29 to +31
Whenever one or more +1/+1 counters are put on this creature, put a creature card exiled with this \
creature onto the battlefield under your control with a finality counter on it. It gains haste. \
Sacrifice it at the beginning of the next end step.";

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use the authoritative Oracle wording for both self-references.

The fixture replaces both self-references with this creature. The authoritative Modern Horizons 3 text uses Emperor of Bones in both places. (magic.wizards.com) This test can otherwise exercise a different parser path from the production card text.

Proposed Oracle-text fix
-Whenever one or more +1/+1 counters are put on this creature, put a creature card exiled with this \
-creature onto the battlefield under your control with a finality counter on it. It gains haste. \
+Whenever one or more +1/+1 counters are put on Emperor of Bones, put a creature card exiled with \
+Emperor of Bones onto the battlefield under your control with a finality counter on it. It gains haste. \

As per path instructions: “Preserve authoritative Oracle text.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Whenever one or more +1/+1 counters are put on this creature, put a creature card exiled with this \
creature onto the battlefield under your control with a finality counter on it. It gains haste. \
Sacrifice it at the beginning of the next end step.";
Whenever one or more +1/+1 counters are put on Emperor of Bones, put a creature card exiled with \
Emperor of Bones onto the battlefield under your control with a finality counter on it. It gains haste. \
Sacrifice it at the beginning of the next end step.";
🤖 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/tests/integration/issue_1515_emperor_of_bones.rs` around lines
29 - 31, Update the Emperor of Bones fixture text in the affected test to
replace both “this creature” self-references with “Emperor of Bones,” preserving
the authoritative Oracle wording and all other text unchanged.

Source: Path instructions

Comment on lines +203 to +208
let state = runner.state();
assert_eq!(
state.objects[&returned].zone,
Zone::Battlefield,
"the counter trigger must return the linked creature through apply()"
);

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Assert the finality counter on the returned creature.

The test proves that returned reaches the battlefield, but it does not prove that the return effect adds the required finality counter. The upstream build_dies_return_with_counter_trigger contract explicitly models this with enter_with_counters.

A regression that omits the counter would still pass these assertions. Under CR 122.1h, the counter changes a later graveyard move into exile. (media.wizards.com) Add an assertion using the existing counter accessor, and reference CR 122.1h in the test comment.

As per path instructions: “A test must exercise the failure path the fix prevents.”

🤖 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/tests/integration/issue_1515_emperor_of_bones.rs` around lines
203 - 208, Extend the assertions in the test around returned and state to verify
that the returned creature has the required finality counter using the existing
counter accessor. Update the test comment to reference CR 122.1h, ensuring the
test fails when enter_with_counters is omitted.

Source: Path instructions

@matthewevans matthewevans self-assigned this Aug 11, 2026

@matthewevans matthewevans left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved — current-head production-path regression coverage is load-bearing.

✅ Clean

  • crates/engine/tests/integration/issue_1515_emperor_of_bones.rs:181-236 drives Emperor's printed trigger from an actual counter spell through GameRunner::cast(...).resolve(), then distinguishes the returned creature from Emperor for battlefield placement, the finality entry modifier, haste, and the delayed-sacrifice target. That covers the cast/reducer path not exercised by the existing direct-resolver regressions.
  • CodeRabbit's finality-counter finding was valid and is covered by the maintainer fixup at lines 209-218. Its Oracle-wording finding is refuted: the current official Scryfall Oracle text uses “this creature” for both source references, matching lines 29-30.

Recommendation: merge when the required checks settle.

@matthewevans matthewevans added the test Add tests label Aug 11, 2026
@matthewevans
matthewevans enabled auto-merge August 11, 2026 21:04
@matthewevans

Copy link
Copy Markdown
Member

Current head 8e218b7cac28fb4410267ca65ac75d90a4ed05ce remains approved with auto-merge enabled. The only red CI result failed while GitHub's mozilla-actions/sccache-action initialized (self-signed certificate / missing executable), before the shard reached cargo test; it is not a test failure from this PR. I have retried the failed CI jobs. Once that retry settles, the normal merge queue will resume automatically; no contributor action is needed unless the retry reports a code-level failure.

@matthewevans
matthewevans added this pull request to the merge queue Aug 11, 2026
Merged via the queue into phase-rs:main with commit eae73f2 Aug 11, 2026
25 of 27 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 12, 2026
4 tasks
@traemyn
traemyn deleted the card/emperor-of-bones branch August 14, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Add tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants