From f6515073bf65a39048adb23ccaa35e73bf045a9f Mon Sep 17 00:00:00 2001 From: Ragnor Comerford Date: Sun, 31 May 2026 15:52:58 +0200 Subject: [PATCH] test(engine): sweep multiple legacy __run__ branches; doc nit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Strengthen the v2→v3 migration test to synthesize three `__run__*` branches (a real legacy graph accumulates one per run) so the migration's delete loop is exercised on a single reused dataset handle, not just a single branch. Confirms multi-branch deletion is safe. Also drop a stale "active runs" reference from the branch_delete doc line. --- crates/omnigraph/src/db/manifest/tests.rs | 15 ++++++++++----- docs/user/branches-commits.md | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/omnigraph/src/db/manifest/tests.rs b/crates/omnigraph/src/db/manifest/tests.rs index a522168..885a2a8 100644 --- a/crates/omnigraph/src/db/manifest/tests.rs +++ b/crates/omnigraph/src/db/manifest/tests.rs @@ -1468,14 +1468,19 @@ async fn test_v2_to_v3_sweeps_legacy_run_branches_on_write_open() { let catalog = build_test_catalog(); let mut mc = ManifestCoordinator::init(uri, &catalog).await.unwrap(); - // Synthesize a pre-MR-770 graph: a stale `__run__` staging branch left on - // `__manifest`, alongside a real user branch that must survive the sweep. + // Synthesize a pre-MR-770 graph: several stale `__run__` staging branches + // left on `__manifest` (a real legacy graph accumulates one per run), plus + // a real user branch that must survive the sweep. Multiple run branches + // exercise the migration's delete loop on a single reused dataset handle. mc.create_branch("__run__01J9LEGACY").await.unwrap(); + mc.create_branch("__run__01J9SECOND").await.unwrap(); + mc.create_branch("__run__01J9THIRD").await.unwrap(); mc.create_branch("feature").await.unwrap(); let before = mc.list_branches().await.unwrap(); - assert!( - before.iter().any(|b| b == "__run__01J9LEGACY"), - "precondition: legacy run branch exists on __manifest; got {before:?}", + assert_eq!( + before.iter().filter(|b| b.starts_with("__run__")).count(), + 3, + "precondition: three legacy run branches exist on __manifest; got {before:?}", ); // Rewind the internal-schema stamp to v2 so the next write-open runs the diff --git a/docs/user/branches-commits.md b/docs/user/branches-commits.md index 02cbe1a..96b3f13 100644 --- a/docs/user/branches-commits.md +++ b/docs/user/branches-commits.md @@ -10,7 +10,7 @@ OmniGraph builds *graph branches* on top by branching every sub-table coherently - `branch_create(name)` / `branch_create_from(target, name)` — disallowed name `main`; fails if branch exists; ensures the schema-apply lock is idle. - `branch_list()` — returns public branches, **filters the internal** `__schema_apply_lock__` branch. -- `branch_delete(name)` — refuses if there are descendants or active runs on the branch; cleans up owned per-branch fragments. +- `branch_delete(name)` — refuses if there are descendants on the branch, or if it is the current branch; cleans up owned per-branch fragments. - **Lazy forking**: a branch only forks a sub-table when that sub-table is first mutated on it. Pure-read branches share fragments with their source. - `sync_branch(branch)` — re-binds the in-memory handle to the latest head of the branch.