Skip to content

refactor: consolidate review-dispatch test helpers and plan plugin module extraction #769

Open

Description

@jflowers

Summary

Follow-up from the fix-review-dispatch-recovery review council (iteration 1, architect LOW findings). Two structural refactors deliberately deferred out of the fix loop:

  1. Shared test helpers: .opencode/test/ now has seven files with locally-defined withBun copies (build-review-prompts, plugin-integration, submit-tools, dispatch-status, dispatch-review-runs, scratch-smoke, dispatch-recovery) and scratchProject defined locally in dispatch-recovery.test.ts. CS-004 requires extraction once identical logic exceeds two locations. Extract a shared helpers module under .opencode/test/ and import from all seven suites.

  2. Plugin module extraction: .opencode/plugins/review-dispatch/index.ts reached 5,992 lines after fix-review-dispatch-recovery (schemas, persistence, recovery tools, dispatch, consolidation in one file), dual-maintained byte-identical with internal/scaffold/assets/opencode/plugins/review-dispatch/index.ts. Plan a module extraction (schemas / persistence / recovery / dispatch / consolidation) preserving the byte-identical twin contract — either generating the scaffold twin at build time or extracting modules in both copies in lockstep, with TestEmbeddedAssets_MatchSource drift tests enforcing parity.

Context

Activity

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

    @jflowers
    ContributorAuthor

    Triage Summary

    The Divisor review panel assessed this issue as VALID — enhancement (objective) by a 5/5 persona majority (adversary, architect, guard, sre, testing).

    Verified against current repository state

    Item 1 — shared test helpers: the CS-004 violation persists, partially remediated since filing. A shared module now exists (.opencode/test/helpers/bun-runtime.ts:13 exports withBun; helpers/aggregate-dispatch-fixtures.ts exports makeScratchProjectFactory), and two of the seven originally-named suites (dispatch-status, dispatch-review-runs) have migrated to it. Six suites still define withBun locally (build-review-prompts.test.ts:20, plugin-integration.test.ts:38, submit-tools.test.ts:14, scratch-smoke.test.ts:23, dispatch-recovery.test.ts:29, and read-diff-chunk.test.ts:16 — a copy site that accreted after this issue was filed), and scratchProject remains locally defined in several suites. The remaining work is migration onto the existing helpers rather than extraction; a structural guard (for example, a test asserting no function withBun definitions outside helpers/) keeps the duplication from regenerating.

    Item 2 — plugin module extraction: the claim has strengthened. .opencode/plugins/review-dispatch/index.ts now measures 8,634 lines, up from 5,992 at filing. The byte-identical twin at internal/scaffold/assets/opencode/plugins/review-dispatch/index.ts and the TestEmbeddedAssets_MatchSource drift test (internal/scaffold/scaffold_test.go:96) define the parity constraint. The build-time-generation vs. lockstep-extraction decision is the governing design question and belongs in an OpenSpec design doc, because the build-time option re-points a governance gate.

    Recommendation: split

    The two refactors touch disjoint file sets and carry materially different risk profiles — item 1 is a mechanical, test-only migration with no twin-sync impact; item 2 is a production decomposition gated on an open design decision. The panel recommends splitting this issue into:

    1. Migrate remaining test suites to shared helpers — move the six remaining local withBun and scratchProject copies onto helpers/bun-runtime.ts and helpers/aggregate-dispatch-fixtures.ts, with a guard against new local copies.
    2. Plan review-dispatch plugin module extraction — a design-doc-first decomposition (schemas / persistence / recovery / dispatch / consolidation) that resolves the twin-contract strategy while keeping the drift test as the parity gate of record.

    Similar issues

    The duplicate search surfaced related but non-duplicate issues: #741 (decomposes the uf-workflow plugin — different file set, useful precedent for the twin-contract strategy), #771, #873, and #798 (unrelated).

    Proposed label: enhancement

    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

    enhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions