Skip to content

parser: harden possessive participle classifier (#808 followup) - #904

Merged
matthewevans merged 2 commits into
phase-rs:mainfrom
MichaelMillsOfficial:card/yuriko-followup
May 23, 2026
Merged

parser: harden possessive participle classifier (#808 followup)#904
matthewevans merged 2 commits into
phase-rs:mainfrom
MichaelMillsOfficial:card/yuriko-followup

Conversation

@MichaelMillsOfficial

Copy link
Copy Markdown
Contributor

Follow-up to #808 (Yuriko, the Tiger's Shadow). Addresses Gemini review feedback on `parse_possessive_participle` / `parse_possessive_object_type` in `oracle_quantity.rs`.

Changes

1. Decompose the object-type combinator

Replace the verbatim 9-string `alt(tag(...))` with `opt(parse_supertype_prefix) + alt(singular_type_words ∪ token)`. Reuses `oracle_nom::target::parse_supertype_prefix` (CR 205.4a) so composed forms like `"the sacrificed legendary creature's power"` parse via the supertype × type axis instead of the cartesian enumeration. Adds the `token` referent (CR 109.1 / CR 110.5) which is not a CR 205 card type but anchors real possessive references.

2. Extend the participle list

Add `milled` (Court of Cunning, Patchwork Automaton, Demilich class) and `discovered` (LCI Discover mechanic). These are the two missing participle-possessive cost / trigger-condition referents Gemini called out.

3. Lock the word-boundary invariant with regression tests

The determiner gate (`"that "` / `"the "`) in `classify_possessive_referent`, combined with `all_consuming((participle, tag(" "), object_type))`, already guarantees that player-possessives (`"an opponent's ..."`) cannot match the participle branch. New tests pin both halves of the contract — positive composition tests for the new participles + supertype + token cases, and negative tests for `"an opponent's"` and plural `creatures'` prefixes.

Sample card texts now covered

  • `"the milled card's mana value"` → `ObjectManaValue { CostPaidObject }`
  • `"the discovered card's mana value"` → same
  • `"the sacrificed legendary creature's power"` → `Power { CostPaidObject }` (via supertype composition)
  • `"the sacrificed token's power"` → same
  • Negative: `"an opponent's life total"`, `"the sacrificed creatures' power"` → `None`

Verification

  • `cargo fmt --all`: clean
  • `cargo clippy --all-targets -- -D warnings`: clean
  • `cargo test -p engine --lib parser::oracle_quantity`: 112/112 pass
  • `./scripts/gen-card-data.sh`: success
  • `cargo coverage`: 85.33% (29670 / 34770), unchanged

🤖 Generated with Claude Code

@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!

@github-actions github-actions Bot added the ai-contribution PR opened via docs/AI-CONTRIBUTOR.md flow label May 23, 2026
…rs#808)

Three targeted fixes against `parse_possessive_participle` /
`parse_possessive_object_type` in `oracle_quantity.rs`:

1. Decompose the object-type combinator. Replace the verbatim 9-string
   `alt(tag(...))` with `opt(parse_supertype_prefix) +
   alt(singular_type_words ∪ token)`. Reuses
   `oracle_nom::target::parse_supertype_prefix` (CR 205.4a) so composed
   forms like `"the sacrificed legendary creature's power"` parse via
   the supertype × type axis instead of the cartesian enumeration. Adds
   the `token` referent (CR 109.1 / CR 110.5) which is not a CR 205
   card type but anchors real possessive references.

2. Extend the participle list. Add `milled` (Court of Cunning,
   Patchwork Automaton, Demilich class) and `discovered` (LCI Discover
   mechanic). These are the two missing participle-possessive cost /
   trigger-condition referents Gemini called out.

3. Lock the word-boundary invariant with regression tests. The
   determiner gate (`"that "` / `"the "`) in
   `classify_possessive_referent`, combined with
   `all_consuming((participle, tag(" "), object_type))`, already
   guarantees that player-possessives (`"an opponent's ..."`) cannot
   match the participle branch. New tests pin both halves of the
   contract — positive composition tests for the new participles +
   supertype + token cases, and negative tests for `"an opponent's"`
   and plural `creatures'` prefixes.

8 new tests in `parser::oracle_quantity::tests`. All 112 module tests
pass; `cargo clippy --all-targets -- -D warnings` clean; coverage
holds at 85.33% (29670 / 34770).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-contribution PR opened via docs/AI-CONTRIBUTOR.md flow status:ready-to-merge Maintainer-reviewed and ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants