[P1] Scope all player-keyed recording to the local player in co-op (zero LocalContext usage today) #260

Closed
opened 2026-07-03 09:33:38 -07:00 by nelsong6 · 2 comments
nelsong6 commented 2026-07-03 09:33:38 -07:00 (Migrated from github.com)

Priority: P1. Promoted from #257's P2 "decision needed" bullet — the uncapped audit pass (2026-07-02) confirmed these as HIGH stat-corruption in a supported mode (co-op), not hygiene.

Problem

Verified: grep LocalContext over Core/ returns zero SpireLens uses of IsMe / IsMine / GetMe. In co-op the local machine simulates all players, so partner events fold into the local run file every combat.

Confirmed sites:

  • CardEnterDeckPatch.cs:41 mints aggregates for partner deck cards, while CaptureInstanceNumbersByDeckRank snapshots only Players.FirstOrDefault() (#61, HIGH).
  • RedMaskBeforeSideTurnStartPatch.cs:34, BagOfMarblesBeforeSideTurnStartPatch, OstyCmdSummonPatch record partner relic/summon activations into local RelicAggregates/MetaStats (#71, HIGH).
  • TheAbacusAfterShufflePatch.cs:26 arms on a partner shuffle (#53).
  • The player block ledger and _pendingPlayerBlockClear are singletons fed by every IsPlayer creature, so ReconcilePlayerBlockLedgerLocked (RunTracker.cs:5278/5304) compares one player's Block against the summed total — garbaging block stats in any MP combat (#43, #32, HIGH).

Decision (pick one, apply uniformly)

  1. Scope to local player: establish RunTracker.TrackedPlayer at OnRunStarted via LocalContext.GetMe(runState) ?? Players.FirstOrDefault(), and gate every IsPlayer / Type==Deck / relic-model entry point on it.
  2. Kill-switch: disable tracking when Players.Count > 1 and document MP as out of scope.

Single-player is unchanged either way. The current implicit single-player assumption cannot be fixed piecemeal — the leak re-enters at the next unguarded entry point — so decide once and encode it as a reviewable convention.

**Priority: P1.** Promoted from #257's P2 "decision needed" bullet — the uncapped audit pass (2026-07-02) confirmed these as **HIGH** stat-corruption in a supported mode (co-op), not hygiene. ## Problem **Verified:** `grep LocalContext` over `Core/` returns **zero** SpireLens uses of `IsMe` / `IsMine` / `GetMe`. In co-op the local machine simulates all players, so partner events fold into the local run file every combat. Confirmed sites: - `CardEnterDeckPatch.cs:41` mints aggregates for **partner** deck cards, while `CaptureInstanceNumbersByDeckRank` snapshots only `Players.FirstOrDefault()` (#61, HIGH). - `RedMaskBeforeSideTurnStartPatch.cs:34`, `BagOfMarblesBeforeSideTurnStartPatch`, `OstyCmdSummonPatch` record partner relic/summon activations into local `RelicAggregates`/`MetaStats` (#71, HIGH). - `TheAbacusAfterShufflePatch.cs:26` arms on a **partner** shuffle (#53). - The player block ledger and `_pendingPlayerBlockClear` are singletons fed by every `IsPlayer` creature, so `ReconcilePlayerBlockLedgerLocked` (`RunTracker.cs:5278/5304`) compares one player's `Block` against the summed total — garbaging block stats in any MP combat (#43, #32, HIGH). ## Decision (pick one, apply uniformly) 1. **Scope to local player:** establish `RunTracker.TrackedPlayer` at `OnRunStarted` via `LocalContext.GetMe(runState) ?? Players.FirstOrDefault()`, and gate every `IsPlayer` / `Type==Deck` / relic-model entry point on it. 2. **Kill-switch:** disable tracking when `Players.Count > 1` and document MP as out of scope. Single-player is unchanged either way. The current implicit single-player assumption cannot be fixed piecemeal — the leak re-enters at the next unguarded entry point — so decide once and encode it as a reviewable convention.
nelsong6 commented 2026-07-03 11:15:59 -07:00 (Migrated from github.com)

Implemented in #268: co-op now tracks the LOCAL player's stats (not a kill-switch). Resolves the tracked NetId from LocalContext.NetId (sole-player fallback) at run start + adopt; fail-open (null → allow all, so single-player is byte-identical). Player-keyed ingresses gated on ownership (card play, deck entry, enemy-damage-taken, block, energy dispatch, Red Mask / Bag of Marbles / The Abacus). Live-verified: 'TrackedPlayer resolved: net_id=1' on the running run. Remaining relic side-turn patches follow the identical IsTrackedRelic template; Osty-summon + poison-power co-op ownership are small follow-ups.

Implemented in #268: co-op now tracks the LOCAL player's stats (not a kill-switch). Resolves the tracked NetId from LocalContext.NetId (sole-player fallback) at run start + adopt; fail-open (null → allow all, so single-player is byte-identical). Player-keyed ingresses gated on ownership (card play, deck entry, enemy-damage-taken, block, energy dispatch, Red Mask / Bag of Marbles / The Abacus). Live-verified: 'TrackedPlayer resolved: net_id=1' on the running run. Remaining relic side-turn patches follow the identical IsTrackedRelic template; Osty-summon + poison-power co-op ownership are small follow-ups.
nelsong6 commented 2026-07-05 15:44:59 -07:00 (Migrated from github.com)

Closing during repository issue cleanup. If this becomes active work again, we can reopen or recreate it as a fresh, specific task.

Closing during repository issue cleanup. If this becomes active work again, we can reopen or recreate it as a fresh, specific task.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/spirelens#260
No description provided.