Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix: pre-landing review fixes
garrytan739a60f7ca44
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1489995c61..2d3b537677 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,7 +16,7 @@ identifiers and attribution are available in the pre-removal Git revision### Itemized changes-- New `scripts/stable-daily.ts` and `.github/workflows/stable-daily.yml`: the reason (a released `stable:important` fix stable lacks, or the 7-day weekly floor), the candidate (newest release on master newer than stable with a successful full soak of its exact tree, both default cells for at least 2 hours on the 600,000-page fixture with privacy probes run, and `privacy_leaks`, `read_errors`, `version_skew`, `residents_alive` and `session_refusals` passing in every cell; on the important-only path it must contain the fix), one soak dispatch when nothing qualifies (never while a soak runs, never twice on one tree), the rollback pause and the kill switch. A manual dispatch defaults to a dry run, and `dry_run=false` needs an admin or maintainer before it writes anything.+- New `scripts/stable-daily.ts` and `.github/workflows/stable-daily.yml`: the reason (a released `stable:important` fix stable lacks, or the 7-day weekly floor), the candidate (newest release on master newer than stable with a successful full soak of its exact tree, both default cells for at least 2 hours on the requested 600,000-page fixture with privacy probes run and none erroring, and `privacy_leaks`, `read_errors`, `version_skew`, `residents_alive` and `session_refusals` passing in every cell; on the important-only path it must contain the fix), one soak dispatch when nothing qualifies (never while a soak runs, never after a soak on a newer release failed to qualify, with a warning once stable is past the weekly floor), the rollback pause and the kill switch. A manual dispatch defaults to a dry run, and `dry_run=false` needs an admin or maintainer before it writes anything.- `scripts/promote-stable.ts`: `scheduleAuthorized()` lets only a schedule event of `stable-daily.yml` on the default branch promote without the admin or maintain role; every other check is unchanged, and the record's `promoted_by` names the schedule. Manual dispatches keep the maintainer check.- `docs/RELEASING.md#daily-stable-check` documents the label, the schedule, the kill switch and the rollback.- `test/scripts/stable-daily.test.ts` covers the authorization, the integrity gates, each reason and no-op path, the soak dispatch rules, the dry run and the workflow shape.diff --git a/docs/RELEASING.md b/docs/RELEASING.mdindex a6d4252864..12c17aa528 100644--- a/docs/RELEASING.md+++ b/docs/RELEASING.md@@ -662,14 +662,15 @@ and keeps stable between one day and one week behind what matters:`read_errors`, `version_skew`, `residents_alive`, `session_refusals`)passing in every cell; the latency gates stay record-only. The soak must bethe full default one: both the 65 ms and 2 ms cells, at least 2 hours each,- on the 600,000-page fixture, with privacy probes run, so a smaller smoke- dispatch never qualifies. On the important-only path the candidate must contain the fix.+ on the requested 600,000-page fixture, with privacy probes run and none+ erroring, so a smaller smoke dispatch never qualifies. On the important-only path the candidate must contain the fix.It is promoted through the same `promote()` as a manual promotion, so everycheck above still applies and the record's `promoted_by` is`schedule (.github/workflows/stable-daily.yml)` with the reason in `reason`.With no qualifying soak it dispatches one soak on the newest release's tag- (never while another soak runs, and never again on a tree that already had- one), and a later run promotes it.+ (never while another soak runs, and never after a soak on any newer release+ failed to qualify: then a maintainer decides, and the check warns once stable+ is past the weekly floor), and a later run promotes it.- **Who.** A schedule event runs only the workflow file as merged on thedefault branch, so a scheduled run promotes by rule without a maintainer. Amanual dispatch defaults to `dry_run` (report only); `dry_run=false` needs andiff --git a/scripts/stable-daily.ts b/scripts/stable-daily.tsindex 94ac02b269..10ff682b24 100644--- a/scripts/stable-daily.ts+++ b/scripts/stable-daily.ts@@ -20,8 +20,9 @@* promoted through scripts/promote-stable.ts promote(), so every promotion* check (published release, exact tree, never older) still applies.* 4. Nothing promotable yet: the newest release is soaked (one dispatch of the- * soak on its tag) unless a soak is already running, or one already ran on- * that tree; a failed soak is never retried by the schedule.+ * soak on its tag) unless a soak is already running, or a soak on any newer+ * release did not qualify (a maintainer decides; past the weekly floor it+ * warns); a failed soak is never retried by the schedule.** Docs: docs/RELEASING.md#daily-stable-check*/@@ -45,8 +46,8 @@ const VERSION_RE = /^\d+\.\d+\.\d+(\.\d+)?$/;export interface SoakRunRow { id: number; status: string | null; conclusion: string | null; head_sha: string; html_url: string }export interface Scoreboard {- label?: string; rtt_ms?: number | null; hours?: number | null; elapsed_s?: number | null; privacy?: { probes?: number };- brain?: { fixture?: { pages?: number } } | null;+ label?: string; rtt_ms?: number | null; hours?: number | null; elapsed_s?: number | null; privacy?: { probes?: number; probe_errors?: number };+ brain?: { fixture?: { pages?: number; options?: { pages?: number } } } | null;gates?: Array<{ id: string; pass: boolean | null }>;}@@ -85,14 +86,16 @@ export function integrityFailures(boards: Scoreboard[]): string[] {return failures;}-/** Ways a soak falls short of the full default soak (SOAK_SHAPE): a missing cell, a short run, a small fixture, no privacy probes. */+/** Ways a soak falls short of the full default soak (SOAK_SHAPE): a missing cell, a short run, a small requested fixture, no clean privacy probes. */export function shapeFailures(boards: Scoreboard[]): string[] {const failures = SOAK_SHAPE.rtts.filter(rtt => !boards.some(b => b.rtt_ms === rtt)).map(rtt => `no ${rtt} ms cell`);for (const b of boards) {const cell = b.label ?? 'cell';if ((b.hours ?? 0) < SOAK_SHAPE.hours || (b.elapsed_s ?? 0) < SOAK_SHAPE.hours * 3600) failures.push(`${cell}: ran ${b.elapsed_s ?? 0} s of a ${SOAK_SHAPE.hours} h soak`);- if ((b.brain?.fixture?.pages ?? 0) < SOAK_SHAPE.pages) failures.push(`${cell}: ${b.brain?.fixture?.pages ?? 0} fixture pages, under ${SOAK_SHAPE.pages}`);+ const requested = b.brain?.fixture?.options?.pages ?? 0;+ if (requested < SOAK_SHAPE.pages) failures.push(`${cell}: a ${requested}-page fixture, under ${SOAK_SHAPE.pages}`);if (!((b.privacy?.probes ?? 0) > 0)) failures.push(`${cell}: no privacy probes ran`);+ if (b.privacy?.probe_errors !== 0) failures.push(`${cell}: ${b.privacy?.probe_errors ?? 'unknown'} privacy probe errors`);}return failures;}@@ -168,10 +171,12 @@ export async function daily(deps: DailyDeps): Promise<DailyResult> {if (tree) runsByTree.set(tree, [...(runsByTree.get(tree) ?? []), run]);}const oldestImportant = important.reduce<string | null>((v, i) => (!v || compareVersions(i.version, v) < 0 ? i.version : v), null);+ let failedSoak: { version: string; run: SoakRunRow } | null = null;for (const rel of releases) {if (!weekly && oldestImportant && compareVersions(rel.version, oldestImportant) < 0) break;const tree = await treeOf(deps, rel.commit);- const passed = (runsByTree.get(tree ?? '') ?? []).filter(r => r.status === 'completed' && r.conclusion === 'success');+ const completed = (runsByTree.get(tree ?? '') ?? []).filter(r => r.status === 'completed');+ const passed = completed.filter(r => r.conclusion === 'success');let chosen: SoakRunRow | null = null;for (const run of passed) {const boards = await deps.scoreboards(run.id);@@ -179,19 +184,18 @@ export async function daily(deps: DailyDeps): Promise<DailyResult> {if (failures.length === 0) { chosen = run; break; }deps.log(`[stable-daily] not promotable: v${rel.version} soak ${run.html_url}: ${failures.join(', ')}.`);}- if (!chosen) continue;+ if (!chosen) { failedSoak ??= completed[0] ? { version: rel.version, run: completed[0] } : null; continue; }if (deps.dryRun) return { action: 'dry_run', why: reason, would: `promote v${rel.version} on soak ${chosen.html_url}` };const promotion = await promote(deps, { version: rel.version, soakRunUrl: chosen.html_url, scoreboardUrl: '', rollback: false, reason: `scheduled daily check; ${reason}` });return { action: 'promoted', why: reason, promotion };}const newest = releases[0]!;- const newestTree = await treeOf(deps, newest.commit);const active = runs.find(r => r.status !== 'completed');if (active) return { action: 'waiting', why: `${reason}; soak ${active.html_url} is still running.`, version: newest.version };- const ranOnNewest = runsByTree.get(newestTree ?? '') ?? [];- if (ranOnNewest.length > 0) {- return { action: 'waiting', why: `${reason}; v${newest.version} already had a soak (${ranOnNewest[0]!.html_url}, ${ranOnNewest[0]!.conclusion}) that did not qualify, so a maintainer decides.`, version: newest.version };+ if (failedSoak) {+ if (weekly) deps.log(`::warning::Daily stable check: stable v${current.version} is past the ${WEEKLY_FLOOR_DAYS}-day floor and no soak qualifies; a maintainer decides. Docs: docs/RELEASING.md#daily-stable-check`);+ return { action: 'waiting', why: `${reason}; v${failedSoak.version} already had a soak (${failedSoak.run.html_url}, ${failedSoak.run.conclusion}) that did not qualify, so no new soak is dispatched and a maintainer decides.`, version: newest.version };}if (deps.dryRun) return { action: 'dry_run', why: reason, would: `dispatch the soak on v${newest.version}` };await deps.ghPost(`repos/${deps.repo}/actions/workflows/${soakPath.split('/').at(-1)}/dispatches`, { ref: `v${newest.version}` });diff --git a/test/scripts/stable-daily.test.ts b/test/scripts/stable-daily.test.tsindex 78185a1522..a8dbd54fbe 100644--- a/test/scripts/stable-daily.test.ts+++ b/test/scripts/stable-daily.test.ts@@ -25,7 +25,8 @@ const NOW = new Date('2026-11-10T13:17:00Z');const sha = (n: number) => String(n).padStart(40, 'c');const tree = (n: number) => String(n).padStart(40, 'e');const CLEAN: Scoreboard[] = [2, 65].map(rtt => ({- label: `rtt${rtt}`, rtt_ms: rtt, hours: 2, elapsed_s: 7204, privacy: { probes: 40 }, brain: { fixture: { pages: 600_000 } },+ label: `rtt${rtt}`, rtt_ms: rtt, hours: 2, elapsed_s: 7204, privacy: { probes: 40, probe_errors: 0 },+ brain: { fixture: { pages: 598_561, options: { pages: 600_000 } } },gates: ['privacy_leaks', 'read_errors', 'version_skew', 'residents_alive', 'session_refusals', 'freshness_p95'].map(id => ({ id, pass: id === 'freshness_p95' ? false : true })),}));const ok = (stdout = ''): GitResult => ({ code: 0, stdout: `${stdout}\n`, stderr: '' });@@ -173,12 +174,14 @@ describe('integrity gates', () => {expect(integrityFailures([{ label: 'rtt2', gates: [] }])).toHaveLength(5);});- test('a soak short of the full default shape is not promotable: a missing cell, a short run, a small fixture, no privacy probes', () => {+ test('a soak short of the full default shape is not promotable: a missing cell, a short run, a small requested fixture, no clean privacy probes', () => {expect(shapeFailures(CLEAN)).toEqual([]);- const smoke: Scoreboard[] = [{ ...CLEAN[0]!, hours: 0.01, elapsed_s: 36, privacy: { probes: 0 } }];+ const smoke: Scoreboard[] = [{ ...CLEAN[0]!, hours: 0.01, elapsed_s: 36, privacy: { probes: 0, probe_errors: 0 } }];expect(shapeFailures(smoke)).toEqual(['no 65 ms cell', 'rtt2: ran 36 s of a 2 h soak', 'rtt2: no privacy probes ran']);- const small = CLEAN.map(b => ({ ...b, brain: { fixture: { pages: 2000 } } }));- expect(shapeFailures(small)).toEqual(['rtt2: 2000 fixture pages, under 600000', 'rtt65: 2000 fixture pages, under 600000']);+ const small = CLEAN.map(b => ({ ...b, brain: { fixture: { pages: 1991, options: { pages: 2000 } } } }));+ expect(shapeFailures(small)).toEqual(['rtt2: a 2000-page fixture, under 600000', 'rtt65: a 2000-page fixture, under 600000']);+ const errored = CLEAN.map(b => ({ ...b, privacy: { probes: 40, probe_errors: 40 } }));+ expect(shapeFailures(errored)).toEqual(['rtt2: 40 privacy probe errors', 'rtt65: 40 privacy probe errors']);});test('parseRecord reads the key: value body of a stable tag', () => {@@ -287,6 +290,15 @@ describe('daily: weekly floor', () => {expect(w.logs.some(l => l.includes('no 65 ms cell'))).toBe(true);});+ test('a soak on a newer release that did not qualify stops new soak dispatches, with a warning past the weekly floor', async () => {+ const w = world(base({ stable: old, runs: [soak(9, 3, { conclusion: 'failure' })] }));+ const r = await daily(w.deps);+ expect(r).toMatchObject({ action: 'waiting', version: '1.0.4' });+ expect(r.why).toContain('v1.0.3 already had a soak');+ expect(w.posts).toEqual([]);+ expect(w.logs.some(l => l.startsWith('::warning::') && l.includes('past the 7-day floor'))).toBe(true);+ });+test('a release tag whose commit is not on master is never soaked or promoted by the schedule', async () => {const w = world(base({ stable: old, master: 3, runs: [soak(9, 3), soak(10, 4)] }));const r = await daily(w.deps);