fix(workflow): derive a declared output's captures need for profile selection

A declared output is written through a capture tool, but the dispatch-time
harness check read only the workflow's needs.captures. A workflow that
declared outputs without also writing needs: {captures: true} could name a
Kit profile whose adapter serves no capture tools; a required output then
parked with "output %q is required" instead of the profile being refused.

WorkflowInterface.Needs now reports captures for a non-empty Outputs beside
the declared needs, and the profile check and Kit launcher read it. The
needs: block keeps its meaning for a workflow that captures without
declaring outputs.

- internal/domain/workflow/task: Needs() derives captures; DeclaredNeeds
  carries only the declared block.
- internal/daemon: pinTaskProfile and runKitTask read Needs().
- tests: parse-time derivation, and pinTaskProfile refusing an
  outputs-declaring workflow against a Kit adapter with no capture MCP.
This commit is contained in:
sam committed 2026-10-02 03:19:07 +10:00
1 parent 446d94681b
commit 721968eeff
8 files changed
+59 -21

No files matched your search

@@ -47,8 +47,22 @@ func TestParseWorkflowInterfaceNeeds(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if !w.Needs.Captures || w.Needs.GateRetries != 3 {
t.Fatalf("Needs = %+v, want {Captures:true GateRetries:3}", w.Needs)
if needs := w.Needs(); !needs.Captures || needs.GateRetries != 3 {
t.Fatalf("Needs() = %+v, want {Captures:true GateRetries:3}", needs)
}
}
// TestParseWorkflowInterfaceOutputsForceCaptures: an output is written
// through a capture tool, so declaring one forces the captures need whether
// or not the author also wrote needs.captures
// (docs/prds/workflow-call-outputs.md, "How a run writes one").
func TestParseWorkflowInterfaceOutputsForceCaptures(t *testing.T) {
w, err := ParseWorkflowInterface("id: a\noutputs:\n summary: {type: string}\n")
if err != nil {
t.Fatal(err)
}
if needs := w.Needs(); !needs.Captures {
t.Fatalf("Needs() = %+v, want Captures for a workflow that declares an output", needs)
}
}