harnery 0.24.0 → 0.26.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 (55) hide show
  1. package/dist/commands/harness.d.ts +2 -1
  2. package/dist/commands/harness.d.ts.map +1 -1
  3. package/dist/commands/harness.js +113 -3
  4. package/dist/commands/supervisor.d.ts.map +1 -1
  5. package/dist/commands/supervisor.js +3 -13
  6. package/dist/commands/work.d.ts.map +1 -1
  7. package/dist/commands/work.js +2 -7
  8. package/dist/commands/workflow.d.ts.map +1 -1
  9. package/dist/commands/workflow.js +3 -13
  10. package/dist/core/harnesses/attest.d.ts +53 -0
  11. package/dist/core/harnesses/attest.d.ts.map +1 -0
  12. package/dist/core/harnesses/attest.js +120 -0
  13. package/dist/core/harnesses/attestation.d.ts +82 -0
  14. package/dist/core/harnesses/attestation.d.ts.map +1 -0
  15. package/dist/core/harnesses/attestation.js +171 -0
  16. package/dist/core/harnesses/bench.d.ts +26 -1
  17. package/dist/core/harnesses/bench.d.ts.map +1 -1
  18. package/dist/core/harnesses/bench.js +137 -32
  19. package/dist/core/harnesses/index.d.ts +6 -2
  20. package/dist/core/harnesses/index.d.ts.map +1 -1
  21. package/dist/core/harnesses/index.js +3 -1
  22. package/dist/core/harnesses/profiles.d.ts +6 -6
  23. package/dist/core/harnesses/profiles.js +3 -3
  24. package/dist/core/workflow/engine.js +3 -0
  25. package/dist/core/workflow/proof.d.ts +4 -1
  26. package/dist/core/workflow/proof.d.ts.map +1 -1
  27. package/dist/core/workflow/proof.js +3 -2
  28. package/dist/core/workflow/spawn-claude.d.ts.map +1 -1
  29. package/dist/core/workflow/spawn-claude.js +2 -1
  30. package/dist/core/workflow/spawn-codex.d.ts.map +1 -1
  31. package/dist/core/workflow/spawn-codex.js +2 -1
  32. package/dist/core/workflow/spawn-cursor.d.ts.map +1 -1
  33. package/dist/core/workflow/spawn-cursor.js +2 -1
  34. package/dist/core/workflow/spawn-failure.d.ts +18 -0
  35. package/dist/core/workflow/spawn-failure.d.ts.map +1 -0
  36. package/dist/core/workflow/spawn-failure.js +24 -0
  37. package/dist/core/workflow/types.d.ts +14 -0
  38. package/dist/core/workflow/types.d.ts.map +1 -1
  39. package/package.json +4 -2
  40. package/src/commands/harness.ts +135 -2
  41. package/src/commands/supervisor.ts +11 -15
  42. package/src/commands/work.ts +8 -8
  43. package/src/commands/workflow.ts +11 -15
  44. package/src/core/harnesses/attest.ts +181 -0
  45. package/src/core/harnesses/attestation.ts +249 -0
  46. package/src/core/harnesses/bench.ts +192 -32
  47. package/src/core/harnesses/index.ts +26 -1
  48. package/src/core/harnesses/profiles.ts +3 -3
  49. package/src/core/workflow/engine.ts +3 -0
  50. package/src/core/workflow/proof.ts +7 -1
  51. package/src/core/workflow/spawn-claude.ts +2 -1
  52. package/src/core/workflow/spawn-codex.ts +2 -1
  53. package/src/core/workflow/spawn-cursor.ts +2 -1
  54. package/src/core/workflow/spawn-failure.ts +28 -0
  55. package/src/core/workflow/types.ts +15 -0
@@ -1,8 +1,9 @@
1
1
  import type { Command } from "commander";
2
2
  import type { EmitContext } from "../commander.js";
3
- import { type BenchResult, type HarnessBenchReport } from "../core/harnesses/index.js";
3
+ import { type BenchResult, type HarnessAttestationReport, type HarnessBenchReport } from "../core/harnesses/index.js";
4
4
  import type { HarnessProfile } from "../core/harnesses/types.js";
