You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
guards: a matched warning is still lost when the tags join, a table probe or db.close() throws #371
#358 made pre-edit-recall hold a fault from the two observations reads and still emit a matched lesson guard. Three other statements inside the same outer try still take the warning with them when they throw (same behaviour before #358):
statement
on throw
sqlite_master table probe
outer catch, stdout empty
PRAGMA table_info(entities)
outer catch, stdout empty
Strategy 1 tags join
outer catch, stdout empty
db.close() in finally
outer catch, stdout empty
Reproduced through the real hook with tags renamed away and an accepted Edit guard matching the payload: outcome: error, stderr no such table: tags, stdout empty — the guard matched and the user never saw it.
The guard half is evaluated before any of these. It should not depend on them.
Related, in scripts/hooks/guard-check.js: the fire counter is written BEFORE the warning is printed, and process.exit(0) follows console.log immediately. With the counter's wait now bounded to the hook budget the warning is no longer lost under a held write lock, but it is delayed by that wait; and on POSIX, where a piped stdout is asynchronous, process.exit right after a large console.log can truncate it.
Suggested direction
Emit the guard block as soon as it is known (or hold every recall-side fault the way recallFault does) so no recall-side statement can cost a warning.
guard-check.js: print, record, then count — and end by returning instead of process.exit when output was written.
One shared "emit warning, record outcome, count" helper for both hooks so the order cannot drift again.
guard-check.js calls process.exit(0) immediately after console.log. On POSIX a piped stdout is asynchronous, so everything past the 64 KiB pipe buffer is dropped: the host receives half a JSON document, the whole additionalContext is lost, exit is 0 and stderr is clean. It needs no lock and no slow reader. The threshold is roughly 215 simultaneously matching accepted guards at the 280-character message cap, so it is unlikely today, but it is silent when it happens.
Also measured under a held write lock, time to first byte: guard-check.js 2.14 s (it counts before it prints, and the counter now waits its 2 s budget) versus pre-edit-recall.js 0.07 s (prints first).
When this is fixed, point the POSIX slow-reader test in tests/hooks/guard-check.test.ts at guard-check.js as well — today it only spawns pre-edit-recall.js.
Activity
kevintseng commentedon Sep 20, 2026
Measured while reviewing #358 (real
scripts/hooks/guard-check.js, a real OS pipe, 400 accepted Bash guards matching the command):guard-check.jscallsprocess.exit(0)immediately afterconsole.log. On POSIX a piped stdout is asynchronous, so everything past the 64 KiB pipe buffer is dropped: the host receives half a JSON document, the wholeadditionalContextis lost, exit is 0 and stderr is clean. It needs no lock and no slow reader. The threshold is roughly 215 simultaneously matching accepted guards at the 280-character message cap, so it is unlikely today, but it is silent when it happens.Also measured under a held write lock, time to first byte:
guard-check.js2.14 s (it counts before it prints, and the counter now waits its 2 s budget) versuspre-edit-recall.js0.07 s (prints first).When this is fixed, point the POSIX slow-reader test in
tests/hooks/guard-check.test.tsatguard-check.jsas well — today it only spawnspre-edit-recall.js.kevintseng commentedon Dec 2, 2026
A matched guard now survives recall faults, and warning output is preserved on a slow pipe. Verified on the open PR #650.