ADR-077: Admin-Unit Scoping — The Worker→Unit Registry and Claim Enrichment

Status

Accepted (2026-09-17). The program landed as epic &95 in nine MRs — U0 !1651 (the plan page + this ADR, Proposed 2026-09-16), U2a !1652 (#1898), U1a !1653 (#1899), U1b !1654 (#1900), U3a !1656 (#1901), U3b !1657 (#1902), U2 !1658 (#1903), U4 !1659 (#1904, merged 2026-09-17) and U5 !1660 (#1905, the close-out); plan: Admin-Unit Scoping (#1086). Drafted FIRST per the draft-first path as U0 of #1086. Architecture B was ratified by the maintainer on 2026-08-29 (the A/B/C fork of 2026-08-09); the design took a five-lane research pass, a contextless critique and the maintainer’s 15-finding gate on rev 2 (2026-09-16), approved as rev 3 with rulings R1–R4. U2 (!1658) was the first consumer of the enrichment; acceptance is recorded at the close-out, with U4 (!1659) merged. The As-built notes under the decisions record where the merged tree differs from the text as approved (each traces to a plan-page erratum or a named pin).

Context

#1086 was filed at Step 0 of the subsidy-agreement foundation plan when review 2 flagged the Texas regional authz rows as an over-grant, and parked 2026-08-09 at a three-way fork: (A) the IdP mints an assigned_units claim, (B) CRAIG owns a worker→unit registry and the engine enriches claims, © a store-side office doctrine. The maintainer ratified B on 2026-08-29. Five read-only research lanes, a contextless critique and the maintainer’s rev-2 gate (15 findings, each re-verified against source) fixed the constraints:

  • The over-grant is real but unreachable. 52 of the 56 rulesets/texas/texas-authz-*.json files declare the input i_regional ('regional_supervisor' in claims.roles): 50 carry the template row (allow, scope "all", reason "regional_supervisor: admin_unit-scoped (Texas)" — the pre-#1904 shape; the token appears nowhere under rulesets/ since !1659), foster_portal declares it unused, subsidy_agreement carries the #1083 DENY. regional_supervisor is NOT a realm role — the office role is regional_director, held by rita.regional alongside supervisor — so no identity can hit the row today. Two authz jurisdictions exist (georgia, texas; testonia has no authz files).

  • The engine is purely token-fed, with THREE entrypoints. build_check_input / build_scope_input (crates/craig-authz/src/engine.rs:1238 / :1276) emit claims.{sub, preferred_username, roles, is_service, service_id, channel} and nothing about units; check_typed, auto_scope_list_typed and resolve_field_permission (engine.rs:1049 / :1118 / :1157) each build their own input (the field path through build_check_input); compile_fetched holds the raw JDM; the engine caches RULESETS, never decisions.

  • Scope handling is not uniform. 35 auto_scope_list call expressions fan out to 46 list handlers (the security and rules helpers cover 9 and 4). 13 production sites match ListScope NON-exhaustively — matches! + if let Custom, then the UNFILTERED query (field_proposals.rs:117 would list every proposal under a new variant; health.rs:208 / :464, education.rs:278, foster_homes.rs:338, exchange transactions / partners / agreements, reporting quality / ncands / afcars, financial rates / claims); wildcard_enum_match_arm = deny cannot see them and validate_authz_coverage only checks that a handler calls the engine. craig-cases lists run through the ADR-049 channel (ScopeConstraints is Copy, scalar binds only).

  • Checks do not all see the row. Report / referral GETs and eleven other Report sites check attr-less refs BEFORE fetching; investigation create checks before fetching its referral; financial’s check_lifecycle_authz and the adjustment approve / deny check id-only refs. admin_unit reaches attrs at exactly four places today (case refs, case create, foster-home refs); Report refs come from FOUR duplicate builders plus one inline literal.

  • Who carries admin_unit. Natively: cases, referrals, reports, foster_homes (mutable). NOT: payments, payment_adjustments, subsidy_agreements (case_id NULLABLE; NO create reads the projection — ERR / SG learn case_id from the placement S2S read AFTER the check; imports carry none), placements, kinship_options, investigations (referral-keyed; Texas assignment_area is a REGION token; read through v_investigations). case.created carries admin_unit; both case_assignments projections drop it; the seeds are ON CONFLICT DO NOTHING; the heals rewrite the PAIR and REVISION under a revision / pair predicate; financial takes a per-case advisory lock at per-diem birth (an absent projection row locks nothing under FOR SHARE) — placement has no such lock; the generator already row-locks agreements; adjustments copy their parent without a lock; the backfill upserts only strictly-newer revisions.

  • craig-security owns the vocabulary and its writers rename. admin_unit_registry (Georgia 159 / Texas 254 counties; unit_type unconstrained TEXT) is renamed / retyped through the PUT, the CLI and the xtask seed’s direct-SQL UPSERT; soft delete frees the name; worker_identities.attrs is clobbered to {} on every touch. The audit subscriber lifts the actor from created_by | approved_by | user_id | archived_by | sub and routes unknown security.* events to a catch-all (action = system, resource_type = security); extract_resource_id knows eight prefix families. validate_admin_unit matches case-insensitively (admin_unit_by_name lowercases both sides). rules-bootstrap creates only absent families; rules-promote takes one file.

  • The ADR-026 attrs path was never built. ADR-026 reserved worker_identities.attrs for IdP-mapped assigned_units and named claims.attrs.assigned_units as the authz expression; no mapper, no consumer and no ruleset ever used it, and every touch of the row clobbers the column.

Decision

Eight decisions. Each names its mechanism, then the alternative it rejects; the plan page carries the unit split, the test matrix and the rollout.

D1 — The registry is a NEW audited craig-security table with a resolvable subject

worker_admin_units { id uuidv7, worker_sub UUID NOT NULL, admin_unit_id UUID NOT NULL → admin_unit_registry, unit_name TEXT NOT NULL, unit_type TEXT NOT NULL, jurisdiction TEXT NOT NULL, assigned_by UUID NOT NULL, assigned_at, revoked_at, revoked_by, version }, partial-unique (worker_sub, admin_unit_id) WHERE revoked_at IS NULL — a second assign of a LIVE (worker_sub, admin_unit_id) pair is 409 ADMIN_UNIT_ALREADY_BOUND (the admin-unit create’s conflict_typed shape); a single-row worker_admin_units_meta (generation BIGINT) bumped inside every assign / revoke transaction (the keyring_meta shape). Writes: POST /v1/security/admin/workers/{sub}/admin-units (ADR-062 claim security.assign_worker_admin_unit), DELETE …/admin-units/{id} (soft revoke, If-Match; a replay is 200); GET …/admin-units/{id} answers REVOKED rows too. Authority = ResourceType::WorkerAdminUnit
{j}-authz-worker_admin_unit.json ×2 (admin only; readonly read / list). Events security.worker_admin_unit.assigned { binding_id, worker_sub, admin_unit_id, unit_name, jurisdiction, created_by } / …revoked { binding_id, …, user_id } — keyed on the names the audit actor chain already lifts — with EXPLICIT audit arms above the security. catch-all (assign_admin_unit / revoke_admin_unit, resource_type = worker_admin_unit) and a NINTH extract_resource_id family resolving binding_id, so GET /v1/security/audit/resource/worker_admin_unit/{id} lists both acts. No craig-web page: the CLI (craig worker-unit assign | revoke | list — the CLI takes --sub <uuid> or --username <name> resolved through GET /v1/security/workers?search=, exactly one match, else a typed error) and the API are the operator surface (a Studio page is #1907). The devstack seed binds rita.regional to Harris and Travis. As-built (#1907): the admin-only Studio page /studio/worker-units is now the browser surface (find a worker by name or worker ID, list the live bindings, assign from the jurisdiction’s active counties, revoke under If-Match, read a binding’s audit rows), so "No craig-web page" here and under Neutral records the U1a scope; the CLI and the API stay the scriptable surface.

Rejected: worker_identities.attrs JSONB as the store (clobbered on every touch, unaudited); revoked_by as the revoke event’s actor key (the audit chain does not lift it — the sibling partner.key_revoked records system today, #1913).

D2 — The token is the unit NAME, frozen at assign; counties only

Assign reads the registry row FOR SHARE, refuses unit_type != 'county' or active = false (typed 400 ADMIN_UNIT_NOT_BINDABLE; parish / borough join the allowlist with the first bundle that seeds them ⁂) and copies unit_name / unit_type onto the binding. The snapshot is a read of BINDING rows (unit_type = 'county' AND revoked_at IS NULL), never the live registry. update_unit / delete_unit — API, CLI and the xtask seed’s UPSERT — gain AND NOT EXISTS (live binding): a rename / retype / deactivate of a BOUND row is 409 ADMIN_UNIT_BOUND (revoke first; deactivation never cascades to revocation). As-built (#1899, U1a): ANY PUT on a bound row is refused, fips_code / state_fips edits included — a split SET would make the guarded-update miss ambiguous under version drift; revoke first. Rename procedure: new row → revoke / re-assign each binding (audited) → deactivate the old; stamps carrying the old name fall outside the new scope (the stamp-rewrite xtask is #1911). The create paths that mint stamps — CreateCaseRequest, CreateReportRequest, foster-home create / update — validate via validate_admin_unit(State::from_jurisdiction_key(..)) and PERSIST the returned canonical unit.name (the lookup is case-insensitive; typed 400 INVALID_ENUM_VALUE; pre-1.0 Changed). The token stays a plain String across Ready(Vec<String>), ListScope::AdminUnits, ScopeFilter::Units and BindValue::TextArray — the primitive IS the concept (the validated admin_unit TEXT vocabulary the four native columns already carry); no newtype.

Rejected: the registry id as the token (four native TEXT admin_unit columns would migrate); immutable registry names outright (operators seed and correct the registry; the bound-row 409 freezes only what is in use).

D3 — Enrichment is an engine-side port consulted by ALL THREE entrypoints, only for rulesets that declare a unit token

craig_authz::WorkerUnitsSource (units(worker_sub, jurisdiction) → UnitsAnswer::{ Ready(Vec<String>), NotReady(reason) }) on ZenAuthzEngine via AuthzBootSpec (ONE test double, craig_authz::StaticUnitsSource). compile_fetched records consults_units on CachedRuleset from the D5 census — the o_scope cell parsed as JSON for the LIST marker, and the expression token claims.admin_units in any input field; one helper units_for(entry, claims, jurisdiction) runs between lazy_load and the input build in check_typed, auto_scope_list_typed AND resolve_field_permission (the field path inherits through build_check_input). claims.admin_units is ALWAYS a JSON array — [] for service principals and for non-consulting rulesets; an absent key would make i_unit_match an evaluation error. A consulting ruleset with NotReady → AuthzError::UnitsUnavailable → typed 503 ADMIN_UNITS_UNAVAILABLE on all three paths — never [], never FieldPermission::None, never collapsed to Denied by the untyped auto_scope_list. Georgia rulesets declare no unit token and pay nothing. As-built (#1903, U2): the port is installed through ZenAuthzEngine::set_units_source (the set_eval_budget shape), and an engine nobody wires DEFAULTS to StaticUnitsSource::not_ready(Unconfigured) — fail-closed, NotReady to every consult; units_for is a private engine method; the census locates the LIST marker by the output whose field == "scope" (o_scope is the id, used above as shorthand) and flags any input field containing claims.admin_units.

Rejected: a per-request S2S read of the worker’s units from every handler (46 list handlers and every check site would each carry the dependency; the engine is the one seam all three paths cross).

D4 — The source is a verified snapshot whose monotonicity is a server-issued generation

craig_bootstrap::admin_units::SecurityUnitsSource: the service’s own principal reads GET /v1/security/worker-identities/admin-units?jurisdiction= — service-only, admitted by ONE {j}-authz-worker_identity 1.3.0 row claims.is_service && resource.attrs.projection == 'admin_units' ABOVE the service DENY (deliberately wider than the #1850 allowlist-of-one: every engine-bearing service); the map sub → [unit_name] + registry_generation, no PII, no-store — under a 4 s budget; the client reuses and re-documents the existing security_base_url leaf (crates/craig-common/src/settings.rs — today documented as placement-only and degrade-on-unreachable; after U2 every engine-bearing service reads it and the snapshot path is 503-class while the display-name path still degrades); the store reads the generation FIRST, then the rows, in one transaction. A Critical admin-units-verifier re-reads every 60 s AND on security.worker_admin_unit. — each service that boots an authz engine subscribes in the composition cache-invalidation shape (subscribe_exclusive: a per-instance exclusive queue bound to security.worker_admin_unit. on craig.events, no inbox, no idempotency row — the handler only calls refresh_now()); only the craig.events exchange rides the operator-owned topology (ADR-003 #1202) — the exclusive queue and its binding are declared by the consumer at subscribe time, as composition’s invalidation subscriber does today — and each subscriber is a mq-consumer entry in contested-surfaces.toml (the two-path rule applies). The three callers (cadence, event, refresh_now()) serialize on one mutex and never coalesce onto an in-flight fetch; a snapshot installs only when generation > held (equal = no-op; lower = refused + WARN). A snapshot older than CRAIG_<SVC>ADMIN_UNITSMAX_AGE_SECS (default 300, injectable) answers NotReady(Stale). The verifier records admin_units_snapshot_verified{jurisdiction} (the authority_surface_verified shape) and logs the missing-1.3.0-row remedy on a 403; readiness is NOT gated on it. craig-security reads its own table; the #1369 BootSpec gains verify_units. As-built (#1903, U2): the spec field is AuthzBootSpec.units_source: UnitsSourceSpec — UnitsSourceSpec::http (the shared client, security_base_url, the service’s OWN principal) for the seven HTTP consumers, UnitsSourceSpec::custom over craig-security’s own-table OwnTableSnapshotSource — plus the age bound, resolved into the ONE SecurityUnitsSource by boot_authz_engine; security_base_url was LIFTED from PlacementSettings to ServiceSettings (env names unchanged; a twin would be the cases_base_url flatten hazard) — craig-rules takes the HTTP source like the other six, its first outbound HTTP edge (rules → security); the contested census keys on CALL SITES, not services: ONE mq-consumer.craig-bootstrap.admin_units entry at the single subscribe_exclusive (both two-path legs), s2s-client.craig-bootstrap.admin-units (the shared fetch body) and seven s2s-client.<svc>.security-admin-units consumer entries (craig-security’s own-table read is not an S2S client); the eight per-instance queues <svc>.authz-cache.units.{uuid} sit inside each service’s existing authz-cache broker ACL and are recorded in the deployment guide’s topology row.

Rejected: fetch-start ordering as the monotonicity (request start ≠ DB read order — a later-started fetch can carry an earlier read); coalescing callers onto an in-flight fetch (a refresh_now() issued after a revoke must observe the revoke); /readyz gating on the snapshot (a craig-security outage would evict the fleet).

The ruleset cache’s refresh guard (RulesetCache::supersedes, crates/craig-authz/src/cache.rs) orders competing commits by fetch-START instant — the same non-monotonic shape, for RULESETS. It is bounded there by the policy TTL and by promotion-only changes (a stale commit can hold a superseded revision for at most one TTL window); recorded here, out of this program’s scope.

D5 — LIST scope is a TYPED filter every handler matches exhaustively; every CHECK on a unit-bearing type sees the row

ListScope gains AdminUnits(Vec<String>). The wire is pinned literally: the o_scope cell is exactly {"custom": {"scope": "admin_units"}}; parse_scope_output maps THAT custom payload to ListScope::AdminUnits(units) and leaves every other custom payload as Custom; compile_fetched parses the cell as JSON (not a substring) when flagging consults_units, and flags the expression token claims.admin_units wherever it appears in an input field; the CHECK input is {"id": "i_unit_match", "name": "UnitMatch", "field": "resource.attrs.admin_unit in claims.admin_units"} (an absent attrs.admin_unit evaluates false — a NULL stamp never matches). ListScope also gains #[must_use] fn filter(&self) → ScopeFilter { All, Worker, Supervisor, Units(Vec<String>), Denied, Refused }; list_scope_verdict, refuse_custom_scope and PortalScope::decode are re-expressed over it. All 46 list handlers match ScopeFilter: the unit-bearing eleven (cases / referrals / reports / investigations / foster_homes / placements ×2 / kinship / payments / adjustments / subsidy_agreements) BIND admin_unit = ANY($n) (craig-cases via ScopeConstraints::AdminUnits, BindValue::TextArray, push_scope → {col} = ANY($n), admin_unit_column(); an entity without the column → Break(PageEmpty); v_investigations recreated; ScopeConstraints becomes Clone); every other handler’s Units arm IS its Denied arm; the 13 non-exhaustive sites become exhaustive matches; validate_authz_coverage gains a BLOCKING rule (if let .ListScope:: or matches!(scope inside a list handler fails validate). CHECK rule: every authz.check on Case / Referral / Report / Investigation / Placement / KinshipOption / FosterHome / Payment / PaymentAdjustment / SubsidyAgreement carries attrs.admin_unit — from the ROW through the type’s ONE builder fetched BEFORE the check (the get_payment shape; existence-first 404), from the BODY on report / case / foster-home creates (after the canonical-name belt), from the pre-check case_assignments read on placement / kinship creates, from the referral fetched BEFORE the check on investigation create; a NULL stamp = attr ABSENT. The four duplicate Report builders + conversion_resource collapse into one; inline Case / Report / Kinship / Payment literals route through builders; check_lifecycle_authz and the adjustment approve / deny fetch-then-check. Recorded exceptions: subsidy-agreement creates (the case is unknown pre-check; i_unit_match is authored on Read / Update / Approve rows only) and nil-id List / sweep checks. The existing {"admin_units": [..]} fail-closed pins keep payload AND expectation (Refused). *As-built (#1902, U3b; #1903, U2): the fetch-before-check reorders are 13 handler paths / 10 code edits (check_lifecycle_authz is ONE fn behind approve / issue / clear / void; the attachment delete was already existence-first and only routes its literal); the recorded nil-id exceptions are SEVEN sites — the subsidy-agreement create, the payment calculate preview, subsidy generation, the review sweep and its run reads, the foster-home matching check(List) and the expiry sweep — each carrying a // authz-unit: nil-id exception — marker and pinned as the census by recorded_nil_id_exceptions_are_exactly_these (validate_authz_coverage); a field-proposal accept AND reject on a vanished foster home answers 404 naming the home BEFORE any check (decide_on_a_vanished_home_is_404_before_any_check); ScopeConstraints already was Clone — as built it drops Copy.

Amendment (2026-10-08, #2225): SubsidyBackpay joins the CHECK set (ruling 3 of 2026-10-07 on #1115): its ONE builder (backpay_record_ref) carries the agreement’s stamp, fetched BEFORE the check (an unknown agreement or record is 404 first), and UNIT_BEARING_TYPES holds eleven types. subsidy_backpay_batch is a recorded exception to unit scoping (ruling F-2): a batch spans agreements, so the type sits outside the set, carries no nil-id marker, and leaves the nil-id census at seven. Both ship admin-only.

Amendment (2026-10-08, #1928 / #1909): FosterHomeCaregiver and HomeDocument join the CHECK set (the maintainer’s rulings of 2026-10-06) and UNIT_BEARING_TYPES holds thirteen types. The caregiving-unit ref (UnitFacts::resource_ref) already carried its unit’s admin_unit, a foster home’s or a kinship household’s (#2058), both NOT NULL. The home-document ref (home_document_resource_ref) now carries the parent home’s LIVE admin_unit, read by the home fetch each handler runs before its check (NOT NULL: a live home has no absent-key path). The caregiver-bindings service read (bindings_for_subject: a portal subject’s bindings across units, service-only) is the eighth recorded nil-id exception: making the type unit-bearing turns its nil-id literal into a blocking UnmarkedNilId, so the literal carries the // authz-unit: nil-id exception — marker and recorded_nil_id_exceptions_are_exactly_these lists eight sites. Neither type is listed through the list scope, so neither binds a unit list. The education / health creation-time stamp (#1909 (b)) is outside this amendment.

As-built (#2666): the nil-id census moved from the recorded_nil_id_exceptions_are_exactly_these test const to xtask/authz-nil-id-exceptions.txt (since #2300 the ledger xtask/baselines/authz-nil-id-exceptions.toml), which the authz-coverage gate enforces itself (validate and --bail-on-bypass); the eight sites are unchanged.

Amendment (2026-10-09, #1909 (b), plan child-record-unit-stamp U2, #2234): EducationRecord and HealthRecord join the CHECK set and UNIT_BEARING_TYPES holds fifteen types. Each type has ONE builder (education_ref / health_ref) carrying the record’s creation-time stamp (the D6 amendment below) as attrs.admin_unit, a NULL stamp leaving the key absent: the row refs read the row; the field-proposal decision loads its target record first (soft-deleted included; an absent record is 404 before the check); the create refs carry the unit of the handler’s pre-transaction episode read and replace the type-variable nil_record_ref; the child-fact routes carry the child’s latest live episode unit. A create replay is answered only after Action::Read on the stored record’s ref. No literal is a nil-id exception: the census stays at eight. The three child-record lists join the lists that BIND admin_unit = ANY($n) in page and count; their Worker and Supervisor arms keep the empty page (#1912). Whether a role consults the unit stays each jurisdiction’s rules (D7); no shipped ruleset reads it for these types until the Texas rows (U3).

Rejected: a dynamic scope cell (the ruleset emitting the unit list itself — the engine would bind ruleset output; the static marker keeps the JDM census a scan and the bound list a server fact).

D6 — The stamp rides the projection under ONE lock protocol, healed and backfilled unit-only

case_assignments.admin_unit TEXT NULL ×2 (placement, financial), seeded from case.created (the seed’s DO NOTHING becomes DO UPDATE SET admin_unit = EXCLUDED.admin_unit WHERE admin_unit IS NULL) and from case.assignment_changed, whose new admin_unit key is OPTIONAL at every consumer (COALESCE(EXCLUDED.admin_unit, admin_unit) in the upsert; exchange ignores it) because retained pre-upgrade envelopes reach the parser after the cases image ships — staged-but-undrained outbox rows at the restart, queued deliveries, and admin replays past the 31 d inbox window (POST /v1/admin/events/replay re-stages verbatim) — and the unit is not an authorization identity ordered by the revision: absent = NULL = fail-closed until the unit-only fill writes it; the identity keys keep the #1084 hard-required posture. Stamp columns admin_unit TEXT NULL + a partial index on placements, kinship_options, payments, payment_adjustments, subsidy_agreements, investigations. Protocol: every ROOT birth with a case_id takes lock_case_assignment (pg_advisory_xact_lock(hashtext('case-assign:' || case_id)), ported verbatim to placement) BEFORE its FOR SHARE projection read — placement / kinship after claim_first, create_agreement_active after the pay-exclusion lock, create_guardianship_agreement after the family lock, per-diem unchanged; both placement inbox handlers take it FIRST; every CHILD birth copies its parent under a parent-row lock (the generator’s FOR UPDATE OF a; create_adjustment’s SELECT gains `FOR SHARE); the generator never takes the case lock (a cycle). Heals are SEPARATE unit-only statements (SET admin_unit = ca.admin_unit WHERE … admin_unit IS NULL — never the pair or the revision), parents first — agreements → payments → adjustments; placements → kinship — run by case.created AND assignment_changed; the pair predicates stay byte-identical. backfill-assignments selects the unit and runs an unconditional, revision-independent unit-fill pass after the pair legs (projections, then resources, adjustments via the payments JOIN). investigations.admin_unit is stamped from the referral at create and BACKFILLED in the same cases migration (UPDATE … FROM referrals, total: referral_id NOT NULL, plaintext) that recreates v_investigations — additive, no floor bump. Imports and case-less agreements stay NULL (R3; #1908).

Rejected: a NULL arm inside the pair predicate (it rewinds a payload-born revision-N row); the #1084 hard-required assignment_changed key for the unit (retained pre-upgrade envelopes reach the parser after the cases image ships, and the unit is not an identity key — the identity keys keep that posture).

Amendment (2026-10-09, #1909 (b), U1 #2233 / U2 #2234): the child-keyed records carry a CREATION-TIME stamp, not a projection copy. education_records / health_records gain admin_unit TEXT NULL and unit_episode_id (the source episode). A create copies the child’s latest live removal episode and its unit, read FOR SHARE under a child-level advisory lock (hashtext('child-episodes:' || child_id)) that every episode writer takes after its case-level locks; a selection that moved since the check is 409 concurrent-modification, and a unit filled since is stamped. Both inbox handlers and backfill-assignments fill a NULL record from its source episode right after the episode heal (fill-only, app SQL); the migration backfills best-effort and bumps the floor; the BLOCKING invariant child_record_admin_unit_from_episode checks sourced rows. Lock order: case lock → child lock → episode → record.

D7 — Honest Texas rows on regional_director (R1), qualified

For a UNIT-BEARING resource the regional row = the TX supervisor row’s actions with i_unit_match on CHECK and the marker on LIST, the regional LIST row ABOVE the supervisor LIST row (one scope per evaluation; CHECK rows fall through, so a dual holder keeps both reads); the eight regional FIELD rows (foster_home / placement / health_record / education_record) are re-keyed with their CHECK twins. For a resource with no unit attribute the regional row = the supervisor row ONLY where that row is satisfiable at the resource’s check sites (R2); where the TX supervisor row keys on i_supervises and every check ref carries supervisor_sub: None (~35 types: rules / security skeleton_ref, reporting, exchange, rate / claim, health / education / home_document, person / report / referral / attachment / investigation) NO regional row is added — a pure regional_director stays default-deny and the dead supervisor rows are #1912. rule_evaluation keeps its two County director create (#1624) / Regional director create (#1624) rows byte-identical (the relayed eligibility consult) and texas_rule_evaluation_directors_create_only UNCHANGED; investigation keeps its County director / Regional director response-deadline override rows (#1748). The i_regional input is DELETED from all 52 files (grep gate: zero regional_supervisor under rulesets/); the subsidy DENY flips to the scoped shape; texas_regional_supervisor_role_recognized and the two subsidy pins are re-authored. The #1369 supervisor legs move to dana.county; rita.regional is the regional probe; fixtures seed a financial case_assignments row carrying the unit (grant_case_assignment_with_unit). Investigations take the referral’s county (R4 — Texas assignment_area is a REGION token). As-built (#1904, U4): the regional FIELD rows are two re-keyed (foster_home), four deleted (health_record / education_record — no admin_unit column, refs None) and two deleted (placement — the TX placement supervisor admits read + list only, so a field row has no update twin); "byte-identical" reads cell-identical on the declared inputs — the deleted i_regional input’s "" key is dropped from every row, and investigation’s two #1748 director rows gain an i_unit_match "" cell (texas_rule_evaluation_directors_create_only’s assertions stay byte-identical); `grant_case_assignment_with_unit serves Georgia births only — every subsidy write route is require_georgia, so the TX live harness raw-seeds agreements / payments and stamps admin_unit directly; the "~35 types" is a census, not a contract — as built the non-unit Texas files split into those with NO regional_director row (read from the tree) and the three R2 copies whose supervisor row IS satisfiable, contact_attachment, icpc_request and foster_home_caregiver (the last per #1928), rule_evaluation’s #1624 director rows predating the program; NO realm-flat regional arm sits above `i_unit_match anywhere — the nil-id generator / sweep / run-read / expiry-sweep / matching checks fall through the unit row, so a pure regional_director is refused exactly where a Texas supervisor is (the subsidy CHECK row is i_regional_director + i_unit_match + 'read'; foster_home’s regional CHECK row is the wildcard-action unit row, so a real-id home ref admits in-unit Approve = proposal accept); the dual-holder order — the unit LIST row above the supervisor LIST row, the CHECK rows falling through — is pinned in-process by texas_dual_holder_lists_units_and_keeps_the_supervised_read; the changed-file set equals the former i_regional set (former_i_regional_set_equals_the_changed_set) behind the grep gate no_texas_authz_file_declares_i_regional; seven regional pins were re-authored (four renamed for the property they now assert) and texas_regional_supervisor_claims() retired for regional_director_claims() / the bound bound_regional_claims().

Amendment (2026-10-08, #1928 / #1909): foster_home_caregiver leaves the R2 copies. Its supervisor copy, dead since #2058 because no caregiving-unit ref carries a pair, is deleted. It and home_document take the unit CHECK row: the supervisor row’s action-wildcard shape keyed i_regional_director + i_unit_match. The row is CHECK only, with no LIST marker: neither type is listed through the list scope, and a 'list'-keyed marker row would answer the caregiver list’s per-unit check(List) with a unit-blind allow. Twelve Texas files now consult units (exactly_the_twelve_texas_unit_files_consult_units: ten with both legs, two CHECK-only). The R2 copies are contact_attachment and icpc_request. home_document leaves the no-unit list above. Georgia is unchanged.

Amendment (2026-10-09, #1909 (b), plan child-record-unit-stamp U3): education_record and health_record leave the no-unit list — their checks carry the unit (the record’s creation-time stamp, or the child’s latest live episode unit on a create and the child-fact routes) since the D5 / D6 amendments of U2 — and take the foster_home shape, each file 1.3.0 → 1.4.0: a Regional director: unit LIST (#1909) marker row above the case-scoped supervisor row (the scope the three child-record lists bind), the action-wildcard Regional director: unit CHECK (#1909) row keyed i_regional_director + i_unit_match, and that row’s state and shared field twins — the four regional FIELD rows the U4 as-built note records as deleted return as two per file, keyed on the unit pair. The supervisor rows are not re-keyed (#1912). A check reads only allow, so the LIST row admits a check(List) on the role alone; no handler sends either type one (child_record_lists_resolve_scope_only_through_auto_scope_list). Fourteen Texas files now consult units (exactly_the_fourteen_texas_unit_files_consult_units: twelve with both legs, two CHECK-only), and every human evaluation of the two types answers 503 ADMIN_UNITS_UNAVAILABLE while the worker-units source is not ready. Georgia is unchanged.

ADR-054 D1 note. In Texas the office role regional_director ALSO carries unit-scoped OPERATIONAL rows. The approval-floor axis stays the ADR-074 family — office roles authorize floors there and operations here — and the reading that a Texas regional director operates inside assigned counties is a jurisdiction reading ⁂ #1073 — landed on ADR-054 (#1905).

Rejected: adding regional_supervisor as a tenth realm role (a second regional token with no IdP holder and no office meaning, bought with a fleet contract change — IdP configs, DDL — for a name the rows never needed); a resource-less regional_director grant on the ~35 non-unit types (widens the very over-grant the program retires).

D8 — Rollout gates on the derived manifest and the gauge

A new cargo xtask rules drift [--strict] classifies every JDM file against the live service (absent → bootstrap, behind by version or canonical content → promote, current); no count is ever a literal. Per environment: the registry image + rules-bootstrap worker_admin_unit ×2, the projection image + rules-promote worker_identity 1.3.0 ×2, rules drift --strict green; the cases image FIRST (the optional key), then placement / financial images
migrations + backfill-assignments, then the check-census images; the engine images, GATED on admin_units_snapshot_verified{jurisdiction} = 1 on every engine-bearing service (readiness stays green while unverified); then rules-promote every file rules drift reports behind (the 52 + any twin); nothing product-side ships with that step. As-built (#1900, U1b; #1904, U4): rules drift also prints a fourth status, fixture, for FIXTURE-JURISDICTION files (testonia, #1621 — never looked up, outside --strict; the classifier stays absent | behind | current); the approved text put the Texas rows in images for the last step, but no engine evaluates a JDM file from its image (the placement / composition images copy rulesets/ for their .toml surfaces, the seed image’s copy is what seed.sh POSTs into craig-rules; every engine reads the live craig-rules row), so step 7 of the deployment guide’s rollout section is the per-file two-step promote over the verified gauge (rules-promote takes ONE file; the printed execute line carries --confirm-preview <id> AND --acknowledged-thin-corpus; the guide’s loop over the drift manifest is the idiom, the batch form is #1930) and the devstack converges through cargo xtask dev reseed.

As-built (#1920): the classifier gains ahead — the live version strictly newer than the file’s, by a numeric version order over semver 1.3.0 and the seed’s v1.0 (a pair with an unparsable side stays behind by inequality); its remedy brings the tree up to the live row (rebase onto the commit that carries it, or commit the live content to the file) and never names a promote, and --strict fails on it.

Rejected: a literal file count as the promotion gate (the 52 is a census, not a contract — the drift manifest is derived from the tree).

Consequences

Positive:

  • A worker’s units are a CRAIG fact — audited, revoked in one act, resolvable by GET /v1/security/audit/resource/worker_admin_unit/{binding_id} — with no IdP mapper, no per-deployment claim contract and no second identity model (the ADR-026 neutrality claim is unchanged; its attrs reservation is superseded).

  • Unit scope is a TYPED filter: ScopeFilter + the BLOCKING validate_authz_coverage rule turn the 13 silent non-exhaustive sites into a lint failure rather than a leak, and no future variant can fall through to an unfiltered query.

  • Every check on a unit-bearing type sees the row’s stamp, so i_unit_match decides on a fact the handler fetched, not an id-only ref; every birth with a case takes ONE lock protocol, so no root or child row is born unit-less while its projection row exists.

  • The Texas rows say what they mean: regional_director is scoped to the units it is bound to, the unreachable regional_supervisor token is gone, and a pure regional director is default-deny wherever the supervisor row is dead.

  • Georgia pays nothing: no Georgia ruleset declares a unit token, so no Georgia evaluation consults the source.

Negative / accepted:

  • The authz engine gains a BOUNDED cross-service dependency on craig-security: consulting evaluations only, one verified snapshot per service refreshed on cadence + event, MAX_AGE 300 s, a typed 503 while it is not ready. Readiness is deliberately not gated on it.

  • The frozen-name token makes a unit rename a PROCEDURE (new row → re-bind → deactivate the old) with 409 ADMIN_UNIT_BOUND in the way, and old-name stamps fall outside the new scope until #1911’s rewrite runs.

  • 52 hand-edited Texas files change shape in one unit; the guard is rules check + twin parity + the computed-set pins (the changed-file set equals the i_regional set), never a literal count.

  • ScopeConstraints loses Copy (the array bind) — every craig-cases scope site that copied it clones.

  • Pre-1.0 Changed: the canonical-name belt persists unit.name on case / report / foster-home creates; six new nullable stamp columns; assignment_changed gains an optional key; the i_regional input disappears from every Texas authz file.

  • Six fail-closed postures a reader must know: NotReady → 503 on check, list AND field permission; an empty unit list → an empty page, never a widened one; a NULL stamp is outside every unit scope; a Custom of any shape but the marker → Refused; a snapshot older than MAX_AGE → 503; a lower generation never replaces a held snapshot.

Neutral:

  • No craig-web page for bindings (CLI + API; a Studio page is #1907); no realm-role change; every migration in the program is additive (nullable columns, a new table, a recreated view) — no schema-floor bump.

  • Case-less agreements, imports and payments stay NULL-stamped and therefore outside every unit scope (R3; #1908).

  • The ruleset cache’s fetch-start guard keeps its shape (the D4 note).

Open questions

  • Whether DFPS regions enter the registry as a HIERARCHY over counties rather than a second unit_type the allowlist refuses — ⁂ #1073, tracked as #1906.

  • Which unit a case-less subsidy_agreement / payment / import belongs to (R3 left them NULL; approving_county was the rejected stamp) — ⁂ #1073, tracked as #1908.

  • When parishes and boroughs join the county-only allowlist — with the first bundle that seeds them (D2 ⁂); no issue until a bundle does.

  • Whether the dead Texas i_supervises supervisor rows (every check ref on ~35 types carries supervisor_sub: None) are re-keyed or deleted — #1912 (fix:), decided outside this program.

Alternatives considered

  • A — the IdP mints an assigned_units claim (the ADR-026 attrs path). Rejected: a per-deployment mapper contract on every supported IdP, no audit trail in CRAIG, revocation at token lifetime, and a reservation that was never built.

  • C — a store-side office doctrine (each service checks units in SQL against a local table). Rejected: a copy of the check in every engine-bearing service, none citable from a ruleset, and the Texas rows would still lie.

  • worker_identities.attrs JSONB as the registry. Rejected: clobbered to {} on every touch, unaudited, no generation (D1).

  • A per-request S2S read of the worker’s units from every handler. Rejected: the dependency would ride 46 list handlers and every check site instead of the one engine seam; the snapshot bounds it (D3).

  • A dynamic scope cell (the ruleset emitting the unit list). Rejected: the engine would bind ruleset output; the static marker keeps the census a scan and the bind a server fact (D5).

  • The registry id as the token. Rejected: four native TEXT admin_unit columns would migrate to UUID for a name that is already the vocabulary (D2).

  • A cadence-only snapshot (no event invalidation, no generation). Rejected: a revoke would take up to 60 s to bite and an out-of-order install could resurrect it (D4).

  • Fetch-start ordering as the snapshot’s monotonicity. Rejected: request start ≠ DB read order (D4; the ruleset cache’s guard is the recorded exception).

  • /readyz gating on the snapshot. Rejected: a craig-security outage would evict every engine-bearing service (D4).

  • A NULL arm inside the projection heal’s pair predicate. Rejected: it rewinds a payload-born revision-N row; the unit heal is a separate statement (D6).

  • The #1084 hard-required assignment_changed key for the unit. Rejected: retained pre-upgrade envelopes reach the parser after the cases image ships and the unit is not an identity key; the key is optional and absent = NULL (D6).

Amendment — #2999 (2026-11-08): the configuration layers left CRAIG’s source

ADR-087 U4 (#2955) moved the configuration layers out of CRAIG’s source. A rulesets/<j>/<file> path above now names <file> in layer <j>: the federal, Georgia and Texas layers are the craig-config-{federal,georgia,texas} repositories, pinned in config-sources.lock and fetched to target/config/layers/<j>/ by cargo xtask config fetch, and the synthetic testonia layer is fixtures/config/testonia/. No image carries configuration any more; the services and the seed read the fetched layers. The decision above is unchanged.

Edit this page · latest