fix(statestore): workflow pin is never persisted over gRPC and its digest guard is dead in production #1693

Closed
opened 2026-10-27 13:41:25 +00:00 by sam · 0 comments
Owner

State Store contract defect (risk-routed, section 5a). Found by the Wave 0R claims audit (c8, verdict BLOCK).

task.WorkflowDefinitionVersion/Digest/YAML (internal/domain/workflow/task/task.go:51-53) have no matching field in pb.Task (proto/state/v1/state.proto:179-209; grep WorkflowDefinition in internal/contracts/state/v1/*.go returns nothing) and no mapping in taskProto/taskValue (internal/infrastructure/staterpc/values.go:57-89). store.Update (internal/store/store.go:415-425) writes all three columns unconditionally, so over gRPC the pin is never persisted and any pin already in the row is zeroed by the same call. Inserts omit the columns entirely (store.go:254-255,274-278; DDL defaults 0/''/'' at :120-122).

The production daemon's Store is the gRPC client (internal/app/archied/bootstrap.go:359 openStateStoreAdapter, :1226 Store: b.stateStore), so this is the production path, not a test-only one. Consequence: the digest-mismatch guard at internal/daemon/daemon.go:1469-1470 is dead in production (task.WorkflowDefinitionYAML != "" is never true for a task re-read over the wire), so each retry re-resolves from the active control-plane resource instead of the pinned version. PRD clause: docs/prds/runtime-control-plane.md:95 "Each run keeps the workflow version it started with."

The only covering test (internal/daemon/workflow_definition_test.go:32) drives the local SQL store, so it cannot fail for production's reason. The conformance battery (internal/infrastructure/staterpc/conformance_test.go:134) walks Update and TaskByID through both adapters but asserts one unrelated field, so proto/domain field parity is untied.

Fix direction: carry the pin on the contract (proto + values.go mapping), and tie proto/domain parity in the conformance battery. Also reconcile the field comment at task/task.go:47 which asserts retry behaviour the wire cannot deliver.

Close reason

Already fixed in 90fda8d5 (2026-09-21): pb.Task carries workflow_definition_version/digest/yaml (fields 28-30), values.go maps them both ways, TestTaskProtoCarriesEveryDomainField ties proto/domain parity, and the conformance battery round-trips the pin over gRPC. The Postgres UpdateTask query writes all three columns, so the daemon's digest guard (pinWorkflowDefinition) now sees the pin on re-read and the task.go field comment holds.


Imported from beads archie-core-zf8h · GitHub #997 · type bug · priority P0 · created 2026-09-21 · closed 2026-09-26

State Store contract defect (risk-routed, section 5a). Found by the Wave 0R claims audit (c8, verdict BLOCK). task.WorkflowDefinitionVersion/Digest/YAML (internal/domain/workflow/task/task.go:51-53) have no matching field in pb.Task (proto/state/v1/state.proto:179-209; grep WorkflowDefinition in internal/contracts/state/v1/*.go returns nothing) and no mapping in taskProto/taskValue (internal/infrastructure/staterpc/values.go:57-89). store.Update (internal/store/store.go:415-425) writes all three columns unconditionally, so over gRPC the pin is never persisted and any pin already in the row is zeroed by the same call. Inserts omit the columns entirely (store.go:254-255,274-278; DDL defaults 0/''/'' at :120-122). The production daemon's Store is the gRPC client (internal/app/archied/bootstrap.go:359 openStateStoreAdapter, :1226 Store: b.stateStore), so this is the production path, not a test-only one. Consequence: the digest-mismatch guard at internal/daemon/daemon.go:1469-1470 is dead in production (task.WorkflowDefinitionYAML != "" is never true for a task re-read over the wire), so each retry re-resolves from the active control-plane resource instead of the pinned version. PRD clause: docs/prds/runtime-control-plane.md:95 "Each run keeps the workflow version it started with." The only covering test (internal/daemon/workflow_definition_test.go:32) drives the local SQL store, so it cannot fail for production's reason. The conformance battery (internal/infrastructure/staterpc/conformance_test.go:134) walks Update and TaskByID through both adapters but asserts one unrelated field, so proto/domain field parity is untied. Fix direction: carry the pin on the contract (proto + values.go mapping), and tie proto/domain parity in the conformance battery. Also reconcile the field comment at task/task.go:47 which asserts retry behaviour the wire cannot deliver. ### Close reason Already fixed in 90fda8d5 (2026-09-21): pb.Task carries workflow_definition_version/digest/yaml (fields 28-30), values.go maps them both ways, TestTaskProtoCarriesEveryDomainField ties proto/domain parity, and the conformance battery round-trips the pin over gRPC. The Postgres UpdateTask query writes all three columns, so the daemon's digest guard (pinWorkflowDefinition) now sees the pin on re-read and the task.go field comment holds. --- _Imported from beads `archie-core-zf8h` · GitHub #997 · type bug · priority P0 · created 2026-09-21 · closed 2026-09-26_
sam added the criticalbug labels 2026-10-27 13:41:25 +00:00
sam self-assigned this 2026-10-27 13:41:25 +00:00
sam closed this issue 2026-10-27 13:41:25 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1693