agentskeptic 0.1.9 → 0.2.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 (59) hide show
  1. package/README.md +3 -0
  2. package/dist/bootstrap/bootstrapCliArgs.d.ts +8 -0
  3. package/dist/bootstrap/bootstrapCliArgs.d.ts.map +1 -0
  4. package/dist/bootstrap/bootstrapCliArgs.js +47 -0
  5. package/dist/bootstrap/bootstrapCliArgs.js.map +1 -0
  6. package/dist/bootstrap/executeBootstrapPack.d.ts +32 -0
  7. package/dist/bootstrap/executeBootstrapPack.d.ts.map +1 -0
  8. package/dist/bootstrap/executeBootstrapPack.js +208 -0
  9. package/dist/bootstrap/executeBootstrapPack.js.map +1 -0
  10. package/dist/bootstrap/runBootstrapSubcommand.d.ts +3 -7
  11. package/dist/bootstrap/runBootstrapSubcommand.d.ts.map +1 -1
  12. package/dist/bootstrap/runBootstrapSubcommand.js +22 -202
  13. package/dist/bootstrap/runBootstrapSubcommand.js.map +1 -1
  14. package/dist/cli/lockOrchestration.d.ts.map +1 -1
  15. package/dist/cli/lockOrchestration.js +36 -0
  16. package/dist/cli/lockOrchestration.js.map +1 -1
  17. package/dist/cli.js +50 -111
  18. package/dist/cli.js.map +1 -1
  19. package/dist/cliOperationalCodes.d.ts +1 -0
  20. package/dist/cliOperationalCodes.d.ts.map +1 -1
  21. package/dist/cliOperationalCodes.js +1 -0
  22. package/dist/cliOperationalCodes.js.map +1 -1
  23. package/dist/commercial/postVerifyOutcomeBeacon.d.ts +1 -1
  24. package/dist/commercial/postVerifyOutcomeBeacon.d.ts.map +1 -1
  25. package/dist/crossing/crossingDecisionReadyFooter.d.ts +3 -0
  26. package/dist/crossing/crossingDecisionReadyFooter.d.ts.map +1 -0
  27. package/dist/crossing/crossingDecisionReadyFooter.js +3 -0
  28. package/dist/crossing/crossingDecisionReadyFooter.js.map +1 -0
  29. package/dist/crossing/runCrossingSubcommand.d.ts +2 -0
  30. package/dist/crossing/runCrossingSubcommand.d.ts.map +1 -0
  31. package/dist/crossing/runCrossingSubcommand.js +177 -0
  32. package/dist/crossing/runCrossingSubcommand.js.map +1 -0
  33. package/dist/funnel/workflowLineageClassify.d.ts +18 -0
  34. package/dist/funnel/workflowLineageClassify.d.ts.map +1 -0
  35. package/dist/funnel/workflowLineageClassify.js +29 -0
  36. package/dist/funnel/workflowLineageClassify.js.map +1 -0
  37. package/dist/operationalDisposition.d.ts +8 -0
  38. package/dist/operationalDisposition.d.ts.map +1 -1
  39. package/dist/operationalDisposition.js +8 -0
  40. package/dist/operationalDisposition.js.map +1 -1
  41. package/dist/publicDistribution.generated.d.ts +1 -1
  42. package/dist/publicDistribution.generated.d.ts.map +1 -1
  43. package/dist/publicDistribution.generated.js +2 -1
  44. package/dist/publicDistribution.generated.js.map +1 -1
  45. package/dist/telemetry/maybeEmitOssClaimTicketUrl.d.ts +1 -1
  46. package/dist/telemetry/maybeEmitOssClaimTicketUrl.d.ts.map +1 -1
  47. package/dist/telemetry/postOssClaimTicket.d.ts +1 -1
  48. package/dist/telemetry/postOssClaimTicket.d.ts.map +1 -1
  49. package/dist/telemetry/postProductActivationEvent.d.ts +5 -2
  50. package/dist/telemetry/postProductActivationEvent.d.ts.map +1 -1
  51. package/dist/telemetry/postProductActivationEvent.js +4 -2
  52. package/dist/telemetry/postProductActivationEvent.js.map +1 -1
  53. package/dist/telemetry/postProductActivationEvent.test.js +7 -1
  54. package/dist/telemetry/postProductActivationEvent.test.js.map +1 -1
  55. package/dist/verify/batchVerifyTelemetrySubcommand.d.ts +8 -0
  56. package/dist/verify/batchVerifyTelemetrySubcommand.d.ts.map +1 -0
  57. package/dist/verify/batchVerifyTelemetrySubcommand.js +141 -0
  58. package/dist/verify/batchVerifyTelemetrySubcommand.js.map +1 -0
  59. package/package.json +9 -4
