Skip to content

Import/Content restructure plan (ADR-0061)

Implements ADR-0061: Import and Content as separate terminal identities, before Phase 3 of the language module. Ruled 2026-08-03: restructure-first — Phase 3’s learner-visible slice (reader state, language events, client outbox) writes exactly the learner data whose keys this model changes, and pre-launch is the cheapest this cut will ever be (clients resync from scratch at cutovers; no data migration, no compat shims).

Slices land additively: new tables beside old, consumers moved slice by slice, old tables dropped only in the final cutover slice — every intermediate commit keeps validate and the integration lanes green. This is staged implementation of one short programme, not a strangler: the old entities take no new consumers from the moment slice 1 lands.

  • Producers: apps/api external-package import + binding services, personal-import, common-cartridge import, offering-duplication, offering-provisioning.
  • Processing: apps/api lang-enrichment (stage + rerun route), package-runtime.
  • Consumers: launch-session/cmi5, document-delivery, web-content-delivery, media-delivery, cartridge-export, telemetry readers (package-progress, media-playback), apps/content-runtime, apps/learner-web (offering-materials + viewport-content hooks), LRS storage references.
  • Registries: packages/db sync-registry (learner/teacher/admin entries for externalPackage/Version/Binding, mediaResource/Binding/PlaybackEvent, catalogResource, documentProgressEvent), erasure-registry (external_package, external_package_binding, media_resource, media_binding, cartridge_import, catalog_resource, the playback/progress events), packages/offline-data client registry + store names.
  • Integration lanes: media-sync-cycle, offering-contents-sync-cycle, mutations-api, oneroster-roundtrip, lang-event-lane, plus the A2-parity assertions landed in 2d7a5362 (media_resource / gradebook) whose exclusion proofs must survive the port.

Target schema (the shapes ADR-0061 implies)

Section titled “Target schema (the shapes ADR-0061 implies)”

import — one row per intake event. Homing: organization_id NOT NULL (personal-0 sentinel for personal space) + created_by_person_id (the personal ownership handle, A3 pattern). Intake: intake_kind (upload | cartridge; fetch reserved), source_file_name, source_sha256, size_bytes, storage_bucket/storage_key (nullable — recorded when the raw file is kept), status (pending/ready/failed) + failure_reason + report_payload (the cartridge per-resource report, generalized). Terminal at ready/failed. Deletable while unconsumed, enforced structurally: content.import_id is ON DELETE RESTRICT.

content — one processing of one origin. import_id nullable FK (RESTRICT); source (imported | reference | generated) + url + source_content_id with the per-mode CHECK from ADR-0061. kind merges the package kinds and media kinds (h5p, scorm-1.2, scorm-2004, cmi5, epub, pdf, audio, video, web-content). Homing: organization_id nullable (null = platform-global — media_resource’s tested null-org class survives the dissolution; amended from “mirrors import” at R1) + created_by_person_id. Metadata (LWW, mutable in place): title, description_payload, license_payload, estimated_duration_iso8601, the language-content declaration (stays payload-shaped for now; typed columns are a later decision), launch_kind (from the dissolved version). Processing: processing_state (none/processing_requested/processing/failed/processed), processing_engine_version, processing_attempts, processing_reason/processing_detail, processed_at. processed is terminal and frozen — structurally, from R1: a BEFORE INSERT OR UPDATE trigger refuses origin/processing changes on a processed row (the R3 freeze pulled forward), and the vacuous-processed rule is a CHECK plus mint-time derivation — a reference-source Content is minted directly at processed (nothing to process, consumable immediately), keeping the learner gate one uniform predicate. A typo’d reference URL is therefore not edited but replaced (ADR-0061 multiplicity-over-mutation). Learner reads gate on processed. No lifecycle_state — visibility is the binding’s job.