5
5
  export declare function registerHarnessCommand(program: Command, emit: EmitContext): void;
6
+ export declare function renderAttestationReport(report: HarnessAttestationReport): string;
6
7
  export declare function renderProfileTable(profiles: readonly HarnessProfile[]): string;
7
8
  export declare function renderProfile(profile: HarnessProfile): string;
8
9
  export declare function renderBenchReport(report: HarnessBenchReport): string;
@@ -1 +1 @@
1
- {"version":3,"file":"harness.d.ts","sourceRoot":"","sources":["../../src/commands/harness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,C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AY,EAAE,WAAW,EAAE,CAAC"}
@@ -1,4 +1,5 @@
1
- import { createBuiltinHarnessRegistry, runHarnessBench, } from "../core/harnesses/index.js";
1
+ import { workflowSubscriptionOnly } from "../core/config.js";
2
+ import { createBuiltinHarnessRegistry, listAttestations, runHarnessAttestation, runHarnessBench, } from "../core/harnesses/index.js";
2
3
  const registry = createBuiltinHarnessRegistry();
3
4
  export function registerHarnessCommand(program, emit) {
4
5
  const command = program
@@ -62,6 +63,103 @@ export function registerHarnessCommand(program, emit) {
62
63
  emit.setExitCode(1);
63
64
  }
64
65
  });
66
+ command
67
+ .command("attest [harnesses...]")
68
+ .description("Record what the installed vendor CLIs actually do. Runs one real model turn each; needs --yes.")
69
+ .option("--yes", "Confirm that this spends real vendor tokens")
70
+ .option("--subscription-only", "Scrub API-key vars so the child uses its stored login (repo default via config.jsonc workflow.subscriptionOnly)")
71
+ .option("--timeout <ms>", "Per-harness probe timeout in milliseconds")
72
+ .option("--json", "Machine-readable attestation report")
73
+ .action(async (harnesses, opts) => {
74
+ if (!opts.yes) {
75
+ emit.error({
76
+ code: "harness_attest_unconfirmed",
77
+ message: "harness attest runs one real model turn per harness and spends vendor tokens. Re-run with --yes.",
78
+ });
79
+ emit.setExitCode(1);
80
+ return;
81
+ }
82
+ const timeoutMs = opts.timeout ? Number(opts.timeout) : undefined;
83
+ if (timeoutMs !== undefined && (!Number.isFinite(timeoutMs) || timeoutMs <= 0)) {
84
+ emit.error({
85
+ code: "harness_attest_bad_timeout",
86
+ message: "--timeout must be a positive number",
87
+ });
88
+ emit.setExitCode(1);
89
+ return;
90
+ }
91
+ try {
92
+ const subscriptionOnly = opts.subscriptionOnly || workflowSubscriptionOnly();
93
+ const report = await runHarnessAttestation(registry, {
94
+ harnesses,
95
+ timeoutMs,
96
+ subscriptionOnly,
97
+ });
98
+ if (opts.json) {
99
+ emit.config({ format: "json" });
100
+ emit.data(report);
101
+ }
102
+ else {
103
+ emit.text(renderAttestationReport(report));
104
+ }
105
+ // A sweep that recorded nothing at all is a failure; a partial sweep is
106
+ // reported honestly and still exits 0, because a host is not required
107
+ // to install every vendor CLI.
108
+ emit.setExitCode(report.recorded === 0 ? 1 : 0);
109
+ }
110
+ catch (error) {
111
+ emit.error({ code: "harness_attest_failed", message: error.message });
112
+ emit.setExitCode(1);
113
+ }
114
+ });
115
+ command
116
+ .command("attestations")
117
+ .description("Show the recorded live attestations without running any model turns.")
118
+ .option("--json", "Machine-readable attestation list")
119
+ .action((opts) => {
120
+ try {
121
+ const records = listAttestations();
122
+ if (opts.json) {
123
+ emit.config({ format: "json" });
124
+ emit.data({ attestations: records });
125
+ return;
126
+ }
127
+ if (records.length === 0) {
128
+ emit.text("No attestations recorded. Run `harness attest --yes` to create one.");
129
+ return;
130
+ }
131
+ emit.text(renderTable(["HARNESS", "VERSION", "BILLING", "OBSERVED AT", "OBSERVATIONS"], records.map((record) => [
132
+ record.harness,
133
+ record.binary_version,
134
+ record.subscription_only ? "subscription" : "any",
135
+ record.observed_at,
136
+ Object.entries(record.observations)
137
+ .map(([dimension, support]) => `${dimension}=${support}`)
138
+ .join(" "),
139
+ ])));
140
+ }
141
+ catch (error) {
142
+ emit.error({ code: "harness_attestations_failed", message: error.message });
143
+ emit.setExitCode(1);
144
+ }
145
+ });
146
+ }
147
+ export function renderAttestationReport(report) {
148
+ const rows = report.results.map((result) => [
149
+ result.harness,
150
+ result.outcome,
151
+ result.binaryVersion ?? "",
152
+ result.observations
153
+ ? Object.entries(result.observations)
154
+ .map(([dimension, support]) => `${dimension}=${support}`)
155
+ .join(" ")
156
+ : result.note,
157
+ ]);
158
+ const table = renderTable(["HARNESS", "OUTCOME", "VERSION", "OBSERVED"], rows);
159
+ const tail = report.incomplete
160
+ ? "Some harnesses were not attested; their bench rows keep an adapter basis."
161
+ : "Every selected harness was attested.";
162
+ return `${table}\n\nrecorded: ${report.recorded}/${report.results.length}\n${tail}`;
65
163
  }
