Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test: fixture case proving later fixes survive the hunk reversal; bot-typed maintainer login never overrides

garrytan5b39b181e859
diff --git a/scripts/contributor-audit-fixture.ts b/scripts/contributor-audit-fixture.ts
index b18c8b0449..fe8c4589aa 100644
--- a/scripts/contributor-audit-fixture.ts
+++ b/scripts/contributor-audit-fixture.ts
@@ -5,13 +5,16 @@
*
* bun scripts/contributor-audit-fixture.ts <empty-dir>
*
- * The range <base>..<head> holds four merges, each a shape the audit must tell
+ * The range <base>..<head> holds six merges, each a shape the audit must tell
* apart, plus one open PR that conflicts with head:
*
* #101 fix clamp product fix + a test that pins it → discriminates
* #102 greet suffix product change + a test that never calls it → does_not_discriminate
* #103 parse ints product change + a test that is red at head → setup_failed
* #104 docs README only → not_audited (no_product_change)
+ * #106 score note a comment + a test that only #107 makes green → does_not_discriminate
+ * (a whole-file revert would also drop #107's fix and call it discriminating)
+ * #107 fix score product fix, no test change → not_audited (no_tests)
* PR #105 rewrites the clamp line #101 fixed → conflict
*
* No package.json, so nothing installs and nothing touches the network.
@@ -22,6 +25,8 @@ import { dirname, join, resolve } from 'node:path';
export interface Fixture { dir: string; base: string; head: string; prsManifest: string }
+const SCORE = '// score helpers\nexport function score(): number {\n const a = 1;\n const b = 1;\n const c = 1;\n const d = 1;\n return 0;\n}\n';
+
export function buildFixture(dir: string): Fixture {
const git = (...args: string[]) => execFileSync('git', args, { cwd: dir, encoding: 'utf8' }).trim();
const write = (rel: string, body: string) => { mkdirSync(dirname(join(dir, rel)), { recursive: true }); writeFileSync(join(dir, rel), body); };
@@ -45,6 +50,7 @@ export function buildFixture(dir: string): Fixture {
write('src/clamp.ts', 'export function clamp(x: number, lo: number, hi: number): number {\n return x;\n}\n');
write('src/greet.ts', 'export function greet(name: string): string {\n return `hello ${name}`;\n}\n');
write('src/parse.ts', 'export function parseInts(s: string): number[] {\n return [];\n}\n');
+ write('src/score.ts', SCORE.replace('// score helpers\n', ''));
commit('base');
const base = git('rev-parse', 'HEAD');
@@ -61,6 +67,11 @@ export function buildFixture(dir: string): Fixture {
write('test/parse.test.ts', "import { expect, test } from 'bun:test';\nimport { parseInts } from '../src/parse';\n\ntest('parses a list', () => {\n expect(parseInts('1,2')).toEqual([1, 2, 3]);\n});\n");
});
mergePr(104, 'docs', 'erin-example', () => write('README.md', '# audit fixture\n\nA tiny repository for the contributor audit.\n'));
+ mergePr(106, 'score-note', 'gina-example', () => {
+ write('src/score.ts', SCORE);
+ write('test/score.test.ts', "import { expect, test } from 'bun:test';\nimport { score } from '../src/score';\n\ntest('scores two', () => {\n expect(score()).toBe(2);\n});\n");
+ });
+ mergePr(107, 'fix-score', 'hana-example', () => write('src/score.ts', SCORE.replace('return 0;', 'return a + b;')));
const head = git('rev-parse', 'HEAD');
git('checkout', '-qb', 'pr-105', base);
diff --git a/test/scripts/contributor-audit.test.ts b/test/scripts/contributor-audit.test.ts
index eb2bc7d832..3c511e591b 100644
--- a/test/scripts/contributor-audit.test.ts
+++ b/test/scripts/contributor-audit.test.ts
@@ -30,7 +30,7 @@ function withFixture(fn: (f: ReturnType<typeof buildFixture>) => void) {
}
describe('contributor audit on the fixture range', () => {
- test('classifies discriminating, non-discriminating, setup-failure, docs-only and conflicting changes', () => {
+ test('classifies discriminating, non-discriminating, setup-failure, docs-only and conflicting changes, keeping later fixes in place', () => {
withFixture(f => {
const r = audit(f.dir, [`${f.base}..${f.head}`, '--prs', f.prsManifest, '--json', '--skip-security', '--skip-lanes']);
expect(r.code, r.stderr).toBe(1);
@@ -44,6 +44,8 @@ describe('contributor audit on the fixture range', () => {
expect(byPr[102].result).toBe('does_not_discriminate');
expect(byPr[103]).toMatchObject({ result: 'setup_failed', reason: 'baseline_red' });
expect(byPr[104]).toMatchObject({ result: 'not_audited', reason: 'no_product_change' });
+ expect(byPr[106]).toMatchObject({ result: 'does_not_discriminate', audited_at: f.head });
+ expect(byPr[107]).toMatchObject({ result: 'not_audited', reason: 'no_tests' });
expect(byPr[105].result).toBe('conflict');
expect(byPr[105].reason).toContain('src/clamp.ts');
expect(report.exit_code).toBe(1);
@@ -54,7 +56,7 @@ describe('contributor audit on the fixture range', () => {
const md = audit(f.dir, [`${f.base}..${f.head}`, '--resume', '--prs', join(report.run_dir, 'prs.pinned.json'), '--skip-security', '--skip-lanes']);
expect(md.code).toBe(1);
- expect(md.stderr).toContain('resuming: 5 case(s) already done');
+ expect(md.stderr).toContain('resuming: 7 case(s) already done');
expect(md.stdout).toContain('| **discriminates** |');
expect(md.stdout).toContain('| Human verdict |');
});
diff --git a/test/scripts/fix-wave-gate.test.ts b/test/scripts/fix-wave-gate.test.ts
index 25bacfe655..883ef41d77 100644
--- a/test/scripts/fix-wave-gate.test.ts
+++ b/test/scripts/fix-wave-gate.test.ts
@@ -69,7 +69,7 @@ describe('fix-wave gate decision', () => {
expect(ok.out).toContain('::notice title=Fix-wave gate override::');
expect(ok.out).toContain(`${OVERRIDE_LABEL} applied by @garrytan (User) at 2026-10-05T01:00:00Z (timeline event 1)`);
- for (const actor of [['capy-ai[bot]', 'Bot'], ['github-actions[bot]', 'Bot'], ['alice-example', 'User'], ['garrytan[bot]', 'User']] as const) {
+ for (const actor of [['capy-ai[bot]', 'Bot'], ['github-actions[bot]', 'Bot'], ['alice-example', 'User'], ['garrytan[bot]', 'User'], ['garrytan', 'Bot']] as const) {
const r = await gate(event, fakeClient([labeled(actor[0], actor[1], 2)]).client);
expect(r.code, actor[0]).toBe(1);
expect(r.summary).toContain('override_not_by_maintainer');