Skip to content

Fix Brainspoil - #7130

Merged
matthewevans merged 9 commits into
phase-rs:mainfrom
keloide:card/brainspoil
Aug 9, 2026
Merged

Fix Brainspoil#7130
matthewevans merged 9 commits into
phase-rs:mainfrom
keloide:card/brainspoil

Conversation

@keloide

@keloide keloide commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes Brainspoil's dropped that isn't enchanted target restriction. The parser now reuses the existing negated relative-clause grammar and target legality excludes Aura-enchanted creatures while preserving Equipment targets.

Files changed

  • crates/engine/src/parser/oracle_target.rs
  • crates/engine/tests/integration/brainspoil.rs
  • crates/engine/tests/integration/main.rs

Track

Developer

LLM

Model: gpt-5.6-sol
Tier: Frontier
Thinking: high

Implementation method (required)

Method: /engine-implementer

CR references

  • CR 303.4b
  • CR 301.5a

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 — PASS

  • git diff --check — PASS

  • ./scripts/check-parser-combinators.sh — PASS

  • Independent review-impl — PASS

  • Focused cargo test -p phase-engine --test integration brainspoil — CI-owned: local cargo process could not report completion in the constrained workspace.

  • cargo coverage / cargo semantic-audit — CI-owned: required generated card data could not be retained within available disk space.

Gate A

Gate A PASS head=324ac171418e7b1e8dde66743b3b71492660a3ec base=b42dcb14150f1bfff64e7ae87019360c59c0c1af

Anchored on

  • crates/engine/src/parser/oracle_target.rs:6775 — existing attachment-relative-clause parsing and attachment predicate construction.
  • crates/engine/src/parser/oracle_target.rs:7131 — existing negated relative-clause introducer consumption.

Final review-impl

Final review-impl PASS head=324ac171418e7b1e8dde66743b3b71492660a3ec

Claimed parse impact

Brainspoil.

Scope Expansion

None.

Validation Failures

None.

CI Failures

Local Developer-track card-data generation, coverage, and semantic audit could not run because bootstrap outputs exhausted the workspace disk. The focused engine test was launched but the local runner did not return its completion status.

Summary by CodeRabbit

  • Bug Fixes

    • Improved interpretation of negated relative clauses, including combined Aura-or-Equipment conditions.
    • Corrected targeting behavior so creatures enchanted by Auras are excluded while equipped creatures remain valid targets.
    • Ensured Brainspoil bypasses active regeneration shields as expected.
    • Preserved normal regeneration behavior for standard destruction effects.
  • Tests

    • Added coverage for Aura, Equipment, targeting, regeneration, and standard destruction scenarios.

@keloide
keloide requested a review from matthewevans as a code owner August 9, 2026 15:15
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The parser now recognizes negated relative attachment clauses and creates negated attachment predicates. Brainspoil integration tests cover Aura targeting exclusions, Equipment exceptions, and destruction behavior with regeneration shields.

Changes

Brainspoil targeting behavior

Layer / File(s) Summary
Parse negated attachment clauses
crates/engine/src/parser/oracle_target.rs
Relative-clause parsing detects negated introductions, updates consumed lengths, and wraps attachment predicates in FilterProp::Not. Tests cover Aura, Equipment, and combined attachment clauses.
Wire Brainspoil targeting tests
crates/engine/tests/integration/brainspoil.rs, crates/engine/tests/integration/main.rs
The integration suite defines Brainspoil scenarios and verifies legal targets for bare, equipped, Aura-enchanted, and unattached creatures.
Validate regeneration behavior
crates/engine/tests/integration/brainspoil.rs
Tests verify that Brainspoil destroys a shielded target, while ordinary destruction is prevented and consumes the regeneration shield.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant BrainspoilTest
  participant OracleTargetParser
  participant Engine
  participant Battlefield
  BrainspoilTest->>OracleTargetParser: parse negated attachment clause
  OracleTargetParser-->>BrainspoilTest: return negated target predicate
  BrainspoilTest->>Engine: resolve Brainspoil target
  Engine->>Battlefield: check attachments and regeneration shield
  Battlefield-->>Engine: return target state
  Engine-->>BrainspoilTest: apply destruction behavior
Loading

