Files
pbakaus_impeccable/tests/oracle.test.mjs
T
Paul Bakaus b6a34de55a Tests: gate behavior on the oracle and the engine binary
Unit tests of the deleted Node scripts and the JS detector are removed;
their behavior is pinned by tests/oracle goldens (frozen JS behavior plus
reviewed deltas) and the engine's own tests. tests/oracle.test.mjs replays
the corpus against the binary (IMPECCABLE_BIN or skill/scripts/bin/<target>/,
via tests/lib/engine-bin.mjs) and skips cleanly without one; the framework
fixture sweep drives live-inject, live-wrap, and detect-csp through the
binary the same way. record.mjs learns --bin. The function-level vectors
under tests/oracle/vectors/calls are committed as the frozen snapshot they
can no longer be regenerated from. Suites: core trimmed to build and
transformer tests, oracle added to the default run, detector/live reduced to
packaging and reference checks, the live-e2e helper tests move to the opt-in
live-e2e lane pending its retarget, cli-remote-e2e is an empty placeholder.

Prepared with AI assistance (Claude Code).
2026-08-31 19:59:20 -07:00

42 lines
1.8 KiB
JavaScript

/**
* Behavior gate: replays the oracle corpus (tests/oracle) against the engine
* binary and asserts no case differs from its golden beyond the reviewed
* deltas in tests/oracle/DELTAS.md.
*
* Skips cleanly when no binary is available: set IMPECCABLE_BIN or run
* `bun run fetch:engine` (which writes skill/scripts/bin/<os>-<arch>/).
*
* Run with: node --test tests/oracle.test.mjs
* Scope: IMPECCABLE_ORACLE_PREFIX=detect- node --test tests/oracle.test.mjs
*/
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { ENGINE_MISSING_MESSAGE, findEngineBinary } from './lib/engine-bin.mjs';
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const ENGINE_BIN = findEngineBinary();
describe('oracle corpus against the engine binary', { skip: ENGINE_BIN ? false : ENGINE_MISSING_MESSAGE }, () => {
it('replays every recorded case with zero unreviewed differences', () => {
const args = [path.join(REPO_ROOT, 'tests', 'oracle', 'run.mjs')];
if (process.env.IMPECCABLE_ORACLE_PREFIX) args.push(process.env.IMPECCABLE_ORACLE_PREFIX);
const result = spawnSync(process.execPath, args, {
cwd: REPO_ROOT,
encoding: 'utf-8',
env: { ...process.env, IMPECCABLE_BIN: ENGINE_BIN },
maxBuffer: 64 * 1024 * 1024,
});
const summary = (result.stdout || '').trim().split('\n').pop();
const failures = (result.stdout || '').split('\n').filter((line) => line.startsWith('XX ') || line.startsWith('?? '));
assert.equal(
result.status,
0,
`oracle run exited ${result.status}: ${summary}\n${failures.slice(0, 40).join('\n')}\n${(result.stderr || '').slice(-4000)}`,
);
});
});