content_artifact — content_id FK CASCADE, role (e.g. runtime-bundle, enriched-package), storage_bucket/storage_key, sha256, size_bytes, content_type. Row-first, write-once, frozen with its Content. Pass-through artifacts (settled): for trivial processing (H5P/PDF as-is) the artifact row points at the import’s own object — no byte copy; identity separation is the row, and import bytes are immutable so the reference is safe. An import with contents is RESTRICT-protected, so pass-through can never dangle.

content_binding — replaces external_package_binding AND media_binding: offering_id, content_id, learning_unit_id, visibility_state, xapi_activity_root_iri + registration_strategy (nullable — media bindings have no xAPI surface; R5’s launch service enforces presence for launchable kinds), binding_kind, required_flag, available_from + due_at (+ CHECK), grading + cmi5 payloads (server-only), author. The A2 read-filter contracts port byte-for-byte: content is org-keyed (sentinel exclusion on the admin branch; the null-org globals disjunct is processed-gated — a deliberate R1 divergence from media_resource, which never rode the learner rail) and binding is offering-keyed (authority_level <> 'person' exclusion + member fan-out). The binding reach fence (R1 adversarial finding): RESTRICTIVE INSERT/UPDATE policies require the bound Content to be null-org, in the offering’s own org (non-personal path), or sentinel-org-and-authored-by-the-caller into the caller’s own personal offering — without it, any person’s personal-offering grant made a published binding a cross-tenant read primitive.

Learner-data keying (ADR-0061’s split):

  • stays on the binding (assignment outcomes): launch_session, package_progress, package_evidence_link — FK target swaps to content_binding, semantics unchanged.
  • rekeys to (person, content) (consumption): document_progress_event (reading state), media_playback_event. Settled: each keeps a nullable content_binding_id context column for the Caliper readers’ offering context — context, never the key.

catalog_resource gains content_id FK; the fabricated personal-document:<uuid> string stops being load-bearing (kept only as OneRoster vendor-facing projection detail). cartridge_import dissolves into import.

R1 — schema + registries. The four tables above in packages/db/src/schema; sync entries in all three registries (row filters ported from the external-package/media entries — the ADR-0056 exclusions are privacy contracts, ported predicates get unit tests mirroring personal-offering-exclusion.test.ts and must keep the 2d7a5362 Electric-level parity); erasure-registry entries for the four tables (old entries stay until R6); offline-data client registry + store names; append-forward drizzle migrations; migration-drift lane. Adversarial review: the ported RLS/row filters.

R2 — producers. import-service writes Import + Content (+ binding + catalog FK) instead of package + version + asset; personal-import-service likewise (the fabricated vendorResourceId link becomes the FK); common-cartridge import writes one Import → N Contents with real FKs and retires the cartridge_import table (report → import.report_payload; QTI/Ingest outputs stay outside Content per ADR-0009, recorded in the report as today); offering-duplication + offering-provisioning clone content_binding; test-support fixtures.

