The cutover instrument: the A-side export, and the run as one script with --check #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ceres/19-rag-cutover-run"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 whenrag-export.jsonlandrag-export.counts.jsonare 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 inrag_export_file's format (the module the import uses, so the format is not carried twice). It then reads its own file back withrag_export_file:decode/1and refuses unless the lines add up to the documents, vectors and per-prefix counts the fold counted. A document it cannot export is named inrag-export.problems.txtand 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 andquadlet-offlineline, the store's shape (barrel dirs, norag.sqlite, no stale export), space, ollama and the model, the modules.--exportis the A side and refuses while the service is running or the installed unit is present, becauseapply-quadlets.shstarts any unit that is not running on every reconcile tick and would open the volume under the export.--healthwaits 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 --checkwas 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, andquadlet-offlinedoes not namemcl-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 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#19Uranus'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#6Purpose met: PR 6 landed on main as
bc6c746c176cbf7c636de00878cab418c20e6b7e(merge of77adec95fd4ec18f767bc3d9c68697cd8b7bed49), green r=2 — Uranus's PASS on8796bcbf..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 writesrag-export.jsonlandrag-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/targetsline, themcl-rag-publisherlogin, the tag), then the fleet PR and the two landings inrun_the_cutover.sh's README.