Skip to content

fix: read a record again when it was replaced during the read - #92

Merged
youdie006 merged 3 commits into
mainfrom
fix/record-read-during-replace
Nov 9, 2026
Merged

youdie006 merged 3 commits into
mainfrom
fix/record-read-during-replace

Conversation

@youdie006

Copy link
Copy Markdown
Owner

Problem

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, 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 show and MCP bridge_list_tasks failed the same way while a consult updated its records.

Change

readRecordJson and readReceiptIntegrityKeys now go through readReplacedFileText. 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.ts passes. 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.
  • The cross-process race script from the hunt: 171 failures against main, 0 in 1,056 reads with this branch.
  • npx tsc --noEmit passes. Full suite: 1873 passed, 3 skipped.

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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T01:29:36.405501Z 990a535 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

What this touches

  • bridge store
  • tests

3 file(s), 104 line(s) changed. Tests changed.

Worth a look

  • Careful read: touches the receipt/integrity path.

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
@youdie006
youdie006 merged commit cb2c940 into main Nov 9, 2026
7 checks passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant