Skip to content

Extend SearchFound with bound exile-play permissions#6059

Merged
matthewevans merged 15 commits into
phase-rs:mainfrom
parthmishra:codex/opposition-agent-found-card-permission
Jul 17, 2026
Merged

Extend SearchFound with bound exile-play permissions#6059
matthewevans merged 15 commits into
phase-rs:mainfrom
parthmishra:codex/opposition-agent-found-card-permission

Conversation

@parthmishra

Copy link
Copy Markdown
Contributor

Summary

Extends the engine-owned SearchFound pipeline with the next two reusable Opposition Agent prerequisites:

  • binds searched-library ownership after CantSearchLibrary filtering and carries it through standard/scoped choices, serialized batches, and every found-card event;
  • binds an exact ChangeZone-to-exile plus GrantCastingPermission replacement chain, then installs the snapshotted play/AnyColor permission only after the card actually reaches exile.

This is intentionally an engine-authority slice, not a full card-support claim. Search-scoped player control and parser/card-data integration remain separate follow-up work.

Context:

Files changed

  • crates/engine/src/types/proposed_event.rs
  • crates/engine/src/types/game_state.rs
  • crates/engine/src/game/effects/search_library.rs
  • crates/engine/src/game/effects/scoped_library_search.rs
  • crates/engine/src/game/engine_resolution_choices.rs
  • crates/engine/src/game/replacement.rs
  • crates/engine/src/game/visibility.rs
  • crates/engine/src/game/elimination.rs
  • crates/engine/src/game/effects/mod.rs
  • crates/engine/src/ai_support/candidates.rs
  • crates/engine/src/ai_support/mod.rs
  • crates/phase-ai/src/search.rs

CR references

  • CR 701.23a — searching and found-card provenance
  • CR 614.6 — replacement-selected modified event delivery
  • CR 616.1 — frozen replacement ordering and resume authority
  • CR 611.2b — lasting play permission created by a resolving effect
  • CR 609.4b — exact AnyColor payment concession
  • CR 601.3 — effect-provided spell-casting permission
  • CR 400.7 — exact source incarnation and zone-change identity

Implementation method (required)

Method: /engine-implementer

Track

Developer

LLM

Model: codex-5
Thinking: high
Tier: Standard

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

  • cargo check -p engine --tests — pass

  • cargo test -p engine search_found --lib — 18 passed

  • cargo test -p engine library_provenance --lib — 4 passed

  • cargo clippy -p engine --tests -- -D warnings — pass

  • repository pre-push hook — pass: workspace clippy, release card-data validation, parser gate, 584 parser tests, 1,281 phase-ai tests, Oracle generation, card-data validation, coverage regression check (0 engine regressions), frontend lint (0 errors), and frontend type-check

Gate A

Gate A PASS head=58dc89f96e6b481731bb3c4ca361565d7b2d3542 base=cea140e85006c3452731f8ca03fdd59149598e94

Anchored on

  • crates/engine/src/game/replacement.rs:4040 — existing frozen SearchFound candidate snapshot authority for CR 616 resumes.
  • crates/engine/src/game/zone_pipeline.rs:932 — existing typed deferred-completion seam for paused zone deliveries.
  • crates/engine/src/game/effects/grant_permission.rs:29 — canonical resolver that stamps and installs casting-permission authority.

Final review-impl

Final review-impl PASS head=58dc89f96e6b481731bb3c4ca361565d7b2d3542

Claimed parse impact

None.

Validation Failures

None.

CI Failures

None.

@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 updates the MTG game engine to correctly track and propagate library ownership during searches, ensuring compliance with CR 701.23a, and implements CR 611.2b and CR 601.3 to grant casting permissions only after a card is successfully delivered to exile. These changes are supported by comprehensive unit tests covering various mixed-zone and muzzled search scenarios. The review feedback identifies a violation of style guide rule R6, noting a missing mandatory CR annotation on a rules-touching line of engine code in crates/engine/src/game/replacement.rs.

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.

}

let canonical_shell = AbilityDefinition::new(execute.kind, execute.effect.as_ref().clone());
let grant = match execute.sub_ability.as_deref() {

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.

medium

[MEDIUM] Missing mandatory CR annotation. Evidence: crates/engine/src/game/replacement.rs:3940. Why it matters: Under rule R6 of the repository style guide, every rules-touching line of engine code must carry a comment of the form CR <number>: <description>. Suggested fix: Add a CR annotation such as // CR 611.2b: Bind the lasting casting permission from the resolving SearchFound replacement effect.

Suggested change
let grant = match execute.sub_ability.as_deref() {
// CR 611.2b: Bind the lasting casting permission from the resolving SearchFound replacement effect.
let grant = match execute.sub_ability.as_deref() {
References
  1. Every rules-touching line of engine code must carry a comment of the form CR : (regex CR \d{3}(.\d+[a-z]?)?). (link)

@matthewevans matthewevans self-assigned this Jul 17, 2026
Resolve maintainer-caused conflict from phase-rs#6057 while preserving the serialized SearchFound grant payload and its post-delivery permission installation.\n\nCo-authored-by: parthmishra <parthmishra@users.noreply.github.com>
@matthewevans matthewevans added the enhancement New feature or request label Jul 17, 2026
@matthewevans matthewevans removed their assignment Jul 17, 2026
@github-actions

Copy link
Copy Markdown

Parse changes introduced by this PR

✓ No card-parse changes detected.

@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 — maintainer port preserves both contracts.

The current head retains the contributor's post-delivery permission grant and the batch-move completion contract introduced by main. The deferred-delivery regression reaches the relevant continuation boundary, and the current CI and no-change parse artifact are clean.

@matthewevans
matthewevans added this pull request to the merge queue Jul 17, 2026
Merged via the queue into phase-rs:main with commit cce8169 Jul 17, 2026
17 checks passed
@parthmishra
parthmishra deleted the codex/opposition-agent-found-card-permission branch July 18, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants