Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(sync): #6712 PR 4b the pass adopts or holds #6727 legacy pages; seeded mix asserts rulings b1-b6
garrytanf16e10980fa0
diff --git a/scripts/bench/sync-convergence-seeded.ts b/scripts/bench/sync-convergence-seeded.tsindex 76490b68c7..7f699eb3dd 100644--- a/scripts/bench/sync-convergence-seeded.ts+++ b/scripts/bench/sync-convergence-seeded.ts@@ -127,11 +127,11 @@ export function mixCases(): SeededCase[] {c('drift unknown', 'mix/drift-unknown.md', { key: 'drift', action: 'hold', settled: false, side: 'unknown' }, 'row 19', 'sync, raw SQL (record revision removed), put_page (write-through off), git commit'),c('held: file_drift', 'mix/held-file-drift.md', { key: 'held', ...settledNone }, 'row 1', 'sync, put_page (write-through off), git commit, writeGitHold'),c('held: concurrent_write', 'mix/held-concurrent.md', { key: 'held', ...settledNone }, 'row 1', 'sync, git commit, writeGitHold'),- c('held: worktree_dirty', 'mix/held-dirty.md', { key: 'held', ...settledNone }, 'row 1', 'git commit and uncommitted edit, sync (writes the hold)'),+ c('held: worktree_dirty', 'mix/held-dirty.md', { key: 'held', ...settledNone }, 'row 1', 'git commit and uncommitted edit, the worktree_dirty hold a release before PR 4b wrote (raw state)'),c('held: invalid_frontmatter', 'mix/held-badfm.md', { key: 'held', ...settledNone }, 'row 1', 'git commit, sync (writes the hold)'),- c('held: frontmatter_slug_conflict (#6865 stray slug: line)', 'mix/held-stray.md', { key: 'legacy_same', ...settledNone }, 'row 1 skipped (rescreen-due), row 10', 'git commit, sync (writes the hold)', FINDINGS.rescreenHold),- c('held: legacy_slug_conflict', 'mix/Legacy Name.md', { key: 'legacy_same', ...settledNone }, 'row 1 skipped (rescreen-due), row 10', 'raw SQL (legacy page without source_path), git commit, sync (writes the hold)', FINDINGS.rescreenHold),- c('refused once, no hold row (#6875 gate 2, #6865)', 'mix/refused-once.md', { key: 'legacy_same', ...settledNone }, 'row 10 via §2.7 bootstrap', 'git commit, sync (writes the hold), clearGitHold', FINDINGS.refusedOnce),+ c('held: frontmatter_slug_conflict (#6865 stray slug: line)', 'mix/held-stray.md', { key: 'held', action: 'import', settled: false }, 'row 1, re-screen due (rulings b2)', 'git commit, sync (writes the hold)'),+ c('held: legacy_slug_conflict', 'mix/Legacy Name.md', { key: 'held', action: 'import', settled: false }, 'row 1, re-screen due (rulings b2)', 'raw SQL (legacy page without source_path), git commit, sync (writes the hold)'),+ c('refused once, no hold row (#6875 gate 2, #6865)', 'mix/refused-once.md', { key: 'import', action: 'import', settled: false }, 'row 16: no deletion proof, so no legacy marker (rulings b1)', 'git commit, sync (writes the hold), clearGitHold'),c('delete (proof)', 'mix/delete-proof.md', { key: 'delete', action: 'delete', settled: false }, 'row 5', 'sync, git rm and commit'),c('delete_drift (no proof)', 'mix/delete-drift.md', { key: 'delete_drift', action: 'hold', settled: false, side: 'deleted', state: 'file_gone' }, 'row 6', 'sync, put_page (write-through off), git rm and commit'),c('deleted_same: tombstone', 'mix/tomb-same.md', { key: 'deleted_same', ...settledNone }, 'row 8', 'sync, delete_page (write-through off)'),@@ -140,12 +140,12 @@ export function mixCases(): SeededCase[] {c('gone (committed mode: row 3 precedes row 7)', 'mix/tomb-gone.md', { key: 'untracked', ...settledNone }, 'row 3', 'sync, delete_page, git rm and commit'),c('untracked page-less file (committed mode)', 'mix/untracked-new.md', { key: 'outside_domain' }, 'v3.1 §2.3 domain', 'file written, never committed'),c('purged before PR 4, no marker', 'mix/purged-nomarker.md', { key: 'legacy_same', ...settledNone }, 'row 10 via §2.7 bootstrap', 'sync, delete_page purge (write-through off)'),- c('deleted_same: deleted marker', 'mix/purged-marker-same.md', { key: 'deleted_same', ...settledNone }, 'row 8', 'sync, delete_page purge, raw SQL (the marker PR 4b writes)'),+ c('deleted_same: deleted marker', 'mix/purged-marker-same.md', { key: 'deleted_same', ...settledNone }, 'row 8', 'sync, delete_page purge (writes the marker)'),c('deleted_edited: deleted marker', 'mix/purged-marker-differs.md', { key: 'deleted_edited', action: 'hold', settled: false, side: 'deleted', state: 'purged_differs' }, 'row 9', 'sync, delete_page purge, raw SQL (marker), git commit'),c('legacy_same: legacy marker', 'mix/legacy-marker.md', { key: 'legacy_same', ...settledNone }, 'row 10', 'sync, delete_page purge, raw SQL (the legacy marker PR 4b writes)'),c('kept: live page, file left T, still on disk', 'mix/kept-file.md', { key: 'kept', ...settledNone }, 'row 4', 'sync, git rm --cached and commit'),c('dirty: committed edit under an uncommitted one', 'mix/dirty-held.md', { key: 'dirty', action: 'hold', settled: false }, 'row 11', 'sync, git commit, uncommitted edit'),- c('dirty: uncommitted edit of a synced file (absorbed)', 'mix/dirty-absorbed.md', { key: 'dirty', action: 'none', settled: true }, 'row 11 (settled: T[p] absorbed)', 'sync, uncommitted edit', FINDINGS.dirtyAbsorbed, { key: 'matched', action: 'none', settled: true }),+ c('dirty: uncommitted edit of a synced file (absorbed)', 'mix/dirty-absorbed.md', { key: 'matched', action: 'none', settled: true }, 'row 12: Dp is read for candidates only (rulings b3)', 'sync, uncommitted edit', FINDINGS.dirtyAbsorbed),c('dirty: write-through publication not committed (published)', 'mix/dirty-published.md', { key: 'dirty', action: 'none', settled: true }, 'row 11 (settled: published)', 'sync, put_page (write-through)', FINDINGS.dirtyGlossary),c('spelling: case-only', 'mix/Case-Pair.md', { key: 'spelling', action: 'refuse' }, 'row 2', 'git commit'),c('spelling: case-only', 'mix/case-pair.md', { key: 'spelling', action: 'refuse' }, 'row 2', 'git commit'),@@ -205,11 +205,18 @@ export async function seedMix(brain: MixBrain): Promise<SeededCase[]> {add('mix/held-dirty.md', 'mix/held-badfm.md', 'mix/held-stray.md', 'mix/refused-once.md', 'mix/Legacy Name.md');commitStaged(root, 'files sync holds');write(root, 'mix/held-dirty.md', note('held-dirty', 'An uncommitted draft on top.'));+ // PR 4b's pass does not import a dirty working copy and raises no worktree_dirty hold (the path is dirty); the hold is+ // the one a release before PR 4b wrote for this state, so it is seeded as that release left it (raw state).+ const draft = note('held-dirty', 'An uncommitted draft on top.'), staged = note('held-dirty', 'Synthetic held-dirty two.');+ await engine.transaction(tx => writeGitHold(tx, { source_id: 'default', incarnation, path: 'mix/held-dirty.md', source_path: 'mix/held-dirty.md', slug: 'mix/held-dirty', page_id: null,+ code: 'worktree_dirty', message: 'mix/held-dirty.md has uncommitted working-tree bytes that match neither the pinned commit nor the current page, so its import is held.',+ upstream_version: createHash('sha256').update(staged).digest('hex'), observed_at: new Date().toISOString(), run_id: null, mode: 'managed',+ meta: { recovery_version: RECOVERY_VERSION, blob_oid: oidAt('mix/held-dirty.md'), working_hash: createHash('sha256').update(draft).digest('hex') } } as Parameters<typeof writeGitHold>[1]));await performManagedSync(engine, SYNC);const holds = new Map(((await readGitSourceHolds(engine, { sourceIds: ['default'] }))[0]?.holds ?? []).map(hold => [hold.path, hold.code]));for (const [path, code] of [['mix/held-dirty.md', 'worktree_dirty'], ['mix/held-badfm.md', 'invalid_frontmatter'], ['mix/held-stray.md', 'frontmatter_slug_conflict'],['mix/refused-once.md', 'frontmatter_slug_conflict'], ['mix/Legacy Name.md', 'legacy_slug_conflict']] as const)- if (holds.get(path) !== code) throw new Error(`the second sync held ${path} as ${holds.get(path) ?? 'nothing'}, expected ${code}`);+ if (holds.get(path) !== code) throw new Error(`the second sync held ${path} as ${holds.get(path) ?? 'nothing'}, expected ${code}; holds ${JSON.stringify([...holds])}; pages ${JSON.stringify(await engine.executeRaw("SELECT slug, source_path FROM pages WHERE slug LIKE 'mix/%' AND (slug ILIKE '%legacy%' OR slug LIKE '%held%' OR slug LIKE '%refused%' OR slug LIKE '%place%' OR slug LIKE '%somewhere%')"))}`);// #6875 gate 2: a file refused before refusals were recorded as holds has no hold row at all.await engine.transaction(tx => clearGitHold(tx, { sourceId: 'default', incarnation, path: 'mix/refused-once.md', observedAt: new Date(Date.now() + 60_000).toISOString() }));@@ -237,11 +244,18 @@ export async function seedMix(brain: MixBrain): Promise<SeededCase[]> {await declarePersistenceProtocol(tx);await tx.executeRaw("UPDATE persistence_requests SET intent=NULL, compacted=true WHERE slug='mix/legacy-unverified'");});- const marker = (path: string, kind: 'deleted' | 'legacy', oids: string[]) => engine.executeRaw('INSERT INTO op_checkpoints(op,fingerprint,completed_keys) VALUES($1,$2,$3::text::jsonb)',- [SYNC_ORIGIN_DELETED_OP, `default:${incarnation}:${path}`, JSON.stringify([{ kind, blob_oids: oids, sha256: null, revision: null, page_id: null, at: new Date().toISOString() }])]);- await marker('mix/purged-marker-same.md', 'deleted', [purgedOids.get('mix/purged-marker-same.md')!]);- await marker('mix/purged-marker-differs.md', 'deleted', [purgedOids.get('mix/purged-marker-differs.md')!]);- await marker('mix/legacy-marker.md', 'legacy', [purgedOids.get('mix/legacy-marker.md')!]);+ // The purge wrote each origin's deleted marker through PR 4b's writer (sync-markers.ts); the deleted cases check that+ // real row. A purge before PR 4b left none (purged-nomarker), and a legacy marker is the bootstrap's (raw SQL for both).+ // The bootstrap writes a legacy marker with its deletion proof: the committed delete_page that removed the page (rulings b1).+ const purgeRequest = async (slug: string) => (await engine.executeRaw<{ id: string }>("SELECT request_id::text AS id FROM persistence_requests WHERE slug=$1 AND operation='delete_page' AND state='committed' ORDER BY sequence DESC LIMIT 1", [slug]))[0]?.id ?? null;+ const markerKey = (path: string) => `default:${incarnation}:${path}`;+ for (const path of ['mix/purged-marker-same.md', 'mix/purged-marker-differs.md']) {+ const [row] = await engine.executeRaw<{ value: { kind: string; blob_oids: string[] } }>('SELECT completed_keys->0 AS value FROM op_checkpoints WHERE op=$1 AND fingerprint=$2', [SYNC_ORIGIN_DELETED_OP, markerKey(path)]);+ if (row?.value.kind !== 'deleted' || !row.value.blob_oids.includes(purgedOids.get(path)!)) throw new Error(`the purge of ${path} wrote no deleted marker naming its blob: ${JSON.stringify(row ?? null)}`);+ }+ await engine.executeRaw('DELETE FROM op_checkpoints WHERE op=$1 AND fingerprint=$2', [SYNC_ORIGIN_DELETED_OP, markerKey('mix/purged-nomarker.md')]);+ await engine.executeRaw('INSERT INTO op_checkpoints(op,fingerprint,completed_keys) VALUES($1,$2,$3::text::jsonb) ON CONFLICT (op,fingerprint) DO UPDATE SET completed_keys=EXCLUDED.completed_keys',+ [SYNC_ORIGIN_DELETED_OP, markerKey('mix/legacy-marker.md'), JSON.stringify([{ kind: 'legacy', blob_oids: [purgedOids.get('mix/legacy-marker.md')!], deletion: await purgeRequest('mix/legacy-marker'), sha256: null, revision: null, page_id: null, at: new Date().toISOString() }])]);await withoutTrigger(() => engine.executeRaw("INSERT INTO pages(source_id,slug,type,page_kind,title,compiled_truth) VALUES('default','mix/Twin Page','note','markdown','Twin Page','Synthetic Twin Page one.')"));// Stage 3d: the Git side, one commit that names its paths.@@ -278,6 +292,9 @@ export async function seedMix(brain: MixBrain): Promise<SeededCase[]> {if (row.state !== 'queued') throw new Error(`the open put_page on ${slug} is ${row.state}`);}await engine.setConfig('sync.write_through', 'false');+ // The mix is the brain as PR 4b's first pass finds it on upgrade: no pass row, so the shadow reads it as the bootstrap+ // (design §2.7). The seeding's own syncs ran the pass; its row is removed (raw state).+ await engine.executeRaw("DELETE FROM op_checkpoints WHERE op='managed-sync-pass'");// keep_db is read from the checkout when the pass classifies; it is written last so no keep_db worker acts during seeding.write(root, 'gbrain.yml', 'storage:\n keep_db:\n - kept/\n');return mixCases().filter(entry => !SPELLING.includes(entry.path));@@ -338,12 +355,12 @@ export function fullCases(cases: SeededCase[]): SeededCase[] {return cases.map(entry => {const e = entry.expect;// An open episode makes the matched dirty-absorbed path a candidate, so its Dp is read and row 11 applies.- if (entry.path === 'mix/dirty-absorbed.md') return to(entry, 'row 11 (a candidate under --full, so Dp is read)', e);+ if (entry.path === 'mix/dirty-absorbed.md') return to(entry, 'row 11 (a candidate under --full, so Dp is read)', { key: 'dirty', action: 'none', settled: true });if (e.key === 'matched') return to(entry, 'row 14 (episode obligation)', { key: 'reparse', action: 'reparse', settled: false }, entry.finding);if (entry.path === 'mix/adopt-revision.md') return to(entry, 'row 15 (fileSame, ¬dbSame, arm 1 attests)', { key: 'db_ahead', action: 'none', settled: true, sub: 'pending' });if (e.key === 'adopt') return to(entry, 'row 16 (¬fileSame, proof)', { key: 'import', action: 'import', settled: false });if (e.key === 'db_ahead' && e.sub !== 'pending') return to(entry, 'row 15 (full_skipped_db_ahead)', { ...e, fullSkipped: true });- if (e.key === 'legacy_same') return to(entry, 'v3.1 §2.7: --full imports legacy-marked paths', { key: 'import', action: 'import', settled: false }, FINDINGS.fullLegacy, { key: 'legacy_same', action: 'none', settled: true });+ if (e.key === 'legacy_same') return to(entry, 'v3.1 §2.7: --full imports legacy-marked paths (rulings b5)', { key: 'import', action: 'import', settled: false });return entry;});}@@ -534,7 +551,7 @@ const SCALE_EXPECT: Record<ScaleKind, { expect: Expected; row: string; finding?:tombstone_same: { expect: { key: 'deleted_same', action: 'none' }, row: 'row 8' }, tombstone_edited: { expect: { key: 'deleted_edited', action: 'hold' }, row: 'row 9' },tombstone_untracked: { expect: { key: 'untracked', action: 'none' }, row: 'row 3' }, kept: { expect: { key: 'kept', action: 'none' }, row: 'row 4' },dirty: { expect: { key: 'dirty', action: 'hold' }, row: 'row 11' },- dirty_absorbed: { expect: { key: 'dirty', action: 'none' }, row: 'row 11 (absorbed)', finding: FINDINGS.dirtyAbsorbed, today: { key: 'matched', action: 'none' } },+ dirty_absorbed: { expect: { key: 'matched', action: 'none' }, row: 'row 12: Dp is read for candidates only (rulings b3)', finding: FINDINGS.dirtyAbsorbed },held_invalid_frontmatter: { expect: { key: 'held', action: 'none' }, row: 'row 1' }, legacy_unverified: { expect: { key: 'legacy_unverified', action: 'none' }, row: 'row 17' },deleted_marker_same: { expect: { key: 'deleted_same', action: 'none' }, row: 'row 8' }, legacy_marker: { expect: { key: 'legacy_same', action: 'none' }, row: 'row 10' },pageless_baseline: { expect: { key: 'legacy_same', action: 'none' }, row: 'row 10 via §2.7', finding: FINDINGS.refusedOnce }, spelling: { expect: { key: 'spelling', action: 'refuse' }, row: 'row 2' },diff --git a/src/core/persistence/sync-discovery.ts b/src/core/persistence/sync-discovery.tsindex 822668a40d..0c6927c963 100644--- a/src/core/persistence/sync-discovery.ts+++ b/src/core/persistence/sync-discovery.ts@@ -566,7 +566,7 @@ export async function discoverManagedSync(engine: BrainEngine, opts: SyncOpts, c}return discovered;}-type LegacyIdentity = { id: number; slug: string; source_path: string | null; deleted_at: Date | string | null };+export type LegacyIdentity = { id: number; slug: string; source_path: string | null; deleted_at: Date | string | null };/*** #6727: per discovery, its live pages with no recorded origin whose slug the current fold changes, by folded slug. Built on* first need; database-only pages (never imported from a file) are left out by one read over just those candidates, so a@@ -586,7 +586,7 @@ async function foldLegacyPages(engine: BrainEngine, identities: LegacyIdentity[]* links and history). Several, or one whose slug the importer cannot write as it stands (`validateSlug` lowercases), keep* the folded slug and are named on the entry, so the freeze holds the file `legacy_slug_conflict`.*/-async function adoptLegacyPage(engine: BrainEngine, identities: LegacyIdentity[], holder: LegacyIdentity | undefined, slug: string, entry: SyncEntry): Promise<string> {+export async function adoptLegacyPage(engine: BrainEngine, identities: LegacyIdentity[], holder: LegacyIdentity | undefined, slug: string, entry: Pick<SyncEntry, 'legacySlugs'>): Promise<string> {if (holder && holder.deleted_at == null) return slug;let folded = legacyByFold.get(identities);if (!folded) legacyByFold.set(identities, folded = foldLegacyPages(engine, identities));diff --git a/src/core/persistence/sync-pass-run.ts b/src/core/persistence/sync-pass-run.tsindex d08bce5a89..b80a1abc1b 100644--- a/src/core/persistence/sync-pass-run.ts+++ b/src/core/persistence/sync-pass-run.ts@@ -17,7 +17,7 @@ import { randomUUID } from 'node:crypto';import type { BrainEngine } from '../engine.ts';import type { SyncOpts, SyncResult } from '../../commands/sync.ts';import type { Cursor, RetryWait } from './sync-run.ts';-import { syncExcludePatterns, syncGit, type ManagedSyncContext, type SyncSlugCollision } from './sync-discovery.ts';+import { adoptLegacyPage, syncExcludePatterns, syncGit, type LegacyIdentity, type ManagedSyncContext, type SyncSlugCollision } from './sync-discovery.ts';import type { SyncAuthority, SyncProcessingOptions } from './sync-authority.ts';import type { PassStamp, SyncCursorOptions } from './sync-prepare.ts';import { OPEN_AT_STAMP_CAP, passFingerprint, readPassRow, SYNC_ORIGIN_DELETED_OP, writePassRow, type ManagedSyncPassValue, type PassEpisode,@@ -36,7 +36,7 @@ import { clearManagedSyncFailureAfterSuccess } from './sync-failures.ts';import { managedCursorKey, resolveManagedCursor, retireManagedCursor } from './sync-cursor-key.ts';import { withCoordinatedWrite } from './context.ts';import { principalAttribution } from './attribution.ts';-import { resolveSlugForPath } from '../sync.ts';+import { isCodeFilePath, resolveSlugForPath } from '../sync.ts';import { syncOriginPath } from './sync-origin.ts';import { originMarkerFingerprint } from './sync-markers.ts';import { passResumeArgs } from './sync-pass-readers.ts';@@ -118,6 +118,20 @@ async function batchEntries(engine: BrainEngine, level: ShadowLevel, deletes: Shconst leaving = new Map(deletes.map(entry => [entry.path, entry]));const fresh = imports.filter(entry => !entry.state.page);const slugOf = new Map(fresh.map(entry => [entry.path, resolveSlugForPath(entryPaths(level, entry.path).sourcePath)]));+ // #6727, as discovery does: a new origin with no live page at its slug takes the one legacy page (no recorded origin)+ // that folds to it; several, or one the importer cannot write, keep the slug and the freeze holds legacy_slug_conflict.+ const legacySlugs = new Map<string, string[]>();+ const adopting = fresh.filter(entry => slugOf.get(entry.path) && !isCodeFilePath(entryPaths(level, entry.path).sourcePath));+ if (adopting.length) {+ const identities = await engine.executeRaw<LegacyIdentity>('SELECT id, slug, source_path, deleted_at FROM pages WHERE source_id=$1 AND (source_path IS NULL OR slug=ANY($2::text[]))',+ [level.sourceId, [...new Set(adopting.map(entry => slugOf.get(entry.path)!))]]);+ const bySlug = new Map(identities.map(page => [page.slug, page]));+ for (const entry of adopting) {+ const named: { legacySlugs?: string[] } = {};+ slugOf.set(entry.path, await adoptLegacyPage(engine, identities, bySlug.get(slugOf.get(entry.path)!), slugOf.get(entry.path)!, named));+ if (named.legacySlugs) legacySlugs.set(entry.path, named.legacySlugs);+ }+ }const slugs = [...new Set([...slugOf.values()].filter(Boolean))];const holders = new Map((slugs.length ? await engine.executeRaw<{ id: number | string; slug: string; source_path: string | null; revision: string; deleted: boolean }>('SELECT id, slug, source_path, knowledge_revision::text AS revision, deleted_at IS NOT NULL AS deleted FROM pages WHERE source_id=$1 AND slug=ANY($2::text[])', [level.sourceId, slugs]) : [])@@ -143,7 +157,7 @@ async function batchEntries(engine: BrainEngine, level: ShadowLevel, deletes: Shif (losers.length) collisions.push({ slug, kept: kept ?? entryPaths(level, winner!.path).sourcePath, skipped: losers.map(entry => entryPaths(level, entry.path).sourcePath) });if (!winner) continue;const paths = entryPaths(level, winner.path);- const base = { ...paths, action: 'import' as const, working: working(winner), level: winner.state.level, slug };+ const base = { ...paths, action: 'import' as const, working: working(winner), level: winner.state.level, slug, ...(legacySlugs.has(winner.path) ? { legacySlugs: legacySlugs.get(winner.path)! } : {}) };if (holder) {entries.push({ ...base, pageId: Number(holder.id), revision: holder.revision,...(holder.source_path !== null ? { renameFrom: { sourcePath: holder.source_path, slug, pageId: Number(holder.id), revision: holder.revision } } : {}) });diff --git a/test/sync-convergence-seeded-6712.test.ts b/test/sync-convergence-seeded-6712.test.tsindex 43ef79c324..b77aca05fa 100644--- a/test/sync-convergence-seeded-6712.test.ts+++ b/test/sync-convergence-seeded-6712.test.ts@@ -10,7 +10,9 @@* seeding and the reads are the production calls (scripts/bench/sync-convergence-seeded.ts names the raw SQL it needs).** Cases whose 4a prediction differs from the design carry it as today: the mix asserts today, so a fix turns the mix red- * until the case drops it. The (a) findings this validation found (a write-through-off request outside U_db, an absent+ * until the case drops it. PR 4b's rulings b1-b6 set the design values the mix now asserts (no case carries today): a+ * re-screen-due hold is held (b2), a page-less file with no deletion proof imports (b1), an absorbed dirty path is+ * matched (b3), --full imports legacy-marked paths (b5). The mix is read as PR 4b's first pass finds it (no pass row). The (a) findings this validation found (a write-through-off request outside U_db, an absent* working-mode path read as unreadable, a spelling refusal without its dry-run receipt) are fixed in 4a; each keeps a* focused test below.*@@ -82,7 +84,7 @@ for (const backend of testBackends()) {expectRun(committed);expect(committed.receipt.deletes).toMatchObject({ count: 1, verdict: 'apply' });expect(committed.receipt.db_ahead).toMatchObject({ pending: 1, db_only: 2, unproven: 1 });- expect(committed.receipt).toMatchObject({ keep_db_admitted: 2, legacy_unverified: 1, legacy_pageless: 4, decisions: { both: 0, unknown: 0, deleted: 3 } });+ expect(committed.receipt).toMatchObject({ keep_db_admitted: 2, legacy_unverified: 1, legacy_pageless: 1, decisions: { both: 0, unknown: 0, deleted: 3 } });const cli = await cliChecks(engine, committed);expect({ dry: cli.dryRunExit, status: cli.statusExit }).toEqual({ dry: 0, status: 0 });diff --git a/test/sync-pass-live-6712.test.ts b/test/sync-pass-live-6712.test.tsindex 8a55ff5614..6f46247966 100644--- a/test/sync-pass-live-6712.test.ts+++ b/test/sync-pass-live-6712.test.ts@@ -17,6 +17,8 @@* settles in a later round with no hold.* - kill after a group's admission commit, before the stamp: the next run resumes the pass and converges, each path imported once.* - probe 40: a connection or pooler fault (SQLSTATE 08006, 57P01) in a pass never becomes a hold; the next run converges.+ * - #6727 on the pass route: a new file whose slug folds to a legacy page (no recorded origin) the importer cannot write is+ * held legacy_slug_conflict and forks no second page.* - probe 54: a pass intent keeps what the #6862 FIFO guard reads: a `managed_sync_` kind, the slug and page, and `renameFrom.slug`.** Each test fails on capy/6712-pr4b (8cda2764b), where a non-company source still runs the cursor engine: the fences do not@@ -245,6 +247,21 @@ describe('#6712 PR 4b live pass fences (pglite)', () => {await converged(engine, after);}, { setup }), 180_000);+ test('#6727 on the pass route: a new file whose slug folds to a legacy page it cannot write is held legacy_slug_conflict, never forked', () => managedBrain(async ({ engine, root }) => {+ expect((await performManagedSync(engine, OPTS)).status).toBe('first_sync');+ await engine.transaction(async tx => {+ await tx.executeRaw('UPDATE persistence_brain SET enabled=false WHERE singleton=1');+ await tx.executeRaw("INSERT INTO pages(source_id,slug,type,page_kind,title,compiled_truth) VALUES('default','notes/Legacy Name','note','markdown','Legacy Name','A legacy page.')");+ await tx.executeRaw('UPDATE persistence_brain SET enabled=true WHERE singleton=1');+ });+ writeFileSync(join(root, 'notes/Legacy Name.md'), note('Legacy Name', 'The file of an unwritable legacy page.')); commit(root, 'legacy file');+ const result = await performManagedSync(engine, OPTS);+ expect((result.held ?? []).map(hold => [hold.path, hold.code])).toEqual([['notes/Legacy Name.md', 'legacy_slug_conflict']]);+ const pages = await engine.executeRaw<{ slug: string; source_path: string | null; body: string }>(+ "SELECT slug, source_path, compiled_truth AS body FROM pages WHERE source_id='default' AND deleted_at IS NULL AND lower(slug) LIKE 'notes/legacy%' ORDER BY slug");+ expect(pages.map(page => ({ slug: page.slug, source_path: page.source_path, body: page.body.trim() }))).toEqual([{ slug: 'notes/Legacy Name', source_path: null, body: 'A legacy page.' }]);+ }, { setup }), 180_000);+test('probe 54: a pass intent keeps what the #6862 FIFO guard reads, renameFrom included', () => managedBrain(async ({ engine, root }) => {expect((await performManagedSync(engine, OPTS)).status).toBe('first_sync');git(root, 'mv', 'notes/b.md', 'notes/renamed.md'); commit(root, 'rename b');