Repository navigation
fix(review-dispatch): recover dispatches stranded by failed child runs - #776
Conversation
ab2b1e6 to
d33ad07
Compare
jflowers
left a comment
There was a problem hiding this comment.
Note: The review council's verdict is REQUEST CHANGES. GitHub does not allow requesting changes on one's own pull request, so this review posts as a comment. The blocking HIGH finding below should be addressed before merge.
Review Summary
The review council (adversary, architect, curator, guard) ran on the full diff (31 files, +6533/−291). Three personas approved with advisories; the architect requested changes, and consolidation escalates one compound HIGH finding.
Blocking issue (HIGH): the recovery tools' run-file mutations are neither verified nor atomic. redispatch_failed_runs reports redispatched from in-memory data while executeDispatchRun's persistence is best-effort with a swallowed catch — a silently-failed write after the archive rename leaves the plan entry with no active run file while recovery reports success, recreating the exact #751 stranding this PR fixes, undetectably. discard_orphaned_submissions rewrites run files in place non-atomically; a mid-write failure truncates them permanently. Suggested fix: persistence-verified outcomes, restore-on-failed-write, and write-temp-then-rename — in both the live plugin and the scaffold twin.
Advisories (4 MEDIUM, 7 LOW): decomposition of the two new tool executes (repeated result literals), plus JSDoc, API-contract, spec-scenario, error-message consistency, zero-waste, and learning-hygiene items — detailed inline.
CI: all 17 checks pass. Pre-flight: ci-aware PASS, no local execution needed.
Request changes to address the HIGH persistence/atomicity finding before merge; the MEDIUM/LOW items can follow up.
This review was generated by /uf.review-pr (AI-assisted).
d33ad07 to
b11358a
Compare
Addresses PR unbound-force#776 review feedback from @jflowers. - Gate redispatch_failed_runs success on the run file actually reaching disk (outcome.persisted); a failed replacement write restores the archived prior run file like the throw path (items 1/4/5, DR-FR-002) - Write run files and discard rewrites atomically via temp-then-rename so a mid-write failure can never truncate a run record (item 2) - Route every redispatch and discard per-run result through single builders owning the no-change defaults (item 3) - Remove the dead harvestedFindings/harvestedProposals outcome fields (item 10) - Fail consolidate_dispatch closed as not_found for unresolvable correlation ids, mirroring dispatch_status envelopes (item 8) - Omit the empty warnings key from consolidate results, mirroring proposals (item 9) - Correct the dispatch-recovery test header (item 12) Signed-off-by: Jay Flowers <[email protected]> Assisted-by: glm-5
Addresses PR unbound-force#776 review feedback from @jflowers. - Add the malformed-correlation-id rejection scenario to the RD-FR-027 scenario list (item 7) - Sweep the stale RD-FR-009 reference to RD-FR-027 in the 214836 learning (item 11) - Record the review-dispatch learnings captured while assessing this feedback round Signed-off-by: Jay Flowers <[email protected]> Assisted-by: glm-5
jflowers
left a comment
There was a problem hiding this comment.
Note: The review council's verdict is REQUEST CHANGES. GitHub does not allow requesting changes on one's own pull request, so this review posts as a comment. The blocking HIGH finding below should be addressed before merge.
Review Summary
The review council (adversary, architect, curator, guard) ran on the full diff of head b11358a (32 files, +6533/−291) — the second iteration of this change. All four runs completed: two personas approved with advisories, two requested changes. 22 findings total (2 HIGH, 4 MEDIUM, 16 LOW).
Blocking issue (HIGH — architect + guard, adversary concurs): the redispatch success path still reports redispatched from in-memory runData without verifying that the replacement run file persisted to disk. executeDispatchRun's run-file write is best-effort with a swallowed catch ("Persistence is best-effort"), and the iteration-2 restore paths cover only runData === null (early exits) and thrown errors (pre-persistence) — a silent write failure after the prior run file is archived to superseded/ leaves the plan entry with no active run file while recovery reports success. Consolidation then fails plan validation ("included plan entry has no run"), a re-invoked redispatch reports not_found (the archived file is invisible to the discovery glob), and the session strands exactly as in #751 — now unrecoverable through the recovery tooling itself. This violates DR-FR-002's consolidatable-session MUST and is documented as known-unremediated in the change's own learning review-dispatch-20261020T000155. Fix: expose a persistence outcome from executeDispatchRun, gate the redispatched result and archive finality on it (restoring the archived file on failed write) or read the file back before reporting success — in both the live plugin and the scaffold twin.
Advisories: discard rewrite atomicity (MEDIUM — 3 personas concur: in-place writeFile truncates before writing; a torn write destroys both the run record and the DR-FR-003 audit trail; write-temp-then-rename precedent already exists in the redispatch archive step), result-literal decomposition (~280-line execute, 11+6 hand-repeated result literals; CS-004/CS-008), plus LOW items detailed inline: RD-FR-027 missing rejection scenario, consolidate_dispatch not_found contract alignment, shouldReclassifyToSuccess JSDoc tags, dead harvestedFindings/harvestedProposals outcome fields, stale RD-FR-009 learning citations.
Additional LOW findings not attached inline:
- The persisted learning
review-dispatch-20261019T214836-jay-flowers.md:10cites the stale pre-renumberingRD-FR-009ID (now RD-FR-025; RD-FR-009..018 reserved by optional-profile-models) — same defect curator flagged on214832. - The
dispatch-recovery.test.tsheader claimsscratch-redispatch-smoke.test.tswas "deleted in this same change"; no such file appears in the 32-file diff or the repo (architect + curator). - website#313 carries no
docslabel, unlike the website repo's convention for docs issues (#307, #309, #310, #312, #314, #316), weakening label-filtered discoverability (curator).
CI: all 17 checks pass (11 SUCCESS, 2 NEUTRAL, 4 SKIPPED). Pre-flight: ci-aware PASS — build/test/lint/plugin suite verified by CI on the head SHA; no local execution needed.
Request changes to close the HIGH persistence finding (and ideally the discard atomicity MEDIUM) before merge; the remaining MEDIUM/LOW items can follow up (several already tracked in #771).
This review was generated by /uf.review-pr (AI-assisted).
| })) | ||
| continue | ||
| } | ||
|
|
There was a problem hiding this comment.
HIGH — structural-integrity (divisor-architect): The redispatch success path reports outcome: "redispatched" from in-memory runData without verifying the replacement run file reached disk. executeDispatchRun persists best-effort — its writeFile failure path is caught and swallowed (line 3167, "Persistence is best-effort") — so non-null runData proves the run was computed, not written. The iteration-2 restore paths cover runData === null (early exits) and thrown errors (both pre-persistence); a silent write failure after the prior run file moves to superseded/ leaves the plan entry with no active run file while the operator reads a success result. Consolidation then fails plan validation, a re-invoked redispatch reports not_found (the archived file is invisible to the discovery glob), and the session strands exactly as in #751 — unrecoverable through the recovery tooling itself. The scaffold twin carries the identical gap. Expose a persistence outcome from executeDispatchRun, gate the redispatched result and archive finality on it (restoring the archived file on failed write), or read the file back before reporting success — in both this file and the scaffold twin.
| })) | ||
| continue | ||
| } | ||
|
|
There was a problem hiding this comment.
HIGH — spec-conformance (divisor-guard): This path violates DR-FR-002's MUST that a re-run leaving no replacement record restores the prior run file so the session "remains consolidatable." The "computed in memory, failed on disk" window — runData non-null, swallowed write failure, prior file already renamed to superseded/ — neither restores nor signals failure. The change's own retrospective learning (review-dispatch-20261020T000155) records this gap as unremediated in iteration 2; a self-authored learning documenting a same-change defect is an open fix obligation, which gates this verdict.
| }) | ||
|
|
||
| for (const { file, run } of targets) { | ||
| // Refuse successful runs (DR-FR-001): the request for this run is |
There was a problem hiding this comment.
MEDIUM — error-handling (divisor-adversary): discard_orphaned_submissions rewrites run files with a direct in-place writeFile. POSIX writeFile truncates before writing, so a crash mid-write leaves partial JSON that neither recovery tool can parse (reported as "unreadable"), requiring manual intervention to restore a consolidatable state. Learning review-dispatch-20261019T223123 documents this gap and recommends write-to-temp-then-rename; the redispatch archive step already establishes the rename precedent in this same change.
| }) | ||
|
|
||
| for (const { file, run } of targets) { | ||
| // Refuse successful runs (DR-FR-001): the request for this run is |
There was a problem hiding this comment.
MEDIUM — error-handling (divisor-architect): The in-place rewrite truncates the destination before writing; a mid-write failure (ENOSPC, EIO, process kill) destroys both the original record and the DR-FR-003 discarded_submissions audit trail the discard was supposed to annotate. The chmod-0444 test covers only the pre-truncation open failure — the truncation-to-completion window is unhandled and untested. Write the rewritten record to a temp file in the same directory and rename over the target (atomic on POSIX), preserving the original on any failure — in both the plugin and the scaffold twin.
| }) | ||
|
|
||
| for (const { file, run } of targets) { | ||
| // Refuse successful runs (DR-FR-001): the request for this run is |
There was a problem hiding this comment.
MEDIUM — data-integrity (divisor-guard): A torn write here both corrupts the active run file and destroys the audit block DR-FR-003 requires the discard to preserve — the original submissions are unrecoverable after a partial rewrite, and the plan entry's run drops out of consolidation with a plan-validation error. Mid-write corruption is neither tested nor mitigated. Learning review-dispatch-20261019T223123 records write-temp-then-rename as the established pattern for exactly this hazard and it remains unimplemented here.
| * consolidation warn (RD-FR-025). Successful runs are never touched; a | ||
| * successful run named in the agents filter is refused per run and reported | ||
| * in the machine-readable summary. Uses direct run-file rewrites only — | ||
| * never executeDispatchRun, since discard executes no child. |
There was a problem hiding this comment.
LOW — path-safety (divisor-adversary): Informational confirmation: the recovery tools' layered input validation is sound — UUIDSchema blocks traversal characters in correlation_id, AgentNameSchema constrains agent names, paths are built via join under the restricted OS temp dir (learning review-dispatch-20261020T000151). No path traversal vector exists under the schema constraints.
| // session (issue #751). When neither resolves, the tool fails closed as | ||
| // not_found with the same envelope dispatch_status emits for the | ||
| // condition (RD-FR-027, PR #776). | ||
| const correlationId = input.correlation_id ?? sessionCorrelationMap.get(context.sessionID) |
There was a problem hiding this comment.
LOW — api-contract (divisor-architect): For an unresolvable correlation_id, consolidate_dispatch returns a prose error ("no session metadata found ... pass session_metadata") while its three sibling tools return the structured not_found envelope via recoveryNotFoundOutput. The remediation advice misdirects a caller who already passed a correlation_id that resolves to nothing. RD-FR-027 defines not_found semantics for the recovery family; align this consumer so all four tools share one contract.
| tier: draft | ||
| --- | ||
|
|
||
| Recovery tools that operate on persisted run files (discard_orphaned_submissions, redispatch_failed_runs) use `JSON.parse(content) as PersistedRunData` without Zod validation, consistent with the pre-existing consolidate_dispatch and dispatch_status patterns. This is acceptable because the files live in a restricted OS temp directory and are written by the same plugin, but the recovery tools' design explicitly anticipates operator use on stale or hand-edited files (design R5). If a future change introduces external sources of run files or expands the recovery tools' scope, adding Zod validation on read would be a proportionate hardening step. |
There was a problem hiding this comment.
LOW — documentation-completeness (divisor-curator): This learning cites the pre-renumbering requirement ID "(RD-FR-009)"; the requirement it describes is now RD-FR-025, and RD-FR-009..018 is reserved by optional-profile-models. The stale citation now points at a different requirement and misleads future retrieval.
| * execution (policy load, agent validation, or model resolution failure): | ||
| * those early exits never wrote run files before the extraction and still | ||
| * do not. `persisted` records whether the run file actually reached disk; | ||
| * redispatch_failed_runs gates its success outcome on it (DR-FR-002). |
There was a problem hiding this comment.
LOW — zero-waste (divisor-guard): ExecuteDispatchRunOutcome.harvestedFindings and harvestedProposals are constructed and returned but consumed by no caller — redispatch_failed_runs reads runData.findings/.proposals directly and the dispatch_agent_run boundary ignores the outcome object. The fields duplicate runData contents and ship in the scaffold twin too; consume them (report harvested counts from redispatch) or remove them.
| superseded_run_file: `superseded/${supersededName}`, | ||
| reason: `the re-run exited before child execution and the prior run file could not be restored from superseded/${supersededName} to ${file} (${errorText(restore.error)}); operator intervention required — the agent has no active run file and the prior run is preserved in the superseded archive`, | ||
| error: outcome.result.error ?? undefined, | ||
| })) |
There was a problem hiding this comment.
LOW — error-handling (divisor-adversary): outcome.runData !== null is not a persistence signal: runData is populated in memory before the best-effort writeFile, whose failures are swallowed. The result reports redispatched even when no replacement run file exists on disk, while consolidation and recovery discovery read only the run-file directory — every downstream consumer disagrees with this report. (The HIGH findings on line 5857 trace the full stranding chain; this reviewer assesses the blast radius as bounded — a later consolidate_dispatch surfaces the missing file rather than silently approving — but the report/disk disagreement stands.)
A failed child run with already-accepted submissions permanently bricked dispatch finalization (issue unbound-force#751): consolidation harvested failed-run findings, the fail-closed finalizer rejected the payload, and no sanctioned recovery existed. - Scope consolidation payload to successful runs only; findings and proposals from non-success runs are excluded and surfaced as machine-readable orphaned-submission warnings - Recognize post-submission completion: a run that delivered its structured submissions is recorded completed, not failed, when the session aborts afterward - Add recovery operations: discard orphaned submissions (DR-FR-001) and partial re-dispatch of failed reviewers within the same dispatch session (DR-FR-002) - Surface per-run input-token usage in dispatch_status output - Add dispatch-recovery test suite (23 tests); sync scaffold asset twin byte-identical - Record Dewey learnings from the change workflow Assisted-by: glm-5 Generated with AI assistance (glm-5)
Addresses PR unbound-force#776 review feedback from @jflowers. - Gate redispatch_failed_runs success on the run file actually reaching disk (outcome.persisted); a failed replacement write restores the archived prior run file like the throw path (items 1/4/5, DR-FR-002) - Write run files and discard rewrites atomically via temp-then-rename so a mid-write failure can never truncate a run record (item 2) - Route every redispatch and discard per-run result through single builders owning the no-change defaults (item 3) - Remove the dead harvestedFindings/harvestedProposals outcome fields (item 10) - Fail consolidate_dispatch closed as not_found for unresolvable correlation ids, mirroring dispatch_status envelopes (item 8) - Omit the empty warnings key from consolidate results, mirroring proposals (item 9) - Correct the dispatch-recovery test header (item 12) Signed-off-by: Jay Flowers <[email protected]> Assisted-by: glm-5
Addresses PR unbound-force#776 review feedback from @jflowers. - Add the malformed-correlation-id rejection scenario to the RD-FR-027 scenario list (item 7) - Sweep the stale RD-FR-009 reference to RD-FR-027 in the 214836 learning (item 11) - Record the review-dispatch learnings captured while assessing this feedback round Signed-off-by: Jay Flowers <[email protected]> Assisted-by: glm-5
c3b2d5d to
2c069c4
Compare
…n contract The fix-dispatch-verdict-derivation change (issue unbound-force#764) made emission and validation share calculatedWorkflowValue, so a zero-success panel now finalizes as INCONCLUSIVE with a persisted artifact instead of being rejected by a value mismatch. Three pre-existing pins still asserted the superseded rejection envelope (status failed, mismatch errors, null artifact) and failed CI on 2c069c4. Align them with the canonical contract the unbound-force#764 regression test pins: status success, operation_verdict INCONCLUSIVE, empty errors, artifact persisted — the fail-closed verdict and RD-FR-025 warning behavior are unchanged. Fixes the Plugin Tests check on PR unbound-force#776. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: glm-5
Addresses PR #776 review feedback from @jflowers. - Gate redispatch_failed_runs success on the run file actually reaching disk (outcome.persisted); a failed replacement write restores the archived prior run file like the throw path (items 1/4/5, DR-FR-002) - Write run files and discard rewrites atomically via temp-then-rename so a mid-write failure can never truncate a run record (item 2) - Route every redispatch and discard per-run result through single builders owning the no-change defaults (item 3) - Remove the dead harvestedFindings/harvestedProposals outcome fields (item 10) - Fail consolidate_dispatch closed as not_found for unresolvable correlation ids, mirroring dispatch_status envelopes (item 8) - Omit the empty warnings key from consolidate results, mirroring proposals (item 9) - Correct the dispatch-recovery test header (item 12) Signed-off-by: Jay Flowers <[email protected]> Assisted-by: glm-5
Addresses PR #776 review feedback from @jflowers. - Add the malformed-correlation-id rejection scenario to the RD-FR-027 scenario list (item 7) - Sweep the stale RD-FR-009 reference to RD-FR-027 in the 214836 learning (item 11) - Record the review-dispatch learnings captured while assessing this feedback round Signed-off-by: Jay Flowers <[email protected]> Assisted-by: glm-5
Summary
Recovery tooling for Divisor review dispatches stranded by failed child
runs (issue #751). A failed child run with already-accepted submissions
permanently bricked dispatch finalization: consolidation harvested
failed-run findings, the fail-closed finalizer rejected the payload, and
no sanctioned recovery existed.
discard_orphaned_submissions(DR-FR-001 — empties findings/proposalsfrom non-success runs while preserving every other field verbatim,
with a
discarded_submissionsaudit block) andredispatch_failed_runs(DR-FR-002 — re-runs failed reviewers withtheir original persisted prompt and plan entry, archiving the prior
run file to
superseded/and restoring it when a re-run exits beforewriting its replacement).
correlation_idresolution onconsolidate_dispatch/dispatch_statusfor cross-session recovery (fail-closednot_found),session_metadatapersistence whenever supplied, andper-run token/cost usage reporting.
machine-readable orphaned-submission warnings.
24-test recovery suite, byte-identical scaffold twin, and CHANGELOG
entry.
Closes #751
How to Test
Manual scenario (DR-FR-002): in a session with a failed reviewer run,
call
redispatch_failed_runs— prior run file is archived tosuperseded/, replacement executed with the original prompt; on earlyexit or error the prior file is restored to its active path and the
session stays consolidatable.
How to Demo
Recovery suite:
cd .opencode && npx vitest run test/dispatch-recovery.test.ts— 24/24 pass. Full
make check: 33 files / 934 tests PASS, coverage94.69% statements (gate 90%), 87.38% branches (gate 85%).
Key Files Changed
.opencode/plugins/review-dispatch/index.ts(+1639) — recoverytools, success-scoped consolidation, status persistence
internal/scaffold/assets/opencode/plugins/review-dispatch/index.ts— scaffold twin, synced byte-identical
.opencode/test/dispatch-recovery.test.ts(new, +1256) — 24-testrecovery suite
.opencode/test/— consolidate-dispatch, dispatch-agent-run,dispatch-status, finalize-error-boundaries updates
openspec/changes/fix-review-dispatch-recovery/— proposal, design,spec deltas, tasks
.uf/dewey/learnings/— 16 learnings from the change workflowCHANGELOG.mdKnown Issues
Review council returned APPROVE WITH ADVISORIES (iteration 2; 4/4
personas approved, 0 blocking findings). 5 advisories accepted and
tracked in #771, including prompt/evidence trimming deferred from this
change.
This PR was generated by /uf.finale (AI-assisted).