skillfit 0.11.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.
Files changed (172) hide show
  1. package/README.md +68 -104
  2. package/README.zh-CN.md +68 -101
  3. package/benches/README.md +6 -2
  4. package/dist/cli.js +28 -16
  5. package/dist/commands/bench-calibration.js +5 -1
  6. package/dist/commands/bench-check-report.js +1 -34
  7. package/dist/commands/bench-draft.js +167 -0
  8. package/dist/commands/bench-draft.test.js +168 -0
  9. package/dist/commands/bench-manage.js +5 -4
  10. package/dist/commands/bench-source.js +101 -0
  11. package/dist/commands/bench-source.test.js +84 -0
  12. package/dist/commands/bench.js +157 -328
  13. package/dist/commands/eval-api-failure.test.js +46 -0
  14. package/dist/commands/eval-layout.test.js +126 -0
  15. package/dist/commands/eval-preflight-error.js +9 -0
  16. package/dist/commands/eval-preflight.js +4 -11
  17. package/dist/commands/eval-report.js +6 -459
  18. package/dist/commands/eval.js +7 -32
  19. package/dist/commands/install.js +14 -98
  20. package/dist/harness/agent-preflight.js +18 -2
  21. package/dist/harness/bench-check.js +277 -0
  22. package/dist/harness/bench-diagnostics.js +34 -0
  23. package/dist/harness/bench-location.js +29 -0
  24. package/dist/harness/bench-location.test.js +33 -0
  25. package/dist/harness/bench.js +8 -3
  26. package/dist/harness/eval-acceptance.js +1 -1
  27. package/dist/harness/eval-audit.js +2 -2
  28. package/dist/harness/eval-manifest.js +456 -0
  29. package/dist/harness/evaluation-layout.js +30 -0
  30. package/dist/harness/executors/api.js +20 -7
  31. package/dist/harness/executors/cli.js +15 -25
  32. package/dist/harness/experiment-session.js +5 -15
  33. package/dist/harness/hash.js +3 -1
  34. package/dist/harness/runner.js +5 -4
  35. package/dist/harness/single-arm-audit.js +1 -1
  36. package/dist/harness/trigger.js +1 -1
  37. package/dist/harness/verifier-timeout.js +8 -0
  38. package/dist/harness/verifier-timeout.test.js +76 -0
  39. package/dist/install/constants.js +1 -0
  40. package/dist/install/transaction.js +112 -0
  41. package/docs/README.md +65 -0
  42. package/docs/architecture.md +86 -0
  43. package/docs/archive-delivery.md +83 -0
  44. package/docs/archive-inventory.md +91 -0
  45. package/docs/bench-authoring.md +23 -3
  46. package/docs/bench-drafting.md +75 -0
  47. package/docs/case-management.md +12 -1
  48. package/docs/eval-agent-preflight.md +15 -2
  49. package/docs/eval-costs.md +28 -2
  50. package/docs/eval-planning.md +14 -0
  51. package/docs/evaluation-input-snapshots.md +20 -4
  52. package/docs/evaluation-reports.md +1 -1
  53. package/docs/first-real-eval.md +28 -3
  54. package/docs/growth-roadmap-2026-10.md +23 -18
  55. package/docs/package-contents.md +73 -0
  56. package/docs/plans/2026-10-17-workflow-foundations.md +37 -2
  57. package/docs/plans/2026-10-20-archive-replay-verification.json +125 -0
  58. package/docs/plans/2026-10-20-archive-source-verification.json +256 -0
  59. package/docs/plans/2026-10-20-delivery-verification.json +146 -0
  60. package/docs/plans/2026-10-20-docs-architecture-cleanup.md +233 -0
  61. package/docs/plans/2026-10-20-install-transactions-and-archive-delivery.md +233 -0
  62. package/docs/plans/2026-10-21-npm-0.13.0-release.md +41 -0
  63. package/docs/releases/0.11.0-ci-registry-install.json +130 -0
  64. package/docs/releases/0.11.0-feature-smoke.json +1576 -0
  65. package/docs/releases/0.11.0-local-attempt-1.json +24 -0
  66. package/docs/releases/0.11.0-local-attempt-1.log +19 -0
  67. package/docs/releases/0.11.0-local-registry-install.json +25 -0
  68. package/docs/releases/0.11.0-registry-metadata.json +33 -0
  69. package/docs/releases/0.11.0-signatures.txt +12 -0
  70. package/docs/releases/0.11.0-verification.json +95 -0
  71. package/docs/releases/0.11.0.md +54 -11
  72. package/docs/releases/0.12.0-attestation-check.json +22 -0
  73. package/docs/releases/0.12.0-attestations.json +155 -0
  74. package/docs/releases/0.12.0-ci-registry-install.json +90 -0
  75. package/docs/releases/0.12.0-feature-smoke.json +34 -0
  76. package/docs/releases/0.12.0-feature-smoke.mjs +73 -0
  77. package/docs/releases/0.12.0-foundations-smoke.json +1576 -0
  78. package/docs/releases/0.12.0-local-registry-install.json +75 -0
  79. package/docs/releases/0.12.0-preparation-attempt-1.json +22 -0
  80. package/docs/releases/0.12.0-registry-metadata.json +96 -0
  81. package/docs/releases/0.12.0-signatures.txt +6 -0
  82. package/docs/releases/0.12.0-verification.json +99 -0
  83. package/docs/releases/0.12.0.md +82 -0
  84. package/docs/releases/0.13.0-feature-smoke.mjs +114 -0
  85. package/docs/releases/0.13.0-preparation.json +102 -0
  86. package/docs/releases/0.13.0.md +61 -0
  87. package/docs/releases/archive-delivery-smoke.mjs +37 -0
  88. package/docs/reproducible-offline-example.md +1 -1
  89. package/docs/schemas/agent-preflight.schema.json +1 -1
  90. package/docs/verifier-contract.md +9 -0
  91. package/evidence/README.md +24 -1
  92. package/evidence/archive-catalog.v1.json +8044 -0
  93. package/evidence/fetch-archives.mjs +211 -0
  94. package/package.json +9 -2
  95. package/skills/skillfit/SKILL.md +25 -5
  96. package/dist/cli.test.js +0 -193
  97. package/dist/commands/bench-calibration.test.js +0 -237
  98. package/dist/commands/bench-check-json.test.js +0 -242
  99. package/dist/commands/bench-manage.test.js +0 -87
  100. package/dist/commands/bench.test.js +0 -1162
  101. package/dist/commands/bundle.test.js +0 -142
  102. package/dist/commands/calibration-cli.test.js +0 -145
  103. package/dist/commands/doctor.test.js +0 -280
  104. package/dist/commands/eval-agent-preflight.test.js +0 -245
  105. package/dist/commands/eval-export-modes.test.js +0 -350
  106. package/dist/commands/eval-export.test.js +0 -279
  107. package/dist/commands/eval-interruption.test.js +0 -238
  108. package/dist/commands/eval-preflight.test.js +0 -382
  109. package/dist/commands/eval-report.test.js +0 -367
  110. package/dist/commands/eval.test.js +0 -503
  111. package/dist/commands/evaluation-report.test.js +0 -243
  112. package/dist/commands/install.test.js +0 -555
  113. package/dist/commands/replay-cancellation.test.js +0 -105
  114. package/dist/commands/report.test.js +0 -110
  115. package/dist/commands/setup.test.js +0 -150
  116. package/dist/commands/upstream.test.js +0 -139
  117. package/dist/commands/workflow-entrypoints.test.js +0 -137
  118. package/dist/docs.test.js +0 -154
  119. package/dist/frontmatter.test.js +0 -49
  120. package/dist/harness/bench.test.js +0 -109
  121. package/dist/harness/bundle.test.js +0 -71
  122. package/dist/harness/codex-usage.test.js +0 -87
  123. package/dist/harness/costs.test.js +0 -92
  124. package/dist/harness/eval-budget.test.js +0 -237
  125. package/dist/harness/eval-component.test.js +0 -770
  126. package/dist/harness/eval-efficiency.test.js +0 -56
  127. package/dist/harness/execution-timing.test.js +0 -61
  128. package/dist/harness/executors/api.test.js +0 -136
  129. package/dist/harness/executors/cli.test.js +0 -510
  130. package/dist/harness/executors/mock.test.js +0 -43
  131. package/dist/harness/experiment-session.test.js +0 -317
  132. package/dist/harness/installed-skill.test.js +0 -162
  133. package/dist/harness/interruption.test.js +0 -31
  134. package/dist/harness/judge-accounting.test.js +0 -216
  135. package/dist/harness/judge.test.js +0 -181
  136. package/dist/harness/kimi-usage.test.js +0 -62
  137. package/dist/harness/native-diff.test.js +0 -53
  138. package/dist/harness/oss-lru-cache.test.js +0 -79
  139. package/dist/harness/oss-normalize-url.test.js +0 -64
  140. package/dist/harness/oss-regression-witness.test.js +0 -89
  141. package/dist/harness/oss-skill-followup.test.js +0 -59
  142. package/dist/harness/prompt.test.js +0 -48
  143. package/dist/harness/receipts.test.js +0 -148
  144. package/dist/harness/report.test.js +0 -297
  145. package/dist/harness/runner.test.js +0 -635
  146. package/dist/harness/skill-revision.test.js +0 -148
  147. package/dist/harness/stats.test.js +0 -124
  148. package/dist/harness/target.test.js +0 -60
  149. package/dist/harness/trigger.test.js +0 -261
  150. package/dist/harness/verifier-summary.test.js +0 -99
  151. package/dist/harness/verifier.test.js +0 -128
  152. package/dist/harness/waza-behavior.test.js +0 -139
  153. package/dist/mcp/probe.test.js +0 -139
  154. package/evidence/artifacts/2026-10-12-diagnosing-revision/calibration-records.tar.gz +0 -0
  155. package/evidence/artifacts/2026-10-12-diagnosing-revision/interrupted-records.tar.gz +0 -0
  156. package/evidence/artifacts/2026-10-12-diagnosing-revision/validation-records.tar.gz +0 -0
  157. package/evidence/artifacts/2026-10-12-diagnosing-v2/regression-records.tar.gz +0 -0
  158. package/evidence/artifacts/2026-10-12-diagnosing-v2/transfer-records.tar.gz +0 -0
  159. package/evidence/artifacts/2026-10-12-normalize-url-v2-available/readiness-records.tar.gz +0 -0
  160. package/evidence/artifacts/2026-10-12-normalize-url-v2-comparison/records.tar.gz +0 -0
  161. package/evidence/artifacts/2026-10-12-normalize-url-v2-recovery/records.tar.gz +0 -0
  162. package/evidence/artifacts/2026-10-12-normalize-url-v2-validated/records.tar.gz +0 -0
  163. package/evidence/artifacts/2026-10-13-debugging-completed-development/package.tar.gz +0 -0
  164. package/evidence/artifacts/2026-10-13-debugging-controls-and-sleep-stop/package.tar.gz +0 -0
  165. package/evidence/artifacts/2026-10-13-debugging-development-stops/package.tar.gz +0 -0
  166. package/evidence/artifacts/2026-10-14-debugging-followup-routing-stop/package.tar.gz +0 -0
  167. package/evidence/artifacts/2026-10-14-debugging-independent-validation/package.tar.gz +0 -0
  168. package/evidence/artifacts/2026-10-14-debugging-reading-pilot-and-cost-review/package.tar.gz +0 -0
  169. package/evidence/artifacts/2026-10-14-debugging-spending-stop/package.tar.gz +0 -0
  170. package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/package.tar.gz +0 -0
  171. package/evidence/artifacts/2026-10-15-native-diff-mechanism/package.tar.gz +0 -0
  172. 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
- });