Repository navigation
fix: read a record again when it was replaced during the read - #92
Merged
Merged
Conversation
Tasks, sessions and the receipt key are replaced by renaming a new file over them. readVerifiedUtf8File checks that the file it opened is still the one at the path, so a read that raced a replacement failed as "Target path changed during read file operation". Found 2026-11-09: with one process rewriting a session, 171 of about 1,100 reads from another failed; tasks list, sessions show and MCP bridge_list_tasks failed the same way while a consult updated its records. readRecordJson and readReceiptIntegrityKeys now go through readReplacedFileText, which repeats the whole verified read (every check included) up to five times on exactly that error. Any other failure, a symlink swap among them, is not retried. Verified: tests/record-read-during-replace.test.ts (unit cases plus an in-process writer/reader race that failed 5 of 150 reads against main) passes; the cross-process race script went from 171 failures against main to 0 in 1,056 reads; npx tsc --noEmit; full suite 1873 passed, 3 skipped. Claude-Session: https://claude.ai/code/session_01EMqNwnnhHXznd2P2PDsaDV
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
What this touches
3 file(s), 104 line(s) changed. Tests changed. Worth a look
This is an automated first pass, not a review. CI is the gate; a person decides. |
CI on Windows failed the race test from the writer side: renaming the new session file over one the reader has open fails there with EPERM, a different limitation from the one this branch fixes. The unit cases for readReplacedFileText still run on every platform. Claude-Session: https://claude.ai/code/session_01EMqNwnnhHXznd2P2PDsaDV
…g-replace # Conflicts: # CHANGELOG.md
youdie006
added a commit
that referenced
this pull request
Nov 10, 2026
…g the read) to the container image Same change as main PR #92 (merge cb2c940), released in 0.40.51, applied to src, tests and docs without changes. The CHANGELOG lines are main's with the PR noted. Claude-Session: https://claude.ai/code/session_01EMqNwnnhHXznd2P2PDsaDV
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.
Problem
Tasks, sessions and the receipt key are replaced by renaming a new file over them.
readVerifiedUtf8Filechecks that the file it opened is still the one at the path. So a read that raced a replacement failed asTarget path changed during read file operation, without naming the file.Found 2026-11-09: with one process rewriting a session, 171 of about 1,100 reads from another process failed.
prodex tasks list,sessions showand MCPbridge_list_tasksfailed the same way while a consult updated its records.Change
readRecordJsonandreadReceiptIntegrityKeysnow go throughreadReplacedFileText. It repeats the whole verified read, with every check, up to five times, but only on that exact error. Any other failure, including a swap to a symlink, still fails at once.Verification
tests/record-read-during-replace.test.tspasses. It has unit cases (retries, no retry on other errors, gives up after five tries) and an in-process writer/reader race. Against main's behavior the race failed 5 of 150 reads.npx tsc --noEmitpasses. Full suite: 1873 passed, 3 skipped.