Files
gstack/test/git-ref-fixture-tripwire.test.ts
Garry TanandClaude Fable 5 d6df2af7dd fix: retire decided A/B experiments; vendor the pre-cut fixture; ban raw-SHA fixtures
Three one-shot decision experiments kept re-running weekly as N=1
stochastic comparisons — flaky by construction with near-zero remaining
information: skill-e2e-auq-repetition-cut-ab (its own header: gate "passed
pre-landing, approved 2026-08-25"), skill-e2e-preamble-script-ab ("demoted
post-Phase-3"), and opus-47's fanout arm-vs-arm (parA >= parB across two
SINGLE stochastic runs — a coin flip). Deleted, with their selection keys;
the SDK overlay-harness stays as the maintained instrument for the next
experiment, and opus-47 keeps its routing-precision cases.

verboseSkill() now reads the VENDORED test/fixtures/auq-pre-cut-...-SKILL.md
instead of `git show ab66193e^:...` — a branch-local ref that dies on
branch prune and already failed on shallow clones. New free tripwire
(test/git-ref-fixture-tripwire.test.ts) bans the raw-SHA fixture class
outright: quoted SHA:path rev-specs and gitRef-style hex defaults in the
test trees fail the suite with the vendor-instead instruction.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-31 05:01:46 +00:00

65 lines
2.9 KiB
TypeScript

/**
* Git-ref fixture tripwire: no test or helper may pin repo content to a raw
* commit SHA (the `git show <sha>:path` fixture pattern).
*
* The class: test/helpers/auq-sdk-capture.ts defaulted verboseSkill() to
* `git show ab66193e^:plan-ceo-review/SKILL.md` — a BRANCH-LOCAL ref. That
* fixture dies the day the branch is pruned, and already failed on shallow
* clones (CI executors fetch-depth-0 exists precisely because self-derived
* selection crashed on shallow checkouts). The v1.75 precedent is to VENDOR
* the frozen content under test/fixtures/ instead — content-addressed by the
* repo itself, immune to ref pruning and clone depth.
*
* Scans test trees + helpers for two shapes:
* - a quoted `<hex>{7,40}[^]?:` rev-path (the `git show SHA:path` form)
* - a gitRef-style default parameter carrying a raw hex SHA
*/
import { describe, expect, test } from 'bun:test';
import * as fs from 'node:fs';
import * as path from 'node:path';
const ROOT = path.resolve(import.meta.dir, '..');
const SCAN_ROOTS = ['test', 'browse/test', 'design/test', 'make-pdf/test'];
const SELF = path.join('test', 'git-ref-fixture-tripwire.test.ts');
// Quoted `SHA:` rev-path (7-40 hex chars, optional ^/~ suffix, then colon) —
// requires >= 2 digits among the hex so ordinary words ('deadbeef' aside)
// and pure-alpha identifiers don't false-positive.
const REV_PATH = /['"`]([0-9a-f]{7,40})[\^~]?:/g;
const GIT_REF_DEFAULT = /gitRef\s*=\s*['"`][0-9a-f]{7,40}/;
const looksLikeSha = (s: string): boolean => /[0-9]/.test(s) && /[a-f]/.test(s);
describe('git-ref fixture tripwire', () => {
test('no raw-SHA fixture refs in the test trees (vendor the content instead)', () => {
const hits: string[] = [];
for (const root of SCAN_ROOTS) {
const abs = path.join(ROOT, root);
if (!fs.existsSync(abs)) continue;
const stack = [abs];
while (stack.length > 0) {
const dir = stack.pop()!;
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
const full = path.join(dir, entry.name);
if (entry.isDirectory()) { stack.push(full); continue; }
if (!/\.(?:[cm]?[jt]s|tsx)$/.test(entry.name)) continue;
const rel = path.relative(ROOT, full);
if (rel === SELF) continue;
const src = fs.readFileSync(full, 'utf-8');
src.split('\n').forEach((line, i) => {
for (const m of line.matchAll(REV_PATH)) {
if (looksLikeSha(m[1])) hits.push(`${rel}:${i + 1} ${line.trim().slice(0, 100)}`);
}
if (GIT_REF_DEFAULT.test(line)) hits.push(`${rel}:${i + 1} ${line.trim().slice(0, 100)}`);
});
}
}
}
expect(
hits,
`raw-SHA fixture reference(s) — these die on branch prune and fail on shallow clones. `
+ `Vendor the frozen content under test/fixtures/ instead (v1.75 precedent):\n ${hits.join('\n ')}`,
).toEqual([]);
});
});