Skip to content

Competency-node merge lifecycle, provenance dynamics, and machine-lexicon versioning

Status: accepted

Date: 2026-07-31

Relates to: ADR-0052 (fine-grained competency referents — refines decisions 4–6 into implementable mechanics), ADR-0018 (durable competency referents and edition stamping), ADR-0014 (erasure), docs/design/language-module-phase-1-plan.md (slice B2; decisions ratified 2026-07-31), docs/architecture/language-module-migration-v1.md.

ADR-0052 committed to: evidence and state re-point to the survivor on merge; alias rows as permanent redirects; a bulk authoring path that never touches the human revision workflow; provenance tiers as core columns on competency_node. It left open the loser row’s fate, the state-collision rule, alias/minting interaction, tier mutability, and what “versioned in bulk” concretely means.

A competency node is a meaningful unit — a thing it makes sense to track learning for (word, character, saying, grammar pattern). Node membership of a living language is open and contested; quality is a property (the tier), never an admission criterion. Dictionary and gloss content is not node content: multi-provider resource sets (system vs personal ownership, resource types, per-learner access) are the Phase 2 enrichment port, outside the competency core.

The merge blast radius today (packages/db/src/schema/competency-framework.ts and consumers): competency_node_id is referenced by evidence, state (UNIQUE (person, node)), alignments, associations (from <> to CHECK, per-version uniqueness), CAT pools, the CASE boundary, external packages, and the credential/cartridge exports — all FKs onDelete: cascade. Nothing writes person_competency_evidence or person_competency_state yet (the Phase 2 projector is their first producer), so the merge procedure defined here is proven by tests before data exists.

  1. Merge deletes the loser after re-map. One transaction: re-point evidence, state, alignments, associations, and pool members to the survivor; coalesce rows that would become self-referential (from = to) or duplicate under existing uniques; write the alias row; delete the loser. Any straggler still holding the dead id fails loudly on FK violation — no tombstone status, no new read-side exclusion obligation (the A1 exclusion campaign documented what a distributed “must exclude X” invariant costs; merged nodes simply do not exist). Merge input is an explicit (loser, survivor) pair; tooling may suggest candidates, but no automatic survivor-selection policy exists.

  2. Alias rows make chains structurally impossible. competency_node_alias carries the freed (competency_framework_id, node_key) (unique), the dead id as a plain uuid (no FK), and a survivor FK with ON DELETE RESTRICT — a survivor that is itself merged away cannot be deleted until every alias pointing at it is re-pointed, so aliases always target a live node (depth 1 by construction). An alias is permanent until deliberately retired by a human.

  3. Mint collisions are tier-differentiated. A lazy learner-activity mint whose node_key hits an alias follows the redirect silently (same behavior, same knowledge item — the alias doing its stated job). A bulk/curated ingest whose entry hits an alias refuses that entry loudly — the run continues, the conflict is reported, and resolution (retire the alias, or map the entry onto the survivor) is a deliberate human act. A silent redirect would swallow a higher-quality source’s assertion that the merged-away key is a real item.

  4. Merge never decides state; derivation does. On a person_competency_state collision (the person holds state on both nodes), the merge keeps the survivor’s row, deletes the loser’s, and stamps the survivor’s derivation_meta merge-touched (mergedFrom, timestamp). The combined state is re-derived from the combined evidence by the versioned derivation machinery — the Phase 2 projector treats the stamp as a standing work item. No combination heuristic lives in the merge procedure: facts (evidence rows) re-point mechanically; state is policy output and only the policy may write it.

  5. Provenance is a current endorsement, monotonic upward. The tier records the best source that has vouched for the node. A curated/bulk ingest matching a live node upgrades learner-coined / machine-segmented → list-member / curated-dictionary and moves the source ref to the endorsing source. Downgrades never happen. Every committed tier consumer (the B3 projection’s curated-tier filter, decision 8’s curation-granularity exports) reads the tier as “how much is this referent trusted now”, not as a birth record.

  6. One machine lexicon per language, one permanent edition. Per language, a platform-homed framework (organization_id NULL — no sentinel-org entanglement) holds every knowledge item; person-scoping lives in evidence/state, never node residency (ADR-0052 decision 1 applied literally). It carries a single long-lived “current” competency_framework_version row: every mint — lazy or bulk — inserts under it, and machine-lexicon evidence stamps that one stable uuid (satisfying person_competency_evidence.competency_framework_version_id NOT NULL at lazy-mint time with no “latest edition” resolution logic). Real editions exist only where they mean something: curated frameworks (HSK 2.0 vs 3.0 as genuine versions, connected to lexicon nodes by cross-framework associations) and ADR-0052 decision 8’s export-on-demand frozen snapshots.

  7. Bulk authoring is an occasional event, not a cadence. The path serves curated inventory imports — an HSK list minting absent member nodes at list-member plus membership associations plus tier upgrades for nodes that already exist; a grammar-pattern inventory. There is no recurring inventory rewrite. Run identity rides provenance source refs and the run’s report, not lexicon editions.

  • Resource sets (multi-provider dictionaries, sounds, synonym sets; system vs personal ownership; per-learner access driving sync) — the Phase 2 enrichment port. Learner re-import of a personal resource replaces in place; no versioning in V1 (extend later only on demonstrated need).
  • Reproducibility of “what did the lexicon look like that Wednesday” is served by run reports and the archive lane, never by machine-lexicon editions.
  • Tombstoning merged nodes (a merged status kept forever): FK integrity for free, but every reader, projection, and pool assembly inherits a “must exclude merged nodes” obligation — a new distributed exclusion invariant of exactly the shape the A1 campaign paid for — and a straggler holding the dead id keeps writing to it silently instead of failing.
  • Inline state-combination rules in the merge procedure (higher state wins, latest wins): an unversioned learner-model policy embedded in a mechanical identity procedure; derivation_policy_version would claim the row came from the derivation policy when it came from a merge heuristic.
  • Uniform silent alias redirect for all minters: absorbs a curated source’s contradiction of a past merge without anyone learning of it.
  • Immutable birth-record provenance: a learner-coined word later endorsed by a curated dictionary would stay invisible to the curated-tier projection and exports the endorsement should have unlocked.
  • A zh-lexicon edition per ingest run: lazy mints between runs puncture every “frozen” snapshot on arrival, editions accumulate without bound at no meaning gained, and “current revision of node X” becomes a version-chain walk forever.
  • The merge procedure and alias behavior are provable now, on empty evidence/state tables, before Phase 2 turns data on.
  • The Phase 2 projector inherits two contracts from this ADR: honor merge-touched stamps as work items (decision 4), and stamp machine-lexicon evidence with the rolling version id (decision 6).
  • The bulk-ingest report is a first-class artifact: refused alias collisions (decision 3) and tier upgrades (decision 5) are its content, and it is the run-granularity reproducibility record (decision 7).
  • CASE reconcile and any inbound external reference resolution must consult the alias table for previously exported ids of merged-away nodes; the alias is the permanent record of that mapping.