checkpoints: a restore queued behind a stalled save has no ceiling (follow-up to PR 1404 thread PRRT_kwDOSK-bwM607p-r)

未关闭
#2,440 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
git, typescript
领域
backend, testing

调研方向

Start with src/core/checkpoints/index.ts, especially enqueueCheckpointWork around lines 293–327, and read the named checkpoint tests around lines 143–184 and 261. Trace the queued save calls from Task.ts and ApplyPatchTool.ts to confirm which callers can wait behind a stalled predecessor. Done means a deadline releases affected waiters and tests cover that behavior while preserving the rule that expired saves do not commit.

由索引模型根据 Issue 内容生成。

描述

Filed as the disposition the reviewer offered on PR 1404, thread PRRT_kwDOSK-bwM607p-r (https://github.com/Zoo-Code-Org/Zoo-Code/pull/1404#discussion_r4542246559).

What is unbounded

src/core/checkpoints/index.ts line 316 builds next = previous.then(attempt, attempt) and line 327 returns it; attempt reads options.expiresAt only at line 306, when its turn arrives. The deadline therefore decides whether an operation starts. It never releases the caller waiting behind a stalled predecessor.

Saves are content-safe because of that gate: lines 307-313 warn and resolve with no commit, and src/core/checkpoints/__tests__/checkpoint.test.ts:143 ("drops a queued save whose checkpoint window expired behind a stalled predecessor") tests it. The shape of that test's own lines 164-174 is the evidence that the release comes at the predecessor's settlement and not at the deadline.

The user-initiated restore is the case with no ceiling at all. index.ts:415 calls enqueueCheckpointWork with no options, DEFAULT_QUEUED_WORK_OPTIONS at line 293 carries no expiresAt, and checkpoint.test.ts:261 ("never drops a user-initiated restore queued behind a stall") pins that a restore must run whenever its turn arrives. Its ceiling is the in-flight save's git add . --ignore-errors plus git commit (src/services/checkpoints/ShadowCheckpointService.ts:258, called at 356 and 456). A -E grep for timeout|setTimeout over that whole file returns exactly one row, line 566 ({ interval: 500, timeout: 2_000 }, a different wait), so nothing bounds it. The task-start baseline is bounded separately by its own race at src/core/task/Task.ts:3968-3980, default window 15 seconds (packages/types/src/global-settings.ts:115 DEFAULT_CHECKPOINT_TIMEOUT_SECONDS = 15).

What a fix costs, priced with the gate's own instrument

scripts/stryker-diff.mjs (executableChangedLines), run against the blob at 9811691a111537e1be290330f43e7bd9dccb1289:

  • release the waiter at its own deadline when the work carries one: 18 diff rows, 12 counted executable lines;
  • the single-warning variant that also flags attempt so it does not warn a second time: 23 diff rows, 17 counted lines.

PR 1404 counts 463 of the instrument's 500 counted-line cap (435 of it in the extension package), so the cheap shape would take the pull to 475 and the tidy one to 479. Either rewrites checkpoint.test.ts:143-184, which today tests release-at-settlement, adds one test row (a test file is priced zero executable lines by that instrument), and adds a branch whose mutants only that new test can kill.

Why it was not done in 1404

The harm is latency and a missing warning, not a wrong commit: no save commits state its caller did not ask about, and the only genuinely unbounded await is a restore behind a hung git child. Spending 12 to 17 counted lines of the 37 this pull has left under the cap, rewriting a passing behavioural test, and preflighting a new branch is the dearer path - and 1404 is green at that head on all six required contexts (the organisation door prints HTTP 200 with total_count 21, the six contexts all completed/success).

Filed by this account as the answer to the reviewer's offer. If a maintainer would rather see the guard here, the 12-line shape above is the whole change and the test that has to move is named in it.

Amended 2026-11-12T21:33Z by the lane that read the review reply, so the destination matches what the reviewers described

Filed for one coordinate, the restore queued at index.ts:415. A reviewer row under thread PRRT_kwDOSK-bwM607p-r (comment 4556008315, served 2026-11-12T20:34:36Z, 599 B at sha256-16 1746fa7e54bcfa83) corrected that scope and stated it would not mark the finding as addressed; the lane that answered it checked the mechanism at head 9811691a111537e1be290330f43e7bd9dccb1289 and named the added coordinates there. They belong on this issue, so they are added here in the words that thread uses.

  1. The per-write save path is not exempt from the finding. options.expiresAt is read at index.ts:306 inside attempt, which everything queued reaches through the chain previous.then(attempt, attempt) at index.ts:316, so the same deadline field is read by the per-write save path as well as by baselines. The per-write saves get one at index.ts:374, expiresAt: Date.now() + Math.max(1, timeoutSeconds * 1000), under both labels named at :373. The reviewer put it as: "a per-write save can also wait indefinitely behind a stalled baseline. The expiry check runs only after the baseline settles, so apply_patch and its queued-message handoff can remain blocked."
  2. A stalled predecessor blocks the tool handoff, not only a background commit. apply_patch awaits those saves at ApplyPatchTool.ts:196, :206 and :220, each written await checkpointSave(task, false, true).catch(() => {}) - three call sites that await a checkpoint save and swallow its error.
  3. The predecessor is named by the sites that request it: the task-start baseline requested at Task.ts:3963 and the turn-boundary save at Task.ts:2495, which is where a stalled baseline comes from. The task-start race at Task.ts:3968-3980 with its 15-second default bounds that baseline's own record, and commit 872f5630d364 bounds what a late baseline records, not how long its waiters wait.

Nothing in the paragraphs above this line was rewritten. Both priced shapes stand exactly as filed - 12 and 17 counted executable lines, taking PR 1404 to 475 or 479 of the instrument's 500 counted lines, each rewriting checkpoint.test.ts:143-184 - and what changes is that release-at-deadline now has to be priced against both victims, the restore and the per-write saves.

Two sentences the reviewers asked for, recorded so they are not mistaken for work this issue owes. The reply thread PRRT_kwDOSK-bwM607p-r stays open, because the unbounded wait is unfixed at head 9811691a111537e1be290330f43e7bd9dccb1289. And the ask, raised by a reviewer row under thread PRRT_kwDOSK-bwM607p-u at src/core/tools/ApplyPatchTool.ts, that the last saved security gate be reassessed at the current head before merge belongs to the people who own that gate rather than to this campaign: this issue neither carries it nor defers it.

Amended once, 2026-11-12T21:33Z, by lane u9-1917 from the thread rather than by re-deriving it. Everything between the top of this body and the heading above is the body as filed at 2026-11-12T20:33:39Z, 3,359 B at sha256 eecdedf8019c0039b24b95688393dffe9beb6f1708ecb338c828d37d7206fca7, byte-for-byte intact.

主要语言
TypeScript
星标
2k
派生
301
平均合并
3 天 14 小时
30 天内合并 PR
103

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Zoo-Code-Org/Zoo-Code 的其他 Issue

查看 Zoo-Code-Org/Zoo-Code 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。