Skip to content

refactor(parser): emit temporal delayed triggers as native ir - #6807

Closed
matthewevans wants to merge 4 commits into
mainfrom
ship/temporal-delayed-trigger-native-ir
Closed

refactor(parser): emit temporal delayed triggers as native ir#6807
matthewevans wants to merge 4 commits into
mainfrom
ship/temporal-delayed-trigger-native-ir

Conversation

@matthewevans

@matthewevans matthewevans commented Jul 30, 2026

Copy link
Copy Markdown
Member

Converts the narrow instant/sorcery temporal delayed-trigger route to emit native AbilityIr while preserving its four recognizer arms and the Pact payload’s separately lowered boxed definition.\n\nVerification: focused two-layer snapshots (Pact of Negation, Full Throttle, Galvanic Iteration), formatting and parser structural gates. Independent review approved. Strict clippy/full-pool parity deferred locally because the isolated test target consumed available disk; CI will provide that coverage.

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of spell-based temporal delayed triggers so they consistently flow through the parser’s IR path, preserving source text and ensuring delayed-trigger effects resolve correctly during lowering.
  • Tests

    • Expanded delayed-trigger spell coverage with updated cases, including a spell-only example that no longer produces IR/lowered snapshots.
    • Strengthened assertions to verify emitted delayed-trigger structure and, for applicable cases, payload effect details.
    • Adjusted an existing copy-next delayed-trigger test to use only the first sentence of the Oracle text.

@matthewevans
matthewevans enabled auto-merge July 30, 2026 06:59
@coderabbitai

coderabbitai Bot commented Jul 30, 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: 0ffcc211-9040-48e8-887a-24cde672e990

📥 Commits

Reviewing files that changed from the base of the PR and between e1c6890 and 6117828.

📒 Files selected for processing (1)
  • crates/engine/src/parser/oracle_effect/tests.rs

📝 Walkthrough

Walkthrough

Temporal delayed spell triggers now produce AbilityIr, use the IR-native emitter path, and defer lowering and slot stamping. Unit and snapshot coverage validates representative spell grammars and lowered effects.

Changes

Temporal delayed trigger routing

Layer / File(s) Summary
Native IR construction and emission
crates/engine/src/parser/oracle_effect/mod.rs, crates/engine/src/parser/oracle.rs
Temporal delayed trigger parsing returns AbilityIr, and spell dispatch emits it through ability_ir_at.
Parser and snapshot regression coverage
crates/engine/src/parser/oracle_effect/tests.rs, crates/engine/src/parser/oracle_ir/snapshot_tests.rs
Tests verify native IR construction, representative delayed-trigger grammars, lowered effects, conditional snapshots, and the Pact of Negation payload kind.

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

Sequence Diagram(s)

sequenceDiagram
  participant parse_oracle_ir
  participant try_parse_temporal_delayed_trigger_ability
  participant ability_ir_at
  participant lower_oracle_ir
  parse_oracle_ir->>try_parse_temporal_delayed_trigger_ability: parse temporal delayed trigger
  try_parse_temporal_delayed_trigger_ability-->>parse_oracle_ir: return AbilityIr
  parse_oracle_ir->>ability_ir_at: emit AbilityIr
  ability_ir_at->>lower_oracle_ir: lower during later IR phase
Loading

Possibly related PRs

  • phase-rs/phase#6708: Modifies the related IR-native spell emission and printed-slot stamping paths.
  • phase-rs/phase#6715: Routes another oracle parser ability path through AbilityIr and ability_ir_at.
  • phase-rs/phase#6806: Changes another ability parser path from lowered definitions to native AbilityIr emission.

Suggested labels: quality

