Skip to content

fix(anthropic): complete transcript reverse-scan windows across short reads#109431

Merged
steipete merged 2 commits into
openclaw:mainfrom
masatohoshino:fix/anthropic-transcript-reverse-scan-short-read
Jul 21, 2026
Merged

fix(anthropic): complete transcript reverse-scan windows across short reads#109431
steipete merged 2 commits into
openclaw:mainfrom
masatohoshino:fix/anthropic-transcript-reverse-scan-short-read

Conversation

@masatohoshino

@masatohoshino masatohoshino commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Opening a Claude session transcript could fail with Claude transcript changed while it was being read even when the file was unchanged. The reverse pager required one positional read to fill an entire 128 KiB window, but Node permits a successful read to return fewer positive bytes than requested.

Why This Change Was Made

The Anthropic plugin now completes each already-bounded reverse window across positive short reads, advancing both the buffer and file offsets. A zero-byte read before the stat-sized window is full remains a premature-EOF error, so concurrent truncation still fails closed.

The implementation stays plugin-local because bundled plugins may not import core src/infra helpers across the Plugin SDK boundary. It mirrors the established bounded-read loop used by core readers without adding API, config, dependency, or storage surface.

User Impact

Claude transcript pagination no longer fails spuriously on filesystems that return positive short positional reads. Real truncation during a page read still reports the existing error.

Evidence

  • node scripts/run-vitest.mjs extensions/anthropic/session-catalog.test.ts — 37 passed.
  • The short-read regression spans multiple 128 KiB windows and produces the same two-page items/order/cursor as normal reads.
  • A first-position-discriminated fault injects one short reverse read followed by zero bytes and preserves the premature-EOF error.
  • node scripts/check-changed.mjs -- extensions/anthropic/session-catalog.ts extensions/anthropic/session-catalog.test.ts — passed on Blacksmith Testbox tbx_01ky1m69ad5sftt2jpfnpybfgw, run 29805682398.
  • Full-branch AutoReview — clean, no accepted/actionable findings (0.98 confidence).
  • git diff --check — passed.

Contributor credit is preserved in Masato Hoshino's original commit.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 17, 2026, 9:09 AM ET / 13:09 UTC.

Summary
The branch makes Anthropic transcript reverse-scan windows fill across positive short positional reads and adds regressions for repeated partial reads and premature EOF.

PR surface: Source +10, Tests +128. Total +138 across 2 files.

Reproducibility: yes. The exported production reader was run against the same real on-disk transcript before and after the patch with FileHandle reads capped to 4 KiB; baseline fails immediately and the branch matches the uncapped two-page result while preserving the EOF control.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: extensions/anthropic/session-catalog.test.ts, unknown-data-model-change: extensions/anthropic/session-catalog.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦀 challenger crab
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] The head is behind current main, so the exact rebased result still needs confirmation.
  • [P1] The supplied check state includes failures in build-artifacts and check-additional-boundaries-bcd; their underlying failure logs were not available in the hydrated context, so maintainers should require a clean rerun or confirm they are unrelated before merge.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the plugin-local fill loop and both positive-short-read and premature-EOF regressions, then merge the rebased exact head once required checks are green or their failures are conclusively unrelated.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • Human handling is limited to rebasing and resolving or attributing the two failed required checks; no narrow automated code repair is supported by the review.

Security
Cleared: The two-file patch only changes bounded local file reading and tests; it adds no dependency, secret, permission, network, workflow, package-resolution, or supply-chain surface.

Review details

Best possible solution:

Keep the plugin-local fill loop and both positive-short-read and premature-EOF regressions, then merge the rebased exact head once required checks are green or their failures are conclusively unrelated.

Do we have a high-confidence way to reproduce the issue?

Yes. The exported production reader was run against the same real on-disk transcript before and after the patch with FileHandle reads capped to 4 KiB; baseline fails immediately and the branch matches the uncapped two-page result while preserving the EOF control.

Is this the best way to solve the issue?

Yes. Completing the already-bounded window in the owning Anthropic plugin mirrors the existing forward scan and merged sibling patterns without changing APIs, limits, configuration, or ownership boundaries.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8020dd3e0830.

Label changes

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦀 challenger crab and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This is a focused correctness fix for a limited Anthropic session-catalog failure with strong reproduction and no broad runtime outage.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦀 challenger crab and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR provides convincing before/after live output from the exported production reader using a real on-disk transcript, real FileHandle reads, identical pagination hashing, and a preserved premature-EOF control.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR provides convincing before/after live output from the exported production reader using a real on-disk transcript, real FileHandle reads, identical pagination hashing, and a preserved premature-EOF control.
Evidence reviewed

PR surface:

Source +10, Tests +128. Total +138 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 16 6 +10
Tests 1 128 0 +128
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 144 6 +138

What I checked:

