Skip to content

fix: verify replacement run-file persistence before reporting redispatched outcome #771

Open

Description

@jflowers

Context

Review-council iteration 2 on opsx/fix-review-dispatch-recovery (artifact 69995229-876d-497b-ba3e-e770db2b143b) returned APPROVE WITH ADVISORIES with one MEDIUM advisory from divisor-guard.

Advisory

redispatch_failed_runs reports outcome redispatched whenever executeDispatchRun returns non-null runData, but runData non-null does not prove the replacement run file was persisted: executeDispatchRun's persistence step wraps mkdir/writeFile in a best-effort catch ("Persistence is best-effort; the result is authoritative.") and still returns runData. Because the prior run file is archived to superseded/ before execution, a silent replacement-writeFile failure leaves the plan entry with no active run file (dispatch_status blind, consolidate_dispatch rejectable, re-invoked redispatch not_found) while the summary falsely reports redispatched with a new_run_id that was never durably recorded.

The early-exit (runData === null) and thrown-error paths already restore the prior record (iteration-2 FIX 1); only the silent persistence-failure window lacks restore + accurate reporting.

Proposed fix

Before pushing the redispatched outcome, verify the replacement file exists at its active path (join(dir, file)) — or have executeDispatchRun report persistence success — and on verification failure restore the prior file exactly as the early-exit path does, reporting an error outcome instead. Extend dispatch-recovery.test.ts with a persistence-failure restoration test.

Related

Activity

  1. added
    bug
    on Nov 2, 2026
  2. jflowers commented on Nov 2, 2026

    @jflowers
    ContributorAuthor

    Triage Summary

    Verdict: VALID — bug (objective)

    The Divisor review panel assessed this issue across six personas (adversary, architect, curator, guard, SRE, testing). All six reach VALID with category bug.

    Assessment

    The defect report is accurate and verifiable against the code as it stood at filing:

    • redispatch_failed_runs reported outcome redispatched whenever executeDispatchRun returned non-null runData, but a non-null runData does not prove the replacement run file was persisted — the executor's persistence step wraps mkdir/writeFile in a best-effort catch and still returns runData.
    • Because the prior run file is archived to superseded/ before execution, a silent replacement-write failure left the plan entry with no active run file (dispatch_status blind, consolidate_dispatch rejectable, re-invoked redispatch_failed_runs reporting not_found) while the summary reported redispatched with a new_run_id that was never durably recorded.
    • The report precisely scopes the remaining gap: the early-exit (runData === null) and thrown-error paths already restored the prior record; only the silent persistence-failure window lacked restore plus accurate reporting.

    Fix status: already landed

    PR #776 (iteration 3 of the parent change fix-review-dispatch-recovery) implemented exactly what this issue proposes, and the fix is present in the current tree:

    • ExecuteDispatchRunOutcome.persisted, set only after a write-temp-then-rename completes in executeDispatchRun (.opencode/plugins/review-dispatch/index.ts:3384-3412)
    • the !outcome.persisted gate in redispatch_failed_runs that restores the archived prior file to its active path and reports an error outcome instead of redispatched (.opencode/plugins/review-dispatch/index.ts:7421-7445)
    • the requested persistence-failure restoration test in dispatch-recovery.test.ts ("reports an error outcome when the replacement run file cannot be persisted")
    • the gate is byte-identical in the scaffold twin (internal/scaffold/assets/opencode/plugins/review-dispatch/index.ts), which carries only merged canonical work

    The report was accurate and actionable when filed, so the verdict remains VALID. The recommended next step is to close this issue as completed referencing PR #776. Note that PR #776's code comments cite only the parent issue #751, so closing this follow-up requires an explicit reference to #776.

    Related issues

    This triage was performed by the Divisor review panel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions