Fix merged State Store runtime, authorization and deployment regressions #1703

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

Resolve six review findings in merged PRs #754/#770-775: scoped revocable agent credentials; Update validation; capture batches beyond unary receive limit; consistent token resolution; external network topology; complete task dev orchestration. Add regression tests, run task check, commit and push main as requested.

Close reason

All six review findings verified landed on main (f94e484 + accb987); regression tests pass. Only residual: nil-Task Update regression test, filed as a follow-up.


Imported from beads archie-core-zs27 · GitHub #776 · type bug · priority P1 · created 2026-09-07 · closed 2026-09-11

Resolve six review findings in merged PRs #754/#770-775: scoped revocable agent credentials; Update validation; capture batches beyond unary receive limit; consistent token resolution; external network topology; complete task dev orchestration. Add regression tests, run task check, commit and push main as requested. ### Close reason All six review findings verified landed on main (f94e484 + accb987); regression tests pass. Only residual: nil-Task Update regression test, filed as a follow-up. --- _Imported from beads `archie-core-zs27` · GitHub #776 · type bug · priority P1 · created 2026-09-07 · closed 2026-09-11_
sam added the highbug labels 2026-10-27 13:41:27 +00:00
sam self-assigned this 2026-10-27 13:41:27 +00:00
sam closed this issue 2026-10-27 13:41:27 +00:00
Author
Owner

sam wrote (originally 2026-09-11):

Triage of the six review findings (issue description) against main @ 1f4ce05. All six were fixed by commit f94e484 ("Closes six review findings against .4.6") with follow-up accb987; verified by code + targeted tests.

  1. scoped revocable agent credentials — LANDED. internal/infrastructure/staterpc/task_grants.go (admin-only Register/RevokeTaskGrant; a task grant authorizes only Update/Transition/InsertEvent on its own task ID) + daemon wiring (StateStoreGrantIssuer issued before Acquire, revoked on Release, fails closed); TestTaskGrantScopesWorkerToItsOwnThreeRPCs / TestOnlyAdminCanRegisterOrRevokeTaskGrants / internal/daemon/state_store_grants_test.go pass.
  2. Update validation — LANDED (behaviour). internal/infrastructure/staterpc/server.go:119 rejects a nil Task with codes.InvalidArgument instead of panicking in the store layer. Residual: no dedicated regression test for the nil case.
  3. capture batches beyond unary receive limit — LANDED, contrary to the probe. f94e484 added server-streaming StreamCaptures/StreamUndispatchedCaptures (server.go:348/546) and the client facade calls them (client.go:278/398), one capture per message (<=256 KiB), so MaxCallRecvMsgSize is unnecessary; TestCaptureListsExceedUnaryMessageLimit pushes 20x256 KiB = 5 MiB over bufconn gRPC and passes (would exceed the 4 MiB unary cap).
  4. consistent token resolution — LANDED. Client and server share stateStoreResolvedToken (target_token, then STATE_STORE_TOKEN): state_store_client.go:17, state_store.go:67; archie-ui env fallback in 7a6f4e4/80eff2d; TestRunStateStoreAcceptsEnvironmentToken / TestGatewayResolvedToken pass.
  5. external network topology — LANDED. RequireHostGateway = cfg.NATS.Mode == config.NATSModeEmbedded (internal/app/archied/main.go:1079), so an externally reachable NATS/State Store no longer forces local Docker-bridge discovery; deployment profiles carry the container-reachable 172.17.0.1 target + token; TestExternalServicesDoNotRequireBridgeNetwork passes.
  6. complete task dev orchestration — LANDED. Taskfile.yml:116/128: task dev deps include dev:state-store; deployments/dev.toml points [services.state] at 127.0.0.1:9090.

Conclusion: all six landed; only residual is the missing nil-Task Update regression test (finding 2).

