Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Turning sync.on_commit off still ends a retry a HEAD move started; review wording fixes (GST-2515, GST-2520)

garrytan319c3b0b66b7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 01a4164fe7..d9a261bab8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,8 +15,8 @@ identifiers and attribution are available in the pre-removal Git revision
**A stalled background sync of a large source is retried with a budget that can finish it, and the retries no longer stop silently**
- A large source that the background syncer could not finish no longer retries forever with the same short budget. A resident gives its first run 30 seconds, and every resident restart or change of the process holding the notifier counted as "first" again, so each retry stopped at the same point having saved nothing. That short budget now goes only to a source with no failed attempts on record, and a retry after a run that saved nothing gets the full sync budget.
-- A source the background syncer marked stalled (`notifier_stalled`, "retrying every 300 s") now really is retried every five minutes. With `sync.on_commit` off (the default), the retry only happened while the original sync request was still on record, and a run that stopped early could clear that request, so the source sat stalled with nothing retrying it and nothing in the log. The retry now continues until a run completes, also after a restart or when another resident takes over the notifier, which now reads the state the previous one recorded.
-- `gbrain sync --skip-failed`, and the automatic skip after three failed syncs, no longer skip files that were refused because of how the source is set up rather than because anything is wrong with them (`strict_requires_managed`: a `canonical: git` source on a brain without managed persistence). Skipping them moved the sync checkpoint to the latest commit with no pages imported, after which `sync status` said synced and later syncs found nothing to do, even once the setup was fixed. The sync now stays blocked, says why, and names the two fixes: turn on managed persistence, or remove `canonical: git`, after which the next plain sync imports every page. A brain that was already skipped past this way needs one `gbrain sync --source <id> --full`.
+- A source the background syncer marked stalled (`notifier_stalled`, "retrying every 300 s") now really is retried every five minutes. With `sync.on_commit` off (the default), the retry only happened while the original sync request was still on record, and a run that stopped early could clear that request, so the source sat stalled with nothing retrying it and nothing in the log. The retry now continues until a run completes, also after a restart or when another resident takes over the notifier, which now reads the state the previous one recorded. Turning `sync.on_commit` off, or excluding the source, still ends a retry that a HEAD move started.
+- `gbrain sync --skip-failed`, and the automatic skip after three failed syncs, no longer skip files that were refused because of how the source is set up rather than because anything is wrong with them (`strict_requires_managed`: a `canonical: git` source on a brain without managed persistence). Skipping them moved the sync checkpoint to the latest commit with no pages imported, after which `sync status` said synced and later syncs found nothing to do, even once the setup was fixed. The sync now stays blocked, says why, and names the two fixes: turn on managed persistence, or remove `canonical: git`, after which the next plain sync imports every page. A brain that was already skipped past this way needs one `gbrain sync --source <id> --full`. A scheduled `gbrain sync --skip-failed && …` on such a source now stops at the blocked sync until the setup is fixed.
## [0.60.688.0] - 2026-11-12
diff --git a/docs/guides/on-commit-sync.md b/docs/guides/on-commit-sync.md
index 338b81e816..6a6658dd3b 100644
--- a/docs/guides/on-commit-sync.md
+++ b/docs/guides/on-commit-sync.md
@@ -178,6 +178,9 @@ itself is settled) and across a resident restart or a change of lease owner,
which reads the attempt count the previous owner recorded. The short budget a
resident gives its first run applies only to a source with no failed attempts,
so a retry after a run that advanced nothing gets the full sync budget.
+Turning sync.on_commit off, or excluding the source with
+sync.on_commit.sources, still ends a retry that a HEAD move started: the source
+goes idle.
A run that committed pages counts as progress even before the source's last
synced commit moves. When the last error is drain_holder_stalled, another
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index 4e071cb968..c479902737 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -1548,8 +1548,8 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;
{ since: '0.60.686.0', id: 'readers_label_setter_gst2476', text: 'New `gbrain repair visibility (--slug <page>... | --slugs-file <file>) --readers <ids|none>` sets or removes a page\'s `readable_by` through the label-only door: the page keeps its trust tier and provenance and its file changes only on that line. Unknown or disabled members and unknown groups refuse `access_member_invalid`; a list without the brain owner refuses unless `--allow-without-owner`. Every `repair visibility` write to a managed page with no file outside a declared `storage.db_only` path is now held `canonical_file_missing` with nothing written, instead of failing `source_changed`.' },
{ since: '0.60.686.0', id: 'fence_fact_private_in_place_gst2487', text: 'A page write that only makes a `## Facts` row private (same claim, world to private) now makes the stored row private in place, keeping its id and trust tier, even when the row is more trusted than the writer. Before, such a row stayed live and world beside a contested private copy, so `gbrain repair visibility --class facts` could leave a fact remote callers still read while the page and its file read as fixed (`fact_left_readable`, `fact_left_world`). On a brain without managed persistence the repair now also makes the fenced row private. A write that makes a more trusted private row world is still held for the owner as before.' },
{ since: '0.60.688.0', id: 'sync_status_commits_waiting_gst2515', text: '`gbrain sync status` now reads `resumable` / `commits_waiting` when a managed source has nothing else pending (or only holds that need no person) but its checkout\'s HEAD is past the last synced commit. It used to read `synced` (`nothing_pending` or `held_by_design`) until some later sync ran. Its `next` is the plain sync (`gbrain sync` with `resume_argv`), which imports the waiting commits; status reads `synced` again once that sync lands. A script that treats `state: synced` as up to date now sees `resumable` while commits wait: run `next.argv`, or keep waiting for a resident to sync. A hold that needs a person (`held_needs_human`), a selection-scoped convergence, pending Git push holds and company-brain sources (which sync to their approved revision) keep their own reasons.' },
- { since: 'TBD', id: 'notifier_retry_unwatched_gst2515', text: 'The background syncer (the commit notifier in `gbrain serve`, `gbrain jobs work` or the autopilot daemon) now keeps retrying a source in `retry` / `notifier_stalled` on its backoff tier until a run completes, also with `sync.on_commit` off and across a restart or a change of the resident holding the notifier. Before, with `sync.on_commit` off, a source stopped being retried once its sync request was settled, while status still said it was retrying. A retry also no longer gets the 30-second first-run budget after a run that saved nothing: that budget now goes only to a source with no failed attempts on record, so a large source gets the full sync budget. `sync.on_commit` still defaults to off; this finishes runs a recorded request already asked for and does not start watching HEAD.' },
- { since: 'TBD', id: 'strict_skip_mode_refusal_gst2520', text: '`gbrain sync --skip-failed`, and the automatic skip after repeated failed syncs, no longer move the checkpoint past files refused because of how the source or brain is set up (`strict_requires_managed`, a `canonical: git` source on a brain without managed persistence; `writer_coordinator_required`). The sync stays blocked and prints which setup to fix, and after the fix the next plain sync imports every page. A brain that was skipped past this way before upgrading needs one `gbrain sync --source <id> --full`. Files that are themselves bad are skipped as before.' },
+ { since: 'TBD', id: 'notifier_retry_unwatched_gst2515', text: 'The background syncer (the commit notifier in `gbrain serve`, `gbrain jobs work` or the autopilot daemon) now keeps retrying a source in `retry` / `notifier_stalled` on its backoff tier until a run completes, also with `sync.on_commit` off and across a restart or a change of the resident holding the notifier. Before, with `sync.on_commit` off, a source stopped being retried once its sync request was settled, while status still said it was retrying. A retry also no longer gets the 30-second first-run budget after a run that saved nothing: that budget now goes only to a source with no failed attempts on record, so a large source gets the full sync budget. `sync.on_commit` still defaults to off; this finishes runs a recorded request already asked for and does not start watching HEAD, and turning `sync.on_commit` off or excluding the source with `sync.on_commit.sources` still ends a retry that a HEAD move started.' },
+ { since: 'TBD', id: 'strict_skip_mode_refusal_gst2520', text: '`gbrain sync --skip-failed`, and the automatic skip after repeated failed syncs, no longer move the checkpoint past files refused because of how the source or brain is set up (`strict_requires_managed`, a `canonical: git` source on a brain without managed persistence; `writer_coordinator_required`). The sync stays blocked and prints which setup to fix, and after the fix the next plain sync imports every page. A brain that was skipped past this way before upgrading needs one `gbrain sync --source <id> --full`. In a run with no such refusal, files that are themselves bad are skipped as before; a scheduled `gbrain sync --skip-failed && …` on a source in this state now stops at the blocked sync until its setup is fixed.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */
diff --git a/src/core/commit-notifier.ts b/src/core/commit-notifier.ts
index 8c8e882a8f..bef7aaaf6d 100644
--- a/src/core/commit-notifier.ts
+++ b/src/core/commit-notifier.ts
@@ -366,7 +366,7 @@ export function startCommitNotifier(opts: CommitNotifierOptions): CommitNotifier
const states = await guard('reading the notifier states', () => opts.store.readStates(fresh.map(r => r.sourceId)), [] as NotifierSourceRow[]);
restoreStates(sources, states, now());
}
- for (const rt of sources.values()) rt.watched = enabled && !excluded.has(rt.sourceId);
+ for (const rt of fresh) rt.watched = enabled && !excluded.has(rt.sourceId);
for (const rt of sources.values()) {
if (stopped) return;
if (!rt.watched || forcePoll || !opts.watch) { if (!rt.watched) closeWatch(rt); continue; }
@@ -503,7 +503,7 @@ export function startCommitNotifier(opts: CommitNotifierOptions): CommitNotifier
running.set(rt.sourceId, { id: start.jobId, sourceId: rt.sourceId, head: rt.head, lastCommit: rt.lastCommit, intent, markers });
await transition(rt, { state: 'running', firstDue: 'keep' });
decide(rt.sourceId, 'start', { detail: `${intent}${slice ? ` slice ${slice}s` : ''}` });
- log(`${rt.sourceId}: ${intent === 'freshness' && rt.head ? `HEAD moved to ${short(rt.head)} (last synced ${short(rt.lastCommit)})` : `a ${intent} request is pending`}; started ${rt.kind === 'classic' ? 'classic' : 'managed'} sync job ${start.jobId}`);
+ log(`${rt.sourceId}: ${intent === 'freshness' && rt.head ? `HEAD moved to ${short(rt.head)} (last synced ${short(rt.lastCommit)})` : rt.markers.length ? `a ${intent} request is pending` : 'retrying an unfinished run'}; started ${rt.kind === 'classic' ? 'classic' : 'managed'} sync job ${start.jobId}`);
}
};
@@ -527,7 +527,7 @@ export function startCommitNotifier(opts: CommitNotifierOptions): CommitNotifier
if (stopped) return;
for (const rt of sources.values()) {
const w = enabled && !excluded.has(rt.sourceId);
- if (w !== rt.watched) { rt.watched = w; if (!w) closeWatch(rt); else listedAt = -Infinity; }
+ if (w !== rt.watched) { rt.watched = w; if (w) listedAt = -Infinity; else { closeWatch(rt); if ((rt.state === 'retry' || rt.state === 'due') && !rt.markers.length) await transition(rt, { state: 'idle', reason: null, firstDue: 'clear', attempts: 0, error: null }); } }
}
const wasNudged = nudged;
nudged = false;
diff --git a/test/notifier-retry-unwatched-gst2515.test.ts b/test/notifier-retry-unwatched-gst2515.test.ts
index 69e959c7c3..c2a2259348 100644
--- a/test/notifier-retry-unwatched-gst2515.test.ts
+++ b/test/notifier-retry-unwatched-gst2515.test.ts
@@ -12,7 +12,7 @@
*/
import { describe, expect, test } from 'bun:test';
import type { BrainEngine } from '../src/core/engine.ts';
-import { RETRY_BACKOFF_MS, startCommitNotifier, type CommitNotifier, type JobStatus, type NotifierStore, type StartRequest } from '../src/core/commit-notifier.ts';
+import { FLAG_EVERY_MS, RETRY_BACKOFF_MS, startCommitNotifier, type CommitNotifier, type JobStatus, type NotifierStore, type StartRequest } from '../src/core/commit-notifier.ts';
import { readNotifierSources, settleMarkers, upsertMarker } from '../src/core/notifier/store.ts';
import { sqlNotifierStore } from '../src/core/notifier/resident.ts';
import { isolatedSharedSkillsEngine } from './helpers/shared-skills-engine.ts';
@@ -25,12 +25,12 @@ const QUIET = 400;
interface World { t: number; starts: StartRequest[]; jobs: Map<string, JobStatus> }
-function resident(w: World, store: NotifierStore, kind: 'serve' | 'jobs-worker' = 'serve'): CommitNotifier {
+function resident(w: World, store: NotifierStore, kind: 'serve' | 'jobs-worker' = 'serve', flag = { on: false }): CommitNotifier {
return startCommitNotifier({
resident: kind, log: () => {}, hostId: HOST, store, now: () => w.t, pollMs: 3000, quietMs: QUIET, heartbeatMs: 10_000,
firstSliceSeconds: 30, sliceSeconds: 120, maxConcurrent: 1,
setInterval: () => 'interval', clearInterval: () => {}, setTimeout: () => 'timer', clearTimeout: () => {},
- readFlag: async () => false,
+ readFlag: async () => flag.on,
listSources: async () => [{ sourceId: SOURCE, root: '/nonexistent/source-a', gitDir: null, lastCommit: A, kind: 'managed' }],
lastCommit: async () => A, revParse: async () => B, syncRunning: () => false, drainHeld: async () => false,
startSync: async (_s, req) => { w.starts.push(req); const jobId = 'job-' + w.starts.length; w.jobs.set(jobId, { state: 'running' }); return { jobId }; },
@@ -98,6 +98,24 @@ describe('GST-2515: an unwatched source keeps its retry tier (in-memory store)',
await standby.stop();
});
+ test('turning sync.on_commit off stops a retry that a HEAD move started: the source goes idle and nothing more starts', async () => {
+ const w: World = { t: 1_000_000, starts: [], jobs: new Map() };
+ const store = memoryNotifierStore({ lastCommit: () => A });
+ const flag = { on: true };
+ const n = resident(w, store, 'serve', flag);
+ await n.tick();
+ w.t += QUIET; await n.tick();
+ expect(w.starts).toHaveLength(1);
+ await stallLast(w, n);
+ expect(store.states.get(SOURCE)).toMatchObject({ state: 'retry' });
+ flag.on = false;
+ w.t += FLAG_EVERY_MS; await n.tick();
+ for (const wait of RETRY_BACKOFF_MS) { w.t += wait; await n.tick(); }
+ expect(w.starts).toHaveLength(1);
+ expect(store.states.get(SOURCE)).toMatchObject({ state: 'idle' });
+ await n.stop();
+ });
+
test('a run that completes clears the owed retry: the source goes idle and nothing more starts', async () => {
const w: World = { t: 1_000_000, starts: [], jobs: new Map() };
const store = memoryNotifierStore({ lastCommit: () => A });