R3 — enrichment on the new model. runLangEnrichment targets a Content row: the status machine replaces the lang.v1 fold; artifact rows land row-before-object under a content-id-keyed temp prefix; the content-addressed-key protocol, compensating delete, and foldLangEnrichmentRun are deleted, not adapted; the rerun route names a content id; attempts + cap + dead-letter semantics (resurrection = direct SQL only). Closes the open “enrichment publish protocol integration lane” item against the new protocol: the lane proves row-first artifacts, the frozen terminal state, and the cap refusal. Schemes chosen at R3, recorded because ADR-0061 left both open. Storage key: <ownerPrefix>lang-enrichment/<contentId>.lang.v1.json, where the owner prefix is derived from the Content’s own homing (personalSpaceStorageKeyPrefix(createdByPersonId) in the sentinel org, <organizationId>/ otherwise) — one key per Content per role, overwritten by a retry, because content_artifact is UNIQUE on (content_id, role) and a pre-processed Content is invisible to every learner read. Deriving the prefix from the Content (rather than inheriting the source object’s key, as the deleted scheme did) also means a bad source pointer can no longer place derived bytes in someone else’s prefix. Engine version: lang-enrichment@<LANG_CONTENT_EXTENSION_VERSION>.<ENRICHED_CONTENT_VERSION> — the output-contract version, the only version signal that exists (CoreNLP/Bing return none, and the package version is the 0.0.0 release-standard placeholder). It does not move on an engine behaviour change that keeps the output shape; nothing branches on it, because attempts are never auto-reset on an engine bump. Concurrency is refused, not tolerated (R3 adversarial review). Two runs over one Content could interleave so the loser’s upload landed AFTER the winner published, leaving a processed, frozen row whose digest described bytes that were gone — unrepairable, and outside ADR-0061’s “overwrite temporary output” licence, which covers pre-processed output only. The Content row is now the claim: processing_requested/processing refuse a second run, and an operator breaks a dead claim explicitly (breakClaim on the rerun route). Chosen over a stale-claim timeout (turns a certainty into a tuning parameter; there is no usable claim clock) and a heartbeat. Paired with a content_artifact_freeze trigger: ADR-0061’s “write-once, frozen with their Content” was prose, and a losing attempt really did re-point a frozen Content’s bytes and rewrite the manifest_payload that carries its publication claim. An UPDATE that changes nothing is still allowed — provisioning re-asserts byte-identical copies.

Declines do not spend the cap (same review). The dead-letter rationale is singular: a fundamentally broken INPUT must not burn the cap on every release. A decline is the opposite fact — the input is fine, the platform is not ready — and no-text-extractor fires for every epub and pdf today, so counting it dead-lettered the exact kinds R2 leaves at none for enrichment to own. The attempt is now claimed at the CLAIM and counted at the START, past the decline gates: language-not-launched, no-text-extractor, no-import-object, nothing-enrichable and source-outside-owner-prefix record failed with a reason and no attempt; the cap still bounds engines-unavailable, run-failed and storage-failed.

content.organization_id is frozen and server-only (same review). The publication claim is derived structurally from the homing, so re-homing a processed personal Content turned a re-run into a promotion of that person’s private lexemes to platform vocabulary — and the recorded-provenance 409 could not fire, because lexemes mint before the artifact row that records the claim exists. The column joins the origin freeze’s list and leaves the client projection. Nothing legitimately re-homes a Content; provisioning creates rows, it does not move them. The 409 is kept as a pathological-state refusal whose trigger condition is now structurally unreachable.

Two consequences R3 recorded rather than solved. (1) The kinds whose import genuinely IS their processing (h5p/cmi5/scorm — player bundles with no text extractor and no plan for one) stay terminal at import, so a lang.v1 declaration on one is refused (already-processed). Declared web-content is NOT in that set: it was supported, reachable and tested before R3, so the import mints it none and enrichment owns the transition — while still writing its pass-through runtime-bundle artifact, because the bytes really are stored and only the state is owed. (2) The dissolved record’s three-valued outcome (enriched/skipped/failed) collapses to the state machine’s two terminals; the decline versus breakage distinction survives in content.processing_reason, and the run counters (lexemesMinted/lexemesPromoted) are no longer persisted anywhere — ADR-0061 rejects attempt history, so they exist only in the run’s return value.

R4 — media dissolution. media_resource/media_binding consumers move to content/content_binding: media-delivery-service, media-playback reader (rekeyed events + context column), the media-survey-demo seed, learner-web viewport hook; media-sync-cycle lane rewritten to the content shapes, preserving the A2 exclusion proofs (org-keyed sentinel exclusion now lives on the content entry).

The column inputs R2 left here, settled. description (text) → content.description_payload as { text: … }. content_type + size_bytes → content_artifact (both NOT NULL there, which is exactly right for an uploaded object; a reference Content has no artifact and no content type). storage_bucket/storage_key → import, plus a pass-through artifact naming the Import’s own object. duration_ms → content.estimated_duration_iso8601, with no new numeric column — that column already exists, already sits outside the origin freeze, and is already the repo-wide convention. captions_url → DROPPED, not ported. Both of the last two were dead: no producer ever wrote either (every create path hardcoded null). Captions’ designed replacement is already named in the ported engine’s own seam note — a stored caption track, which on this model is a content_artifact with role captions and needs no column on content at all.

