Salvage 3 kernels from the optimization-spec review (decay escalation · override audit · traceback de-noise)#7
Merged
Conversation
escalateByMemory now decays each outcome-tagged entry by e^(-k·age) (half-life 72h) at recall time instead of flat-counting. Recent evidence arbitrates the failure-vs-success balance, and a live-failure-mass floor lets a cluster of purely stale failures fade rather than warn forever. Contract intact: OPEN→PAUSE only, never WITNESS, no new tables/writes, no row deletion — pure function of timestamps. Dateless entries weigh 1.0, so behavior is byte-identical for callers passing rows without created_at (full back-compat). Salvaged from the external optimization-spec review (the circuit-breaker section's one defensible kernel), folded into the existing coupling rather than a parallel failure_chronicle table. 291 tests green (+6 decay tests). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…r_override The compass_log.user_override column has existed in the schema since phase 1 but was never written. On an approved PAUSE override the PreToolUse hook now sets it to the consumed approval's row id (not the token value), and getCompassHistory / getCompassSince surface it — so "this fire was overridden" is a queryable signal instead of being buried in the free-text reason. recall_compass exposes it for free. Salvaged from the spec review (security section): the one defensible piece of the proposed audit_compass_trail table, done without a new table, HMAC, CAS, or cross-process key — and routed through the existing logCompass scrub chokepoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tching) New lib/query-normalize.js (pure, ReDoS-safe: line splits + linear regexes only) strips stack-frame lines, file paths, line:col offsets, and hex addresses from a prompt that contains a traceback, leaving the error identity (ModuleNotFoundError, sqlite3.OperationalError, ...) to lead the FTS query. surface.js applies it to the generic-recall query so a pasted error matches the v0.10 error-fix atlas instead of being diluted by path noise. No-op on ordinary prompts; never returns empty. Salvaged from the spec review (traceback section): the one defensible kernel, reframed as a recall-side query normalizer feeding the existing matcher — NOT the rejected sha256 frame-signature identity store. 297 tests green (+5). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
templetwo
added a commit
that referenced
this pull request
Jun 18, 2026
The leading-identifier run `[\w$]*` before the Error/Exception/Warning
suffix was unbounded, so a long suffix-less word run forced O(n^2)
backtracking from every offset (~21s at 200K chars) — contradicting the
file's own "linear, ReDoS-safe" header. Live exposure was bounded by the
4000-char prompt cap (~10ms), so this was a false-guarantee / correctness
issue, not an exploitable hang. Bound the run to {0,64} (real exception
names are far shorter) → linear; 200K worst case now <100ms.
Also corrects the header claim and adds a smoke test that feeds a single
200K-char suffix-less token under a wall-clock bound — the prior
frame-flood test used short lines and never reached the quadratic path,
so the linear-time claim was asserted but untested.
Found by the post-merge adversarial review of #7.
298 tests green.
Co-authored-by: CAF Agent <agent@caf.cli>
Co-authored-by: Claude Opus 4.8 (1M context) <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.
Three small, contract-safe improvements salvaged from the review of an external
"deep optimization" spec. The spec itself was mostly rejected (server-shaped
proposals grafted onto a per-event fail-open hook plugin; several invariant
violations). These are the defensible kernels, each reframed to fit T2Helix's
real model — folded into existing structure, no new tables, no new write
paths, no row deletion.
1.
feat(coupling)— recency-weighted memory→compass escalationescalateByMemorydecays each outcome-tagged entry bye^(-k·age)(half-life72h) at recall time instead of flat-counting. Recent evidence arbitrates the
failure-vs-success balance, and a live-failure-mass floor lets a cluster of
purely stale failures fade rather than warn forever.
function of timestamps; dateless entries weigh 1.0 → byte-identical to the old
behavior for callers without
created_at.recent-failure-dominant set whose raw ratio is <0.5 (e.g. 1 fresh failure +
2 stale successes). Still a soft, overridable PAUSE. Half-life (72h) and mass
floor (1.0) are exported, tunable constants.
2.
feat(compass)— overridden-fire audit signal incompass_log.user_overrideThe
user_overridecolumn has existed since phase 1 but was never written. Onan approved PAUSE override the hook now sets it to the consumed approval's row
id (not the token value), and the two history reads surface it. "This fire was
overridden" becomes queryable;
recall_compassexposes it for free. Routedthrough the existing
logCompassscrub chokepoint.3.
feat(surface)— de-noise pasted tracebacks before recallNew pure
lib/query-normalize.js(ReDoS-safe: line splits + linear regexesonly) strips stack frames / paths /
line:col/ hex from a prompt containing atraceback, so the error identity leads the FTS query against the v0.10 error-fix
atlas. No-op on ordinary prompts; never returns empty. Not the rejected
sha256 frame-signature store — just a recall-side query normalizer feeding the
matcher that already exists.
Verification
19, sse 9, import-atlas 18, atlas-acceptance 15, sync-stack 17). Baseline was
285 before these changes; +12 new tests (6 decay, 1 override round-trip, 5
query-normalize incl. a frame-flood linear-time check).
OPEN→PAUSE-only / append-only / ReDoS invariants.
🤖 Generated with Claude Code