@skill-harness/cli 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.
package/README.md CHANGED
@@ -24,6 +24,7 @@ npm i -g @skill-harness/cli
24
24
  | `skill-harness grade <run-dir> [--judge p:m]` | re-grade saved transcripts |
25
25
  | `skill-harness review <skill> --skills <root> [--port N]` | serve the interactive review UI |
26
26
  | `skill-harness add-test <skill> --skills <root> --id ID --title T ...` | scaffold a new scenario |
27
+ | `skill-harness qualification prepare\|start\|status\|poll\|validate\|abort ...` | durable external-config qualification lifecycle |
27
28
 
28
29
  ## More
29
30
 
@@ -28,6 +28,7 @@ export function effective(cell) {
28
28
  // Mechanical evidence outranks a prose judge. Objective PASS deliberately
29
29
  // forces nothing — the checklist judge still decides the behavioral rubric.
30
30
  if (cell.objective && cell.objective.status === "ERROR") return "ERROR";
31
+ if (cell.objective && cell.objective.status === "NOT-MEASURED") return "NOT-MEASURED";
31
32
  if (cell.objective && cell.objective.status === "FAIL") return "FAIL";
32
33
  return cell.judge_verdict;
33
34
  }
@@ -53,6 +54,7 @@ export function gradeColumn(col, shipBar, critical) {
53
54
  let bFails = 0;
54
55
  let suspect = 0;
55
56
  let errors = 0;
57
+ let notMeasured = 0;
56
58
 
57
59
  for (const id of Object.keys(col.cells)) {
58
60
  const cell = col.cells[id];
@@ -62,6 +64,10 @@ export function gradeColumn(col, shipBar, critical) {
62
64
  continue; // excluded, blocks ship
63
65
  }
64
66
  const verdict = effective(cell);
67
+ if (verdict === "NOT-MEASURED") {
68
+ notMeasured++;
69
+ continue;
70
+ }
65
71
  if (verdict === "ERROR" || verdict === "JUDGE-AMBIGUOUS") {
66
72
  errors++;
67
73
  continue;
@@ -76,7 +82,7 @@ export function gradeColumn(col, shipBar, critical) {
76
82
  }
77
83
 
78
84
  if (col.partial === true) {
79
- return { passed: 0, total: 0, pct: 0, letter: "-", ship: false, criticalFails, bFails, suspect, errors };
85
+ return { passed: 0, total: 0, pct: 0, letter: "-", ship: false, criticalFails, bFails, suspect, errors, notMeasured };
80
86
  }
81
87
 
82
88
  const pct = total > 0 ? Math.round((passed * 100) / total) : 0;
@@ -89,9 +95,10 @@ export function gradeColumn(col, shipBar, critical) {
89
95
  (!shipBar.no_critical_fail || criticalFails === 0) &&
90
96
  bFails === 0 &&
91
97
  suspect === 0 &&
92
- errors === 0;
98
+ errors === 0 &&
99
+ notMeasured === 0;
93
100
 
94
- return { passed, total, pct, letter, ship, criticalFails, bFails, suspect, errors };
101
+ return { passed, total, pct, letter, ship, criticalFails, bFails, suspect, errors, notMeasured };
95
102
  }
96
103
 
97
104
  /**
@@ -107,7 +114,7 @@ export function gradeColumn(col, shipBar, critical) {
107
114
  */
108
115
  export function liftClass(liftCell, greenCell) {
109
116
  const conclusive = (verdict, suspect) =>
110
- !suspect && verdict !== "ERROR" && verdict !== "JUDGE-AMBIGUOUS";
117
+ !suspect && verdict !== "ERROR" && verdict !== "NOT-MEASURED" && verdict !== "JUDGE-AMBIGUOUS";
111
118
 
112
119
  const redOk = conclusive(liftCell.red, liftCell.redSuspect);
113
120
  const greenOk = conclusive(effective(greenCell), !!greenCell.suspect && !greenCell.override);
@@ -25,6 +25,7 @@
25
25
  .cell.PASS { background: rgba(31,139,76,.22); }
26
26
  .cell.FAIL { background: rgba(192,57,43,.24); }
27
27
  .cell.ERROR { background: rgba(107,114,128,.22); }
28
+ .cell.NOT-MEASURED { background: rgba(180,83,9,.18); }
28
29
  .cell.empty { color: var(--dim); cursor: default; font-weight: 400; }
29
30
  .cell .ov { display: block; font-size: 11px; color: var(--over); font-weight: 600; }
30
31
  .cell .ov.unsaved { color: #b45309; font-style: italic; }
@@ -49,7 +50,7 @@
49
50
  amber rather than red — missing evidence is not a failing gate. */
50
51
  .cell .lm.obj-pass { color: var(--pass); }
51
52
  .cell .lm.obj-fail { color: var(--fail); }
52
- .cell .lm.obj-error { color: #b45309; }
53
+ .cell .lm.obj-error, .cell .lm.obj-not-measured { color: #b45309; }
53
54
  /* Adjudication. `unresolved` is amber for the same reason `suspect` is: it must
54
55
  never read as a clean PASS or FAIL. */
55
56
  .cell .lm.adj-settled { color: var(--dim); }
@@ -94,6 +95,7 @@
94
95
  .tgrid td.tc.PASS { color: #16a34a; }
95
96
  .tgrid td.tc.FAIL { color: #dc2626; }
96
97
  .tgrid td.tc.ERROR { color: #a855f7; }
98
+ .tgrid td.tc.NOT-MEASURED { color: #b45309; }
97
99
  .tgrid td.tc.suspect { color: #b45309; }
98
100
  .tgrid td.tc.absent { color: var(--dim, #bbb); }
99
101
  .dim { color: var(--dim, #888); font-weight: 400; }
@@ -429,7 +431,7 @@ function sparkline(runs) {
429
431
  function renderTrends(data) {
430
432
  const box = document.getElementById("trends");
431
433
  if (!data.models.length) { box.innerHTML = `<div class="empty-state">No runs yet.</div>`; return; }
432
- const glyph = { PASS: "✓", FAIL: "✗", ERROR: "!" };
434
+ const glyph = { PASS: "✓", FAIL: "✗", ERROR: "!", "NOT-MEASURED": "∅" };
433
435
  let html = "";
434
436
  for (const m of data.models) {
435
437
  const last = m.runs[m.runs.length - 1].grade;
@@ -0,0 +1,3 @@
1
+ import type { Args } from './cli.js';
2
+ /** Explicit operator requests, not a scheduler or model route. The inert host cannot invoke this CLI. */
3
+ export declare function cmdArchiveLearning(args: Args): void;
@@ -0,0 +1,153 @@
1
+ import { constants, openSync, readSync, fstatSync, closeSync } from 'node:fs';
2
+ import { isAbsolute } from 'node:path';
3
+ import { createArchiveAccess, openArchiveAccess, readFixedOrderFacts, createWeeklyInvestigation, openWeeklyInvestigation, createTrustLifecycle, openTrustLifecycle } from '@skill-harness/adapters';
4
+ import { parseLearningRequest } from '@skill-harness/core';
5
+ /** Explicit operator requests, not a scheduler or model route. The inert host cannot invoke this CLI. */
6
+ export function cmdArchiveLearning(args) {
7
+ if (args._.length !== 1 || Object.keys(args.flags).sort().join() !== 'request,state' || typeof args.flags.state !== 'string' || !isAbsolute(args.flags.state) || typeof args.flags.request !== 'string')
8
+ throw Error('archive weekly|trust|access requires --state /absolute/directory --request file');
9
+ const fd = openSync(args.flags.request, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
10
+ let text;
11
+ try {
12
+ const stat = fstatSync(fd);
13
+ if (!stat.isFile() || stat.size > 65536)
14
+ throw Error('bounded regular learning request required');
15
+ const bytes = Buffer.alloc(65537);
16
+ let n = 0;
17
+ while (n < bytes.length) {
18
+ const k = readSync(fd, bytes, n, bytes.length - n, n);
19
+ if (!k)
20
+ break;
21
+ n += k;
22
+ }
23
+ if (n > 65536)
24
+ throw Error('learning request exceeds bound');
25
+ text = new TextDecoder('utf-8', { fatal: true }).decode(bytes.subarray(0, n));
26
+ }
27
+ finally {
28
+ closeSync(fd);
29
+ }
30
+ const request = parseLearningRequest(text);
31
+ if (Object.keys(request).sort().join() !== 'authority,input,operation')
32
+ throw Error('closed learning request required');
33
+ const input = request.input, authority = request.authority, state = args.flags.state;
34
+ let result;
35
+ if (args._[0] === 'access') {
36
+ if (request.operation === 'create')
37
+ result = createArchiveAccess(state, input, authority).inspect();
38
+ else {
39
+ const access = openArchiveAccess(state);
40
+ switch (request.operation) {
41
+ case 'inspect':
42
+ result = access.inspect();
43
+ break;
44
+ case 'preview-consent':
45
+ result = access.previewConsent(input);
46
+ break;
47
+ case 'consent': {
48
+ const p = input;
49
+ result = access.consent(p.grant, authority, p.now);
50
+ break;
51
+ }
52
+ case 'preview-revocation':
53
+ result = access.previewRevocation(input);
54
+ break;
55
+ case 'revoke': {
56
+ const p = input;
57
+ access.revoke(p.id, authority, p.now);
58
+ result = { recorded: true };
59
+ break;
60
+ }
61
+ case 'facts': {
62
+ const p = input;
63
+ result = readFixedOrderFacts(access.inspect().policy.archiveRoot, p.manifestId, { directory: state, purpose: p.purpose }, p.expected, p.now);
64
+ break;
65
+ }
66
+ default: throw Error('unsupported access operation; raw read/export is not a CLI operation');
67
+ }
68
+ }
69
+ }
70
+ else if (args._[0] === 'weekly') {
71
+ if (request.operation === 'create') {
72
+ result = createWeeklyInvestigation(state, input).inspect();
73
+ }
74
+ else {
75
+ const job = openWeeklyInvestigation(state);
76
+ switch (request.operation) {
77
+ case 'inspect':
78
+ result = job.inspect();
79
+ break;
80
+ case 'run':
81
+ result = job.run(request.input);
82
+ break;
83
+ case 'approve':
84
+ result = job.approve(authority);
85
+ break;
86
+ case 'preview': {
87
+ const p = request.input;
88
+ result = job.preview(p.specPath, p.scenario);
89
+ break;
90
+ }
91
+ case 'promote':
92
+ result = job.promote(input, authority);
93
+ break;
94
+ case 'freeze':
95
+ result = job.freeze(input, authority);
96
+ break;
97
+ case 'preview-edit':
98
+ result = job.previewEdit(input);
99
+ break;
100
+ case 'edit':
101
+ result = job.edit(input, authority);
102
+ break;
103
+ case 'evaluation':
104
+ result = job.evaluation();
105
+ break;
106
+ case 'preview-screen':
107
+ result = job.previewScreen(input);
108
+ break;
109
+ case 'screen':
110
+ result = job.screen(input, authority);
111
+ break;
112
+ default: throw Error('unsupported weekly operation');
113
+ }
114
+ }
115
+ }
116
+ else if (args._[0] === 'trust') {
117
+ if (request.operation === 'create') {
118
+ result = createTrustLifecycle(state, input, authority).inspect(0);
119
+ }
120
+ else {
121
+ const job = openTrustLifecycle(state);
122
+ switch (request.operation) {
123
+ case 'inspect':
124
+ result = job.inspect(input);
125
+ break;
126
+ case 'predict':
127
+ job.predict(input);
128
+ result = { recorded: true };
129
+ break;
130
+ case 'correct': {
131
+ const p = request.input;
132
+ job.correct(p.prior, p.prediction, p.reason);
133
+ result = { recorded: true };
134
+ break;
135
+ }
136
+ case 'outcome':
137
+ job.outcome(input, authority);
138
+ result = { recorded: true };
139
+ break;
140
+ case 'expose': {
141
+ const p = request.input;
142
+ result = job.expose(p.id, p.now);
143
+ break;
144
+ }
145
+ default: throw Error('unsupported trust operation');
146
+ }
147
+ }
148
+ }
149
+ else
150
+ throw Error('unsupported learning family');
151
+ console.log(JSON.stringify(result, null, 2));
152
+ }
153
+ //# sourceMappingURL=archive-learning.js.map
@@ -0,0 +1,3 @@
1
+ import type { Args } from "./cli.js";
2
+ /** Explicit file ingestion/metadata inspection only; never launches a worker or publishes content. */
3
+ export declare function cmdArchive(args: Args): Promise<void>;
@@ -0,0 +1,52 @@
1
+ import { ingestPolicySource, inspectPolicyCheckpoint, observeArchiveSource } from "@skill-harness/adapters";
2
+ import { cmdArchiveLearning } from "./archive-learning.js";
3
+ /** Explicit file ingestion/metadata inspection only; never launches a worker or publishes content. */
4
+ export async function cmdArchive(args) {
5
+ const operation = args._[0];
6
+ if (operation === "weekly" || operation === "trust" || operation === "access") {
7
+ cmdArchiveLearning(args);
8
+ return;
9
+ }
10
+ if (operation === "watch") {
11
+ if (args._.length !== 1 || Object.keys(args.flags).some(key => !["policy", "source", "previous", "interval-ms", "max-polls"].includes(key)))
12
+ throw new Error("unsupported archive watch option");
13
+ const required = (key) => { const value = args.flags[key]; if (typeof value !== "string" || !value)
14
+ throw new Error(`archive watch requires --${key}`); return value; };
15
+ const signal = new AbortController(), abort = () => signal.abort();
16
+ process.on("SIGINT", abort);
17
+ process.on("SIGTERM", abort);
18
+ try {
19
+ const result = await observeArchiveSource({ policyPath: required("policy"), sourceId: required("source"),
20
+ previousCheckpointId: args.flags.previous === undefined ? undefined : required("previous"),
21
+ intervalMs: args.flags["interval-ms"] === undefined ? 1000 : Number(required("interval-ms")), maxPolls: Number(required("max-polls")), signal: signal.signal,
22
+ onObservation: observation => console.log(JSON.stringify({ checkpointId: observation.checkpointId, policySha256: observation.policySha256, syntax: observation.syntax })),
23
+ });
24
+ console.log(JSON.stringify(result));
25
+ }
26
+ finally {
27
+ process.removeListener("SIGINT", abort);
28
+ process.removeListener("SIGTERM", abort);
29
+ }
30
+ return;
31
+ }
32
+ if (args._.length !== 1 || !["ingest", "inspect"].includes(operation)) {
33
+ throw new Error("usage: archive ingest|inspect --policy <file> --source <id> [--previous <checkpoint> | --checkpoint <id>]");
34
+ }
35
+ const allowed = operation === "ingest" ? ["policy", "source", "previous"] : ["policy", "source", "checkpoint"];
36
+ for (const key of Object.keys(args.flags))
37
+ if (!allowed.includes(key))
38
+ throw new Error(`unsupported archive option: ${key}`);
39
+ const required = (key) => {
40
+ const value = args.flags[key];
41
+ if (typeof value !== "string" || !value)
42
+ throw new Error(`archive requires --${key}`);
43
+ return value;
44
+ };
45
+ const policy = required("policy"), source = required("source");
46
+ const result = operation === "ingest"
47
+ ? ingestPolicySource(policy, source, args.flags.previous === undefined ? undefined : required("previous"))
48
+ : inspectPolicyCheckpoint(policy, source, required("checkpoint"));
49
+ // Successful storage/reporting is not successful work: missing/partial fields are never promoted to acceptance.
50
+ console.log(JSON.stringify(result, null, 2));
51
+ }
52
+ //# sourceMappingURL=archive.js.map
package/dist/cli.d.ts CHANGED
@@ -30,13 +30,14 @@ export declare function cmdGrade(args: Args, adapterOverride?: HarnessAdapter):
30
30
  * Reps are the measurement; thresholds are policy. When policy changes, recompute rather
31
31
  * than reconcile two numbers in prose.
32
32
  */
33
- export declare function cmdMutationTest(): Promise<void>;
33
+ export declare function cmdJudgeAgreement(args: Args): void;
34
34
  /**
35
- * Re-evaluate needle gates against the saved staged diffs — free, except for the reps
36
- * whose gate verdict flips from fail to pass, which the judge never saw and must now
37
- * be shown. Prints the cost before making those calls.
35
+ * Re-evaluate needle gates against the saved staged diffs — no subject call. A rep
36
+ * whose gate verdict flips from fail to pass was never judged and costs one judge call.
37
+ * The completion summary reports how many judge calls were made.
38
38
  */
39
39
  export declare function cmdRegate(args: Args, adapterOverride?: HarnessAdapter): Promise<void>;
40
+ export declare function cmdScreen(args: Args): Promise<void>;
40
41
  export declare function cmdInit(args: Args): Promise<void>;
41
42
  export declare function cmdSuggest(args: Args, adapterOverride?: HarnessAdapter): Promise<void>;
42
43
  /**
package/dist/cli.js CHANGED
@@ -3,10 +3,12 @@ import { readFileSync, existsSync, mkdirSync, writeFileSync, mkdtempSync, rmSync
3
3
  import { load as yamlLoad } from "js-yaml";
4
4
  import { basename, dirname, join, resolve, relative } from "node:path";
5
5
  import { tmpdir } from "node:os";
6
- import { discover, resolveSkill, loadSpec, parseSpec, appendScenario, parseModelRef, runSkillModel, formatScorecard, readResults, regradeRun, lintSkill, failsGate, renderTemplateSpec, isTemplateSpec, renderDraftSpec, buildSuggestPrompt, parseSuggestDraft, rescoreRun, regateRun, specPathForRunDir, collectLift, collectStability, boundaryCells, stabilityNote, PATH_LEGEND, restampSkill, resolveAdjudicationJudges, adjudicateRun, judgeResemblesSubject, computeCoverage, formatCoverage, selectAffected, formatAffected, gitDiff, exec, HARNESS_VERSION, defaultJudge, assertJudgeAllowed, assertNotDowngraded, downgradeWarning, isScoredMode, runTrajectoryMutationSelfTest, resolveArm, } from "@skill-harness/core";
6
+ import { discover, resolveSkill, loadSpec, parseSpec, appendScenario, parseModelRef, runSkillModel, formatScorecard, readResults, regradeRun, lintSkill, failsGate, renderTemplateSpec, isTemplateSpec, renderDraftSpec, buildSuggestPrompt, parseSuggestDraft, rescoreRun, regateRun, specPathForRunDir, collectLift, collectStability, boundaryCells, stabilityNote, PATH_LEGEND, restampSkill, resolveAdjudicationJudges, adjudicateRun, judgeResemblesSubject, computeCoverage, formatCoverage, selectAffected, formatAffected, gitDiff, exec, HARNESS_VERSION, defaultJudge, assertJudgeAllowed, judgeAgreement, assertNotDowngraded, downgradeWarning, isScoredMode, resolveArm, isFreeOfflineCommand, screenResults, formatScreen, } from "@skill-harness/core";
7
7
  import { getAdapter } from "@skill-harness/adapters";
8
8
  import { serveReview } from "./serve.js";
9
9
  import { runCompareCommand } from "./compare.js";
10
+ import { cmdQualification } from "./qualification.js";
11
+ import { cmdArchive } from "./archive.js";
10
12
  const DEFAULT_MODEL = "fireworks:accounts/fireworks/models/deepseek-v4-pro";
11
13
  // The judge default lives in core (`defaultJudge()`), which resolves
12
14
  // SKILL_HARNESS_JUDGE over a baked value — it was duplicated in three places
@@ -388,16 +390,19 @@ export async function cmdGrade(args, adapterOverride) {
388
390
  * Reps are the measurement; thresholds are policy. When policy changes, recompute rather
389
391
  * than reconcile two numbers in prose.
390
392
  */
391
- export async function cmdMutationTest() {
392
- const report = runTrajectoryMutationSelfTest();
393
- console.log(`trajectory assertion mutation self-test: baseline ${report.baseline}`);
394
- for (const test of report.cases) {
395
- console.log(` ${test.detected ? "✓" : "✗"} ${test.id}: ${test.status} — ${test.detail}`);
396
- }
397
- const missed = report.cases.filter((test) => !test.detected);
398
- console.log(`\n${report.cases.length - missed.length}/${report.cases.length} mutations detected; no model or judge calls.`);
399
- if (missed.length)
400
- process.exitCode = 1;
393
+ export function cmdJudgeAgreement(args) {
394
+ const raw = args._[0];
395
+ if (!raw)
396
+ throw new Error("usage: skill-harness judge-agreement <run-dir>");
397
+ const runDir = resolve(raw);
398
+ if (!existsSync(runDir))
399
+ throw new Error(`run dir not found: ${runDir}`);
400
+ const report = judgeAgreement(readResults(runDir));
401
+ for (const cell of report.cells) {
402
+ console.log(` ${cell.status === "agree" ? "=" : cell.status === "disagree" ? "≠" : "?"} ${cell.scenario}: ${cell.status} — ${cell.detail}${cell.judges.length ? ` (${cell.judges.join(" vs ")})` : ""}`);
403
+ }
404
+ console.log(`\njudge agreement: ${report.agree} agree / ${report.disagree} disagree / ${report.error} error; ${report.rate === null ? "n/a" : `${(report.rate * 100).toFixed(1)}%`} across ${report.comparable} comparable scenario(s).`);
405
+ console.log("offline report only; no model or judge calls.");
401
406
  }
402
407
  async function cmdRescore(args) {
403
408
  const runDirs = args._;
@@ -423,9 +428,9 @@ async function cmdRescore(args) {
423
428
  console.log(`\n${runDirs.length} run(s) re-scored, ${moved} verdict(s) moved.`);
424
429
  }
425
430
  /**
426
- * Re-evaluate needle gates against the saved staged diffs — free, except for the reps
427
- * whose gate verdict flips from fail to pass, which the judge never saw and must now
428
- * be shown. Prints the cost before making those calls.
431
+ * Re-evaluate needle gates against the saved staged diffs — no subject call. A rep
432
+ * whose gate verdict flips from fail to pass was never judged and costs one judge call.
433
+ * The completion summary reports how many judge calls were made.
429
434
  */
430
435
  export async function cmdRegate(args, adapterOverride) {
431
436
  const runDirs = args._;
@@ -462,7 +467,7 @@ export async function cmdRegate(args, adapterOverride) {
462
467
  moved += changes.length;
463
468
  calls += judgeCalls;
464
469
  }
465
- // The cost line matters: regate is advertised as free, and it is — except for the
470
+ // The cost line matters: regate makes no subject call, but fail→pass reps require a judge.
466
471
  // flipped reps, which it must not spend silently.
467
472
  console.log(`\n${runDirs.length} run(s) re-gated, ${moved} verdict(s) moved, ${calls} judge call(s) (no model re-runs).`);
468
473
  }
@@ -517,6 +522,13 @@ async function cmdRestamp(args) {
517
522
  console.log(`\n${runs} run(s) examined: ${upgraded} upgraded, ${unprovable} left alone, ${unchanged} already current.` +
518
523
  `${partial > 0 ? ` (${partial} upgraded only in part.)` : ""} No models were called.`);
519
524
  }
525
+ export async function cmdScreen(args) {
526
+ if (args._.length === 0)
527
+ throw new Error("usage: skill-harness screen <run-dir> [<run-dir> ...]");
528
+ const results = args._.map(runDir => readResults(resolve(runDir)));
529
+ console.log(formatScreen(screenResults(results)));
530
+ console.log(`\n${results.length} retained result(s) screened; 0 subject calls, 0 judge calls.`);
531
+ }
520
532
  async function cmdStability(args) {
521
533
  const root = flagStr(args, "skills", process.cwd());
522
534
  const target = args._[0] ?? "all";
@@ -860,6 +872,11 @@ export async function cmdLint(args) {
860
872
  * prints none.
861
873
  */
862
874
  export function help() {
875
+ const free = (command) => {
876
+ if (!isFreeOfflineCommand(command))
877
+ throw new Error(`${command} is not a free/offline command`);
878
+ return "free, offline";
879
+ };
863
880
  return `skill-harness ${HARNESS_VERSION} — test/optimize loop for agent skills (pi harness)
864
881
 
865
882
  run <skill|all> --skills <root> [--model prov:model ...] [--models file] [--only A1,D2]
@@ -877,19 +894,28 @@ export function help() {
877
894
  [--auto-rejudge] [--secondary-judge p:m] [--tie-break-judge p:m]
878
895
  ask again about untrustworthy cells (ambiguous / contradictory / non-unanimous /
879
896
  ship-deciding). OFF by default; prints the exact MAX extra call count first.
880
- mutation-test prove trajectory assertions turn red (free, offline)
881
- rescore <run-dir>... re-score saved reps vs current spec thresholds (free)
882
- regate <run-dir>... [--judge prov:model] re-evaluate diff needles against the saved diffs (free; judges only reps whose gate flipped)
883
- restamp <skill|all> --skills <root> [--from <git-ref>] record the model-visible skill digest on runs that still match (free, offline; one-time migration)
884
- stability <skill|all> --skills <root> [--window N] [--all] run-over-run verdict flips per scenario (free, offline)
897
+ archive ingest|inspect|watch --policy file --source id explicit external ingestion/metadata (${free("archive")})
898
+ archive weekly|trust|access --state /private/dir --request file durable learning/consent lifecycle (${free("archive")})
899
+ watch requires --max-polls N; optional --interval-ms N and --previous checkpoint
900
+ judge-agreement <run-dir> compare two distinct persisted judge votes per scenario (${free("judge-agreement")})
901
+ rescore <run-dir>... re-score saved reps vs current spec thresholds (${free("rescore")})
902
+ regate <run-dir>... [--judge prov:model] re-evaluate saved gates (no subject call; judges fail→pass reps)
903
+ restamp <skill|all> --skills <root> [--from <git-ref>] record the model-visible skill digest on runs that still match (${free("restamp")}; one-time migration)
904
+ stability <skill|all> --skills <root> [--window N] [--all] run-over-run verdict flips per scenario (${free("stability")})
905
+ screen <run-dir>... retained control/treatment + criterion rates (${free("screen")})
885
906
  review <skill> --skills <root> [--port N] serve the interactive review UI
886
907
  add-test <skill> --skills <root> --id ID --title T --turn ... --check ... [--critical] [--mode seeded --fixture path]
887
- init <skill> --skills <root> [--force] scaffold a commented template spec (free, offline)
908
+ init <skill> --skills <root> [--force] scaffold a commented template spec (${free("init")})
888
909
  suggest <skill> --skills <root> [--model prov:model] [--force] LLM-draft a spec from SKILL.md (spends tokens)
889
- list --skills <root> discovered skills + spec status
890
- lint <skill|all> --skills <root> validate specs/fixtures + results-consistency (CI gate; exits non-zero on findings)
891
- coverage <skill|all> --skills <root> [--strict] which instruction sections have a declared test (free, offline)
892
- affected <skill> --skills <root> [--base ref] which scenarios a change could touch (free, offline)
910
+ list --skills <root> discovered skills + spec status (${free("list")})
911
+ lint <skill|all> --skills <root> validate specs/fixtures + results-consistency (${free("lint")}; CI gate; exits non-zero on findings)
912
+ coverage <skill|all> --skills <root> [--strict] which instruction sections have a declared test (${free("coverage")})
913
+ affected <skill> --skills <root> [--base ref] which scenarios a change could touch (${free("affected")})
914
+ qualification <prepare|start|status|poll|validate|panel|cell|abort> durable qualification-runner-v1 lifecycle + offline panel collapse
915
+ prepare --spool DIR --config FILE --request FILE [--expected-config-sha256 HEX] (required in production)
916
+ start|status|poll|abort --spool DIR --id ID (abort also requires --reason ID)
917
+ start may resume only with --continuation-authority-file <private-0600-prebound-one-use-capability>
918
+ validate --spool DIR (all calls use external, schema-validated arms; no automatic retry)
893
919
 
894
920
  version print ${HARNESS_VERSION} and exit (also --version / -v)
895
921
 
@@ -907,11 +933,13 @@ export async function main(argv) {
907
933
  case "run": return cmdRun(args);
908
934
  case "compare": return cmdCompare(args);
909
935
  case "grade": return cmdGrade(args);
910
- case "mutation-test": return cmdMutationTest();
936
+ case "archive": return cmdArchive(args);
937
+ case "judge-agreement": return cmdJudgeAgreement(args);
911
938
  case "rescore": return cmdRescore(args);
912
939
  case "regate": return cmdRegate(args);
913
940
  case "restamp": return cmdRestamp(args);
914
941
  case "stability": return cmdStability(args);
942
+ case "screen": return cmdScreen(args);
915
943
  case "review": return cmdReview(args);
916
944
  case "add-test": return cmdAddTest(args);
917
945
  case "init": return cmdInit(args);
@@ -920,6 +948,7 @@ export async function main(argv) {
920
948
  case "lint": return cmdLint(args);
921
949
  case "coverage": return cmdCoverage(args);
922
950
  case "affected": return cmdAffected(args);
951
+ case "qualification": return cmdQualification(args);
923
952
  case "version":
924
953
  case "--version":
925
954
  case "-v":
@@ -0,0 +1,7 @@
1
+ export interface QualificationCliArgs {
2
+ _: string[];
3
+ flags: Record<string, string | true>;
4
+ }
5
+ export declare function qualificationSupervisorRuntimeArgs(mode: "production" | "test", scriptPath: string): string[];
6
+ export declare function consumeQualificationContinuationAuthority(path: string): string;
7
+ export declare function cmdQualification(args: QualificationCliArgs): Promise<void>;
@@ -0,0 +1,210 @@
1
+ import { spawn } from "node:child_process";
2
+ import { closeSync, constants, fstatSync, lstatSync, openSync, readFileSync, realpathSync, unlinkSync } from "node:fs";
3
+ import { setTimeout as sleep } from "node:timers/promises";
4
+ import { abortQualificationInvocation, checkQualificationAuthentication, pollQualificationInvocation, prepareQualificationInvocation, qualificationCanonicalJson, recordQualificationCell, recordQualificationJudgePanel, qualificationInvocationStatus, readQualificationSpoolConfig, superviseQualificationInvocation, validateQualificationRunnerSpool, verifyQualificationExecutable, } from "@skill-harness/core";
5
+ function flag(args, name) {
6
+ const value = args.flags[name];
7
+ return typeof value === "string" && value.length > 0 ? value : undefined;
8
+ }
9
+ function required(args, name) {
10
+ const value = flag(args, name);
11
+ if (!value)
12
+ throw new Error(`qualification ${args._[0] ?? "command"} requires --${name} <value>`);
13
+ return value;
14
+ }
15
+ function integerFlag(args, name, fallback) {
16
+ const raw = flag(args, name);
17
+ if (raw === undefined)
18
+ return fallback;
19
+ const value = Number(raw);
20
+ if (!Number.isSafeInteger(value) || value < 0)
21
+ throw new Error(`qualification --${name} must be a non-negative integer`);
22
+ return value;
23
+ }
24
+ export function qualificationSupervisorRuntimeArgs(mode, scriptPath) {
25
+ // Production supervisors execute built JavaScript with no inherited Node
26
+ // loader/import/debug hooks. Source-mode tests need exactly the repository's
27
+ // tsx import and nothing from the parent process.execArgv.
28
+ return mode === "test" && scriptPath.endsWith(".ts") ? ["--import", "tsx"] : [];
29
+ }
30
+ export function consumeQualificationContinuationAuthority(path) {
31
+ let fd;
32
+ try {
33
+ fd = openSync(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
34
+ const stat = fstatSync(fd);
35
+ if (!stat.isFile())
36
+ throw new Error("qualification continuation authority must be a regular non-symlink file");
37
+ if (process.platform !== "win32" && ((stat.mode & 0o077) !== 0 || stat.uid !== process.getuid?.()))
38
+ throw new Error("qualification continuation authority file must be mode 0600 and owned by the qualification user");
39
+ if (stat.size < 32 || stat.size > 4096)
40
+ throw new Error("qualification continuation authority must be 32..4096 bytes");
41
+ const authority = readFileSync(fd, "utf8");
42
+ const pathStat = lstatSync(path);
43
+ if (pathStat.isSymbolicLink() || pathStat.dev !== stat.dev || pathStat.ino !== stat.ino)
44
+ throw new Error("qualification continuation authority path changed while it was consumed");
45
+ unlinkSync(path);
46
+ if (!authority.trim())
47
+ throw new Error("qualification continuation authority must not be blank");
48
+ return authority;
49
+ }
50
+ finally {
51
+ if (fd !== undefined)
52
+ closeSync(fd);
53
+ }
54
+ }
55
+ function print(value) {
56
+ process.stdout.write(`${qualificationCanonicalJson(value)}\n`);
57
+ }
58
+ export async function cmdQualification(args) {
59
+ const operation = args._[0];
60
+ if (!operation)
61
+ throw new Error("usage: skill-harness qualification <prepare|start|status|poll|validate|panel|cell|abort> ...");
62
+ if (operation === "prepare") {
63
+ const invocation = prepareQualificationInvocation({
64
+ spool_dir: required(args, "spool"),
65
+ config_path: required(args, "config"),
66
+ request_path: required(args, "request"),
67
+ expected_configuration_sha256: flag(args, "expected-config-sha256"),
68
+ });
69
+ print({ invocation_id: invocation.invocation_id, phase: "prepared", consumed_calls: 0 });
70
+ return;
71
+ }
72
+ const spool = required(args, "spool");
73
+ if (operation === "validate") {
74
+ print(validateQualificationRunnerSpool(spool));
75
+ return;
76
+ }
77
+ if (operation === "panel") {
78
+ print(recordQualificationJudgePanel({
79
+ spool_dir: spool,
80
+ panel_id: required(args, "panel-id"),
81
+ member_invocation_ids: required(args, "members").split(",").filter(Boolean),
82
+ }));
83
+ return;
84
+ }
85
+ if (operation === "cell") {
86
+ print(recordQualificationCell({
87
+ spool_dir: spool,
88
+ cell_id: required(args, "cell-id"),
89
+ }));
90
+ return;
91
+ }
92
+ const id = required(args, "id");
93
+ if (operation === "status") {
94
+ print(qualificationInvocationStatus(spool, id));
95
+ return;
96
+ }
97
+ if (operation === "poll") {
98
+ print(await pollQualificationInvocation({
99
+ spool_dir: spool,
100
+ invocation_id: id,
101
+ wait_ms: integerFlag(args, "wait-ms", 0),
102
+ interval_ms: Math.max(5, integerFlag(args, "interval-ms", 100)),
103
+ }));
104
+ return;
105
+ }
106
+ if (operation === "abort") {
107
+ print(await abortQualificationInvocation({
108
+ spool_dir: spool,
109
+ invocation_id: id,
110
+ reason: required(args, "reason"),
111
+ }));
112
+ return;
113
+ }
114
+ if (operation === "__supervise") {
115
+ const fdRaw = flag(args, "authority-fd");
116
+ if (fdRaw !== "3")
117
+ throw new Error("qualification internal authority descriptor must be fd 3");
118
+ let authority;
119
+ try {
120
+ authority = JSON.parse(readFileSync(3, "utf8"));
121
+ }
122
+ catch {
123
+ throw new Error("qualification internal authority payload is invalid JSON");
124
+ }
125
+ finally {
126
+ closeSync(3);
127
+ }
128
+ if (!authority || typeof authority !== "object" || Array.isArray(authority) ||
129
+ Object.keys(authority).sort().join(",") !== "authentication_authority,continuation_authority") {
130
+ throw new Error("qualification internal authority payload is not closed");
131
+ }
132
+ const payload = authority;
133
+ if (typeof payload.authentication_authority !== "string" ||
134
+ (payload.continuation_authority !== null && typeof payload.continuation_authority !== "string")) {
135
+ throw new Error("qualification internal authority payload has invalid fields");
136
+ }
137
+ await superviseQualificationInvocation({
138
+ spool_dir: spool,
139
+ invocation_id: id,
140
+ child_env: process.env,
141
+ authentication_authority: payload.authentication_authority,
142
+ continuation_authority: payload.continuation_authority ?? undefined,
143
+ });
144
+ return;
145
+ }
146
+ if (operation === "start") {
147
+ const config = readQualificationSpoolConfig(spool);
148
+ const before = qualificationInvocationStatus(spool, id);
149
+ if (before.phase === "terminal" || ((before.phase === "running" || before.phase === "launch-claimed") && before.supervisor_alive === true)) {
150
+ print(before);
151
+ return;
152
+ }
153
+ const needsContinuation = before.attempt === 1 && before.supervisor_alive !== true;
154
+ if (needsContinuation && !flag(args, "continuation-authority-file")) {
155
+ throw new Error("qualification interrupted claimed invocation requires --continuation-authority-file");
156
+ }
157
+ if (config.mode === "production") {
158
+ const pinned = verifyQualificationExecutable(config.runner.executable);
159
+ const running = realpathSync(process.argv[1]);
160
+ if (running !== pinned.realpath) {
161
+ throw new Error(`qualification runner executable mismatch: configuration pins ${pinned.realpath}, running ${running}`);
162
+ }
163
+ }
164
+ const auth = await checkQualificationAuthentication({ spool_dir: spool, invocation_id: id });
165
+ if (flag(args, "continuation-authority") !== undefined)
166
+ throw new Error("qualification continuation authority must use --continuation-authority-file, never argv text");
167
+ const continuationFile = flag(args, "continuation-authority-file");
168
+ const continuation = continuationFile ? consumeQualificationContinuationAuthority(continuationFile) : undefined;
169
+ const childArgs = [
170
+ ...qualificationSupervisorRuntimeArgs(config.mode, process.argv[1]),
171
+ process.argv[1],
172
+ "qualification", "__supervise",
173
+ "--spool", spool,
174
+ "--id", id,
175
+ "--authority-fd", "3",
176
+ ];
177
+ const supervisor = spawn(process.execPath, childArgs, {
178
+ cwd: process.cwd(),
179
+ env: auth.child_env,
180
+ detached: true,
181
+ stdio: ["ignore", "ignore", "ignore", "pipe"],
182
+ });
183
+ await new Promise((resolve, reject) => {
184
+ supervisor.once("spawn", resolve);
185
+ supervisor.once("error", reject);
186
+ });
187
+ const authorityPipe = supervisor.stdio[3];
188
+ if (!authorityPipe || !("write" in authorityPipe))
189
+ throw new Error("qualification private authority pipe was not created");
190
+ authorityPipe.end(JSON.stringify({ authentication_authority: auth.launch_authority, continuation_authority: continuation ?? null }));
191
+ supervisor.unref();
192
+ const deadline = Date.now() + integerFlag(args, "ack-wait-ms", 1500);
193
+ const priorSupervisor = qualificationCanonicalJson(before.supervisor);
194
+ let status = qualificationInvocationStatus(spool, id);
195
+ const acknowledged = () => needsContinuation
196
+ ? status.phase === "terminal" || (status.supervisor_alive === true && qualificationCanonicalJson(status.supervisor) !== priorSupervisor)
197
+ : status.phase !== "prepared";
198
+ while (!acknowledged() && Date.now() < deadline) {
199
+ await sleep(10);
200
+ status = qualificationInvocationStatus(spool, id);
201
+ }
202
+ if (!acknowledged()) {
203
+ throw new Error(`qualification supervisor did not durably acknowledge ${id} before the acknowledgement deadline`);
204
+ }
205
+ print(status);
206
+ return;
207
+ }
208
+ throw new Error(`unknown qualification operation: ${operation}`);
209
+ }
210
+ //# sourceMappingURL=qualification.js.map
package/dist/serve.js CHANGED
@@ -3,7 +3,7 @@ import { readFileSync, existsSync } from "node:fs";
3
3
  import { join, dirname } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { spawn } from "node:child_process";
6
- import { collectReport, renderReport, collectTrends, readResults, writeResults, applyOverride, preserveTranscript, findTranscriptFiles, ensureResultsGitignore, appendJournal, loadSpec, regradeScenario, refreshRubricHashes, findJudgeRawFiles, effectiveThreshold, scoreContextFor, isScoredMode, rebuildScenarioResult, mergeScenarioMetrics, envFlag, planAdjudication, adjudicateRun, assertJudgeAllowed, cellsFromResults, } from "@skill-harness/core";
6
+ import { collectReport, renderReport, collectTrends, readResults, writeResults, applyOverride, preserveTranscript, findTranscriptFiles, ensureResultsGitignore, appendJournal, loadSpec, regradeScenario, appendJudgeHistory, refreshRubricHashes, findJudgeRawFiles, effectiveThreshold, scoreContextFor, isScoredMode, rebuildScenarioResult, mergeScenarioMetrics, carryRepObjectives, envFlag, planAdjudication, adjudicateRun, assertJudgeAllowed, cellsFromResults, } from "@skill-harness/core";
7
7
  import { getAdapter } from "@skill-harness/adapters";
8
8
  const __dirname = dirname(fileURLToPath(import.meta.url));
9
9
  /** Locate assets/report.template.html relative to dist/ or src/. */
@@ -115,17 +115,23 @@ export async function serveReview(opts) {
115
115
  res.writeHead(404).end("unknown scenario");
116
116
  return;
117
117
  }
118
+ const prev = results.scenarios.find((s) => s.id === body.scenarioId);
119
+ if (!prev) {
120
+ res.writeHead(404).end("scenario not in this run");
121
+ return;
122
+ }
123
+ const delivery = prev.objective?.assertions.find(assertion => assertion.kind === "skill_delivered");
124
+ if (results.schema === 3 && delivery?.status !== "PASS") {
125
+ res.writeHead(400, { "content-type": "application/json" });
126
+ res.end(JSON.stringify({ ok: false, error: `scenario ${body.scenarioId} is ${delivery?.status ?? "ERROR"}: delivery-gated evidence cannot be re-judged` }));
127
+ return;
128
+ }
118
129
  const adapter = opts.adapter ?? getAdapter(results.harness);
119
130
  if (!(await adapter.available())) {
120
131
  res.writeHead(400, { "content-type": "application/json" });
121
132
  res.end(JSON.stringify({ ok: false, error: `harness \`${results.harness}\` is not on PATH` }));
122
133
  return;
123
134
  }
124
- const prev = results.scenarios.find((s) => s.id === body.scenarioId);
125
- if (!prev) {
126
- res.writeHead(404).end("scenario not in this run");
127
- return;
128
- }
129
135
  const threshold = effectiveThreshold(prev, scenario);
130
136
  try {
131
137
  const rr = await regradeScenario({
@@ -133,12 +139,21 @@ export async function serveReview(opts) {
133
139
  specDir: dirname(specPath), threshold, mode: results.mode,
134
140
  expectedReps: prev.reps ?? 1,
135
141
  });
136
- const merged = results.scenarios.map((s) =>
137
- // Same contract as `grade`, through the same choke point.
138
- s.id === body.scenarioId
139
- ? rebuildScenarioResult({ ...rr, metrics: mergeScenarioMetrics(s.metrics, rr.metrics) }, s, { objective: "carry", adjudication: "drop" })
140
- : s);
142
+ const merged = results.scenarios.map((s) => {
143
+ if (s.id !== body.scenarioId)
144
+ return s;
145
+ const judge_history = appendJudgeHistory(s, results.judge, {
146
+ judge: results.judge,
147
+ verdict: rr.judge_verdict,
148
+ reason: rr.judge_reason,
149
+ suspect: rr.suspect,
150
+ criteria: rr.rep_judgments?.find(panel => panel.repetition === 0)?.judgments[0]?.criteria,
151
+ });
152
+ // Same contract as `grade`, through the same choke point.
153
+ return rebuildScenarioResult({ ...rr, metrics: mergeScenarioMetrics(s.metrics, rr.metrics), rep_judgments: carryRepObjectives(rr.rep_judgments, s.rep_judgments), judge_history }, s, { objective: "carry", adjudication: "drop" });
154
+ });
141
155
  const written = writeResults(column.runDir, {
156
+ schema: results.schema, subject_invocations: results.subject_invocations,
142
157
  skill: results.skill, harness: results.harness, model: results.model, judge: results.judge,
143
158
  timestamp: results.timestamp, label: results.label, mode: results.mode, scenarios: merged,
144
159
  partial: results.partial,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skill-harness/cli",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "skill-harness CLI — run, grade, review, and lint agent-skill scenarios on the pi harness",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -41,10 +41,10 @@
41
41
  "node": ">=20"
42
42
  },
43
43
  "scripts": {
44
- "prepack": "rm -rf ./assets && mkdir -p ./assets && cp ../../assets/report.* ./assets/ && cp ../../LICENSE ./LICENSE"
44
+ "prepack": "node ../../scripts/release-pack.mjs --guard"
45
45
  },
46
46
  "dependencies": {
47
- "@skill-harness/core": "0.11.0",
48
- "@skill-harness/adapters": "0.11.0"
47
+ "@skill-harness/core": "0.13.0",
48
+ "@skill-harness/adapters": "0.13.0"
49
49
  }
50
50
  }