Skip to content

Seam verification for prose→tool migrations: registration surface, golden output-shape, and round-trip tests (DE-007) #765

Closed

Description

@jflowers

Seam verification for prose→tool migrations: registration surface, golden output-shape, and round-trip tests (DE-007)

Related: #659 (token-reduction epic), #758 (DE-005/DE-006 — numbering dependency), #735 (first application of Layer 2), #716 (the migration that surfaced the defect class). Provenance: learnings determinism-20261016T202416 (drift tests only pin what they explicitly assert) and review-dispatch-20261014T165445 (learnings flag defects that persist in merged candidates).

Summary

Since #674, the closed-issue stream is dominated by one defect class: breakage at the seams the prose→tool migration created, found in live use rather than by any verification layer. The migration moved code across the prose/tool boundary; verification stayed behind. Unit tests verify tool interiors (DI'd execute paths), the review council reasons statically about diffs, and the plugin smoke tests assert tool names only — never their schema surfaces (.opencode/test/uf-workflow.test.ts:133, uf-finale.test.ts:80). Nothing executes the seams.

This issue adds three mechanical test layers that verify the seams, and codifies them as determinism rule DE-007 so every future migration increment ships them.

Evidence

Issue Defect Seam Caught by
#732 parameters: vs SDK args: — empty schemas exposed to the model; hard break in two consecutive finales tool ↔ SDK registration Layer 1
#735 (open) triage-issue prose documents findings/proposals/warnings arrays that dispatch_review_runs does not return prose ↔ tool output contract Layer 2
#707/#737 unleash-summary artifact never written; command-layer invocation unpinned while suite stayed green writer tool ↔ reader command Layer 3
#693 advisor runs with empty profiles resolved no model dispatch ↔ model resolution Layer 2, where prose documents the behavior
#685 console.debug surfaced in the OpenCode UI plugin ↔ host output channel adjacent (no-console lint, see Out of scope)
#687/#688 phantom files in review diff from stale local main prose git recipe ↔ environment adjacent (DE-001 completion + staleness guard)
#712 gh api --slurp + --jq flags incompatible; triage ingestion halted prose shell incantation ↔ CLI reality adjacent (DE-001 completion)

Three layers catch the three highest-impact classes mechanically; the adjacent classes are DE-001 completion work already governed by the existing rule (prose incantations are untested code that belongs in scripts/tools) plus one lint and one staleness guard, deliberately kept out of this issue's scope.

The three test layers

Layer 1 — Registration surface test (catches #732 class)

What: For every registered tool in every plugin (uf-workflow, uf-finale, review-dispatch, invoke-agent), assert through the SDK's actual registration path that:

  1. The exposed parameter schema is non-empty exactly when the tool declares parameters (empty == empty is correct — resolve_base_ref takes none)
  2. The exposed schema's keys are in parity with the keys the execute path validates (the zod shape)
  3. A factory that regresses to a mis-keyed or non-zod declaration (parameters: plain objects, the uf-workflow and uf-finale tools expose empty parameter schemas to the model (parameters: vs SDK args: mismatch) #732 root cause) fails the suite

Where: extend the plugin smoke tests (uf-workflow.test.ts, uf-finale.test.ts) or add registration-surface.test.ts; run under make plugin-test. Mechanism note for the implementer: @opencode-ai/plugin 1.4.10's tool() helper expects args: z.ZodRawShape and silently ignores anything else — the test must assert on what the SDK actually exposes (or on the structural presence of a valid args shape per tool), not on the factory's self-description. The #732 issue body documents the exact failure mechanism.

Proof bar: the test must fail if any factory reverts to its pre-#732 declaration form.

Layer 2 — Golden output-shape contract tests (catches #735 class)

What: Every output-format example preserved in command prose (the DE-002 arrow-notation examples: Call <tool> with <input> → {consumed fields}) is pinned by a test that executes the tool with DI'd dependencies and asserts the documented fields are present in the returned envelope.

Where: alongside the existing per-tool vitest files in .opencode/test/.

Discovery: enumerate documented examples by scanning command markdown for the arrow-notation pattern; each hit names a tool and its consumed fields. A small script or an in-test fixture list is sufficient — a prose-lint that requires a golden test per example is an optional enhancement, not a gate.

First application forces #735 to resolve: the golden test for dispatch_review_runs fails until either the tool returns the documented arrays or the prose is corrected — test and prose must agree, which is the entire point. File the direction decision (change tool or change prose) under #735.

Layer 3 — Writer↔reader round-trips and command-layer pins (catches #707/#737 class)

What:

  1. Artifact round-trips: artifact-producing tools tested against their consumers end-to-end — write_unleash_summary → uf_finale_pr_context read path (field survival through the shared sanitizeSlug derivation and JSON round-trip); finalize_review_dispatch artifact → uf_unleash_detect_resume parse path.
  2. Command-layer invocation pins (the four from learning determinism-20261016): for each tool invocation a command depends on, pin (a) the invocation's presence within the consuming step's span, (b) the named parameters that define the input contract, (c) absence of superseded tool names, (d) the count of removed ceremony markers. Go tests in internal/scaffold/ following the existing TestUnleashCommand_* precedent; the byte-identical scaffold mirror means one command-text assertion covers canonical and embedded copies.

Known gap to close first: per the learning, the write_unleash_summary invocation in uf.unleash Step 10 is currently unpinned — deleting it or reverting to the superseded persist_unleash_summary 3-argument shape keeps the suite green. That pin is the acceptance proof for this layer.

DE-007 — the increment checklist as a pack rule

Add to .opencode/uf/packs/determinism.md (draft text):

- **DE-007** [MUST] A prose→tool migration increment MUST verify the
  seams it creates in the same increment: (1) registration surface —
  every new or modified tool exposes a parameter schema through the
  plugin SDK's registration path in parity with its execute-path
  validation; (2) documented output shape — every output-format
  example preserved in instruction text (DE-002) is pinned by a
  contract test asserting the tool returns that shape; (3)
  round-trips — artifact-producing tools are tested against their
  consumers, and command-layer invocations are pinned for presence,
  named parameters, superseded-name absence, and ceremony-marker
  count. A migration increment whose seam tests are red or absent
  is not complete.

Pack changes:

Retroactivity: none required, per the pack's own migration rule (existing prose migrates opportunistically). The in-flight migrations — #757 (Step 6 lifecycle), #664 (post_github_review), and #758's own follow-on migrations — MUST apply DE-007 when they land.

Out of scope (adjacent follow-ups, not this issue)

Acceptance criteria

Spec workflow

OpenSpec change (opsx/seam-verification or similar), modeled on determinism-codification: code + tests + one pack rule in a single change, spec delta pinning DE-007's ID/severity the way that change pinned DE-001..DE-004.

Metadata

Metadata

Assignees

Labels

enhancementllm_assisted

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions