fix(dispatch): release the scope after a late answer on the received-journal replay (ISS-4) #119

Merged
janpeter merged 1 commit from claude/competent-snyder-d261fd into master 2026-10-08 21:25:28 +02:00
Owner

Fixes a leak found while reviewing the ISS-4 fix.

In runDispatchAttempt, the phase==='received' && receiptId replay returned {outcome:'late'} without calling releaseScope. The staged path and the main path both release on a late answer. Because of that, the broker container, the broker attempt directory (holding the child's provider key) and the prepared-sources staging in /run/sources stayed behind. The 48h orphan sweep (armPreparedSourcesSweep) skips them because the supervisor journal stays.

Change: call releaseScope(ports,scope,proof.attempt_id) before returning late on that path, following the M41 U3 rule in docs/dispatch-runtime-operator.md ("A late answer is released too").

Test: release after the terminal answer → releases after a late answer on the received-journal replay too. It writes a received journal with receiptId and result, and submitResult answers {status:'late',result_id:null}. The test expects outcome late and runtime.release(scope,id). It failed before the fix (0 calls) and passes after.

Verification:

  • npx vitest run __tests__/dispatch-supervisor.test.ts: 63/63 passed
  • npm run typecheck:dispatch: clean

🤖 Generated with Claude Code

Fixes a leak found while reviewing the ISS-4 fix. In `runDispatchAttempt`, the `phase==='received' && receiptId` replay returned `{outcome:'late'}` without calling `releaseScope`. The `staged` path and the main path both release on a late answer. Because of that, the broker container, the broker attempt directory (holding the child's provider key) and the prepared-sources staging in `/run/sources` stayed behind. The 48h orphan sweep (`armPreparedSourcesSweep`) skips them because the supervisor journal stays. **Change:** call `releaseScope(ports,scope,proof.attempt_id)` before returning `late` on that path, following the M41 U3 rule in `docs/dispatch-runtime-operator.md` ("A late answer is released too"). **Test:** `release after the terminal answer` → *releases after a late answer on the received-journal replay too*. It writes a `received` journal with `receiptId` and `result`, and `submitResult` answers `{status:'late',result_id:null}`. The test expects outcome `late` and `runtime.release(scope,id)`. It failed before the fix (0 calls) and passes after. **Verification:** - `npx vitest run __tests__/dispatch-supervisor.test.ts`: 63/63 passed - `npm run typecheck:dispatch`: clean 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(dispatch): release the scope after a late answer on the received-journal replay (ISS-4)
All checks were successful
CI / Compose config (pull_request) Successful in 10s
CI / Build-arg coverage (pull_request) Successful in 9s
CI / Docker build (pull_request) Successful in 1m52s
d77b152c15
The phase 'received' replay returned `late` without releaseScope, unlike the
'staged' and main late paths. The broker container, its attempt directory
(with the child's provider key) and the /run/sources staging stayed behind,
and the 48h orphan sweep skips them because the supervisor journal remains.
Release there too, per M41 U3 ("A late answer is released too").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
s4m-codex-reviewer left a comment

COMMENT

De wijziging in lib/dispatch-supervisor.ts:195 hergebruikt releaseScope vóór de late-return op het received-replaypad. Dit sluit aan op de bestaande staged-/normale paden en de expliciete M41 U3-regel in docs/dispatch-runtime-operator.md. De helper behoudt het terminale resultaat bij cleanup-fouten; de broker controleert zelf de gestopte scope en ondersteunt herhaalde release. Geen blokkerende codekwaliteit-, architectuur- of documentatiefindings gevonden. Deze kleine correctie vereist geen nieuwe productdocumentatie.

Findings:

  • INFO — tests/dispatch-supervisor.test.ts:357: de nieuwe regressietest dekt het bedoelde received-journal met late-response en controleert release van de juiste scope/attempt. De tests konden hier niet starten: de werkmap onder /tmp weigert uitvoering en het laden van Vitests native binding. Daardoor is de testuitvoering niet onafhankelijk bevestigd; uit voorzorg COMMENT.

Verificatie: PR resolveert en head komt overeen met d77b152c15; diff gecontroleerd. Typecheck (node node_modules/typescript/bin/tsc -p tsconfig.dispatch.json) slaagt na initialisatie van de gepinde shared-submodule. git diff --check slaagt. Vitest-uitvoering blijft door de genoemde omgevingsbeperking onbevestigd.

geen gekoppeld plan gevonden — beoordeeld op codekwaliteit + product-standaarden.

# COMMENT De wijziging in lib/dispatch-supervisor.ts:195 hergebruikt releaseScope vóór de late-return op het received-replaypad. Dit sluit aan op de bestaande staged-/normale paden en de expliciete M41 U3-regel in docs/dispatch-runtime-operator.md. De helper behoudt het terminale resultaat bij cleanup-fouten; de broker controleert zelf de gestopte scope en ondersteunt herhaalde release. Geen blokkerende codekwaliteit-, architectuur- of documentatiefindings gevonden. Deze kleine correctie vereist geen nieuwe productdocumentatie. Findings: - **INFO — __tests__/dispatch-supervisor.test.ts:357:** de nieuwe regressietest dekt het bedoelde received-journal met late-response en controleert release van de juiste scope/attempt. De tests konden hier niet starten: de werkmap onder /tmp weigert uitvoering en het laden van Vitests native binding. Daardoor is de testuitvoering niet onafhankelijk bevestigd; uit voorzorg COMMENT. Verificatie: PR resolveert en head komt overeen met d77b152c1571f136e4d47d513f8740edead854e6; diff gecontroleerd. Typecheck (`node node_modules/typescript/bin/tsc -p tsconfig.dispatch.json`) slaagt na initialisatie van de gepinde shared-submodule. `git diff --check` slaagt. Vitest-uitvoering blijft door de genoemde omgevingsbeperking onbevestigd. geen gekoppeld plan gevonden — beoordeeld op codekwaliteit + product-standaarden.
Author
Owner

Test run for the review's open INFO point: Vitest was run locally (macOS) on head d77b152c1571f136e4d47d513f8740edead854e6. CI does not run Vitest; it only validates compose, checks build-arg coverage and runs the docker build.

  • npx vitest run __tests__/dispatch-supervisor.test.ts: 63/63 passed, including releases after a late answer on the received-journal replay too. Before the fix this test failed with 0 runtime.release calls.
  • npm run typecheck:dispatch: clean.
  • Full suite: 1288 passed, 2 failed, both in __tests__/transcript-retention.test.ts (chmod: illegal option -- -). The script calls GNU-style chmod, which macOS rejects. This PR doesn't touch that test or script.

🤖 Generated with Claude Code

Test run for the review's open INFO point: Vitest was run locally (macOS) on head `d77b152c1571f136e4d47d513f8740edead854e6`. CI does not run Vitest; it only validates compose, checks build-arg coverage and runs the docker build. - `npx vitest run __tests__/dispatch-supervisor.test.ts`: **63/63 passed**, including *releases after a late answer on the received-journal replay too*. Before the fix this test failed with 0 `runtime.release` calls. - `npm run typecheck:dispatch`: clean. - Full suite: 1288 passed, 2 failed, both in `__tests__/transcript-retention.test.ts` (`chmod: illegal option -- -`). The script calls GNU-style `chmod`, which macOS rejects. This PR doesn't touch that test or script. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
janpeter merged commit e5f9d3e5c9 into master 2026-10-08 21:25:28 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
janpeter/scrum4me-docker!119
No description provided.