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

+1 -1
View File
@@ -1921,7 +1921,7 @@ func (d *Daemon) pinTaskProfile(ctx context.Context, task *workflow.Task) (confi
if err == nil {
var profile config.AgentProfile
if profile, err = d.configFor(task).Containers.Profile(iface.Profile); err == nil {
if err = validateProfileMeetsNeeds(profile, iface.Needs); err == nil {
if err = validateProfileMeetsNeeds(profile, iface.Needs()); err == nil {
return profile, true
}
}
+13 -5
View File
@@ -2373,6 +2373,11 @@ func TestPinTaskProfileRefusesCapturesTheHarnessCannotServe(t *testing.T) {
{ID: "needs-captures-served", YAML: "id: needs-captures-served\nrepository: none\nprofile: serves-captures\nneeds: {captures: true}\nsteps:\n - type: agent.run\n settings: {mission: go}\n"},
{ID: "needs-captures-codex", YAML: "id: needs-captures-codex\nrepository: none\nprofile: no-captures\nneeds: {captures: true}\nsteps:\n - type: agent.run\n settings: {mission: go}\n"},
{ID: "needs-captures-bare", YAML: "id: needs-captures-bare\nrepository: none\nprofile: no-adapter\nneeds: {captures: true}\nsteps:\n - type: agent.run\n settings: {mission: go}\n"},
// A declared output is written through a capture tool, so it forces
// the captures need whether or not the author also wrote
// needs.captures (docs/prds/workflow-call-outputs.md).
{ID: "outputs-served", YAML: "id: outputs-served\nrepository: none\nprofile: serves-captures\noutputs: { summary: {type: string} }\nsteps:\n - type: agent.run\n settings: {mission: go}\n"},
{ID: "outputs-codex", YAML: "id: outputs-codex\nrepository: none\nprofile: no-captures\noutputs: { summary: {type: string, required: true} }\nsteps:\n - type: agent.run\n settings: {mission: go}\n"},
}}, version: 1}
ctx := context.Background()
@@ -2389,17 +2394,20 @@ func TestPinTaskProfileRefusesCapturesTheHarnessCannotServe(t *testing.T) {
return task
}
served := claim(51, "needs-captures-served")
if _, ok := d.pinTaskProfile(ctx, served); !ok {
t.Fatal("a Kit profile whose adapter serves captures was refused")
for i, servedWorkflow := range []string{"needs-captures-served", "outputs-served"} {
served := claim(51+i, servedWorkflow)
if _, ok := d.pinTaskProfile(ctx, served); !ok {
t.Fatalf("a Kit profile whose adapter serves captures was refused for %s", servedWorkflow)
}
}
for _, tt := range []struct {
number int
workflow string
}{
{52, "needs-captures-codex"},
{53, "needs-captures-bare"},
{53, "needs-captures-codex"},
{54, "needs-captures-bare"},
{55, "outputs-codex"},
} {
task := claim(tt.number, tt.workflow)
if _, ok := d.pinTaskProfile(ctx, task); ok {
+1 -1
View File
@@ -72,7 +72,7 @@ func (d *Daemon) runKitTask(ctx context.Context, task *workflow.Task, repo confi
Adapter: profile.Adapter,
WorkDir: workDir,
WorkerEnv: env,
GateRetries: iface.Needs.GateRetries,
GateRetries: iface.Needs().GateRetries,
Org: taskCfg.Org,
GrantedServices: taskCfg.GrantedCredentials,
})