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
run-consolidation.sh commits the staging tail with the same cross-device mv #242 fixes in save-session.sh, and the result is unchecked #246
run-consolidation.sh:198 creates the staging tail with mktemp "${TMPDIR:-/tmp}"/remember-staging-tail-XXXXXX, and line 201 does mv "$staging_tail" "$staging_path" — onto a today-*.md memory file. Unchecked.
I read those lines. It is #242 with the destination changed: /tmp is tmpfs on most Linux distributions, on any devcontainer, and under WSL with the project on /mnt/c, so this is copy-then-unlink, not rename(2).
What makes it worth its own issue rather than a note on #242: #242's fix does not touch this file.#242 was scoped to save-session.sh's NDC commit, deliberately, because this one is a different file under a different lock (consolidation.lock + staging.lock, not save.lock). Two readings of the same mistake in two places, and only one of them is fixed.
What the failure looks like here
The #242 reproduction on a real second filesystem is the evidence for the shape: BSD mv unlinks the partial destination, so the target was gone entirely — total loss, not truncation — while the log reported the byte count it had computed before the move. GNU mv leaves the prefix instead.
Here the target is a today-*.md staging file, so the loss is a day's compressed summaries rather than now.md's live buffer. Whether that is better or worse depends on whether consolidation has already written recent.md — which is exactly the kind of thing that should not be left to chance.
Lines 205 and 208 are also unchecked (mv "$staging_path" "$staging_done"). Those are same-directory, so they are real renames and cannot half-complete — but an unchecked rename that fails still lets the loop continue as though the file were retired. Different severity, same reading.
The fix already exists in this repo
Do not design one. lib-env-cache.sh:170-174 writes a sibling temp and renames, and its comment says exactly why: "Rename, so no reader ever parses a partial file and rejects a resolution that was merely mid-write."post-tool-hook.sh:260 does the same. #242 adopted that pattern for the NDC commit. This is the third call site, and the only remaining one that hasn't.
So the judgment here is small and mostly about the failure arm: what should happen when the rename fails, given the loop is mid-way through a list of staging paths and staging.lock is held. Silently continuing is what it does now.
Also in scope, smaller
save-session.sh:393 — mv "$NORMALIZED" "$HAIKU_TEXT_FILE", likewise unchecked. That one is a transient file inside $TMPDIR on both sides, so it is not a cross-device write onto memory; the consequence is a stale header surviving the correction. Cosmetic, listed here so it is not lost rather than because it is urgent.
Provenance
Found by the agent implementing #242/#243, which scoped it out on purpose — correctly, it is not that diff's blast radius. Verified independently by me before filing: I read lines 195–209.
Activity
fix(#246): checked, same-directory rename for the consolidation stagi…