The cutover instrument: the A-side export, and the run as one script with --check #6

Manually merged
terra merged 0 commits from ceres/19-rag-cutover-run into main 2026-11-23 23:26:32 +00:00
Member

Purpose (change): the two halves of the mcl-rag cutover the 0.11.0 release cannot carry itself — the A-side export from the barrel store, and the run on the box as one script (macula-io/macula-ci-images#19 step 2).

0.11.0's first start refuses a data dir that still holds the barrel store ({store_open_failed, {store_missing_beside_barrel, ...}}) and imports only when rag-export.jsonl and rag-export.counts.json are beside it. Nothing in 0.11.0 can write those files, because barrel is gone from it.

  • cutover/rag_cutover_export.erl — runs in the OLD (0.10.x) image against a stopped volume. Folds the barrel store, reads each vector on its own, writes the two files in rag_export_file's format (the module the import uses, so the format is not carried twice). It then reads its own file back with rag_export_file:decode/1 and refuses unless the lines add up to the documents, vectors and per-prefix counts the fold counted. A document it cannot export is named in rag-export.problems.txt and no counts file is written, so the import cannot run on a store that lost documents.
  • cutover/run_the_cutover.sh — --check (default) is read-only against the real box: box name, the fleet's committed pin and quadlet-offline line, the store's shape (barrel dirs, no rag.sqlite, no stale export), space, ollama and the model, the modules. --export is the A side and refuses while the service is running or the installed unit is present, because apply-quadlets.sh starts any unit that is not running on every reconcile tick and would open the volume under the export. --health waits for the new release, reads the version off /health, and prints the box's one line with the downtime and the counts.
  • cutover/README.md — what the script needs first (the two fleet landings), what the run costs, and what it keeps (nothing is deleted; the barrel dirs are the way back for a release).

Proof so far: both Erlang modules compile clean with the pinned OTP 28.4.3; the format round-trip (external-term fields + little-endian f32 vector) is proven with the repo's own decoder; run_the_cutover.sh --check was run on msi00 against the real box and correctly refuses today on exactly the two landings that have not happened (the fleet's unit still names ghcr 0.10.2, and quadlet-offline does not name mcl-rag.container). A dry run of the export against the 2026-11-23 copy of the live store (never the live files) is running on msi00; its numbers go on macula-io/macula-ci-images#19.

Not in this PR: no release, no tag, no fleet change, nothing deleted.

Refs macula-io/macula-ci-images#19