Media authoring became SERVER-AUTHORITATIVE, which R3 forced. The teacher portal used to create media_resource rows client-side over the sync rail. That is structurally impossible on content: R3 removed organization_id from the client projection, so a client-authored insert could only ever land a null-org row the write RLS refuses. So the upload endpoint now mints import → content → pass-through content_artifact itself, a second endpoint registers a hosted URL as a reference Content (the vacuous-processed rule stamps it), and the client’s only remaining write is the content_binding placement. The alternative — re-projecting organization_id — was rejected: it reverses an R3 privilege-escalation fix.

Playback rekeyed to (person, content), with content_binding_id alongside as nullable CONTEXT. The RLS org expression became a CASE — the binding’s offering when a binding is present, else the Content’s own org. CONSEQUENCE, recorded because it will surprise someone: content.organization_id is nullable, so an unbound event on a platform-global Content matches no ORGANIZATION admin at all — only its owner and a platform admin. That is the correct direction to fail (a row with no organization has no organization admin), and a test pins it.

The rekey DISCARDS the table’s existing rows, in the migration. media_playback_event is the one table the “old rows die with their tables” non-goal does not cover — it is rekeyed here and SURVIVES R6 — and its new content_id is NOT NULL with no default, so on a populated table the migration would abort the whole lane. There is also nothing to backfill: an old row names a media_binding, and the Content its successor placement points at is minted fresh by R4’s producers, so no content_id is derivable for any historical event. The migration therefore carries a hand-added DELETE FROM "media_playback_event" ahead of the ADD COLUMN, which makes executable the claim the schema comment was already making. Pre-launch; clients resync from scratch.

Two Caliper rulings the rekey forced. An unbound event still PROJECTS — the reader LEFT JOINs the binding and omits the optional group — because losing telemetry to a null context is a worse error than emitting an event without a group. And the MediaProfile object IRI segment moved from media to content: the id is a Content’s now, and R5 projects the SAME rows from the document-progress reader, so two segments would make one Content two distinct objects in the LRS. The Caliper object TYPE (AudioObject/VideoObject) is what carries “this is media”, not the path.

content.launch_kind became NULLABLE with no default. It was NOT NULL default h5p, which made every media Content nonsensically an h5p launch. A Content that is never launched has no launch kind.

The closure is enforced POSITIVELY, not just by absence. media_resource/media_binding are off the sync write rail entirely (builders deleted, tables absent from the writable set) while the tables and their sync entries stay defined until R6 — an explicit deliberatelyUnwritableSyncTableNames set records that the absence is deliberate, since “readwrite entry with no batch branch” is also the normal shape of ~23 pessimistic-only tables and therefore no signal on its own. Every other enforcement is a NEGATIVE (a deleted builder, a removed gate entry) and a negative cannot fail when someone re-adds the thing, so the dual-write guard gained a second class: for a dissolved AND consumer-free table, ANY write token is the error and no twin discharges it. Their remaining legitimate touchers are the erasure sweep (both are sever on created_by_person_id), the sync entries clients still materialize, and the migration history.

Two things R4 recorded rather than solved. (1) The rewritten media-sync-cycle lane is correct by construction only: it typechecks and reuses the SHIPPED row-filter builders rather than hand-rebuilt equivalents, but it has never been executed — R6’s full run is its first. (2) content.estimated_duration_iso8601 is a STRING the Caliper reader passes through unrendered into MediaObject.duration, where the dissolved duration_ms was an integer the reader rendered. The type system stopped being the validator exactly when the value started reaching an external contract verbatim, so both writers (the media door and the sync rail’s content update) now validate the ISO-8601 shape through one @emergent/domain helper. The pre-existing external-package import routes accept the same column unvalidated and were left alone — that is R5’s to sweep.

