Language module Phase 1 — core enablers — implementation plan
Companion to ADR-0052 and Language Module Migration V1 (decisions 3-6; Phase plan → Phase 1). Executable, sliced build plan for the three Phase 1 workstreams: the personal offering, the ADR-0052 competency mechanics, and the archive lane. Nothing in this phase is learner-visible; it is the substrate every later phase anchors to. Each slice is independently shippable + validated; feature work lands per the repo’s rebase-only flow.
Grounding (verified 2026-07-30)
Section titled “Grounding (verified 2026-07-30)”- The sentinel-org mechanism exists but is importer-private. ADR-0034’s
customer-0org is minted by the English Planet importer (tools/scripts/import-english-planet/cli.ts,SENTINEL_ORG_ID, offering slugplatform-sentinel) as the platform-content master home. It is not a seeded platform primitive, and nothing anywhere provisions per-person structures. - Offering-scoped manage grants already exist.
person_role_grantenforces org-XOR-offering scope;canManageTeacherOffering(packages/domain/src/auth.ts) grants manage to an offering-scoped teacher/assistant on exactly that offering. The personal offering needs no new authority mechanism — only provisioning that issues the offering-scoped grant. - The catalog teacher read fans out org-wide.
catalog_resource’s row filter (packages/db/src/schema/catalog-resource.ts,buildTeacherManagedOrganizationRowFilterWhere) gives any teacher — including an offering-scoped one, one hop through offering → org — the whole org catalog. Under a shared personal org this leaks every person’s imported-content metadata; the carve-out is mandatory before any personal import ships. - Erasure is enforced, not optional.
packages/db/src/erasure-registry.ts(ADR-0014) fails its test for any unregistered person-linked table — every table this phase adds is a registry entry by construction. - Read/sync rules are the ADR-0053 contract. Every new sync entry declares a registry tier; read-contract preservation is asserted in the unit suite; schema work follows the migrations runbook; person scoping keys on the JWT person id.
- No goal construct, no archive schema, no node provenance/merge/bulk machinery exists —
re-verified 2026-07-30; the only mentions are ADR-0052 and the migration doc. The
lrspg schema (packages/db/src/schema/lrs.ts) is the precedent for a separately-scoped schema. - Predecessor patterns ready to port (transcrobes, its ADR-0003): versioned policy functions
(
LEARNER_POLICY_VERSION), strict-zod versioned research events in one append-only deny-all table — the working precursors for the summarisation convention (B4) and archive lane (C1).
A1 inventory findings (2026-07-30)
Section titled “A1 inventory findings (2026-07-30)”The boundary sweep (recorded in ADR-0056’s consequences) found three leak vectors, which scope the exclusion campaign:
- Offering→org one-hop reversal: several teacher row filters resolve the caller’s offering
grants to an org and then match all org-keyed rows — under a shared personal org this fans one
person’s offering-scoped grant out to every person’s rows. Affected helper families in
packages/db/src/schema/authorization.ts(plus a hand-rolled copy incat-pool.tsand the survey disjuncts) each gain anauthority_level <> 'person'guard, with every consuming sync entry revision-bumped and the claim-aware RLS write twins moved in lockstep. - Platform-admin
nullbranches: enumeration surfaces (theofferingentry first among them) stream every personal row to admin/teacher consoles; the admin branches gain the exclusion — member/owner branches keep a person’s own rows. - Claim-free server projections: the OneRoster provider projection (offering predicate + every derived set narrowed; round-trip gate re-proven with a personal offering seeded), the Caliper package-progress aggregate collector, and the seed value pools/assertions.
Scope adjustments this produced: the catalog_resource carve-out lands in A1 (it is one
consumer of the shared helper fix), so A3 reduces to the person-usable import workflow;
offering.authority_level is client-omitted, so exclusions are server-side by construction; the
duplication/provisioning services must reject person-authority sources. Deferred rulings
(recorded in ADR-0056): erasure semantics for person-authority rows (settled in A2) and Caliper
per-person event emission (settled with workstream C / Phase 2). customer-0’s own latent
exclusion gap is backlog 0011.
Decisions to settle in the personal-offering ADR (recommendations inline)
Section titled “Decisions to settle in the personal-offering ADR (recommendations inline)”- Dedicated personal sentinel org vs reusing
customer-0. Recommend dedicated (personal-0):customer-0is the platform-content master home with its own exclusion semantics (tracking copies, provisioned_from); personal space wants the opposite posture (nothing org-visible, everything person-private). One org id to exclude per boundary either way — but different boundaries. - Provisioning timing. Recommend lazy — the personal offering is minted (idempotently, server-side) on first personal-space use, not at person creation; org-only learners never carry the rows.
personauthority level. The migration doc left the enum value optional. Recommend adding it: every boundary exclusion (dashboards, OneRoster, aggregates) becomes an indexed predicate on the offering row itself instead of a join to the sentinel org id.- Node provenance placement (workstream B). Recommend core columns on
competency_node(provenance tier + source ref): ADR-0052 declares provenance a property of the referent space itself, not a language-module concern. - Goal referent encoding v1. Recommend a closed kind set —
competency_framework_version|assessment_definition|extension(module-defined referent carried as namespaced text) — one nullable FK per kind, checked one-of, no polymorphic FK.
Slices
Section titled “Slices”Workstream A — personal offering
Section titled “Workstream A — personal offering”A1 — ADR + sentinel primitive + boundary inventory. Author the personal-offering ADR (decisions 1-3 above; the migration doc’s decision 3 is its skeleton). Seed the personal sentinel org as a platform primitive (migration + seed, not importer side-effect). Inventory and test every boundary that must exclude personal offerings: teacher/admin dashboards and rosters, OneRoster provider output, Caliper org-scoped aggregates (ADR-0048), gradebook views, catalog reads. Each exclusion lands with a row-filter or projection test; the OneRoster round-trip gate must stay green with a seeded personal offering present.
A2 carry-forwards from the A1 reviews (updated 2026-07-31): (i) harden the
no-sentinel-org-grants rule into structure — direct org-column literal-IN filter branches (and the
org-grant write twins) are guarded only by provisioning discipline today; strip
PERSONAL_SENTINEL_ORG_ID from the claims org-id sets or add a CHECK forbidding sentinel-org
grants on person_role_grant. (ii) Rule explicitly on platform-admin visibility of personal
authored content in admin enumerations left un-guarded by deviation (assessment-definition admin
summary, CAT candidate pickers; also the LTI proctoring session/control-event filters — same
class, unreachable for personal offerings while LTI deployments require org entitlements). The
learner-data enumeration class (attempt/score/gradebook/item-session/PNP/LTI line items+results)
was closed 2026-07-31 after external review. (iii) The provisioner’s personal learning container
will not sync to its owner until A3’s owner-scoped path lands — closed 2026-07-31 by A3
(owner branches on the personal offering / sentinel-org authorship; the A1 exclusions are
untouched and re-proven). (iv) Erasure
ruling for person-authority rows (per ADR-0056’s deferred ruling). (v) The single-member floor:
invites and survey-family writes are refused for personal offerings at both RLS and the applier
(closed 2026-07-31); the offering_membership floor is applier-only — an inline RESTRICTIVE
policy broke the learner self-join (the subquery evaluates under the writer’s role, which cannot
SELECT the offering pre-membership; proven by test) — so A2 should add the SECURITY DEFINER helper
(fn_person_pnp_proxy_allowed precedent, pre-baseline custom migration + runbook row) if a
database-level floor is wanted under the applier refusal.
A2 — auto-provisioned personal offering. Idempotent server-side provisioning path in
apps/api: person → learning container + personal offering (sentinel org; person authority
level per ADR) + learner membership + offering-scoped teacher grant. Claims: the grant must
surface in the JWT authorization claims like any other. Concurrency-safe (two tabs racing first
use mint one offering). Row-filter tests prove: the owner reads/manages their personal offering;
no other personal user, org teacher, or org admin reaches it; platform admin does.
A3 — catalog carve-out + person-usable import. Revise the catalog_resource teacher read
filter to exclude the sentinel org from the org-wide fan-out (revision-bumped sync entry;
row-filter test proves personal catalog rows never reach another person). Add the person-usable
import workflow: a person-scoped variant of the ADR-0026 document-package path (upload →
decompose) that creates catalog_resource rows in the sentinel org bound via offering_resource
to the caller’s personal offering, owner-private end to end. Personal imports remain
person-private by construction — no share/redistribute path exists.
Workstream B — ADR-0052 competency mechanics
Section titled “Workstream B — ADR-0052 competency mechanics”B1 — goal construct. goal table (person, referent per decision 5, success criterion, due
date, status, policy-version stamp), domain contracts in packages/domain, owner readwrite sync
entry (background-eager tier), RLS + erasure registration. Model + sync only; UI is Phase 5.
B2 — node provenance, merge lifecycle, bulk authoring. Mechanics ratified 2026-07-31 as
ADR-0057; the slice implements it. Provenance columns per decision 4 (tier:
curated-dictionary / list-member / machine-segmented / learner-coined + source ref), tier
monotonic-upgrade on curated endorsement. Merge: explicit (loser, survivor) input; one
transaction re-points evidence/state/alignments/associations/pool members, coalesces rows that
would become self-referential or duplicate, writes the alias, then deletes the loser (no
tombstone — stragglers fail on FK). competency_node_alias: freed (framework_id, node_key)
unique + dead id as plain uuid + survivor FK ON DELETE RESTRICT (chains impossible by
construction; permanent until deliberately retired). State collisions are never combined inline —
survivor row kept, derivation_meta merge-touched, re-derivation is the Phase 2 projector’s
obligation. Mint collisions with an alias: lazy learner mints redirect silently; bulk/curated
ingest refuses the entry loudly in the run report. Machine lexicon: one platform-homed framework
per language (organization_id NULL) with a single permanent “current” version row every mint
inserts under; real editions live in curated frameworks + export-on-demand only. Bulk ingest is
an occasional curated-inventory import (batched per the English Planet importer’s chunked
pattern), never a recurring rewrite, and never touches the human-curated revision workflow.
B3 — node inventory client projection. A scoped sync entry projecting the language node
inventory to learner clients (CAT-pool precedent), declared lazy (activated by the language
module; nothing pays for it before Phase 2), filtered to curated tiers + the person’s evidenced
nodes. Read-contract assertion in the unit suite; the base competency_node entry stays
DENY_ALL.
B4 — evidence summarisation convention. The documented contract + typed helpers for
projector-emitted person_competency_evidence: summary-or-transition rows only, policy-version
stamped (the ported formalism), provenance pointing into the archive lane. Conventions + types +
tests this phase; the first real producer is the Phase 2 projector.
Workstream C — archive lane
Section titled “Workstream C — archive lane”C1 — archive schema + forwarder seam + retention. A dedicated archive pg schema (lrs
precedent): append-only native-event tables, retention designed in from day
one (the predecessor’s research_event shipped without it — recorded warning). The forwarder
seam in apps/api: the single reader of rail event tables, moving rows past their client
retention window into the archive (the swap seam if the archive ever leaves Postgres). Deny-all
RLS; erasure registration (erasure-is-anonymization applies to archived events). Schema + seam +
trim job + tests this phase; the first producing rail table arrives in Phase 2.
Amendment (2026-07-31, post-implementation review): the originally planned time partitioning was declined in C1 — drizzle-kit cannot express partitioned tables and the PGlite test shape would diverge from production — with retention delivered by the trim pass instead. Revisit trigger: before the first high-volume producing stream registers, implement custom partition migrations or record why volume does not warrant them. Resolved (2026-08-01, Phase-2 ratification review): declined again, by ruling. Launch-scale volume does not warrant it — the streams are narrow append-only rows (~10⁵/learner/year), cheap for years, and an append-only table converts to partitioned via a one-time maintenance migration whenever warranted. New trigger: before multi-org production launch, or when any archive stream passes ~50M rows, whichever comes first.
Amendment (2026-08-01, ADR-0058): the forwarder seam is dormant — Phase 2 ruled events queue-shaped (client outbox → flush → queue → consumer; archive written on arrival), so no producing rail table will ever exist and the copy-then-delete forwarder has no client. The archive schema, mandatory retention, and mandatory anonymization contracts remain fully load-bearing. The Phase-2 entry obligations recorded below are both discharged: forwarder/ projector ordering by ADR-0058, lexicon-projection language scoping by ADR-0060.
Order and dependencies
Section titled “Order and dependencies”A1 → A2 → A3 in sequence; B1 independent; B2 → B3; B4 after B2; C1 independent. The three workstreams parallelize. Phase 2 (module tables + projector + enrichment port) needs B2/B3/B4 + C1; the personal content channel (Phases 3-4) needs A3.
Phase 2 entry obligations (recorded 2026-07-31, binding)
Section titled “Phase 2 entry obligations (recorded 2026-07-31, binding)”Two design gates settled neither by Phase 1 code nor its ADRs; both MUST be resolved in Phase 2 planning before the named machinery ships:
- Forwarder/projector ordering. ADR-0052 makes the projector the only canonical reader of
raw events, but the C1 forwarder deletes rail rows purely by
occurred_atage — no projector cursor, acknowledgement, or eligibility predicate coordinates them. Before the first producing stream registers, rule on exactly one ordering: archive-and-project atomically, projector consumes from the archive, or a durable projector acknowledgement in the forwarder’s delete predicate. - Language scoping of the lexicon inventory projection. B3’s predicate scopes to machine-lexicon frameworks + curated tiers with no language dimension; activated as-is it would sync every language’s curated inventory to every activated client. The scope input is the person’s language selection, which the Phase 2 language module introduces — the projection MUST NOT be activated before that predicate lands (revision bump required; the entry carries the same warning).
Verification baseline (every slice)
Section titled “Verification baseline (every slice)”Migrations runbook for all schema work; row-filter/RLS tests in the schema test
convention; erasure-registry test green; bun run validate + affected conformance lanes
(OneRoster round-trip for workstream A); no new read helper wraps the upstream hooks.