Repository navigation
Merged
Conversation
…write down the cross-host lock contract (#509, #491) #509: a today-YYYY-MM-DD.md staging file re-created for a day already retired -- a long-running session spanning midnight, or NDC re-opening a retired day's staging file -- had its second retirement silently truncate the existing .done.md over the previous span, in both the plain-rename and the concurrent-append (head -c / tail-split) retire paths. Both now append to an existing .done.md instead of overwriting it. #491: established, rather than assumed, whether the lock primitive (lib-lock.sh) and the staging lock (lib-staging-lock.sh) are safe when Claude Code and Codex share one .remember/ store on one machine. They are, because mkdir/kill -0 are OS-level process-table operations indifferent to which CLI spawned the contending process, and every lock is keyed by a fixed literal name or by day, never by session id. Both files now carry that contract as a header comment, proved under real concurrent writes from two simulated hosts in tests/test_cross_host_lock_contract_491.py, which also documents the one general, pre-existing kill -0 PID-reuse limitation this design inherits (not new, not worsened by a second host). Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ned, and be honest in the log when it can't tell (#509) Two reviewers (Explore, oss:auditor) spawned against the first commit found: - retire_prefix_into wrote the consumed prefix straight into staging_done before the tail extraction below it was known to succeed. When `tail` failed, the whole-file fallback re-committed the same prefix on top, duplicating it unconditionally on the very first attempt (not only on a retry, as the comment at the time claimed). Fixed by extracting both the prefix and the tail into fresh temp files first and touching staging_done only once both are known good -- reproduced red (a tail-stub forcing the failure) before the fix, green after, verified against the pre-fix commit and restored cleanly. - retire_whole_into's cat+rm is not atomic like the mv it replaces: if cat durably appends but the trailing rm fails, the two "left in place" log lines asserted a clean, safely-retriable state that does not hold in that sub-case. Reworded to say the append may already have landed. Co-Authored-By: Claude Sonnet 5 <[email protected]>
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.
#509 -- consolidation retire overwrites an existing .done.md
run-consolidation.sh's retire loop turned atoday-YYYY-MM-DD.mdstaging file intotoday-YYYY-MM-DD.done.mdwith a plainmv(orhead -c ... >in the concurrent-append path). When a day was re-opened after already being retired once -- a session spanning midnight, or NDC re-creating the staging file for an already-retired day -- the second retirement silently truncate-overwrote the existing.done.md, destroying the first retired span's hourly-detail data with no log line.recent.md/archive.mdare unaffected (they already merged both spans), so this was never memory-injection loss, but it destroyed the "searchable, not injected" hourly detail layer the README promises.Fixed by appending to an existing
.done.mdinstead of overwriting it, in both the plain-rename and the concurrent-append retire paths. Test-first:tests/test_consolidation_retire_reopened_day_509.pyreproduces the overwrite (retire the same day twice, assert the first span survives), red before the fix and green after, plus a positive control (a day retired for the first time still works normally).#491 -- cross-host locking contract, Claude Code + Codex sharing one store
scripts/lib-lock.shandscripts/lib-staging-lock.shwere written and tested against a single host's process model and never mentioned Codex or "host" anywhere. Established (not assumed): the lock primitive is safe when Claude Code and Codex share one.remember/store on one machine, becausemkdir/kill -0are OS-level process-table operations indifferent to which CLI spawned the contending process, and every lock is keyed by a fixed literal name or by day, never by session id. Both files now carry that contract as a header comment.tests/test_cross_host_lock_contract_491.pyproves it under real concurrent writes from two simulated hosts (no lost/interleaved entries -- a genuine two-writer test, not one where the second writer never actually wrote), documents the one general, pre-existingkill -0PID-reuse limitation this design inherits (not new, not worsened by a second host), and locks in via a grep contract that the lock/staging layer never assumes a session-ID shape.Self-review
Spawned
Exploreandoss:auditoragainst the first commit. Both found a real duplication bug my first draft introduced:retire_prefix_intowrote the consumed prefix straight into.done.mdbefore the pairedtailextraction was known to succeed, so atailfailure's whole-file fallback re-committed the same prefix on top -- duplicating it unconditionally on the very first attempt, not only on a documented retry. Fixed in a follow-up commit by landing both extractions in temp files first and touching.done.mdonly once both are known good; reproduced red against the pre-restructure code with atail-stub, green after. Also reworded two ERROR log lines and a stale comment that overclaimed a clean, safely-retriable state whencat(not atomic, unlike themvit replaces here) can durably succeed while the trailingrmfails.Below the bar, recorded here rather than filed: a persistent
rmfailure after a successfulcat(a stuck permission/immutable-flag condition unlinking a retired staging file) still causes unbounded duplicate growth in.done.mdacross every subsequent run -- only its logging is now honest, not the underlying growth. A real fix needs a design decision (a commit marker, refusing a partialcat, or an atomicity redesign of the append path) beyond this issue's scope; the class is reachable in principle but requires a pathological, sustained filesystem-permission condition to trigger, which is why it stops here rather than becoming a filed issue.Closes #509, closes #491.