Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test: run the kill loop's passed-over rounds on the single sync path so the primed edit always passes over (#8838)

garrytan01519a9531bd
diff --git a/scripts/persistence/README.md b/scripts/persistence/README.md
index dec7f15c90..488940e9fc 100644
--- a/scripts/persistence/README.md
+++ b/scripts/persistence/README.md
@@ -563,7 +563,7 @@ The chaos modes, each named in failures and selectable with
| Mode | What happens | Expected end state | On master |
| --- | --- | --- | --- |
-| (a) client kills, (b) serve kills | A kill loop of `GBRAIN_TEST_CONVERGENCE_KILLS` change rounds, each ending in one `kill -9` at a point of the curated list (`publication:before_commit`, `publication:after_commit`, `consumer:preparing`, `lane:applied`, `sync:before_group_admission`, `sync:mid_checkpoint`, `sync:held_settled`, `sync:passed_over`, `sync:batch_entries`, `sync:tail_started`), cycling a `--no-delegate` client, a serve running a delegated catch-up, and a serve with its delegating client | strict convergence | runs |
+| (a) client kills, (b) serve kills | A kill loop of `GBRAIN_TEST_CONVERGENCE_KILLS` change rounds, each ending in one `kill -9` at a point of the curated list (`publication:before_commit`, `publication:after_commit`, `consumer:preparing`, `lane:applied`, `sync:before_group_admission`, `sync:mid_checkpoint`, `sync:held_settled`, `sync:passed_over`, `sync:batch_entries`, `sync:tail_started`), cycling a `--no-delegate` client, a serve running a delegated catch-up, and a serve with its delegating client; a `sync:passed_over` round syncs with `--no-bulk`, so its primed edit is admitted before any re-freeze can read it (#8838) | strict convergence | runs |
| (c) concurrent writers | During the kill loop: `gbrain put` rewrites of 5% of the notes, `remember` facts on an entity page, `gbrain extract timeline --source db` (a managed maintenance job) | strict convergence; every acknowledged write in the ledger | runs |
| (c-db) DB-only competitor | With `sync.write_through=false`, a DB-only `put` lands while the run is stalled on that page's frozen entry, and another on a page whose file did not change | the raced page is held `concurrent_write` (needs a person), its file keeps the committed bytes and its page the DB write; both pages are left out of disk == DB | runs |
| (d) out-of-band Git | While a run is stalled mid-manifest: `git mv` and `git rm` of 1% of the files, committed, and deletion of 1% uncommitted | moves and removals converge strictly; each uncommitted deletion is listed by `gbrain pages ghosts` with the `gbrain repair ghost-pages` exit and left out of disk == DB | runs |
diff --git a/test/sync-convergence.serial.test.ts b/test/sync-convergence.serial.test.ts
index 998c72dd5b..62433f80e0 100644
--- a/test/sync-convergence.serial.test.ts
+++ b/test/sync-convergence.serial.test.ts
@@ -128,9 +128,12 @@ class Brain extends HarnessBrain { constructor(name: string, modes: Mode[]) { su
* read and before any admission. `sync:passed_over` and `sync:held_settled` need a file that changes after its freeze:
* their round primes one with an uncommitted edit at `sync:after_freeze`, which the pass passes over once (the level
* moved) and, when the next round reads the same uncommitted bytes, holds `worktree_dirty` (the hold); the harness
- * commits the edit after the round. Every point here must be one a pass crosses: the cursor engine's
- * `sync:retry_deferred` and `sync:prescreened` are company-source only since #6712 PR 4b, so a non-company kill loop
- * never reaches them.
+ * commits the edit after the round. A `sync:passed_over` round syncs with `--no-bulk`, which a delegated serve receives
+ * too (#8838): a bulk group or admit-ahead window can freeze the primed entry and drop it unadmitted (a group fallback
+ * or a kill), and its re-freeze reads the edited bytes, which hold at once instead of passing over. On the single path
+ * an entry is admitted right after its freeze, so the edit always reaches publication as a change after admission.
+ * Every point here must be one a pass crosses: the cursor engine's `sync:retry_deferred` and `sync:prescreened` are
+ * company-source only since #6712 PR 4b, so a non-company kill loop never reaches them.
*/
const KILL_POINTS = [
{ point: 'publication:before_commit', per: 'page' }, { point: 'publication:after_commit', per: 'page' },
@@ -332,15 +335,16 @@ scenario(['a', 'b', 'c'], 'managed sync converges after a seeded kill loop of cl
...(edited !== null ? { prime: { point: 'sync:after_freeze', nth: 1, path: `${noteSlug(edited)}.md`,
edit: { file: join(b.repo, `${noteSlug(edited)}.md`), content: noteText(edited, `Round ${p.round} edit`) } } } : {}) };
b.writeNotes(indexes, `Round ${p.round}`, `round ${p.round}`, p.round % 3 === 1 ? [b.bigFile(120 + 20 * p.round, 400 + 40 * p.round, `v${p.round}`)] : []);
+ const single = p.point === 'sync:passed_over' ? ['--no-bulk'] : [];
let line: string;
if (p.kind === 'client') {
- const r = await b.sync(['--no-pull', '--no-delegate', '--json'], fault).result;
+ const r = await b.sync(['--no-pull', '--no-delegate', '--json', ...single], fault).result;
syncErrs[tag] = r.err; b.keepLog(`${tag}-client.log`, `${r.out}\n${r.err}`);
line = `client exit ${r.code} in ${(r.ms / 1000).toFixed(1)}s`;
} else {
const serve = new StdioServe(b, fault);
await serve.start();
- const client = b.sync(['--no-pull', '--json']);
+ const client = b.sync(['--no-pull', '--json', ...single]);
await Promise.race([serve.exited, client.result]);
if (p.kind === 'serve+client' && !serve.alive) { client.proc.kill('SIGKILL'); b.killedPids.add(client.proc.pid); }
const r = await client.result;