66
164
  export function renderProfileTable(profiles) {
67
165
  const rows = profiles.map((profile) => [
@@ -100,13 +198,25 @@ export function renderBenchReport(report) {
100
198
  result.declared,
101
199
  result.observed,
102
200
  result.verdict,
201
+ result.basis,
103
202
  ]);
104
- const table = renderTable(["HARNESS", "DIMENSION", "DECLARED", "OBSERVED", "VERDICT"], rows);
203
+ const table = renderTable(["HARNESS", "DIMENSION", "DECLARED", "OBSERVED", "VERDICT", "BASIS"], rows);
105
204
  const summary = Object.entries(report.summary)
106
205
  .filter(([, count]) => count > 0)
107
206
  .map(([verdict, count]) => `${verdict}=${count}`)
108
207
  .join(", ");
109
- return `${table}\n\nmode: ${report.mode} (no model calls)\n${summary}`;
208
+ const basis = Object.entries(report.basisSummary)
209
+ .filter(([, count]) => count > 0)
210
+ .map(([name, count]) => `${name}=${count}`)
211
+ .join(", ");
212
+ return [
213
+ table,
214
+ "",
215
+ `mode: ${report.mode} (no model calls)`,
216
+ summary,
217
+ `basis: ${basis}`,
218
+ "adapter = checked against Harnery's planner/normalizer/fixture, not the installed CLI",
219
+ ].join("\n");
110
220
  }
111
221
  function renderTable(headers, rows) {
112
222
  const widths = headers.map((header, index) => Math.max(header.length, ...rows.map((row) => row[index]?.length ?? 0)));
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../../src/commands/supervisor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAsEnD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAgGnF"}
1
+ {"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../../src/commands/supervisor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA0EnD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAgGnF"}
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { dirname, isAbsolute, resolve } from "node:path";
3
3
  import { workflowSubscriptionOnly } from "../core/config.js";
4
- import { createBuiltinHarnessRegistry } from "../core/harnesses/index.js";
4
+ import { createBuiltinHarnessRegistry, harnessProofInputs, probeBinaryVersion, } from "../core/harnesses/index.js";
5
5
  import { findCoordRoot } from "../core/hooks/resolve/coord-root.js";
6
6
  import { loadPolicyFile } from "../core/policy/index.js";
7
7
  import { approveSupervisorPlan, configureSupervisorService, createSupervisor, listSupervisors, readSupervisor, readSupervisorPlan, readSupervisorServiceConfig, readSupervisorServiceStatus, rejectSupervisorPlan, requestSupervisorServiceStop, retrySupervisorPlan, runSupervisor, runSupervisorServiceDaemon, spawnSupervisorService, supervisorServiceLogPath, } from "../core/supervisor/index.js";
@@ -332,12 +332,7 @@ function serviceEngine(config, registry) {
332
332
  cwd: config.engine.cwd,
333
333
  subscriptionOnly: config.engine.subscription_only,
334
334
  allowApiBilling: config.engine.allow_api_billing,
335
- harnessEvidence: Object.fromEntries(registry
336
- .list()
337
- .map((adapter) => [
338
- adapter.profile.id,
339
- { toolEvidence: adapter.profile.capabilities.toolEvidence },
340
- ])),
335
+ ...harnessProofInputs(registry.list().map((adapter) => adapter.profile), { versionProbe: probeBinaryVersion }),
341
336
  policy: config.engine.policy,
342
337
  approvalMode: "park",
343
338
  approvalAddressee: config.engine.approval_addressee,
@@ -413,12 +408,7 @@ function registerRunCommand(supervisor, mode, registry, emit) {
413
408
  cwd: opts.cwd,
414
409
  subscriptionOnly: opts.subscriptionOnly === true ? true : workflowSubscriptionOnly(coordRoot),
415
410
  allowApiBilling: opts.allowApiBilling,
416
- harnessEvidence: Object.fromEntries(registry
417
- .list()
418
- .map((adapter) => [
419
- adapter.profile.id,
420
- { toolEvidence: adapter.profile.capabilities.toolEvidence },
421
- ])),
411
+ ...harnessProofInputs(registry.list().map((adapter) => adapter.profile), { versionProbe: probeBinaryVersion }),
422
412
  policy: opts.policy ? loadPolicyFile(opts.policy) : undefined,
423
413
  approvalMode: "park",
424
414
  approvalAddressee: opts.approvalTo,
@@ -1 +1 @@
1
- {"version":3,"file":"work.d.ts","sourceRoot":"","sources":["../../src/commands/work.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAmDnD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CA8F7E"}
1
+ {"version":3,"file":"work.d.ts","sourceRoot":"","sources":["../../src/commands/work.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAuDnD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CA8F7E"}
@@ -1,5 +1,5 @@
1
1
  import { workflowSubscriptionOnly } from "../core/config.js";
2
- import { createBuiltinHarnessRegistry } from "../core/harnesses/index.js";
2
+ import { createBuiltinHarnessRegistry, harnessProofInputs, probeBinaryVersion, } from "../core/harnesses/index.js";
3
3
  import { findCoordRoot } from "../core/hooks/resolve/coord-root.js";
4
4
  import { loadPolicyFile } from "../core/policy/index.js";
5
5
  import { acceptWorkItem, cancelWorkItem, createWorkItem, listWorkItems, readWorkItem, reconcileAllWorkItems, reconcileWorkItem, reopenWorkItem, runWorkItem, } from "../core/work/index.js";
@@ -132,12 +132,7 @@ function registerRunCommand(work, name, retry, registry, harnesses, emit) {
132
132
  cwd: opts.cwd,
133
133
  subscriptionOnly: opts.subscriptionOnly === true ? true : workflowSubscriptionOnly(coordRoot),
134
134
  allowApiBilling: opts.allowApiBilling,
135
- harnessEvidence: Object.fromEntries(registry
136
- .list()
137
- .map((adapter) => [
138
- adapter.profile.id,
139
- { toolEvidence: adapter.profile.capabilities.toolEvidence },
140
- ])),
135
+ ...harnessProofInputs(registry.list().map((adapter) => adapter.profile), { versionProbe: probeBinaryVersion }),
141
136
  policy: opts.policy ? loadPolicyFile(opts.policy) : undefined,
142
137
  approvalMode: "park",
143
138
  approvalAddressee: opts.approvalTo,
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/commands/workflow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAiEnD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAqqBjF"}
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/commands/workflow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAqEnD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CA6pBjF"}
@@ -1,7 +1,7 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { join, resolve } from "node:path";
3
3
  import { resolveBinName, workflowSubscriptionOnly } from "../core/config.js";
4
- import { createBuiltinHarnessRegistry } from "../core/harnesses/index.js";
4
+ import { createBuiltinHarnessRegistry, harnessProofInputs, probeBinaryVersion, } from "../core/harnesses/index.js";
5
5
  import { findCoordRoot } from "../core/hooks/resolve/coord-root.js";
6
6
  import { loadPolicyFile } from "../core/policy/index.js";
7
7
  import { WorkflowParkedError } from "../core/workflow/engine.js";
@@ -88,12 +88,7 @@ export function registerWorkflowCommand(program, emit) {
88
88
  maxAgents: opts.maxAgents ? Number.parseInt(opts.maxAgents, 10) : undefined,
89
89
  concurrency: opts.concurrency ? Number.parseInt(opts.concurrency, 10) : undefined,
90
90
  cwd: opts.cwd,
91
- harnessEvidence: Object.fromEntries(registry
92
- .list()
93
- .map((adapter) => [
94
- adapter.profile.id,
95
- { toolEvidence: adapter.profile.capabilities.toolEvidence },
96
- ])),
91
+ ...harnessProofInputs(registry.list().map((adapter) => adapter.profile), { versionProbe: probeBinaryVersion }),
97
92
  policy: opts.policy ? loadPolicyFile(opts.policy) : undefined,
98
93
  approvalMode: "park",
99
94
  approvalAddressee: opts.approvalTo,
@@ -179,12 +174,7 @@ export function registerWorkflowCommand(program, emit) {
179
174
  writableRoots: [binding.writable_root.configured],
180
175
  }
181
176
  : undefined,
182
- harnessEvidence: Object.fromEntries(registry
183
- .list()
184
- .map((adapter) => [
185
- adapter.profile.id,
186
- { toolEvidence: adapter.profile.capabilities.toolEvidence },
187
- ])),
177
+ ...harnessProofInputs(registry.list().map((adapter) => adapter.profile), { versionProbe: probeBinaryVersion }),
188
178
  });
189
179
  if (opts.json) {
190
180
  emit.config({ format: "json" });
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The opt-in live probe that produces an attestation (ADR 0038).
3
+ *
4
+ * One bounded turn per harness, through the same `spawn` the workflow engine
5
+ * uses, so what gets attested is the path production takes rather than a
6
+ * parallel test rig.
7
+ */
8
+ import type { SpawnResult } from "../workflow/types.js";
9
+ import type { AttestableDimension, HarnessAttestation } from "./attestation.js";
10
+ import type { HarnessRegistry } from "./registry.js";
11
+ import type { CapabilitySupport, HarnessId } from "./types.js";
12
+ /** Fixed and content-free, so nothing user-supplied can reach the record and
13
+ * the turn stays as cheap as a turn can be. */
14
+ export declare const ATTESTATION_PROMPT = "Reply with the single word: ok";
15
+ export declare const DEFAULT_ATTESTATION_TIMEOUT_MS = 120000;
16
+ export type AttestationOutcome = "recorded" | "skipped" | "unreachable" | "failed";
17
+ export interface HarnessAttestationResult {
18
+ harness: HarnessId;
19
+ outcome: AttestationOutcome;
20
+ binaryVersion?: string;
21
+ observations?: Partial<Record<AttestableDimension, CapabilitySupport>>;
22
+ durationMs?: number;
23
+ note: string;
24
+ }
25
+ export interface HarnessAttestationReport {
26
+ generatedAt: string;
27
+ harnesses: HarnessId[];
28
+ results: HarnessAttestationResult[];
29
+ recorded: number;
30
+ /** True when at least one selected harness could not be attested, so a
31
+ * caller can tell a partial sweep from a complete one. */
32
+ incomplete: boolean;
33
+ }
34
+ export interface RunHarnessAttestationOptions {
35
+ harnesses?: readonly string[];
36
+ timeoutMs?: number;
37
+ cwd?: string;
38
+ coordRoot?: string;
39
+ /** Scrub API-key vars from the child so it can only use its stored login,
40
+ * matching `workflow run --subscription-only`. The observation is recorded
41
+ * against this mode, because a child that may fall back to an API key can
42
+ * behave differently from one that may not. */
43
+ subscriptionOnly?: boolean;
44
+ /** Test seam and alternate host probe. A null version means unavailable. */
45
+ versionProbe?: (binary: string) => string | null;
46
+ /** Test seam. Defaults to the adapter's production spawner. */
47
+ spawn?: (harness: HarnessId, prompt: string, timeoutMs: number) => Promise<SpawnResult>;
48
+ /** Test seam. Defaults to writing under the coord root. */
49
+ persist?: (record: HarnessAttestation) => void;
50
+ now?: () => Date;
51
+ }
52
+ export declare function runHarnessAttestation(registry: HarnessRegistry, opts?: RunHarnessAttestationOptions): Promise<HarnessAttestationReport>;
53
+ //# sourceMappingURL=attest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attest.d.ts","sourceRoot":"","sources":["../../../src/core/harnesses/attest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAQhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,iB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O,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC/C,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,eAAe,EACzB,IAAI,GAAE,4BAAiC,GACtC,OAAO,CAAC,wBAAwB,CAAC,CA4FnC"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * The opt-in live probe that produces an attestation (ADR 0038).
3
+ *
4
+ * One bounded turn per harness, through the same `spawn` the workflow engine
5
+ * uses, so what gets attested is the path production takes rather than a
6
+ * parallel test rig.
7
+ */
8
+ import { ATTESTATION_SCHEMA_VERSION, profileDigest, sealAttestation, writeAttestation, } from "./attestation.js";
9
+ import { probeBinaryVersion } from "./bench.js";
10
+ /** Fixed and content-free, so nothing user-supplied can reach the record and
11
+ * the turn stays as cheap as a turn can be. */
12
+ export const ATTESTATION_PROMPT = "Reply with the single word: ok";
13
+ export const DEFAULT_ATTESTATION_TIMEOUT_MS = 120_000;
14
+ /** Vendor failures arrive as whole console transcripts, banner and prompt echo
15
+ * included. Reports are bounded evidence, so the reason is collapsed to one
16
+ * short line and the echoed prompt is removed. */
17
+ const MAX_NOTE_REASON_CHARS = 200;
18
+ /** Keep the TAIL, not the head. A CLI prints its banner, config, and startup
19
+ * warnings first and the reason it actually failed last, so truncating from the
20
+ * front reliably preserves the noise and discards the answer. Learned the hard
21
+ * way: a head-truncated note once surfaced a cosmetic startup warning while
22
+ * hiding the real "out of credits" failure on the final line. */
23
+ function boundedReason(reason) {
24
+ if (!reason)
25
+ return "no error reported";
26
+ const collapsed = reason.split(ATTESTATION_PROMPT).join("<prompt>").replace(/\s+/g, " ").trim();
27
+ if (!collapsed)
28
+ return "no error reported";
29
+ return collapsed.length > MAX_NOTE_REASON_CHARS
30
+ ? `…${collapsed.slice(-MAX_NOTE_REASON_CHARS)}`
31
+ : collapsed;
32
+ }
33
+ export async function runHarnessAttestation(registry, opts = {}) {
34
+ const ids = opts.harnesses?.length ? [...opts.harnesses] : registry.ids();
35
+ const timeoutMs = opts.timeoutMs ?? DEFAULT_ATTESTATION_TIMEOUT_MS;
36
+ const cwd = opts.cwd ?? process.cwd();
37
+ const subscriptionOnly = opts.subscriptionOnly === true;
38
+ const versionProbe = opts.versionProbe ?? probeBinaryVersion;
39
+ const now = opts.now ?? (() => new Date());
40
+ const results = [];
41
+ for (const id of ids) {
42
+ const adapter = registry.require(id);
43
+ const binaryVersion = versionProbe(adapter.profile.binary);
44
+ if (!binaryVersion) {
45
+ results.push({
46
+ harness: id,
47
+ outcome: "skipped",
48
+ note: `${adapter.profile.binary} not found on PATH`,
49
+ });
50
+ continue;
51
+ }
52
+ let result;
53
+ try {
54
+ result = opts.spawn
55
+ ? await opts.spawn(id, ATTESTATION_PROMPT, timeoutMs)
56
+ : await adapter.spawn({
57
+ prompt: ATTESTATION_PROMPT,
58
+ timeoutMs,
59
+ maxTurns: 1,
60
+ cwd,
61
+ subscriptionOnly,
62
+ });
63
+ }
64
+ catch (error) {
65
+ results.push({
66
+ harness: id,
67
+ outcome: "failed",
68
+ binaryVersion,
69
+ note: `probe threw: ${boundedReason(error.message)}`,
70
+ });
71
+ continue;
72
+ }
73
+ // Prerequisite rule: an unreachable subject cannot evidence anything, so a
74
+ // failed turn records nothing at all rather than a page of `unsupported`.
75
+ if (!result.ok) {
76
+ results.push({
77
+ harness: id,
78
+ outcome: "unreachable",
79
+ binaryVersion,
80
+ durationMs: result.durationMs,
81
+ note: `the probe turn did not complete (${boundedReason(result.error)}); nothing recorded`,
82
+ });
83
+ continue;
84
+ }
85
+ const observations = {
86
+ invocation: "supported",
87
+ finalResult: result.text.trim().length > 0 ? "supported" : "unsupported",
88
+ sessionId: result.sessionId ? "supported" : "unsupported",
89
+ cost: result.costUsd !== undefined ? "supported" : "unsupported",
90
+ };
91
+ const record = sealAttestation({
92
+ schema_version: ATTESTATION_SCHEMA_VERSION,
93
+ harness: id,
94
+ binary_version: binaryVersion,
95
+ profile_digest: profileDigest(adapter.profile),
96
+ subscription_only: subscriptionOnly,
97
+ observed_at: now().toISOString(),
98
+ observations,
99
+ });
100
+ if (opts.persist)
101
+ opts.persist(record);
102
+ else
103
+ writeAttestation(record, { coordRoot: opts.coordRoot });
104
+ results.push({
105
+ harness: id,
106
+ outcome: "recorded",
107
+ binaryVersion,
108
+ observations,
109
+ durationMs: result.durationMs,
110
+ note: `observed on ${binaryVersion}`,
111
+ });
112
+ }
113
+ return {
114
+ generatedAt: now().toISOString(),
115
+ harnesses: ids,
116
+ results,
117
+ recorded: results.filter((row) => row.outcome === "recorded").length,
118
+ incomplete: results.some((row) => row.outcome !== "recorded"),
119
+ };
120
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Durable record of what an installed vendor CLI was actually observed doing
3
+ * (ADR 0038).
4
+ *
5
+ * The conformance bench proves Harnery's own planner and normalizer against a
6
+ * committed fixture. That is an adapter check, not a vendor check
7
+ * (ADR 0037). An attestation is the other half: one bounded live turn, its
8
+ * observations, and the vendor version they were observed on.
9
+ *
10
+ * A record stores structural facts only. No prompt text, no completion text,
11
+ * no host paths. It lives under the host's coordination directory and is never
12
+ * published.
13
+ */
14
+ import type { CapabilitySupport, HarnessId, HarnessProfile } from "./types.js";
15
+ export declare const ATTESTATION_SCHEMA_VERSION = 2;
16
+ /** Dimensions one minimal live turn can honestly establish. Everything else
17
+ * needs a purpose-built scenario and stays outside the record rather than
18
+ * being guessed at. */
19
+ export declare const ATTESTABLE_DIMENSIONS: readonly ["invocation", "finalResult", "sessionId", "cost"];
20
+ export type AttestableDimension = (typeof ATTESTABLE_DIMENSIONS)[number];
21
+ export interface HarnessAttestation {
22
+ schema_version: number;
23
+ harness: HarnessId;
24
+ /** What the vendor binary reported when this was recorded. Staleness is
25
+ * keyed on this, so a vendor upgrade invalidates the record automatically. */
26
+ binary_version: string;
27
+ /** Digest of the capability declaration at record time, so an edited
28
+ * declaration also invalidates the record. */
29
+ profile_digest: string;
30
+ /** The billing policy the probe ran under. A child launched with API keys
31
+ * scrubbed can behave differently from one that can fall back to them, so an
32
+ * observation only speaks for the mode it was made in. */
33
+ subscription_only: boolean;
34
+ observed_at: string;
35
+ /** Only what the probe actually saw. A dimension absent from this map was
36
+ * not observed, which is not the same as unsupported. */
37
+ observations: Partial<Record<AttestableDimension, CapabilitySupport>>;
38
+ /** Over every field above. A hand-edited record fails to load. */
39
+ record_digest: string;
40
+ }
41
+ export interface AttestationStoreOptions {
42
+ /** Test seam and alternate host. Defaults to the resolved coord root. */
43
+ coordRoot?: string;
44
+ }
45
+ export declare function attestationsDir(opts?: AttestationStoreOptions): string;
46
+ /** Stable identity of a declaration, so editing a claim invalidates the
47
+ * attestation that was recorded against the old one. */
48
+ export declare function profileDigest(profile: HarnessProfile): string;
49
+ export declare function sealAttestation(record: Omit<HarnessAttestation, "record_digest">): HarnessAttestation;
50
+ /** Replace-in-place write. Unlike a workflow record an attestation is meant to
51
+ * be re-recorded, so this is a mutable atomic swap rather than an immutable
52
+ * create. */
53
+ export declare function writeAttestation(record: HarnessAttestation, opts?: AttestationStoreOptions): string;
54
+ /** Null for absent, unreadable, malformed, wrong-schema, or tampered records.
55
+ * A record that fails its own digest is discarded rather than trusted, because
56
+ * the whole point of the file is that it was not hand-written. */
57
+ export declare function readAttestation(harness: HarnessId, opts?: AttestationStoreOptions): HarnessAttestation | null;
58
+ export declare function validateAttestation(value: unknown, harness?: HarnessId): HarnessAttestation | null;
59
+ /** An attestation speaks only for the vendor version and declaration it was
60
+ * recorded against. */
61
+ export declare function isAttestationCurrent(record: HarnessAttestation | null, binaryVersion: string | null, profile: HarnessProfile, subscriptionOnly?: boolean): record is HarnessAttestation;
62
+ export declare function listAttestations(opts?: AttestationStoreOptions): HarnessAttestation[];
63
+ /** Both harness-derived proof inputs, read once, for a workflow run
64
+ * (ADR 0038). Callers inject the result so the engine performs no capability
65
+ * lookups of its own. A harness with no current attestation simply has no
66
+ * citation; that absence is not a proof unknown. */
67
+ export declare function harnessProofInputs(profiles: readonly HarnessProfile[], opts: AttestationStoreOptions & {
68
+ versionProbe: (binary: string) => string | null;
69
+ /** Billing policy this run will use, so a record made under the other mode
70
+ * is not cited as if it applied. */
71
+ subscriptionOnly?: boolean;
72
+ }): {
73
+ harnessEvidence: Record<string, {
74
+ toolEvidence: HarnessProfile["capabilities"]["toolEvidence"];
75
+ }>;
76
+ harnessAttestations: Record<string, {
77
+ binary_version: string;
78
+ observed_at: string;
79
+ record_digest: string;
80
+ }>;
81
+ };
82
+ //# sourceMappingURL=attestation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attestation.d.ts","sourceRoot":"","sources":["../../../src/core/harnesses/attestation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAaH,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE/E,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C;;uBAEuB;AACvB,eAAO,MAAM,qBAAqB,6DAA8D,CAAC;AAEjG,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzE,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,SAAS,CAAC;IACnB;kFAC8E;IAC9E,cAAc,EAAE,MAAM,CAAC;IACvB;kDAC8C;IAC9C,cAAc,EAAE,MAAM,CAAC;IACvB;;8DAE0D;IAC1D,iBAAiB,EAAE,OAAO,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB;6DACyD;IACzD,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC,CAAC;IACtE,kEAAkE;IAClE,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACtC,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,eAAe,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