feat(pr-review): benchmark live pipeline through generic workflow spawn

This commit is contained in:
sam committed 2026-09-29 00:35:34 +10:00
1 parent 081ee4a8ba
commit ed698fced1
23 files changed
+647 -232

No files matched your search

+6
View File
@@ -1784,6 +1784,12 @@ func (d *Daemon) pinTaskProfile(ctx context.Context, task *workflow.Task) (confi
return config.AgentProfile{}, false
}
iface, err := workflowtask.ParseWorkflowInterface(task.WorkflowDefinitionYAML)
if err == nil {
// Every producer meets the declared interface here, including the
// ones that cannot read definitions when they enqueue (chat and
// dashboard spawns go through the Gateway, which never does).
err = iface.CheckInputs(task.Inputs)
}
if err == nil {
var profile config.AgentProfile
if profile, err = d.configFor(task).Containers.Profile(iface.Profile); err == nil {
+46
View File
@@ -2412,6 +2412,52 @@ func TestPinTaskProfileRefusesCapturesTheHarnessCannotServe(t *testing.T) {
}
}
// TestPinTaskProfileRefusesInputsTheWorkflowDoesNotAccept holds every
// producer to the workflow's declared interface at the one point each task
// meets its definition. Bindings check inputs before they enqueue; a chat or
// dashboard spawn cannot, because the Gateway never reads workflow
// definitions, so without this a spawn missing a required input would run
// and fail deep inside the workflow instead of parking with the reason.
func TestPinTaskProfileRefusesInputsTheWorkflowDoesNotAccept(t *testing.T) {
d, s, _ := daemonWithNATS(t)
d.WorkflowDefinitions = &workflowDefinitionsStub{collection: workflow.WorkflowDefinitionCollection{Definitions: []workflow.WorkflowDefinitionEntry{
{ID: "investigate", YAML: investigateYAML},
}}, version: 1}
ctx := context.Background()
for _, tt := range []struct {
name string
inputs map[string]any
ok bool
reason string
}{
{"declared inputs run", map[string]any{"src_ip": "10.0.0.1"}, true, ""},
{"missing required input parks", nil, false, `input "src_ip" is required`},
{"undeclared input parks", map[string]any{"src_ip": "10.0.0.1", "extra": "x"}, false, `input "extra" is not declared`},
{"mistyped input parks", map[string]any{"src_ip": 7}, false, `input "src_ip" is number, want string`},
} {
t.Run(tt.name, func(t *testing.T) {
if _, err := s.EnqueueChatTask(ctx, "acme", "widget", tt.name, "", "investigate", "", tt.inputs); err != nil {
t.Fatal(err)
}
task, err := s.ClaimNext(ctx)
if err != nil || task == nil {
t.Fatalf("claim: (%v, %v)", task, err)
}
if _, ok := d.pinTaskProfile(ctx, task); ok != tt.ok {
t.Fatalf("pinTaskProfile ok = %v, want %v", ok, tt.ok)
}
if tt.ok {
return
}
got, err := s.TaskByID(ctx, task.ID)
if err != nil || got.Status != workflow.StatusParked || !strings.Contains(got.ParkReason, tt.reason) {
t.Fatalf("task = %+v, %v; want parked naming %q", got, err, tt.reason)
}
})
}
}
// TestWorkflowCallGivesACalleeItsOwnProfile is the harness PRD's "a stage may
// name a different profile" (docs/prds/external-agent-harness.md, Selection):
// there is no mid-container runner switch, and none is built here. A stage