Skip to content

Import and Content are separate terminal identities

Status: accepted

An imported file and a processing of that file are two first-class entities — Import and Content — and both are terminal: neither is ever updated after reaching its final state. Multiplicity replaces mutation everywhere. A “new version” of a file is a new Import. A better processing of the same file is a new Content. There is no revision axis, no re-enrichment, no supersession, and no continuity of learner data across Contents, ever.

Decided after an audit of the current model found the same defect in four places: a genuine relationship carried as payload instead of a row. The enrichment artifact was a JSON slot on external_package_version (whose compensating-delete protocol could orphan storage objects no row names); the personal import’s catalog link was a fabricated personal-document:<uuid> string; cartridge_import recorded its outputs as integer counters with no FKs; and external_package_version itself was a vestigial 1:1 row documenting an “editing publishes a new version” path the code never had.

  • Import — one row per file intake event, linking the stored bytes and their source facts (filename, sha256, size, importer, when). Never updated. Deletable outright while no Content was generated from it (cascading to storage). Generalizes cartridge_import (the event) and absorbs package_asset (the bytes pointer).
  • Content — one processing of one Import; the only thing an Offering binds and learner data points at. Carries its own metadata (distinct from the Import’s; mutable in place under LWW — the operation log is the history), a processing state machine (none → processing_requested → processing → failed → processed), a processing_engine_version, and a processing_attempts counter. processed is terminal and frozen: no transition out, and output-describing fields never change after it. Learner-facing reads gate on processed. One Import may have many Contents (different uses, different engine versions); each is a distinct object with distinct learner histories — HP1@0.1.0 and HP1@0.1.1 may be bound side by side in one offering, and a learner’s activity on each is unrelated. A Content records its origin as a discriminated source — imported (bytes in our custody: import_id NOT NULL, however they arrived), reference (url NOT NULL; no custody — the platform guarantees the reference, never the referent: no byte identity, no processing, anchor stability not ours to promise), or generated (platform-produced: no import, no URL; origin is the engine version and parameters, plus source_content_id when generated from another Content, e.g. TTS of a text). One CHECK enforces the per-mode shape. Fetching an external file to process it takes custody and is therefore an ordinary Import.
  • Content Artifacts — the derived files of one Content, each with its own row, written row-before-object so every byte in storage is named by a row at every moment. Write-once; frozen with their Content. For trivial processing an artifact row may reference the Import’s own stored object (a pass-through artifact) — no byte copy: the identity separation is the row, and Import immutability plus content.import_id ON DELETE RESTRICT make the reference safe for as long as the Content lives.
  • Failure and retry — the Content row is the attempt record; there is no run entity and no attempt history. Retry mutates only pre-processed rows and may overwrite temporary output (keyed by the Content row id — nothing consumable ever points there). Retries stop at a cap; a capped row is dead-lettered: the API can retry within the cap, but resurrection (zeroing processing_attempts, e.g. after an engine fix) is a deliberate act by a dev with direct database access. Deliberately not admin-tweakable, and deliberately no auto-reset on engine bump: a fundamentally broken input would burn the full cap on every release forever.
  • Learner data — consumption state (reading state, annotations, language events) keys on (person, content): one history per person per Content, however many offerings bind it. Assignment outcomes (completion/score projections, cmi5 registrations, evidence links) key on the Content Binding (offering → content): the same Content bound into two offerings legitimately yields two. Nothing ever points at an Import.
  • Uniform for opaque kinds and media — an H5P’s Lumi preparation is its processing (engine: lumi@<version>); documents’ enrichment is theirs; audio/video (ADR-0045’s lane) is Content of kind audio/video with no entity of its own — media_resource and media_binding dissolve, and Phase-6 caption enrichment becomes ordinary processing. No special cases: every Import gets a Content identity even when processing is trivial, and learners never consume Import bytes.

external_package + external_package_version dissolve into content; media_resource does too (kind audio/video, source imported or reference). package_asset + cartridge_import generalize into import. external_package_binding and media_binding become the Content Binding (offering → content, visibility unchanged). media_playback_event and document_progress_event (reading state) rekey to (person, content) per the consumption rule, each keeping a nullable binding context column for the telemetry readers’ offering context — context, never the key. catalog_resource keeps its OneRoster projection role and gains a real FK to content, replacing the string link.

  • Promote catalog_resource into the consumable — rejected: org-scoped (same content in two orgs would split identity), admin-rail (readwrite, admin-authored), and OneRoster vocabulary (vendorResourceId NOT NULL forced the fabricated string).
  • Global content-addressed Content identity (same bytes → one shared object) — rejected: personal erasure becomes structurally impossible, provenance/licence claims are per-import, and the artifact is a function of (bytes, declared languages, engine) — not bytes alone.
  • A revision axis on the consumable (stable “the book” identity over changing derivations) — rejected: it manufactures exactly the supersession, migration, and anchoring problems it appears to solve. Fragment ids may stay run-minted uuids because Contents are immutable — anchors are stable by construction, not by discipline.
  • A Processing Run entity (one row per attempt, attempt history) — rejected: history has no value; the Content row with status/engine/attempts is the record.
  • Auto-reset of attempts on engine change — rejected (poison inputs; see above).
  • A separate media entity (media_resource/media_binding, ADR-0045’s lane) — rejected: no entity-level difference from Content — kind, consumption surface, and telemetry shape are per-kind properties, not identities.
  • Retirement / migration / reconciliation machinery (repointing consumers to a newer Content, refcount-driven reaping) — rejected: broken content is a bespoke manual process by definition; engine machinery for it is pure tech debt. Nothing ever moves.
  • The content-addressed artifact-key protocol with post-commit compensating delete (the previous fix on external_package_version) shrinks to the pre-commit temp window. The orphan class inverts: a crash can leave a row naming missing bytes (visible, queryable, repairable) instead of bytes no row names (invisible).
  • Binding an improved processing of the same book starts fresh learner histories. This is deliberate, not a migration gap.
  • The restructure touches the import services (generic + personal), the enrichment service, the media lane, the sync registry entries and bindings, catalog_resource, the erasure registry, and the launch/cmi5 paths. Pre-launch; clients resync from scratch at cutovers.
  • ADR-0045’s media entities are superseded by this model; its playback-telemetry and Caliper-projection semantics are unchanged.