Goal — REFACTOR_PLAN.md Step 6
Add the Redis runtime layer in api/pkg/runtime. Redis is for Control Plane runtime coordination only (per BRD §10.1, FR-15) — rate limits, short-lived cache, distributed locks, job coordination, agent heartbeat cache. No secret values, ever. Agents do not connect to Redis.
Scope
Acceptance criteria
- Integration tests against a real Redis (testcontainers or CI service container)
- A simulated double-submit of the same idempotency key returns the cached first result, not two executions
- Two concurrent workers contending for the same lock → exactly one acquires it; the loser gets a typed
ErrLockHeld
- Code review checklist explicitly verifies that no
SetValue(secretValue.Bytes ...) shows up in the runtime layer
- Agent has no
pkg/runtime import — enforced by a CI lint that fails if agent/... ever imports api/pkg/runtime
Hard rules (CLAUDE.md / BRD)
- Redis is private to the Control Plane (BRD §10.1, §15 Runtime dependency exposure, §24)
- No secret values in Redis values, keys, or pub/sub payloads (BRD §11, FR-04)
References
- BRD §9 (Control Plane Runtime row), §10.1, §13 FR-15, §15, §24
- REFACTOR_PLAN §6 row 6
Dependencies
- api scaffold (Step 4)
- Postgres storage (Step 5)
Goal — REFACTOR_PLAN.md Step 6
Add the Redis runtime layer in
api/pkg/runtime. Redis is for Control Plane runtime coordination only (per BRD §10.1, FR-15) — rate limits, short-lived cache, distributed locks, job coordination, agent heartbeat cache. No secret values, ever. Agents do not connect to Redis.Scope
go-redis/v9client, configured from env (URL, pool size, TLS)WithIdempotencyKey(ctx, key, fn)— single-execution guarantee per (key, TTL)SETNX+ lease + renewal): used byworkerto serialize job executionworker-side notifications/readyzto fail-open when Redis is unreachable for read-only operations, fail-closed when writes are requiredAcceptance criteria
ErrLockHeldSetValue(secretValue.Bytes ...)shows up in the runtime layerpkg/runtimeimport — enforced by a CI lint that fails ifagent/...ever importsapi/pkg/runtimeHard rules (CLAUDE.md / BRD)
References
Dependencies