Files
gstack/test/helpers/fake-impeccable.ts
T
garrytan a06d22e52a fix(review): pass Review Army checklists by path, run research alongside dispatch, always probe the design detector; state review-log invocation and statuses in the caller fixture
- review-army-perf-n-plus-one: the parent copied full checklists into agent
  prompts and ran web research before dispatch (290 s on a 12-line diff); 212 s now.
- review-design-lite: 5 of 6 captured trials reported the detector absent
  without probing; the probe is mandatory and its first line is reported, and
  the contract credits only fake-engine rule ids the checklist never names.
- review-exploratory-small-cli: the fixture never gave review-log's direct
  invocation or status vocabulary; the model ran it through bun and wrote
  status "blocked". The prompt states both and the validator rejects
  out-of-vocabulary review statuses.
Each case passed a focused paid run after repair.
2026-09-29 22:49:12 +00:00

32 lines
1.6 KiB
TypeScript

/**
* Install test/fixtures/fake-impeccable.ts as an executable `impeccable` in a
* fresh temp dir OUTSIDE any repo (the wrapper refuses an in-repo IMPECCABLE_BIN
* by design). Shared by the unit and E2E suites so the shim is set up one way.
*/
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
export const IMPECCABLE_FAKE_SRC = path.join(import.meta.dir, '..', 'fixtures', 'fake-impeccable.ts');
export const DETECT_SAMPLE = path.join(import.meta.dir, '..', 'fixtures', 'impeccable-detect-sample.json');
export function installFakeImpeccable(prefix = 'gstack-fake-impeccable-'): { dir: string; bin: string } {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
const bin = path.join(dir, 'impeccable');
fs.copyFileSync(IMPECCABLE_FAKE_SRC, bin);
fs.chmodSync(bin, 0o755);
fs.copyFileSync(DETECT_SAMPLE, path.join(dir, 'impeccable-detect-sample.json')); // the shim's documented default output, beside it
return { dir, bin };
}
/** Sample rule ids the design checklist never names: a review can carry them only from the detector's rows. */
export function detectorOnlyRuleIds(checklist: string): string[] {
const rules = JSON.parse(fs.readFileSync(DETECT_SAMPLE, 'utf-8')) as Array<{ antipattern: string }>;
return [...new Set(rules.map(rule => rule.antipattern))].filter(id => !checklist.includes(id));
}
export function carriesDetectorRows(review: string, checklist: string): boolean {
const text = review.toLowerCase();
return detectorOnlyRuleIds(checklist).some(id => new RegExp(`(?<![\\w-])${id}(?![\\w-])`).test(text));
}