Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(convergence): recovery reruns when HEAD moved past the synced run's last_commit, naming the commits (busy-agent (h) after #8828)

garrytan4702ca5087d8
diff --git a/scripts/persistence/README.md b/scripts/persistence/README.md
index 2cc4294a5c..dec7f15c90 100644
--- a/scripts/persistence/README.md
+++ b/scripts/persistence/README.md
@@ -579,9 +579,9 @@ anyway, which is how the PR that fixes it turns it on.
After the chaos every scenario gets a fresh serve (what a supervisor restarts)
and at most two plain `gbrain sync --no-pull` runs, with no operator step; only
-exit 0 with outcome `synced` counts, and a synced run whose
-receipt reports commits landed behind it (`watermark.pending.commits_behind`, a
-queued write's Git commit) is followed by the second. Then the oracle, each check its own test
+exit 0 with outcome `synced` counts, and a synced run that HEAD
+has moved past since (a queued write's Git commit landing during or after it, the
+commits named in the log) is followed by the second. Then the oracle, each check its own test
named by this gate's violation class: disk == database both ways (except the
pages the mode's end state names), no request queued, running, recovering or
holding a recovery record, every non-committed terminal request superseded or
diff --git a/test/helpers/convergence-brain.ts b/test/helpers/convergence-brain.ts
index b169becffa..b1f1e796ae 100644
--- a/test/helpers/convergence-brain.ts
+++ b/test/helpers/convergence-brain.ts
@@ -334,7 +334,7 @@ export class Brain {
this.note(`phase 0: fault-free import in ${(this.elapsed.baseline_import_ms / 1000).toFixed(1)}s; oracle calibration problems: ${this.calibration.length}`);
}
- /** A fresh resident serve and at most MAX_RECOVERY_RUNS plain syncs, no operator step; a synced run that reports commits landed behind it (a queued write's Git commit) is followed by the next. */
+ /** A fresh resident serve and at most MAX_RECOVERY_RUNS plain syncs, no operator step; a synced run that HEAD has moved past since (a queued write's Git commit landing during or after it) is followed by the next. */
async recover(): Promise<void> {
const started = performance.now();
const serve = new StdioServe(this);
@@ -344,9 +344,11 @@ export class Brain {
const envelope = lastJson(r.out);
this.recoveryRuns.push({ ...r, envelope });
this.keepLog(`recovery-${run}-client.log`, `${r.out}\n${r.err}`);
- const behind = ((envelope?.watermark as { pending?: { commits_behind?: { count?: number } } } | undefined)?.pending?.commits_behind?.count) ?? 0;
- this.note(`recovery run ${run}: exit ${r.code} in ${(r.ms / 1000).toFixed(1)}s outcome=${String(envelope?.outcome ?? envelope?.sync_status ?? envelope?.error ?? 'none')}${behind ? `, ${behind} commit(s) landed behind it` : ''}`);
- if (r.code === 0 && envelope?.outcome === 'synced' && behind === 0) break;
+ const [source] = await this.engine!.executeRaw<{ last_commit: string | null }>('SELECT last_commit FROM sources WHERE id=$1', [SOURCE]);
+ const head = this.git('rev-parse', 'HEAD');
+ const behind = source.last_commit && source.last_commit !== head ? this.git('log', '--format=%h %s', `${source.last_commit}..HEAD`).split('\n').filter(Boolean) : [];
+ this.note(`recovery run ${run}: exit ${r.code} in ${(r.ms / 1000).toFixed(1)}s outcome=${String(envelope?.outcome ?? envelope?.sync_status ?? envelope?.error ?? 'none')}${behind.length ? `; ${behind.length} commit(s) landed after it: ${behind.join('; ')}` : ''}`);
+ if (r.code === 0 && envelope?.outcome === 'synced' && !behind.length) break;
}
this.elapsed.recovery_ms = performance.now() - started;
this.keepLog('recovery-serve.log', serve.stderr);