Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: clear verified sync head sentinels (#2734)

symmetric-matthew7a1f61a31a9c
diff --git a/src/commands/sync.ts b/src/commands/sync.ts
index 55177421b6..84f47488d2 100644
--- a/src/commands/sync.ts
+++ b/src/commands/sync.ts
@@ -3129,6 +3129,7 @@ async function performSyncInner(engine: BrainEngine, opts: SyncOpts): Promise<Sy
// pin..HEAD diff. Advance to pin.
// - pin NOT an ancestor of HEAD (history REWRITE / reset / force-push) →
// the tree we imported against is gone. Block; do not advance.
+ let headVerificationSucceeded = false;
try {
const currentHead = git(gitContextRoot, ['rev-parse', 'HEAD']);
if (currentHead !== pin) {
@@ -3144,8 +3145,12 @@ async function performSyncInner(engine: BrainEngine, opts: SyncOpts): Promise<Sy
path: '<head>',
error: `git history rewritten during sync: pinned target ${pin.slice(0, 8)} is no longer an ancestor of HEAD ${currentHead.slice(0, 8)}`,
});
+ } else {
+ headVerificationSucceeded = true;
}
// else: forward progress (enrich committed on top) — safe, advance to pin.
+ } else {
+ headVerificationSucceeded = true;
}
} catch (e) {
// rev-parse failure is itself a drift signal (worktree disappeared).
@@ -3191,6 +3196,10 @@ async function performSyncInner(engine: BrainEngine, opts: SyncOpts): Promise<Sy
...succeededPaths,
...filtered.deleted,
...filtered.renamed.map(r => r.from),
+ // A prior transient rev-parse timeout records a hard-blocking sentinel that
+ // operators cannot acknowledge manually. Once pin ancestry is verified on
+ // a later run, clear that stale sentinel through the ordinary success path.
+ ...(headVerificationSucceeded ? ['<head>'] : []),
];
const gate = await applySyncFailureGate({
diff --git a/test/sync-failure-ledger.serial.test.ts b/test/sync-failure-ledger.serial.test.ts
index 76eab4e3a3..a2c895b2e7 100644
--- a/test/sync-failure-ledger.serial.test.ts
+++ b/test/sync-failure-ledger.serial.test.ts
@@ -90,6 +90,17 @@ describe('#4 success clears → consecutive attempts', () => {
expect(rows.length).toBe(1);
expect(rows[0].source_id).toBe('s2');
});
+
+ test('caller-verified HEAD success can clear a prior sentinel', async () => {
+ const { recordFailures, clearFailures, loadSyncFailures } = await L();
+ recordFailures('s', [{ path: '<head>', error: 'git HEAD verification timed out' }], 'c1');
+ expect(loadSyncFailures()[0].state).toBe('open');
+
+ // Sentinels cannot be acknowledged or auto-skipped; the sync caller may
+ // remove one only after it has successfully re-verified pin ancestry.
+ clearFailures('s', ['<head>']);
+ expect(loadSyncFailures()).toEqual([]);
+ });
});
describe('#3 sentinel never auto-skips', () => {