Suggested reviewers: claytonlin1110, 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 summarizes the main change: emitting temporal delayed triggers as native IR in the parser.
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/temporal-delayed-trigger-native-ir

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/parser/oracle_ir/snapshot_tests.rs`:
- Around line 1001-1023: Expand the temporal recognizer fixture table to include
a distinct card case matching the `try_parse_whenever_this_turn` arm, while
retaining separate fixtures for the existing recognizers and adding any missing
fourth-arm coverage. Keep each fixture representative of a reusable temporal
pattern rather than a card-specific special case.
🪄 Autofix (Beta)

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: dc50c1cb-22b8-45c8-ae20-546fe9f2dcae

📥 Commits

Reviewing files that changed from the base of the PR and between 77e0a75 and 9ca1916.

⛔ Files ignored due to path filters (6)
  • crates/engine/src/parser/oracle_ir/snapshots/engine__parser__oracle_ir__snapshot_tests__temporal_delayed_trigger@full_throttle_temporal_ir.snap is excluded by !**/*.snap, !**/snapshots/**
  • crates/engine/src/parser/oracle_ir/snapshots/engine__parser__oracle_ir__snapshot_tests__temporal_delayed_trigger@full_throttle_temporal_lowered.snap is excluded by !**/*.snap, !**/snapshots/**
  • crates/engine/src/parser/oracle_ir/snapshots/engine__parser__oracle_ir__snapshot_tests__temporal_delayed_trigger@galvanic_iteration_temporal_ir.snap is excluded by !**/*.snap, !**/snapshots/**
  • crates/engine/src/parser/oracle_ir/snapshots/engine__parser__oracle_ir__snapshot_tests__temporal_delayed_trigger@galvanic_iteration_temporal_lowered.snap is excluded by !**/*.snap, !**/snapshots/**
  • crates/engine/src/parser/oracle_ir/snapshots/engine__parser__oracle_ir__snapshot_tests__temporal_delayed_trigger@pact_of_negation_temporal_ir.snap is excluded by !**/*.snap, !**/snapshots/**
  • crates/engine/src/parser/oracle_ir/snapshots/engine__parser__oracle_ir__snapshot_tests__temporal_delayed_trigger@pact_of_negation_temporal_lowered.snap is excluded by !**/*.snap, !**/snapshots/**
📒 Files selected for processing (3)
  • crates/engine/src/parser/oracle.rs
  • crates/engine/src/parser/oracle_effect/mod.rs
  • crates/engine/src/parser/oracle_ir/snapshot_tests.rs

Comment thread crates/engine/src/parser/oracle_ir/snapshot_tests.rs
@matthewevans
matthewevans added this pull request to the merge queue Jul 30, 2026
@github-actions

Copy link
Copy Markdown

Parse changes introduced by this PR

✓ No card-parse changes detected.

@matthewevans
matthewevans removed this pull request from the merge queue due to a manual request Jul 30, 2026
@matthewevans
matthewevans added this pull request to the merge queue Jul 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a manual request Jul 30, 2026
@matthewevans matthewevans reopened this Jul 30, 2026
@matthewevans
matthewevans enabled auto-merge July 30, 2026 07:22

@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

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/parser/oracle_ir/snapshot_tests.rs (1)

1064-1073: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Remove the card-name-specific assertion.

Add an expected payload-kind field to each fixture row and assert it generically. This avoids extending the test with additional card-name branches for future spell payload cases.

As per path instructions, tests must exercise reusable building blocks instead of one-card special cases.

🤖 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/parser/oracle_ir/snapshot_tests.rs` around lines 1064 -
1073, Replace the Pact of Negation-specific branch in the snapshot tests with an
expected payload-kind field on each fixture row, then assert the parsed
delayed-trigger effect’s kind against that field generically. Update all fixture
rows to provide the expected value and remove the card-name check and
unreachable branch.

Source: Path instructions

🧹 Nitpick comments (1)
crates/engine/src/parser/oracle_effect/tests.rs (1)

11135-11145: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the delayed-trigger payload, not only its outer variant.

This test would pass if parsing dropped the second sentence or produced the wrong trigger duration, event, or copy effect: source_text is copied from the original input by the upstream constructor, and matches! discards all CreateDelayedTrigger fields. Add payload-level assertions or a focused IR snapshot that proves the complete clause was parsed.

