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
post-tool-hook.sh: keep pipeline.shell read-position off the hot path (part 2 of #350) #353
Split out of #350, which reported two changes. Part 1 — the #227 env-cache fast path — is PR #352. This is part 2, deliberately left out of that PR so it gets its own argument rather than riding a perf win.
What was proposed
Have save-session.sh also write the per-session position to a bash-read-able sidecar (e.g. tmp/position.<session_id>, a plain integer), so scripts/post-tool-hook.sh:304's $PYTHON -m pipeline.shell read-position only runs when the sidecar is missing.
What it is worth
Measured on the #352 branch, macOS 24.3.0 arm64, GNU bash 3.2.57 — observed, and not a claim about Windows, which is the platform the original report was made on:
warm tool call, no save yet: 6 spawns / 130 ms
warm tool call, once last-save.json exists: 8 spawns / 248 ms
So the sidecar is worth roughly 2 spawns and ~118 ms per warm tool call on that machine, and only on calls after the first save. Real.
last-save.json already holds the position. A sidecar is a second source of truth for the same number, and the two can disagree — a partial write, a session id collision, a save that updated one and not the other, a stale file surviving a crash. A disagreement produces a wrong delta with nothing to notice: the hook silently saves too early, too late, or not at all, and the failure looks exactly like the feature working.
That is the misreports class, traded for latency. It may still be the right trade — but it needs the design that makes the two agree or makes a disagreement loud, and that design is the issue, not the sidecar.
What would have to be true
The sidecar is written by whatever writes last-save.json, in an order where a crash between them leaves the sidecar stale-and-detectable rather than wrong-and-plausible.
The read path has three states, not two: the sidecar's value, read-position's value, and could not tell — never a silent fallback to zero or to the last delta.
A sidecar that disagrees with last-save.json is a loud finding, with a test that pairs "must not fire" against a "must fire" in the same fixture.
Credit to @oguzhanpisgin, who reported both halves in #350 with the measurement matrix.
Activity
post-tool-hook.sh: keep pipeline.shell read-position off the hot path (…
test: pin the hot-path cost budget for the sidecar branch #353 changed (
fix: sidecar hot-path trust check now actually consults last-save.json (
Clear a leaked REMEMBER_TRANSCRIPT_PATH in post-tool/user-prompt hook…
Harden cmd_save_position: validate session_id before path use (#538) (#…
fix(#913): cache SESSION_DIR in post-tool-hook.sh to stop re-forking …
Fix #913 CI round: restore #353 sidecar-trust under cooldown, re-pin …
Fix #913: incremental transcript line count in post-tool-hook, skip s…
Part of #1011: reduce post-tool-hook.sh no-save forks (#1016)
Fix #1021: linear sidecar-trust "sessions" scope extraction in post-t…