Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

upgrade matrix: pin every cell to the alpha channel so W1 from-versions upgrade to the candidate

garrytanfaf857b1d648
diff --git a/docs/ci-upgrade-matrix.md b/docs/ci-upgrade-matrix.md
index d71b166dca..da4c674bd2 100644
--- a/docs/ci-upgrade-matrix.md
+++ b/docs/ci-upgrade-matrix.md
@@ -92,6 +92,11 @@ The old release's updater must only ever see the candidate:
objects and holds only the fixture refs (`master`, `latest-stable`,
`stable`, the old tag and `v<candidate version>`), so `git ls-remote`
lists the candidate as the newest release.
+- **Release channel**: every cell process runs with
+ `GBRAIN_RELEASE_CHANNEL=alpha`. The fixture publishes no stable evidence
+ record, so a release that defaults to stable (v0.60.606.0 on) would refuse
+ `stable_invalid` instead of upgrading to the candidate; older releases read
+ no such variable and already follow every release.
- **Bun's tarball fetch**: `GITHUB_API_URL` points at the fixture's loopback
server, which answers `/repos/garrytan/gbrain/tarball/<ref>` with
`git archive` of the ref's commit.
diff --git a/scripts/upgrade-matrix/cell.ts b/scripts/upgrade-matrix/cell.ts
index e8a01c765e..d5f6b53180 100644
--- a/scripts/upgrade-matrix/cell.ts
+++ b/scripts/upgrade-matrix/cell.ts
@@ -41,6 +41,19 @@ export interface CellSpec {
export interface Step { name: string; ok: boolean; ms: number; exit?: number | null; detail?: string; log?: string }
+/**
+ * Every cell process follows the alpha channel (every published release). The fixture publishes the candidate as the
+ * newest release and never a stable evidence record, so a from-version that defaults to stable (v0.60.606.0 on, #8726)
+ * would refuse with stable_invalid instead of upgrading to the build under test. Releases before that read no
+ * GBRAIN_RELEASE_CHANNEL and already follow every release; it outranks self_upgrade.channel on the ones that read it.
+ */
+export const CELL_RELEASE_CHANNEL_ENV: Readonly<Record<string, string>> = { GBRAIN_RELEASE_CHANNEL: 'alpha' };
+
+/** The refs the fixture serves while the old release upgrades: the candidate everywhere, the from-version's own tag kept. */
+export function upgradeRefs(from: { tag: string; sha: string }, candidate: { version: string; sha: string }): Record<string, string> {
+ return { HEAD: candidate.sha, 'latest-stable': candidate.sha, stable: candidate.sha, [from.tag]: from.sha, ['v' + candidate.version]: candidate.sha };
+}
+
export const cellId = (s: { from: { tag: string }; engine: string; keys: string; brain: string }) => [s.from.tag, s.engine, s.keys, s.brain].join('__');
const SEED_WORD = 'zephyrquartz';
@@ -95,6 +108,7 @@ export async function runCell(spec: CellSpec): Promise<Record<string, unknown>>
GIT_CONFIG_GLOBAL: join(dir, 'gitconfig'), GIT_CONFIG_NOSYSTEM: '1',
HTTPS_PROXY: fx.proxyUrl, HTTP_PROXY: fx.proxyUrl, https_proxy: fx.proxyUrl, http_proxy: fx.proxyUrl,
NO_PROXY: '127.0.0.1,localhost', no_proxy: '127.0.0.1,localhost', NODE_EXTRA_CA_CERTS: fx.caFile, GITHUB_API_URL: fx.apiUrl,
+ ...CELL_RELEASE_CHANNEL_ENV,
...(mock ? { VOYAGE_API_KEY: 'pa-upgrade-matrix-mock-not-a-key' } : {}),
};
@@ -195,8 +209,7 @@ export async function runCell(spec: CellSpec): Promise<Record<string, unknown>>
const oldServe = processes.serve!;
// ── 2. the old release's own updater, seeing only the candidate ───────
- const candidateTag = 'v' + spec.candidate.version;
- fx.setRefs({ HEAD: spec.candidate.sha, 'latest-stable': spec.candidate.sha, stable: spec.candidate.sha, [spec.from.tag]: spec.from.sha, [candidateTag]: spec.candidate.sha });
+ fx.setRefs(upgradeRefs(spec.from, spec.candidate));
const switchedAt = fx.requests.length;
let up = await gbrain('upgrade', ['upgrade'], { timeoutMs: 900_000 });
if (up.code === 3 && /restart_refused|--stop-mcp/.test(up.stdout + up.stderr)) {
diff --git a/test/scripts/upgrade-matrix.test.ts b/test/scripts/upgrade-matrix.test.ts
index 7f80788122..e16ec873b9 100644
--- a/test/scripts/upgrade-matrix.test.ts
+++ b/test/scripts/upgrade-matrix.test.ts
@@ -6,12 +6,12 @@
import { describe, expect, test } from 'bun:test';
import { PGlite } from '@electric-sql/pglite';
import { execFileSync } from 'node:child_process';
-import { mkdtempSync, rmSync, unlinkSync, writeFileSync } from 'node:fs';
+import { mkdirSync, mkdtempSync, rmSync, unlinkSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { resolveFromVersions, type Release } from '../../scripts/upgrade-matrix/versions.ts';
import { parseFixturePath, startGithubFixture } from '../../scripts/upgrade-matrix/github-fixture.ts';
-import { compareInstalledTree } from '../../scripts/upgrade-matrix/cell.ts';
+import { CELL_RELEASE_CHANNEL_ENV, compareInstalledTree, upgradeRefs } from '../../scripts/upgrade-matrix/cell.ts';
import { diffCatalog, diffContent, takeSnapshot, type Query } from '../../scripts/upgrade-matrix/snapshot.ts';
import { CHECKS, doctorVerdict, judgeCell, loadKnownExceptions, summarize, validateKnownExceptions, type CellSummary } from '../../scripts/upgrade-matrix/verdict.ts';
import { buildSummary, type Plan } from '../../scripts/upgrade-matrix.ts';
@@ -123,6 +123,36 @@ describe('GitHub fixture', () => {
}
}, 60_000);
+ test('the cell pins the alpha channel, so an updater that defaults to stable upgrades to the candidate instead of refusing stable_invalid', async () => {
+ const src = gitRepo(), work = mkdtempSync(join(tmpdir(), 'um-ch-'));
+ const fx = await startGithubFixture({ source: src.dir, mirrorDir: join(work, 'mirror.git'), archiveDir: join(work, 'archives'), certDir: join(work, 'certs') });
+ try {
+ fx.setRefs(upgradeRefs({ tag: 'v0.0.1', sha: src.first }, { version: '0.0.2', sha: src.second }));
+ const home = join(work, 'home');
+ mkdirSync(join(home, '.gbrain'), { recursive: true });
+ writeFileSync(join(home, '.gbrain', 'config.json'), JSON.stringify({ engine: 'pglite', database_path: join(home, '.gbrain', 'brain.pglite'), self_upgrade: { mode: 'notify', channel: 'stable' } }));
+ writeFileSync(join(work, 'gitconfig'), '[url "' + fx.mirror + '"]\n\tinsteadOf = https://github.com/garrytan/gbrain\n');
+ const dryRun = async (extra: Record<string, string>) => {
+ const p = Bun.spawn([process.execPath, join(import.meta.dir, '..', '..', 'src', 'cli.ts'), 'upgrade', '--dry-run', '--json'], {
+ cwd: home, stdout: 'pipe', stderr: 'pipe',
+ env: { PATH: process.env.PATH ?? '/usr/bin:/bin', HOME: home, GBRAIN_HOME: home, TMPDIR: work, NO_COLOR: '1', GIT_CONFIG_GLOBAL: join(work, 'gitconfig'), GIT_CONFIG_NOSYSTEM: '1',
+ HTTPS_PROXY: fx.proxyUrl, https_proxy: fx.proxyUrl, NO_PROXY: '127.0.0.1,localhost', NODE_EXTRA_CA_CERTS: fx.caFile, GITHUB_API_URL: fx.apiUrl, ...extra },
+ });
+ const [stdout, stderr] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text()]);
+ return { code: await p.exited, out: stdout + stderr };
+ };
+ const unpinned = await dryRun({});
+ expect(unpinned.code).not.toBe(0);
+ expect(unpinned.out).toContain('stable_invalid');
+ const pinned = await dryRun({ ...CELL_RELEASE_CHANNEL_ENV });
+ expect(pinned.code, pinned.out).toBe(0);
+ expect(JSON.parse(pinned.out.slice(pinned.out.indexOf('{'), pinned.out.lastIndexOf('}') + 1))).toMatchObject({ dry_run: true, channel: 'alpha', channel_source: 'env', action: 'install_method_update' });
+ } finally {
+ fx.stop();
+ rmSync(work, { recursive: true, force: true }); rmSync(src.dir, { recursive: true, force: true });
+ }
+ }, 120_000);
+
test('compareInstalledTree finds an installed file that differs from the commit, and one that is missing', () => {
const src = gitRepo(), installed = mkdtempSync(join(tmpdir(), 'um-inst-'));
try {