Skip to content

fix(parser): parse repeated named control clauses#5114

Merged
matthewevans merged 8 commits into
phase-rs:mainfrom
ntindle:codex/root30-control-named-clauses
Jul 8, 2026
Merged

fix(parser): parse repeated named control clauses#5114
matthewevans merged 8 commits into
phase-rs:mainfrom
ntindle:codex/root30-control-named-clauses

Conversation

@ntindle

@ntindle ntindle commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Extend the you control ... named ... condition parser so repeated typed named clauses keep their own type/name pairs.
  • Preserve the existing shared-type named-pair path for cards like the Empires cycle.
  • Remove the fixed High Marshal Arguel and Liu Bei entries from the parser misparse backlog root chore: update coverage stats and badges #30.

Root cause

parse_control_named_pair handled you control artifacts named A and B by sharing one parsed type across both names. That same path over-consumed repeated typed clauses:

  • High Marshal Arguel parsed the second condition as Enchantment named "a land named temple of aclazotz".
  • Liu Bei parsed both repeated named permanents as one Named string.

Parse audit

Focused before/after export for root #30 changed exactly these cards:

  • high marshal arguel
  • liu bei, lord of shu

Raw JSON deltas are intentional:

  • High Marshal Arguel: second condition is now Land named "temple of aclazotz" instead of Enchantment named "a land named temple of aclazotz".
  • Liu Bei, Lord of Shu: condition is now Or(IsPresent permanent named Guan Yu, IsPresent permanent named Zhang Fei) instead of one overrun Named value.

coverage-parse-diff on the same focused exports reported no card-parse changes detected.

Review cleanup

Addressed current Gemini review comments in 9b89e5533:

  • Added guarded terminators for common comma-led effect verbs/pronouns so named-card parsing stops before the effect clause.
  • Added verified CR annotations for the named-control helpers (CR 201.2, CR 603.4).
  • Added a regression test covering the new effect-lead terminator family.

Verification

  • cargo fmt --all
  • ./scripts/check-parser-combinators.sh
  • cargo test -p engine --features cli --lib control_named -- --nocapture
  • cargo test -p engine --features cli --lib repeated_typed_named_pair -- --nocapture
  • cargo clippy -p engine --all-targets -- -D warnings
  • focused oracle-gen before/after export for root chore: update coverage stats and badges #30
  • coverage-parse-diff /tmp/phase-root30-search-named-or-before.json /tmp/phase-root30-control-named-after.json
  • review cleanup rerun: cargo fmt --all, ./scripts/check-parser-combinators.sh, cargo test -p engine --features cli --lib control_named -- --nocapture, cargo test -p engine --features cli --lib repeated_typed_named_pair -- --nocapture, cargo clippy -p engine --all-targets -- -D warnings, git diff --check

Note: full workspace cargo clippy --all-targets -- -D warnings is blocked on this host by missing pkg-config/OpenSSL for non-engine targets; the engine crate clippy gate passed.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request enhances the condition parser in crates/engine/src/parser/oracle_nom/condition.rs to support disjunctions in 'you control [type] named [Name1] or a [type] named [Name2]' phrases, resolving backlog issues for cards like High Marshal Arguel and Liu Bei. The feedback suggests expanding the list of condition terminators in parse_control_named_condition_terminator to prevent name parser overruns, and adding mandatory CR annotations to the new rules-touching helper functions per Rule R6.

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.

Comment thread crates/engine/src/parser/oracle_nom/condition.rs
Comment thread crates/engine/src/parser/oracle_nom/condition.rs
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

Parse changes introduced by this PR

✓ No card-parse changes detected.

@ntindle ntindle marked this pull request as ready for review July 5, 2026 00:56
@ntindle ntindle requested a review from matthewevans as a code owner July 5, 2026 00:56
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

…named-clauses

# Conflicts:
#	docs/parser-misparse-backlog.md
@matthewevans matthewevans self-assigned this Jul 5, 2026
@matthewevans matthewevans added the bug Bug fix label Jul 5, 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.

