Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

sync: deletion candidates in their own helper (function-size); Postgres lanes for the 4b suites

garrytan896e97a7ecb3
diff --git a/src/core/persistence/sync-pass.ts b/src/core/persistence/sync-pass.ts
index 1aa2ffbee5..22de03f7bb 100644
--- a/src/core/persistence/sync-pass.ts
+++ b/src/core/persistence/sync-pass.ts
@@ -604,6 +604,12 @@ async function reclassifyByOrigin(gitRoot: string, tips: Array<string | null | u
return true;
}
+/** GBRA-133: the deleted-side `file_drift` holds whose file is gone (`gone`, on the Git path); the stamp releases those whose page is no longer live. */
+function deletionCandidates(holds: readonly GitHoldRecord[], gone: (path: string) => boolean, toGit: (path: string) => string): DeletionCandidate[] {
+ return holds.filter(hold => hold.code === 'file_drift' && fileDriftSide(hold.meta) === 'deleted' && gone(toGit(hold.path)))
+ .map(hold => ({ path: hold.path, page_id: hold.page_id ?? null, slug: hold.slug ?? null }));
+}
+
/**
* The shadow level of a managed source: every path classified, nothing written. Null for a company-brain source, which
* keeps its frozen manifest (design v3.2 §3.6).
@@ -900,11 +906,8 @@ export async function readShadowLevel(engine: BrainEngine, input: { sourceId: st
return { sourceId, incarnation, root, gitRoot, scope, slugMode, mode, head, baselineCommit, full: input.full === true, kind: kind.kind, kindBlockers: kind.blockers,
heldRenames: holds.flatMap(hold => hold.meta.rename_from ? [{ path: toGit(hold.path), rename: hold.meta.rename_from }] : []),
releasableHolds: holds.filter(hold => !domain.has(toGit(hold.path))).map(hold => hold.path),
- deletionCandidates: holds.filter(hold => {
- const path = toGit(hold.path);
- return hold.code === 'file_drift' && fileDriftSide(hold.meta) === 'deleted' && domain.has(path) && !tree.has(path)
- && !(mode === 'working' && (untracked.has(path) || index.has(path))) && !readPresent(root, path, scope);
- }).map(hold => ({ path: hold.path, page_id: hold.page_id ?? null, slug: hold.slug ?? null })),
+ deletionCandidates: deletionCandidates(holds, path => domain.has(path) && !tree.has(path)
+ && !(mode === 'working' && (untracked.has(path) || index.has(path))) && !readPresent(root, path, scope), toGit),
paths, reconcilable, ...(colon.refusals.size ? { fileRefusals: [...colon.refusals.values()] } : {}), timings_ms: timings, statements: statements + attestationStatements + 3,
...(confirm ? { confirm: narrow ? { ...confirm, narrow: narrow === 'taken' && !reuse ? 'classified' : narrow } : confirm } : {}), ...(reuse ? { reused } : {}), ...(treeReuse ? { treeReuse } : {}), pack: pack?.identity ?? null,
selection: { exclude: [...exclude].sort(), includeHidden: [...includeHidden].sort(), strategy, srcSubpath: scope || null, mode },
diff --git a/test/postgres-unit-arms.txt b/test/postgres-unit-arms.txt
index 3e79f1bf9e..7f69e6f84d 100644
--- a/test/postgres-unit-arms.txt
+++ b/test/postgres-unit-arms.txt
@@ -67,9 +67,11 @@ test/extraction-watermark-atoms.test.ts
test/fact-embedding-oversized-7211.test.ts
test/fact-fence-adoption-exits.test.ts
test/fact-purge-lookup-timeout-6511.test.ts
+test/facts-absorb-stalled-receipt-7439.test.ts
test/facts-insert-guards-7105.test.ts
test/facts-publication-large-fence-6898.test.ts
test/fence-repair-receipts.test.ts
+test/file-drift-soft-delete-hold-release-gbra133.test.ts
test/forecast-journal.test.ts
test/frontmatter-reserved-keys-6454.test.ts
test/get-chunks-paging.test.ts
@@ -468,6 +470,7 @@ test/sync-status-failure-detail-6513.test.ts
test/sync-tree-reuse-gbra133.test.ts
test/sync-unblock-repair-error-gbra130.test.ts
test/sync-uncommitted-origin-7130.test.ts
+test/sync-unknown-drift-rescreen-gbra133.test.ts
test/sync-unreadable-file-gbra130.test.ts
test/sync-waiver-budget.test.ts
test/sync-waiver-run-imports.test.ts