skillfit 0.11.0 → 0.12.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 (61) hide show
  1. package/README.md +28 -5
  2. package/README.zh-CN.md +28 -5
  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-draft.js +167 -0
  7. package/dist/commands/bench-draft.test.js +168 -0
  8. package/dist/commands/bench-manage.js +5 -4
  9. package/dist/commands/bench-source.js +101 -0
  10. package/dist/commands/bench-source.test.js +84 -0
  11. package/dist/commands/bench.js +165 -103
  12. package/dist/commands/bench.test.js +7 -3
  13. package/dist/commands/eval-agent-preflight.test.js +24 -0
  14. package/dist/commands/eval-api-failure.test.js +46 -0
  15. package/dist/commands/eval-cli-usage.test.js +75 -0
  16. package/dist/commands/eval-interruption.test.js +26 -1
  17. package/dist/commands/eval-layout.test.js +126 -0
  18. package/dist/commands/eval.js +7 -32
  19. package/dist/commands/npm-first-run.test.js +74 -0
  20. package/dist/harness/agent-preflight.js +18 -2
  21. package/dist/harness/bench-location.js +29 -0
  22. package/dist/harness/bench-location.test.js +33 -0
  23. package/dist/harness/bench.js +8 -3
  24. package/dist/harness/eval-audit.js +1 -1
  25. package/dist/harness/evaluation-layout.js +30 -0
  26. package/dist/harness/executors/api.js +20 -7
  27. package/dist/harness/executors/api.test.js +39 -0
  28. package/dist/harness/executors/cli.js +15 -25
  29. package/dist/harness/executors/cli.test.js +33 -2
  30. package/dist/harness/experiment-session.js +5 -15
  31. package/dist/harness/hash.js +3 -1
  32. package/dist/harness/runner.js +5 -4
  33. package/dist/harness/single-arm-audit.js +1 -1
  34. package/dist/harness/trigger.js +1 -1
  35. package/dist/harness/verifier-timeout.js +8 -0
  36. package/dist/harness/verifier-timeout.test.js +76 -0
  37. package/docs/bench-authoring.md +23 -3
  38. package/docs/bench-drafting.md +75 -0
  39. package/docs/case-management.md +12 -1
  40. package/docs/eval-agent-preflight.md +15 -2
  41. package/docs/eval-costs.md +28 -2
  42. package/docs/eval-planning.md +14 -0
  43. package/docs/evaluation-input-snapshots.md +20 -4
  44. package/docs/first-real-eval.md +28 -3
  45. package/docs/growth-roadmap-2026-10.md +23 -14
  46. package/docs/plans/2026-10-17-workflow-foundations.md +37 -2
  47. package/docs/releases/0.11.0-ci-registry-install.json +130 -0
  48. package/docs/releases/0.11.0-feature-smoke.json +1576 -0
  49. package/docs/releases/0.11.0-local-attempt-1.json +24 -0
  50. package/docs/releases/0.11.0-local-attempt-1.log +19 -0
  51. package/docs/releases/0.11.0-local-registry-install.json +25 -0
  52. package/docs/releases/0.11.0-registry-metadata.json +33 -0
  53. package/docs/releases/0.11.0-signatures.txt +12 -0
  54. package/docs/releases/0.11.0-verification.json +95 -0
  55. package/docs/releases/0.11.0.md +54 -11
  56. package/docs/releases/0.12.0-feature-smoke.mjs +73 -0
  57. package/docs/releases/0.12.0.md +68 -0
  58. package/docs/schemas/agent-preflight.schema.json +1 -1
  59. package/docs/verifier-contract.md +9 -0
  60. package/package.json +1 -1
  61. package/skills/skillfit/SKILL.md +25 -5
@@ -1,3 +1,4 @@
1
+ import { ExecutorFailure } from '../types.js';
1
2
  import { evaluationSignal } from '../interruption.js';
2
3
  function tokenCount(value) {
3
4
  return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined;
@@ -63,16 +64,28 @@ export class ApiExecutor {
63
64
  }),
64
65
  signal: interrupted ? AbortSignal.any([interrupted, AbortSignal.timeout(this.timeoutMs)]) : AbortSignal.timeout(this.timeoutMs),
65
66
  });