package/README.md CHANGED
@@ -92,6 +92,8 @@ This is the fastest way to see **`ROW_ABSENT`** versus **verified** on the same
92
92
 
93
93
  **Fast first run on your own DB (bundled quickstart example):** after `npm install` and `npm run build`, run **`npm run partner-quickstart`** from the repo root (SQLite temp DB). Commands reference: **[`docs/partner-quickstart-commands.md`](docs/partner-quickstart-commands.md)**; narrative: **[`docs/first-run-integration.md`](docs/first-run-integration.md)** and **`/integrate`** on the site.
94
94
 
95
+ **Integrator-owned output:** The demo above is pedagogy. Default path: **`agentskeptic crossing`** — see **`docs/crossing-normative.md`**. For verification on **your** NDJSON, registry, and authoritative SQLite or Postgres, follow **[Grounded integrator-owned output](docs/first-run-integration.md#grounded-integrator-owned-output-primary-path)** in **`docs/first-run-integration.md`** after **`npm run build`**. Standalone **`agentskeptic verify-integrator-owned`** remains for explicit pack-led parity and CI (same flags as contract batch verify; rejects shipped example fixture triples with exit **2** and stderr **`INTEGRATOR_OWNED_GATE`**—see **`docs/agentskeptic.md`** Integrator-owned gate).
96
+
95
97
  ```bash
96
98
  npm install
97
99
  npm start
@@ -250,6 +252,7 @@ Everything beyond core contract verification lives in **[`docs/agentskeptic.md`]
250
252
 
251
253
  | Doc | Purpose |
252
254
  |-----|---------|
255
+ | [`docs/epistemic-contract.md`](docs/epistemic-contract.md) | **Normative epistemic contract** (grounded output vs funnel; ranking limits; telemetry proxies)—single authored source; other docs link or generate from here |
253
256
  | [README — Buy vs build](#buy-vs-build-why-not-only-sql-checks) | Canonical **buy vs build** narrative (failure mode, scripts limits, Quick → Contract) |
254
257
  | [`docs/agentskeptic.md`](docs/agentskeptic.md) | Authoritative CLI and behavior reference (SSOT) |
255
258
  | [`docs/quick-verify-normative.md`](docs/quick-verify-normative.md) | Quick Verify normative contract |
@@ -0,0 +1,8 @@
1
+ export type ParsedBootstrapCli = {
2
+ inputPath: string;
3
+ outPath: string;
4
+ dbPath: string | undefined;
5
+ postgresUrl: string | undefined;
6
+ };
7
+ export declare function parseBootstrapCliArgs(args: string[]): ParsedBootstrapCli;
8
+ //# sourceMappingURL=bootstrapCliArgs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrapCliArgs.d.ts","sourceRoot":"","sources":["../../src/bootstrap/bootstrapCliArgs.ts"],"names":[],"mappings":"AAiCA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,kBAAkB,CAiBxE"}
@@ -0,0 +1,47 @@
1
+ import { CLI_OPERATIONAL_CODES } from "../cliOperationalCodes.js";
2
+ import { TruthLayerError } from "../truthLayerError.js";
3
+ import { argValue } from "../cliArgv.js";
4
+ const ALLOWED_BOOTSTRAP_FLAGS = new Set([
5
+ "--input",
6
+ "--out",
7
+ "--db",
8
+ "--postgres-url",
9
+ "--help",
10
+ "-h",
11
+ ]);
12
+ function assertBootstrapArgsWellFormed(args) {
13
+ for (let i = 0; i < args.length; i++) {
14
+ const a = args[i];
15
+ if (a === "-h" || a === "--help")
16
+ continue;
17
+ if (!a.startsWith("--")) {
18
+ throw new TruthLayerError(CLI_OPERATIONAL_CODES.BOOTSTRAP_USAGE, `Unexpected argument: ${a}`);
19
+ }
20
+ if (!ALLOWED_BOOTSTRAP_FLAGS.has(a)) {
21
+ throw new TruthLayerError(CLI_OPERATIONAL_CODES.BOOTSTRAP_USAGE, `Unknown option: ${a}`);
22
+ }
23
+ if (a === "--input" || a === "--out" || a === "--db" || a === "--postgres-url") {
24
+ const v = args[i + 1];
25
+ if (v === undefined || v.startsWith("--")) {
26
+ throw new TruthLayerError(CLI_OPERATIONAL_CODES.BOOTSTRAP_USAGE, `Missing value after ${a}.`);
27
+ }
28
+ i++;
29
+ }
30
+ }
31
+ }
32
+ export function parseBootstrapCliArgs(args) {
33
+ assertBootstrapArgsWellFormed(args);
34
+ const inputPath = argValue(args, "--input");
35
+ const outPath = argValue(args, "--out");
36
+ const dbPath = argValue(args, "--db");
37
+ const postgresUrl = argValue(args, "--postgres-url");
38
+ if (!inputPath || !outPath) {
39
+ throw new TruthLayerError(CLI_OPERATIONAL_CODES.BOOTSTRAP_USAGE, "Missing --input or --out.");
40
+ }
41
+ const dbCount = (dbPath ? 1 : 0) + (postgresUrl ? 1 : 0);
42
+ if (dbCount !== 1) {
43
+ throw new TruthLayerError(CLI_OPERATIONAL_CODES.BOOTSTRAP_USAGE, "Provide exactly one of --db or --postgres-url.");
44
+ }
45
+ return { inputPath, outPath, dbPath, postgresUrl };
46
+ }
47
+ //# sourceMappingURL=bootstrapCliArgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrapCliArgs.js","sourceRoot":"","sources":["../../src/bootstrap/bootstrapCliArgs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC;IACtC,SAAS;IACT,OAAO;IACP,MAAM;IACN,gBAAgB;IAChB,QAAQ;IACR,IAAI;CACL,CAAC,CAAC;AAEH,SAAS,6BAA6B,CAAC,IAAc;IACnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC;QACnB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,QAAQ;YAAE,SAAS;QAC3C,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,eAAe,CAAC,qBAAqB,CAAC,eAAe,EAAE,wBAAwB,CAAC,EAAE,CAAC,CAAC;QAChG,CAAC;QACD,IAAI,CAAC,uBAA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C;IACzD,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;QAClB,MAAM,IAAI,eAAe,CACvB,qBAAqB,CAAC,eAAe,EACrC,gDAAgD,CACjD,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AACrD,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { WorkflowResult } from "../types.js";
2
+ import type { ParsedBootstrapCli } from "./bootstrapCliArgs.js";
3
+ export declare function cleanupOutDirFromPath(outResolved: string): void;
4
+ export type ExecuteBootstrapPackSuccess = {
5
+ kind: "pack_ready";
6
+ workflowId: string;
7
+ eventsPath: string;
8
+ registryPath: string;
9
+ outResolved: string;
10
+ exportedToolCount: number;
11
+ };
12
+ export type ExecuteBootstrapPackFailure = {
13
+ kind: "bootstrap_cli_error";
14
+ exitCode: 2 | 3;
15
+ code: string;
16
+ message: string;
17
+ } | {
18
+ kind: "verify_terminal";
19
+ exitCode: 1 | 2;
20
+ result: WorkflowResult;
21
+ truthBuffered: string;
22
+ outResolved: string;
23
+ };
24
+ /**
25
+ * Core bootstrap pack build + in-process contract verify.
26
+ * On success (`pack_ready`), leaves `outResolved` on disk.
27
+ * On `verify_terminal`, leaves `outResolved` on disk until the caller exits (caller must cleanup via exit hook).
28
+ * On `operational`, cleans up `outResolved` when it was created.
29
+ */
30
+ export declare function executeBootstrapPack(parsed: ParsedBootstrapCli): Promise<ExecuteBootstrapPackSuccess | ExecuteBootstrapPackFailure>;
31
+ export declare function writeBootstrapOperationalFailure(code: string, message: string): void;
32
+ //# sourceMappingURL=executeBootstrapPack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executeBootstrapPack.d.ts","sourceRoot":"","sources":["../../src/bootstrap/executeBootstrapPack.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AASlD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAM/D;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,2BAA2B,GACnC;IAAE,IAAI,EAAE,qBAAqB,CAAC;IAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC/E;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IAChB,MAAM,EAAE,cAAc,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEN;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,2BAA2B,GAAG,2BAA2B,CAAC,CAyLpE;AAED,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAEpF"}
@@ -0,0 +1,208 @@
1
+ import { existsSync, mkdirSync, readFileSync, rmSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { runLicensePreflightIfNeeded } from "../commercial/licensePreflight.js";
4
+ import { CLI_OPERATIONAL_CODES } from "../cliOperationalCodes.js";
5
+ import { cliErrorEnvelope, formatOperationalMessage, } from "../failureCatalog.js";
6
+ import { verifyWorkflow } from "../pipeline.js";
7
+ import { loadSchemaValidator } from "../schemaLoad.js";
8
+ import { TruthLayerError } from "../truthLayerError.js";
9
+ import { atomicWriteUtf8File } from "../quickVerify/atomicWrite.js";
10
+ import { buildQuickContractEventsNdjson } from "../quickVerify/buildQuickContractEventsNdjson.js";
11
+ import { stableStringify } from "../quickVerify/canonicalJson.js";
12
+ import { runQuickVerifyToValidatedReport } from "../quickVerify/runQuickVerify.js";
13
+ import { buildBootstrapReadmeMarkdown } from "./bootstrapReadmeTemplate.js";
14
+ import { parseBootstrapPackInputJson } from "./parseBootstrapPackInput.js";
15
+ import { synthesizeQuickInputUtf8FromOpenAiV1 } from "./synthesizeQuickInputFromOpenAiV1.js";
16
+ export function cleanupOutDirFromPath(outResolved) {
17
+ try {
18
+ rmSync(outResolved, { recursive: true, force: true });
19
+ }
20
+ catch {
21
+ /* best-effort */
22
+ }
23
+ }
24
+ /**
25
+ * Core bootstrap pack build + in-process contract verify.
26
+ * On success (`pack_ready`), leaves `outResolved` on disk.
27
+ * On `verify_terminal`, leaves `outResolved` on disk until the caller exits (caller must cleanup via exit hook).
28
+ * On `operational`, cleans up `outResolved` when it was created.
29
+ */
30
+ export async function executeBootstrapPack(parsed) {
31
+ const outResolved = path.resolve(parsed.outPath);
32
+ if (existsSync(outResolved)) {
33
+ return {
34
+ kind: "bootstrap_cli_error",
35
+ exitCode: 3,
36
+ code: CLI_OPERATIONAL_CODES.BOOTSTRAP_OUT_EXISTS,
37
+ message: `--out already exists: ${outResolved}`,
38
+ };
39
+ }
40
+ let rawInput;
41
+ try {
42
+ rawInput = readFileSync(path.resolve(parsed.inputPath), "utf8");
43
+ }
44
+ catch (e) {
45
+ const msg = e instanceof Error ? e.message : String(e);
46
+ return {
47
+ kind: "bootstrap_cli_error",
48
+ exitCode: 3,
49
+ code: CLI_OPERATIONAL_CODES.BOOTSTRAP_USAGE,
50
+ message: `Cannot read --input: ${msg}`,
51
+ };
52
+ }
53
+ let packInput;
54
+ try {
55
+ packInput = parseBootstrapPackInputJson(rawInput);
56
+ }
57
+ catch (e) {
58
+ if (e instanceof TruthLayerError) {
59
+ return { kind: "bootstrap_cli_error", exitCode: 3, code: e.code, message: e.message };
60
+ }
61
+ throw e;
62
+ }
63
+ try {
64
+ await runLicensePreflightIfNeeded("verify");
65
+ }
66
+ catch (e) {
67
+ if (e instanceof TruthLayerError) {
68
+ return { kind: "bootstrap_cli_error", exitCode: 3, code: e.code, message: e.message };
69
+ }
70
+ const msg = e instanceof Error ? e.message : String(e);
71
+ return {
72
+ kind: "bootstrap_cli_error",
73
+ exitCode: 3,
74
+ code: CLI_OPERATIONAL_CODES.INTERNAL_ERROR,
75
+ message: formatOperationalMessage(msg),
76
+ };
77
+ }
78
+ mkdirSync(outResolved, { recursive: false });
79
+ const database = parsed.postgresUrl
80
+ ? { kind: "postgres", connectionString: parsed.postgresUrl }
81
+ : { kind: "sqlite", path: path.resolve(parsed.dbPath) };
82
+ const inputUtf8 = synthesizeQuickInputUtf8FromOpenAiV1(packInput);
83
+ let report;
84
+ let registryUtf8;
85
+ let contractExports;
86
+ try {
87
+ const out = await runQuickVerifyToValidatedReport({
88
+ inputUtf8,
89
+ postgresUrl: parsed.postgresUrl ?? undefined,
90
+ sqlitePath: parsed.dbPath !== undefined ? path.resolve(parsed.dbPath) : undefined,
91
+ });
92
+ report = out.report;
93
+ registryUtf8 = out.registryUtf8;
94
+ contractExports = out.contractExports;
95
+ }
96
+ catch (e) {
97
+ cleanupOutDirFromPath(outResolved);
98
+ if (e instanceof TruthLayerError) {
99
+ return { kind: "bootstrap_cli_error", exitCode: 3, code: e.code, message: e.message };
100
+ }
101
+ const msg = e instanceof Error ? e.message : String(e);
102
+ return {
103
+ kind: "bootstrap_cli_error",
104
+ exitCode: 3,
105
+ code: CLI_OPERATIONAL_CODES.INTERNAL_ERROR,
106
+ message: formatOperationalMessage(msg),
107
+ };
108
+ }
109
+ if (report.verdict !== "pass") {
110
+ cleanupOutDirFromPath(outResolved);
111
+ return {
112
+ kind: "bootstrap_cli_error",
113
+ exitCode: 2,
114
+ code: CLI_OPERATIONAL_CODES.BOOTSTRAP_QUICK_NOT_PASS,
115
+ message: `Quick Verify verdict was "${report.verdict}" (expected pass).`,
116
+ };
117
+ }
118
+ if (contractExports.length === 0) {
119
+ cleanupOutDirFromPath(outResolved);
120
+ return {
121
+ kind: "bootstrap_cli_error",
122
+ exitCode: 2,
123
+ code: CLI_OPERATIONAL_CODES.BOOTSTRAP_NO_EXPORTABLE_TOOLS,
124
+ message: "Quick Verify produced zero exportable tools for contract replay.",
125
+ };
126
+ }
127
+ const eventsPath = path.join(outResolved, "events.ndjson");
128
+ const toolsPath = path.join(outResolved, "tools.json");
129
+ const quickReportPath = path.join(outResolved, "quick-report.json");
130
+ const readmePath = path.join(outResolved, "README.bootstrap.md");
131
+ try {
132
+ atomicWriteUtf8File(toolsPath, registryUtf8);
133
+ atomicWriteUtf8File(eventsPath, buildQuickContractEventsNdjson({
134
+ workflowId: packInput.workflowId,
135
+ exports: contractExports,
136
+ }));
137
+ atomicWriteUtf8File(quickReportPath, `${stableStringify(report)}\n`);
138
+ atomicWriteUtf8File(readmePath, buildBootstrapReadmeMarkdown(packInput.workflowId));
139
+ }
140
+ catch (e) {
141
+ cleanupOutDirFromPath(outResolved);
142
+ const msg = e instanceof Error ? e.message : String(e);
143
+ return {
144
+ kind: "bootstrap_cli_error",
145
+ exitCode: 3,
146
+ code: CLI_OPERATIONAL_CODES.INTERNAL_ERROR,
147
+ message: formatOperationalMessage(`pack write: ${msg}`),
148
+ };
149
+ }
150
+ let truthBuffered = "";
151
+ let result;
152
+ try {
153
+ result = await verifyWorkflow({
154
+ workflowId: packInput.workflowId,
155
+ eventsPath,
156
+ registryPath: toolsPath,
157
+ database,
158
+ truthReport: (r) => {
159
+ truthBuffered = r;
160
+ },
161
+ });
162
+ }
163
+ catch (e) {
164
+ cleanupOutDirFromPath(outResolved);
165
+ if (e instanceof TruthLayerError) {
166
+ return { kind: "bootstrap_cli_error", exitCode: 3, code: e.code, message: e.message };
167
+ }
168
+ const msg = e instanceof Error ? e.message : String(e);
169
+ return {
170
+ kind: "bootstrap_cli_error",
171
+ exitCode: 3,
172
+ code: CLI_OPERATIONAL_CODES.INTERNAL_ERROR,
173
+ message: formatOperationalMessage(msg),
174
+ };
175
+ }
176
+ const validateResult = loadSchemaValidator("workflow-result");
177
+ if (!validateResult(result)) {
178
+ cleanupOutDirFromPath(outResolved);
179
+ return {
180
+ kind: "bootstrap_cli_error",
181
+ exitCode: 3,
182
+ code: CLI_OPERATIONAL_CODES.WORKFLOW_RESULT_SCHEMA_INVALID,
183
+ message: JSON.stringify(validateResult.errors ?? []),
184
+ };
185
+ }
186
+ if (result.status === "complete") {
187
+ return {
188
+ kind: "pack_ready",
189
+ workflowId: packInput.workflowId,
190
+ eventsPath,
191
+ registryPath: toolsPath,
192
+ outResolved,
193
+ exportedToolCount: contractExports.length,
194
+ };
195
+ }
196
+ const exitCode = result.status === "inconsistent" ? 1 : 2;
197
+ return {
198
+ kind: "verify_terminal",
199
+ exitCode,
200
+ result,
201
+ truthBuffered,
202
+ outResolved,
203
+ };
204
+ }
205
+ export function writeBootstrapOperationalFailure(code, message) {
206
+ console.error(cliErrorEnvelope(code, formatOperationalMessage(message)));
207
+ }
208
+ //# sourceMappingURL=executeBootstrapPack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executeBootstrapPack.js","sourceRoot":"","sources":["../../src/bootstrap/executeBootstrapPack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EACL,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,eAA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| undefined;
5
- postgresUrl: string | undefined;
6
- };
7
- export declare function parseBootstrapCliArgs(args: string[]): ParsedBootstrapCli;
1
+ import { type ParsedBootstrapCli } from "./bootstrapCliArgs.js";
2
+ export type { ParsedBootstrapCli };
3
+ export { parseBootstrapCliArgs } from "./bootstrapCliArgs.js";
8
4
  export declare function runBootstrapSubcommand(args: string[]): Promise<void>;
9
5
  //# sourceMappingURL=runBootstrapSubcommand.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runBootstrapSubcommand.d.ts","sourceRoot":"","sources":["../../src/bootstrap/runBootstrapSubcommand.ts"],"names":[],"mappings":"AAuEA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,kBAAkB,CAiBxE;AAcD,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAmM1E"}
1
+ {"version":3,"file":"runBootstrapSubcommand.d.ts","sourceRoot":"","sources":["../../src/bootstrap/runBootstrapSubcommand.ts"],"names":[],"mappings":"AAUA,OAAO,EAAyB,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAoBvF,YAAY,EAAE,kBAAkB,EAAE,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA6D1E"}
@@ -1,29 +1,10 @@
1
- import { existsSync, mkdirSync, readFileSync, rmSync } from "node:fs";
2
- import path from "node:path";
3
- import { runLicensePreflightIfNeeded } from "../commercial/licensePreflight.js";
4
1
  import { CLI_OPERATIONAL_CODES } from "../cliOperationalCodes.js";
5
- import { cliErrorEnvelope, formatOperationalMessage, } from "../failureCatalog.js";
6
- import { verifyWorkflow } from "../pipeline.js";
7
- import { loadSchemaValidator } from "../schemaLoad.js";
8
- import { TruthLayerError } from "../truthLayerError.js";
2
+ import { formatOperationalMessage } from "../failureCatalog.js";
9
3
  import { formatDistributionFooter } from "../distributionFooter.js";
10
- import { atomicWriteUtf8File } from "../quickVerify/atomicWrite.js";
11
- import { buildQuickContractEventsNdjson } from "../quickVerify/buildQuickContractEventsNdjson.js";
12
- import { stableStringify } from "../quickVerify/canonicalJson.js";
13
- import { runQuickVerifyToValidatedReport } from "../quickVerify/runQuickVerify.js";
14
4
  import { emitVerifyWorkflowCliJsonAndExitByStatus } from "../standardVerifyWorkflowCli.js";
15
- import { buildBootstrapReadmeMarkdown } from "./bootstrapReadmeTemplate.js";
16
- import { parseBootstrapPackInputJson } from "./parseBootstrapPackInput.js";
17
- import { synthesizeQuickInputUtf8FromOpenAiV1 } from "./synthesizeQuickInputFromOpenAiV1.js";
18
- import { argValue } from "../cliArgv.js";
19
- const ALLOWED_BOOTSTRAP_FLAGS = new Set([
20
- "--input",
21
- "--out",
22
- "--db",
23
- "--postgres-url",
24
- "--help",
25
- "-h",
26
- ]);
5
+ import { TruthLayerError } from "../truthLayerError.js";
6
+ import { cleanupOutDirFromPath, executeBootstrapPack, writeBootstrapOperationalFailure, } from "./executeBootstrapPack.js";
7
+ import { parseBootstrapCliArgs } from "./bootstrapCliArgs.js";
27
8
  function usageBootstrap() {
28
9
  return `Usage:
29
10
  agentskeptic bootstrap --input <path> (--db <sqlitePath> | --postgres-url <url>) --out <path>
@@ -41,52 +22,7 @@ Exit codes:
41
22
 
42
23
  Normative: docs/bootstrap-pack-normative.md`;
43
24
  }
44
- function assertBootstrapArgsWellFormed(args) {
45
- for (let i = 0; i < args.length; i++) {
46
- const a = args[i];
47
- if (a === "-h" || a === "--help")
48
- continue;
49
- if (!a.startsWith("--")) {
50
- throw new TruthLayerError(CLI_OPERATIONAL_CODES.BOOTSTRAP_USAGE, `Unexpected argument: ${a}`);
51
- }
52
- if (!ALLOWED_BOOTSTRAP_FLAGS.has(a)) {
53
- throw new TruthLayerError(CLI_OPERATIONAL_CODES.BOOTSTRAP_USAGE, `Unknown option: ${a}`);
54
- }
55
- if (a === "--input" || a === "--out" || a === "--db" || a === "--postgres-url") {
56
- const v = args[i + 1];
57
- if (v === undefined || v.startsWith("--")) {
58
- throw new TruthLayerError(CLI_OPERATIONAL_CODES.BOOTSTRAP_USAGE, `Missing value after ${a}.`);
59
- }
60
- i++;
61
- }
62
- }
63
- }
64
- export function parseBootstrapCliArgs(args) {
65
- assertBootstrapArgsWellFormed(args);
66
- const inputPath = argValue(args, "--input");
67
- const outPath = argValue(args, "--out");
68
- const dbPath = argValue(args, "--db");
69
- const postgresUrl = argValue(args, "--postgres-url");
70
- if (!inputPath || !outPath) {
71
- throw new TruthLayerError(CLI_OPERATIONAL_CODES.BOOTSTRAP_USAGE, "Missing --input or --out.");
72
- }
73
- const dbCount = (dbPath ? 1 : 0) + (postgresUrl ? 1 : 0);
74
- if (dbCount !== 1) {
75
- throw new TruthLayerError(CLI_OPERATIONAL_CODES.BOOTSTRAP_USAGE, "Provide exactly one of --db or --postgres-url.");
76
- }
77
- return { inputPath, outPath, dbPath, postgresUrl };
78
- }
79
- function writeBootstrapCliError(code, message) {
80
- console.error(cliErrorEnvelope(code, formatOperationalMessage(message)));
81
- }
82
- function cleanupOutDir(outResolved) {
83
- try {
84
- rmSync(outResolved, { recursive: true, force: true });
85
- }
86
- catch {
87
- /* best-effort */
88
- }
89
- }
25
+ export { parseBootstrapCliArgs } from "./bootstrapCliArgs.js";
90
26
  export async function runBootstrapSubcommand(args) {
91
27
  if (args.includes("--help") || args.includes("-h")) {
92
28
  console.log(usageBootstrap());
@@ -98,162 +34,46 @@ export async function runBootstrapSubcommand(args) {
98
34
  }
99
35
  catch (e) {
100
36
  if (e instanceof TruthLayerError) {
101
- writeBootstrapCliError(e.code, e.message);
37
+ writeBootstrapOperationalFailure(e.code, e.message);
102
38
  process.exit(3);
103
39
  }
104
40
  throw e;
105
41
  }
106
- const outResolved = path.resolve(parsed.outPath);
107
- if (existsSync(outResolved)) {
108
- writeBootstrapCliError(CLI_OPERATIONAL_CODES.BOOTSTRAP_OUT_EXISTS, `--out already exists: ${outResolved}`);
109
- process.exit(3);
110
- }
111
- let rawInput;
112
- try {
113
- rawInput = readFileSync(path.resolve(parsed.inputPath), "utf8");
114
- }
115
- catch (e) {
116
- const msg = e instanceof Error ? e.message : String(e);
117
- writeBootstrapCliError(CLI_OPERATIONAL_CODES.BOOTSTRAP_USAGE, `Cannot read --input: ${msg}`);
118
- process.exit(3);
119
- }
120
- let packInput;
121
- try {
122
- packInput = parseBootstrapPackInputJson(rawInput);
123
- }
124
- catch (e) {
125
- if (e instanceof TruthLayerError) {
126
- writeBootstrapCliError(e.code, e.message);
127
- process.exit(3);
128
- }
129
- throw e;
130
- }
131
- try {
132
- await runLicensePreflightIfNeeded("verify");
133
- }
134
- catch (e) {
135
- if (e instanceof TruthLayerError) {
136
- writeBootstrapCliError(e.code, e.message);
137
- process.exit(3);
138
- }
139
- const msg = e instanceof Error ? e.message : String(e);
140
- writeBootstrapCliError(CLI_OPERATIONAL_CODES.INTERNAL_ERROR, formatOperationalMessage(msg));
141
- process.exit(3);
142
- }
143
- mkdirSync(outResolved, { recursive: false });
144
- const database = parsed.postgresUrl
145
- ? { kind: "postgres", connectionString: parsed.postgresUrl }
146
- : { kind: "sqlite", path: path.resolve(parsed.dbPath) };
147
- const inputUtf8 = synthesizeQuickInputUtf8FromOpenAiV1(packInput);
148
- let report;
149
- let registryUtf8;
150
- let contractExports;
151
- try {
152
- const out = await runQuickVerifyToValidatedReport({
153
- inputUtf8,
154
- postgresUrl: parsed.postgresUrl ?? undefined,
155
- sqlitePath: parsed.dbPath !== undefined ? path.resolve(parsed.dbPath) : undefined,
156
- });
157
- report = out.report;
158
- registryUtf8 = out.registryUtf8;
159
- contractExports = out.contractExports;
160
- }
161
- catch (e) {
162
- cleanupOutDir(outResolved);
163
- if (e instanceof TruthLayerError) {
164
- writeBootstrapCliError(e.code, e.message);
165
- process.exit(3);
166
- }
167
- const msg = e instanceof Error ? e.message : String(e);
168
- writeBootstrapCliError(CLI_OPERATIONAL_CODES.INTERNAL_ERROR, formatOperationalMessage(msg));
169
- process.exit(3);
170
- }
171
- if (report.verdict !== "pass") {
172
- cleanupOutDir(outResolved);
173
- writeBootstrapCliError(CLI_OPERATIONAL_CODES.BOOTSTRAP_QUICK_NOT_PASS, `Quick Verify verdict was "${report.verdict}" (expected pass).`);
174
- process.exit(2);
175
- }
176
- if (contractExports.length === 0) {
177
- cleanupOutDir(outResolved);
178
- writeBootstrapCliError(CLI_OPERATIONAL_CODES.BOOTSTRAP_NO_EXPORTABLE_TOOLS, "Quick Verify produced zero exportable tools for contract replay.");
179
- process.exit(2);
180
- }
181
- const eventsPath = path.join(outResolved, "events.ndjson");
182
- const toolsPath = path.join(outResolved, "tools.json");
183
- const quickReportPath = path.join(outResolved, "quick-report.json");
184
- const readmePath = path.join(outResolved, "README.bootstrap.md");
185
- try {
186
- atomicWriteUtf8File(toolsPath, registryUtf8);
187
- atomicWriteUtf8File(eventsPath, buildQuickContractEventsNdjson({
188
- workflowId: packInput.workflowId,
189
- exports: contractExports,
190
- }));
191
- atomicWriteUtf8File(quickReportPath, `${stableStringify(report)}\n`);
192
- atomicWriteUtf8File(readmePath, buildBootstrapReadmeMarkdown(packInput.workflowId));
193
- }
194
- catch (e) {
195
- cleanupOutDir(outResolved);
196
- const msg = e instanceof Error ? e.message : String(e);
197
- writeBootstrapCliError(CLI_OPERATIONAL_CODES.INTERNAL_ERROR, formatOperationalMessage(`pack write: ${msg}`));
198
- process.exit(3);
199
- }
200
- let truthBuffered = "";
201
- let result;
202
- try {
203
- result = await verifyWorkflow({
204
- workflowId: packInput.workflowId,
205
- eventsPath,
206
- registryPath: toolsPath,
207
- database,
208
- truthReport: (r) => {
209
- truthBuffered = r;
210
- },
211
- });
212
- }
213
- catch (e) {
214
- cleanupOutDir(outResolved);
215
- if (e instanceof TruthLayerError) {
216
- writeBootstrapCliError(e.code, e.message);
217
- process.exit(3);
218
- }
219
- const msg = e instanceof Error ? e.message : String(e);
220
- writeBootstrapCliError(CLI_OPERATIONAL_CODES.INTERNAL_ERROR, formatOperationalMessage(msg));
221
- process.exit(3);
222
- }
223
- const validateResult = loadSchemaValidator("workflow-result");
224
- if (!validateResult(result)) {
225
- cleanupOutDir(outResolved);
226
- writeBootstrapCliError(CLI_OPERATIONAL_CODES.WORKFLOW_RESULT_SCHEMA_INVALID, JSON.stringify(validateResult.errors ?? []));
227
- process.exit(3);
228
- }
229
- if (result.status === "complete") {
42
+ const outcome = await executeBootstrapPack(parsed);
43
+ if (outcome.kind === "pack_ready") {
230
44
  const envelope = {
231
45
  schemaVersion: 1,
232
46
  kind: "agentskeptic_bootstrap_result",
233
- workflowId: packInput.workflowId,
234
- outDir: outResolved,
47
+ workflowId: outcome.workflowId,
48
+ outDir: outcome.outResolved,
235
49
  quickVerdict: "pass",
236
50
  verifyStatus: "complete",
237
- exportedToolCount: contractExports.length,
51
+ exportedToolCount: outcome.exportedToolCount,
238
52
  };
239
53
  try {
240
54
  process.stdout.write(`${JSON.stringify(envelope)}\n`);
241
55
  }
242
56
  catch (e) {
243
- cleanupOutDir(outResolved);
57
+ cleanupOutDirFromPath(outcome.outResolved);
244
58
  const msg = e instanceof Error ? e.message : String(e);
245
- writeBootstrapCliError(CLI_OPERATIONAL_CODES.INTERNAL_ERROR, formatOperationalMessage(`stdout: ${msg}`));
59
+ writeBootstrapOperationalFailure(CLI_OPERATIONAL_CODES.INTERNAL_ERROR, formatOperationalMessage(`stdout: ${msg}`));
246
60
  process.exit(3);
247
61
  }
248
62
  process.exit(0);
63
+ return;
64
+ }
65
+ if (outcome.kind === "bootstrap_cli_error") {
66
+ writeBootstrapOperationalFailure(outcome.code, outcome.message);
67
+ process.exit(outcome.exitCode);
68
+ return;
249
69
  }
250
- process.stderr.write(`${truthBuffered}\n`);
70
+ process.stderr.write(`${outcome.truthBuffered}\n`);
251
71
  process.stderr.write(formatDistributionFooter());
252
72
  const exitWithCleanup = (code) => {
253
- cleanupOutDir(outResolved);
73
+ cleanupOutDirFromPath(outcome.outResolved);
254
74
  process.exit(code);
255
75
  };
256
- emitVerifyWorkflowCliJsonAndExitByStatus(result, {
76
+ emitVerifyWorkflowCliJsonAndExitByStatus(outcome.result, {
257
77
  consoleLog: (line) => {
258
78
  console.log(line);
259
79
  },