fix(daemon): carry kind/label routing bindings to the process that routes

An operator's kind/label -> workflow overrides were decoded, validated and
installed into the DAEMON's package-level state via
workflow.SetKindWorkflows/SetLabelWorkflows -- but workflow.Route's only
production caller is app/agentworker/task_execution.go, in the separate
archie-agent process. The bindings never crossed the boundary, so every
configured override was silently ignored and routing always fell back to the
built-in defaults (bug -> tdd, feature -> feasibility, bootstrap -> bootstrap).

Carry the resolved bindings on taskrun.Request, mirroring how MCPServers already
crosses this boundary, and apply them in the worker before Route is called.
Resolved values are carried rather than file paths, so the worker does not need
the routing files to be readable in its sandbox. nil still means "use the
built-in defaults", so this is backward compatible for any request built by an
older daemon.

routeTask is a named seam for that install-then-route step. It mutates
package-level routing state, which is sound here because each archie-agent
process is task-scoped and ephemeral; if the worker ever served more than one
task that assumption would need revisiting.

Tests are mutation-verified: removing either the two Set calls in routeTask or
the two request fields in runViaAgent reproduces the exact assertion failures
the lane observed red-first, so neither test is vacuous.

Found by an adversarial package sweep (temp tracker: workflow-engine-1,
.local/issue-tracker/).
This commit is contained in:
sam committed 2026-09-15 02:13:33 +10:00
1 parent f54f130065
commit 669f98a059
6 files changed
+145 -6

No files matched your search

+8
View File
@@ -29,6 +29,14 @@ type Request struct {
// transports, discover tools, and register them locally. Absent/empty
// means no MCP servers (backward compatible).
MCPServers []config.MCPServer `json:"mcp_servers,omitempty"`
// KindWorkflows and LabelWorkflows carry the resolved kind/label ->
// workflow-name bindings the daemon loaded from WorkflowRoutingFile,
// WorkflowLabelsFile and PlaybookDirs. workflow.Route runs in the
// archie-agent process, not the daemon, so these resolved values must
// cross the process boundary here; nil means use the built-in defaults
// (backward compatible).
KindWorkflows workflow.KindWorkflows `json:"kind_workflows,omitempty"`
LabelWorkflows workflow.LabelWorkflows `json:"label_workflows,omitempty"`
// WorktreeGrant is an opaque, per-dispatch capability authorizing the
// daemon to publish this task's already-prepared branch. Repository
// coordinates never cross back from the sandbox as authority.