66
- if (!response.ok) {
67
- const body = (await response.text()).slice(0, 300);
68
- throw new Error(`API request failed with status ${response.status}: ${body}`);
67
+ const body = await response.text();
68
+ let data, parsed = false;
69
+ try {
70
+ const value = JSON.parse(body);
71
+ parsed = true;
72
+ if (value && typeof value === 'object' && !Array.isArray(value))
73
+ data = value;
69
74
  }
70
- const data = (await response.json());
71
- const content = data.choices?.[0]?.message?.content;
75
+ catch { /* Retain the public body; malformed JSON cannot establish usage. */ }
76
+ const content = data?.choices?.[0]?.message?.content;
77
+ const tokens = tokenUsage(data?.usage);
78
+ const failure = (message) => new ExecutorFailure(message, {
79
+ output: typeof content === 'string' ? content : '', rawOutput: body,
80
+ ...(tokens ? { tokens, usageStatus: 'final' } : {}),
81
+ });
82
+ if (!response.ok)
83
+ throw failure(`API request failed with status ${response.status}: ${body.slice(0, 300)}`);
84
+ if (!parsed)
85
+ throw failure('API response was not valid JSON');
72
86
  if (typeof content !== 'string') {
73
- throw new Error('API response did not contain choices[0].message.content');
87
+ throw failure('API response did not contain choices[0].message.content');
74
88
  }
75
- const tokens = tokenUsage(data.usage);
76
89
  return tokens ? { output: content, tokens } : { output: content };
77
90
  }
78
91
  }
@@ -3,6 +3,7 @@ import { test } from 'node:test';
3
3
  import { ApiExecutor } from './api.js';
4
4
  import { summarizeCosts } from '../costs.js';
5
5
  import { spendingBudgetState } from '../eval-budget.js';
