feat(dag): add workflow draft action for schema-checked graph authoring - #264
Merged
Conversation
Models writing workflow YAML by hand drift on field names and structure (live-observed: objective at top level, worker instead of worker_type) even with the reference template in context — YAML is an unvalidated text channel, so prompting alone cannot reach zero. This closes the gap at three layers: - workflow(action="draft"): pass the structured config through the tool parameter schema; the harness renders YAML to .opencode/workflow-drafts/, validates it, and returns the spec_path. Unknown fields are rejected by the provider-side schema before any file is written; YAML syntax errors disappear because rendering is code. spec_path contract unchanged. - routing guide now carries the minimal complete start-spec example inline (one hop) plus the field-ownership rules; description budget 5k -> 6.5k. - schemaDiagnostics maps high-frequency drift fields (worker/agent -> worker_type, prompt -> instruction, top-level objective -> config) to "Did you mean" hints, matching both message text and diagnostic path. Verified: test/dag 496/496 green incl. 5 new draft tests (render round-trip, bad-dependency diagnostics, unsafe-name rejection, schema drift rejection, drift hint); core command tests 21/21; tsgo clean in both packages.
The draft action commit (76df802) added the 11th parameter-union branch but missed test/tool/__snapshots__/parameters.test.ts.snap; the stale snapshot failed 'tool parameters > JSON Schema (wire shape) > workflow' deterministically (surfaced as an external red gate during a concurrent verification run). Regenerated via bun test --update-snapshots; full test/tool + workflow-tool suites green (384 pass).
6 tasks
The draft-action commit spliced the heading onto the preceding paragraph line, dropping it from rendered markdown structure.
The RegExp escape forms tripped two unnecessary-escape warnings, pushing CI's oxlint count past the --max-warnings=4852 ratchet. Diagnostic paths are JSON.stringify-segmented, so a plain ["field"] substring check covers the same matches without the regex.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Models writing workflow YAML by hand drift on field names and structure (live-observed in this session:
objectiveat top level,workerinstead ofworker_type) even with the reference template in context. YAML is an unvalidated text channel — prompting alone cannot reach zero drift. This PR closes the gap at three layers:1.
workflow(action="draft")— harness-rendered specs (root fix)configthrough the tool parameter schema (reusesWorkflowGraphSchema); the harness renders it to.opencode/workflow-drafts/<name>.yamlviayaml.stringify, runs the portable authoring check, and returns thespec_pathwith node count or diagnostics.worker, top-levelobjective, missingconfig) are rejected by the provider-side tool-call schema before anything is written; YAML syntax/indentation errors disappear because rendering is code.spec_pathcontract unchanged: start/extend/replan/validate still accept only file paths; draft only produces the file.2. Routing guide carries the minimal complete start spec inline
workflow-routing.md(the tool description) now includes a one-hop minimal start YAML example plus field-ownership rules (objectivelives insideconfig; block fields are exhaustive; neverworker/prompt/agent).3. Drift-aware diagnostics
schemaDiagnosticsmaps high-frequency wrong fields (worker/workers/agent→worker_type,prompt/task→instruction, top-levelobjective→config.objective,blocks↔nodes) toDid you mean "..."?hints, matching both message text and diagnostic path (decode leaves carry only the tag; the field name lives in the path).Why this design
The tool parameter schema is the only layer the provider enforces structurally (OpenAI tools contract). Moving graph serialization from free-text YAML into the harness puts field-name errors under that enforcement — the same reasoning as the params-object-root contract from #262, applied to the authoring side.
Test plan
worker, top-levelobjective, missing config), mixed blocks+nodes owned by authoring layerworker: generalyieldsDid you mean "worker_type"?bun test test/dag496/496 greentest/plugin/command.test.ts21/21 greentsgo --noEmitclean in packages/opencode and packages/core