Likely related people:

  • steipete: Authored the merged broad session positional-read cleanup that established the current fill-until-EOF approach across related core transcript readers. (role: recent short-read invariant contributor; confidence: high; commits: 203b8dbf0c15; files: src/gateway/session-utils.fs.ts, src/gateway/session-transcript-files.fs.ts, src/gateway/session-utils.fs.test.ts)
  • sunlit-deng: Introduced a closely related merged fix for completing bounded transcript reads in the continuation bootstrap marker path and also proposed the separate gateway short-read repair. (role: adjacent behavior contributor; confidence: medium; commits: 8cc8feee4d35; files: src/agents/bootstrap-files.ts, src/agents/bootstrap-files.test.ts, src/gateway/session-utils.fs.ts)
  • Monkey-wusky: Authored the merged async session tail-reader short-read fix that reused the repository's fill-window helper pattern. (role: adjacent behavior contributor; confidence: medium; commits: 8ebb1d2aec6f; files: src/gateway/session-utils.fs.ts, src/gateway/session-utils.fs.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (5 earlier review cycles)
  • reviewed 2026-07-17T00:03:51.317Z sha 7fd6f82 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T04:02:15.911Z sha d387123 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T09:39:48.601Z sha 3695111 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T10:29:52.270Z sha 223e79b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T12:49:54.428Z sha 223e79b :: needs maintainer review before merge. :: none

@masatohoshino
masatohoshino force-pushed the fix/anthropic-transcript-reverse-scan-short-read branch 3 times, most recently from 3695111 to 223e79b Compare July 17, 2026 10:24
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 17, 2026
@masatohoshino

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added standalone real-behavior proof using the exported production reader with a real on-disk transcript and capped real FileHandle.read calls. Before the fix, the first positive short read throws; after the fix, pagination is identical across 82 real short reads, while the zero-byte premature-EOF control still throws. The PR remains a focused 2-file diff and has been rebased onto e0478e2.

@clawsweeper

clawsweeper Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 17, 2026
@steipete steipete self-assigned this Jul 21, 2026
masatohoshino and others added 2 commits July 20, 2026 22:52
… reads

readLocalClaudeTranscriptPage filled each reverse-scan window with a single
positional read and threw "Claude transcript changed while it was being read"
whenever bytesRead !== size. A positional read may return fewer bytes than
requested inside an unchanged file, so a benign short read failed the transcript
page load with a message implying the file changed. The forward metadata scan in
the same file already loops short reads; the reverse scan did not.

Fill each window across short reads, advancing both the buffer offset and the
file position. A zero-byte read before the window is filled is premature EOF and
still throws the same error.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@steipete
steipete force-pushed the fix/anthropic-transcript-reverse-scan-short-read branch from 223e79b to 3899599 Compare July 21, 2026 06:06
@clawsweeper

clawsweeper Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(anthropic): complete transcript reverse-scan windows across short reads This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete
steipete merged commit f1205f5 into openclaw:main Jul 21, 2026
89 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 21, 2026
… reads (openclaw#109431)

* fix(anthropic): complete transcript reverse-scan windows across short reads

readLocalClaudeTranscriptPage filled each reverse-scan window with a single
positional read and threw "Claude transcript changed while it was being read"
whenever bytesRead !== size. A positional read may return fewer bytes than
requested inside an unchanged file, so a benign short read failed the transcript
page load with a message implying the file changed. The forward metadata scan in
the same file already loops short reads; the reverse scan did not.

Fill each window across short reads, advancing both the buffer offset and the
file position. A zero-byte read before the window is filled is premature EOF and
still throws the same error.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* test(anthropic): tighten transcript short-read coverage

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
vincentkoc added a commit that referenced this pull request Jul 21, 2026
* origin/main: (24 commits)
  fix(agents): keep compaction on live session model (#95713)
  fix(plugin-sdk): guard provider catalog live URL parsing against malformed responses (#109986)
  chore(cli): drop dead classifiers and single-use wrappers left by fallback removal (#112191)
  feat(ui): expand the lobster pet's random universe (#112073)
  chore(ci): audit dependency fingerprint exports (#112190)
  fix(ui): preserve graphemes in provider icons (#109509)
  fix(ui): align settings search with navigation rows (#112172)
  fix(agents): allow configless gateway rebind to activate standalone owner (#111841)
  fix(secrets): register secret targets for installed-origin plugins (#104347)
  improve(ui): show real machine identity in the place picker (#112162)
  fix: webChat scrollback history is too limited — older assistant replies and tool outputs disappear when scrolling… (#104250)
  test(ui): run DOM-free suites in Node (#112031)
  feat(nodes): make computer.act eligibility capability-based for desktop nodes (#112107)
  fix(apps): harden mobile gateway and watch state
  fix(ci): restore Z.AI API Platform validation (#112171)
  fix(ui): prevent Logs controls from overlapping (#112170)
  fix #95291: message tool fails to deliver files/images on Feishu (400 volc-dcdn / write ECONNRESET) while same Lark SDK upload succeeds standalone (#95514)
  refactor(cli)!: remove automatic gateway→embedded fallback from openclaw agent (#112074)
  refactor: move provider transports into packages/ai behind a typed host port (#111669)
  fix(anthropic): complete transcript reverse-scan windows across short reads (#109431)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: anthropic P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants