[P1] PatchGuard convention + always-on Error logging so a broken hook can't silently kill tracking #261
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#261
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: P1. From the 2026-07-02 uncapped audit pass. Completes the open half of the patch-resilience work (per-class install isolation landed in PR #248; this is the exception-discipline convention).
Problem
RunHistoryUtilitiesCreateEntryPatch.Postfix(finding #70) is the only file underCore/Patches/with no try/catch. Its throw propagates intoRunManager.OnEnded, skippingDeleteCurrentRunat the worst moment.RunTrackerlifecycle handlers (OnRunStarted/OnRunEnded/OnCombatSetUp/OnCombatEnded) have no top-level guard — a tracker throw propagates into the game's run-history creation.e.MessageviaLogDebug— a no-op whenDebugLoggingis off — so a permanently-broken patch produces zero signal in normal play. (CombatHistoryAddPatch.cs:26(#63) relies solely onObserve's internal catch.)Fix
Immediate: wrap the 5 hot spots —
RunHistoryUtilitiesCreateEntryPatch.Postfixand the fourRunTrackerlifecycle handlers — in try/catch that logs the full exception at Error level (always-on).Systemic: introduce
PatchGuard.Run(site, action)with always-on rate-limited Error logging, and adopt the convention that every Harmony body and every game-event handler is exactly onePatchGuard.Runcall. Enforce with a source-scan test asserting the shape. This makes "a hook silently stopped working" visible instead of invisible-until-stats-look-wrong — the failure mode behind most of this audit.Findings: #143 (open half), #70, #63.
Partially addressed in #265: the terminal run-end funnel (RunHistoryUtilitiesCreateEntryPatch.Postfix, previously the only patch with no try/catch) and the three event-subscribed lifecycle handlers (OnRunStarted/OnCombatSetUp/OnCombatEnded) now run under an always-on Error-logging guard. Still open: the full PatchGuard.Run convention + source-scan test across all ~57 patches, and converting the ~53 LogDebug-only catches to always-on rate-limited Error logging.
Closing during repository issue cleanup. If this becomes active work again, we can reopen or recreate it as a fresh, specific task.