Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
repair file-drift --held: durability warning for removed files
garrytane131f688d2bd
diff --git a/src/core/repair/file-drift.ts b/src/core/repair/file-drift.tsindex 46425eca38..0307d034d4 100644--- a/src/core/repair/file-drift.ts+++ b/src/core/repair/file-drift.ts@@ -621,12 +621,15 @@ export const fileDriftRepair: RepairHandler = {: [page.slug, page.preview.preconditions.revision, page.preview.preconditions.raw_file_hash, page.preview.result_digest]) });// #6712 wave: a recreated file stays only once committed; without Git durability the next sync imports the committed deletion again.const recreated = pages.flatMap(page => 'preview' in page && page.file_gone ? [page.preview.preconditions.relative_path] : []);+ // #6712 PR 4b: a removed file is gone only once its deletion is committed; without Git durability the next sync finds the committed file held again.+ const removed = pages.flatMap(page => 'remove_file' in page ? [page.remove_file.path] : []);let warnings: string[] = [];- if (recreated.length) {+ if (recreated.length || removed.length) {const binding = await getWorktreeBinding(engine, sourceId);const root = join(binding!.local_path!, binding!.relative_path);if (!(await gitDurabilityPolicy(binding, root).catch(() => ({ durable: false }))).durable) {- warnings = [`Git durability is off for ${sourceId}, so the apply leaves each recreated file uncommitted. Commit it afterwards (git -C ${root} add -- ${recreated.join(' ')} && git -C ${root} commit), or the next sync imports the committed deletion again.`];+ if (recreated.length) warnings.push(`Git durability is off for ${sourceId}, so the apply leaves each recreated file uncommitted. Commit it afterwards (git -C ${root} add -- ${recreated.join(' ')} && git -C ${root} commit), or the next sync imports the committed deletion again.`);+ if (removed.length) warnings.push(`Git durability is off for ${sourceId}, so the apply leaves each removed file's deletion uncommitted. Commit it afterwards (git -C ${root} add -- ${removed.join(' ')} && git -C ${root} commit), or the next sync holds the committed file again.`);}}let artifact: string | undefined;diff --git a/test/repair-file-drift-held-6712.test.ts b/test/repair-file-drift-held-6712.test.tsindex cc4fdd48e3..2474a3c8d7 100644--- a/test/repair-file-drift-held-6712.test.ts+++ b/test/repair-file-drift-held-6712.test.ts@@ -174,6 +174,7 @@ for (const backend of testBackends()) describe(`#6712 PR 4b: repair file-drift -expect(preview).toMatchObject({ mode: 'dry_run', affected: 1 });expect(preview.details!.pages).toEqual([expect.objectContaining({ slug: 'notes/tomb', action: 'remove_file', state: 'tombstone_edited', verb: 'keep the deletion and remove the file' })]);expect(preview.listing).toEqual(expect.arrayContaining([expect.objectContaining({ detail: `keep the deletion and remove the file: ${path}` })]));+ expect(preview.warnings).toEqual([expect.stringContaining("leaves each removed file's deletion uncommitted")]);expect(existsSync(join(f.root, path))).toBe(true);const applied = await run(f.sourceId, { side: 'deleted', state: 'tombstone_edited', prefer: 'database', expect: preview.preview_hash! });expect(applied.outcomes).toEqual({ repaired: 1 });