Suggested labels: bug

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 identifies the main change: fixing Brainspoil’s target restriction and related behavior.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 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/src/parser/oracle_target.rs`:
- Around line 14986-15035: Add full-consumption parser tests alongside
that_isnt_enchanted_negates_aura_attachment,
that_isnt_equipped_negates_equipment_attachment, and
that_isnt_enchanted_or_equipped_negates_attachment_disjunction for “that aren’t
enchanted”, “that aren’t equipped”, and “that aren’t enchanted or equipped”.
Assert the same negated attachment FilterProp structures and consumed lengths as
the singular cases, verifying plural subjects retain the restriction.

In `@crates/engine/tests/integration/brainspoil.rs`:
- Around line 84-109: Replace the direct build_target_slots-only assertions in
the Brainspoil legality test with production-pipeline scenarios that cast
Brainspoil through the scenario runner and target-selection flow. Add cases
confirming the equipped creature is accepted and each Aura-enchanted creature is
rejected, exercising apply/WaitingFor/GameAction/stack resolution as required
while preserving the existing bare and unattached-Aura coverage where
applicable.
🪄 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: f2c50352-0e21-4ab2-94da-b0d014c67ba9

📥 Commits

Reviewing files that changed from the base of the PR and between 4b69d83 and 324ac17.

📒 Files selected for processing (3)
  • crates/engine/src/parser/oracle_target.rs
  • crates/engine/tests/integration/brainspoil.rs
  • crates/engine/tests/integration/main.rs

Comment thread crates/engine/src/parser/oracle_target.rs
Comment thread crates/engine/tests/integration/brainspoil.rs Outdated
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

Generated for head 77c9fb34cc3dcb964e20fef152b05722e7a24c5c.

Parse changes introduced by this PR · 4 card(s), 3 signature(s) (baseline: main 227f6a3d520b)

🟡 Modified fields (3 signatures)

  • 2 cards · 🔄 ability/Destroy · changed field target: creaturenot attached by aura creature
    • Affected (first 3): Akoum, Brainspoil
  • 1 card · 🔄 ability/Bounce · changed field target: permanentnot attached by aura permanent
    • Affected (first 3): Time Elemental
  • 1 card · 🔄 ability/DestroyAll · changed field filter: creaturenot attached by aura creature
    • Affected (first 3): Winds of Rath

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

Blocking for current head b21be0f0629ee12722747d951175e2ab3d095797.

The required Rust test shard is red. Job 93266136511 fails the new regression brainspoil_cant_regenerate_rider_bypasses_a_real_regeneration_shield at crates/engine/tests/integration/brainspoil.rs:139: the asserted regeneration shield was not installed (13,284 passed, 1 failed; exit 100). Please fix, remove, or rework that regression so it establishes the actual shield state before asserting Brainspoil's rider behavior, then provide fresh exact-head green CI and a refreshed parse-diff artifact.

The current parse-diff sticky is for older head eda2f515…, and this branch is behind main; do not treat either older evidence or the prior review state as clearance.

@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/tests/integration/brainspoil.rs`:
- Around line 149-164: Update both precondition assertions in the Brainspoil
integration test to require each matching Regeneration shield to have
is_consumed set to false, in addition to matching ShieldKind::Regeneration.
Ensure the test setup exercises the failure path where a consumed shield would
otherwise allow Brainspoil to destroy the target.
🪄 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: f5df6b54-e7b6-4703-940b-4f06c8b3293f

📥 Commits

Reviewing files that changed from the base of the PR and between eda2f51 and 5f4b849.

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

Comment thread crates/engine/tests/integration/brainspoil.rs

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

Blocking for current head e2aed8f045b0a56614d18746aa3897866220e581.

The new tests still do not discriminate the production behavior completely:

  1. brainspoil.rs:105–130 calls build_target_slots directly, bypassing the production target-selection path (engine.rs:7843–7849). Exercise Brainspoil through that real selection/resolution pipeline so the test proves the target restriction is enforced where players/AI use it.
  2. The regeneration fixture at brainspoil.rs:154–169 does not require the shield to be unconsumed. Establish and assert a live !is_consumed regeneration shield before testing the rider, then retain the ordinary-destruction control that proves consumption.
  3. oracle_target.rs:14986–15035 lacks full-consumption tests for plural attachment clauses. Add parser coverage for the plural grammar, including that the complete clause is consumed and produces the intended negated attachment filter rather than falling through to a partial parse.

The prior requested-changes review predates this head. Required CI is still running and the parse-diff sticky is for 5f4b849…, so neither is approval evidence for this revision.

@matthewevans

Copy link
Copy Markdown
Member

Maintainer hold — current head cff6c4cfa559966d2874e8e42779d1fc2aeb174e.

Fresh review confirms the prior requested coverage fixes are clean and no substantive finding remains. Approval is waiting only on external evidence: Rust lint and both Rust test shards are still running, and the available coverage-parse-diff sticky is for older head d2fa3fc…, not this revision.

Next step: let the required checks complete successfully and refresh the parse-diff artifact for this exact head against current main; maintainer approval/enqueue can then resume. No author code change is requested at this time.

@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 for exact head 77c9fb34cc3dcb964e20fef152b05722e7a24c5c.

Fresh review found all prior coverage blockers resolved. The current parse-diff artifact matches this head and reports only the intended negated-Aura attachment-filter changes for Akoum, Brainspoil, Time Elemental, and Winds of Rath; all required hosted checks are green.

@matthewevans matthewevans added the bug Bug fix label Aug 9, 2026
@matthewevans
matthewevans added this pull request to the merge queue Aug 9, 2026
Merged via the queue into phase-rs:main with commit cbdfa04 Aug 9, 2026
13 checks passed
@keloide
keloide deleted the card/brainspoil branch August 9, 2026 22:38
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