🤖 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/parser/oracle_effect/tests.rs` around lines 11135 - 11145,
Strengthen the test for try_parse_temporal_delayed_trigger_ability by inspecting
the fields inside Effect::CreateDelayedTrigger rather than only matching its
outer variant. Assert the complete delayed-trigger payload, including its
duration, triggering event, and copy effect, so both sentences and the intended
behavior are verified; retain the existing source_text and clause-count
assertions.
🤖 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/parser/oracle_ir/snapshot_tests.rs`:
- Around line 1001-1010: Strengthen the `Glimpse of Nature` case in the `cases`
fixture within the snapshot test by either supplying expected IR and lowered
snapshot values or explicitly asserting its `Whenever … this turn` condition and
draw-card payload. Ensure the test exercises the fourth recognizer arm’s
semantic parsing and lowering, not only the generic `CreateDelayedTrigger`
shape.

---

Outside diff comments:
In `@crates/engine/src/parser/oracle_ir/snapshot_tests.rs`:
- Around line 1064-1073: Replace the Pact of Negation-specific branch in the
snapshot tests with an expected payload-kind field on each fixture row, then
assert the parsed delayed-trigger effect’s kind against that field generically.
Update all fixture rows to provide the expected value and remove the card-name
check and unreachable branch.

---

Nitpick comments:
In `@crates/engine/src/parser/oracle_effect/tests.rs`:
- Around line 11135-11145: Strengthen the test for
try_parse_temporal_delayed_trigger_ability by inspecting the fields inside
Effect::CreateDelayedTrigger rather than only matching its outer variant. Assert
the complete delayed-trigger payload, including its duration, triggering event,
and copy effect, so both sentences and the intended behavior are verified;
retain the existing source_text and clause-count assertions.
🪄 Autofix (Beta)

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: 2164a2b1-93eb-448c-8e2c-41737c22d9f0

📥 Commits

Reviewing files that changed from the base of the PR and between 9ca1916 and e1c6890.

📒 Files selected for processing (2)
  • crates/engine/src/parser/oracle_effect/tests.rs
  • crates/engine/src/parser/oracle_ir/snapshot_tests.rs

Comment on lines +1001 to +1010
// The three established grammar representatives remain the stable IR/lowered
// snapshot fixtures. The direct `Whenever … this turn` arm uses the same
// structural assertions without a fourth snapshot pair.
let cases = [
(
None,
"Whenever you cast a creature spell this turn, draw a card.",
"Glimpse of Nature",
&["Sorcery"][..],
),

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

Verify the fourth recognizer arm semantically.

The Glimpse of Nature case uses None for snapshots and therefore only reaches the generic CreateDelayedTrigger shape checks. A regression in its condition, draw payload, lowering, or arm dispatch could still pass. Add a two-layer snapshot pair or assert the expected condition and payload explicitly.

As per path instructions, test the reusable parser building block across its parameter range rather than leaving one recognizer arm with only a generic wrapper check.

🤖 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/parser/oracle_ir/snapshot_tests.rs` around lines 1001 -
1010, Strengthen the `Glimpse of Nature` case in the `cases` fixture within the
snapshot test by either supplying expected IR and lowered snapshot values or
explicitly asserting its `Whenever … this turn` condition and draw-card payload.
Ensure the test exercises the fourth recognizer arm’s semantic parsing and
lowering, not only the generic `CreateDelayedTrigger` shape.

Source: Path instructions

auto-merge was automatically disabled July 30, 2026 07:40

Pull request was closed

@matthewevans matthewevans reopened this Jul 30, 2026
@matthewevans
matthewevans enabled auto-merge July 30, 2026 07:40
auto-merge was automatically disabled July 30, 2026 07:41

Pull request was closed

@matthewevans matthewevans reopened this Jul 30, 2026
@matthewevans
matthewevans enabled auto-merge July 30, 2026 07:42
auto-merge was automatically disabled July 30, 2026 07:42

Pull request was closed

@matthewevans
matthewevans deleted the ship/temporal-delayed-trigger-native-ir branch July 30, 2026 08:19
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