Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
ci: nightly sync-freshness gate on ubicloud-standard-4 for the three serve-watch cells (baseline + 25%, 25-run stress with no false failure)
garrytan66fd63114ead
diff --git a/.github/workflows/nightly-watch.yml b/.github/workflows/nightly-watch.ymlindex 296e2fa0b0..f6f0c1323a 100644--- a/.github/workflows/nightly-watch.yml+++ b/.github/workflows/nightly-watch.yml@@ -50,6 +50,7 @@ on:- Heavy Tests- Scale tier- Convergence nightly+ - Sync freshness gate- macOS 26 validation- Semgrep- OSV-Scannerdiff --git a/.github/workflows/sync-freshness-gate.yml b/.github/workflows/sync-freshness-gate.ymlnew file mode 100644index 0000000000..1e50fc4290--- /dev/null+++ b/.github/workflows/sync-freshness-gate.yml@@ -0,0 +1,58 @@+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).+# 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 committed+# baseline (scripts/bench/sync-freshness-baseline.json) + 25%. The baseline is valid only+# on this runner class (Ubicloud standard-4). Nightly and on dispatch; never in the PR tier.++on:+ schedule:+ - cron: '29 9 * * *'+ workflow_dispatch:++permissions:+ contents: read++concurrency:+ group: ${{ github.workflow }}-${{ github.ref }}+ cancel-in-progress: false++jobs:+ gate:+ name: Sync freshness gate (10k, watch, p50 of 10 vs baseline +25%)+ runs-on: ubicloud-standard-4-ubuntu-2404+ timeout-minutes: 60+ steps:+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2+ with:+ bun-version: 1.4.3+ - name: Install dependencies (bounded, retried once)+ timeout-minutes: 8+ run: bun scripts/ci-bun-install.ts --frozen-lockfile --ignore-scripts+ - name: Run the gate (builds 10k-page brains, then 11 reps per cell)+ timeout-minutes: 45+ run: |+ set -o pipefail+ git config --global user.name "Bench Example"+ git config --global user.email [email protected]+ bun scripts/bench/sync-freshness-gate.ts --work-dir .context/bench/sync-freshness-gate --out .context/bench/sync-freshness-gate/run.json \+ | tee -a "$GITHUB_STEP_SUMMARY"+ - name: Stop harness containers and processes+ if: always()+ run: |+ pkill -9 -f 'src/cli\.ts serve' || true+ docker rm -f gbrain-bench-pg gbrain-bench-toxiproxy >/dev/null 2>&1 || true+ - name: Upload the per-cell results and logs+ if: always()+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02+ with:+ name: sync-freshness-gate+ path: |+ .context/bench/sync-freshness-gate/run.json+ .context/bench/sync-freshness-gate/results+ include-hidden-files: true+ if-no-files-found: warndiff --git a/docs/TESTING.md b/docs/TESTING.mdindex 26d7df9ab1..4d5579b7e6 100644--- a/docs/TESTING.md+++ b/docs/TESTING.md@@ -302,6 +302,22 @@ 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/scripts/bench/sync-freshness-baseline.json b/scripts/bench/sync-freshness-baseline.jsonnew file mode 100644index 0000000000..c1b9ce1222--- /dev/null+++ b/scripts/bench/sync-freshness-baseline.json@@ -0,0 +1,24 @@+{+ "schema": "gbrain-sync-freshness-baseline/1",+ "machine_class": "ubicloud-standard-4",+ "measured_at": "2026-10-19",+ "machine": {+ "cores": 4,+ "ram_gb": 15,+ "bun": "1.4.3",+ "image": "ubuntu-noble (Ubicloud standard-4 VM)"+ },+ "source": "first of 25 stress runs (vm1, run 1) on gbra133-pr2b-bench@61d0789e, product revision 4ba4c36f; the other 24 runs all passed against it",+ "margin": 1.25,+ "cells": {+ "postgres-managed-serve-watch": {+ "p50_ms": 452.1+ },+ "pglite-managed-serve-watch": {+ "p50_ms": 442.1+ },+ "postgres-classic-serve-watch": {+ "p50_ms": 401.4+ }+ }+}diff --git a/scripts/bench/sync-freshness-gate.ts b/scripts/bench/sync-freshness-gate.tsindex ecfd4b0b58..5596937a8f 100644--- a/scripts/bench/sync-freshness-gate.ts+++ b/scripts/bench/sync-freshness-gate.ts@@ -9,6 +9,10 @@* gate value is the p50 of commit -> keyword-visible over reps 1..10. A cell fails when that p50 exceeds the committed* baseline p50 by more than 25%, or when any counted rep never became visible. A baseline is valid only on the machine* class it names (machine_class); --write-baseline records this run as the baseline instead of comparing.+ *+ * Only cells measured stable are gated: 25 runs on 5 fresh Ubicloud standard-4 VMs (the CI runner class) put every+ * serve-watch cell's p50 within a max/min ratio of 1.18, with no false failure in any of 600 baseline/candidate run+ * pairs at +25%. A manual managed sync was left out: its p50 moves with the VM (852 to 1254 ms, 52 of 600 pairs failed).*/import { join, resolve } from 'node:path';import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';@@ -24,7 +28,6 @@ const CELLS: Record<string, string[]> = {'postgres-managed-serve-watch': ['--engine', 'postgres', '--mode', 'managed', '--commit', 'single', '--trigger', 'serve', '--detection', 'watch'],'pglite-managed-serve-watch': ['--engine', 'pglite', '--mode', 'managed', '--commit', 'single', '--trigger', 'serve', '--detection', 'watch'],'postgres-classic-serve-watch': ['--engine', 'postgres', '--mode', 'classic', '--commit', 'single', '--trigger', 'serve', '--detection', 'watch'],- 'postgres-managed-manual': ['--engine', 'postgres', '--mode', 'managed', '--commit', 'single', '--trigger', 'manual'],};const names = flag('cells', Object.keys(CELLS).join(',')).split(',').filter(Boolean);for (const n of names) if (!CELLS[n]) { console.error('unknown cell ' + n + '; known: ' + Object.keys(CELLS).join(', ')); process.exit(2); }