Skip to main content

Module binding_migrate

Module binding_migrate 

Source
Expand description

Migration to binding v2 — the single-record pipeline format.

Two conversion legs live here, both pure and IO-free (the CLI’s memstead projection migrate wraps them with the load / write / tree-removal IO):

  1. Gen-2 → v2 (migrate_gen2_bindings): each flat legacy ingest is merged into the projection its projection ref names, and the projection’s facet references are folded inline — each referenced facet joins its medium and becomes one Source under the facet’s name, byte-verbatim (source names key sync watermarks).
  2. v1 → v2 (fold_v1_binding): a three-file-store binding (LegacyBindingV1, source_facets by name) folds its referenced facets + mediums inline the same way; every other field carries over verbatim and version becomes 2.

After both legs every medium/facet record must be consumed (check_all_consumed) — an orphan (a record no binding references) is a typed error, never a silent drop; the CLI removes the emptied mediums/ and facets/ trees only after that check passes.

A dangling reference (ingest→projection, projection→facet, facet→medium) is a typed migrate error, never a silent drop. refinement build mode is a typed error — the vocabulary is deleted, not migrated.

Structs§

LegacyBindingV1
The retired v1 binding shape (migrate-local): the three-file-store record that referenced facets by name. Parsed only by the v1→v2 fold leg; the live loader refuses version: 1 files with the migrate-naming error.
MigratedBinding
A single migrated binding paired with the identity and provenance the CLI needs to write it to disk and report it.

Enums§

BindingMigrateError
Why a legacy config could not be migrated to a v2 binding. Every variant names the offending record so the failure is diagnosable without re-reading the store.

Functions§

check_all_consumed
Verify every medium/facet record in configs was consumed by a fold — consumed_facets is the union of every migrated binding’s (mem, facet-name) pairs. A facet no binding referenced, or a medium no consumed facet engages, is an orphan: removing the trees would drop its content silently, so the migration refuses instead (BindingMigrateError::OrphanRecords) and names each leftover.
fold_v1_binding
Fold one v1 three-file-store binding into a v2 Binding: every field carries over verbatim, version becomes 2, and each source_facets entry folds its facet + medium inline under the facet’s name byte-verbatim (it keys sync watermarks). Pure — no IO.
migrate_gen2_bindings
Migrate every gen-2 flat ingest in configs into a v2 MigratedBinding, keyed by binding id (<mem>/<stem>), in id order.