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,7 +1,7 @@
1
1
  import { execFileSync } from 'node:child_process';
2
2
  import { appendFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readlinkSync, readdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
3
3
  import { homedir } from 'node:os';
4
- import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
4
+ import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { getAgent } from '../agents.js';
7
7
  import { parseFrontmatter } from '../frontmatter.js';
@@ -13,6 +13,7 @@ import { freezeInputSnapshot, verifyInputSnapshot } from './input-snapshot.js';
13
13
  import { loadBench } from './bench.js';
14
14
  import { globalSkillRoots } from './agent-preflight.js';
15
15
  import { spendingStopFrom } from './eval-budget.js';
16
+ import { assertEvaluationOutputLayout, physicalPath } from './evaluation-layout.js';
16
17
  function skillInventory(root) {
17
18
  if (!existsSync(root))
18
19
  return { root, entries: ['missing'] };
@@ -40,15 +41,6 @@ function inside(root, path) {
40
41
  return false;
41
42
  return !rel.startsWith(`..${sep}`) && rel !== '..' && !rel.startsWith(sep);
42
43
  }
43
- function physicalPath(path) {
44
- let parent = resolve(path);
45
- const parts = [];
46
- while (!existsSync(parent)) {
47
- parts.unshift(basename(parent));
48
- parent = dirname(parent);
49
- }
50
- return join(realpathSync(parent), ...parts);
51
- }
52
44
  function filesUnder(root, exclude) {
53
45
  const out = [];
54
46
  const walk = (rel) => {
@@ -187,10 +179,8 @@ export class ExperimentSession {
187
179
  this.trustWorkspaces = [...new Set([...this.workspaces, ...this.workspaceAliases.map(alias => alias.physical)])];
188
180
  if (existsSync(this.groupDir))
189
181
  throw new Error(`Run group directory already exists: ${this.groupDir}`);
190
- for (const input of [options.target.sourceDir, ...(options.baselineTarget ? [options.baselineTarget.sourceDir] : []), ...options.bench.tasks.map(task => join(options.bench.dir, task.fixture))]) {
191
- if (inside(physicalPath(input), physicalPath(this.groupDir)))
192
- throw new Error('Experiment output must be outside the Skill/overlay and fixture inputs; run the CLI from their parent directory.');
193
- }
182
+ assertEvaluationOutputLayout(this.groupDir, { benchDir: options.bench.dir,
183
+ targetDirs: [options.target.sourceDir, ...(options.baselineTarget ? [options.baselineTarget.sourceDir] : [])] });
194
184
  const packageRoot = fileURLToPath(new URL('../../', import.meta.url));
195
185
  this.inputs = [pin('bench', options.bench.dir, this.groupDir), pin('target', options.target.sourceDir), pin('implementation', join(packageRoot, 'dist'))];
196
186
  for (const metadata of [options.details['component'], options.details['reviewedPlan']])
@@ -269,7 +259,7 @@ export class ExperimentSession {
269
259
  try {
270
260
  this.inputSnapshot = freezeInputSnapshot(this.groupDir, this.inputs, this.guardFiles);
271
261
  if (loadBench(join(this.groupDir, '_inputs/bench')).contentSha256 !== options.bench.contentSha256)
272
- throw new Error('Sealed bench does not match the planned content hash; keep Git metadata and run outputs outside bench inputs.');
262
+ throw new Error('Sealed bench does not match the planned content hash; input bytes changed before sealing.');
273
263
  for (const input of this.inputs)
274
264
  if (pin(input.label, input.root, input.exclude).sha256 !== input.sha256)
275
265
  throw new Error(`Frozen ${input.label} input changed while sealing snapshots.`);
@@ -7,10 +7,12 @@ export function sha256Text(text) {
7
7
  export function sha256File(path) {
8
8
  return createHash('sha256').update(readFileSync(path)).digest('hex');
9
9
  }
10
- export function listFilesRecursive(rootDir) {
10
+ export function listFilesRecursive(rootDir, options = {}) {
11
11
  const out = [];
12
12
  const walk = (rel) => {
13
13
  for (const entry of readdirSync(join(rootDir, rel), { withFileTypes: true })) {
14
+ if (options.excludeGitMetadata && entry.name === '.git')
15
+ continue;
14
16
  const childRel = rel ? `${rel}/${entry.name}` : entry.name;
15
17
  if (entry.isDirectory()) {
16
18
  walk(childRel);
@@ -22,6 +22,7 @@ import { createSpendingBudgetRecorder, parseSpendingBudget } from './eval-budget
22
22
  import { summarizeInvocationCosts } from './invocation-costs.js';
23
23
  import { parseCommand } from './command.js';
24
24
  import { verifierRuntimeError } from './verifier-error.js';
25
+ import { parseVerifierTimeoutSeconds } from './verifier-timeout.js';
25
26
  function applyOverlay(overlayDir, runDir) {
26
27
  for (const rel of listFilesRecursive(overlayDir)) {
27
28
  const destination = join(runDir, rel);
@@ -29,7 +30,6 @@ function applyOverlay(overlayDir, runDir) {
29
30
  cpSync(join(overlayDir, rel), destination);
30
31
  }
31
32
  }
32
- const VERIFIER_TIMEOUT_MS = 2 * 60 * 1000;
33
33
  const MAX_PROCESS_OUTPUT_BYTES = 8 * 1024 * 1024;
34
34
  function runProcess(command, args, cwd, timeoutMs) {
35
35
  const signal = evaluationSignal();
@@ -265,7 +265,7 @@ export async function runTrial(plan, taskId, condition, trial) {
265
265
  let score = null;
266
266
  let checks = null;
267
267
  if (error === null) {
268
- const verifier = await runVerifier(bench.dir, task.verifier, runDir);
268
+ const verifier = await runVerifier(bench.dir, task.verifier, runDir, task.verifierTimeoutSeconds);
269
269
  verifierExitCode = verifier.exitCode;
270
270
  writeFileSync(join(runDir, '_verifier.txt'), verifierLogFor(verifier), 'utf8');
271
271
  if (verifier.error !== null || verifier.exitCode === null) {
@@ -324,7 +324,8 @@ export async function runTrial(plan, taskId, condition, trial) {
324
324
  }, null, 2)}\n`, 'utf8');
325
325
  return record;
326
326
  }
327
- export async function runVerifier(benchDir, command, runDir) {
327
+ export async function runVerifier(benchDir, command, runDir, timeoutSeconds) {
328
+ const timeoutMs = parseVerifierTimeoutSeconds(timeoutSeconds) * 1000;
328
329
  let tokens;
329
330
  try {
330
331
  tokens = parseCommand(command);
@@ -332,7 +333,7 @@ export async function runVerifier(benchDir, command, runDir) {
332
333
  catch (error) {
333
334
  return { exitCode: null, output: '', error: `VERIFIER_COMMAND_ERROR: ${error.message}` };
334
335
  }
335
- const result = await runProcess(tokens[0], [...tokens.slice(1), runDir], benchDir, VERIFIER_TIMEOUT_MS);
336
+ const result = await runProcess(tokens[0], [...tokens.slice(1), runDir], benchDir, timeoutMs);
336
337
  return { ...result, error: result.error ?? verifierRuntimeError(result.output, result.exitCode, benchDir, runDir) };
337
338
  }
338
339
  export function verifierLogFor(result) {
@@ -349,7 +349,7 @@ export async function auditSingleArmEvaluation(runDir, options = {}) {
349
349
  const scratch = mkdtempSync(join(tmpdir(), 'skillfit-single-replay-'));
350
350
  try {
351
351
  cpSync(join(root, path), scratch, { recursive: true, filter: file => basename(file) !== '.git' });
352
- const grade = await runVerifier(bench.dir, task.verifier, scratch), verdict = verdictFromOutput(grade.output);
352
+ const grade = await runVerifier(bench.dir, task.verifier, scratch, task.verifierTimeoutSeconds), verdict = verdictFromOutput(grade.output);
353
353
  assert.equal(grade.error, null, `Replay verifier failed: ${grade.error}`);
354
354
  assert.notEqual(grade.exitCode, null);
355
355
  assert.equal(grade.exitCode === 0, r.passed, 'Replay task verdict differs from retained delivery.');
@@ -92,7 +92,7 @@ async function runTriggerTrial(plan, taskId, trial, installedSkill) {
92
92
  let score = null;
93
93
  let checks = null;
94
94
  if (error === null) {
95
- const verifier = await runVerifier(plan.bench.dir, task.verifier, runDir);
95
+ const verifier = await runVerifier(plan.bench.dir, task.verifier, runDir, task.verifierTimeoutSeconds);
96
96
  writeFileSync(join(runDir, '_verifier.txt'), verifierLogFor(verifier), 'utf8');
97
97
  if (verifier.error !== null || verifier.exitCode === null) {
98
98
  error = verifierFailure('verifier', task.verifier, verifier.error);
@@ -0,0 +1,8 @@
1
+ export const DEFAULT_VERIFIER_TIMEOUT_SECONDS = 120;
2
+ /** Kept separate from the model deadline: case checks and oracle commands use this limit. */
3
+ export function parseVerifierTimeoutSeconds(value = DEFAULT_VERIFIER_TIMEOUT_SECONDS) {
4
+ if (typeof value !== 'number' || !Number.isInteger(value) || value < 1 || value > 3600) {
5
+ throw new Error('verifierTimeoutSeconds must be an integer between 1 and 3600.');
6
+ }
7
+ return value;
8
+ }
@@ -0,0 +1,76 @@
1
+ import assert from 'node:assert/strict';
2
+ import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
3
+ import { tmpdir } from 'node:os';
4
+ import { join } from 'node:path';
5
+ import { test } from 'node:test';
6
+ import { loadBench } from './bench.js';
7
+ import { parseVerifierTimeoutSeconds } from './verifier-timeout.js';
8
+ import { runTrial, runVerifier } from './runner.js';
9
+ import { collectSkillBundle } from './bundle.js';
10
+ import { runTriggerExperiment } from './trigger.js';
11
+ import { runBenchCheck, runBenchInit } from '../commands/bench.js';
12
+ import { manageBench } from '../commands/bench-manage.js';
13
+ async function fixture(t) {
14
+ const root = mkdtempSync(join(tmpdir(), 'skillfit-verifier-deadline-'));
15
+ t.after(() => rmSync(root, { recursive: true, force: true }));
16
+ const bench = join(root, 'bench'), run = join(root, 'run'), skill = join(root, 'skill');
17
+ await runBenchInit({ dir: bench, yes: true, log: () => { } });
18
+ mkdirSync(run);
19
+ mkdirSync(skill);
20
+ writeFileSync(join(skill, 'SKILL.md'), '---\nname: timeout-skill\ndescription: Offline deadline regression.\n---\nCheck output.\n');
21
+ return { root, bench, run, skill, manifest: join(bench, 'bench.json') };
22
+ }
23
+ test('case deadlines validate, persist through editing, and keep the historical default when absent', async (t) => {
24
+ const f = await fixture(t), raw = JSON.parse(readFileSync(f.manifest, 'utf8'));
25
+ assert.equal(parseVerifierTimeoutSeconds(), 120);
26
+ assert.equal(loadBench(f.bench).tasks[0].verifierTimeoutSeconds, undefined);
27
+ for (const value of [0, -1, 1.2, 3601, '5', null]) {
28
+ raw.tasks[0].verifierTimeoutSeconds = value;
29
+ writeFileSync(f.manifest, JSON.stringify(raw));
30
+ assert.throws(() => loadBench(f.bench), /verifierTimeoutSeconds/);
31
+ }
32
+ raw.tasks[0].verifierTimeoutSeconds = 600;
33
+ writeFileSync(f.manifest, JSON.stringify(raw));
34
+ assert.equal(loadBench(f.bench).tasks[0].verifierTimeoutSeconds, 600);
35
+ manageBench({ dir: f.bench, taskId: 'example-task', action: 'edit', set: ['verifierTimeoutSeconds=900'], yes: true, log: () => { } });
36
+ assert.equal(loadBench(f.bench).tasks[0].verifierTimeoutSeconds, 900);
37
+ manageBench({ dir: f.bench, taskId: 'example-task', action: 'edit', unset: ['verifierTimeoutSeconds'], yes: true, log: () => { } });
38
+ assert.equal(loadBench(f.bench).tasks[0].verifierTimeoutSeconds, undefined);
39
+ });
40
+ test('a verifier uses its configured deadline and a longer deadline permits the same offline command', async (t) => {
41
+ const f = await fixture(t);
42
+ writeFileSync(join(f.bench, 'slow.mjs'), "setTimeout(()=>{console.log(JSON.stringify({passed:true}));},1500);");
43
+ const stopped = await runVerifier(f.bench, 'node slow.mjs', f.run, 1);
44
+ assert.equal(stopped.exitCode, null);
45
+ assert.match(stopped.error, /timed out after 1000ms/);
46
+ const completed = await runVerifier(f.bench, 'node slow.mjs', f.run, 5);
47
+ assert.equal(completed.exitCode, 0);
48
+ assert.equal(completed.error, null);
49
+ });
50
+ test('bench check uses the case deadline for oracle commands', async (t) => {
51
+ const f = await fixture(t), raw = JSON.parse(readFileSync(f.manifest, 'utf8'));
52
+ raw.tasks[0].verifierTimeoutSeconds = 1;
53
+ raw.tasks[0].oracle = 'node slow-oracle.mjs';
54
+ writeFileSync(join(f.bench, 'slow-oracle.mjs'), 'setTimeout(()=>process.exit(0),1500);');
55
+ writeFileSync(f.manifest, JSON.stringify(raw));
56
+ const report = await runBenchCheck({ dir: f.bench, log: () => { } });
57
+ assert.ok(report.checks.some(check => check.code === 'ORACLE' && check.status === 'FAIL' && check.message.includes('timed out after 1000ms')));
58
+ });
59
+ test('paired and trigger execution classify a case deadline as an ungraded error and retain usage', async (t) => {
60
+ const f = await fixture(t), raw = JSON.parse(readFileSync(f.manifest, 'utf8'));
61
+ raw.tasks[0].verifierTimeoutSeconds = 1;
62
+ raw.tasks[0].shouldTrigger = true;
63
+ raw.tasks[0].verifier = 'node slow.mjs';
64
+ writeFileSync(join(f.bench, 'slow.mjs'), 'setTimeout(()=>process.exit(0),1500);');
65
+ writeFileSync(f.manifest, JSON.stringify(raw));
66
+ const bench = loadBench(f.bench), skill = collectSkillBundle(f.skill, 'timeout-skill');
67
+ const executor = { describe: () => ({ kind: 'cli', model: 'injected-offline-stub' }), run: async () => ({ output: 'done', tokens: { input: 20, cachedInput: 5, output: 3 }, skillTriggered: true }) };
68
+ const paired = await runTrial({ bench, target: skill, executor, trials: 1, runsRoot: f.root, runGroup: 'paired' }, 'example-task', 'baseline', 1);
69
+ assert.equal(paired.verifierPassed, null);
70
+ assert.match(paired.error, /timed out after 1000ms/);
71
+ assert.equal(paired.tokens.input, 20);
72
+ await runTriggerExperiment({ bench, skill, executor, trials: 1, runsRoot: f.root, runGroup: 'trigger', skillInstallDir: 'skills' });
73
+ const trigger = JSON.parse(readFileSync(join(f.root, 'trigger/example-task/installed/trial-1/_result.json'), 'utf8'));
74
+ assert.match(trigger.error, /timed out after 1000ms/);
75
+ assert.equal(trigger.tokens.input, 20);
76
+ });
@@ -0,0 +1 @@
1
+ export const BACKUP_SUFFIX = '.skillfit-bak';
@@ -0,0 +1,112 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { constants, existsSync, promises as fs } from 'node:fs';
3
+ import * as path from 'node:path';
4
+ import { BACKUP_SUFFIX } from './constants.js';
5
+ /** Stage every write before replacing any target; rollback is best effort, not crash atomicity. */
6
+ export async function executeTransaction(files, validate) {
7
+ const staged = [];
8
+ try {
9
+ for (const file of files) {
10
+ await fs.mkdir(path.dirname(file.path), { recursive: true });
11
+ const suffix = `${process.pid}.${randomUUID()}`;
12
+ const tmp = `${file.path}.${suffix}.skillfit-staged`;
13
+ const restore = existsSync(file.path) ? `${file.path}.${suffix}.skillfit-restore` : null;
14
+ const entry = { target: file.path, tmp, restore, backedUp: null };
15
+ staged.push(entry);
16
+ if (restore)
17
+ await fs.copyFile(file.path, restore);
18
+ if (file.backup !== 'none') {
19
+ // Metadata may track the previous version; user content keeps the first original.
20
+ if (file.backup === 'previous') {
21
+ await fs.copyFile(file.path, file.path + BACKUP_SUFFIX);
22
+ entry.backedUp = file.path + BACKUP_SUFFIX;
23
+ }
24
+ else {
25
+ entry.backedUp = await backupOnce(file.path);
26
+ }
27
+ }
28
+ await fs.writeFile(tmp, file.content);
29
+ }
30
+ }
31
+ catch (error) {
32
+ const cleanupFailures = await cleanupStaged(staged);
33
+ throw transactionFailure(error, [], cleanupFailures);
34
+ }
35
+ const applied = [];
36
+ try {
37
+ for (const entry of staged) {
38
+ await fs.rename(entry.tmp, entry.target);
39
+ applied.push(entry);
40
+ }
41
+ await validate();
42
+ }
43
+ catch (error) {
44
+ const rollbackFailures = [];
45
+ const preserveRestores = new Set();
46
+ for (const entry of applied.reverse()) {
47
+ try {
48
+ if (entry.restore)
49
+ await fs.copyFile(entry.restore, entry.target);
50
+ else
51
+ await fs.rm(entry.target, { force: true });
52
+ }
53
+ catch (rollbackError) {
54
+ const recovery = entry.restore ? `recovery copy retained at ${entry.restore}` : 'new target remains; no previous file to restore';
55
+ rollbackFailures.push(`${entry.target}: ${rollbackError.message} (${recovery})`);
56
+ preserveRestores.add(entry.target);
57
+ }
58
+ }
59
+ const cleanupFailures = await cleanupStaged(staged, preserveRestores);
60
+ throw transactionFailure(error, rollbackFailures, cleanupFailures);
61
+ }
62
+ const cleanupFailures = await cleanupStaged(staged);
63
+ if (cleanupFailures.length > 0) {
64
+ throw new Error(`Install files were validated, but cleanup failed for ${cleanupFailures.join('; ')}`);
65
+ }
66
+ return staged.map(({ target, backedUp }) => ({ target, backedUp }));
67
+ }
68
+ function transactionFailure(error, rollbackFailures, cleanupFailures) {
69
+ if (rollbackFailures.length === 0 && cleanupFailures.length === 0)
70
+ return error;
71
+ const details = [`Install failed (${error instanceof Error ? error.message : String(error)})`];
72
+ if (rollbackFailures.length > 0) {
73
+ details.push(`rollback failed for ${rollbackFailures.join('; ')}`);
74
+ }
75
+ if (cleanupFailures.length > 0)
76
+ details.push(`cleanup failed for ${cleanupFailures.join('; ')}`);
77
+ return new Error(details.join('; '), { cause: error });
78
+ }
79
+ async function cleanupStaged(staged, preserveRestores = new Set()) {
80
+ const failures = [];
81
+ for (const entry of staged) {
82
+ const files = [entry.tmp];
83
+ if (entry.restore && !preserveRestores.has(entry.target))
84
+ files.push(entry.restore);
85
+ for (const file of files) {
86
+ try {
87
+ await fs.rm(file, { force: true });
88
+ }
89
+ catch (error) {
90
+ failures.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);
91
+ }
92
+ }
93
+ }
94
+ return failures;
95
+ }
96
+ /**
97
+ * Back up a file at most once. `.skillfit-bak` is a single slot, and the copy worth keeping is the
98
+ * user's pre-skillfit original: overwriting it on a later update would destroy the only copy of the
99
+ * content the suffix exists to protect. Returns the backup path when one was created, else null.
100
+ */
101
+ async function backupOnce(target) {
102
+ const backup = target + BACKUP_SUFFIX;
103
+ try {
104
+ await fs.copyFile(target, backup, constants.COPYFILE_EXCL);
105
+ return backup;
106
+ }
107
+ catch (error) {
108
+ if (error.code === 'EEXIST')
109
+ return null;
110
+ throw error;
111
+ }
112
+ }
package/docs/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # skillfit documentation
2
+
3
+ Start with your own task: create a case, check it offline, preview an evaluation,
4
+ then read and share its saved evidence. The bundled cases teach the format.
5
+
6
+ ## Start here
7
+
8
+ - [First real evaluation](first-real-eval.md): npm onboarding, prerequisites, call counts and interpreting results.
9
+ - [Case authoring](bench-authoring.md): turn a real failure into a fixture, verifier and reference repair.
10
+ - [Offline first-check example](reproducible-offline-example.md): dated checks you can reproduce without a model.
11
+ - [Bench format](../benches/README.md): manifests, files and self-containment requirements.
12
+
13
+ ## Build and manage cases
14
+
15
+ - [Case management](case-management.md): list, inspect, select, edit and unregister tasks.
16
+ - [Drafting records](bench-drafting.md): one confirmed drafting call and its retained costs/failures.
17
+ - [Verifier contract](verifier-contract.md): quoted commands, task failures and infrastructure errors.
18
+ - [Bench check JSON](bench-check-json.md): offline gate codes, diagnostics and exit codes.
19
+ - [Real OSS tasks](oss-task-evaluation.md): workspace inputs and independent acceptance checks.
20
+
21
+ ## Plan and run evaluations
22
+
23
+ - [Bounded workflow](experiment-workflow.md) and [shared planning](eval-planning.md): previews, confirmation, budgets and output groups.
24
+ - [Installed Skill evaluation](installed-skill-evaluation.md) and [revision comparisons](skill-revisions.md): complete Skill delivery and distinct baselines.
25
+ - [Rules and MCP experiments](config-experiments.md): project overlays and server discovery.
26
+ - [Agent environment preflight](eval-agent-preflight.md) and [case preflight](eval-case-preflight.md): failures, warnings and unknown evidence before spending.
27
+ - [Agent evaluation component](eval-component.md): request/result contracts and adoption policy.
28
+ - [Timing](eval-timing.md), [interruption](evaluation-interruption.md) and [sealed inputs](evaluation-input-snapshots.md): what a run retains and how it stops.
29
+
30
+ ## Read and reproduce results
31
+
32
+ - [Report types and states](evaluation-reports.md): paired, calibration and trigger evidence.
33
+ - [Cost accounting](eval-costs.md): invocation populations, cache partitions and unknown usage.
34
+ - [Metrics protocol](metrics.md): statistical verdicts and limits of claims.
35
+ - [Sharing results](sharing-results.md) and [portable replay](replay-packages.md): saved evidence, integrity and offline reproduction.
36
+ - [Historical archive restoration](archive-delivery.md) and [exact inventory](archive-inventory.md): explicit pinned downloads and offline workspaces.
37
+ - [Evidence index](../evidence/README.md): all dated public reports and their limits.
38
+ - [Debugging Skill study](skill-evaluation-evidence.md): current study status and cumulative accounting.
39
+
40
+ ## Configure agents
41
+
42
+ - [Selectable Codex setup](selectable-codex.md): choose pinned sources for particular tasks.
43
+ - [Portable Codex setup](portable-codex.md): move used Skills and global guidance between machines.
44
+ - [Codex source audit](codex-upstream-audit.md): source provenance and installation scope.
45
+
46
+ ## Develop and maintain
47
+
48
+ - [Architecture](architecture.md): workflows, module ownership, dependency and evidence boundaries.
49
+ - [Contributing](../CONTRIBUTING.md): development checks, bench submissions and evidence requirements.
50
+ - [Roadmap](growth-roadmap-2026-10.md): current product work and later decisions.
51
+ - [Changelog](../CHANGELOG.md) and [release records](releases/): versioned behavior and publication evidence.
52
+ - [Package contents](package-contents.md): retained offline inputs, external archives and package checks.
53
+ - [Trusted publishing](releases/trusted-publishing.md): release preparation and verification.
54
+ - [Experiment script navigation](../scripts/README.md): active utilities and fixed historical procedures.
55
+ - [Installation and archive delivery plan](plans/2026-10-20-install-transactions-and-archive-delivery.md): ordered tasks, actual progress and verification.
56
+ - [Previous cleanup plan](plans/2026-10-20-docs-architecture-cleanup.md): the preceding documentation and architecture work.
57
+
58
+ ## Historical work records
59
+
60
+ [Plans](plans/) describe the scope and observations of their dates. Publication
61
+ status belongs to the corresponding release record; study status belongs to its
62
+ maintained evidence index. Fixed evidence and replay inputs keep their original paths.
63
+
64
+ The [September 24 audit](audit-2026-09-24.md) and its [triage](audit-2026-09-24-triage.md)
65
+ are historical findings against their recorded commit, rather than a current issue list.
@@ -0,0 +1,86 @@
1
+ # skillfit architecture
2
+
3
+ skillfit has two main workflows: measure a configuration against task cases, and
4
+ inspect or install agent configuration. CLI adapters choose a workflow; the
5
+ measurement core owns evidence and interpretation. Runtime code uses Node built-ins.
6
+
7
+ ## Entry points and modules
8
+
9
+ | Area | Responsibility | Starting points |
10
+ | --- | --- | --- |
11
+ | CLI | Parse arguments, reject unsupported combinations and select a command | [cli](../src/cli.ts) |
12
+ | Evaluation commands | Prepare/confirm plans, preflight inputs and dispatch paired or single-arm work | [eval CLI](../src/commands/eval-cli.ts), [plans](../src/commands/eval-plan.ts), [component](../src/commands/eval-component.ts) |
13
+ | Measurement core | Load cases, run disposable workspaces, verify outcomes and retain costs/session evidence | [bench loader](../src/harness/bench.ts), [runner](../src/harness/runner.ts), [session](../src/harness/experiment-session.ts), [trigger](../src/harness/trigger.ts) |
14
+ | Reports and policy | Parse saved observations, audit receipts, render reports and assess adoption separately | [manifest parser](../src/harness/eval-manifest.ts), [report adapter](../src/commands/eval-report.ts), [audit](../src/harness/eval-audit.ts), [acceptance](../src/harness/eval-acceptance.ts) |
15
+ | Case authoring | Scaffold, capture, draft and check cases; manage manifest registrations | [bench commands](../src/commands/bench.ts), [offline checks](../src/harness/bench-check.ts), [diagnostics](../src/harness/bench-diagnostics.ts), [source capture](../src/commands/bench-source.ts), [drafting](../src/commands/bench-draft.ts), [management](../src/commands/bench-manage.ts) |
16
+ | Agent integration | Resolve matrix capabilities and execute via CLI/API/injected adapters | [matrix](../src/matrix/agents.json), [definitions](../src/agents.ts), [executors](../src/harness/executors/) |
17
+ | Configuration | Inspect local configuration; plan and apply selected profiles or portable bundles | [doctor](../src/commands/doctor.ts), [install](../src/commands/install.ts), [setup](../src/commands/setup.ts), [bundle export](../src/commands/bundle.ts) |
18
+ | Installation transaction | Stage ordered file writes, preserve backups, commit, validate and roll back failures | [transaction](../src/install/transaction.ts), [shared constants](../src/install/constants.ts) |
19
+ | MCP discovery | Handshake and inspect the tool catalog without invoking a tool | [probe](../src/mcp/probe.ts) |
20
+
21
+ ## Evaluation lifecycle
22
+
23
+ The preview resolves selected cases, target fingerprints, executor capabilities,
24
+ call ceilings and the output layout. It performs no verifier, oracle or model call.
25
+ Live dispatch checks the agent environment and case integrity, rechecks inputs,
26
+ then creates a fresh run with sealed inputs and a frozen plan.
27
+
28
+ The session tracks every invoked call, including failures, judges and partial
29
+ usage. Paired runs compare baseline/treatment; calibration measures baseline
30
+ difficulty; trigger runs measure Skill discovery. Saved reports audit original
31
+ evidence. Rendering and replay do not make a single-arm run a paired efficacy
32
+ study or turn unknown usage into zero. [Metrics](metrics.md), [planning](eval-planning.md)
33
+ and [cost accounting](eval-costs.md) define these contracts.
34
+
35
+ ## Dependency boundaries
36
+
37
+ Commands can depend on core functions and render their results. The core should
38
+ not import command adapters. Shared data parsing, diagnostics and policy belong
39
+ with their domain rather than a renderer. Agent-specific paths and capabilities
40
+ come from the matrix; no new command-local vendor path constants are needed.
41
+
42
+ Saved-manifest parsing lives in the core; audit and adoption policy use the same
43
+ parser as report adapters. `node scripts/check-architecture.mjs` verifies the
44
+ compiled runtime, including literal dynamic imports, for cycles and core-to-command
45
+ dependencies in both `harness/` and `install/`. This development check uses the existing TypeScript compiler and
46
+ adds no runtime dependency.
47
+
48
+ Offline case gates and their diagnostic model also live in the core. Eval
49
+ preflight calls that shared offline entry directly. The bench command keeps
50
+ loading/selection, calibration preparation, confirmation and CLI summaries;
51
+ calibration reuses the same gate implementation. Generated verifier templates
52
+ remain standalone programs rather than importing command modules.
53
+
54
+ ## Configuration writes and artifact writes
55
+
56
+ Actual user-configuration changes go through dry-run/planning, confirmation,
57
+ backup, write/validation and rollback on failure. Setup reuses the installer.
58
+ The command prepares ordered writes and validates profile content and lockfile
59
+ bytes. The independent `install/` transaction stages all files before committing,
60
+ then runs that validation callback. User backups retain the first original;
61
+ lockfile backups retain the previous version. Temporary restore copies retain
62
+ the immediately previous target for rollback. Cleanup attempts every file and
63
+ reports its failures alongside the initial error; failed rollbacks retain their
64
+ restore copies. This is best-effort rollback, not multi-file crash atomicity.
65
+
66
+ Setup delegates to the same command. Bundle export copies all active compiled
67
+ runtime modules, including `install/`, so relocated bundles use this transaction
68
+ without referring to the source checkout.
69
+
70
+ New benches, evaluation runs and replay exports instead use fresh destinations
71
+ and preserve collision checks. Verifiers execute against disposable fixture
72
+ copies. See [case management](case-management.md), [sealed inputs](evaluation-input-snapshots.md)
73
+ and [portable packages](replay-packages.md) for the distinct record contracts.
74
+
75
+ ## Active code and frozen evidence
76
+
77
+ `src/` is the active TypeScript implementation and `dist/` is its build output.
78
+ `evidence/artifacts/` contains fixed observations, archives and historical replay
79
+ implementations. Those copies are inputs to reproduction, not extra active
80
+ modules to refactor or include in an active dependency scan. Dated release recipes
81
+ and receipts retain their original versions too.
82
+
83
+ `runs/` is local evaluation output. The ignored private lab is outside development,
84
+ CI and package scans. Offline tests use injected executors and temporary roots;
85
+ see [contributing](../CONTRIBUTING.md) for the existing build/test commands and
86
+ [the documentation index](README.md) for the public contracts.
@@ -0,0 +1,83 @@
1
+ # Restore historical evidence archives
2
+
3
+ Starting with 0.13.0, the npm package keeps the frozen replay support files and a versioned catalog,
4
+ while the 19 compressed archives are fetched explicitly from a fixed Git
5
+ commit. Git checkouts still retain the original archives. Ordinary npm install,
6
+ CLI commands and evaluations never download them automatically.
7
+
8
+ These commands apply to 0.13.0. Published 0.12.0 still carries its archives
9
+ and does not include the new restore entry. From your project, install the
10
+ versioned package and invoke its restore tool:
11
+
12
+ ```bash
13
+ npm install --save-exact skillfit@0.13.0
14
+ node ./node_modules/skillfit/evidence/fetch-archives.mjs --list
15
+ node ./node_modules/skillfit/evidence/fetch-archives.mjs --all --output ./historical-evidence
16
+ node ./node_modules/skillfit/evidence/fetch-archives.mjs --all --output ./historical-evidence --yes
17
+ ```
18
+
19
+ `--list` shows stable IDs. Without `--yes`, restoration only prints its plan:
20
+ no network requests or filesystem writes. The output parent must already exist;
21
+ the output itself must be new and outside both the installed package and any
22
+ local archive source. An existing destination is always refused, even if empty.
23
+ Use one or more `--id <id>` options instead of `--all` for selected archives.
24
+ Every selection also copies the catalog's 1,583 shared support files (12,973,972 bytes): READMEs, indexes, reports, declarations, licensed inputs and frozen
25
+ source/runtime/scripts. Four historical macOS metadata files excluded by npm
26
+ are carried as hash-checked base64 support entries, preserving frozen indexes.
27
+ Aggregate procedures can require sibling archives;
28
+ choose `--all` to reproduce those procedures.
29
+
30
+ ## Once online, then offline
31
+
32
+ The default HTTPS source is the public repository at full commit
33
+ `56b4dc68e115475e197c6510c9cb2235a5ad2c62`. Each archive's exact byte count and
34
+ SHA-256 are checked against [the versioned catalog](../evidence/archive-catalog.v1.json).
35
+ Downloads reject redirects, have a 30-second deadline per archive and cannot
36
+ exceed the catalog size. Support files are also hash-checked. All selected
37
+ bytes are staged before publishing the new directory, with exclusive creation
38
+ and collision checks. Failed operations attempt to remove their temporary files;
39
+ cleanup preserves other files and reports any files it cannot remove.
40
+ It does not promise a crash-atomic multi-file publication.
41
+
42
+ When complete, the workspace contains the original repository-relative paths.
43
+ Keep it for later offline use; the tool never extracts or executes its archives.
44
+ Read each restored artifact's README, manually extract into a fresh directory,
45
+ and run only its documented offline replay. Historical live entry points are
46
+ retained records, not instructions to start new paid experiments.
47
+
48
+ To restore from a previous complete workspace or Git checkout without a network:
49
+
50
+ ```bash
51
+ node ./node_modules/skillfit/evidence/fetch-archives.mjs --all --output ./historical-evidence-copy --from ./historical-evidence --offline --yes
52
+ ```
53
+
54
+ The local root must contain the original `evidence/artifacts/...` paths. Local
55
+ files receive the same size/hash checks; missing or corrupt files fail without
56
+ network fallback. `--offline` requires `--from` and guarantees no network access.
57
+ Keep the installed package available for the frozen support allowlist.
58
+
59
+ If the fixed remote is unavailable, restoration fails and cleans up its staging
60
+ directory, reporting any cleanup failure. Retry explicitly after connectivity returns, or supply a previously
61
+ verified workspace/checkout via `--from`. There is no fallback to `main`, another
62
+ version or an unverified mirror. A catalog hash detects corruption; it does not
63
+ independently authenticate a modified npm package or replace normal source trust.
64
+
65
+ ## Historical compatibility and distribution
66
+
67
+ [The inventory](archive-inventory.md) records every original path, full digest,
68
+ replay entry and runtime requirement. The restoration tool needs Node >=22.
69
+ Historical recipes keep their recorded requirements: several require Node
70
+ 24.21.0 or built-in TypeScript support, and their POSIX shell commands/verifiers
71
+ are not a new Windows compatibility claim. Saved failures must reproduce their
72
+ original grades; restoration does not promote a rejected or inconclusive Skill.
73
+
74
+ This distribution change starts with 0.13.0. Published 0.12.0 archives, dated
75
+ reports, release receipts and recipes are unchanged. See the
76
+ [0.13.0 release record](releases/0.13.0.md) for publication and verification status.
77
+
78
+ The independent installed-package check is
79
+ [archive-delivery-smoke.mjs](releases/archive-delivery-smoke.mjs). Run it with
80
+ the installed package path, a local archive source root and a fresh output
81
+ parent. It checks all restored bytes, preview purity and destination collision
82
+ protection, without network or model calls. It supplements each version's
83
+ feature recipe; it does not establish registry publication.