Approving a task that is waiting_human requeues it under implement but leaves its workflow pin untouched. pinWorkflowDefinition returns early whenever workflow_definition_yaml is non-empty and only checks that YAML against its own digest — never against task.Workflow. A requeue therefore hands the daemon a task whose stored definition id disagrees with its workflow column, and the pin is never repaired.
The mismatch then fails the worker's identity check in CompilePinnedWorkflow:
pinned workflow definition does not match task identity
Observed live: a task that had parked under feasibility (its stored pin was the feasibility definition) was approved. Requeue set status=queued, workflow=implement and cleared park_reason, but workflow_definition_yaml still held id: feasibility, so wf.Name (feasibility) != req.Task.Workflow (implement) parked the task again. Approving a second time reproduces it identically — the task is unrecoverable through the operator surface.
Impact
An approval cannot succeed. Any task approved out of waiting_human whose stored pin names a different workflow re-parks immediately, every time. The operator's only working action on that task is to decline it.
Silent at the write. The requeue audit row records requeued implement and the dashboard shows the task leave waiting_human, so the failure looks like a worker fault rather than stale state.
Not repairable from the UI. Retry/approve both route through the same requeue, so neither clears the pin.
Defect — the pin invariant is assumed, never enforced
The guard is self-referential: it proves the stored YAML matches its own recorded digest, which is a property of the write, not of the task. It never asks whether the stored definition is the one task.Workflow names, which is exactly the invariant CompilePinnedWorkflow later enforces:
ifwf.Name!=req.Task.Workflow||workflow.DigestDefinition(req.WorkflowDefinition)!=req.Task.WorkflowDefinitionDigest{returnworkflow.Workflow{},fmt.Errorf("pinned workflow definition does not match task identity")}
So the producer (daemon pin) accepts a state the consumer (worker compile) rejects. Per the repo's own rule — fix invalid state at the producer — the guard belongs here.
The comment on resolveWorkflowID shows the requeue path is a deliberate, supported case ("a decision already made about this specific task"), which makes the missing re-pin a defect rather than an unreachable state.
Reproduction
Task runs feasibility, reaches deliver, parks as waiting_human with workflow_definition_yaml = "id: feasibility\n...".
UpdateTaskOnRequeue sets status/workflow/park_reason and not the workflow_definition_* columns.
Next dispatch calls pinWorkflowDefinition, which returns early on the non-empty stale YAML.
Worker's CompilePinnedWorkflow fails the identity check; the task parks transient.
Expected
pinWorkflowDefinition re-pins whenever the stored definition's id disagrees with task.Workflow: clear the pin and resolve it from the active collection for the named workflow, instead of trusting a pin that names a different workflow. A pin that is present, digest-valid and id-consistent should stay a no-op.
Cover with tests for: a requeue whose stored pin names the previous workflow (the case above), and a stored pin that is id-consistent (must remain untouched, so an operator's active definition override still survives).
Imported from GitHub #1235 · type bug · priority P1 · created 2026-09-29 · closed 2026-09-29
## Summary
Approving a task that is `waiting_human` requeues it under `implement` but **leaves its workflow pin untouched**. `pinWorkflowDefinition` returns early whenever `workflow_definition_yaml` is non-empty and only checks that YAML against its own digest — never against `task.Workflow`. A requeue therefore hands the daemon a task whose stored definition id disagrees with its `workflow` column, and the pin is never repaired.
The mismatch then fails the worker's identity check in `CompilePinnedWorkflow`:
```
pinned workflow definition does not match task identity
```
Observed live: a task that had parked under `feasibility` (its stored pin was the `feasibility` definition) was approved. `Requeue` set `status=queued, workflow=implement` and cleared `park_reason`, but `workflow_definition_yaml` still held `id: feasibility`, so `wf.Name` (`feasibility`) `!= req.Task.Workflow` (`implement`) parked the task again. Approving a second time reproduces it identically — the task is unrecoverable through the operator surface.
## Impact
- **An approval cannot succeed.** Any task approved out of `waiting_human` whose stored pin names a different workflow re-parks immediately, every time. The operator's only working action on that task is to decline it.
- **Silent at the write.** The requeue audit row records `requeued implement` and the dashboard shows the task leave `waiting_human`, so the failure looks like a worker fault rather than stale state.
- **Not repairable from the UI.** Retry/approve both route through the same requeue, so neither clears the pin.
## Defect — the pin invariant is assumed, never enforced
`internal/daemon/daemon.go`, `pinWorkflowDefinition`:
```go
if task.WorkflowDefinitionYAML != "" {
if workflow.DigestDefinition(task.WorkflowDefinitionYAML) != task.WorkflowDefinitionDigest {
return fmt.Errorf("stored workflow definition digest mismatch")
}
return nil
}
```
The guard is self-referential: it proves the stored YAML matches its own recorded digest, which is a property of the write, not of the task. It never asks whether the stored definition is the one `task.Workflow` names, which is exactly the invariant `CompilePinnedWorkflow` later enforces:
```go
if wf.Name != req.Task.Workflow || workflow.DigestDefinition(req.WorkflowDefinition) != req.Task.WorkflowDefinitionDigest {
return workflow.Workflow{}, fmt.Errorf("pinned workflow definition does not match task identity")
}
```
So the producer (daemon pin) accepts a state the consumer (worker compile) rejects. Per the repo's own rule — fix invalid state at the producer — the guard belongs here.
The comment on `resolveWorkflowID` shows the requeue path is a deliberate, supported case ("a decision already made about this specific task"), which makes the missing re-pin a defect rather than an unreachable state.
## Reproduction
1. Task runs `feasibility`, reaches `deliver`, parks as `waiting_human` with `workflow_definition_yaml = "id: feasibility\n..."`.
2. Operator approves: `POST /api/tasks/{id}/action {"action":"approve"}` → `Service.apply` → `Store.Requeue(ctx, id, "waiting_human", "implement")`.
3. `UpdateTaskOnRequeue` sets `status`/`workflow`/`park_reason` and **not** the `workflow_definition_*` columns.
4. Next dispatch calls `pinWorkflowDefinition`, which returns early on the non-empty stale YAML.
5. Worker's `CompilePinnedWorkflow` fails the identity check; the task parks `transient`.
## Expected
`pinWorkflowDefinition` re-pins whenever the stored definition's id disagrees with `task.Workflow`: clear the pin and resolve it from the active collection for the named workflow, instead of trusting a pin that names a different workflow. A pin that is present, digest-valid **and** id-consistent should stay a no-op.
Cover with tests for: a requeue whose stored pin names the previous workflow (the case above), and a stored pin that is id-consistent (must remain untouched, so an operator's active definition override still survives).
Refs: `internal/domain/taskactions/service.go` (approve → `Requeue(..., "implement")`), `internal/infrastructure/postgres/queries/tasks.sql` (`RequeueTask`), `internal/app/agentworker/task_execution.go` (`CompilePinnedWorkflow`).
---
_Imported from GitHub #1235 · type bug · priority P1 · created 2026-09-29 · closed 2026-09-29_
sam
added the highbug labels 2026-10-27 13:41:28 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Approving a task that is
waiting_humanrequeues it underimplementbut leaves its workflow pin untouched.pinWorkflowDefinitionreturns early wheneverworkflow_definition_yamlis non-empty and only checks that YAML against its own digest — never againsttask.Workflow. A requeue therefore hands the daemon a task whose stored definition id disagrees with itsworkflowcolumn, and the pin is never repaired.The mismatch then fails the worker's identity check in
CompilePinnedWorkflow:Observed live: a task that had parked under
feasibility(its stored pin was thefeasibilitydefinition) was approved.Requeuesetstatus=queued, workflow=implementand clearedpark_reason, butworkflow_definition_yamlstill heldid: feasibility, sowf.Name(feasibility)!= req.Task.Workflow(implement) parked the task again. Approving a second time reproduces it identically — the task is unrecoverable through the operator surface.Impact
waiting_humanwhose stored pin names a different workflow re-parks immediately, every time. The operator's only working action on that task is to decline it.requeued implementand the dashboard shows the task leavewaiting_human, so the failure looks like a worker fault rather than stale state.Defect — the pin invariant is assumed, never enforced
internal/daemon/daemon.go,pinWorkflowDefinition:The guard is self-referential: it proves the stored YAML matches its own recorded digest, which is a property of the write, not of the task. It never asks whether the stored definition is the one
task.Workflownames, which is exactly the invariantCompilePinnedWorkflowlater enforces:So the producer (daemon pin) accepts a state the consumer (worker compile) rejects. Per the repo's own rule — fix invalid state at the producer — the guard belongs here.
The comment on
resolveWorkflowIDshows the requeue path is a deliberate, supported case ("a decision already made about this specific task"), which makes the missing re-pin a defect rather than an unreachable state.Reproduction
feasibility, reachesdeliver, parks aswaiting_humanwithworkflow_definition_yaml = "id: feasibility\n...".POST /api/tasks/{id}/action {"action":"approve"}→Service.apply→Store.Requeue(ctx, id, "waiting_human", "implement").UpdateTaskOnRequeuesetsstatus/workflow/park_reasonand not theworkflow_definition_*columns.pinWorkflowDefinition, which returns early on the non-empty stale YAML.CompilePinnedWorkflowfails the identity check; the task parkstransient.Expected
pinWorkflowDefinitionre-pins whenever the stored definition's id disagrees withtask.Workflow: clear the pin and resolve it from the active collection for the named workflow, instead of trusting a pin that names a different workflow. A pin that is present, digest-valid and id-consistent should stay a no-op.Cover with tests for: a requeue whose stored pin names the previous workflow (the case above), and a stored pin that is id-consistent (must remain untouched, so an operator's active definition override still survives).
Refs:
internal/domain/taskactions/service.go(approve →Requeue(..., "implement")),internal/infrastructure/postgres/queries/tasks.sql(RequeueTask),internal/app/agentworker/task_execution.go(CompilePinnedWorkflow).Imported from GitHub #1235 · type bug · priority P1 · created 2026-09-29 · closed 2026-09-29