tenant-engine/tests
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
..
test_api_lifecycle.py Implement tenant update and reversible retirement API (TEN-WP-0005 T01-T04) 2026-08-10 20:00:43 +02:00
test_api_reads.py Fix: resolve tenants by identifier, not only internal tenant_id 2026-07-24 00:15:26 +02:00
test_api_writes.py TEN-WP-0002 T04-T07: cache-read, live-lookup (fail-closed), write API, close 2026-07-23 22:24:09 +02:00
test_app.py TEN-WP-0002 T01-T03: service skeleton, domain model, storage layer 2026-07-23 22:01:23 +02:00
test_authz_flex.py TEN-WP-0003: FlexAuthWriteAuthorizer -- gate writes through flex-auth 2026-07-23 22:54:44 +02:00
test_domain.py TEN-WP-0002 T01-T03: service skeleton, domain model, storage layer 2026-07-23 22:01:23 +02:00
test_flex_auth.py TEN-WP-0003: FlexAuthWriteAuthorizer -- gate writes through flex-auth 2026-07-23 22:54:44 +02:00
test_lifecycle_domain.py Implement tenant update and reversible retirement API (TEN-WP-0005 T01-T04) 2026-08-10 20:00:43 +02:00
test_lifecycle_store_conformance.py Implement tenant update and reversible retirement API (TEN-WP-0005 T01-T04) 2026-08-10 20:00:43 +02:00
test_sqlite_store.py Deploy durable tenant authority runtime 2026-08-09 01:35:00 +02:00
test_store.py Fix: resolve tenants by identifier, not only internal tenant_id 2026-07-24 00:15:26 +02:00