R4’s migration set is four folders: media_playback_content_rekey (the rekey, carrying the row discard above), sync_artifact (regenerated because the apply function’s per-table DML changed with the rekeyed columns), content_launch_kind_nullable, and client_role_acl. The slice originally produced two ACL folders — one per sub-slice — which was wrong; there is one.

Observation, recorded for a decision that is not R4’s. The client_role_acl floor’s position is asserted POSITIONALLY: migration-drift.test.ts requires it to sort last, full stop. The floor’s underlying requirement is narrower — nothing after it may create a public object whose grants only the floor installs — and neither of R4’s schema migrations creates one (ALTER COLUMN … DROP NOT NULL and ALTER POLICY cannot inherit a grant; the sync artifact creates a function but revokes its own PUBLIC/client-role grants in the same file). So the positional rule means every slice that adds any migration regenerates a byte-identical 771-line ACL folder purely to hold last place, and R4 ships one such folder for that reason alone. Stated as a cost, not a proposal: changing the assertion is a security-adjacent decision with its own review, separate from this programme.

The source_content_id topological-ordering TODO does NOT come due here. Its site says “before R3/R4”, on the assumption that media introduces self-edges. It does not: media mints imported and reference Contents, and the origin CHECK forbids source_content_id outside generated. The real trigger is the FIRST generated producer (Phase 6’s TTS/captions work), and the comment now says so.

R5 — consumption surfaces. launch-session/cmi5 + package-runtime + content-runtime + document-delivery + web-content-delivery + cartridge-export swap FK targets; document_progress_event rekeys (reading state = consumption); learner-web offering-materials + viewport hooks read content/binding; LRS storage references; offering-contents-sync-cycle, mutations-api, oneroster-roundtrip lanes updated. Adversarial review: the learner discovery filters (member fan-out + published gate + processed gate) — this is where a filter mistake leaks unprocessed or foreign content. Open product decision this slice must settle (raised by R2): external_package_org_slug_uq is not ported — org-slug uniqueness is incompatible with ADR-0061, since many Contents per Import is the model and two processings of one book share a title-derived slug. So the materialSlugConflict 409 duplicate-import guard has no equivalent. SETTLED 2026-08-18: the guard is replaced by a NON-BLOCKING DUPLICATE SIGNAL. The import always succeeds; the response reports that an earlier Import in the same organization carries the same source_sha256. The index it needs (import_source_sha256_idx) already exists.

WHAT THE OLD GUARD ACTUALLY WAS, established by survey rather than assumed — it is three different things depending on who supplies the slug, which is why “port it or drop it” was the wrong question:

• CALLER-SUPPLIED (the teacher import routes, slug: z.string().min(1)): a namespace collision check on a name the caller chose. • DERIVED (package-import-service.ts, when no slug is supplied): h5p-<sha256[0:12]>, cmi5-package-<sha256[0:12]>, <format>-<sha256[0:12]> — i.e. for archive uploads the guard WAS duplicate-bytes detection, wearing a slug’s clothes. • RANDOM (personal-import-service.ts): personal-<personId>-<uuid>, so the guard could never fire there at all. That path’s docblock already says re-importing is deliberately not deduplicated.

AND NOTHING READS THE SLUG BACK. Every other reference in the repo is a writer or the guard’s own probe; R3 omitted it from the content client projection because no client renders it (the discovery list keys on title + kind). So the constraint was protecting a namespace nobody navigates.

WHY NON-BLOCKING RATHER THAN A 409 ON source_sha256. A blocking guard would make byte identity an IDENTITY KEY, which ADR-0061 refuses in as many words: import.source_sha256 is documented as “Provenance, NOT an identity key: the same bytes imported twice are two Imports.” A 409 would therefore have to be overridable, and the override would become the normal path — a constraint everyone routes around is worse than none. The signal keeps the only value the old guard really had (catching an accidental double-upload of a large package) without contradicting the model: two Imports, two Contents, and the caller decides whether it was an accident. Also R5’s input: content.processing_state = 'processed' becomes the delivery gate that package_asset.import_status = 'ready' is today (R2 aligned the mint so the two agree).

