Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
ci-executed-counts: identities carry the backend their test name pins; a PGLite move may change arm
garrytan729a8b0571c4
diff --git a/docs/test-audit/2026-10-04/expected-deltas.tsv b/docs/test-audit/2026-10-04/expected-deltas.tsvindex 4882a5f04d..6f9b083a53 100644--- a/docs/test-audit/2026-10-04/expected-deltas.tsv+++ b/docs/test-audit/2026-10-04/expected-deltas.tsv@@ -22,6 +22,10 @@## A move passes only when the target identity executes in head; a skip row# (planned pass-to-skip) passes only when head reports the test skipped.+# The target keeps the arm, except for a test whose name pins its database+# backend (pglite or postgres, as testBackends() suites name it): a PGLite+# test may move to any arm, including the unit lane's empty one, and a+# PostgreSQL test to another database arm.kind lane file test arm new_lane new_file new_test reason evidenceskip tier2 test/e2e/skills.test.ts * D-1: the baseline runs predate the OPENAI_API_KEY and ANTHROPIC_API_KEY repo secrets (set 2026-10-05), so Tier 2 skipped every skill test there; head runs execute themmove serial test/admin-embed-spawn.serial.test.ts * unit test/admin-embed-spawn.test.ts D6: lint-clean, no process-wide state, 615/615 in one bun process forward and reverse; rejoins the parallel unit lanediff --git a/scripts/ci-executed-counts.ts b/scripts/ci-executed-counts.tsindex 57d8ec552a..398e10f786 100644--- a/scripts/ci-executed-counts.ts+++ b/scripts/ci-executed-counts.ts@@ -5,7 +5,11 @@* Reads the receipts every CI lane writes (scripts/lib/test-env.sh* `receipts_init`: one `<id>.receipt` + `<id>.files` + Bun JUnit report per bun* invocation; verify writes one testcase per check) and accounts for every- * executed test by identity: (lane, file, test name, backend arm).+ * executed test by identity: (lane, file, test name, backend arm). Each+ * identity also carries the database backend its name pins (`testBackend`):+ * a test registered per backend (`testBackends()`) names it, and a move of+ * such a test may change arm, because the backend, not the lane's arm, is+ * what it exercises.** One side (head only) prints the per-lane executed/skipped/failed table and* every completeness problem. Two sides (base and head) also list each base@@ -224,7 +228,7 @@ export function loadReceiptDir(dir: string): Receipt[] {return receipts;}-export interface Identity { lane: string; file: string; test: string; arm: string; status: Status; artifact: string; kind: string }+export interface Identity { lane: string; file: string; test: string; arm: string; backend: TestBackend; status: Status; artifact: string; kind: string }export interface Issue { kind: string; lane?: string; artifact?: string; file?: string; detail: string }export interface LaneStats { lane: string; files: number; executed: number; passed: number; failed: number; skipped: number; superseded: number; declaredEmpty: boolean }export interface Side {@@ -239,6 +243,19 @@ export interface Side {}export const identityKey = (lane: string, file: string, test: string, arm: string) => [lane, file, test, arm].join('\u001f');++/**+ * The database backend a test name pins: `pglite` or `postgres` when the name+ * names exactly one of them as a word (testBackends() suites prefix or suffix+ * it, e.g. "postgres: semantic writes …" or "… (pglite)"), else '' (the name+ * does not say, or names both).+ */+export type TestBackend = 'pglite' | 'postgres' | '';+export function testBackend(test: string): TestBackend {+ const pglite = /\bpglite\b/i.test(test);+ const postgres = /\bpostgres(?:ql)?\b/i.test(test);+ return pglite === postgres ? '' : pglite ? 'pglite' : 'postgres';+}const executed = (status: Status | undefined) => status === 'pass' || status === 'fail';function describeAttempt(r: Receipt): string {@@ -312,7 +329,7 @@ export function buildSide(label: string, all: Receipt[], expectedAttempts = newseen.set(c.test, n);const test = n === 1 ? c.test : `${c.test} [#${n}]`;if (n > 1) duplicateCounts.set(identityKey(lane, file, c.test, winner.arm), n);- side.identities.set(identityKey(lane, file, test, winner.arm), { lane, file, test, arm: winner.arm, status: c.status, artifact: winner.artifact, kind: winner.kind });+ side.identities.set(identityKey(lane, file, test, winner.arm), { lane, file, test, arm: winner.arm, backend: testBackend(c.test), status: c.status, artifact: winner.artifact, kind: winner.kind });}}}@@ -412,6 +429,11 @@ export function deltaRow(kind: DeltaKind, id: Pick<Identity, 'lane' | 'file' | 'export function compare(head: Side, base: Side | undefined, deltas: { rows: DeltaRow[]; errors: string[] }, opts: { failOnAdditions?: boolean } = {}): Comparison {const result: Comparison = { ok: true, base, head, drops: [], additions: [], issues: [...(base?.issues.map(i => ({ ...i, detail: `base: ${i.detail}` })) ?? []), ...head.issues.map(i => ({ ...i, detail: base ? `head: ${i.detail}` : i.detail }))], deltaErrors: deltas.errors, unusedRows: [], suggestions: [] };const used = new Set<DeltaRow>();+ const headAt = new Map<string, Identity[]>();+ for (const h of head.identities.values()) {+ const at = identityKey(h.lane, h.file, h.test, '');+ headAt.set(at, [...(headAt.get(at) ?? []), h]);+ }const sideOf = (detail: string) => (base && detail.startsWith('base: ') ? base : head);result.issues = result.issues.filter(issue => {if (issue.kind !== 'empty-lane') return true;@@ -440,9 +462,9 @@ export function compare(head: Side, base: Side | undefined, deltas: { rows: Deltif (row.kind === 'retire') drop.verdict = 'retired';else if (row.kind === 'skip') drop.verdict = now && !executed(now.status) ? 'skipped' : 'skip-mismatch';else {- const target = identityKey(row.newLane || id.lane, row.newFile || id.file, row.test === '*' ? id.test : row.newTest || id.test, id.arm);- drop.verdict = executed(head.identities.get(target)?.status) ? 'moved' : 'move-target-missing';- if (drop.verdict === 'move-target-missing') drop.detail = `declared move target ${target.split('\u001f').join(' | ')} did not execute in head`;+ const [lane, file, test] = [row.newLane || id.lane, row.newFile || id.file, row.test === '*' ? id.test : row.newTest || id.test];+ drop.verdict = (headAt.get(identityKey(lane, file, test, '')) ?? []).some(h => movedTo(id, h)) ? 'moved' : 'move-target-missing';+ if (drop.verdict === 'move-target-missing') drop.detail = `declared move target ${[lane, file, test, id.arm].join(' | ')} did not execute in head${id.backend ? ` under any arm on the ${id.backend} backend` : ''}`;}} else if (head.lanes.get(id.lane)?.declaredEmpty) {drop.verdict = 'lane-declared-empty';@@ -459,6 +481,18 @@ export function compare(head: Side, base: Side | undefined, deltas: { rows: Deltreturn result;}+/**+ * Whether head identity `to` executes what base identity `from` did: the same+ * arm, or another arm when the test's name pins its backend. The Bun 1.4.3+ * PostgreSQL-arm cell runs only the PostgreSQL side of testBackends() suites,+ * so their PGLite tests leave that lane (arm postgres) for the unit and serial+ * lanes (no arm) and still run on PGLite there. A PostgreSQL test may change+ * arm only to another database arm: a lane with no arm has no database.+ */+const movedTo = (from: Identity, to: Identity) =>+ executed(to.status) && (to.arm === from.arm+ || (from.backend !== '' && to.backend === from.backend && (from.backend === 'pglite' || to.arm !== '')));+/** The exact TSV rows that would declare each undeclared drop: a move when the test runs elsewhere in head, else a retirement. */export function suggestRows(drops: Drop[], base: Side, head: Side): string[] {const rows: string[] = [];@@ -473,7 +507,15 @@ export function suggestRows(drops: Drop[], base: Side, head: Side): string[] {const { lane, file, arm } = group[0].identity;const baseExecuted = [...base.identities.values()].filter(id => id.lane === lane && id.file === file && id.arm === arm && executed(id.status)).length;const headFileRuns = [...head.identities.values()].some(id => id.lane === lane && id.file === file && id.arm === arm && executed(id.status));- const elsewhere = (d: Drop) => (headByTest.get(d.identity.test) ?? []).find(h => h.lane !== lane || h.file !== file);+ const elsewhere = (d: Drop) => (headByTest.get(d.identity.test) ?? []).find(h => (h.lane !== lane || h.file !== file) && movedTo(d.identity, h));+ const backend = group[0].identity.backend;+ const backendBase = [...base.identities.values()].filter(id => id.lane === lane && id.file === file && id.arm === arm && id.backend === backend && executed(id.status)).length;+ const targets = new Set(group.map(d => { const h = elsewhere(d); return h ? `${h.lane}\u001f${h.file}` : ''; }));+ if (backend && group.length > 1 && group.length === backendBase && group.every(d => d.identity.backend === backend) && targets.size === 1 && !targets.has('')) {+ const [newLane, newFile] = [...targets][0]!.split('\u001f');+ rows.push(deltaRow('move', { lane, file, test: '*', arm }, { lane: newLane === lane ? '' : newLane, file: newFile === file ? '' : newFile }));+ continue;+ }if (group.length === baseExecuted && !headFileRuns && group.length > 1) {const votes = new Map<string, number>();for (const d of group) {@@ -545,6 +587,15 @@ export function render(result: Comparison, extra: string[] = []): string {}}out.push('');+ const byBackend = lanes.map(lane => {+ const ids = [...head.identities.values()].filter(id => id.lane === lane && executed(id.status));+ return { lane, pglite: ids.filter(id => id.backend === 'pglite').length, postgres: ids.filter(id => id.backend === 'postgres').length, unnamed: ids.filter(id => !id.backend).length };+ }).filter(b => b.pglite || b.postgres);+ if (byBackend.length) {+ out.push('Head executed by backend (the backend a test name pins; testBackends() suites name it):', '', '| Lane | PGLite | PostgreSQL | Name pins none |', '|---|---:|---:|---:|');+ for (const b of byBackend) out.push(`| ${md(b.lane)} | ${b.pglite} | ${b.postgres} | ${b.unnamed} |`);+ out.push('');+ }out.push(...extra);if (result.issues.length) {out.push(`### Incomplete (${result.issues.length})`, '', 'Why: a lane without a complete receipt cannot prove which tests ran, so the comparison fails closed.', 'Fix: rerun every job of the run (not only failed jobs) so each lane uploads a receipt from one attempt; a killed shard needs its rescue or a rerun.', DOCS, '');diff --git a/test/scripts/ci-executed-counts.test.ts b/test/scripts/ci-executed-counts.test.tsindex 2bd47d555e..3a8551f364 100644--- a/test/scripts/ci-executed-counts.test.ts+++ b/test/scripts/ci-executed-counts.test.ts@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import { spawnSync } from 'node:child_process';import {- buildSide, compare, loadReceiptDir, parseDeltas, parseJUnit, missingKeySkips, canonicalTestName,+ buildSide, compare, loadReceiptDir, parseDeltas, parseJUnit, missingKeySkips, canonicalTestName, render, testBackend,DELTA_COLUMNS, JUnitError,} from '../../scripts/ci-executed-counts.ts';@@ -165,6 +165,48 @@ describe('identity comparison', () => {expect(result.drops.map(d => d.identity.arm)).toEqual(['pgbouncer']);});+ test('each identity carries the backend its test name pins', () => {+ expect(testBackend('pglite: semantic writes > adds')).toBe('pglite');+ expect(testBackend('A-1 managed link extraction (PGLite) > isolates')).toBe('pglite');+ expect(testBackend('postgres: semantic writes > adds')).toBe('postgres');+ expect(testBackend('migrate (postgresql target) > copies')).toBe('postgres');+ expect(testBackend('pglite and postgres agree')).toBe('');+ expect(testBackend('pgliteish postgresify')).toBe('');+ expect(testBackend('math > adds')).toBe('');+ });++ // The Bun 1.4.3 PostgreSQL-arm cell runs only the PostgreSQL side of+ // testBackends() suites (GBRA-135 E1b): their PGLite tests leave the+ // pg-arms lane (arm postgres) and keep running in unit (no arm).+ const ARMS = 'pg-arms-bun-1.4.3';+ const backendCases = (file: string, names: string[]): Case[] => names.map(name => ({ file, name, describe: [] }));+ test('a PGLite test leaving the PostgreSQL-arm lane reads as moved when it runs on PGLite in unit', () => {+ const f = 'test/w.test.ts';+ writeReceipt('base', { artifact: 'receipts-pg-arms-1-bun-1.4.3', id: 'p1', lane: ARMS, shard: 1, of: 1, arm: 'postgres', files: [f], cases: backendCases(f, ['pglite: writes', 'pglite: reads', 'postgres: writes', 'postgres: reads']) });+ writeReceipt('head', { artifact: 'receipts-pg-arms-1-bun-1.4.3', id: 'p1', lane: ARMS, shard: 1, of: 1, arm: 'postgres', files: [f], cases: backendCases(f, ['postgres: writes', 'postgres: reads']) });+ for (const s of ['base', 'head']) writeReceipt(s, { artifact: 'receipts-unit-1', id: 'u1', shard: 1, of: 1, files: [f], cases: backendCases(f, ['pglite: writes', 'pglite: reads']) });+ const undeclared = compare(side('head'), side('base'), noDeltas);+ expect(undeclared.drops.map(d => [d.identity.test, d.identity.backend, d.verdict])).toEqual([['pglite: writes', 'pglite', 'undeclared'], ['pglite: reads', 'pglite', 'undeclared']]);+ const row = ['move', ARMS, f, '*', 'postgres', 'unit', '', '', 'E1b: the PGLite side runs in the unit shards', ''].join('\t');+ expect(undeclared.suggestions).toEqual([row.replace('E1b: the PGLite side runs in the unit shards', 'TODO: why this test no longer runs here')]);+ const declared = compare(side('head'), side('base'), parseDeltas(`${HEADER}\n${row}\n`));+ expect(declared.drops.map(d => d.verdict)).toEqual(['moved', 'moved']);+ expect(declared.ok).toBe(true);+ expect(render(declared)).toContain(`| ${ARMS} | 0 | 2 | 0 |`);+ });++ test('a move that changes arm is refused for a PostgreSQL test and for a test whose name pins no backend', () => {+ const f = 'test/w.test.ts';+ writeReceipt('base', { artifact: 'receipts-pg-arms-1-bun-1.4.3', id: 'p1', lane: ARMS, shard: 1, of: 1, arm: 'postgres', files: [f], cases: backendCases(f, ['postgres: writes', 'engines agree']) });+ writeReceipt('head', { artifact: 'receipts-pg-arms-1-bun-1.4.3', id: 'p1', lane: ARMS, shard: 1, of: 1, arm: 'postgres', files: [f], cases: backendCases(f, ['pglite: writes']) });+ writeReceipt('head', { artifact: 'receipts-unit-1', id: 'u1', shard: 1, of: 1, files: [f], cases: backendCases(f, ['postgres: writes', 'engines agree']) });+ const row = ['move', ARMS, f, '*', 'postgres', 'unit', '', '', 'claimed move', ''].join('\t');+ const result = compare(side('head'), side('base'), parseDeltas(`${HEADER}\n${row}\n`));+ expect(result.drops.map(d => [d.identity.test, d.verdict])).toEqual([['postgres: writes', 'move-target-missing'], ['engines agree', 'move-target-missing']]);+ expect(result.ok).toBe(false);+ expect(compare(side('head'), side('base'), noDeltas).suggestions.every(s => s.startsWith('retire\t'))).toBe(true);+ });+test('a base artifact missing from head fails unless a job row declares it', () => {writeReceipt('base', { artifact: 'receipts-unit-1', id: 'u1', files: ['test/a.test.ts'], cases: [A] });writeReceipt('base', { artifact: 'receipts-slow-eval', id: 'e1', lane: 'slow', files: ['test/e.slow.test.ts'], cases: [{ file: 'test/e.slow.test.ts', name: 'evals' }] });