Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(graduation): older-release cases use releases that predate graduation; a graduation-aware binary refuses the lock-gap write
garrytan8a9c914467ed
diff --git a/test/e2e/graduation-clients.test.ts b/test/e2e/graduation-clients.test.tsindex 6ec15a5fe3..0f3c22a209 100644--- a/test/e2e/graduation-clients.test.ts+++ b/test/e2e/graduation-clients.test.ts@@ -174,6 +174,10 @@ describe.skipIf(!DATABASE_URL)('graduation: older released binaries', () => {await waitForEvent(c.events, e => e.event === 'paused', child);child.kill('SIGKILL');await child.exited;+ const aware = await gbrain(['put', 'notes/lock-gap-aware', '--source', 'default', '--json'], { home: c.fx.home, stdin: 'a graduation-aware binary must not write here\n', timeoutMs: 120_000 });+ if (boundary === 'source_closed') {+ expect({ code: aware.code, error: codeOf(aware.json) }).toEqual({ code: 1, error: 'graduation_interrupted' });+ }const write = await olderRun(older[0].binary, c.fx.home, ['put', 'notes/lock-gap-write', '--source', 'default'], 'written by an older release in the lock gap\n');expect({ code: write.code, stderr: write.code === 0 ? '' : write.stderr.slice(-1500) }).toEqual({ code: 0, stderr: '' });const resumed = await gbrain(['migrate', '--resume', '--json'], { home: c.fx.home, timeoutMs: 900_000 });diff --git a/test/helpers/graduation-e2e.ts b/test/helpers/graduation-e2e.tsindex f5ef8798b7..829f521530 100644--- a/test/helpers/graduation-e2e.ts+++ b/test/helpers/graduation-e2e.ts@@ -260,15 +260,29 @@ export function manifestPath(home: string): string {// ── Older released binaries ───────────────────────────────────────────────────/** The last `count` release tags at or below this checkout's VERSION, newest first (from origin). */+/** The first release that knows engine graduation (its intent marker, source row and tombstone). */+export const FIRST_GRADUATION_RELEASE = '0.60.52.0';++/**+ * The newest released tags that predate engine graduation: binaries that know nothing of the+ * marker, the source row or the tombstone. A graduation-aware release refuses where these tests+ * need an unaware writer, so the newest tags at or after FIRST_GRADUATION_RELEASE never qualify.+ */export function previousReleaseTags(count = 2): string[] {- const version = readFileSync(join(REPO, 'VERSION'), 'utf8').trim();+ const version = [readFileSync(join(REPO, 'VERSION'), 'utf8').trim(), FIRST_GRADUATION_RELEASE]+ .sort((a, b) => cmpVersion(a.split('.').map(Number), b.split('.').map(Number)))[0]!;const out = Bun.spawnSync(['git', '-C', REPO, 'ls-remote', '--tags', '--refs', 'origin', 'v*'], { stdout: 'pipe', stderr: 'pipe' });if (out.exitCode !== 0) throw new Error(`git ls-remote failed: ${out.stderr.toString()}`);const parse = (tag: string) => tag.slice(1).split('.').map(Number);const cmp = (a: number[], b: number[]) => { for (let i = 0; i < Math.max(a.length, b.length); i++) { const d = (a[i] ?? 0) - (b[i] ?? 0); if (d) return d; } return 0; };const current = version.split('.').map(Number);return out.stdout.toString().split('\n').map(line => line.split('refs/tags/')[1]).filter((t): t is string => !!t && /^v\d+(\.\d+){3}$/.test(t))- .filter(t => cmp(parse(t), current) <= 0).sort((a, b) => cmp(parse(b), parse(a))).slice(0, count);+ .filter(t => cmp(parse(t), current) < 0).sort((a, b) => cmp(parse(b), parse(a))).slice(0, count);+}++function cmpVersion(a: number[], b: number[]): number {+ for (let i = 0; i < Math.max(a.length, b.length); i++) { const d = (a[i] ?? 0) - (b[i] ?? 0); if (d) return d; }+ return 0;}/**