fix: add timeout to parent-fork token count resolution (fixes #101718)#101766
fix: add timeout to parent-fork token count resolution (fixes #101718)#101766zw-xysk wants to merge 1 commit into
Conversation
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Codex review: needs real behavior proof before merge. Reviewed July 7, 2026, 12:39 PM ET / 16:39 UTC. Summary PR surface: Source +6, Tests +46. Total +52 across 2 files. Reproducibility: yes. source inspection gives a high-confidence path: make parent-token resolution exceed the new timeout and the PR returns a fork decision, after which callers still read the same parent transcript. I did not run a live slow-filesystem reproduction in this read-only review. Review metrics: none identified. Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Make a timed-out parent-token probe choose a bounded non-fork path, or bound fork creation too, while preserving the oversized-parent isolated-context behavior and proving it with a delayed or large parent fork run. Do we have a high-confidence way to reproduce the issue? Yes, source inspection gives a high-confidence path: make parent-token resolution exceed the new timeout and the PR returns a fork decision, after which callers still read the same parent transcript. I did not run a live slow-filesystem reproduction in this read-only review. Is this the best way to solve the issue? No: timing out to an unknown token count is not the best fix because it lets callers start the unbounded fork read and can bypass the oversized-parent cap. A safer fix either skips/isolates on timeout or bounds the subsequent fork transcript read too. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 453f5968bbca. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +6, Tests +46. Total +52 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
Review history (1 earlier review cycle)
|
…w#101718) resolveParentForkTokenCount reads the parent transcript to estimate token count when forking a session, but has no timeout. On large transcripts or slow filesystems (NFS, FUSE), this blocks session creation indefinitely, accumulating blocked async contexts on the gateway. Wrap the runtime call in resolveParentForkTokenCount with withTimeout(..., 2_000) so the function returns undefined within bounded time. resolveParentForkDecision already handles undefined parentTokens correctly (returns fork without a token estimate), which is the safe default vs. blocking indefinitely. Includes regression tests for the fast-resolve, timeout, and too-large paths.
658818b to
fa09d43
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
What Problem This Solves
resolveParentForkTokenCountreads the parent transcript to estimate token count when forking a session, but has no timeout or abort signal. On large transcripts (hundreds of MB) or slow filesystems (NFS, FUSE, saturated SSD), this blocks session creation and reply fork paths indefinitely, accumulating blocked async contexts that exhaust gateway connection slots (#101718).Call chain
Changes
2 files, +54/-2 (source: +6; tests: +48)
src/auto-reply/reply/session-fork.ts(+6 lines):withTimeoutfrom../../infra/fs-safe.jsPARENT_FORK_TOKEN_TIMEOUT_MS = 2_000constantresolveParentForkTokenCountRuntimeinwithTimeout(..., 2_000).catch(() => undefined)When the 2-second timeout fires,
resolveParentForkTokenCountreturnsundefined— the same sentinel the normal fallback path already produces.resolveParentForkDecisionalready handlesundefinedcorrectly: returns{status: "fork"}withoutparentTokensestimate.This single bounded deadline (recommended by ClawSweeper review) covers all filesystem awaits inside the runtime (fs.stat + transcript read up to 1MB + potential index scan) in one wrapper.
src/auto-reply/reply/session-fork.test.ts(+48 lines):resolveParentForkDecision:forkwithparentTokens(50k)forkwithoutparentTokenswithin 2s (timeout proof)skipWhy 2 seconds and not 10?
freshPersistedTokensfast pathundefined(allow fork without estimate) is always better than blocking indefinitelyEvidence
Unit tests (18/18 passed)
Timeout test specifically runs for ~2008ms, confirming the deadline fires and fork proceeds without blocking.
Real behavior proof (13/13 passed — Platinum level)
Review