Personal media joins R5 (ruled 2026-08-18, out of R4). Personal content import is the stated reason ADR-0056 exists — “its core value is self-directed learning over personally imported content” — and personal-import-service.ts is its purpose-built door: it DERIVES the offering from the verified person claim rather than accepting one as a parameter, ENSURES the personal offering so a first import is also the first-use provisioning trigger (ADR-0056 decision 3), runs one transaction end to end with object compensation across the whole span, and lands a catalog_resource library entry.

R4’s server-authoritative media door does none of that, and its canManageOfferingContent lacks the authority_level <> 'person' conjunct the content write RLS carries — so once the door started minting the Content itself, personal media began completing through the wrong door. (Before R4 the mismatch was masked: the bytes landed and the sync write was refused, leaving an orphaned object and no row.) Concretely, a person whose first personal-space action is a media upload has no personal offering to name, because that door never provisions one.

R4 therefore CLOSED the door’s personal branch — a clean 403, not a silent partial workflow — and R5 owns wiring personal media through personal-import’s shape. This is a deferral of the door, never of the capability.

R5e — ASSIGNMENT OUTCOMES REKEY (found by R5c, 2026-08-19; NOT in the original plan and it BLOCKS R6). Three tables still carry external_package_binding_id with a live FK to the table R6 drops: package_progress, launch_session and package_evidence_link. R6 cannot drop external_package_binding until they move.

It is not merely a cutover chore — it is already WRONG on the new model. A content_binding minted after R4/R5 has no external_package_binding twin at all (personal media, personal document upload, and anything the media doors create), so any consumption or launch that reaches these tables raises an FK violation. R5c hit it head-on: the package_progress projection in the sync applier now runs ONLY when a binding context is present, which is correct on its own terms — ADR-0061 puts consumption state on (person, content) and ASSIGNMENT OUTCOMES on the Content Binding, so an unbound reading has no assignment outcome — but it leaves the bound case still pointing at the dissolved table.

The distinction this slice must hold, and the reason it is separate from R5c: consumption state (reading position, playback, language events) keys on (person, content); ASSIGNMENT OUTCOMES (completion projections, cmi5 registrations, evidence links) key on the CONTENT BINDING, because the same Content bound into two offerings legitimately yields two of them. So these three rekey to content_binding_id, NOT to content_id. content_binding.md — see the entity’s docblock in packages/db/src/schema/import-content.ts, which states this split as the table’s purpose. The LRS path moves with them (apps/lrs/src/db/storage.ts already resolves the placement through content_binding.xapi_activity_root_iri, but still WRITES package_progress.external_package_binding_id).

R6 — cutover. Drop external_package, external_package_version, package_asset, external_package_binding, media_resource, media_binding, cartridge_import; remove their sync/erasure entries; terminology sweep (the dissolved names join the check-terminology guard so they cannot reappear); full validate:full + complete integration suite; operator items: apply migrations to dev DB, clients resync.

R6 also SQUASHES the migration set and rebuilds the database from scratch (ruled 2026-08-18). The set is 38 folders for ~18 distinct things — 6 sync_artifact, 5 client_role_acl, and doubles of content_origin_freeze, registry_governance, pgxsinkit_utilities and identity_linking — because the ACL floor’s positional rule forces a byte-identical 771-line regeneration in every slice that adds any migration. Every custom migration has a generator script (packages/db/package.json, 17 of them), so the squash is: one generated baseline from the final schema, then each generator once.

WHY R6 AND NOT SOONER: a squash changes hashes and the journal, so it needs a genuine drop-and- rebuild rather than a migrate — which is exactly the operator reset R6 already plans. Doing it here means ONE reset instead of two, and the baseline is generated from the POST-dissolution schema, so the seven dropped tables never appear in migration history at all. Doing it earlier would bake seven tables into a baseline that R6 then deletes.

