Skip to content

review-dispatch: sessionCorrelationMap never releases the per-conversation correlation ID (root cause of #760 / #746) #794

Closed

Description

@jflowers

Summary

Live reproduction during the 2026-10-23 triage series confirmed the root cause behind #760 (second dispatch reuses the first dispatch's correlation ID) and #746 (one dispatch session per conversation breaks finalization): the review-dispatch plugin intentionally binds exactly one dispatch correlation ID per opencode conversation and never releases it.

Root cause

.opencode/plugins/review-dispatch/index.ts (file REV 5538A3CC):

  • sessionCorrelationMap is a module-level Map<parent-session-ID, correlation-ID> (line 578) that lives for the opencode process lifetime. Only .get() and .set() are ever called on it — there is no delete, expiry, or reset path.
  • dispatchAgentRun mints a UUID on the first call from a parent session and reuses it for all subsequent calls in that session (documented at lines 568-577, implemented at lines 3270-3277):
let correlationId = sessionCorrelationMap.get(context.sessionID)
const isFirstCall = correlationId === undefined
if (isFirstCall) {
  correlationId = randomUUID()
  sessionCorrelationMap.set(context.sessionID, correlationId)
}
  • The same-session re-dispatch flow this supports is the fix loop (design D5 of fix-review-dispatch-recovery, review-dispatch: failed child run with accepted submissions bricks consolidate_dispatch finalization #751): re-dispatching the same review with an updated plan, where session metadata is replace-with-latest so consolidate_dispatch validates runs against the current plan (lines 3279-3285). The design contract is one dispatch session = one review workflow = one conversation. Running multiple different dispatch workflows (for example, several /uf.triage-issue runs) from one conversation is outside that contract and silently reuses the first workflow's correlation. dispatch_review_runs inherits the same binding (observed live, below), and neither dispatch_review_runs nor dispatch_agent_run exposes a correlation control — the explicit correlation_id escape hatch (design D3) exists only on the read/finalize side (consolidate_dispatch line 3714, dispatch_status line 4846).

Observed failure (live, 2026-10-23)

  1. /uf.triage-issue on Extract plugin helpers into shared libs (issue-reference + state-path) #782 dispatched 5 reviewers under correlation f38bb0f6-2e3e-4c4e-ba39-cef495379ed3 and finalized it (APPROVE / VALID, 2026-10-23T02:33:28Z) — record persisted to .uf/artifacts/dispatch/f38bb0f6-….json.
  2. /uf.triage-issue on fix: verify replacement run-file persistence before reporting redispatched outcome #771 from the same opencode conversation dispatched 6 reviewers (2026-10-23T02:36:47Z). The dispatch resolved the conversation's existing correlation and reused f38bb0f6.
  3. The dispatch-session state under a correlation is replace-with-latest, so fix: verify replacement run-file persistence before reporting redispatched outcome #771's run files, plan, and session metadata replaced Extract plugin helpers into shared libs (issue-reference + state-path) #782's. Extract plugin helpers into shared libs (issue-reference + state-path) #782's finalization artifact on disk was untouched — the dispatch does not write finalization artifacts.
  4. Had fix: verify replacement run-file persistence before reporting redispatched outcome #771 then been finalized, persistEnvelope's collision path would have engaged (see correction below): Extract plugin helpers into shared libs (issue-reference + state-path) #782's artifact survives, but fix: verify replacement run-file persistence before reporting redispatched outcome #771's finalization record would carry a correlation that does not match its dispatch session's run files — broken traceability between artifact and dispatch state.

Correction to the #746 failure-class framing: finalizing a second workflow under a reused correlation does not overwrite the first workflow's artifact. persistEnvelope publishes via hard link and on EEXIST retries with a freshly minted correlation_id (lines 2477-2515), so the second finalization lands under a new artifact UUID. The damage is linkage corruption (artifact correlation ≠ dispatch-session correlation), not data loss.

Fix directions

Any fix must preserve two existing contracts:

  • the fix-loop re-dispatch flow (design D5): same-workflow re-dispatches in one conversation share a correlation with replace-with-latest session metadata; and
  • the recovery tools (DR-FR-001 / DR-FR-002), which address a dispatch session purely by correlation_id.

Directions to consider:

  1. Per-dispatch correlation keying. Mint a fresh correlation per dispatch_review_runs invocation (content-keyed, or a per-session dispatch counter), updating sessionCorrelationMap to the newest correlation so consolidate_dispatch auto-resolution keeps working. Fix-loop iterations would each get their own dispatch dir; redispatch_failed_runs' reuse of run files under one correlation needs re-examination under this model.
  2. Explicit release/reset. Expose dispatch-side correlation control symmetric to design D3: consolidate_dispatch and dispatch_status already accept an optional explicit correlation_id for cross-session use, but there is no way to ask a dispatch for a fresh correlation or to release the session binding (a new_dispatch flag, a correlation_id input on the dispatch tools, or a reset tool).

Salvage option for #771 (no re-dispatch required)

From a fresh opencode session, run consolidate_dispatch with explicit correlation_id: f38bb0f6-2e3e-4c4e-ba39-cef495379ed3 plus provenance. The dispatch-session state under that correlation currently holds #771's panel result (5/5 VALID; 4 of 5 personas verified the issue's fix already landed via PR #776, so the likely disposition is close-as-completed linking #776). Finalization validates those runs and — via the EEXIST collision path — persists under a fresh artifact UUID, leaving #782's artifact intact. The payload will also re-surface #771's five not-yet-stored lesson proposals.

Relations

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions