Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(status): freshness_by_source lists only sources not current on both clocks (caught-up doctor output unchanged); sync-freshness gate documented in its script header, not docs/TESTING.md (120 KB cap)
garrytan9d82f7622da7
diff --git a/.github/workflows/sync-freshness-gate.yml b/.github/workflows/sync-freshness-gate.ymlindex 1e50fc4290..dfc2ec2393 100644--- a/.github/workflows/sync-freshness-gate.yml+++ b/.github/workflows/sync-freshness-gate.yml@@ -1,7 +1,7 @@name: Sync freshness gate# Commit -> keyword-visible regression gate for the resident commit notifier-# (GBRA-133 PR 2b.6; scripts/bench/sync-freshness-gate.ts, docs/TESTING.md#sync-freshness-gate).+# (GBRA-133 PR 2b.6; procedure and baseline in the header of scripts/bench/sync-freshness-gate.ts).# Cells: gbrain serve with sync.on_commit=true, watch detection, a single-file commit,# 10k synthetic pages, on Postgres managed, PGLite managed and Postgres classic. The gate# value is the p50 of 10 reps after one discarded warm-up; a cell fails above the committeddiff --git a/docs/TESTING.md b/docs/TESTING.mdindex 4d5579b7e6..26d7df9ab1 100644--- a/docs/TESTING.md+++ b/docs/TESTING.md@@ -302,22 +302,6 @@ ceilings: [scripts/scale/README.md](../scripts/scale/README.md). The import-rategate times PGLite by the import process's CPU time and Postgres by wall time;the README says why.-### Sync freshness gate--`.github/workflows/sync-freshness-gate.yml` (nightly and on dispatch, never in-the PR tier) runs `bun scripts/bench/sync-freshness-gate.ts` on-`ubicloud-standard-4-ubuntu-2404`. It times commit to keyword-visible through-`gbrain serve` with `sync.on_commit` on and watch detection, for a single-file-commit on a 10k-page synthetic brain: Postgres managed, PGLite managed and-Postgres classic. Each cell runs 11 reps; rep 0 is discarded and the p50 of the-other 10 must stay within 25% of `scripts/bench/sync-freshness-baseline.json`.-The baseline is only valid on that runner class: before it was committed, 25-runs on five fresh Ubicloud standard-4 VMs showed no false failure. Re-record-it on the same class after an intended latency change:-`bun scripts/bench/sync-freshness-gate.ts --write-baseline --machine-class ubicloud-standard-4`.-The full cell matrix (embedding, backlog drain, serve boot, fairness, idle cost,-poll mode) is a bench, not a gate: `scripts/bench/sync-freshness-matrix.sh pr2b6`.-### Authoring gateBefore adding a test, answer four questions in the PR description or the testdiff --git a/src/commands/doctor/checks/managed-sync-latency.ts b/src/commands/doctor/checks/managed-sync-latency.tsindex 182ef1f268..a765dfb993 100644--- a/src/commands/doctor/checks/managed-sync-latency.ts+++ b/src/commands/doctor/checks/managed-sync-latency.ts@@ -9,9 +9,9 @@* synced commit, aged from the reflog entry that moved HEAD (or the commit notifier's persisted first_due_at), or* unknown when neither can date it (no reflog, rewritten history). A stalled source has no new samples, so this* is what keeps it from reading ok.- * Keyword-visible and embedded freshness are reported separately per source that has synced- * (details.freshness_by_source, absent when none has); the embedding backlog is reported, not graded (a keyless brain- * reads disabled).+ * Keyword-visible and embedded freshness are reported separately for every synced source that is not current on both+ * clocks (details.freshness_by_source, absent when every source is current, so a caught-up brain's output is+ * unchanged); the embedding backlog is reported, not graded (a keyless brain reads disabled).* It grades only a brain that asked for low latency, with `sync.on_commit` true or `sync.freshness_target_seconds` set: a* p95 or a waiting commit over the target (default 300 s) warns and one over max(1 h, target) fails; a waiting commit of* unknown age and synced commits it cannot date (not in this host's checkout) warn. Otherwise it reports ok with the@@ -62,9 +62,13 @@ async function runManagedSyncLatencyCheck(ctx: DoctorContext): Promise<Check[]>const freshness = managed ? await readSyncFreshness(engine, { sourceIds: scope }) : [];const backlog = await readEmbedBacklog(engine, roster.map(s => s.id));const samplesBy = new Map(freshness.map(f => [f.source_id, f]));- const freshnessBySource = roster.flatMap((s, i) => pending[i]!.state === 'never_synced' ? [] : [{ source_id: s.id, kind: s.managed ? 'managed' : 'classic',- keyword_visible: { state: pending[i]!.state, oldest_unsynced: pending[i]!, samples: samplesBy.get(s.id)?.commit_to_searchable ?? null },- embedded: { state: embeddedState(pending[i]!, backlog.get(s.id)), backlog: backlog.get(s.id) ?? null, samples: samplesBy.get(s.id)?.commit_to_embedded ?? null } }]);+ const freshnessBySource = roster.flatMap((s, i) => {+ const keyword = pending[i]!.state, embedded = embeddedState(pending[i]!, backlog.get(s.id));+ if (keyword === 'never_synced' || (keyword === 'current' && (embedded === 'current' || embedded === 'disabled'))) return [];+ return [{ source_id: s.id, kind: s.managed ? 'managed' : 'classic',+ keyword_visible: { state: keyword, oldest_unsynced: pending[i]!, samples: samplesBy.get(s.id)?.commit_to_searchable ?? null },+ embedded: { state: embedded, backlog: backlog.get(s.id) ?? null, samples: samplesBy.get(s.id)?.commit_to_embedded ?? null } }];+ });const sampled = freshness.filter(f => f.commit_to_searchable.samples > 0);const details = { graded, on_commit: onCommit, target_seconds: target.seconds, fail_seconds: failSeconds, sources: freshness, ...(freshnessBySource.length ? { freshness_by_source: freshnessBySource } : {}), docs: DOCS };const behind = pending.filter(p => p.state === 'behind');