skillfit 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -119
- package/README.zh-CN.md +60 -116
- package/dist/commands/bench-check-report.js +1 -34
- package/dist/commands/bench.js +6 -239
- package/dist/commands/eval-preflight-error.js +9 -0
- package/dist/commands/eval-preflight.js +4 -11
- package/dist/commands/eval-report.js +6 -459
- package/dist/commands/install.js +14 -98
- package/dist/harness/bench-check.js +277 -0
- package/dist/harness/bench-diagnostics.js +34 -0
- package/dist/harness/eval-acceptance.js +1 -1
- package/dist/harness/eval-audit.js +1 -1
- package/dist/harness/eval-manifest.js +456 -0
- package/dist/install/constants.js +1 -0
- package/dist/install/transaction.js +112 -0
- package/docs/README.md +65 -0
- package/docs/architecture.md +86 -0
- package/docs/archive-delivery.md +83 -0
- package/docs/archive-inventory.md +91 -0
- package/docs/evaluation-reports.md +1 -1
- package/docs/first-real-eval.md +12 -10
- package/docs/growth-roadmap-2026-10.md +17 -18
- package/docs/package-contents.md +80 -0
- package/docs/plans/2026-10-20-archive-replay-verification.json +125 -0
- package/docs/plans/2026-10-20-archive-source-verification.json +256 -0
- package/docs/plans/2026-10-20-delivery-verification.json +146 -0
- package/docs/plans/2026-10-20-docs-architecture-cleanup.md +233 -0
- package/docs/plans/2026-10-20-install-transactions-and-archive-delivery.md +233 -0
- package/docs/plans/2026-10-21-npm-0.13.0-release.md +74 -0
- package/docs/plans/2026-10-21-npm-0.13.1-release.md +38 -0
- package/docs/releases/0.12.0-attestation-check.json +22 -0
- package/docs/releases/0.12.0-attestations.json +155 -0
- package/docs/releases/0.12.0-ci-registry-install.json +90 -0
- package/docs/releases/0.12.0-feature-smoke.json +34 -0
- package/docs/releases/0.12.0-foundations-smoke.json +1576 -0
- package/docs/releases/0.12.0-local-registry-install.json +75 -0
- package/docs/releases/0.12.0-preparation-attempt-1.json +22 -0
- package/docs/releases/0.12.0-registry-metadata.json +96 -0
- package/docs/releases/0.12.0-signatures.txt +6 -0
- package/docs/releases/0.12.0-verification.json +99 -0
- package/docs/releases/0.12.0.md +14 -0
- package/docs/releases/0.13.0-archive-replays.json +266 -0
- package/docs/releases/0.13.0-archive-restoration.json +168 -0
- package/docs/releases/0.13.0-attestation-check.json +22 -0
- package/docs/releases/0.13.0-attestations.json +147 -0
- package/docs/releases/0.13.0-ci-registry-install.json +60 -0
- package/docs/releases/0.13.0-feature-smoke.json +41 -0
- package/docs/releases/0.13.0-feature-smoke.mjs +114 -0
- package/docs/releases/0.13.0-foundations-smoke.json +1576 -0
- package/docs/releases/0.13.0-local-registry-install.json +40 -0
- package/docs/releases/0.13.0-preparation.json +102 -0
- package/docs/releases/0.13.0-preview-review.json +16 -0
- package/docs/releases/0.13.0-registry-metadata.json +92 -0
- package/docs/releases/0.13.0-signatures.txt +12 -0
- package/docs/releases/0.13.0-verification.json +136 -0
- package/docs/releases/0.13.0.md +112 -0
- package/docs/releases/0.13.1-feature-smoke.mjs +116 -0
- package/docs/releases/0.13.1-preparation-failure-1.json +25 -0
- package/docs/releases/0.13.1-preparation.json +149 -0
- package/docs/releases/0.13.1.md +62 -0
- package/docs/releases/archive-delivery-smoke.mjs +37 -0
- package/docs/releases/release-docs-smoke.mjs +37 -0
- package/docs/reproducible-offline-example.md +1 -1
- package/evidence/README.md +24 -1
- package/evidence/archive-catalog.v1.json +8044 -0
- package/evidence/fetch-archives.mjs +211 -0
- package/package.json +9 -2
- package/skills/skillfit/SKILL.md +20 -6
- package/dist/cli.test.js +0 -193
- package/dist/commands/bench-calibration.test.js +0 -237
- package/dist/commands/bench-check-json.test.js +0 -242
- package/dist/commands/bench-manage.test.js +0 -87
- package/dist/commands/bench.test.js +0 -1166
- package/dist/commands/bundle.test.js +0 -142
- package/dist/commands/calibration-cli.test.js +0 -145
- package/dist/commands/doctor.test.js +0 -280
- package/dist/commands/eval-agent-preflight.test.js +0 -269
- package/dist/commands/eval-cli-usage.test.js +0 -75
- package/dist/commands/eval-export-modes.test.js +0 -350
- package/dist/commands/eval-export.test.js +0 -279
- package/dist/commands/eval-interruption.test.js +0 -263
- package/dist/commands/eval-preflight.test.js +0 -382
- package/dist/commands/eval-report.test.js +0 -367
- package/dist/commands/eval.test.js +0 -503
- package/dist/commands/evaluation-report.test.js +0 -243
- package/dist/commands/install.test.js +0 -555
- package/dist/commands/npm-first-run.test.js +0 -74
- package/dist/commands/replay-cancellation.test.js +0 -105
- package/dist/commands/report.test.js +0 -110
- package/dist/commands/setup.test.js +0 -150
- package/dist/commands/upstream.test.js +0 -139
- package/dist/commands/workflow-entrypoints.test.js +0 -137
- package/dist/docs.test.js +0 -154
- package/dist/frontmatter.test.js +0 -49
- package/dist/harness/bench.test.js +0 -109
- package/dist/harness/bundle.test.js +0 -71
- package/dist/harness/codex-usage.test.js +0 -87
- package/dist/harness/costs.test.js +0 -92
- package/dist/harness/eval-budget.test.js +0 -237
- package/dist/harness/eval-component.test.js +0 -770
- package/dist/harness/eval-efficiency.test.js +0 -56
- package/dist/harness/execution-timing.test.js +0 -61
- package/dist/harness/executors/api.test.js +0 -175
- package/dist/harness/executors/cli.test.js +0 -541
- package/dist/harness/executors/mock.test.js +0 -43
- package/dist/harness/experiment-session.test.js +0 -317
- package/dist/harness/installed-skill.test.js +0 -162
- package/dist/harness/interruption.test.js +0 -31
- package/dist/harness/judge-accounting.test.js +0 -216
- package/dist/harness/judge.test.js +0 -181
- package/dist/harness/kimi-usage.test.js +0 -62
- package/dist/harness/native-diff.test.js +0 -53
- package/dist/harness/oss-lru-cache.test.js +0 -79
- package/dist/harness/oss-normalize-url.test.js +0 -64
- package/dist/harness/oss-regression-witness.test.js +0 -89
- package/dist/harness/oss-skill-followup.test.js +0 -59
- package/dist/harness/prompt.test.js +0 -48
- package/dist/harness/receipts.test.js +0 -148
- package/dist/harness/report.test.js +0 -297
- package/dist/harness/runner.test.js +0 -635
- package/dist/harness/skill-revision.test.js +0 -148
- package/dist/harness/stats.test.js +0 -124
- package/dist/harness/target.test.js +0 -60
- package/dist/harness/trigger.test.js +0 -261
- package/dist/harness/verifier-summary.test.js +0 -99
- package/dist/harness/verifier.test.js +0 -128
- package/dist/harness/waza-behavior.test.js +0 -139
- package/dist/mcp/probe.test.js +0 -139
- package/evidence/artifacts/2026-10-12-diagnosing-revision/calibration-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-diagnosing-revision/interrupted-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-diagnosing-revision/validation-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-diagnosing-v2/regression-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-diagnosing-v2/transfer-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-normalize-url-v2-available/readiness-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-normalize-url-v2-comparison/records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-normalize-url-v2-recovery/records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-normalize-url-v2-validated/records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-13-debugging-completed-development/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-13-debugging-controls-and-sleep-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-13-debugging-development-stops/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-14-debugging-followup-routing-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-14-debugging-independent-validation/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-14-debugging-reading-pilot-and-cost-review/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-14-debugging-spending-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-native-diff-mechanism/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/package.tar.gz +0 -0
|
@@ -1,770 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { tmpdir } from 'node:os';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
|
-
import { test } from 'node:test';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
import { reportEvalComponent, runEvalComponent } from '../commands/eval-component.js';
|
|
9
|
-
import { exportEvaluation } from '../commands/eval-export.js';
|
|
10
|
-
import { runEval } from '../commands/eval.js';
|
|
11
|
-
import { runEvalCli } from '../commands/eval-cli.js';
|
|
12
|
-
import { assessEvaluation } from './eval-acceptance.js';
|
|
13
|
-
import { parseAcceptancePolicy, parseEvalRequest, policyHash } from './eval-contract.js';
|
|
14
|
-
import { hashFileSet, listFilesRecursive, sha256File } from './hash.js';
|
|
15
|
-
import { summarizeCosts } from './costs.js';
|
|
16
|
-
import { ExecutorFailure } from './types.js';
|
|
17
|
-
import { nativeDiffDescriptor, NATIVE_DIFF_PATH } from './native-diff.js';
|
|
18
|
-
const CLI = fileURLToPath(new URL('../cli.js', import.meta.url));
|
|
19
|
-
const ROOT = fileURLToPath(new URL('../..', import.meta.url));
|
|
20
|
-
function setup(t) {
|
|
21
|
-
const root = mkdtempSync(join(tmpdir(), 'skillfit-component-'));
|
|
22
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
23
|
-
for (const [name, answer] of [['old', '1'], ['new', '2']]) {
|
|
24
|
-
mkdirSync(join(root, name));
|
|
25
|
-
writeFileSync(join(root, name, 'SKILL.md'), `---\nname: answer-skill\ndescription: Diagnose local answers.\n---\nAnswer ${answer}.\n`);
|
|
26
|
-
writeFileSync(join(root, name, 'answer.txt'), answer);
|
|
27
|
-
}
|
|
28
|
-
const bench = join(root, 'bench');
|
|
29
|
-
mkdirSync(join(bench, 'fixture'), { recursive: true });
|
|
30
|
-
writeFileSync(join(bench, 'fixture/answer.txt'), 'pending');
|
|
31
|
-
writeFileSync(join(bench, 'prompt.md'), 'Fix answer.txt.');
|
|
32
|
-
for (const [id, expected] of [['fix', '2'], ['regression', '1']])
|
|
33
|
-
writeFileSync(join(bench, id + '.mjs'), `import{readFileSync}from'node:fs';import{join}from'node:path';const pass=readFileSync(join(process.argv[2],'answer.txt'),'utf8')===${JSON.stringify(expected)};console.log(JSON.stringify({passed:pass,checks:[{name:'public answer',pass}]}));process.exit(pass?0:1);\n`);
|
|
34
|
-
writeFileSync(join(bench, 'bench.json'), JSON.stringify({ schemaVersion: 1, name: 'component-outcomes', tasks: ['fix', 'regression'].map(id => ({ id, fixture: 'fixture', prompt: 'prompt.md', verifier: `node ${id}.mjs`, verifierKind: 'command' })) }));
|
|
35
|
-
const body = { schemaVersion: 1, baselineSkill: 'old', candidateSkill: 'new', bench: 'bench', agent: 'codex', purpose: 'validation', trials: 1, maxCalls: 4, runsRoot: 'runs', runGroup: 'component' };
|
|
36
|
-
const requestPath = join(root, 'request.json');
|
|
37
|
-
writeFileSync(requestPath, JSON.stringify(body));
|
|
38
|
-
let calls = 0;
|
|
39
|
-
const executor = { describe: () => ({ kind: 'mock', model: 'offline-component' }), run: async (_prompt, workdir) => {
|
|
40
|
-
calls++;
|
|
41
|
-
const answer = readFileSync(join(workdir, 'project-skills/answer-skill/answer.txt'), 'utf8');
|
|
42
|
-
writeFileSync(join(workdir, 'answer.txt'), answer);
|
|
43
|
-
return { output: 'done', skillTriggered: true, tokens: answer === '1' ? { input: 10, cachedInput: 8, output: 2 } : { input: 8, cachedInput: 2, output: 3 } };
|
|
44
|
-
} };
|
|
45
|
-
const options = { executor, skillInstallDir: 'project-skills' };
|
|
46
|
-
return { root, body, requestPath, executor, options, calls: () => calls, runDir: join(root, 'runs/component') };
|
|
47
|
-
}
|
|
48
|
-
async function run(t) {
|
|
49
|
-
const f = setup(t), preview = await runEvalComponent(f.requestPath, { ...f.options, dryRun: true });
|
|
50
|
-
assert.ok('plan' in preview);
|
|
51
|
-
const result = await runEvalComponent(f.requestPath, { ...f.options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
52
|
-
return { ...f, preview, result };
|
|
53
|
-
}
|
|
54
|
-
test('request taskIds bind preview, native scope and offline assessment without relaxing adoption', async (t) => {
|
|
55
|
-
const f = setup(t);
|
|
56
|
-
writeFileSync(f.requestPath, JSON.stringify({ ...f.body, taskIds: ['fix'], maxCalls: 2 }));
|
|
57
|
-
const preview = await runEvalComponent(f.requestPath, { ...f.options, dryRun: true });
|
|
58
|
-
assert.ok('plan' in preview);
|
|
59
|
-
assert.equal(preview.plan.evaluation.plannedCalls, 2);
|
|
60
|
-
assert.deepEqual(preview.plan.evaluation.bench.taskIds, ['fix']);
|
|
61
|
-
const result = await runEvalComponent(f.requestPath, { ...f.options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
62
|
-
assert.equal(f.calls(), 2);
|
|
63
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
64
|
-
const replay = await reportEvalComponent(f.runDir, { replay: true });
|
|
65
|
-
assert.ok('evidence' in replay && replay.evidence.verified);
|
|
66
|
-
assert.equal(f.calls(), 2);
|
|
67
|
-
});
|
|
68
|
-
test('component exports include the frozen request and both complete Skills and replay without originals', async (t) => {
|
|
69
|
-
const f = await run(t), output = join(f.root, 'portable');
|
|
70
|
-
const originalRequest = readFileSync(f.requestPath, 'utf8');
|
|
71
|
-
writeFileSync(f.requestPath, '{}');
|
|
72
|
-
for (const path of ['bench', 'old', 'new'])
|
|
73
|
-
rmSync(join(f.root, path), { recursive: true });
|
|
74
|
-
const nativeReplay = await reportEvalComponent(f.runDir, { replay: true });
|
|
75
|
-
assert.ok('evidence' in nativeReplay && nativeReplay.evidence.verified);
|
|
76
|
-
await exportEvaluation(f.runDir, output, { yes: true, log: () => { } });
|
|
77
|
-
assert.equal(readFileSync(join(output, 'inputs/request.json'), 'utf8'), originalRequest);
|
|
78
|
-
assert.equal(readFileSync(join(output, 'inputs/baseline-skill/answer.txt'), 'utf8'), '1');
|
|
79
|
-
assert.equal(readFileSync(join(output, 'inputs/target/answer.txt'), 'utf8'), '2');
|
|
80
|
-
rmSync(join(f.root, 'runs'), { recursive: true });
|
|
81
|
-
const child = spawnSync(process.execPath, [join(output, 'reproduce.mjs')], { encoding: 'utf8', timeout: 30_000 });
|
|
82
|
-
assert.equal(child.status, 0, child.stderr);
|
|
83
|
-
const replay = JSON.parse(child.stdout);
|
|
84
|
-
assert.equal(replay.evidence.verified, true);
|
|
85
|
-
assert.deepEqual(replay.costs, 'costs' in f.result ? f.result.costs : null);
|
|
86
|
-
assert.equal(replay.acceptance.decision, 'reject');
|
|
87
|
-
assert.equal(f.calls(), 4);
|
|
88
|
-
});
|
|
89
|
-
test('installed component delivers and freezes a working diff tool identically in both arms', async (t) => {
|
|
90
|
-
const f = setup(t), prompts = [];
|
|
91
|
-
const executor = { ...f.executor, run: async (prompt, workdir) => {
|
|
92
|
-
prompts.push(prompt);
|
|
93
|
-
assert.match(prompt, /node _skillfit\/native-diff.cjs/);
|
|
94
|
-
writeFileSync(join(workdir, 'new-regression.mjs'), 'export const retained = true;\n');
|
|
95
|
-
const diff = spawnSync(process.execPath, [join(workdir, NATIVE_DIFF_PATH), 'new-regression.mjs'], { cwd: workdir, encoding: 'utf8' });
|
|
96
|
-
assert.equal(diff.status, 1);
|
|
97
|
-
assert.match(diff.stdout, /\+export const retained/);
|
|
98
|
-
return f.executor.run(prompt, workdir);
|
|
99
|
-
} };
|
|
100
|
-
const options = { ...f.options, executor }, preview = await runEvalComponent(f.requestPath, { ...options, dryRun: true });
|
|
101
|
-
assert.ok('plan' in preview);
|
|
102
|
-
assert.deepEqual(preview.plan.evaluation.nativeDiffTool, nativeDiffDescriptor());
|
|
103
|
-
assert.equal(existsSync(f.runDir), false);
|
|
104
|
-
const result = await runEvalComponent(f.requestPath, { ...options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
105
|
-
assert.equal(result.status, 'completed');
|
|
106
|
-
assert.ok('environment' in result);
|
|
107
|
-
assert.equal(result.evidence.verified, true);
|
|
108
|
-
assert.deepEqual(prompts.slice(0, 2), [prompts[0], prompts[0]]);
|
|
109
|
-
assert.deepEqual(result.environment?.nativeDiffTool, nativeDiffDescriptor());
|
|
110
|
-
const replay = await reportEvalComponent(f.runDir, { replay: true });
|
|
111
|
-
assert.ok('environment' in replay);
|
|
112
|
-
assert.equal(replay.evidence.verified, true);
|
|
113
|
-
assert.deepEqual(replay.costs, result.costs);
|
|
114
|
-
assert.deepEqual(replay.environment?.nativeDiffTool, nativeDiffDescriptor());
|
|
115
|
-
});
|
|
116
|
-
test('helper tampering stops further calls and retains invocation spending', async (t) => {
|
|
117
|
-
const f = setup(t);
|
|
118
|
-
let started = 0;
|
|
119
|
-
const executor = { ...f.executor, run: async (_prompt, workdir) => {
|
|
120
|
-
started++;
|
|
121
|
-
writeFileSync(join(workdir, NATIVE_DIFF_PATH), 'tampered');
|
|
122
|
-
return { output: 'done', tokens: { input: 100, cachedInput: 50, output: 4 } };
|
|
123
|
-
} };
|
|
124
|
-
const options = { ...f.options, executor }, preview = await runEvalComponent(f.requestPath, { ...options, dryRun: true });
|
|
125
|
-
assert.ok('plan' in preview);
|
|
126
|
-
const result = await runEvalComponent(f.requestPath, { ...options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
127
|
-
assert.equal(started, 1);
|
|
128
|
-
assert.equal(result.status, 'stopped');
|
|
129
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
130
|
-
const receipt = JSON.parse(readFileSync(join(f.runDir, 'fix/baseline/trial-1/_result.json'), 'utf8'));
|
|
131
|
-
assert.deepEqual(receipt.tokens, { input: 100, cachedInput: 50, output: 4 });
|
|
132
|
-
assert.match(receipt.error, /native diff tool changed/);
|
|
133
|
-
});
|
|
134
|
-
test('reserved helper fixture collision is rejected before plan writes or calls', async (t) => {
|
|
135
|
-
const f = setup(t);
|
|
136
|
-
mkdirSync(join(f.root, 'bench/fixture/_skillfit'));
|
|
137
|
-
await assert.rejects(runEvalComponent(f.requestPath, { ...f.options, dryRun: true }), /reserved evaluation tool/);
|
|
138
|
-
assert.equal(f.calls(), 0);
|
|
139
|
-
assert.equal(existsSync(f.runDir), false);
|
|
140
|
-
});
|
|
141
|
-
test('component request resolves relative paths, rejects unknown/weak settings and plans without writes', async (t) => {
|
|
142
|
-
const f = setup(t);
|
|
143
|
-
const normalized = parseEvalRequest(f.body, f.root);
|
|
144
|
-
assert.equal(normalized.bench, join(f.root, 'bench'));
|
|
145
|
-
assert.equal(normalized.pairOrder, 'baseline-first');
|
|
146
|
-
assert.throws(() => parseEvalRequest({ ...f.body, pairOrder: 'random' }, f.root), /request.pairOrder/);
|
|
147
|
-
assert.throws(() => parseEvalRequest({ ...f.body, surprise: true }, f.root), /unknown fields/);
|
|
148
|
-
assert.throws(() => parseEvalRequest({ ...f.body, trials: 0 }, f.root), /request.trials/);
|
|
149
|
-
assert.throws(() => parseEvalRequest({ ...f.body, runGroup: '../escape' }, f.root), /runGroup/);
|
|
150
|
-
assert.throws(() => parseAcceptancePolicy({ minTasks: 1 }), /policy.minTasks/);
|
|
151
|
-
assert.throws(() => parseAcceptancePolicy({ minTrialsPerTask: 1 }), /minTrials/);
|
|
152
|
-
const preview = await runEvalComponent(f.requestPath, { ...f.options, dryRun: true });
|
|
153
|
-
assert.equal(preview.status, 'planned');
|
|
154
|
-
assert.equal(f.calls(), 0);
|
|
155
|
-
assert.equal(existsSync(join(f.root, 'runs')), false);
|
|
156
|
-
assert.ok('plan' in preview);
|
|
157
|
-
assert.equal(preview.plan.evaluation.plannedCalls, 4);
|
|
158
|
-
assert.equal(preview.acceptance.eligibleForUpgrade, false);
|
|
159
|
-
});
|
|
160
|
-
test('balanced component execution alternates adjacent first arms and preserves pairing on replay', async (t) => {
|
|
161
|
-
const f = setup(t), observed = [];
|
|
162
|
-
writeFileSync(f.requestPath, JSON.stringify({ ...f.body, trials: 3, maxCalls: 12, pairOrder: 'balanced' }));
|
|
163
|
-
const executor = { ...f.executor, run: async (prompt, workdir) => {
|
|
164
|
-
observed.push(workdir.split(/[\\/]/).slice(-3).join('/'));
|
|
165
|
-
return f.executor.run(prompt, workdir);
|
|
166
|
-
} };
|
|
167
|
-
const options = { ...f.options, executor }, preview = await runEvalComponent(f.requestPath, { ...options, dryRun: true });
|
|
168
|
-
assert.ok('plan' in preview);
|
|
169
|
-
assert.equal(preview.plan.evaluation.pairOrder, 'balanced');
|
|
170
|
-
const result = await runEvalComponent(f.requestPath, { ...options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
171
|
-
assert.equal(result.status, 'completed');
|
|
172
|
-
assert.ok('quality' in result);
|
|
173
|
-
assert.deepEqual(observed, [
|
|
174
|
-
'fix/baseline/trial-1', 'fix/treatment/trial-1',
|
|
175
|
-
'fix/treatment/trial-2', 'fix/baseline/trial-2',
|
|
176
|
-
'fix/baseline/trial-3', 'fix/treatment/trial-3',
|
|
177
|
-
'regression/treatment/trial-1', 'regression/baseline/trial-1',
|
|
178
|
-
'regression/baseline/trial-2', 'regression/treatment/trial-2',
|
|
179
|
-
'regression/treatment/trial-3', 'regression/baseline/trial-3',
|
|
180
|
-
]);
|
|
181
|
-
assert.equal(result.quality.improvedPairs, 3);
|
|
182
|
-
assert.equal(result.quality.regressedPairs, 3);
|
|
183
|
-
assert.equal(result.evidence.verified, true);
|
|
184
|
-
const replay = await reportEvalComponent(f.runDir, { replay: true });
|
|
185
|
-
assert.ok('quality' in replay);
|
|
186
|
-
assert.equal(replay.environment?.pairOrder, 'balanced');
|
|
187
|
-
assert.equal(replay.evidence.verified, true);
|
|
188
|
-
assert.deepEqual(replay.quality, result.quality);
|
|
189
|
-
assert.deepEqual(replay.costs, result.costs);
|
|
190
|
-
});
|
|
191
|
-
test('changing the planned pair order refuses a stale preview before writes or calls', async (t) => {
|
|
192
|
-
const f = setup(t), before = await runEvalComponent(f.requestPath, { ...f.options, dryRun: true });
|
|
193
|
-
assert.ok('plan' in before);
|
|
194
|
-
writeFileSync(f.requestPath, JSON.stringify({ ...f.body, pairOrder: 'balanced' }));
|
|
195
|
-
await assert.rejects(runEvalComponent(f.requestPath, { ...f.options, dryRun: false, expectedPlanSha256: before.plan.sha256 }), /changed/);
|
|
196
|
-
assert.equal(f.calls(), 0);
|
|
197
|
-
assert.equal(existsSync(join(f.root, 'runs')), false);
|
|
198
|
-
});
|
|
199
|
-
test('resealing a ledger with wrong first-arm order still fails the native consistency audit', async (t) => {
|
|
200
|
-
const f = await run(t), path = join(f.runDir, '_calls.jsonl');
|
|
201
|
-
const rows = readFileSync(path, 'utf8').trim().split('\n').map(line => JSON.parse(line));
|
|
202
|
-
const starts = rows.filter(row => row.event === 'started' && row.role === 'agent');
|
|
203
|
-
const first = starts[0].workdir;
|
|
204
|
-
starts[0].workdir = starts[1].workdir;
|
|
205
|
-
starts[1].workdir = first;
|
|
206
|
-
writeFileSync(path, rows.map(row => JSON.stringify(row)).join('\n') + '\n');
|
|
207
|
-
const indexPath = join(f.runDir, '_artifacts.json'), index = JSON.parse(readFileSync(indexPath, 'utf8'));
|
|
208
|
-
index.files['_calls.jsonl'] = sha256File(path);
|
|
209
|
-
writeFileSync(indexPath, JSON.stringify(index, null, 2) + '\n');
|
|
210
|
-
const result = await reportEvalComponent(f.runDir);
|
|
211
|
-
assert.ok('quality' in result);
|
|
212
|
-
assert.equal(result.evidence.verified, false);
|
|
213
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
214
|
-
assert.match(result.evidence.reasons.join(' '), /execution order/);
|
|
215
|
-
});
|
|
216
|
-
test('component refuses absent/stale plan fingerprints and input drift before writes or calls', async (t) => {
|
|
217
|
-
const f = setup(t), preview = await runEvalComponent(f.requestPath, { ...f.options, dryRun: true });
|
|
218
|
-
assert.ok('plan' in preview);
|
|
219
|
-
await assert.rejects(runEvalComponent(f.requestPath, { ...f.options, dryRun: false }), /--plan-sha/);
|
|
220
|
-
writeFileSync(join(f.root, 'new/answer.txt'), '3');
|
|
221
|
-
await assert.rejects(runEvalComponent(f.requestPath, { ...f.options, dryRun: false, expectedPlanSha256: preview.plan.sha256 }), /changed/);
|
|
222
|
-
assert.equal(f.calls(), 0);
|
|
223
|
-
assert.equal(existsSync(join(f.root, 'runs')), false);
|
|
224
|
-
});
|
|
225
|
-
test('component records improvements, regressions and failed-task spending, with an exact offline replay', async (t) => {
|
|
226
|
-
const f = await run(t), result = f.result;
|
|
227
|
-
assert.equal(result.status, 'completed');
|
|
228
|
-
assert.equal(f.calls(), 4);
|
|
229
|
-
assert.ok('quality' in result);
|
|
230
|
-
assert.equal(result.quality.improvedPairs, 1);
|
|
231
|
-
assert.equal(result.quality.regressedPairs, 1);
|
|
232
|
-
assert.equal(result.acceptance.decision, 'reject');
|
|
233
|
-
assert.equal(result.acceptance.automaticUpgrade, false);
|
|
234
|
-
assert.equal(result.costs.populations?.attempts.treatment.metrics.uncachedInput.knownTotal, 12);
|
|
235
|
-
assert.equal(result.costs.populations?.attempts.baseline.metrics.uncachedInput.knownTotal, 4);
|
|
236
|
-
assert.equal(result.evidence.verified, true);
|
|
237
|
-
assert.ok(result.evidence.pairs?.some(p => p.changedChecks.some(c => c.change === 'regressed')));
|
|
238
|
-
const replay = await reportEvalComponent(f.runDir, { replay: true });
|
|
239
|
-
assert.ok('quality' in replay);
|
|
240
|
-
assert.equal(replay.evidence.replayedDeliveries, 4);
|
|
241
|
-
assert.equal(replay.evidence.verified, true);
|
|
242
|
-
assert.deepEqual(replay.quality, result.quality);
|
|
243
|
-
assert.deepEqual(replay.costs, result.costs);
|
|
244
|
-
assert.deepEqual(replay.acceptance, result.acceptance);
|
|
245
|
-
assert.deepEqual(replay.evidence.pairs, result.evidence.pairs);
|
|
246
|
-
assert.equal(readFileSync(join(f.root, 'old/answer.txt'), 'utf8'), '1');
|
|
247
|
-
});
|
|
248
|
-
test('receipt tampering prevents eligibility and is surfaced without rewriting evidence', async (t) => {
|
|
249
|
-
const f = await run(t);
|
|
250
|
-
const path = join(f.runDir, 'fix/treatment/trial-1/_result.json');
|
|
251
|
-
writeFileSync(path, readFileSync(path, 'utf8') + '\n');
|
|
252
|
-
const result = await reportEvalComponent(f.runDir);
|
|
253
|
-
assert.ok('quality' in result);
|
|
254
|
-
assert.equal(result.evidence.verified, false);
|
|
255
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
256
|
-
assert.ok(result.acceptance.reasons.some(r => r.code === 'EVIDENCE_NOT_VERIFIED'));
|
|
257
|
-
});
|
|
258
|
-
test('an added unsealed file invalidates the native inventory', async (t) => {
|
|
259
|
-
const f = await run(t);
|
|
260
|
-
writeFileSync(join(f.runDir, 'fix/treatment/trial-1/unsealed.txt'), 'extra grader input');
|
|
261
|
-
const result = await reportEvalComponent(f.runDir);
|
|
262
|
-
assert.ok('quality' in result);
|
|
263
|
-
assert.equal(result.evidence.verified, false);
|
|
264
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
265
|
-
assert.match(result.evidence.reasons.join(' '), /inventory changed/);
|
|
266
|
-
});
|
|
267
|
-
test('a programmatic injected executor cannot claim genuine component evidence', async (t) => {
|
|
268
|
-
const f = setup(t), p = parseAcceptancePolicy();
|
|
269
|
-
const executor = { ...f.executor, describe: () => ({ kind: 'cli', model: 'offline-spoof-fixture' }) };
|
|
270
|
-
await runEval({ skillPath: join(f.root, 'new'), baselineSkillPath: join(f.root, 'old'), bench: join(f.root, 'bench'), agent: 'codex',
|
|
271
|
-
mode: 'installed', skillInstallDir: 'project-skills', executor, judgeExecutor: null, trials: 1, maxCalls: 4,
|
|
272
|
-
runsRoot: join(f.root, 'runs'), runGroup: 'component', dryRun: false, yes: true, log: () => { },
|
|
273
|
-
component: { schemaVersion: 1, requestSha256: 'a'.repeat(64), previewSha256: 'b'.repeat(64), implementationSha256: hashFileSet(join(ROOT, 'dist'), listFilesRecursive(join(ROOT, 'dist'))),
|
|
274
|
-
policySha256: policyHash(p), policy: p, purpose: 'validation', synthetic: false } });
|
|
275
|
-
const result = await reportEvalComponent(f.runDir);
|
|
276
|
-
assert.ok('quality' in result);
|
|
277
|
-
assert.equal(result.evidence.verified, false);
|
|
278
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
279
|
-
assert.match(result.evidence.reasons.join(' '), /Injected executor/);
|
|
280
|
-
});
|
|
281
|
-
test('native planning rejects an implementation differing from the approved preview before writes', async (t) => {
|
|
282
|
-
const f = setup(t), p = parseAcceptancePolicy();
|
|
283
|
-
await assert.rejects(runEval({ skillPath: join(f.root, 'new'), baselineSkillPath: join(f.root, 'old'), bench: join(f.root, 'bench'), agent: 'codex',
|
|
284
|
-
mode: 'installed', skillInstallDir: 'project-skills', executor: f.executor, judgeExecutor: null, trials: 1, maxCalls: 4,
|
|
285
|
-
runsRoot: join(f.root, 'runs'), runGroup: 'component', dryRun: false, yes: true, log: () => { },
|
|
286
|
-
component: { schemaVersion: 1, requestSha256: 'a'.repeat(64), previewSha256: 'b'.repeat(64), implementationSha256: '0'.repeat(64),
|
|
287
|
-
policySha256: policyHash(p), policy: p, purpose: 'validation', synthetic: true } }), /implementation differs/);
|
|
288
|
-
assert.equal(f.calls(), 0);
|
|
289
|
-
assert.equal(existsSync(join(f.root, 'runs')), false);
|
|
290
|
-
});
|
|
291
|
-
test('unfinished ledgers with missing receipts report unknown spending and cannot authorize adoption', async (t) => {
|
|
292
|
-
const f = setup(t);
|
|
293
|
-
mkdirSync(f.runDir, { recursive: true });
|
|
294
|
-
writeFileSync(join(f.runDir, '_plan.json'), '{}');
|
|
295
|
-
writeFileSync(join(f.runDir, '_calls.jsonl'), JSON.stringify({ event: 'started', role: 'agent', workdir: join(f.runDir, 'fix/baseline/trial-1') }) + '\n');
|
|
296
|
-
const result = await reportEvalComponent(f.runDir);
|
|
297
|
-
assert.ok('costs' in result);
|
|
298
|
-
assert.equal(result.status, 'incomplete');
|
|
299
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
300
|
-
assert.equal(result.costs.populations?.attempts.baseline.metrics.input.coverage.unknown, 1);
|
|
301
|
-
assert.equal(result.costs.populations?.attempts.baseline.metrics.durationSeconds.coverage.unknown, 1);
|
|
302
|
-
});
|
|
303
|
-
test('changing the request policy during a call stops further calls and retains public spending', async (t) => {
|
|
304
|
-
const f = setup(t);
|
|
305
|
-
let calls = 0;
|
|
306
|
-
const executor = { describe: () => ({ kind: 'mock', model: 'policy-drift' }), run: async () => {
|
|
307
|
-
calls++;
|
|
308
|
-
writeFileSync(f.requestPath, JSON.stringify({ ...f.body, policy: { minTasks: 9 } }));
|
|
309
|
-
return { output: 'done', tokens: { input: 10, cachedInput: 2, output: 3 } };
|
|
310
|
-
} };
|
|
311
|
-
const options = { ...f.options, executor }, preview = await runEvalComponent(f.requestPath, { ...options, dryRun: true });
|
|
312
|
-
assert.ok('plan' in preview);
|
|
313
|
-
const result = await runEvalComponent(f.requestPath, { ...options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
314
|
-
assert.equal(calls, 1);
|
|
315
|
-
assert.equal(result.status, 'stopped');
|
|
316
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
317
|
-
assert.ok('costs' in result);
|
|
318
|
-
assert.equal(result.costs.populations?.attempts.baseline.metrics.input.knownTotal, 10);
|
|
319
|
-
const replay = await reportEvalComponent(f.runDir);
|
|
320
|
-
assert.ok('costs' in replay);
|
|
321
|
-
assert.deepEqual(replay.costs, result.costs);
|
|
322
|
-
});
|
|
323
|
-
test('executor failures preserve partial usage and missing cache counts remain unknown', async (t) => {
|
|
324
|
-
const f = setup(t);
|
|
325
|
-
const executor = { describe: () => ({ kind: 'mock', model: 'timeout' }), run: async () => {
|
|
326
|
-
throw new ExecutorFailure('simulated timeout', { output: '', tokens: { input: 12, output: 2 }, usageStatus: 'partial' });
|
|
327
|
-
} };
|
|
328
|
-
const options = { ...f.options, executor }, preview = await runEvalComponent(f.requestPath, { ...options, dryRun: true });
|
|
329
|
-
assert.ok('plan' in preview);
|
|
330
|
-
const result = await runEvalComponent(f.requestPath, { ...options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
331
|
-
assert.equal(result.status, 'stopped');
|
|
332
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
333
|
-
assert.ok('costs' in result);
|
|
334
|
-
assert.equal(result.costs.populations?.attempts.baseline.metrics.input.knownTotal, 12);
|
|
335
|
-
assert.equal(result.costs.populations?.attempts.baseline.metrics.input.coverage.partial, 1);
|
|
336
|
-
assert.equal(result.costs.populations?.attempts.baseline.metrics.uncachedInput.coverage.unknown, 1);
|
|
337
|
-
});
|
|
338
|
-
test('partial numeric usage provenance is sealed in receipts without making a stopped experiment eligible', async (t) => {
|
|
339
|
-
const f = setup(t), tokens = { input: 12, cachedInput: 8, output: 2 };
|
|
340
|
-
const evidence = { source: 'local-session-token-count', threadId: '11111111-1111-4111-8111-111111111111',
|
|
341
|
-
counterAt: '2026-10-13T00:00:00Z', recordSha256: 'a'.repeat(64), tokens, scope: 'Partial counter only.' };
|
|
342
|
-
const executor = { describe: () => ({ kind: 'mock', model: 'partial-metadata' }), run: async () => {
|
|
343
|
-
throw new ExecutorFailure('simulated timeout', { output: '', tokens, usageStatus: 'partial', usageEvidence: evidence });
|
|
344
|
-
} };
|
|
345
|
-
const options = { ...f.options, executor }, preview = await runEvalComponent(f.requestPath, { ...options, dryRun: true });
|
|
346
|
-
assert.ok('plan' in preview);
|
|
347
|
-
const result = await runEvalComponent(f.requestPath, { ...options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
348
|
-
assert.ok('quality' in result);
|
|
349
|
-
const receipt = JSON.parse(readFileSync(join(f.runDir, 'fix/baseline/trial-1/_result.json'), 'utf8'));
|
|
350
|
-
assert.deepEqual(receipt.usageEvidence, evidence);
|
|
351
|
-
assert.equal(result.evidence.verified, true);
|
|
352
|
-
assert.equal(result.costs.populations?.attempts.baseline.metrics.input.coverage.partial, 1);
|
|
353
|
-
assert.equal(result.costs.populations?.attempts.baseline.metrics.uncachedInput.knownTotal, 4);
|
|
354
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
355
|
-
assert.ok(result.acceptance.reasons.some(r => r.code === 'INCOMPLETE_COSTS'));
|
|
356
|
-
});
|
|
357
|
-
function strongManifest() {
|
|
358
|
-
const p = parseAcceptancePolicy();
|
|
359
|
-
const observations = (arm) => Array.from({ length: 5 }, (_, n) => ({
|
|
360
|
-
executorInvoked: true, passed: arm === 'treatment' || n < 3, error: null, durationSeconds: 1,
|
|
361
|
-
tokens: { input: arm === 'baseline' ? 10 : 9, cachedInput: 5, output: arm === 'baseline' ? 2 : 1 }, usageStatus: 'final',
|
|
362
|
-
}));
|
|
363
|
-
const arms = { baseline: observations('baseline'), treatment: observations('treatment') }, costs = summarizeCosts(arms, arms);
|
|
364
|
-
const condition = (passes, trials) => ({ passes, trials, errors: 0 });
|
|
365
|
-
const tasks = Array.from({ length: 8 }, (_, n) => ({ id: 'task-' + n, conditions: { baseline: condition(3, 5), treatment: condition(5, 5) },
|
|
366
|
-
outcomes: { baseline: [true, true, true, false, false], treatment: [true, true, true, true, true] },
|
|
367
|
-
deltaPassRate: 0.4, scoreDelta: null, verdict: 'inconclusive', facets: [], costs }));
|
|
368
|
-
const all = { baseline: tasks.flatMap(() => arms.baseline), treatment: tasks.flatMap(() => arms.treatment) };
|
|
369
|
-
return { schemaVersion: 4, createdAt: '2026-10-13T00:00:00Z', runGroup: 'policy-unit-fixture',
|
|
370
|
-
target: { kind: 'skill', name: 'test', bundleSha256: 'a'.repeat(64), files: ['SKILL.md'] },
|
|
371
|
-
baselineTarget: { kind: 'skill', name: 'test', bundleSha256: 'b'.repeat(64), files: ['SKILL.md'], sourceDir: '/old' },
|
|
372
|
-
inputMode: 'workspace', skillDelivery: { mode: 'installed', installDir: 'project-skills' },
|
|
373
|
-
executor: { kind: 'cli', model: 'synthetic-policy-unit-fixture' }, judge: null,
|
|
374
|
-
bench: { name: 'policy-unit', contentSha256: 'c'.repeat(64), taskCount: 8 }, trials: 5, tasks, warnings: ['Synthetic fixture used only to test the policy function.'],
|
|
375
|
-
component: { schemaVersion: 1, policy: p, policySha256: policyHash(p), requestSha256: 'd'.repeat(64), previewSha256: 'e'.repeat(64), implementationSha256: '0'.repeat(64), purpose: 'validation', synthetic: false },
|
|
376
|
-
experiment: { schemaVersion: 1, status: 'completed', plannedCalls: 80, maxCalls: 80, callsStarted: 80, callsFinished: 80, stopReason: null, planSha256: 'f'.repeat(64) },
|
|
377
|
-
overall: { conditions: { baseline: condition(24, 40), treatment: condition(40, 40) }, costs: summarizeCosts(all, all), deltaPassRate: 0.4, verdict: 'effective', verdictReason: 'synthetic exact-test fixture',
|
|
378
|
-
stats: { discordant: { improved: 16, regressed: 0 }, mcnemarP: 2 / 65536, deltaCi: { point: 0.4, lo: 0.4, hi: 0.4, resamples: 1000 } } } };
|
|
379
|
-
}
|
|
380
|
-
const verified = { verified: true, reasons: [], indexedFiles: 0, receipts: 80, replayedDeliveries: 0, replayRequested: false, policyBound: true };
|
|
381
|
-
function efficientTieManifest() {
|
|
382
|
-
const value = strongManifest();
|
|
383
|
-
value.component.policy = parseAcceptancePolicy({ schemaVersion: 2, objective: 'efficiency' });
|
|
384
|
-
value.component.policySha256 = policyHash(value.component.policy);
|
|
385
|
-
const observations = (input) => Array.from({ length: 5 }, () => ({
|
|
386
|
-
executorInvoked: true, passed: true, error: null, durationSeconds: 1,
|
|
387
|
-
tokens: { input, cachedInput: 20, output: 10 }, usageStatus: 'final',
|
|
388
|
-
}));
|
|
389
|
-
const arms = { baseline: observations(100), treatment: observations(70) };
|
|
390
|
-
for (const task of value.tasks) {
|
|
391
|
-
task.conditions.baseline.passes = 5;
|
|
392
|
-
task.outcomes.baseline.fill(true);
|
|
393
|
-
task.deltaPassRate = 0;
|
|
394
|
-
task.costs = summarizeCosts(arms, arms);
|
|
395
|
-
}
|
|
396
|
-
value.overall.conditions.baseline.passes = 40;
|
|
397
|
-
value.overall.deltaPassRate = 0;
|
|
398
|
-
value.overall.verdict = 'inconclusive';
|
|
399
|
-
value.overall.stats.discordant.improved = 0;
|
|
400
|
-
value.overall.stats.mcnemarP = 1;
|
|
401
|
-
value.overall.stats.deltaCi = { point: 0, lo: 0, hi: 0, resamples: 1000 };
|
|
402
|
-
const all = { baseline: value.tasks.flatMap(() => arms.baseline), treatment: value.tasks.flatMap(() => arms.treatment) };
|
|
403
|
-
value.overall.costs = summarizeCosts(all, all);
|
|
404
|
-
return { ...value, pairOrder: 'balanced' };
|
|
405
|
-
}
|
|
406
|
-
test('explicit efficiency validation accepts stable savings with no observed regression while quality remains inconclusive', () => {
|
|
407
|
-
const value = efficientTieManifest(), result = assessEvaluation(value, verified);
|
|
408
|
-
assert.equal(result.acceptance.decision, 'accept');
|
|
409
|
-
assert.equal(result.acceptance.automaticUpgrade, false);
|
|
410
|
-
assert.equal(result.quality.statisticalVerdict, 'inconclusive');
|
|
411
|
-
assert.equal(result.quality.deltaPassRate, 0);
|
|
412
|
-
assert.equal(result.costs.efficiency?.tasksCompared, 8);
|
|
413
|
-
assert.ok(result.costs.efficiency.ci.hi < -0.1);
|
|
414
|
-
const version1 = parseAcceptancePolicy();
|
|
415
|
-
value.component.policy = version1;
|
|
416
|
-
value.component.policySha256 = policyHash(version1);
|
|
417
|
-
assert.ok(assessEvaluation(value, verified).acceptance.reasons.some(r => r.code === 'QUALITY_GAIN_UNPROVEN'));
|
|
418
|
-
});
|
|
419
|
-
test('efficiency cannot waive predeclaration, independent validation, balanced order or visible regressions', () => {
|
|
420
|
-
const value = efficientTieManifest();
|
|
421
|
-
assert.ok(assessEvaluation(value, verified, parseAcceptancePolicy()).acceptance.reasons.some(r => r.code === 'POLICY_NOT_PREDECLARED'));
|
|
422
|
-
for (const mutate of [
|
|
423
|
-
(v) => { v.component.purpose = 'development'; },
|
|
424
|
-
(v) => { v.component.synthetic = true; },
|
|
425
|
-
(v) => { v.pairOrder = 'baseline-first'; },
|
|
426
|
-
]) {
|
|
427
|
-
const copy = structuredClone(value);
|
|
428
|
-
mutate(copy);
|
|
429
|
-
assert.equal(assessEvaluation(copy, verified).acceptance.decision, 'inconclusive');
|
|
430
|
-
}
|
|
431
|
-
const observation = { executorInvoked: true, passed: true, error: null, durationSeconds: 1, tokens: null, usageStatus: 'unknown', score: null };
|
|
432
|
-
const result = assessEvaluation(value, { ...verified, pairs: [{ taskId: 'task-0', trial: 1, graded: true,
|
|
433
|
-
baseline: observation, treatment: observation, scoreDelta: 0, costs: null, changedChecks: [{ name: 'edge case', change: 'regressed' }] }] });
|
|
434
|
-
assert.equal(result.acceptance.decision, 'reject');
|
|
435
|
-
});
|
|
436
|
-
test('efficiency keeps input partition tradeoffs visible and refuses unstable savings', () => {
|
|
437
|
-
const value = efficientTieManifest();
|
|
438
|
-
for (const scope of ['paired', 'attempts']) {
|
|
439
|
-
for (const task of value.tasks) {
|
|
440
|
-
task.costs[scope].treatment.metrics.cachedInput.knownTotal = 125;
|
|
441
|
-
task.costs[scope].treatment.metrics.uncachedInput.knownTotal = 225;
|
|
442
|
-
}
|
|
443
|
-
value.overall.costs[scope].treatment.metrics.cachedInput.knownTotal = 1000;
|
|
444
|
-
value.overall.costs[scope].treatment.metrics.uncachedInput.knownTotal = 1800;
|
|
445
|
-
}
|
|
446
|
-
assert.ok(assessEvaluation(value, verified).acceptance.reasons.some(r => r.code === 'COST_LIMIT_EXCEEDED'));
|
|
447
|
-
const equal = efficientTieManifest();
|
|
448
|
-
for (const task of equal.tasks)
|
|
449
|
-
for (const scope of ['paired', 'attempts']) {
|
|
450
|
-
task.costs[scope].treatment.metrics.input.knownTotal = 500;
|
|
451
|
-
task.costs[scope].treatment.metrics.uncachedInput.knownTotal = 400;
|
|
452
|
-
}
|
|
453
|
-
for (const scope of ['paired', 'attempts']) {
|
|
454
|
-
equal.overall.costs[scope].treatment.metrics.input.knownTotal = 4000;
|
|
455
|
-
equal.overall.costs[scope].treatment.metrics.uncachedInput.knownTotal = 3200;
|
|
456
|
-
}
|
|
457
|
-
const result = assessEvaluation(equal, verified);
|
|
458
|
-
assert.equal(result.acceptance.decision, 'inconclusive');
|
|
459
|
-
assert.ok(result.acceptance.reasons.some(r => r.code === 'EFFICIENCY_REDUCTION_UNPROVEN'));
|
|
460
|
-
assert.ok(result.acceptance.reasons.some(r => r.code === 'EFFICIENCY_NOT_BROAD'));
|
|
461
|
-
});
|
|
462
|
-
test('versioned policy parsing retains canonical quality bytes and rejects ambiguous objectives', () => {
|
|
463
|
-
const v1 = parseAcceptancePolicy();
|
|
464
|
-
assert.equal(JSON.stringify(v1), '{"schemaVersion":1,"minTasks":8,"minTrialsPerTask":5,"minDeltaPassRate":0,"maxCostIncreaseFraction":{"uncachedInput":0,"output":0,"durationSeconds":0}}');
|
|
465
|
-
assert.equal(policyHash(v1), policyHash(parseAcceptancePolicy({ schemaVersion: 1 })));
|
|
466
|
-
assert.throws(() => parseAcceptancePolicy({ objective: 'efficiency' }), /unknown fields/);
|
|
467
|
-
assert.throws(() => parseAcceptancePolicy({ schemaVersion: 2 }), /objective/);
|
|
468
|
-
assert.throws(() => parseAcceptancePolicy({ schemaVersion: 2, objective: 'quality' }), /objective/);
|
|
469
|
-
assert.throws(() => parseAcceptancePolicy({ schemaVersion: 2, objective: 'efficiency', minUncachedInputReductionFraction: 0 }), /minUncachedInputReductionFraction/);
|
|
470
|
-
assert.throws(() => parseAcceptancePolicy({ schemaVersion: 2, objective: 'efficiency', minImprovedTaskFraction: 0.5 }), /minImprovedTaskFraction/);
|
|
471
|
-
assert.throws(() => parseAcceptancePolicy({ schemaVersion: 2, objective: 'efficiency', minDeltaPassRate: 0 }), /unknown fields/);
|
|
472
|
-
});
|
|
473
|
-
test('a version-2 request binds its objective to native receipts and reproduces cost evidence offline', async (t) => {
|
|
474
|
-
const f = setup(t);
|
|
475
|
-
writeFileSync(f.requestPath, JSON.stringify({ ...f.body, pairOrder: 'balanced', policy: { schemaVersion: 2, objective: 'efficiency' } }));
|
|
476
|
-
const preview = await runEvalComponent(f.requestPath, { ...f.options, dryRun: true });
|
|
477
|
-
assert.ok('plan' in preview);
|
|
478
|
-
const result = await runEvalComponent(f.requestPath, { ...f.options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
479
|
-
assert.ok('quality' in result);
|
|
480
|
-
assert.equal(result.evidence.verified, true);
|
|
481
|
-
assert.ok('policy' in result.acceptance);
|
|
482
|
-
assert.equal(result.acceptance.policy.schemaVersion, 2);
|
|
483
|
-
assert.equal(result.acceptance.decision, 'reject');
|
|
484
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
485
|
-
assert.equal(result.costs.efficiency.ci, null);
|
|
486
|
-
const replay = await reportEvalComponent(f.runDir, { replay: true });
|
|
487
|
-
assert.ok('quality' in replay);
|
|
488
|
-
assert.equal(replay.evidence.verified, true);
|
|
489
|
-
assert.deepEqual(replay.costs, result.costs);
|
|
490
|
-
assert.deepEqual(replay.acceptance, result.acceptance);
|
|
491
|
-
});
|
|
492
|
-
test('declared deadlines are bounded, frozen before execution and reported from the native plan', async (t) => {
|
|
493
|
-
const f = setup(t);
|
|
494
|
-
assert.equal(parseEvalRequest(f.body, f.root).executorTimeoutSeconds, 600);
|
|
495
|
-
for (const executorTimeoutSeconds of [0, 3601, 1.5, Infinity]) {
|
|
496
|
-
assert.throws(() => parseEvalRequest({ ...f.body, executorTimeoutSeconds }, f.root), /executorTimeoutSeconds/);
|
|
497
|
-
}
|
|
498
|
-
writeFileSync(f.requestPath, JSON.stringify({ ...f.body, executorTimeoutSeconds: 1200 }));
|
|
499
|
-
const preview = await runEvalComponent(f.requestPath, { ...f.options, dryRun: true });
|
|
500
|
-
assert.ok('plan' in preview);
|
|
501
|
-
assert.equal(preview.plan.request.executorTimeoutSeconds, 1200);
|
|
502
|
-
assert.equal(preview.plan.evaluation.executorTimeoutSeconds, 1200);
|
|
503
|
-
writeFileSync(f.requestPath, JSON.stringify({ ...f.body, executorTimeoutSeconds: 600 }));
|
|
504
|
-
await assert.rejects(runEvalComponent(f.requestPath, { ...f.options, dryRun: false, expectedPlanSha256: preview.plan.sha256 }), /matching the current dry-run plan/);
|
|
505
|
-
assert.equal(f.calls(), 0);
|
|
506
|
-
assert.equal(existsSync(f.runDir), false);
|
|
507
|
-
const current = await runEvalComponent(f.requestPath, { ...f.options, dryRun: true });
|
|
508
|
-
assert.ok('plan' in current);
|
|
509
|
-
const result = await runEvalComponent(f.requestPath, { ...f.options, dryRun: false, expectedPlanSha256: current.plan.sha256 });
|
|
510
|
-
assert.ok('quality' in result);
|
|
511
|
-
assert.equal(result.evidence.verified, true);
|
|
512
|
-
assert.equal(result.environment?.executorTimeoutSeconds, 600);
|
|
513
|
-
});
|
|
514
|
-
test('adoption policy accepts only positive complete predeclared validation, never performs an upgrade', () => {
|
|
515
|
-
const value = strongManifest(), result = assessEvaluation(value, verified);
|
|
516
|
-
assert.equal(result.acceptance.decision, 'accept');
|
|
517
|
-
assert.equal(result.acceptance.eligibleForUpgrade, true);
|
|
518
|
-
assert.equal(result.acceptance.automaticUpgrade, false);
|
|
519
|
-
for (const change of [(v) => { v.component.purpose = 'development'; },
|
|
520
|
-
(v) => { v.component.synthetic = true; },
|
|
521
|
-
(v) => { v.experiment.status = 'stopped'; v.experiment.stopReason = 'test'; }]) {
|
|
522
|
-
const copy = structuredClone(value);
|
|
523
|
-
change(copy);
|
|
524
|
-
assert.equal(assessEvaluation(copy, verified).acceptance.eligibleForUpgrade, false);
|
|
525
|
-
}
|
|
526
|
-
const changedPolicy = parseAcceptancePolicy({ minTasks: 9 });
|
|
527
|
-
assert.equal(assessEvaluation(value, verified, changedPolicy).acceptance.eligibleForUpgrade, false);
|
|
528
|
-
const looser = assessEvaluation(value, verified, parseAcceptancePolicy({ maxCostIncreaseFraction: { output: 1 } }));
|
|
529
|
-
assert.equal(looser.acceptance.decision, 'inconclusive');
|
|
530
|
-
assert.ok(looser.acceptance.reasons.some(r => r.code === 'POLICY_NOT_PREDECLARED'));
|
|
531
|
-
const largerScale = strongManifest();
|
|
532
|
-
largerScale.component.policy = parseAcceptancePolicy({ minTasks: 9 });
|
|
533
|
-
largerScale.component.policySha256 = policyHash(largerScale.component.policy);
|
|
534
|
-
const small = assessEvaluation(largerScale, verified);
|
|
535
|
-
assert.equal(small.quality.statisticalVerdict, 'effective');
|
|
536
|
-
assert.equal(small.acceptance.decision, 'inconclusive');
|
|
537
|
-
assert.deepEqual(small.acceptance.reasons.map(r => r.code), ['INSUFFICIENT_SCALE']);
|
|
538
|
-
});
|
|
539
|
-
test('a declared cost limit can reject an otherwise positive complete validation fixture', () => {
|
|
540
|
-
const value = strongManifest();
|
|
541
|
-
for (const scope of ['paired', 'attempts']) {
|
|
542
|
-
for (const task of value.tasks)
|
|
543
|
-
task.costs[scope].treatment.metrics.output.knownTotal = 100;
|
|
544
|
-
value.overall.costs[scope].treatment.metrics.output.knownTotal = 800;
|
|
545
|
-
}
|
|
546
|
-
const result = assessEvaluation(value, verified);
|
|
547
|
-
assert.equal(result.quality.statisticalVerdict, 'effective');
|
|
548
|
-
assert.equal(result.acceptance.decision, 'reject');
|
|
549
|
-
assert.ok(result.acceptance.reasons.some(r => r.code === 'COST_LIMIT_EXCEEDED'));
|
|
550
|
-
});
|
|
551
|
-
test('paired named-check regressions cannot be hidden by unchanged task averages', () => {
|
|
552
|
-
const value = strongManifest();
|
|
553
|
-
const observation = { executorInvoked: true, passed: true, error: null, durationSeconds: 1,
|
|
554
|
-
tokens: { input: 10, cachedInput: 5, output: 2 }, usageStatus: 'final', score: null };
|
|
555
|
-
const result = assessEvaluation(value, { ...verified, pairs: [{ taskId: 'task-0', trial: 1, graded: true,
|
|
556
|
-
baseline: observation, treatment: observation, scoreDelta: 0,
|
|
557
|
-
changedChecks: [{ name: 'public callback', change: 'regressed' }], costs: null }] });
|
|
558
|
-
assert.equal(result.quality.statisticalVerdict, 'effective');
|
|
559
|
-
assert.equal(result.acceptance.decision, 'reject');
|
|
560
|
-
assert.ok(result.acceptance.reasons.some(r => r.code === 'OBSERVED_PAIR_REGRESSION'));
|
|
561
|
-
});
|
|
562
|
-
test('aggregate improvement cannot hide a named-check regression or incomplete costs', () => {
|
|
563
|
-
const value = strongManifest();
|
|
564
|
-
value.tasks[0].facets.push({ name: 'public callback', baselinePassRate: 1, treatmentPassRate: 0, baselineTrials: 5, treatmentTrials: 5 });
|
|
565
|
-
assert.equal(assessEvaluation(value, verified).acceptance.decision, 'reject');
|
|
566
|
-
const missing = strongManifest();
|
|
567
|
-
for (const scope of ['paired', 'attempts'])
|
|
568
|
-
for (const metric of ['cachedInput', 'uncachedInput']) {
|
|
569
|
-
for (const task of missing.tasks) {
|
|
570
|
-
task.costs[scope].treatment.metrics[metric].coverage = { final: 0, partial: 0, unknown: 5 };
|
|
571
|
-
task.costs[scope].treatment.metrics[metric].knownTotal = 0;
|
|
572
|
-
}
|
|
573
|
-
missing.overall.costs[scope].treatment.metrics[metric].coverage = { final: 0, partial: 0, unknown: 40 };
|
|
574
|
-
missing.overall.costs[scope].treatment.metrics[metric].knownTotal = 0;
|
|
575
|
-
}
|
|
576
|
-
const assessed = assessEvaluation(missing, verified);
|
|
577
|
-
assert.equal(assessed.acceptance.eligibleForUpgrade, false);
|
|
578
|
-
assert.ok(assessed.acceptance.reasons.some(r => r.code === 'INCOMPLETE_COSTS'));
|
|
579
|
-
assert.equal(assessEvaluation(strongManifest(), { ...verified, verified: false, reasons: ['missing receipts'] }).acceptance.eligibleForUpgrade, false);
|
|
580
|
-
});
|
|
581
|
-
test('published real revision evidence preserves recorded cost coverage and never authorizes an upgrade', async () => {
|
|
582
|
-
for (const name of ['2026-10-12-diagnosing-revision', '2026-10-12-normalize-url-v2-validated']) {
|
|
583
|
-
const path = join(ROOT, 'evidence/artifacts', name, 'manifest.json');
|
|
584
|
-
const result = await reportEvalComponent(path);
|
|
585
|
-
assert.ok('quality' in result);
|
|
586
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
587
|
-
const saved = JSON.parse(readFileSync(path, 'utf8'));
|
|
588
|
-
assert.deepEqual(result.costs.populations, saved.overall.costs ?? null);
|
|
589
|
-
if (saved.overall.costs === undefined)
|
|
590
|
-
assert.ok(result.acceptance.reasons.some(r => r.code === 'INCOMPLETE_COSTS'));
|
|
591
|
-
if (name.includes('diagnosing'))
|
|
592
|
-
assert.equal(result.quality.regressedPairs, 2);
|
|
593
|
-
else
|
|
594
|
-
assert.equal(result.quality.improvedPairs, 0);
|
|
595
|
-
}
|
|
596
|
-
});
|
|
597
|
-
test('CLI request plans and errors emit one parseable JSON document without agent execution', t => {
|
|
598
|
-
const f = setup(t);
|
|
599
|
-
const plan = spawnSync(process.execPath, [CLI, 'eval', '--request', f.requestPath, '--dry-run'], { cwd: tmpdir(), encoding: 'utf8' });
|
|
600
|
-
assert.equal(plan.status, 0, plan.stderr);
|
|
601
|
-
assert.equal(JSON.parse(plan.stdout).status, 'planned');
|
|
602
|
-
const refusal = spawnSync(process.execPath, [CLI, 'eval', '--request=' + f.requestPath, '--plan-sha', 'bad'], { encoding: 'utf8' });
|
|
603
|
-
assert.equal(refusal.status, 2);
|
|
604
|
-
assert.equal(JSON.parse(refusal.stdout).acceptance.eligibleForUpgrade, false);
|
|
605
|
-
const mixed = spawnSync(process.execPath, [CLI, 'eval', '--request', f.requestPath, '--trials', '2', '--dry-run'], { encoding: 'utf8' });
|
|
606
|
-
assert.equal(mixed.status, 2);
|
|
607
|
-
assert.match(JSON.parse(mixed.stdout).error.message, /cannot be combined/);
|
|
608
|
-
assert.equal(existsSync(join(f.root, 'runs')), false);
|
|
609
|
-
});
|
|
610
|
-
test('an explicit null baseline installs no Skill in baseline, preserves identical prompts and replays without originals', async (t) => {
|
|
611
|
-
const f = setup(t), seen = [], prompts = [];
|
|
612
|
-
writeFileSync(f.requestPath, JSON.stringify({ ...f.body, baselineSkill: null, taskIds: ['fix'], maxCalls: 2, executorTimeoutSeconds: 17 }));
|
|
613
|
-
const executor = { describe: () => ({ kind: 'mock', model: 'offline-no-skill' }), run: async (prompt, workdir) => {
|
|
614
|
-
prompts.push(prompt);
|
|
615
|
-
const installed = existsSync(join(workdir, 'project-skills/answer-skill/SKILL.md'));
|
|
616
|
-
seen.push(installed);
|
|
617
|
-
writeFileSync(join(workdir, 'answer.txt'), installed ? '2' : '1');
|
|
618
|
-
return { output: 'done', tokens: { input: 10, cachedInput: 6, output: 2 } };
|
|
619
|
-
} };
|
|
620
|
-
const options = { ...f.options, executor }, preview = await runEvalComponent(f.requestPath, { ...options, dryRun: true });
|
|
621
|
-
assert.equal(preview.plan.request.baselineSkill, null);
|
|
622
|
-
assert.equal(preview.plan.evaluation.baseline, null);
|
|
623
|
-
assert.equal(preview.plan.evaluation.executorTimeoutSeconds, 17);
|
|
624
|
-
assert.equal(preview.plan.evaluation.plannedCalls, 2);
|
|
625
|
-
assert.equal(existsSync(f.runDir), false);
|
|
626
|
-
assert.equal(seen.length, 0);
|
|
627
|
-
const result = await runEvalComponent(f.requestPath, { ...options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
628
|
-
assert.deepEqual(seen, [false, true]);
|
|
629
|
-
assert.equal(prompts[0], prompts[1]);
|
|
630
|
-
assert.ok('identity' in result);
|
|
631
|
-
assert.equal(result.identity.baseline, null);
|
|
632
|
-
assert.equal(result.evidence.verified, true);
|
|
633
|
-
assert.ok(result.acceptance.reasons.some(r => r.code === 'REVISION_COMPARISON_REQUIRED'));
|
|
634
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
635
|
-
for (const path of [f.requestPath, join(f.root, 'bench'), join(f.root, 'old'), join(f.root, 'new')])
|
|
636
|
-
rmSync(path, { recursive: true });
|
|
637
|
-
const replay = await reportEvalComponent(f.runDir, { replay: true });
|
|
638
|
-
assert.equal(replay.evidence.verified, true);
|
|
639
|
-
const output = join(f.root, 'portable');
|
|
640
|
-
await exportEvaluation(f.runDir, output, { yes: true, log: () => { } });
|
|
641
|
-
assert.equal(existsSync(join(output, 'inputs/baseline-skill')), false);
|
|
642
|
-
assert.equal(JSON.parse(readFileSync(join(output, 'inputs/request.json'), 'utf8')).baselineSkill, null);
|
|
643
|
-
rmSync(f.runDir, { recursive: true });
|
|
644
|
-
const child = spawnSync(process.execPath, [join(output, 'reproduce.mjs')], { encoding: 'utf8', timeout: 30_000 });
|
|
645
|
-
assert.equal(child.status, 0, child.stderr);
|
|
646
|
-
const portable = JSON.parse(child.stdout);
|
|
647
|
-
assert.equal(portable.identity.baseline, null);
|
|
648
|
-
assert.equal(portable.acceptance.eligibleForUpgrade, false);
|
|
649
|
-
assert.equal(seen.length, 2);
|
|
650
|
-
});
|
|
651
|
-
test('null is an explicit baseline choice; missing, empty or malformed paths never silently select it', t => {
|
|
652
|
-
const f = setup(t), { baselineSkill: _previous, ...missing } = f.body;
|
|
653
|
-
assert.equal(parseEvalRequest({ ...f.body, baselineSkill: null }, f.root).baselineSkill, null);
|
|
654
|
-
assert.equal(parseEvalRequest(f.body, f.root).baselineSkill, join(f.root, 'old'));
|
|
655
|
-
for (const baselineSkill of [undefined, '', false, 0, {}])
|
|
656
|
-
assert.throws(() => parseEvalRequest({ ...f.body, baselineSkill }, f.root), /baselineSkill/);
|
|
657
|
-
assert.throws(() => parseEvalRequest(missing, f.root), /baselineSkill/);
|
|
658
|
-
assert.equal(f.calls(), 0);
|
|
659
|
-
});
|
|
660
|
-
function ordinaryOptions(f, overrides = {}) {
|
|
661
|
-
return { skillPath: join(f.root, 'new'), baselineSkillPath: join(f.root, 'old'), bench: join(f.root, 'bench'), agent: 'codex',
|
|
662
|
-
mode: 'installed', inputMode: 'workspace', trials: 1, maxCalls: 4, runsRoot: join(f.root, 'runs'), runGroup: 'component',
|
|
663
|
-
dryRun: true, yes: true, ...f.options, log: () => { }, ...overrides };
|
|
664
|
-
}
|
|
665
|
-
test('ordinary eval and request preview share the effective plan, timeout and all spending lines', async (t) => {
|
|
666
|
-
const f = setup(t), spendingBudget = { input: 1000, cachedInput: 1000, uncachedInput: 1000, output: 1000, durationSeconds: 1000 };
|
|
667
|
-
writeFileSync(f.requestPath, JSON.stringify({ ...f.body, pairOrder: 'balanced', executorTimeoutSeconds: 17, spendingBudget }));
|
|
668
|
-
const request = await runEvalComponent(f.requestPath, { ...f.options, dryRun: true });
|
|
669
|
-
const ordinary = await runEvalCli(ordinaryOptions(f, { pairOrder: 'balanced', executorTimeoutSeconds: 17, spendingBudget }));
|
|
670
|
-
assert.ok('plan' in ordinary);
|
|
671
|
-
assert.deepEqual(ordinary.plan.evaluation, request.plan.evaluation);
|
|
672
|
-
assert.equal(ordinary.plan.implementationSha256, request.plan.implementationSha256);
|
|
673
|
-
assert.equal(ordinary.status, 'planned');
|
|
674
|
-
assert.equal(ordinary.acceptance.eligibleForUpgrade, false);
|
|
675
|
-
assert.equal(existsSync(join(f.root, 'runs')), false);
|
|
676
|
-
assert.equal(f.calls(), 0);
|
|
677
|
-
});
|
|
678
|
-
test('ordinary confirmed plans reject changed budget, timeout, ordering, selection and baseline before calls', async (t) => {
|
|
679
|
-
const f = setup(t), spendingBudget = { input: 1000, cachedInput: 1000, uncachedInput: 1000, output: 1000, durationSeconds: 1000 };
|
|
680
|
-
const base = ordinaryOptions(f, { pairOrder: 'balanced', executorTimeoutSeconds: 17, spendingBudget });
|
|
681
|
-
const preview = await runEvalCli(base);
|
|
682
|
-
assert.ok('plan' in preview);
|
|
683
|
-
for (const change of [{ executorTimeoutSeconds: 18 }, { pairOrder: 'baseline-first' }, { spendingBudget: { ...spendingBudget, input: 999 } },
|
|
684
|
-
{ maxCalls: 5 }, { taskIds: ['fix'] }, { baselineSkillPath: undefined }]) {
|
|
685
|
-
await assert.rejects(() => runEvalCli({ ...base, ...change, dryRun: false }, preview.plan.sha256), /--plan-sha matching/);
|
|
686
|
-
}
|
|
687
|
-
assert.equal(f.calls(), 0);
|
|
688
|
-
assert.equal(existsSync(f.runDir), false);
|
|
689
|
-
});
|
|
690
|
-
test('ordinary execution seals the shared reviewed plan and retains replayable costs without component adoption', async (t) => {
|
|
691
|
-
const f = setup(t), spendingBudget = { input: 1000, cachedInput: 1000, uncachedInput: 1000, output: 1000, durationSeconds: 1000 };
|
|
692
|
-
const base = ordinaryOptions(f, { executorTimeoutSeconds: 17, pairOrder: 'balanced', spendingBudget });
|
|
693
|
-
const preview = await runEvalCli(base);
|
|
694
|
-
assert.ok('plan' in preview);
|
|
695
|
-
const result = await runEvalCli({ ...base, dryRun: false }, preview.plan.sha256);
|
|
696
|
-
assert.equal(result.status, 'completed');
|
|
697
|
-
assert.ok('evidence' in result);
|
|
698
|
-
assert.equal(result.evidence.verified, true, result.evidence.reasons.join('; '));
|
|
699
|
-
assert.ok('costs' in result);
|
|
700
|
-
const native = JSON.parse(readFileSync(join(f.runDir, '_plan.json'), 'utf8'));
|
|
701
|
-
assert.deepEqual(native.details.reviewedPlan, preview.plan);
|
|
702
|
-
assert.equal(native.details.executorTimeoutSeconds, 17);
|
|
703
|
-
assert.equal(native.details.component, undefined);
|
|
704
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
705
|
-
for (const path of ['bench', 'old', 'new'])
|
|
706
|
-
rmSync(join(f.root, path), { recursive: true });
|
|
707
|
-
const replay = await reportEvalComponent(f.runDir, { replay: true });
|
|
708
|
-
assert.equal(replay.evidence.verified, true);
|
|
709
|
-
assert.ok('costs' in replay);
|
|
710
|
-
assert.deepEqual(replay.costs, result.costs);
|
|
711
|
-
assert.deepEqual(replay.spendingBudget?.limits, spendingBudget);
|
|
712
|
-
const output = join(f.root, 'portable');
|
|
713
|
-
await exportEvaluation(f.runDir, output, { yes: true, log: () => { } });
|
|
714
|
-
rmSync(f.runDir, { recursive: true });
|
|
715
|
-
const child = spawnSync(process.execPath, [join(output, 'reproduce.mjs')], { encoding: 'utf8', timeout: 30_000 });
|
|
716
|
-
assert.equal(child.status, 0, child.stderr);
|
|
717
|
-
const portable = JSON.parse(child.stdout);
|
|
718
|
-
assert.equal(portable.evidence.verified, true);
|
|
719
|
-
assert.deepEqual(portable.costs, result.costs);
|
|
720
|
-
assert.deepEqual(portable.spendingBudget.limits, spendingBudget);
|
|
721
|
-
assert.equal(portable.acceptance.eligibleForUpgrade, false);
|
|
722
|
-
assert.equal(f.calls(), 4);
|
|
723
|
-
});
|
|
724
|
-
test('ordinary and Agent no-Skill comparisons stop at the same budget line and keep the one invoked receipt', async (t) => {
|
|
725
|
-
const f = setup(t), spendingBudget = { input: 10, cachedInput: 100, uncachedInput: 100, output: 100, durationSeconds: 100 };
|
|
726
|
-
let calls = 0;
|
|
727
|
-
const executor = { describe: () => ({ kind: 'mock', model: 'offline-common-budget' }), run: async (_prompt, workdir) => {
|
|
728
|
-
calls++;
|
|
729
|
-
assert.equal(existsSync(join(workdir, 'project-skills/answer-skill')), false);
|
|
730
|
-
writeFileSync(join(workdir, 'answer.txt'), '1');
|
|
731
|
-
return { output: 'done', tokens: { input: 10, cachedInput: 6, output: 2 } };
|
|
732
|
-
} };
|
|
733
|
-
writeFileSync(f.requestPath, JSON.stringify({ ...f.body, baselineSkill: null, taskIds: ['fix'], maxCalls: 2, spendingBudget }));
|
|
734
|
-
const requestPreview = await runEvalComponent(f.requestPath, { ...f.options, executor, dryRun: true });
|
|
735
|
-
const request = await runEvalComponent(f.requestPath, { ...f.options, executor, dryRun: false, expectedPlanSha256: requestPreview.plan.sha256 });
|
|
736
|
-
const base = ordinaryOptions(f, { baselineSkillPath: undefined, taskIds: ['fix'], maxCalls: 2, spendingBudget, executor, runGroup: 'ordinary' });
|
|
737
|
-
const preview = await runEvalCli(base);
|
|
738
|
-
assert.ok('plan' in preview);
|
|
739
|
-
const ordinary = await runEvalCli({ ...base, dryRun: false }, preview.plan.sha256);
|
|
740
|
-
for (const result of [request, ordinary]) {
|
|
741
|
-
assert.equal(result.status, 'stopped');
|
|
742
|
-
assert.ok('spendingBudget' in result && result.spendingBudget);
|
|
743
|
-
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 10);
|
|
744
|
-
assert.ok(result.spendingBudget.latestState.reached.includes('input'));
|
|
745
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
746
|
-
}
|
|
747
|
-
assert.equal(calls, 2);
|
|
748
|
-
assert.equal(existsSync(join(f.runDir, 'fix/treatment/trial-1')), false);
|
|
749
|
-
assert.equal(existsSync(join(f.root, 'runs/ordinary/fix/treatment/trial-1')), false);
|
|
750
|
-
});
|
|
751
|
-
for (const [label, tokens] of [['missing cache', { input: 10, output: 2 }], ['partial', { input: 10, cachedInput: 6, output: 2 }]]) {
|
|
752
|
-
test(`ordinary ${label} usage cannot authorize a second budgeted invocation`, async (t) => {
|
|
753
|
-
const f = setup(t);
|
|
754
|
-
let calls = 0;
|
|
755
|
-
const executor = { describe: () => ({ kind: 'mock', model: 'offline-incomplete-budget' }), run: async (_prompt, workdir) => {
|
|
756
|
-
calls++;
|
|
757
|
-
writeFileSync(join(workdir, 'answer.txt'), '1');
|
|
758
|
-
return { output: 'done', tokens, ...(label === 'partial' ? { usageStatus: 'partial' } : {}) };
|
|
759
|
-
} };
|
|
760
|
-
const base = ordinaryOptions(f, { executor, spendingBudget: { input: 100, cachedInput: 100, uncachedInput: 100, output: 100, durationSeconds: 100 } });
|
|
761
|
-
const preview = await runEvalCli(base);
|
|
762
|
-
assert.ok('plan' in preview);
|
|
763
|
-
const result = await runEvalCli({ ...base, dryRun: false }, preview.plan.sha256);
|
|
764
|
-
assert.equal(result.status, 'stopped');
|
|
765
|
-
assert.equal(calls, 1);
|
|
766
|
-
assert.ok('spendingBudget' in result && result.spendingBudget);
|
|
767
|
-
assert.equal(result.spendingBudget.latestState.reason, 'FINAL_USAGE_MISSING');
|
|
768
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
769
|
-
});
|
|
770
|
-
}
|