deprovision-tenant
Skill1 starsChanged 5 months agoApache-2.0View on GitHub
Offboards a tenant cleanly (drop DB, revoke secret, mark registry, emit audit) by driving the deprovision state machine. Use for normal contract end / churn — NOT for legal Right-To-Be-Forgotten erasure (use tenant-erasure).
In this repository20 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- control-plane/CLAUDE.mdCLAUDE.md
- docs/CLAUDE.mdCLAUDE.md
- helm/CLAUDE.mdCLAUDE.md
- terraform/CLAUDE.mdCLAUDE.md
- add-cellSkill
- cell-capacity-reportSkill
- dr-drillSkill
- incident-triageSkill
- migrate-schemaSkill
- new-adrSkill
- provision-tenantSkill
- restore-tenantSkill
- retire-cellSkill
- review-terraform-planSkill
- rotate-secretsSkill
- security-baseline-checkSkill
- tenant-erasureSkill
- tenant-usage-reportSkill
- upgrade-arcadedbSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 0 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Read access to the regional tenant registry (DynamoDB, ADR-0008) and Step Functions execute permission for …
- Very specific: line 31
No legal hold: Verify the tenant is NOT under legal hold or active investigation.
- Very specific: line 41
Pull the record: Read the TenantRecord from the regional registry and capture tenant_id, home_geo, env, tier, cell_id, db_name, …
- Very specific: line 43
Set status
deprovisioning: Update the registry status to deprovisioning so the router stops placing new traffic and the … - Very specific: line 45
Execute the deprovision state machine: Start an execution of ../../../control-plane/provisioning/deprovision.asl.json in the in-geo region …
- Very specific: line 68
Wrong tenant dropped: treat as a Sev-1 — invoke incident-triage, then restore-tenant from that tenant's most recent backup into a new DB …
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Deprovision a tenant
Normal offboarding of a tenant whose contract ended: take an optional final retained backup, drop the tenant's ArcadeDB database, revoke its secret, set registry
status=deprovisioning→erased, and emit an audit record. This is NOT legal erasure (RTBF/DSAR) — for that use thetenant-erasureskill, which intentionally skips the retained backup. PHASE NOTE: all mutating steps below (state-machine execution, DB drop, secret deletion, registry write, backup) touch live AWS/cluster resources and are OUT OF SCOPE until after CTO sign-off and go-live; until then this runbook is a dry-read walkthrough only.
Prerequisites
- The CTO package is applied and the target geo's control plane is live (this is a Day-2 runbook).
- You can assume the in-geo control-plane role for the tenant's
home_geo(euorus). You must operate from the matching region — never the paired/foreign geo. - Read access to the regional tenant registry (DynamoDB, ADR-0008) and Step Functions execute permission for
../../../control-plane/provisioning/deprovision.asl.json. - A signed deprovisioning ticket / change record with the tenant_id and explicit confirmation the contract has ended.
- Confirmation this is normal offboarding, not RTBF. If a data-subject erasure obligation applies, STOP and use
tenant-erasure.
Inputs
tenant_id— exact id from the registry (TenantRecord.tenant_id).home_geo—eu|us; MUST equal the control plane you are running in (control_plane_geo).env—dev|stage|prod(prod requires the approval gate below).retain_final_backup—truefor normal offboarding (default),falseonly when erasure is intended (then usetenant-erasureinstead).retention_window— how long the final ZIP is kept before lifecycle expiry (perbackup_policy/ contract).- Change-ticket reference for the audit trail.
Safety checks (MUST pass before proceeding)
- Confirm identity, twice. Re-read
tenant_idANDhome_geofrom the registry and read them back to the requester. ArcadeDB has no per-DB resource quotas or soft fences (the control plane / retrieval proxy is the only enforcement point), so the engine will not stop you from dropping the wrong DB — and a drop is unrecoverable except from backup. - Geo match (Directive 1 — Residency).
home_geoMUST equal this control plane's geo. The state machine'sAssertHomeGeofails closed withResidencyViolationotherwise. Never run an EU tenant's deprovision from US (or vice-versa); there is NO EU↔US data path, and the final backup must land in-jurisdiction (ADR-0006/0007). - No legal hold. Verify the tenant is NOT under legal hold or active investigation. If held, ABORT — do not drop the DB and do not let lifecycle expire the final backup. The
FinalBackupstep is legal-hold aware; honor it. - Final backup before drop (normal offboarding). Ensure
retain_final_backup=trueso a final hot ZIP exists before the DB is dropped. Note the ArcadeDB backup gotchas: it is a hot per-DB ZIP that EXCLUDES the WAL, has no incremental and no PITR, and no native S3 target — our pipeline (ADR-0015) copies the ZIP to the in-geo, KMS-encrypted bucket; supplement with the EBS snapshot lineage (ADR-0016). If you skip the backup you are doing erasure — switch skills. - Encryption (Directive 5). The retained backup bucket and any snapshot are KMS-encrypted (the engine provides none). Do not stage the ZIP anywhere unencrypted.
- Not a write you can split. A tenant DB lives on one cell's leader; deprovision affects only that cell. Confirm
cell_idfrom the registry so you operate against the right cell. - Prod approval (Directive 6 — No click-ops). For
env=prod, the destructive run requires manual approval (Spacelift change / signed ticket). Do not invoke the drop ad hoc from a shell.
Steps
All steps from 3 onward MUTATE AWS/cluster state and are post-approval / post-go-live only.
- Pull the record. Read the
TenantRecordfrom the regional registry and capturetenant_id,home_geo,env,tier,cell_id,db_name,secret_arn_pointer,backup_policy. Confirm currentstatusisactiveorsuspended. (Read-only.) - Run the safety checklist above. Confirm tenant_id + geo with the requester, confirm no legal hold, confirm normal-offboarding (not RTBF). (Read-only.)
- Set status
deprovisioning. Update the registrystatustodeprovisioningso the router stops placing new traffic and the kill-switch/governance view (ADR-0027) reflects intent. [AWS-mutating] - APPROVAL GATE (prod). Obtain manual approval for the destructive run (Spacelift / signed change). Do not proceed without it for
env=prod. [approval gate] - Execute the deprovision state machine. Start an execution of
../../../control-plane/provisioning/deprovision.asl.jsonin the in-geo region with input includingtenant_id,home_geo,control_plane_geo,db_name,cell_id,secret_arn_pointer,retain_final_backup=true,retention_window, and the change-ticket ref. The state machine runs, in order: [AWS-mutating]AssertHomeGeo— fails closed (ResidencyViolation) ifhome_geo ≠ control_plane_geo.FinalBackup— optional, legal-hold-aware final hot ZIP to the in-geo KMS bucket (skipped only when erasure is intended).DropDatabase— drops the tenant DB on its cell leader (idempotent — a no-op if already gone;Catch→DeprovisionFailedon hard error).RevokeSecrets— deletes the tenant DB credentials from Secrets Manager (ADR-0018).EmitDeletionEvidence— sets registrystatus=erasedand emits the audit event + deletion certificate (ArcadeDB has NO native audit — this is the control-plane audit record).
- If the run fails, read
$.errorand re-run the same execution — it is idempotent (the drop is a no-op if the DB is already gone, secret deletion and registry write are convergent). Do not hand-delete resources out of band; let the state machine converge so the audit/evidence stays consistent.
Verification
- State machine execution reached
DeprovisionSucceeded. - Registry
TenantRecord.status == erasedfortenant_id, withupdated_atadvanced. - The tenant DB no longer exists on
cell_id's leader — a query/connect fordb_namereturns "database does not exist" (this is also the precondition a future restore would need, since RESTORE REQUIRES THE TARGET DB TO NOT EXIST). - The Secrets Manager secret at
secret_arn_pointeris deleted/scheduled-for-deletion; ESO no longer syncs it. - Final retained backup ZIP is present in the in-geo KMS-encrypted bucket with the agreed
retention_window(normal offboarding only). - A deletion-evidence audit event + certificate were emitted and are retrievable.
- Capacity reclaimed on the cell — re-run
cell-capacity-reportto confirm headroom moved (no per-DB quota exists, so capacity is tracked at the control plane).
Rollback / if it goes wrong
- There is no "un-drop." Once
DropDatabasesucceeds the DB is gone. Recovery is restore-from-backup only: userestore-tenantagainst the final retained ZIP (plus EBS snapshot lineage if needed). Remember RESTORE REQUIRES THE TARGET DB TO NOT EXIST — restore into a fresh/renamed DB, never over a live one. - Stopped after
FinalBackup, before drop: safe to abort. Reset registrystatusback toactive/suspended; the tenant is unaffected. - Drop succeeded but a later step failed: re-run the execution (idempotent) to converge
RevokeSecrets+EmitDeletionEvidence; do not leave the secret or registry in a half-state. - Wrong tenant dropped: treat as a Sev-1 — invoke
incident-triage, thenrestore-tenantfrom that tenant's most recent backup into a new DB and re-point the secret/registry. Preserve all evidence. ResidencyViolation: you ran from the wrong geo. Stop, switch to the correct in-geo control plane, and re-run; never reroute the data across the EU↔US boundary.
Related
tenant-erasure— RTBF/DSAR legal erasure (same state machine,retain_final_backup=false; the load-bearing difference is no retained backup + erasure evidence).provision-tenant— the inverse onboarding flow.restore-tenant— recover a tenant DB from backup (only path back after a drop).cell-capacity-report/retire-cell— reclaim/confirm capacity after offboarding.- Artifacts:
../../../control-plane/provisioning/deprovision.asl.json,../../../control-plane/registry/schema.ts,../../../control-plane/router/index.ts. - ADRs:
../../../docs/adr/0007-residency-enforcement-scp.md,../../../docs/adr/0008-tenant-registry-dynamodb.md,../../../docs/adr/0015-backup-cronjob-sidecar.md,../../../docs/adr/0016-snapshot-aws-backup.md,../../../docs/adr/0018-secrets-secrets-manager-eso.md,../../../docs/adr/0027-runtime-tenant-governance.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

