CAREFLOW BUILD JOURNALENTRY 011 · JULY 8, 2026
Operations became architecture

The runbook that rejected the schema.

The onboarding code had passed its tests. Then the operator guide placed idempotency beside tenant transfer—and proved our database could not represent the procedure we had documented.

01 · The contradiction

Two correct paragraphs described one impossible sequence.

One section promised idempotent onboarding. Another explained how an identity could move between tenants. The schema allowed only one row for an identity-provider subject anywhere, so the old relationship could not remain as history while a new one became active.

Guide §5

Retry safely.

Return the existing relationship when the request repeats.

Guide §6

Transfer safely.

Preserve history while establishing a new active relationship.

02 · The dangerous workaround

Deleting first satisfied the constraint—and violated the operation.

An instruction to delete the old row before creating the new one would erase history and create a failure window. If creation failed after deletion, the identity would belong nowhere. Operator discipline could not turn that into an atomic transition.

03 · The schema-level answer

Uniqueness belonged to the active state, not all history.

We added lifecycle status and replaced global uniqueness with a partial unique index. PostgreSQL supports enforcing uniqueness only among rows that satisfy an index predicate. The database could now retain historical relationships while rejecting two active owners for the same subject.

The transfer still required a transaction and concurrency tests. The index was an invariant, not a complete workflow.

04 · Evidence

The test identity had to be capable of failing.

Local tests and production can use identities with different privileges. We expanded verification to prove idempotent retries, retained history, rejection of a second active row, rollback after interruption, and behavior through a production-like role.

05 · Decision ledger

Move operational truth into enforceable state.

Docs review is design review.

A runbook must explain time, retries, reversal, and partial failure.

Preserve history.

A transfer should not require deleting the evidence of its prior state.

Encode the invariant.

The database—not operator memory—rejects two active owners.

Test the real boundary.

A green result matters only when the test role can fail appropriately.

Field check

Before trusting an onboarding schema.

  1. Can the runbook explain retry, transfer, rollback, and recovery?
  2. Does any procedure require deleting history before success?
  3. Which invariant is enforced by the database?
  4. Can two concurrent transfers violate the intended state?
  5. Does verification use a production-like database role?
Primary sources

Documentation behind the design.

PostgreSQL: Partial Indexes
PostgreSQL: Constraints
PostgreSQL: Transactions

Educational material only. This dated CareFlow implementation is not a universal identity or database prescription.

Visual edition

The runbook that rejected the schema.

A narrated account of the contradiction, the unsafe workaround, and the database invariant that made transfer enforceable.

How operational documentation exposed a lifecycle the original schema could not represent.