Skip to content

fix(plugins): declare tool args as zod shapes for SDK schema exposure - #744

Merged
jflowers merged 10 commits into
unbound-force:mainfrom
jflowers:opsx/fix-tool-args-schema-mismatch
Oct 17, 2026
Merged

jflowers merged 10 commits into
unbound-force:mainfrom
jflowers:opsx/fix-tool-args-schema-mismatch

Conversation

@jflowers

Copy link
Copy Markdown
Contributor

Summary

Closes #732

Change fix-tool-args-schema-mismatch: 11 opencode plugin tool factories — 8 in uf-workflow (checkpoint, get_progress, clear_progress, normalize_model_name, git_fetch, git_push, git_merge, git_rebase) and 3 in uf-finale (uf_finale_commit_context, uf_finale_create_pr, uf_finale_ci_poll) — converted from plain parameters: objects (silently ignored by @opencode-ai/plugin 1.4.10, which stripped runtime args and exposed empty schemas) to the SDK-recognized args: zod contract, preserving every parameter name, type, optionality, and description exactly. Execute bodies, return envelopes, and error guards (e.g. INVALID_PR_NUMBER) are untouched as defense-in-depth.

The change adds 12 schema-exposure regression tests (9 uf-workflow including a persist_unleash_summary future-regression guard, 3 uf-finale) asserting Object.keys(definition.args) equality, byte-identical scaffold mirrors under internal/scaffold/assets/opencode/plugins/, a CHANGELOG entry, and documentation-gate issues #740 + unbound-force/website#310.

The fix was dogfooded live: the checkpoint/get_progress tools broken throughout the pipeline run (the exact bug being fixed) worked immediately after the opencode restart that loaded the fixed plugin code.

How to Test

  • make plugin-test — 23 test files, 621 tests, including the 12 new schema-exposure tests
  • go test -race -count=1 ./internal/scaffold/... — embedded-asset drift tests prove the scaffold mirrors are byte-identical
  • make check — full CI parity (lint, test, build, coverage gate, plugin tests)
  • grep -c "parameters:" .opencode/plugins/uf-workflow/index.ts .opencode/plugins/uf-finale/index.ts internal/scaffold/assets/opencode/plugins/uf-workflow/index.ts internal/scaffold/assets/opencode/plugins/uf-finale/index.ts — 0 matches in all four files (FR-001)
  • Live check: invoke checkpoint/get_progress in a fresh opencode session — both now respond ok instead of CHECKPOINT_ERROR

How to Demo

In a fresh opencode session on this branch, invoke /uf.unleash or /uf.finale and watch the workflow tools (checkpoint, get_progress, git_push, uf_finale_ci_poll) execute as model-invoked tools rather than falling back to bash.

Key Files Changed

  • .opencode/plugins/uf-workflow/index.ts (+44/−75) — 8 tool factories converted to zod args
  • .opencode/plugins/uf-finale/index.ts (+16/−29) — 3 tool factories converted + zod import
  • .opencode/test/uf-workflow.test.ts (+78) — 9 schema-exposure regression tests
  • .opencode/test/uf-finale.test.ts (+33) — 3 schema-exposure regression tests
  • internal/scaffold/assets/opencode/plugins/{uf-workflow,uf-finale}/index.ts — byte-identical mirrors
  • CHANGELOG.md — Fixed entry
  • openspec/changes/fix-tool-args-schema-mismatch/ — 5 spec artifacts
  • .uf/dewey/learnings/ — 15 learnings (spec-review proposals, code-review proposals, retrospective)

Known Issues