Thanks for the update. I found three remaining parser/scope blockers:

[MED] Comma-led add effects now overrun into the second named card. Evidence: crates/engine/src/parser/oracle_nom/condition.rs:745 terminator list lacks add , while Tower Worker has If you control creatures named Mine Worker and Power Plant Worker, add {C}{C}{C} instead. Why it matters: the new guarded comma boundary regresses a printed shared-type named-control clause that the old comma stop would have split. Suggested fix: terminate on , add and add a discriminating Tower Worker-style parser test.

[MED] The named-control parser still materializes exactly two named predicates, so three-name lists collapse names. Evidence: crates/engine/src/parser/oracle_nom/condition.rs:692 returns only (first, second); Helm of Kaldra has Equipment named Helm of Kaldra, Sword of Kaldra, and Shield of Kaldra. Why it matters: the touched seam handles the class as a pair parser, leaving a same-class printed clause misparsed. Suggested fix: parse a named-member list into N predicates, preserving shared-type and repeated-typed members.

[MED] The sticky parse-diff contains an unexplained out-of-scope parser change. Evidence: the coverage-parse-diff sticky reports Say Its Name added cost/two other cards named Say Its Name from your graveyard, while the PR body claims only High Marshal Arguel and Liu Bei changed. Why it matters: parser PRs need the card-level diff reconciled; unexplained gained/changed signatures are possible blast radius. Suggested fix: reconcile the full sticky diff by explaining/regenerating the baseline or eliminating the unrelated Say Its Name change.

@matthewevans matthewevans removed their assignment Jul 5, 2026
@ntindle

ntindle commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

Updated against latest origin/main and pushed 4c9667c. Addressed review feedback by adding the comma/add terminator path, generalizing named-control lowering from two names to N named members, preserving the repeated-typed member path, and adding Tower Worker plus Helm of Kaldra regressions. I also narrowed the broad CR comments to verified CR 201.2 where the parser is only grounding card names. Verification: cargo fmt --all; git diff --check; WSL cargo test -p engine --lib control_named; WSL cargo test -p engine --lib shared_type_named_serial_list; WSL cargo test -p engine --lib repeated_typed_named. Current branch diff is condition.rs plus the upstream backlog merge cleanup, so the older Say Its Name parse-diff note does not correspond to a current code/data delta in this PR.

@ntindle

ntindle commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

Follow-up: origin/main advanced with #5116 after my review-fix push, so I merged latest main into this PR and pushed 6889b89. Post-merge verification: cargo fmt --all; git diff --check; WSL cargo test -p engine --lib control_named; WSL cargo test -p engine --lib shared_type_named_serial_list; WSL cargo test -p engine --lib repeated_typed_named.

# Conflicts:
#	crates/engine/src/parser/oracle_nom/condition.rs
@ntindle

ntindle commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

Updated this branch onto current main (c10be1fb2) and resolved the named-control parser conflict by keeping this PR's generalized named-control implementation while taking the upstream compound activation-condition changes.

Verified:

  • cargo fmt --all
  • git diff --check
  • cargo test -p engine --lib control_named
  • cargo test -p engine --lib shared_type_named_serial_list
  • cargo test -p engine --lib repeated_typed_named
  • cargo test -p engine --lib parses_compound_or_if_restriction_fragments
  • cargo test -p engine --lib parses_compound_source_zone_shorthand

@matthewevans matthewevans self-assigned this Jul 8, 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.

Maintainer review: prior parser blockers are resolved on this head. Parse-diff is scoped to High Marshal Arguel and Liu Bei; shared-type N-name lists, repeated typed named clauses, and comma-led add effects are covered by parser regressions.

@matthewevans matthewevans enabled auto-merge July 8, 2026 09:03
@matthewevans matthewevans removed their assignment Jul 8, 2026
@matthewevans matthewevans added this pull request to the merge queue Jul 8, 2026
Merged via the queue into phase-rs:main with commit 2ce868c Jul 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants