skillfit 0.12.0 → 0.13.0
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/growth-roadmap-2026-10.md +14 -18
- package/docs/package-contents.md +73 -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 +41 -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-feature-smoke.mjs +114 -0
- package/docs/releases/0.13.0-preparation.json +102 -0
- package/docs/releases/0.13.0.md +61 -0
- package/docs/releases/archive-delivery-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/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,237 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync, existsSync } from 'node:fs';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { tmpdir } from 'node:os';
|
|
5
|
-
import { test } from 'node:test';
|
|
6
|
-
import { runEvalComponent, reportEvalComponent } from '../commands/eval-component.js';
|
|
7
|
-
import { parseEvalRequest } from './eval-contract.js';
|
|
8
|
-
import { assertSpendingCanContinue, parseSpendingBudget, spendingBudgetState, spendingStopFrom, SpendingBudgetStop } from './eval-budget.js';
|
|
9
|
-
import { COST_METRICS } from './costs.js';
|
|
10
|
-
import { sha256File } from './hash.js';
|
|
11
|
-
import { ExecutorFailure } from './types.js';
|
|
12
|
-
const limits = { input: 1000, cachedInput: 1000, uncachedInput: 1000, output: 1000, durationSeconds: 1000 };
|
|
13
|
-
const observation = (extra = {}) => ({ executorInvoked: true, passed: true, error: null,
|
|
14
|
-
tokens: { input: 10, cachedInput: 6, output: 3 }, usageStatus: 'final', durationSeconds: 2, ...extra });
|
|
15
|
-
test('spending stop lines require all five positive values and reject malformed counters/limits', () => {
|
|
16
|
-
assert.deepEqual(parseSpendingBudget(limits), limits);
|
|
17
|
-
for (const bad of [null, [], {}, { ...limits, surprise: 1 }, { ...limits, output: 0 }, { ...limits, input: 1.5 }, { ...limits, durationSeconds: Infinity }]) {
|
|
18
|
-
assert.throws(() => parseSpendingBudget(bad), /spendingBudget/);
|
|
19
|
-
}
|
|
20
|
-
for (const value of [NaN, Infinity, -1, 0.5, Number.MAX_SAFE_INTEGER + 1]) {
|
|
21
|
-
const state = spendingBudgetState(limits, [observation({ tokens: { input: value, cachedInput: 2, output: 3 } })]);
|
|
22
|
-
assert.equal(state.reason, 'FINAL_USAGE_MISSING');
|
|
23
|
-
assert.ok(state.incomplete.includes('input'));
|
|
24
|
-
assert.equal(state.metrics.input.coverage.unknown, 1);
|
|
25
|
-
assert.throws(() => assertSpendingCanContinue(state), /no further/);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
test('all-invocation budgets count functional failures, partial costs and unknown partitions without double counting cache', () => {
|
|
29
|
-
const state = spendingBudgetState(limits, [observation({ passed: false }), observation({ usageStatus: 'partial', tokens: { input: 7, output: 2 } })]);
|
|
30
|
-
assert.equal(state.invocations, 2);
|
|
31
|
-
assert.equal(state.metrics.input.knownTotal, 17);
|
|
32
|
-
assert.equal(state.metrics.cachedInput.knownTotal, 6);
|
|
33
|
-
assert.equal(state.metrics.cachedInput.coverage.unknown, 1);
|
|
34
|
-
assert.equal(state.metrics.uncachedInput.knownTotal, 4);
|
|
35
|
-
assert.equal(state.metrics.uncachedInput.coverage.unknown, 1);
|
|
36
|
-
assert.equal(state.metrics.input.coverage.partial, 1);
|
|
37
|
-
assert.equal(state.reason, 'FINAL_USAGE_MISSING');
|
|
38
|
-
});
|
|
39
|
-
test('budget stop codes survive trusted cause chains without treating arbitrary error text as safe diagnostics', () => {
|
|
40
|
-
const state = spendingBudgetState({ ...limits, input: 10 }, [observation()]);
|
|
41
|
-
let stopped;
|
|
42
|
-
try {
|
|
43
|
-
assertSpendingCanContinue(state);
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
stopped = error;
|
|
47
|
-
}
|
|
48
|
-
assert.ok(stopped instanceof SpendingBudgetStop);
|
|
49
|
-
assert.equal(stopped.code, 'SPENDING_BUDGET_REACHED');
|
|
50
|
-
assert.equal(spendingStopFrom(new Error('wrapper', { cause: stopped })), stopped);
|
|
51
|
-
const ordinary = new Error('SPENDING_BUDGET_REACHED: private credential text');
|
|
52
|
-
ordinary.name = 'SpendingBudgetStop';
|
|
53
|
-
assert.equal(spendingStopFrom(ordinary), null);
|
|
54
|
-
const cycle = new Error('cyclic cause');
|
|
55
|
-
cycle.cause = cycle;
|
|
56
|
-
assert.equal(spendingStopFrom(cycle), null);
|
|
57
|
-
});
|
|
58
|
-
function setup(t, change = {}, result, functionalFailure = false) {
|
|
59
|
-
const root = mkdtempSync(join(tmpdir(), 'skillfit-budget-'));
|
|
60
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
61
|
-
for (const name of ['old', 'new']) {
|
|
62
|
-
mkdirSync(join(root, name));
|
|
63
|
-
writeFileSync(join(root, name, 'SKILL.md'), `---\nname: budget-skill\ndescription: Diagnose answers.\n---\nCheck the public answer using the ${name} revision.\n`);
|
|
64
|
-
}
|
|
65
|
-
const bench = join(root, 'bench');
|
|
66
|
-
mkdirSync(join(bench, 'fixture'), { recursive: true });
|
|
67
|
-
writeFileSync(join(bench, 'fixture/answer.txt'), 'pending');
|
|
68
|
-
writeFileSync(join(bench, 'prompt.md'), 'Repair the answer.');
|
|
69
|
-
writeFileSync(join(bench, 'check.mjs'), `import{readFileSync}from'node:fs';import{join}from'node:path';const passed=readFileSync(join(process.argv[2],'answer.txt'),'utf8')==='fixed';console.log(JSON.stringify({passed,checks:[{name:'answer',pass:passed}]}));process.exit(passed?0:1);\n`);
|
|
70
|
-
writeFileSync(join(bench, 'bench.json'), JSON.stringify({ schemaVersion: 1, name: 'budget', tasks: [
|
|
71
|
-
{ id: 'first', fixture: 'fixture', prompt: 'prompt.md', verifier: 'node check.mjs', verifierKind: 'command' },
|
|
72
|
-
{ id: 'second', fixture: 'fixture', prompt: 'prompt.md', verifier: 'node check.mjs', verifierKind: 'command' },
|
|
73
|
-
] }));
|
|
74
|
-
const body = { schemaVersion: 1, baselineSkill: 'old', candidateSkill: 'new', bench: 'bench', agent: 'codex', purpose: 'validation',
|
|
75
|
-
pairOrder: 'balanced', trials: 1, maxCalls: 4, spendingBudget: { ...limits, ...change }, runsRoot: 'runs', runGroup: 'budget' };
|
|
76
|
-
const request = join(root, 'request.json');
|
|
77
|
-
writeFileSync(request, JSON.stringify(body));
|
|
78
|
-
let count = 0;
|
|
79
|
-
const executor = { describe: () => ({ kind: 'mock', model: 'offline-budget' }), run: async (_prompt, workdir) => {
|
|
80
|
-
if (!functionalFailure)
|
|
81
|
-
writeFileSync(join(workdir, 'answer.txt'), 'fixed');
|
|
82
|
-
count++;
|
|
83
|
-
return result ? result() : { output: 'done', tokens: { input: 10, cachedInput: 6, output: 3 } };
|
|
84
|
-
} };
|
|
85
|
-
const options = { executor, skillInstallDir: 'project-skills', sessionOptions: { homeDir: root, env: {}, versionProbe: () => null } };
|
|
86
|
-
return { root, body, request, options, calls: () => count, directory: join(root, 'runs/budget') };
|
|
87
|
-
}
|
|
88
|
-
async function execute(f) {
|
|
89
|
-
const preview = await runEvalComponent(f.request, { ...f.options, dryRun: true });
|
|
90
|
-
assert.ok('plan' in preview);
|
|
91
|
-
assert.equal(f.calls(), 0);
|
|
92
|
-
assert.equal(existsSync(f.directory), false);
|
|
93
|
-
return runEvalComponent(f.request, { ...f.options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
94
|
-
}
|
|
95
|
-
for (const metric of COST_METRICS)
|
|
96
|
-
test(`${metric} stop line blocks the second executor and retains the first complete receipt`, async (t) => {
|
|
97
|
-
const values = { input: 10, cachedInput: 6, uncachedInput: 4, output: 3, durationSeconds: 0.000001 };
|
|
98
|
-
const f = setup(t, { [metric]: values[metric] }), result = await execute(f);
|
|
99
|
-
assert.equal(f.calls(), 1);
|
|
100
|
-
assert.equal(result.status, 'stopped');
|
|
101
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
102
|
-
const receipt = JSON.parse(readFileSync(join(f.directory, 'first/baseline/trial-1/_result.json'), 'utf8'));
|
|
103
|
-
assert.deepEqual(receipt.tokens, { input: 10, cachedInput: 6, output: 3 });
|
|
104
|
-
assert.equal(existsSync(join(f.directory, 'first/treatment/trial-1')), false);
|
|
105
|
-
const session = JSON.parse(readFileSync(join(f.directory, '_session.json'), 'utf8'));
|
|
106
|
-
assert.equal(session.stopCode, 'SPENDING_BUDGET_REACHED');
|
|
107
|
-
assert.match(session.stopReason, /SPENDING_BUDGET_REACHED/);
|
|
108
|
-
assert.ok('spendingBudget' in result);
|
|
109
|
-
assert.ok(result.spendingBudget);
|
|
110
|
-
assert.ok(result.spendingBudget.latestState.reached.includes(metric));
|
|
111
|
-
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 10);
|
|
112
|
-
const replay = await reportEvalComponent(f.directory);
|
|
113
|
-
assert.equal(replay.status, 'stopped');
|
|
114
|
-
assert.ok('spendingBudget' in replay);
|
|
115
|
-
assert.deepEqual(replay.spendingBudget, result.spendingBudget);
|
|
116
|
-
});
|
|
117
|
-
test('an in-flight overshoot is retained instead of clamped to its stop line', async (t) => {
|
|
118
|
-
const f = setup(t, { input: 5 }), result = await execute(f);
|
|
119
|
-
assert.equal(f.calls(), 1);
|
|
120
|
-
assert.ok('spendingBudget' in result);
|
|
121
|
-
assert.ok(result.spendingBudget);
|
|
122
|
-
assert.equal(result.spendingBudget.limits.input, 5);
|
|
123
|
-
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 10);
|
|
124
|
-
});
|
|
125
|
-
for (const [label, tokens] of [['no counters', undefined], ['missing cache', { input: 10, output: 3 }], ['incompatible cache', { input: 10, cachedInput: 11, output: 3 }]]) {
|
|
126
|
-
test(`${label}: missing or incompatible final usage refuses another call without filling cache with zero`, async (t) => {
|
|
127
|
-
const f = setup(t, {}, () => ({ output: 'returned', tokens })), result = await execute(f);
|
|
128
|
-
assert.equal(f.calls(), 1);
|
|
129
|
-
assert.equal(result.status, 'stopped');
|
|
130
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
131
|
-
const session = JSON.parse(readFileSync(join(f.directory, '_session.json'), 'utf8'));
|
|
132
|
-
assert.equal(session.stopCode, 'FINAL_USAGE_MISSING');
|
|
133
|
-
assert.match(session.stopReason, /FINAL_USAGE_MISSING/);
|
|
134
|
-
assert.ok('spendingBudget' in result);
|
|
135
|
-
assert.ok(result.spendingBudget);
|
|
136
|
-
assert.equal(result.spendingBudget.latestState.reason, 'FINAL_USAGE_MISSING');
|
|
137
|
-
assert.equal(result.spendingBudget.latestState.metrics.cachedInput.coverage.unknown, 1);
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
test('invalid retained receipts remain untouched and appear as unknown rather than disappearing or becoming zero-cost success', async (t) => {
|
|
141
|
-
const f = setup(t, {}, () => ({ output: 'invalid counters', tokens: { input: 10, cachedInput: 11, output: 3 } }));
|
|
142
|
-
const result = await execute(f), path = join(f.directory, 'first/baseline/trial-1/_result.json'), hash = sha256File(path);
|
|
143
|
-
const value = JSON.parse(JSON.stringify(result));
|
|
144
|
-
assert.equal(value.costs.invocationsWithUnknownReceipts, 1);
|
|
145
|
-
assert.equal(value.costs.recordedExecutorInvocations, 0);
|
|
146
|
-
assert.equal(value.costs.invalidReceipts.length, 1);
|
|
147
|
-
assert.equal(value.costs.populations.attempts.baseline.metrics.input.coverage.unknown, 1);
|
|
148
|
-
await reportEvalComponent(f.directory);
|
|
149
|
-
assert.equal(sha256File(path), hash);
|
|
150
|
-
assert.equal(f.calls(), 1);
|
|
151
|
-
});
|
|
152
|
-
test('an executor guard failure stops immediately while retaining its complete returned usage', async (t) => {
|
|
153
|
-
const f = setup(t, {}, () => ({ output: 'retained', guardError: 'simulated configuration drift', tokens: { input: 12, cachedInput: 8, output: 2 } }));
|
|
154
|
-
const result = await execute(f);
|
|
155
|
-
assert.equal(result.status, 'stopped');
|
|
156
|
-
assert.equal(f.calls(), 1);
|
|
157
|
-
assert.ok('spendingBudget' in result);
|
|
158
|
-
assert.ok(result.spendingBudget);
|
|
159
|
-
assert.equal(result.spendingBudget.latestState.reason, 'EXECUTION_FAILED');
|
|
160
|
-
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 12);
|
|
161
|
-
assert.equal(result.spendingBudget.latestState.metrics.input.coverage.final, 1);
|
|
162
|
-
});
|
|
163
|
-
test('executor failure retains partial usage, stops once and never replaces the call', async (t) => {
|
|
164
|
-
const f = setup(t, {}, () => { throw new ExecutorFailure('offline simulated routing failure', { output: 'partial', usageStatus: 'partial', tokens: { input: 17, cachedInput: 4, output: 2 } }); });
|
|
165
|
-
const result = await execute(f);
|
|
166
|
-
assert.equal(f.calls(), 1);
|
|
167
|
-
assert.equal(result.status, 'stopped');
|
|
168
|
-
assert.ok('spendingBudget' in result);
|
|
169
|
-
assert.ok(result.spendingBudget);
|
|
170
|
-
assert.equal(result.spendingBudget.latestState.reason, 'EXECUTION_FAILED');
|
|
171
|
-
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 17);
|
|
172
|
-
assert.equal(result.spendingBudget.latestState.metrics.input.coverage.partial, 1);
|
|
173
|
-
});
|
|
174
|
-
test('ordinary functional failures spend budget and are not executor failures or replacement samples', async (t) => {
|
|
175
|
-
const f = setup(t, {}, undefined, true), result = await execute(f);
|
|
176
|
-
assert.equal(f.calls(), 4);
|
|
177
|
-
assert.equal(result.status, 'completed');
|
|
178
|
-
assert.ok('spendingBudget' in result);
|
|
179
|
-
assert.ok(result.spendingBudget);
|
|
180
|
-
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 40);
|
|
181
|
-
assert.equal(result.spendingBudget.latestState.reason, null);
|
|
182
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
183
|
-
});
|
|
184
|
-
test('complete budget events bind the plan and reproduce from native receipts', async (t) => {
|
|
185
|
-
const f = setup(t), result = await execute(f);
|
|
186
|
-
assert.equal(f.calls(), 4);
|
|
187
|
-
assert.equal(result.status, 'completed');
|
|
188
|
-
assert.ok('evidence' in result);
|
|
189
|
-
assert.equal(result.evidence.verified, true);
|
|
190
|
-
assert.ok('spendingBudget' in result);
|
|
191
|
-
assert.ok(result.spendingBudget);
|
|
192
|
-
assert.equal(result.spendingBudget.events, 8);
|
|
193
|
-
assert.equal(result.spendingBudget.latestState.metrics.uncachedInput.knownTotal, 16);
|
|
194
|
-
const replay = await reportEvalComponent(f.directory, { replay: true });
|
|
195
|
-
assert.equal(replay.evidence.verified, true);
|
|
196
|
-
assert.ok('spendingBudget' in replay);
|
|
197
|
-
assert.deepEqual(replay.spendingBudget, result.spendingBudget);
|
|
198
|
-
});
|
|
199
|
-
test('a resealed under-reported budget trace fails the semantic native audit', async (t) => {
|
|
200
|
-
const f = setup(t);
|
|
201
|
-
await execute(f);
|
|
202
|
-
const path = join(f.directory, '_budget.jsonl'), rows = readFileSync(path, 'utf8').trim().split('\n').map(line => JSON.parse(line));
|
|
203
|
-
rows[1].state.metrics.input.knownTotal = 0;
|
|
204
|
-
writeFileSync(path, rows.map(row => JSON.stringify(row)).join('\n') + '\n');
|
|
205
|
-
const indexPath = join(f.directory, '_artifacts.json'), index = JSON.parse(readFileSync(indexPath, 'utf8'));
|
|
206
|
-
index.files['_budget.jsonl'] = sha256File(path);
|
|
207
|
-
writeFileSync(indexPath, JSON.stringify(index, null, 2) + '\n');
|
|
208
|
-
const result = await reportEvalComponent(f.directory);
|
|
209
|
-
assert.equal(result.evidence.verified, false);
|
|
210
|
-
assert.match(result.evidence.reasons.join(' '), /Budget after-call/);
|
|
211
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
212
|
-
});
|
|
213
|
-
test('changed stop lines invalidate a preview and cannot silently increase the approved budget', async (t) => {
|
|
214
|
-
const f = setup(t), preview = await runEvalComponent(f.request, { ...f.options, dryRun: true });
|
|
215
|
-
assert.ok('plan' in preview);
|
|
216
|
-
writeFileSync(f.request, JSON.stringify({ ...f.body, spendingBudget: { ...limits, input: 2000 } }));
|
|
217
|
-
await assert.rejects(runEvalComponent(f.request, { ...f.options, dryRun: false, expectedPlanSha256: preview.plan.sha256 }), /changed/);
|
|
218
|
-
assert.equal(f.calls(), 0);
|
|
219
|
-
assert.equal(existsSync(f.directory), false);
|
|
220
|
-
});
|
|
221
|
-
test('call ceiling remains independent and old request normalization omits the new optional field', async (t) => {
|
|
222
|
-
const f = setup(t);
|
|
223
|
-
const { spendingBudget: _unused, ...old } = f.body;
|
|
224
|
-
assert.equal(Object.hasOwn(parseEvalRequest(old, f.root), 'spendingBudget'), false);
|
|
225
|
-
writeFileSync(f.request, JSON.stringify({ ...f.body, maxCalls: 3 }));
|
|
226
|
-
await assert.rejects(runEvalComponent(f.request, { ...f.options, dryRun: true }), /exceeding --max-calls/);
|
|
227
|
-
assert.equal(f.calls(), 0);
|
|
228
|
-
});
|
|
229
|
-
test('a stop line reached only by the final declared call permits no extra call and preserves a complete cohort', async (t) => {
|
|
230
|
-
const f = setup(t, { input: 40 }), result = await execute(f);
|
|
231
|
-
assert.equal(f.calls(), 4);
|
|
232
|
-
assert.equal(result.status, 'completed');
|
|
233
|
-
assert.ok('spendingBudget' in result);
|
|
234
|
-
assert.ok(result.spendingBudget);
|
|
235
|
-
assert.deepEqual(result.spendingBudget.latestState.reached, ['input']);
|
|
236
|
-
assert.equal(result.evidence.verified, true);
|
|
237
|
-
});
|