tenant-engine/workplans
tegwick d6fd73bd42 Implement tenant update and reversible retirement API (TEN-WP-0005 T01-T04)
Add an explicit tenant lifecycle (active/retired), allow-listed mutable
metadata, record versioning, and lifecycle timestamps to the tenant authority.

- domain: TenantLifecycle, with_metadata/retire/reactivate, immutability and
  transition invariants. Identifier stays immutable -- it is the IAM Profile
  `tenant` claim key-cape mints into tokens.
- store: mutate_tenant() commits idempotency replay, version CAS, mutation,
  and audit event together; durable receipts survive restart. Retired tenants
  refuse new grants and plan changes but keep their history.
- sqlite: forward-only idempotent migration; existing rows default to active
  at version 1. Reads now take the write lock -- the concurrent-writer test
  caught unguarded reads on the shared connection observing mid-transaction
  state as a spurious tenant_not_found.
- api: GET/PATCH /tenants/{id}, POST retire|reactivate. Idempotency-Key and
  If-Match required, distinct flex-auth actions per operation, stable error
  schema, redacted 503s.
- docs/tenant-lifecycle-api.md: consumer contract for user-engine.

Implemented against SQLite, not PostgreSQL as the workplan assumed --
TEN-WP-0004 shipped SQLite on a PVC as the production store.

124 tests pass (was 66); no breaking change to existing endpoints.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 20:00:43 +02:00
..
ADHOC-2026-07-24.md chore(consistency): register ADHOC-2026-07-24 in State Hub [auto] 2026-07-24 00:16:21 +02:00
TEN-WP-0001-statehub-bootstrap.md chore(consistency): register TEN-WP-0001/0002 in State Hub [auto] 2026-07-23 21:56:43 +02:00
TEN-WP-0002-domain-model-and-scaffold.md TEN-WP-0002 T04-T07: cache-read, live-lookup (fail-closed), write API, close 2026-07-23 22:24:09 +02:00
TEN-WP-0003-flex-auth-write-authorizer.md TEN-WP-0003: FlexAuthWriteAuthorizer -- gate writes through flex-auth 2026-07-23 22:54:44 +02:00
TEN-WP-0004-production-runtime.md Sync tenant runtime workplan state 2026-08-09 01:49:11 +02:00
TEN-WP-0005-tenant-update-and-retirement-api.md Implement tenant update and reversible retirement API (TEN-WP-0005 T01-T04) 2026-08-10 20:00:43 +02:00