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
NDC race: background subshell truncates now.md up to 180s after snapshotting it — saves landing in the window are silently lost #142
Code-read finding (0.8.3; re-verified on main @ 7db7866 — not yet observed as a confirmed loss in my logs, but the window is real and the default cooldowns make it reachable)
Mechanism
In scripts/save-session.sh, the NDC prompt snapshots now.mdsynchronously (line 231, build-ndc-prompt), then the compression runs in a background subshell with a 180s model-call timeout, and only afterwards truncates:
line 231: snapshot into $NDC_PROMPT
line ~237: call-haiku ... 180 (in the backgrounded subshell)
line 248: : > "$MEMORY_FILE"
So the truncation can land up to ~180s after the snapshot. The save cooldown defaults to 120s (scripts/save-session.sh:114), i.e. a different session's save (or a --force save; the lock is released when the parent exits, and the parent exits without waiting on the subshell) can append a fresh entry to now.md inside the window. That entry was never in the snapshot, but : > erases it — never compressed into today-*.md, never seen again. No log line records the discrepancy.
Suggested fix
Truncate-by-content, not blindly: have the subshell replace now.md only up to what it snapshotted — e.g. snapshot to a byte offset (NDC_SRC_BYTES is already computed at line ~229!) and, at completion, atomically rewrite now.md with whatever lies beyond that offset instead of : >:
(mv-over is atomic on the same filesystem; worst case under a concurrent append is the pre-existing race, no worse.) That preserves any entry appended during the compression window at zero cost.
Activity
fix: NDC must drop only the bytes it compressed, not the whole file (#…
fix: NDC must drop only the bytes it compressed, not the whole file (#…
fix: NDC must drop only the bytes it compressed, not the whole file (#…
fix(ndc): re-read the day when compression ends, not when the run began
fix(ndc): file compressed memory under the day it came from (#141) (#164
fix: two ways memory was discarded without a trace
fix(review): raw byte count, NDC reject gate, shared reject sink
fix(ndc): the tail-failure path no longer truncates now.md (#208)
release: 0.9.0 — Mistaken for someone else (#216)
fix(#223): commit NDC's partial truncate under the save lock (#224)
fix(#235): read staging under staging.lock, with the model call outsi…
fix(ndc): commit now.md by rename and gate the day marker on it (#245)
release: 0.11.0 — The argument outlived the code (#248)