WHAT IT CLEARS, beyond the folder count: R3’s snapshot-lineage fork (which R4’s migration had to repair) never existed, and R4’s hand-added DELETE FROM media_playback_event becomes unnecessary — a baseline creates that table already keyed on (person, content), so there is no backfill problem to solve.

WHAT IT DOES NOT FIX, stated so nobody expects it to: the RECURRING cost. The floor must still sort last, so the next slice after R6 regenerates it again. The squash clears the backlog; it does not change the convention, and whether that convention should be replaced by asserting the property it stands for (“nothing after the floor creates a grantable object”) is a SEPARATE security-adjacent decision, deliberately not folded into either slice.

THE REAL WORK IS ORDERING. The dependency order between the 17 generators is currently implicit in folder timestamps — an accident of when each was run. The squash forces it to be written down as an explicit sequence (policies need their tables, the sync artifact needs the registry, the ACL floor needs everything). That is a benefit of the exercise, not a cost of it.

R1 → R2 → R3; R4 and R5 depend on R1 only and can interleave after R2; R6 last, only after every lane is green on the new entities. Phase 3 (consumer k8s Deployment, client outbox, reader slice) starts after R6 — its learner data lands on final keys. The AccessibleDictionarySummary.revision open item is untouched by this programme.

Non-goals (ADR-0061 rulings, restated as scope fences)

Section titled “Non-goals (ADR-0061 rulings, restated as scope fences)”
  • No data migration of any kind — old rows die with their tables (pre-launch; dev DB is operator-reset at cutover).
  • No attempt history, no run entity, no auto-reset of attempts, no retirement/refcount/ migration machinery, no admin surface for dead-letter resurrection.
  • No Ingest-side changes: assessment items/stimuli remain outside Content (ADR-0009).
  • No engine modernisation smuggled in: enrichment behaviour is ported, not improved.
  1. Whether the language declaration gets typed columns on content in R3 or stays payload. Settled at R3: it stays payload. Typed columns would buy a filter or a constraint nobody needs — the declaration gates one server-side stage, is read exactly once per run, and is already Zod-validated and versioned (the Type-A contract’s requirement). It is also the wrong moment: R5 has to settle what processing_state gates on delivery, and R4’s media lane may add per-kind declaration shapes, so typing it now would type the wrong thing. Pre-launch, a payload column becomes typed columns with no data migration whenever a reader needs one.

  2. Whether the dissolved-table names enter the terminology guard at R6 (recommended) or earlier.

  3. Whether the client-role ACL floor’s ordering stays a POSITIONAL assertion. Raised by R4, deliberately NOT settled inside it. migration-drift.test.ts asserts migrationDirs.at(-1) matches _client_role_acl, because the floor’s sweep (REVOKE ALL ON ALL TABLES IN SCHEMA public) only reaches objects that ALREADY EXIST — a table-creating migration sorting after it ships with the Supabase bootstrap grant intact on a FIRST install. The cost is a byte-identical 771-line regeneration in every slice that adds any migration (R3 shipped one; R4 shipped one; neither R4 migration creates a grantable object, so R4’s protects nothing).

    The alternative is to assert the PROPERTY the position stands for — nothing after the floor creates a table/sequence/view, and a routine only from a declared posture-source migration — which removes the no-op migrations at the price of an allowlist that can rot. What makes this a HOUSEKEEPING decision rather than a safety one: the positional test is not what proves the posture. tests/integration/public-table-acl.integration.test.ts proves the actual grants against a booted stack; the unit test proves only the position that makes it reachable. Whichever way this goes, the integration lane is the thing that would catch a regression.

    R4’s recommendation was to keep it as-is: the noise is ugly but inert, and a guard that cannot rot is worth a no-op migration per slice. R6’s squash clears the accumulated backlog either way.