_sam wrote (originally 2026-09-11):_ Triage of the six review findings (issue description) against main @ 1f4ce05. All six were fixed by commit f94e484 ("Closes six review findings against .4.6") with follow-up accb987; verified by code + targeted tests. 1. scoped revocable agent credentials — LANDED. internal/infrastructure/staterpc/task_grants.go (admin-only Register/RevokeTaskGrant; a task grant authorizes only Update/Transition/InsertEvent on its own task ID) + daemon wiring (StateStoreGrantIssuer issued before Acquire, revoked on Release, fails closed); TestTaskGrantScopesWorkerToItsOwnThreeRPCs / TestOnlyAdminCanRegisterOrRevokeTaskGrants / internal/daemon/state_store_grants_test.go pass. 2. Update validation — LANDED (behaviour). internal/infrastructure/staterpc/server.go:119 rejects a nil Task with codes.InvalidArgument instead of panicking in the store layer. Residual: no dedicated regression test for the nil case. 3. capture batches beyond unary receive limit — LANDED, contrary to the probe. f94e484 added server-streaming StreamCaptures/StreamUndispatchedCaptures (server.go:348/546) and the client facade calls them (client.go:278/398), one capture per message (<=256 KiB), so MaxCallRecvMsgSize is unnecessary; TestCaptureListsExceedUnaryMessageLimit pushes 20x256 KiB = 5 MiB over bufconn gRPC and passes (would exceed the 4 MiB unary cap). 4. consistent token resolution — LANDED. Client and server share stateStoreResolvedToken (target_token, then STATE_STORE_TOKEN): state_store_client.go:17, state_store.go:67; archie-ui env fallback in 7a6f4e4/80eff2d; TestRunStateStoreAcceptsEnvironmentToken / TestGatewayResolvedToken pass. 5. external network topology — LANDED. RequireHostGateway = cfg.NATS.Mode == config.NATSModeEmbedded (internal/app/archied/main.go:1079), so an externally reachable NATS/State Store no longer forces local Docker-bridge discovery; deployment profiles carry the container-reachable 172.17.0.1 target + token; TestExternalServicesDoNotRequireBridgeNetwork passes. 6. complete task dev orchestration — LANDED. Taskfile.yml:116/128: `task dev` deps include dev:state-store; deployments/dev.toml points [services.state] at 127.0.0.1:9090. Conclusion: all six landed; only residual is the missing nil-Task Update regression test (finding 2).
Author
Owner

sam wrote (originally 2026-09-11):

Correction to the triage comment above: finding 3 was landed but wire-broken, and is now fixed in 93e36f5.

The capture batch reads were moved onto server-streaming RPCs (StreamCaptures/StreamUndispatchedCaptures) to get past gRPC's 4 MiB unary cap, but staterpc.Dial installed only a unary client interceptor, while the server's TaskGrants.StreamInterceptor demands the administrative token. Every token-protected (non-loopback) listener -- every container-mode deployment profile -- refused the call with PermissionDenied, and the unary fallback those reads replaced is no longer taken. Blast radius was wider than 'a large batch': on that topology every capture list failed, both the daemon's undispatched-capture dispatch and the dashboard's /api/captures inspector.

Neither existing test could see it: the bufconn conformance harness built a plain grpc.NewServer with no interceptors, and the real-process smoke started archie-state-store on loopback with no token. Fixed by adding StreamClientTokenInterceptor and installing it in Dial, routing the agent's duplicate dial through Dial too, and adding regression coverage that goes through the production Dial under a token-protected listener (unit + real binary). task check green.

_sam wrote (originally 2026-09-11):_ Correction to the triage comment above: finding 3 was landed but wire-broken, and is now fixed in 93e36f5. The capture batch reads were moved onto server-streaming RPCs (StreamCaptures/StreamUndispatchedCaptures) to get past gRPC's 4 MiB unary cap, but staterpc.Dial installed only a unary client interceptor, while the server's TaskGrants.StreamInterceptor demands the administrative token. Every token-protected (non-loopback) listener -- every container-mode deployment profile -- refused the call with PermissionDenied, and the unary fallback those reads replaced is no longer taken. Blast radius was wider than 'a large batch': on that topology every capture list failed, both the daemon's undispatched-capture dispatch and the dashboard's /api/captures inspector. Neither existing test could see it: the bufconn conformance harness built a plain grpc.NewServer with no interceptors, and the real-process smoke started archie-state-store on loopback with no token. Fixed by adding StreamClientTokenInterceptor and installing it in Dial, routing the agent's duplicate dial through Dial too, and adding regression coverage that goes through the production Dial under a token-protected listener (unit + real binary). task check green.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#1703