Purpose (change): the two halves of the mcl-rag cutover the 0.11.0 release cannot carry itself — the A-side export from the barrel store, and the run on the box as one script (macula-io/macula-ci-images#19 step 2). 0.11.0's first start refuses a data dir that still holds the barrel store (`{store_open_failed, {store_missing_beside_barrel, ...}}`) and imports only when `rag-export.jsonl` and `rag-export.counts.json` are beside it. Nothing in 0.11.0 can write those files, because barrel is gone from it. - **`cutover/rag_cutover_export.erl`** — runs in the OLD (0.10.x) image against a **stopped** volume. Folds the barrel store, reads each vector on its own, writes the two files in `rag_export_file`'s format (the module the import uses, so the format is not carried twice). It then reads its own file back with `rag_export_file:decode/1` and refuses unless the lines add up to the documents, vectors and per-prefix counts the fold counted. A document it cannot export is named in `rag-export.problems.txt` and **no counts file is written**, so the import cannot run on a store that lost documents. - **`cutover/run_the_cutover.sh`** — `--check` (default) is read-only against the real box: box name, the fleet's committed pin and `quadlet-offline` line, the store's shape (barrel dirs, no `rag.sqlite`, no stale export), space, ollama and the model, the modules. `--export` is the A side and refuses while the service is running or the installed unit is present, because `apply-quadlets.sh` starts any unit that is not running on every reconcile tick and would open the volume under the export. `--health` waits for the new release, reads the version off `/health`, and prints the box's one line with the downtime and the counts. - **`cutover/README.md`** — what the script needs first (the two fleet landings), what the run costs, and what it keeps (nothing is deleted; the barrel dirs are the way back for a release). Proof so far: both Erlang modules compile clean with the pinned OTP 28.4.3; the format round-trip (external-term fields + little-endian f32 vector) is proven with the repo's own decoder; `run_the_cutover.sh --check` was run on msi00 against the real box and correctly refuses today on exactly the two landings that have not happened (the fleet's unit still names ghcr 0.10.2, and `quadlet-offline` does not name `mcl-rag.container`). A dry run of the export against the 2026-11-23 copy of the live store (never the live files) is running on msi00; its numbers go on macula-io/macula-ci-images#19. Not in this PR: no release, no tag, no fleet change, nothing deleted. Refs macula-io/macula-ci-images#19
The cutover instrument: the A-side export, and the run as one script with --check
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 3s
c4 model / c4-model (pull_request) Successful in 0s
lint-and-test / check (pull_request) Successful in 8m45s
2107f2db5e
macula-io/macula-ci-images#19 step 2. 0.11.0 imports `rag-export.jsonl` and
`rag-export.counts.json` or it refuses to open beside the barrel store, and
nothing in 0.11.0 can write them: barrel is gone from it. This is the other
half of the cutover, kept in the repository so it is reviewed and carried with
the release rather than invented on the day.

`rag_cutover_export.erl` runs in the OLD (0.10.x) image against a stopped
volume. It folds the barrel store, reads each vector back on its own, and
writes the two files with `rag_export_file` -- the module the import uses, so
the line format is not carried twice. It then reads its own file back with the
same decoder and refuses unless the lines add up to the documents, vectors and
per-prefix counts the fold counted; a document it cannot export is named and no
counts file is written, so an import cannot run on a store that lost documents.

`run_the_cutover.sh` is the run on the box: `--check` (default) read-only
against the real target -- box, the fleet's pin and offline line, the store's
shape, space, ollama, the modules; `--export` the A side, refusing while the
service is running or the unit is installed (the reconciler would put it back
under the export); `--health` the read-back that prints the box's one line with
the downtime and the version that answered. Nothing deletes the barrel dirs:
they are the way back for a release.

Refs macula-io/macula-ci-images#19
The export writes every document: a line for the vectorless ones too
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 6s
c4 model / c4-model (pull_request) Successful in 0s
lint-and-test / check (pull_request) Successful in 7m32s
702e452b5b
The dry run on msi00 (against the 2026-11-23 copy of the live store) folded
68,774 documents and wrote 55,450 lines: the `none` branch of `one/2` counted a
document with no vector and returned without writing it, so every `source:`,
`watermark:`, `served:` and `reembed:` document was dropped from the export.
The read-back at the end of the export caught it exactly as designed --
`{counted_differently, {68774, 55450, ...}, {55450, 55450, ...}}` -- and wrote
no counts file, so the import could not have run on that store.

One line per document now, the vector or null.

Refs macula-io/macula-ci-images#19
A short fold and an unread vector can no longer pass for a whole export
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 4s
c4 model / c4-model (pull_request) Successful in 0s
lint-and-test / check (pull_request) Successful in 7m38s
24f024d0f8
Uranus's review of 8796bcbf..702e452b, both defects.

barrel_store_rocksdb:fold_loop/4 returns its accumulator on ANY iterator
error, exactly as it does at the end of the range: a read error at document
40,000 of 68,774 ended the fold quietly, the read-back agreed with the short
file, counts were written and 0.11.0 would have imported 40,000. The counts
file is now also gated on the store's own totals, read by a route that does
not share the fold: our own iterator over the document-key range, refusing on
every error but the end of the iteration, each document's live state from
barrel's per-document reader, and the vector store's own index size. Exported
documents, live documents and vectors must all agree or no counts file is
written (exit 5, both sides named in the log).

barrel:vector_get answers {error, incomplete_data} (a vector whose stored data
is missing), {error, {db_error, _}} (a read that failed) and, on a slow box, an
exit from a gen_server timeout; all three were taken for "this document has no
vector", so the document was exported without the vector it has and dropped out
of semantic search with the counts still adding up. Only not_found means none
now; anything else is counted, named, and ends the run.

Proven: the export module's two decisions under eunit (a stand-in for the one
vector-store call, its four shapes read from barrel_vectordb 2.5.1's do_get/2),
with the old swallow and an always-agreeing gate both mutants that fail the
tests; and on msi00 in the 0.10.2 image against a 12-document store, the gate
agreeing at 12/12/12, counting a docdb delete as keys 12 / live 11 / vectors 11,
and refusing an extra vector at exit 5 with the counts file untouched.

Refs macula-services/mcl-rag#6
The totals walk proves it reached the end, not only that it stopped
Some checks failed
c4 model / c4-model-1 (pull_request) Successful in 2s
c4 model / c4-model (pull_request) Successful in 0s
lint-and-test / check (pull_request) Failing after 15m1s
77adec95fd
The rocksdb NIF answers invalid_iterator both at the end of the range and
when a read fails (erocksdb_iter.cc checks Valid() before status()), so a
persistent read error stopped the walk at the same key as the fold and the
two counts agreed. A vectorless tail lost that way also kept the vector
totals equal. The walk now seeks to the range's last key when it stops and
refuses unless that is the key it saw last.

Refs #6
terra manually merged commit bc6c746c17 into main 2026-11-23 23:26:32 +00:00
Author
Member

Purpose met: PR 6 landed on main as bc6c746c176cbf7c636de00878cab418c20e6b7e (merge of 77adec95fd4ec18f767bc3d9c68697cd8b7bed49), green r=2 — Uranus's PASS on 8796bcbf..77adec95, ci=forgejo:2965,2976, lint run 69 and c4-model run 67 both success on that exact tip.

What main now carries, as the Purpose asked:

  • cutover/rag_cutover_export.erl — runs in the old 0.10.x image against a stopped volume, folds the barrel store, reads each vector on its own, and writes rag-export.jsonl and rag-export.counts.json, refusing on a short fold, an unread vector, or a walk that stopped before the range's last key.
  • cutover/run_the_cutover.sh — the cutover as one script: --check, --export --a-side <ref>, --health.

Measured on the 2026-11-23 copy of the live store (68,774 documents, 55,450 with a vector): export exit 0, the store's own totals {ok,#{keys => 97042, live => 68774, vectors => 55450}} agreeing with the export, counts written; the verdict table is comment 2638 on macula-io/macula-ci-images#19.

The deploy half stays in macula-io/macula-ci-images#19 step 2 and waits on the 0.11.0 menu (the /etc/image-signer/targets line, the mcl-rag-publisher login, the tag), then the fleet PR and the two landings in run_the_cutover.sh's README.

Purpose met: PR 6 landed on main as **`bc6c746c176cbf7c636de00878cab418c20e6b7e`** (merge of `77adec95fd4ec18f767bc3d9c68697cd8b7bed49`), green r=2 — Uranus's PASS on `8796bcbf..77adec95`, `ci=forgejo:2965,2976`, lint run 69 and c4-model run 67 both success on that exact tip. What main now carries, as the Purpose asked: - `cutover/rag_cutover_export.erl` — runs in the old 0.10.x image against a stopped volume, folds the barrel store, reads each vector on its own, and writes `rag-export.jsonl` and `rag-export.counts.json`, refusing on a short fold, an unread vector, or a walk that stopped before the range's last key. - `cutover/run_the_cutover.sh` — the cutover as one script: `--check`, `--export --a-side <ref>`, `--health`. Measured on the 2026-11-23 copy of the live store (68,774 documents, 55,450 with a vector): export exit 0, the store's own totals `{ok,#{keys => 97042, live => 68774, vectors => 55450}}` agreeing with the export, counts written; the verdict table is comment 2638 on macula-io/macula-ci-images#19. The deploy half stays in macula-io/macula-ci-images#19 step 2 and waits on the 0.11.0 menu (the `/etc/image-signer/targets` line, the `mcl-rag-publisher` login, the tag), then the fleet PR and the two landings in `run_the_cutover.sh`'s README.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
macula-services/mcl-rag!6
No description provided.