[P0] Introduce an arbitrated AttributionWindow registry for relic/effect one-shot windows #250
Labels
No labels
4-29
bug
documentation
duplicate
enhancement
flow improvement
good first issue
help wanted
invalid
investigating
issue-agent
issue-agent-blocked
issue-agent-complete
issue-agent-pr-open
issue-agent-runner-nelsonlaptop
issue-agent-runner-nelsonpc
issue-agent-runner-nelsonpc-user
issue-agent-running
needs-verification
next to do
question
queue
recon
relics-stats-onboarding
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
romaine-life/spirelens#250
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Priority: P0. From the 2026-07-02 codebase audit. This is the single highest-leverage refactor — it retires an entire class of confirmed and likely double-attribution bugs.
Problem
~14 hand-rolled, independent, non-exclusive attribution flags feed the same game event to multiple consumers with no arbitration, so overlapping armed windows double- or mis-attribute.
HookAfterBlockGainedPatchfeeds one player block-gain event to Orichalcum / The Abacus / Bone Flute / Cloak Clasp recorders simultaneously.Confirmed instances (verified against decompiled game code):
PlayerGainEnergyPatch.cs:34+GremlinHornStatsPatch.cs:54;RunTracker.csRecordEnergyGained/RecordGremlinHornEnergyGained, draw path viaHook.ShouldDraw→NoteDrawAttempt).BeforeSideTurnEnduntilHook.AfterTurnEnd, absorbing every other block gain in the rest of the end-of-turn chain and falsely consuming Orichalcum's one-shot (RunTracker.cs:3112; decompiled CloakClasp grants block in oneGainBlockcall so the open window is unnecessary).Likely instances (internally consistent, verify against the decompile before fixing):
HappyFlowerAfterSideTurnStartPatch.cs:30).Build
An
AttributionWindow/WindowRegistryon the per-combat context:Arm(key, ownerId, exclusive, maxHistoryAdvance)/Disarm(key)/TryConsume(eventKind) -> window?_pendingRelicHeals/_pendingWhiteBeastPotionRewardswhich are never reset at run boundary).Port each existing one-shot onto it one at a time (Orichalcum, Abacus, Bone Flute, Cloak Clasp, Happy Flower, Gremlin Horn ×2, block-clear, poison-tick, Noxious Fumes, effect-source, recent-play), each pinned by its existing per-relic test. Make Orichalcum arm only when it will fire (read
_shouldTrigger) and Cloak Clasp arm only on its real hand-count condition, both consuming.Relates to: the STS2-compat issue (this rework removes the dependency on the now-removed
Hook.AfterTurnEnddisarm).Uncapped audit pass — additional confirmed overlaps to fold into the registry (each pinned by a coexistence test):
HookAfterBlockGainedPatchfan-out feeds the same block gain to 4 non-exclusive consumers (#142) — first-match-consumes.AfterSideTurnStartbut its cleanup patch targetsAfterPlayerTurnStart, which fires before it, so on 2 of 3 turns the flag eats an unrelated energy gain (#46, HIGH) — trigger-gate the arm, delete the wrong-boundary cleanup.Implemented (confirmed-buggy subset) in #268: new AttributionWindowRegistry (per-combat, FIFO, exclusive, lives on PendingCombat so it self-resets). Multiple windows per kind arbitrated FIFO at consume (Orichalcum+CloakClasp both fire legitimately in one turn). Ported block (Orichalcum/Anchor/Abacus/BoneFlute/CloakClasp), energy (HappyFlower/BoomingConch/GremlinHorn + card fallback), draw (GremlinHorn) via single dispatchers replacing the fan-out. Fixes the 4 confirmed double-attribution bugs. Arbitration core pinned by 9 unit tests. DEFERRED (non-buggy, kept as-is): Akabeko, Pendulum, Parrying Shield, Horn Cleat. Old per-relic Record methods left as dead code pending cleanup. NOT yet behaviorally verified in live combat (needs the 4 relic setups).
Closing during repository issue cleanup. If this becomes active work again, we can reopen or recreate it as a fresh, specific task.