Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(sync): reset the once-per-process --retry-failed notice before asserting it prints once
garrytan4ef4468274c7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b0ae2491c2..1089d28226 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,7 +12,7 @@ identifiers and attribution are available in the pre-removal Git revision## [0.60.271.0] - 2026-10-16-**A page write no longer waits behind a sync group that an idle managed sync started in the moment it was being claimed.** While a managed sync drains with lanes, the lanes can sit idle between groups. If an agent's page write arrived just then and its own process was still claiming it, the drain skipped the write and started the next sync group, so the write waited for that group: about 730 ms instead of about 60 ms in the test traces. The FIFO claim now holds that group back, as the lane-head claim already did. The sync still gets one group after each such write commits, so a stream of writes cannot stall it. Two flaky tests on master are fixed with it.+**A page write no longer waits behind a sync group that an idle managed sync started in the moment it was being claimed.** While a managed sync drains with lanes, the lanes can sit idle between groups. If an agent's page write arrived just then and its own process was still claiming it, the drain skipped the write and started the next sync group, so the write waited for that group: about 730 ms instead of about 60 ms in the test traces. The FIFO claim now holds that group back, as the lane-head claim already did. The sync still gets one group after each such write commits, so a stream of writes cannot stall it. Three flaky tests on master are fixed with it.### What you'd see@@ -32,6 +32,7 @@ Nothing. Nothing is rewritten on upgrade and there is no migration.- New no-op fault point `consumer:claiming` before each FIFO and lane-head claim. `test/managed-sync-foreground-priority.test.ts` parks the drain's claims there instead of parking lanes at `lane:applied`, which let each lane take one more group first (the lanes-2 flake); a forced probe covers that race.- `test/claim-fifo-foreground-waiting.test.ts` (PGLite, and Postgres through `test/postgres-unit-arms.txt`): a write row-locked by its own process's claim is not overtaken by a sync head, and a stream of such writes still lets the sync side claim a head after every second write.- `SyncOpts.governMs` test seam (the drain governor's tick). `test/belief-ledger-purge-review.test.ts` "#1 (CI stall)" sets it instead of racing the governor's 10 s confirmation against its deadline's 10 s cooperative stop (master red at v0.60.268.0): it asserts `blocked` / `drain_stalled` with the governor first and, as a forced probe, `resumable` / `deadline` with the deadline first.+- `test/sync-managed-help-l7-6712.test.ts` "--retry-failed is a deprecated alias" failed whenever an earlier test file in the same `bun test` process had already run `sync --retry-failed`, because the coaching notice prints once per process. It now resets that flag first (`resetRetryFailedNoticeForTests`, `src/commands/sync/args.ts`); the once-per-process assertion is unchanged.## [0.60.270.0] - 2026-10-16diff --git a/src/commands/sync/args.ts b/src/commands/sync/args.tsindex c296013dc7..12ed0bb7b0 100644--- a/src/commands/sync/args.ts+++ b/src/commands/sync/args.ts@@ -237,6 +237,11 @@ export function noteRetryFailedDeprecated(args: string[]): void {process.stderr.write(`[gbrain notice sync_retry_failed_deprecated] ${RETRY_FAILED_DEPRECATED}\n`);}+/** Tests share one process across files: forget that an earlier file already printed the notice. */+export function resetRetryFailedNoticeForTests(): void {+ retryFailedNoted = false;+}+/** Flags read before the `--break-lock` branch. *//** setTimeout treats delays above 2^31-1 ms as ~1 ms; --interval stays within that bound. */const MAX_WATCH_INTERVAL_SECONDS = Math.floor(2_147_483_647 / 1000);diff --git a/test/sync-managed-help-l7-6712.test.ts b/test/sync-managed-help-l7-6712.test.tsindex f2ac2ba639..6488743c21 100644--- a/test/sync-managed-help-l7-6712.test.ts+++ b/test/sync-managed-help-l7-6712.test.ts@@ -24,7 +24,7 @@ import { join } from 'node:path';import { PGLiteEngine } from '../src/core/pglite-engine.ts';import type { BrainEngine } from '../src/core/engine.ts';import { runSync } from '../src/commands/sync.ts';-import { noteRetryFailedDeprecated, parseSyncFlags, printSyncHelp, RETRY_FAILED_DEPRECATED } from '../src/commands/sync/args.ts';+import { noteRetryFailedDeprecated, parseSyncFlags, printSyncHelp, resetRetryFailedNoticeForTests, RETRY_FAILED_DEPRECATED } from '../src/commands/sync/args.ts';import { refuseManagedForbiddenFlags } from '../src/commands/sync/managed-no-pull.ts';import { checkSyncConsolidation } from '../src/commands/doctor.ts';import { claimWorktree } from '../src/core/persistence/ownership.ts';@@ -150,6 +150,7 @@ test('--all, --hard-deadline, --no-bulk and --no-lanes stay accepted on a managetest('--retry-failed is a deprecated alias of the plain sync: it prints the coaching notice once and syncs the same', async () => withEnv(env, async () => {expect(NOTICE_CODES.sync_retry_failed_deprecated).toMatchObject({ kind: 'coaching' });expect(RETRY_FAILED_DEPRECATED).toContain('a plain gbrain sync now retries');+ resetRetryFailedNoticeForTests();const plainSource = (await managedSources(1))[0]!;const plain = await captured(() => runSync(engine, ['--source', plainSource.id, '--no-pull']));expect(plain.stderr).not.toContain('sync_retry_failed_deprecated');