fix: make the failure sentinel diagnosable (version stamp, bounded history, scoped hint) - #72
Draft
m3talux wants to merge 1 commit into
Draft
fix: make the failure sentinel diagnosable (version stamp, bounded history, scoped hint)#72m3talux wants to merge 1 commit into
m3talux wants to merge 1 commit into
Conversation
…story, scoped hint)\n\nDuring the 2026-06 cross-version index incident the sentinel was nearly\nuseless for diagnosis: multiple immutable plugin caches shared one\n~/.superbrain so an unattributed last-failure.txt line could have been\nwritten by any version; read-and-clear semantics meant each failure\ndestroyed the previous one; and SessionStart appended 'set\nANTHROPIC_API_KEY' to EVERY failure (index errors included), steering\ndiagnosis toward auth/quota.\n\n- writeFailure() now stamps every line with the writing plugin's package\n version ([vX.Y.Z], resolved via pluginRoot()).\n- Every failure is also appended to ~/.superbrain/failures.log, windowed\n to the last 100 lines (same pattern as the reject-queue cap); the log\n is never read-and-cleared, so history survives the sentinel clear.\n- sb-session-start only appends the ANTHROPIC_API_KEY hint for distill\n failures.\n\nTests (red first, tests/sentinelHygiene.test.ts): version stamp present;\nhistory appends and stays bounded; hint scoped (index failure output has\nno ANTHROPIC_API_KEY, distill failure keeps it); and a capture-failure\nsurfacing E2E â�� vec_chunks corrupted to int8[8], distill entrypoint run\nwith a stub envelope: the note .md is still written, exit 0, and the\nsentinel contains 'index failed' with the version stamp.\n\nCo-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context — diagnosed production incident (2026-06-09)
During the cross-version index incident (a stale pre-0.8 plugin cache writing v0.7 float vectors into the v0.8
int8[256]store — see the companion fence PR), the failure sentinel actively hindered diagnosis:~/.superbrain; an unattributedlast-failure.txtline could have been written by any of them.last-failure.txtis overwrite-on-write and read-and-clear, so each failure destroyed the previous one.sb-session-startappended "set ANTHROPIC_API_KEY if it persists" to EVERY failure, including index errors, steering diagnosis toward auth/quota.No data was lost in the incident; this PR is purely about diagnosability next time.
Change
src/sentinel.ts—writeFailure()stamps every failure line with the writing plugin's package version ([vX.Y.Z], resolved viapluginRoot(), cached per process;"unknown"fallback).~/.superbrain/failures.log, windowed to the lastMAX_FAILURE_LOG_LINES = 100lines (same windowed-log pattern as the reject-queue cap). The log is never read-and-cleared, so history survives the SessionStart sentinel clear. Best-effort: history can never break the sentinel write.bin/sb-session-start.ts— theANTHROPIC_API_KEYhint is now scoped to failures matching/distill/i(the only failures where the API-key escape hatch helps); all other failures keep the "fixed automatically next checkpoint" copy without it.Tests (red → green,
tests/sentinelHygiene.test.ts)last-failure.txt(was red: no stamp existed).failures.log).ANTHROPIC_API_KEY; a distill-failure message keeps it (index case was red).vec_chunksrecreated asint8[8]to reproduce the incident's insert failure, then the real distill entrypoint (bin/sb-distill.ts) run withSUPERBRAIN_DISTILL_STUB— asserts the note.mdIS written, exit code 0, and the sentinel containsindex failedwith the version stamp.Status
dist/rebuilt and committed;git diff --exit-code distclean after build.🤖 Generated with Claude Code