6
+ import { ExecutorFailure } from '../types.js';
6
7
  function jsonResponse(body, status = 200) {
7
8
  return new Response(JSON.stringify(body), {
8
9
  status,
@@ -100,6 +101,44 @@ test('ApiExecutor throws when the payload has no message content', async () => {
100
101
  const executor = new ApiExecutor({ apiKey: 'k', fetchImpl });
101
102
  await assert.rejects(() => executor.run('hi', '/tmp'), /choices\[0\]/);
102
103
  });
104
+ test('API invalid content and HTTP errors retain reported final counters and public response', async () => {
105
+ for (const [content, status] of [[null, 200], [undefined, 200], [{ text: 'unsupported' }, 200], ['retained failed output', 500]]) {
106
+ let calls = 0;
107
+ const payload = { choices: [{ message: { content, refusal: 'synthetic refusal' } }],
108
+ usage: { prompt_tokens: 123, completion_tokens: 17, prompt_tokens_details: { cached_tokens: 23 } } };
109
+ const executor = new ApiExecutor({ apiKey: 'synthetic-key-not-in-evidence', fetchImpl: async () => { calls++; return jsonResponse(payload, status); } });
110
+ await assert.rejects(executor.run('offline'), error => {
111
+ assert.ok(error instanceof ExecutorFailure);
112
+ assert.equal(error.executorInvoked, true);
113
+ assert.deepEqual(error.result.tokens, { input: 123, cachedInput: 23, output: 17 });
114
+ assert.equal(error.result.usageStatus, 'final');
115
+ assert.equal(error.result.rawOutput, JSON.stringify(payload));
116
+ assert.equal(error.result.output, typeof content === 'string' ? content : '');
117
+ assert.equal(JSON.stringify(error.result).includes('synthetic-key-not-in-evidence'), false);
118
+ return true;
119
+ });
120
+ assert.equal(calls, 1);
121
+ }
122
+ });
123
+ test('malformed API payloads retain raw evidence without guessing missing usage', async () => {
124
+ for (const body of ['{broken JSON', 'null', '[]', '{"choices":[]}']) {
125
+ const executor = new ApiExecutor({ apiKey: 'offline-only', fetchImpl: async () => new Response(body) });
126
+ await assert.rejects(executor.run('offline'), error => {
127
+ assert.ok(error instanceof ExecutorFailure);
128
+ assert.equal(error.result.rawOutput, body);
129
+ assert.equal(error.result.tokens, undefined);
130
+ assert.equal(error.result.usageStatus, undefined);
131
+ return true;
132
+ });
133
+ }
134
+ const executor = new ApiExecutor({ apiKey: 'offline-only', fetchImpl: async () => jsonResponse({ choices: [], usage: { prompt_tokens: 12 } }) });
135
+ await assert.rejects(executor.run('offline'), error => {
136
+ assert.ok(error instanceof ExecutorFailure);
137
+ assert.deepEqual(error.result.tokens, { input: 12 });
138
+ assert.equal(error.result.usageStatus, 'final');
139
+ return true;
140
+ });
141
+ });
103
142
  test('ApiExecutor requires an API key', () => {
104
143
  assert.throws(() => new ApiExecutor(), /API key/);
105
144
  });
@@ -60,6 +60,7 @@ export class CliExecutor {
60
60
  sessions;
61
61
  homeDir;
62
62
  triggerSkillName;
63
+ streamJson;
63
64
  triggerToolName;
64
65
  projectTrustConfigArg;
65
66
  clock;
@@ -82,6 +83,7 @@ export class CliExecutor {
82
83
  this.sessions = options.sessions;
83
84
  this.homeDir = options.homeDir;
84
85
  this.triggerSkillName = options.triggerSkillName;
86
+ this.streamJson = options.streamJson ?? (options.triggerSkillName !== undefined);
85
87
  this.triggerToolName = options.triggerToolName ?? DEFAULT_TRIGGER_TOOL_NAME;
86
88
  this.projectTrustConfigArg = options.projectTrustConfigArg;
87
89
  this.clock = options.clock;
@@ -94,30 +96,16 @@ export class CliExecutor {
94
96
  if (opts?.trustProjectConfig && !projectTrustConfigArg) {
95
97
  throw new Error(`Agent "${agent.id}" has no project trust override in the matrix`);
96
98
  }
97
- if (opts?.triggerSkillName !== undefined) {
98
- const streamJson = headless.streamJson;
99
- if (!streamJson || streamJson.argv.length === 0) {
100
- throw new Error(`Agent "${agent.id}" has no headless streamJson command template; trigger detection is unavailable for it`);
101
- }
102
- return new CliExecutor({
103
- argv: streamJson.argv,
104
- label: agent.id,
105
- timeoutMs: opts.timeoutMs,
106
- promptVia: headless.promptVia,
107
- promptFile: headless.promptFile,
108
- usageFromSessionLog: headless.usageFromSessionLog ?? false,
109
- partialUsageFromSessionLog: headless.partialUsageFromSessionLog ?? false,
110
- sessions: agent.sessions,
111
- triggerSkillName: opts.triggerSkillName,
112
- triggerToolName: streamJson.triggerToolName,
113
- projectTrustConfigArg,
114
- });
99
+ const streamJson = headless.streamJson;
100
+ if (opts?.triggerSkillName !== undefined && !streamJson?.argv.length) {
101
+ throw new Error(`Agent "${agent.id}" has no headless streamJson command template; trigger detection is unavailable for it`);
115
102
  }
116
103
  if (!headless || headless.argv.length === 0) {
117
104
  throw new Error(`No default headless command template for agent "${agent.id}"`);
118
105
  }
119
106
  return new CliExecutor({
120
- argv: headless.argv,
107
+ argv: streamJson?.argv ?? headless.argv,
108
+ streamJson: streamJson !== undefined,
121
109
  label: agent.id,
122
110
  timeoutMs: opts?.timeoutMs,
123
111
  promptVia: headless.promptVia,
@@ -125,6 +113,8 @@ export class CliExecutor {
125
113
  usageFromSessionLog: headless.usageFromSessionLog ?? false,
126
114
  partialUsageFromSessionLog: headless.partialUsageFromSessionLog ?? false,
127
115
  sessions: agent.sessions,
116
+ triggerSkillName: opts?.triggerSkillName,
117
+ triggerToolName: streamJson?.triggerToolName,
128
118
  projectTrustConfigArg,
129
119
  });
130
120
  }
@@ -182,7 +172,7 @@ export class CliExecutor {
182
172
  let stopping = false;
183
173
  let drainTimer;
184
174
  const parseResult = () => ({
185
- ...(this.triggerSkillName !== undefined
175
+ ...(this.streamJson
186
176
  ? parseStreamJsonTranscript(stdout, this.triggerToolName, this.triggerSkillName)
187
177
  : { output: stdout }), executionTiming: deadline.snapshot(),
188
178
  });
@@ -280,7 +270,7 @@ export class CliExecutor {
280
270
  return;
281
271
  }
282
272
  if (code !== 0) {
283
- const detail = (this.triggerSkillName !== undefined ? terminalStreamError(stdout) : null)
273
+ const detail = (this.streamJson ? terminalStreamError(stdout) : null)
284
274
  ?? stderr.trim().slice(0, 500);
285
275
  rejectPromise(failure(`"${command}" exited with code ${code ?? 'null'}${detail ? `: ${detail}` : ''}`));
286
276
  return;
@@ -385,7 +375,7 @@ function parseStreamJsonTranscript(stdout, triggerToolName, skillName) {
385
375
  }
386
376
  const args = fnRecord.arguments;
387
377
  const argsText = typeof args === 'string' ? args : JSON.stringify(args ?? null);
388
- if (argsText.includes(skillName)) {
378
+ if (skillName !== undefined && argsText.includes(skillName)) {
389
379
  triggered = true;
390
380
  }
391
381
  }
@@ -409,7 +399,7 @@ function parseStreamJsonTranscript(stdout, triggerToolName, skillName) {
409
399
  }
410
400
  if (blockRecord.type === 'tool_use' &&
411
401
  blockRecord.name === triggerToolName &&
412
- JSON.stringify(blockRecord.input ?? null).includes(skillName)) {
402
+ skillName !== undefined && JSON.stringify(blockRecord.input ?? null).includes(skillName)) {
413
403
  triggered = true;
414
404
  }
415
405
  }
@@ -446,7 +436,7 @@ function parseStreamJsonTranscript(stdout, triggerToolName, skillName) {
446
436
  }
447
437
  if (itemRecord.type === 'command_execution' && typeof itemRecord.command === 'string') {
448
438
  const normalized = itemRecord.command.replace(/\\+/g, '/');
449
- if (normalized.includes(`skills/${skillName}/SKILL.md`)) {
439
+ if (skillName !== undefined && normalized.includes(`skills/${skillName}/SKILL.md`)) {
450
440
  triggered = true;
451
441
  }
452
442
  }
@@ -467,5 +457,5 @@ function parseStreamJsonTranscript(stdout, triggerToolName, skillName) {
467
457
  tokens = undefined;
468
458
  usageStatus = coverage.input === usageTurns && coverage.output === usageTurns ? 'final' : 'partial';
469
459
  }
470
- return { output: textParts.join('\n'), skillTriggered: triggered, rawOutput: stdout, tokens, usageStatus };
460
+ return { output: textParts.join('\n'), ...(skillName === undefined ? {} : { skillTriggered: triggered }), rawOutput: stdout, tokens, usageStatus };
471
461
  }
@@ -78,12 +78,12 @@ test('CliExecutor rejects when the command cannot be started', async () => {
78
78
  });
79
79
  await assert.rejects(() => executor.run('x', process.cwd()), /Failed to start/);
80
80
  });
81
- test('CliExecutor.forAgent uses the headless template from the agent matrix', () => {
81
+ test('CliExecutor.forAgent prefers the structured matrix template even without Skill detection', () => {
82
82
  for (const agentId of agentIds()) {
83
83
  const headless = getAgent(agentId).headless;
84
84
  assert.ok(headless.argv.length > 0, `${agentId} has no headless argv`);
85
85
  const executor = CliExecutor.forAgent(agentId);
86
- assert.equal(executor.describe().detail, `${agentId}: ${headless.argv.join(' ')}`);
86
+ assert.equal(executor.describe().detail, `${agentId}: ${(headless.streamJson?.argv ?? headless.argv).join(' ')}`);
87
87
  }
88
88
  });
89
89
  test('Codex paired and trigger runs both use a writable disposable workspace', () => {
@@ -97,8 +97,39 @@ test('Codex paired and trigger runs both use a writable disposable workspace', (
97
97
  assert.equal(argv[sandboxIndex + 1], 'workspace-write');
98
98
  }
99
99
  assert.match(paired ?? '', /--sandbox workspace-write/);
100
+ assert.match(paired ?? '', /--json/);
100
101
  assert.match(trigger ?? '', /--sandbox workspace-write/);
101
102
  });
103
+ test('ordinary structured output retains counters without inventing a Skill detection', async () => {
104
+ const executor = new CliExecutor({ argv: [process.execPath, '-e', PASSTHROUGH_SCRIPT], shell: false, streamJson: true });
105
+ const transcript = toNdjson([
106
+ { type: 'item.completed', item: { type: 'agent_message', text: 'A normal answer.' } },
107
+ { type: 'turn.completed', usage: { input_tokens: 123, cached_input_tokens: 23, output_tokens: 17 } },
108
+ { type: 'turn.completed', usage: { input_tokens: 10, cached_input_tokens: 0, output_tokens: 2 } },
109
+ ]);
110
+ const result = await executor.run(transcript, process.cwd());
111
+ assert.equal(result.output, 'A normal answer.');
112
+ assert.equal(result.rawOutput, transcript);
113
+ assert.deepEqual(result.tokens, { input: 133, cachedInput: 23, output: 19 });
114
+ assert.equal(result.usageStatus, 'final');
115
+ assert.equal(result.skillTriggered, undefined);
116
+ });
117
+ test('ordinary structured failure retains public counters and diagnostics without a trigger target', async () => {
118
+ const transcript = toNdjson([
119
+ { type: 'turn.completed', usage: { input_tokens: 123, cached_input_tokens: 23, output_tokens: 17 } },
120
+ { type: 'turn.failed', error: { message: 'synthetic stream failure' } },
121
+ ]);
122
+ const executor = new CliExecutor({ argv: [process.execPath, '-e', PASSTHROUGH_SCRIPT + ';process.on("beforeExit",()=>process.exitCode=1)'], shell: false, streamJson: true });
123
+ await assert.rejects(executor.run(transcript, process.cwd()), error => {
124
+ assert.ok(error instanceof ExecutorFailure);
125
+ assert.match(error.message, /synthetic stream failure/);
126
+ assert.deepEqual(error.result.tokens, { input: 123, cachedInput: 23, output: 17 });
127
+ assert.equal(error.result.usageStatus, 'partial');
128
+ assert.equal(error.result.rawOutput, transcript);
129
+ assert.equal(error.result.skillTriggered, undefined);
130
+ return true;
131
+ });
132
+ });
102
133
  test('CliExecutor.forAgent kimi-code passes the prompt as a -p file reference', () => {
103
134
  const headless = getAgent('kimi-code').headless;
104
135
  assert.equal(headless.promptVia, 'file');
@@ -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
+ });
@@ -119,15 +119,24 @@ skillfit bench init my-bench
119
119
  cd /path/to/where/it/broke
120
120
  skillfit bench add ../my-bench --freeze --task review-r1 \
121
121
  --prompt "Review CHANGES.diff against SPEC.md. Report only concrete defects: severity, exact file:line, one sentence on which clause of the spec it violates." \
122
+ --expect "INVALID_QUANTITY" \
122
123
  --should-trigger yes
123
124
  ```
124
125
 
125
- This snapshots the **git-tracked** files of the current directory into `fixtures/review-r1/`, so
126
- `node_modules`, build output and secrets stay out, writes the prompt to `prompts/review-r1.md` plus a
126
+ This snapshots the **git-tracked ordinary files** of the current directory into `fixtures/review-r1/`,
127
+ writes the prompt to `prompts/review-r1.md` plus a
127
128
  `prompts/review-r1.trigger.md` stub you will fix in step 5, and registers the task in `bench.json`.
128
129
  For a multi-paragraph prompt use `--prompt-file <path>` instead; the path is read relative to the
129
130
  current directory, and the *content* is copied into the bench.
130
131
 
132
+ In version 0.12.0, an empty index or a failed Git read is an error, never a
133
+ fallback to ignored/untracked files. Narrow a Git fixture with repeated `--include <file-or-dir>`;
134
+ outside Git these explicit selections are required. Git metadata and `node_modules` are excluded.
135
+ Selected symbolic links, submodules, non-ordinary entries and files inside the destination bench
136
+ are rejected before copying. Freeze imports are capped at 200 files / 1 MiB; narrow the selection
137
+ when it exceeds either limit. A tracked secret or a secret inside an explicitly selected non-Git
138
+ directory can still be included: review the selected files before sharing or authorizing a draft.
139
+
131
140
  Then shrink the fixture by hand. Keep the trap, delete the rest. `review-r1`'s is six small files —
132
141
  `SPEC.md`, `CHANGES.diff`, three source files and one test — totalling 4 KB.
133
142
 
@@ -158,6 +167,13 @@ for pass, non-zero for fail. Three ways to get one, cheapest first:
158
167
  --decompose --agent <id>
159
168
  ```
160
169
 
170
+ Version 0.12.0 confirms a drafting call **before** invoking an agent. Dry runs and declined
171
+ confirmations make zero calls. `--yes` authorizes exactly one call, without retry or automatic
172
+ evaluation/upgrade. Drafting supports `--max-calls`, `--spending-budget`,
173
+ `--executor-timeout-seconds`, `--runs-root` and `--run-group`. Predictable output conflicts are
174
+ checked before dispatch. Failed/interrupted drafts retain their available inputs, outputs, costs
175
+ and gate results. See [draft records and offline replay](bench-drafting.md).
176
+
161
177
  For anything you care about, write `verifiers/<task-id>.mjs` by hand. `review-r1`'s is
162
178
  `verifiers/seeded-bugs.mjs`, and it does two things:
163
179
 
@@ -194,7 +210,11 @@ Two rules that are easy to get wrong:
194
210
  **What the tool checks.** For an `output`-kind task, that the verifier rejects a missing `_output.md`
195
211
  and rejects an empty one — both FAIL, and together they are the NOP gate for tasks that grade text.
196
212
  Also that the check count is in range (WARN), and that the exit code and the JSON `passed` flag agree
197
- (WARN). It gets a 2-minute timeout, and a verifier that produces no exit code at all is reported as a
213
+ (WARN). Each verifier/oracle gets a default 2-minute timeout. Version 0.12.0 accepts
214
+ `verifierTimeoutSeconds` (integer 1–3600) per task; set it with
215
+ `bench add --verifier-timeout-seconds 600` or
216
+ `bench edit <dir> <task-id> --set verifierTimeoutSeconds=600 --yes`. This is separate from the model
217
+ executor deadline and also applies during preflight and offline replay. A verifier with no exit code is reported as a
198
218
  bench defect, never as the agent failing.
199
219
 
200
220
  > **The command in `bench.json` is spawned without a shell.** Its first token must be an executable the
@@ -0,0 +1,75 @@
1
+ # Author a verifier with one recorded drafting call
2
+
3
+ Available in skillfit 0.12.0. Drafting helps author a case; it is not evidence that a Skill
4
+ improves results. It does not run a comparison or authorize an upgrade.
5
+
6
+ ## Preview, then authorize
7
+
8
+ ```bash
9
+ skillfit bench add ./my-bench --freeze --source-dir ./failure --include src --include test \
10
+ --task real-failure --prompt-file issue.md --decompose --verifier-kind command --agent codex \
11
+ --max-calls 1 --executor-timeout-seconds 300 --verifier-timeout-seconds 600 \
12
+ --runs-root ./runs --run-group draft-real-failure --dry-run
13
+ ```
14
+
15
+ Preview validates the selected files, destination paths, record-directory layout, one-call ceiling
16
+ and deadlines. It creates no files and invokes no agent. Re-run without `--dry-run` to confirm,
17
+ or with `--yes` to authorize. Declining also makes zero calls. A record group that already exists
18
+ is never overwritten, including failed/interrupted groups. There is no retry or follow-up call.
19
+
20
+ Git imports select tracked ordinary files; an empty/broken index fails. Non-Git sources require
21
+ explicit `--include` selections. Selected links, non-files and destination-bench files are rejected.
22
+ Inputs, prompts and public outputs can contain private data: review records before sharing them.
23
+
24
+ Optional `--spending-budget budget.json` uses the existing five-field spending contract:
25
+
26
+ ```json
27
+ {
28
+ "input": 100000,
29
+ "cachedInput": 100000,
30
+ "uncachedInput": 100000,
31
+ "output": 10000,
32
+ "durationSeconds": 300
33
+ }
34
+ ```
35
+
36
+ All fields must be positive; token limits are integers. Known unsupported CLI counters block before
37
+ dispatch. Missing/partial final counters or executor errors stop a budgeted draft after retaining
38
+ available usage, without adding a task. These are observed stop lines, not provider-side prepaid
39
+ caps: one in-flight call can exceed a line. Reaching a line with complete final usage prevents more
40
+ calls but still permits the remaining offline gates. The executor deadline bounds model execution,
41
+ separately from the case's verifier/oracle deadline. Cancellation cannot establish that a remote
42
+ provider stopped billing. Without a budget, absent counters remain unknown, never zero. Login
43
+ remains unknown offline. Injected test executors are responsible for honoring their own deadlines.
44
+
45
+ ## Retained evidence
46
+
47
+ Each authorized draft claims a fresh record directory before dispatch:
48
+
49
+ | File | Meaning |
50
+ |---|---|
51
+ | `_plan.json` | `kind: skillfit.bench-draft-plan`, input hashes, executor, package/Node versions, deadlines/budgets, unknown authentication |
52
+ | `_inputs/fixture/`, `prompt.md` | Original selected bytes and exact drafting prompt |
53
+ | `workspace/` | Agent workspace, including generated verifier/oracle scripts when supplied |
54
+ | `_calls.jsonl` | Started/finished dispatch events; at most one call |
55
+ | `_result.json`, `_output.md`, optional `_transcript.jsonl` | Available public usage, final/partial/unknown status, duration, output and raw executor response; no request credential headers |
56
+ | `_budget.jsonl` | Before/after observations when a budget is set |
57
+ | `_gates.jsonl` | Untouched-fixture, oracle and solved-fixture results reached by this attempt |
58
+ | `_summary.json` | `kind: skillfit.bench-draft-result`; completed only after adding the task, otherwise stopped; observed costs/coverage, no automatic retry or upgrade |
59
+
60
+ `Ctrl+C` / `SIGTERM` stops the subprocess tree and seals available records as stopped. Interrupted
61
+ counters stay partial when that is all the executor can establish. Gates also observe cancellation;
62
+ an interrupted draft is not added. Force termination, machine or storage failure can prevent sealing.
63
+ A missing summary is not completion evidence.
64
+
65
+ ## Recheck the case offline
66
+
67
+ After adding a task, `skillfit bench check ./my-bench --json` repeats the NOP/oracle gates without
68
+ an agent. For a rejected draft that supplied both scripts, copy `_inputs/fixture/` to two fresh
69
+ scratch directories. From the saved `workspace/`, run `node verifier.mjs <untouched-copy>`, then
70
+ `node oracle.mjs <solved-copy>` and `node verifier.mjs <solved-copy>`, each with the recorded
71
+ per-command deadline. Compare output and exit codes with `_gates.jsonl`. Preserve original records.
72
+
73
+ This reproduces the case checks and accounting from retained counters, not unreported provider
74
+ usage, undisclosed settings or an identical future generation. Authoring records have their own
75
+ kind; `report eval` remains for evaluation records.
@@ -6,6 +6,15 @@ registration; use your editor to change the referenced file contents.
6
6
 
7
7
  ## Inspect and select
8
8
 
9
+ Version 0.12.0 accepts bundled names (for example `code-review`) in
10
+ read-only `bench check/list/show`, calibration planning and ordinary eval. These
11
+ share one resolver: a local manifest wins; an explicit or existing broken local
12
+ path fails instead of selecting a different bundled case. JSON includes the
13
+ resolved directory and its original content hash. With no path, `bench check`
14
+ still checks the current directory; eval retains its explicit-choice requirement
15
+ when several bundled benches exist. `init/add/edit/remove` continue to use local
16
+ directories; a bare bundled name cannot modify the installed package.
17
+
9
18
  ```bash
10
19
  skillfit bench list ./my-bench --json
11
20
  skillfit bench show ./my-bench fix-cache --json
@@ -47,7 +56,9 @@ Edits/removals default to a read-only before/after plan. `--yes` applies it;
47
56
  are rejected. Manifest writes validate the result and roll back on failure.
48
57
 
49
58
  Repeat `--set field=value` to edit `fixture`, `prompt`, `promptTrigger`, `verifier`,
50
- `verifierKind`, `oracle`, `rubric` or `shouldTrigger`. Values may contain `=`;
59
+ `verifierKind`, `oracle`, `rubric` or `shouldTrigger`. Version 0.12.0 also allows
60
+ `verifierTimeoutSeconds` (integer 1–3600, default 120), including `--unset` to restore the default.
61
+ It applies to each verifier/oracle process, separately from model execution. Values may contain `=`;
51
62
  `shouldTrigger` accepts only literal `true` or `false`. Repeat `--unset field` for
52
63
  `promptTrigger`, `oracle`, `rubric` or `shouldTrigger`. Required fields, task IDs,
53
64
  unknown fields and duplicate field operations are rejected. Referenced paths and