docs(adr): ADR-0003 — sandbox state lifecycle (iso-prod seed, reset & prod-write isolation) #19
Reference in New Issue
Block a user
Delete Branch "claude/adr-0003-sandbox-reset"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Pins down how
erp-sandbox's data is seeded, reset, and kept structurally incapable of harming prod — the application-data-layer complement to ADR-0001 (which rejected an in-cluster sandbox for infra rehearsal) and the lifecycle for theerp-sandboxinstance ADR-0002 stood up.Drafted via a clean-context agent, then the reset mechanism was refined and validated against the live
erp-sandbox(see below).The decision
pg_dumpof proderp, app-scoped tollx_*, as a reusable golden checkpoint.DROP OWNED BY erp_sandbox_role CASCADE+pg_restore --no-owner --role=erp_sandbox_roleinto the existing DB — noDROP/CREATE DATABASE, noCREATEDB, no superuser. Provisioner-owned infra objects (the pgbounceruser_lookupfunction) are deliberately left untouched.postgres.yamlCI;DROP DATABASEgated by ownership (erp_sandbox_roleowns onlyerp-sandbox, never proderp/erp_role); sandbox-scoped Dolibarr key; membership-only runtime creds; host-guard; resettability.dolibarr-data-snapshotskill → human approves → replay against prod under a separate promote-time credential never held by the agent.Validated against the live sandbox (not just argued)
I prototyped the reset on
erp-sandboxend-to-end:The prototype also caught the refinement now baked into §2: a naive
pg_restore --clean/DROP SCHEMAfails or over-reaches on the provisioner-owned pgbouncer function — so the golden is scoped tollx_*and the wipe isDROP OWNED BY <app role>. (Prototype artifacts were throwaway k8s Jobs; the sandbox DB was returned to its empty pre-install state and the pod restored.)Follow-on (not in this PR)
Implementation is Phase E: E1 (enable Dolibarr API module + create
ai_agent_sandboxuser — your UI step), E2 (productionize the seed/reset as a k8s Job + a read-only prod dump role), E3 = V9 write skill + host-guard, E4 BDD harness, E5 promote.🤖 Generated with Claude Code