Skip to content

fix(review-dispatch): per-invocation correlation for dispatch sessions - #809

Merged
jflowers merged 9 commits into
unbound-force:mainfrom
jflowers:opsx/fix-review-dispatch-correlation-release
Oct 23, 2026
Merged

jflowers merged 9 commits into
unbound-force:mainfrom
jflowers:opsx/fix-review-dispatch-correlation-release

Conversation

@jflowers

Copy link
Copy Markdown
Contributor

Summary

Per-invocation dispatch correlation for the review-dispatch plugin (issue
#794; symptoms #760/#746). Each dispatch_review_runs invocation now mints
a fresh correlation ID immediately after input validation and persists its
prompts, run files, and session metadata under its own dispatch session
directory, re-pointing sessionCorrelationMap to the latest dispatch — so
consecutive workflows from one conversation (unleash spec-then-code review,
address-feedback per-item dispatches, consecutive triage/review-pr runs) get
isolated sessions instead of clobbering each other, and prior sessions
survive as an audit trail retrievable by explicit correlation_id.

The dispatch output reports correlation_id on every post-validation return
path (all-skip, prompt-failure, success, budget-exhaustion), making each
session explicitly addressable, symmetric with the read-side D3 control.
The fix loop (D5) is preserved by reframing — each iteration is already a
full re-dispatch, so each becomes a self-contained session; the recovery
tools (DR-FR-001/002) are untouched; direct dispatch_agent_run fan-out
semantics are unchanged (RD-CR-003).

The scaffold twin is synced byte-identical; 16 net-new + 1 rewritten
regression tests cover the #794 reproduction and fail-closed semantics;
shared test fixtures were extracted to
.opencode/test/helpers/aggregate-dispatch-fixtures.ts; CHANGELOG entry
added; docs issues filed in both repos (in-repo #808,
unbound-force/website#319).

Closes #794

How to Test

Run the gate suite from the repo root:

  • make plugin-test — 39 files, 1244 tests, 95.3% statements (94% floor)
  • make check — lint, go test -race (all 13 packages), build, coverage
    gate, plugin tests
  • bash council-review-action/test/test-pipeline.sh — 91 assertions
    (CI parity)
  • go test -race -count=1 ./internal/scaffold/... — scaffold-twin drift
    detection (byte-identical mirror)

Key regression scenarios covered by the new tests:

  • Two dispatch_review_runs invocations from one parent session mint
    distinct correlations with distinct session dirs; the first session's
    run files and metadata survive the second invocation (the review-dispatch: sessionCorrelationMap never releases the per-conversation correlation ID (root cause of #760 / #746) #794
    reproduction).
  • All-skip / prompt-failure invocations re-point the session map so
    no-provenance retrieval fails closed as not_found; an explicit
    correlation_id still retrieves the earlier payload.
  • The dispatch output reports the invocation's correlation_id on every
    post-validation return path (renders "none" for pre-parse validation
    failure).
  • Direct dispatch_agent_run fan-out shares one session; a direct call
    after an aggregate dispatch joins the latest aggregate session.

How to Demo

In one opencode conversation, run two consecutive review dispatches (e.g.
/uf.unleash spec review then code review, or two /uf.triage-issue
runs): each dispatch_review_runs result now reports its own
correlation_id, and dispatch_status / consolidate_dispatch with the
first invocation's explicit correlation_id still returns that session's
runs after the second workflow has run — no more clobbered sessions or
stranded findings.

Key Files Changed

  • .opencode/plugins/review-dispatch/index.ts — per-invocation
    correlation mint, session-dir persistence, correlation_id reporting
    on all return paths (+97)
  • internal/scaffold/assets/opencode/plugins/review-dispatch/index.ts —
    scaffold twin, synced byte-identical (+97)
  • .opencode/test/dispatch-review-runs.test.ts — review-dispatch: sessionCorrelationMap never releases the per-conversation correlation ID (root cause of #760 / #746) #794 reproduction and
    fail-closed semantics (rewritten, 549)
  • .opencode/test/helpers/aggregate-dispatch-fixtures.ts — extracted
    shared dispatch fixtures (new, 247)
  • .opencode/test/dispatch-agent-run.test.ts,
    consolidate-dispatch.test.ts, dispatch-status.test.ts —
    latest-dispatch resolution, direct fan-out, post-aggregate joining
  • CHANGELOG.md — correlation release entry
  • openspec/changes/fix-review-dispatch-correlation-release/ —
    proposal, design, spec delta, tasks
  • .uf/dewey/learnings/ — 12 retrospective learnings from the workflow

Known Issues

This PR was generated by /uf.finale (AI-assisted).

…ewRuns

Implements RD-CR-001..003 for unbound-force#794: dispatchReviewRuns mints a fresh
correlation ID after input validation and re-points sessionCorrelationMap
(latest-wins), so consecutive aggregate dispatches from one conversation
no longer clobber each other. correlation_id is now reported on every
post-validation return path. Scaffold twin synced byte-identical.
Task 4.1 of fix-review-dispatch-correlation-release for unbound-force#794: replace
the FR-007 "correlation is shared" assertion with the RD-CR-001..002
lifecycle. Two aggregate dispatches from one parent session now mint
distinct correlations with distinct dispatch session dirs, and the
first session's run files, prompts, and metadata survive the second
invocation. All-skip and prompt-failure invocations re-point the
session map at a session-less correlation so no-provenance
consolidation fails closed as not_found while the earlier session
stays addressable by explicit correlation_id. The output summary and
metadata report the invocation's correlation_id ("none" on the
pre-parse validation-failure path), and prompts are asserted to land
under the session's prompts/ dir. Full suite: 39 files, 1188 tests,
statements coverage 95.24% (94% floor held).
…e/status

Extends task 4.2 of fix-review-dispatch-correlation-release for unbound-force#794
(RD-CR-001): after two real aggregate dispatches from one parent session,
no-provenance consolidate_dispatch and dispatch_status resolve the latest
session while an explicit correlation_id retrieves the earlier session's
payload (its run files and session metadata survive the second
invocation). An all-skip invocation re-points the map at a session-less
correlation, so no-provenance retrieval fails closed as not_found while
the explicit id still recovers the earlier dispatch. Dispatch sessions
are driven through dispatch_review_runs with the fake-client
scratch-project pattern — no network, no live providers.
…n joining

Extends dispatch-agent-run.test.ts with the RD-CR-003 regression
guards for task 4.3 of fix-review-dispatch-correlation-release:
direct multi-call fan-out mints the correlation on the first call
and reuses one session (all run files land under a single dispatch
directory), and a direct dispatch_agent_run following an aggregate
dispatch_review_runs joins the latest aggregate session's
correlation. Per-invocation minting in dispatchAgentRun would
shatter direct fan-out into N sessions that consolidation cannot
validate as one plan; dispatchAgentRun itself is unchanged
(design D2).

Assisted-by: glm-5
Generated with AI assistance (glm-5)
Also marks all fix-review-dispatch-correlation-release tasks complete
in tasks.md.
- docs: file website issue unbound-force#319 for the dispatch-session lifecycle
  change and extend the CHANGELOG citation (Docs: unbound-force#808)
- refactor(test): extract aggregate-dispatch fixtures duplicated
  across four suites into test/helpers/aggregate-dispatch-fixtures.ts
- fix: resolve post-dispatch findings collection with the
  invocation's own minted correlation instead of a session-map
  re-read, keeping collection self-consistent under concurrent
  invocations from the same parent session

Scaffold mirror synced byte-identical.
Capture knowledge artifacts from the
fix-review-dispatch-correlation-release workflow sessions:

- review-dispatch: correlation lifecycle, latest-dispatch
  resolution, and code council feedback (5 learnings)
- content-pipeline: triage pipeline patterns (2 learnings)
- documentation-pipeline: doc gate patterns (1 learning)
- openspec: workflow clarification patterns (2 learnings)
- uf-unleash: tier-routing and resume learnings (2 learnings)

Assisted-by: glm-5
Generated with AI assistance (glm-5)
@jflowers
jflowers requested a review from a team as a code owner October 23, 2026 15:37
@jflowers jflowers self-assigned this Oct 23, 2026

@jflowers jflowers left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Divisor Council Review — APPROVE WITH ADVISORIES

Council verdict: APPROVE WITH ADVISORIES — 3 successful personas (2× APPROVE WITH ADVISORIES, 1× APPROVE); 1 adversary run failed with a retryable infrastructure error and does not vote.

Summary

This change gives each dispatch_review_runs invocation its own correlation ID minted after input validation, persists prompts, run records, and session metadata under a per-invocation session directory, and reports correlation_id on every post-validation return path. This removes the single-correlation-per-conversation clobbering documented in #794. Sixteen net-new regression tests cover the live repro, fail-closed retrieval, and direct fan-out semantics; the scaffold twin is synced byte-identical.

Findings (5 advisories, non-blocking)

Severity File Finding
MEDIUM design.md:144 RD-FR-027 supersession reconciliation has no executable owner (architect)
MEDIUM design.md:145 Archive step lacks authority over other changes' requirements (guard)
LOW specs/review-dispatch/spec.md:9 RD-CR prefix band lacks numbering-note convention (architect)
LOW index.ts:4622 Internal dispatchAgentRun resolves correlation via shared latest-wins map (guard)
LOW tasks.md:112 website#319 docs-gate half not recorded in tasks.md (architect)

Full details in inline comments. CI: all 11 checks pass. Pre-flight: all local tools covered by CI.

This review was generated by /uf.review-pr (AI-assisted).

and still applies to direct run calls joining an existing session.
RD-FR-027's "Session metadata refreshed on re-dispatch" scenario
remains satisfiable through direct run calls; its fix-loop
example is superseded by RD-CR-001's self-contained-iteration

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM — spec-integrity: The reconciliation D4 assigns to "the archive step" has no executable owner. The delta contains no MODIFIED Requirements section for RD-FR-027, and no tasks.md task edits the registry requirement. OpenSpec archive syncs only the archiving change's own delta, so after #751 and this change both archive, the registry carries contradictory guidance (replace-with-latest vs self-contained iteration) in a family whose IDs are load-bearing for review-dispatch recovery. The retrospective learning openspec-20261023T120157 documents this gap and prescribes the fix — a MODIFIED Requirements section for RD-FR-027 in this delta (viable since R6 documents this change archives after #751) or an explicit tasks.md item that edits the registry requirement at archive time.

RD-FR-027's "Session metadata refreshed on re-dispatch" scenario
remains satisfiable through direct run calls; its fix-loop
example is superseded by RD-CR-001's self-contained-iteration
scenario, and the archive step should reconcile that example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM — spec-consistency: The cleanup D4 defers to "the archive step" has no owner with authority over another change's requirements: no MODIFIED Requirements section for RD-FR-027 in this delta and no tasks.md task edits the registry requirement. The retrospective learning documents the remediation; applying it here (a MODIFIED Requirements section or an explicit archive-time task) closes the gap.


### Requirement: Dispatch Session Correlation Lifecycle

**ID: RD-CR-001** This requirement MUST be satisfied.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW — spec-conventions: The new prefix band RD-CR-001..003 departs from the family's allocation-managed namespace (RD-FR-001..008, 009..018 reserved, 019..024 review-matrix with an explicit numbering note, 025..027 fix-review-dispatch-recovery, DR-FR-001..003 dispatch-recovery) without a numbering note. Continuing as RD-FR-028+ or adding the note keeps the registry convention intact.

// that dispatch no runs (all-skip or prompt failure) pointing at a
// session-less correlation, so later no-provenance retrieval fails closed
// as not_found instead of returning the previous workflow's payload.
const correlationId = randomUUID()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW — session-isolation: Internal dispatchAgentRun calls resolve correlation by re-reading the shared sessionCorrelationMap after the per-invocation mint re-points it. Concurrent interleaved aggregate invocations from one parent session could persist run A's records under session B while reporting A's own correlation_id. All current command flows are sequential, so no live workflow is affected, and D6 documents the deferral. Threading the minted correlation to the internal run calls as a function parameter removes the residual.

self-describing artifacts (I).
- [x] 5.4 Add the change entry to `CHANGELOG.md` (user-facing
dispatch behavior change).
- [x] 5.5 File the in-repo documentation issue for the

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW — documentation-gate: Task 5.5 records only the in-repo documentation-issue half (#808) of the documentation gate. The unbound-force/website#319 half — executed during the review-council fix iteration and cited in the CHANGELOG — has no tasks.md task, so the archived record understates the four-task docs-gate template from #751 (tasks 8.4-8.7). Adding a task that records the website-issue half preserves the template.

@jflowers
jflowers merged commit 42d826e into unbound-force:main Oct 23, 2026
17 checks passed
@jflowers
jflowers deleted the opsx/fix-review-dispatch-correlation-release branch November 15, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant