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

Ouverte
#2,440 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 3 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
35/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
git, typescript
Domaine
backend, testing

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
TypeScript
Étoiles
2k
Forks
301
Merge moyen
3 j 14 h
PR mergées (30 j)
103

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de Zoo-Code-Org/Zoo-Code

Toutes les issues de Zoo-Code-Org/Zoo-Code

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.