The audit story for the platform's security invariant: no NS write happens without all 4 gates. Gate 1 CF Access JWT (edge-enforced). Gate 2 Role palette (X-Role-Id → tool_role_palettes). Gate 3 X-Edit-Token on every write endpoint. Gate 4 proposed_actions HITL queue (ADR-031). Plus 3 kill switches (ns_writes, proposed_apply, high_risk_ops) that flip writes off in seconds. The R560 atomic-claim race fix is shown explicitly: drainer uses UPDATE...RETURNING so two instances cannot race.
| Gate | Where enforced | Failure mode |
|---|---|---|
| 1 · CF Access JWT | Cloudflare edge (pre-Worker) | 302 redirect to CF Access login |
| 2 · X-Role-Id role gate | filterToolsForRole (pre-LLM) | Tool not in catalog → LLM cannot call |
| 3 · X-Edit-Token | checkEditToken on every write endpoint | 403 Forbidden |
| 4 · proposed_actions queue | executeWorkflowContract stages row · drainer claims atomically (R560) | Pending forever until Mike approves |
| Switch | KV key | Effect |
|---|---|---|
ns_writes | kill.ns_writes | Halts ALL NS writes platform-wide |
proposed_apply | kill.proposed_apply | Halts the drainer; queue continues to grow |
high_risk_ops | kill.high_risk_ops | Halts only risk_level ≥ 4 drains |
After Mike approves in /proposed-actions.html, the row flows:
UPDATE proposed_actions SET status='applying', claimed_by=?, claimed_at=now() WHERE action_id=? AND status='approved' RETURNING * (R560 race fix)status='applied' on both rowsretry_count++ up to 3, then DLQ + workflow.failed event + alert email to Mike| Color | Meaning |
|---|---|
| frontend | User-facing surface (chat UI, admin HTML pages) |
| backend | Worker logic / agent code / business rules |
| database | D1 table / R2 object / KV key / Vectorize index |
| cloud | External system (NetSuite, Anthropic, etc.) |
| security | Gate / policy / HITL approval / kill switch |
| messagebus | Event ledger, Queues, async fan-out |
| external | Inbound source (email, webhook, cron tick, user input) |
| → solid | Synchronous call (request → response) |
| → green | Approved / happy-path |
| → red dashed | Policy or security check |
| → grey dashed | Optional / conditional / async |