Review council verdict: APPROVE WITH ADVISORIES (4/4 reviewers succeeded). Unresolved advisories:

  • MEDIUM (design.md:91): D3 overstates the tsc drift guard — optional-to-required drift is tsc-silent; FR-002 optionality/description fidelity rests on review inspection (follow-up recorded in learnings)
  • LOW (uf-workflow/index.ts:624): git_fetch passes model-provided remote/branch without format validation (pre-existing; execFileSync array form prevents shell injection)
  • LOW (spec.md:156): FR-006 wording names only the in-repo doc gate; both gates were satisfied in execution (docs: record restored plugin tool parameter behavior (fix-tool-args-schema-mismatch) #740 + website#310)
  • LOW: duplicate learnings (scaffold-mirrors vs scaffold-parity) under different tags
  • LOW (design.md:91): D3 text contradicts the tsc-silent-drift learning
  • LOW: same duplicate-learnings zero-waste concern

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

@jflowers
jflowers requested a review from a team as a code owner October 16, 2026 17:10
@jflowers jflowers self-assigned this Oct 16, 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.

Council Review: APPROVE WITH ADVISORIES

Four Divisor reviewers (adversary, architect, curator, guard) assessed this change; all four returned APPROVE WITH ADVISORIES. The council verdict maps to this COMMENT event. Two MEDIUM and four LOW advisories follow; none block the merge.

What holds up

  • All 11 tool factory conversions declare SDK-conformant zod args: shapes; execute bodies stay byte-identical, types and optionality match the prior annotations, and no .default() appears.
  • Scaffold mirrors under internal/scaffold/assets/ match the live plugin files byte for byte; the diff blob hashes agree.
  • Runtime guards (INVALID_PR_NUMBER, targetRepo regex) survive as defense in depth.
  • Issue #732's three acceptance steps (rename, zod conversion, schema-exposure tests) are covered 3/3.
  • Documentation gates satisfied: #740 and unbound-force/website#310; CHANGELOG entry present.
  • All 16 CI checks non-failing (11 pass, 2 neutral, 3 skipped).

Advisories

MEDIUM

  1. Test guard gap (architect), .opencode/test/uf-workflow.test.ts:1664: schema-exposure tests assert key names only; optional-to-required drift passes both the assertion and tsc. Zod introspection assertions would pin FR-002 fidelity.
  2. D3 overstates the tsc guard (guard, curator concurring), design.md:91: the assignability guarantee is one-directional; a supersession note or amendment would reconcile it with the co-committed learning.

LOW
3. FR-006 wording (architect, curator, guard), spec.md:147: requirement text names only the in-repo docs gate; the cross-repo rule it satisfies in practice is absent from the text.
4. git_fetch input validation (adversary, pre-existing), .opencode/plugins/uf-workflow/index.ts:624: model-provided remote/branch reach execFileSync unvalidated; the array form blocks shell injection.
5. Duplicate learnings (architect, curator, guard): scaffold-parity vs scaffold-mirrors, and the documentation-gate pair, fragment semantic search.
6. Docs issue label (curator), tasks.md:84: #740 lacks the docs label Curator's gate query expects.

Dispatch provenance

Run Agent Model Verdict
7df70719 adversary claude-opus-4-6 (heavy) APPROVE WITH ADVISORIES
44c50a7d architect glm-5-3 APPROVE WITH ADVISORIES
a7801bd9 curator glm-5-3 APPROVE WITH ADVISORIES
f9acd209 guard glm-5-3 APPROVE WITH ADVISORIES

Skipped: envoy, herald, scribe (content-capability); sre, testing (scope-miss). Correlation: 8dcc9362-dced-49c5-b2bf-e782eb6f2dde.

from what I can tell, the conversion is faithful and the contract holds; the advisories are guard gaps and documentation polish rather than defects in what shipped.

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

// Tool args schema exposure regression tests (fix-tool-args-schema-mismatch)
// ---------------------------------------------------------------------------

describe("tool args schema exposure", () => {

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-architect] MEDIUM, advisory

The 12 schema-exposure tests assert sorted Object.keys(definition.args) equality only. They satisfy FR-004, yet FR-002's optionality and description fidelity rest on review inspection alone. Would an optional-to-required drift, say timeoutMinutes: z.number().optional() becoming z.number(), pass both the key assertion and tsc? Assignability runs one direction, so a required zod-inferred field stays assignable to an optional-annotated execute param. The SDK would then silently reject previously valid calls, such as uf_finale_ci_poll without timeoutMinutes. Wondering if zod introspection assertions, for example expect(shape.timeoutMinutes.isOptional()).toBe(true), could pin the contract; the learning plugin-tool-schemas-20261016T132705 sketches this guard.


The existing inline `execute: async (args: { ... })`
annotations remain valid: the zod-inferred types are assignable
to them, and any drift would surface as a `tsc`/vitest failure

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-guard, divisor-curator concurring] MEDIUM, advisory

D3 states any drift between zod-inferred types and execute annotations would surface as a tsc or vitest failure rather than a silent break. That guarantee runs one direction only; tsc catches required-to-optional drift, not optional-to-required. With FR-004 tests asserting key names alone, a regression making data, key, branch, or timeoutMinutes required would pass both gates while tightening the model-visible contract. The claim also reads against the co-committed learning plugin-tool-schemas-20261016T132705. Could D3 gain a supersession note, or an amendment narrowing the claim to the direction tsc actually guards?

description: "Optional branch name to fetch",
},
args: {
remote: z.string().describe(

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-adversary] LOW, advisory, pre-existing

git_fetch passes model-provided remote and branch strings to execFileSync without format validation. The array form rules out shell injection, so the remaining surface is arbitrary remote names, including URLs with embedded credentials. Worth checking whether a lightweight remote-name pattern and branch-name guard would close that? Flagging as defense in depth; this predates the change under review.

The change MUST add a `CHANGELOG.md` entry describing the fixed
parameter-schema exposure. The documentation gate MUST be
assessed before PR submission: a documentation issue MUST be
filed in this repository for any user-facing impact (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.

[divisor-architect, curator and guard concurring] LOW, advisory

FR-006 names only the in-repo documentation gate. The org constitution's cross-repo documentation rule also asks for a unbound-force/website issue before merge. Both gates were satisfied in practice, #740 and website #310, recorded in tasks.md 4.2. Is the narrower wording intentional, or worth a one-line amendment so the requirement text matches the constitution it cites?

tier: draft
---

Identical git diff index pairs across canonical and scaffold-mirror files prove byte-identical parity, and mismatched pairs are immediate drift evidence — treat the Go drift test suite (internal/scaffold) as the CI backstop rather than the only check. This pattern from the fix-tool-args-schema-mismatch review (uf-workflow and uf-finale plugin mirrors) gives reviewers a zero-cost parity verification inside any unified diff.

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-architect, curator and guard concurring] LOW, advisory

This learning overlaps scaffold-mirrors-20261016T151128; both capture the same diff-index-pair parity verification under different tags. The documentation-gate-20261016T132704 and -132707 pair overlaps similarly. Dewey's identity scoping, tag plus timestamp plus author, cannot merge them, so semantic search fragments. Would consolidating near-duplicates under one tag keep retrieval sharper?

`uf_finale_create_pr`, and model-name attribution during
`/uf.unleash` and `/uf.finale`) and record the issue number
at check-off, or record the exemption with justification
— filed #740 (this repo) and unbound-force/website#310

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-curator] LOW, advisory

Task 4.2 records docs issue #740, which carries only the documentation label. Curator's verification path queries --label docs, so a label-based gate check finds nothing there. Would gh issue edit 740 --add-label docs align the issue with the label the gate expects?

@jflowers
jflowers force-pushed the opsx/fix-tool-args-schema-mismatch branch from cf17989 to 8bacb05 Compare October 17, 2026 20:06
The future-regression guard still expected the original 3-key demo
payload after upstream expanded persist_unleash_summary to 8 args
(change_name, tier, feature_dir, review_verdicts, learnings_stored
plus the 3 payload fields). Align the expectation with the current
zod args declaration.
@jflowers
jflowers merged commit 588fcc4 into unbound-force:main Oct 17, 2026
16 checks passed
@jflowers
jflowers deleted the opsx/fix-tool-args-schema-mismatch 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.

uf-workflow and uf-finale tools expose empty parameter schemas to the model (parameters: vs SDK args: mismatch)

1 participant