Fix killing-blow damage loss, Continue stranding, and loss-combat discard #246
No reviewers
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!246
Loading…
Reference in a new issue
No description provided.
Delete branch "claude/amazing-wing-eefa07"
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?
Summary
Three attribution-loss bugs diagnosed from a live Necrobinder run where Death March showed almost no tracked damage, plus hardening from an 8-angle adversarial review of the diff.
1. Killing-blow damage suppression (game-side gap, biggest cause). The game never emits
DamageReceivedEntryfor a hit that kills the last living enemy: decompiledCreatureCmd.Damageapplies HP loss before itsIsInProgress && !IsEndingemission gate, andIsEndingflips true the moment no primary enemy lives. In the diagnosed run, 5/5 combat-ending Death March kills hadcard_playedbut no damage event, while every mid-combat hit recorded fine — scaling finishers systematically lose their biggest hits. NewHookAfterDamageGivenPatchcaptures the suppressed results viaHook.AfterDamageGiven(which the game explicitly guarantees "must still resolve" for the killing hit), deduped byDamageResultreference against organically observed entries, and routed through the normalObservepipeline without touching the game's own history.2. Run stranding on Continue. Every main-menu Continue re-fires
RunStartedwith the same_startTime;OnRunStartedminted a freshRunDataeach time, stranding all committed stats in orphaned files (the diagnosed run split across six). It now resumes the tracked run in memory, or adopts the newest in-progress on-disk record after a game restart, via a sharedAdoptRunLocked— with pending rank-restore queues so identity binds correctly whether the deck repopulates before or afterRunStarted, and pruning of the ghost aggregates minted by pre-RunStartedCardEnterDeckPatchstamps.3. Loss-combat discard. On a loss,
RunManager.OnEndedfires synchronously from the killing action and the fatal combat'sCombatEndedfires only afterwards — afterOnRunEndedhad already nulled the buffer. Losses now promote the fatal combat's pending stats (abandon still discards; wins already promote viaCombatEnded).Review hardening (8 finder angles + verification): fixed a pre-existing relic
Activationsdouble-count (merge consolidated intoMergeRelicAggregateInto— every relic's activations were doubled at promotion); ghost-emptiness compares structurally against a bare arrival stamp instead of a hand-kept field list;CaptureInstanceNumbersByDeckRankincludes still-queued rank restores so a save during adoption can't orphan stats; resume paths filter to in-progress records at header-scan level (no game-over-screen resurrection); suppressed-damage capture stops once the run record is gone (no junk-file minting in the post-death window);FindByGameStartTimebounds its scan instead of JSON-parsing the whole runs directory on every run start.Runtime facts (suppression gate,
Hook.AfterDamageGivenreliability, Continue re-fire semantics, loss ordering) recorded indocs/sts2-runtime-primer.mdandAGENTS.mdper the primer's maintenance contract.Test plan
dotnet test Tests/SpireLens.Core.Tests— 237/237 pass (14 new: killing-blow dedup contract, ghost-aggregate pruning boundaries, pending-combat promotion merge incl. the Activations regression).🤖 Generated with Claude Code
Superseded by #267, which consolidates this and the rest of the audit work onto current main (these branches all conflicted after #247 landed). Closing in favor of the single mergeable PR.
Pull request closed