fix(parser): parse external entry tap-state grammar - #6853
Conversation
…external entry
Vigorous Farming ("Lands you control enter the battlefield untapped.")
fell through to Unimplemented for the same reason Frozen Aether did before
the previous fix: CR 614.1c external-entry replacement effects are
templated by WotC in both a short form ("enter untapped") and the
fully-spelled long form ("enter the battlefield untapped"), and only the
short form was recognized.
Mirrors the tapped-side fix in the same two gates:
- `oracle_classifier::is_replacement_pattern` — added the long-form
untapped suffix alongside the existing short-form and tapped-long-form
checks.
- `oracle_replacement::parse_external_entry_suffix` — added long-form
"enter(s) the battlefield untapped" arms alongside the existing
short-form and tapped-long-form arms.
Added parser tests for both the real card (Vigorous Farming, single-type
subject) and the controller-scoped Or-filter subject shape.
clippy -D warnings clean; full engine test green (14714 lib + 1721
integration, 0 failures).
Model: claude-sonnet-5 (Claude Code)
📝 WalkthroughWalkthroughThe parser now supports long-form singular and plural untapped battlefield-entry text through one grammar helper. Parser tests and a Vigorous Farming integration test validate classification, replacement ordering, and the final untapped land entry. ChangesExternal-entry replacement parsing
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant OracleClassifier
participant ExternalEntryParser
participant ReplacementPipeline
participant ReplacementChoice
OracleClassifier->>ExternalEntryParser: parse untapped battlefield-entry text
ExternalEntryParser->>ReplacementPipeline: produce replacement definition
ReplacementPipeline->>ReplacementChoice: present replacement ordering
ReplacementChoice-->>ReplacementPipeline: apply self-tap replacement first
ReplacementPipeline-->>ReplacementChoice: land enters untapped
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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_classifier.rs`:
- Around line 736-737: Update is_replacement_pattern to return false before
scanning the long-form patterns when has_trigger_prefix(lower) is true,
preventing triggered abilities from matching these replacement phrases. Add
regression coverage for both “enter” and “enters” forms while preserving
replacement classification for non-triggered text.
🪄 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: b1be679d-2218-4133-956c-84117048aba6
📒 Files selected for processing (5)
crates/engine/src/parser/oracle_classifier.rscrates/engine/src/parser/oracle_replacement.rscrates/engine/src/parser/oracle_tests.rscrates/engine/tests/integration/issue_4991_vigorous_farming.rscrates/engine/tests/integration/main.rs
| "enter the battlefield untapped", | ||
| "enters the battlefield untapped", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Exclude triggered abilities from the new long-form classifier patterns.
is_replacement_pattern returns true for Whenever a land enters the battlefield untapped, .... The external-entry suffix parser requires end-of-input, so it cannot parse the trigger body after the comma. The classifier can send this triggered ability to replacement parsing instead of trigger parsing.
If has_trigger_prefix(lower) is true for either long-form phrase, return false before this pattern scan. Add regression coverage for both enter and enters forms.
🤖 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_classifier.rs` around lines 736 - 737, Update
is_replacement_pattern to return false before scanning the long-form patterns
when has_trigger_prefix(lower) is true, preventing triggered abilities from
matching these replacement phrases. Add regression coverage for both “enter” and
“enters” forms while preserving replacement classification for non-triggered
text.
Parse changes introduced by this PR · 1 card(s), 2 signature(s) (baseline: main
|
Rescues closed contributor PR #4991 for Vigorous Farming.
Parses the general external-entry tap-state grammar through the replacement pipeline and adds parser plus runtime coverage. Rebased onto current main and hardened after maintainer review.
Summary by CodeRabbit
Bug Fixes
Tests