Skip to content

review-dispatch: second dispatch in the same opencode session reuses the first dispatch's correlation ID and stale session metadata #760

Open

Description

@jflowers

Defect

Discovered during the /uf.unleash code-review gate on opsx/fix-triage-issue-dispatch-docs (2026-10-19): running a second review dispatch in the same opencode session (spec-review dispatch followed by code-review dispatch) causes consolidate_dispatch with provenance to fail closed with:

status: failed, operation_verdict: INCONCLUSIVE
errors:
  - artifact commit must equal the immutable reviewed head SHA
  - run <id> has no included plan entry

Root cause (verified in .opencode/plugins/review-dispatch/index.ts)

  • sessionCorrelationMap is an in-memory Map keyed by opencode sessionID (line ~571). dispatch_agent_run reuses the parent session's correlation ID on subsequent calls (lines ~2716-2721) and persists session_metadata only on the first call (line ~2725: if (isFirstCall && input.session_metadata !== undefined)).
  • The first dispatch (spec review, correlation 8b645d7b) persisted ITS metadata. The second dispatch (code review) reused 8b645d7b, its session_metadata argument was ignored, and its runs overwrote the agent-keyed run-divisor-<agent>.json files in the same session dir.
  • consolidate_dispatch reads session-metadata.json fresh from disk → stale first-dispatch metadata (mode specs, old head_sha, old plan) → finalizer validation fails on context mismatch and runs-without-plan-entries.

Impact

Any opencode session that runs two different review dispatches (e.g. spec review then code review via /uf.unleash) cannot finalize the second dispatch without manual intervention.

Suggested fix directions

  • Key the dispatch session by dispatch identity (e.g. derive a fresh correlation per dispatch_review_runs invocation), or
  • Persist/refresh session-metadata.json whenever a differing session_metadata argument arrives (last-writer-wins with run-store compatibility check), or
  • Version the session store per dispatch invocation within one opencode session.

Recovery performed (for the record)

Backed up the first dispatch's finalization artifact and session metadata, rewrote session-metadata.json in the transient dispatch session dir with the byte-identical metadata the second dispatch had passed (and the plugin dropped), and re-ran consolidate_dispatch with the same provenance. Validation then passed; the finalizer assigned a fresh correlation (9124cbb3) to the finalized artifact. The stale-metadata file lives in /var/folders/66/kwgz6_q10ln_8hgzmqt0tbjr0000gn/T/ (transient plugin scratch state, not a governance artifact); run data was never affected.

Related follow-ups from the same change: #755 (consolidate payload assessment-fields extension), #756 (speckit-testreview dispatch data-flow audit).

Activity

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

    @jflowers
    ContributorAuthor

    Divisor Triage: VALID — bug (objective)

    The panel classifies this issue as a valid bug with objective, code-level evidence. All five assessing personas (adversary, architect, curator, guard, sre) reached the same verdict.

    What the panel verified. The reported mechanism checks out against .opencode/plugins/review-dispatch/index.ts as filed on 2026-10-19: sessionCorrelationMap keys dispatch sessions by opencode sessionID, correlation resolution reuses the session's existing ID, and the first-call-only session_metadata persistence guard silently drops the second dispatch's metadata — so consolidate_dispatch reads stale first-dispatch metadata from disk and fails closed with "artifact commit must equal the immutable reviewed head SHA" and "run has no included plan entry". The recovery documented in the issue — rewriting session-metadata.json with the byte-identical metadata the plugin dropped, then re-running consolidation with the same provenance — isolates the stale metadata as the cause. Prior learnings record the identical failure signature recurring across at least four workflows between 2026-10-15 and 2026-10-23.

    Remediation status. Both root-cause components are fixed at current HEAD, implementing the issue's own suggested fix directions:

    Tests cover the correlation mint in four suites (.opencode/test/dispatch-review-runs.test.ts, dispatch-agent-run.test.ts, consolidate-dispatch.test.ts, dispatch-status.test.ts); openspec/changes/fix-review-dispatch-correlation-release/ and the CHANGELOG record the change.

    Recommended next steps.

    1. Re-run the original scenario end-to-end (spec-review dispatch, then code-review dispatch, in one opencode session; consolidate the second with provenance) to confirm the fix in a live session.
    2. Cross-link with review-dispatch: sessionCorrelationMap never releases the per-conversation correlation ID (root cause of #760 / #746) #794 (root cause; closed completed 2026-10-23) and review-dispatch: one dispatch session per conversation silently breaks uf.address-feedback per-item Tier 2 finalization #746 (same root cause, /uf.address-feedback manifestation).
    3. Close this issue as completed referencing fix-review-dispatch-correlation-release once the live verification passes.

    Duplicates: none found. #755 and #756 are distinct follow-ups already filed separately; #746 and #794 share the root cause but are not duplicates of this report.

    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