@patronage/software-factory 1.0.0-alpha.26 → 1.0.0-alpha.27

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/dist/cli.js ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import { PrPublishFollowUpError, run } from "./index.js";
3
+ //#region src/cli.ts
4
+ try {
5
+ await run(process.argv, import.meta.filename);
6
+ } catch (error) {
7
+ if (error instanceof PrPublishFollowUpError) console.error(JSON.stringify(error.result, null, 2));
8
+ else console.error("\nError:", error instanceof Error ? error.message : String(error));
9
+ process.exit(1);
10
+ }
11
+ //#endregion
12
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { existsSync, readFileSync, rmSync } from "node:fs";
2
1
  import { Command } from "commander";
3
2
  import { z } from "zod";
3
+ import { existsSync, readFileSync, rmSync } from "node:fs";
4
4
  import { PreviewProofRegistration } from "@patronage/factory-ci";
5
5
 
6
6
  //#region src/review-rungs.d.ts
@@ -17,8 +17,8 @@ declare const boundaryManifestBaseSchema: z.ZodObject<{
17
17
  boundary: z.ZodString;
18
18
  closeout: z.ZodOptional<z.ZodObject<{
19
19
  review: z.ZodEnum<{
20
- oracle: "oracle";
21
20
  "independent-model": "independent-model";
21
+ oracle: "oracle";
22
22
  human: "human";
23
23
  }>;
24
24
  }, z.core.$loose>>;
@@ -26,8 +26,8 @@ declare const boundaryManifestBaseSchema: z.ZodObject<{
26
26
  integrationBranch: z.ZodOptional<z.ZodString>;
27
27
  schemaVersion: z.ZodLiteral<1>;
28
28
  topology: z.ZodEnum<{
29
- flagged: "flagged";
30
29
  "each-to-main": "each-to-main";
30
+ flagged: "flagged";
31
31
  stacked: "stacked";
32
32
  "each-to-epic": "each-to-epic";
33
33
  }>;
@@ -36,8 +36,8 @@ declare const boundaryManifestBaseSchema: z.ZodObject<{
36
36
  issues: z.ZodArray<z.ZodNumber>;
37
37
  name: z.ZodString;
38
38
  review: z.ZodEnum<{
39
- oracle: "oracle";
40
39
  "independent-model": "independent-model";
40
+ oracle: "oracle";
41
41
  human: "human";
42
42
  }>;
43
43
  }, z.core.$loose>>;
@@ -46,8 +46,8 @@ declare const boundaryManifestSchema: z.ZodObject<{
46
46
  boundary: z.ZodString;
47
47
  closeout: z.ZodOptional<z.ZodObject<{
48
48
  review: z.ZodEnum<{
49
- oracle: "oracle";
50
49
  "independent-model": "independent-model";
50
+ oracle: "oracle";
51
51
  human: "human";
52
52
  }>;
53
53
  }, z.core.$loose>>;
@@ -55,8 +55,8 @@ declare const boundaryManifestSchema: z.ZodObject<{
55
55
  integrationBranch: z.ZodOptional<z.ZodString>;
56
56
  schemaVersion: z.ZodLiteral<1>;
57
57
  topology: z.ZodEnum<{
58
- flagged: "flagged";
59
58
  "each-to-main": "each-to-main";
59
+ flagged: "flagged";
60
60
  stacked: "stacked";
61
61
  "each-to-epic": "each-to-epic";
62
62
  }>;
@@ -65,8 +65,8 @@ declare const boundaryManifestSchema: z.ZodObject<{
65
65
  issues: z.ZodArray<z.ZodNumber>;
66
66
  name: z.ZodString;
67
67
  review: z.ZodEnum<{
68
- oracle: "oracle";
69
68
  "independent-model": "independent-model";
69
+ oracle: "oracle";
70
70
  human: "human";
71
71
  }>;
72
72
  }, z.core.$loose>>;
@@ -151,8 +151,8 @@ declare const boundaryReviewProofBaseSchema: z.ZodObject<{
151
151
  }>;
152
152
  producer: z.ZodString;
153
153
  rung: z.ZodEnum<{
154
- oracle: "oracle";
155
154
  "independent-model": "independent-model";
155
+ oracle: "oracle";
156
156
  human: "human";
157
157
  }>;
158
158
  schemaVersion: z.ZodLiteral<1>;
@@ -195,8 +195,8 @@ declare const boundaryReviewProofSchema: z.ZodObject<{
195
195
  }>;
196
196
  producer: z.ZodString;
197
197
  rung: z.ZodEnum<{
198
- oracle: "oracle";
199
198
  "independent-model": "independent-model";
199
+ oracle: "oracle";
200
200
  human: "human";
201
201
  }>;
202
202
  schemaVersion: z.ZodLiteral<1>;
@@ -1186,6 +1186,58 @@ declare const followUpFromArgv: (argv: string[]) => FollowUpAction;
1186
1186
  /** Canonical zod schema for the optional follow-up field on JSON outputs. */
1187
1187
  declare const FollowUpActionSchema: z.ZodType<FollowUpAction>;
1188
1188
  //#endregion
1189
+ //#region src/user-config.d.ts
1190
+ declare const githubAppConfigSchema: z.ZodObject<{
1191
+ appId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
1192
+ installationId: z.ZodOptional<z.ZodNumber>;
1193
+ privateKeyPath: z.ZodString;
1194
+ }, z.core.$strip>;
1195
+ type GithubAppConfig = z.infer<typeof githubAppConfigSchema>;
1196
+ declare const factoryUserConfigSchema: z.ZodObject<{
1197
+ githubApp: z.ZodOptional<z.ZodObject<{
1198
+ appId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
1199
+ installationId: z.ZodOptional<z.ZodNumber>;
1200
+ privateKeyPath: z.ZodString;
1201
+ }, z.core.$strip>>;
1202
+ hqAllowedOrigins: z.ZodOptional<z.ZodArray<z.ZodString>>;
1203
+ hqIngestCredentials: z.ZodOptional<z.ZodObject<{
1204
+ clientIdRef: z.ZodString;
1205
+ clientSecretRef: z.ZodString;
1206
+ }, z.core.$strip>>;
1207
+ schemaVersion: z.ZodLiteral<2>;
1208
+ }, z.core.$strip>;
1209
+ type FactoryUserConfig = z.infer<typeof factoryUserConfigSchema>;
1210
+ interface LoadUserConfigResult {
1211
+ path: string;
1212
+ config: FactoryUserConfig;
1213
+ ignoredKeys?: string[];
1214
+ }
1215
+ //#endregion
1216
+ //#region src/github-app-access.d.ts
1217
+ interface FactoryAppAccessDependencies {
1218
+ env?: NodeJS.ProcessEnv;
1219
+ existsSync?: (path: string) => boolean;
1220
+ exchangeBroker?: (input: {
1221
+ fetch?: typeof fetch;
1222
+ oidc: string;
1223
+ owner: string;
1224
+ repo: string;
1225
+ timeoutMs?: number;
1226
+ url?: string;
1227
+ }) => Promise<string>;
1228
+ fetch?: typeof fetch;
1229
+ githubApp?: GithubAppConfig;
1230
+ mintCursorOidc?: (input: {
1231
+ audience?: string;
1232
+ socketPath?: string;
1233
+ timeoutMs?: number;
1234
+ }) => Promise<string>;
1235
+ now?: () => number;
1236
+ timeoutMs?: number;
1237
+ token?: string;
1238
+ transportAttempts?: number;
1239
+ }
1240
+ //#endregion
1189
1241
  //#region src/pr-verify-mode.d.ts
1190
1242
  /**
1191
1243
  * The verification mode `pr:verify` resolved for a run.
@@ -1222,33 +1274,6 @@ interface PostCommitStatusInput {
1222
1274
  }
1223
1275
  type PostCommitStatus = (input: PostCommitStatusInput) => void;
1224
1276
  //#endregion
1225
- //#region src/user-config.d.ts
1226
- declare const githubAppConfigSchema: z.ZodObject<{
1227
- appId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
1228
- installationId: z.ZodOptional<z.ZodNumber>;
1229
- privateKeyPath: z.ZodString;
1230
- }, z.core.$strip>;
1231
- type GithubAppConfig = z.infer<typeof githubAppConfigSchema>;
1232
- declare const factoryUserConfigSchema: z.ZodObject<{
1233
- githubApp: z.ZodOptional<z.ZodObject<{
1234
- appId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
1235
- installationId: z.ZodOptional<z.ZodNumber>;
1236
- privateKeyPath: z.ZodString;
1237
- }, z.core.$strip>>;
1238
- hqAllowedOrigins: z.ZodOptional<z.ZodArray<z.ZodString>>;
1239
- hqIngestCredentials: z.ZodOptional<z.ZodObject<{
1240
- clientIdRef: z.ZodString;
1241
- clientSecretRef: z.ZodString;
1242
- }, z.core.$strip>>;
1243
- schemaVersion: z.ZodLiteral<2>;
1244
- }, z.core.$strip>;
1245
- type FactoryUserConfig = z.infer<typeof factoryUserConfigSchema>;
1246
- interface LoadUserConfigResult {
1247
- path: string;
1248
- config: FactoryUserConfig;
1249
- ignoredKeys?: string[];
1250
- }
1251
- //#endregion
1252
1277
  //#region src/github-check-runs.d.ts
1253
1278
  declare const FACTORY_CHECK_NAMES: {
1254
1279
  readonly "pr-ready": "patronage-factory/pr-ready";
@@ -1273,10 +1298,7 @@ interface PublishFactoryCheckInput {
1273
1298
  sha: string;
1274
1299
  status?: "completed" | "in_progress";
1275
1300
  }
1276
- interface CheckRunDependencies {
1277
- fetch?: typeof fetch;
1278
- githubApp?: GithubAppConfig;
1279
- now?: () => number;
1301
+ interface CheckRunDependencies extends FactoryAppAccessDependencies {
1280
1302
  postCommitStatus?: PostCommitStatus;
1281
1303
  resolveDetailsUrl?: (input: PublishFactoryCheckInput) => Promise<string> | string;
1282
1304
  /**
@@ -1291,18 +1313,18 @@ interface CheckRunDependencies {
1291
1313
  };
1292
1314
  /** Injectable delay for the bounded retry (tests only). */
1293
1315
  sleep?: (ms: number) => Promise<void>;
1294
- /** Overrides GITHUB_PUBLISH_TIMEOUT_MS for the App fetch calls (tests only). */
1295
- timeoutMs?: number;
1296
1316
  }
1297
1317
  /**
1298
1318
  * Publish a factory check run and *wait* for it, so a caller that has just made
1299
1319
  * the head SHA visible on GitHub (pushed the branch, created the PR) can make
1300
1320
  * the proof reliably present for that SHA before it returns (#247).
1301
1321
  *
1302
- * Never throws and never posts a commit-status fallback: the commit status is a
1303
- * human-readable mirror, not a proof surface, so a caller that needs an
1304
- * App-verified check run must be told plainly whether it got one. Returns
1305
- * `true` only when the App-owned check run landed.
1322
+ * Never posts a commit-status fallback: the commit status is a human-readable
1323
+ * mirror, not a proof surface, so a caller that needs an App-verified check
1324
+ * run must be told plainly whether it got one. Returns `true` only when the
1325
+ * App-owned check run landed. Throws when Factory App access is fail-closed
1326
+ * (missing mint or Cursor OIDC exchange, #949): `pr:ready` must not notice
1327
+ * that miss and exit 0. An optional-App skip still returns `false`.
1306
1328
  *
1307
1329
  * "Landed" means GitHub serves it, not that the POST was accepted (#520). On
1308
1330
  * PR #519 the POST was accepted, `pr:ready` reported ready and armed, and the
@@ -1338,8 +1360,8 @@ declare const mergeFreezeStateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1338
1360
  generationId: z.ZodNumber;
1339
1361
  headSha: z.ZodString;
1340
1362
  outcome: z.ZodEnum<{
1341
- active: "active";
1342
1363
  stale: "stale";
1364
+ active: "active";
1343
1365
  }>;
1344
1366
  reason: z.ZodString;
1345
1367
  recordedAt: z.ZodISODateTime;
@@ -1501,9 +1523,9 @@ declare const managedReadinessLedgerSchema: z.ZodObject<{
1501
1523
  mergeable: z.ZodString;
1502
1524
  requiredChecks: z.ZodEnum<{
1503
1525
  unknown: "unknown";
1504
- pending: "pending";
1505
1526
  passed: "passed";
1506
1527
  failed: "failed";
1528
+ pending: "pending";
1507
1529
  none: "none";
1508
1530
  }>;
1509
1531
  reviewDecision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -1569,8 +1591,8 @@ declare const managedReadinessLedgerSchema: z.ZodObject<{
1569
1591
  "run-interior-cycle": "run-interior-cycle";
1570
1592
  }>;
1571
1593
  stage: z.ZodEnum<{
1572
- interior: "interior";
1573
1594
  gate: "gate";
1595
+ interior: "interior";
1574
1596
  "interior-complete": "interior-complete";
1575
1597
  }>;
1576
1598
  }, z.core.$strip>>;
@@ -1586,10 +1608,10 @@ declare const managedReadinessLedgerSchema: z.ZodObject<{
1586
1608
  reviewedHeadSha: z.ZodOptional<z.ZodString>;
1587
1609
  reviewedPatchId: z.ZodOptional<z.ZodString>;
1588
1610
  status: z.ZodEnum<{
1589
- stale: "stale";
1590
- "not-required": "not-required";
1591
1611
  blocked: "blocked";
1612
+ "not-required": "not-required";
1592
1613
  current: "current";
1614
+ stale: "stale";
1593
1615
  missing: "missing";
1594
1616
  }>;
1595
1617
  }, z.core.$strip>;
@@ -1598,10 +1620,10 @@ declare const managedReadinessLedgerSchema: z.ZodObject<{
1598
1620
  reviewedHeadSha: z.ZodOptional<z.ZodString>;
1599
1621
  reviewedPatchId: z.ZodOptional<z.ZodString>;
1600
1622
  status: z.ZodEnum<{
1601
- stale: "stale";
1602
- "not-required": "not-required";
1603
1623
  blocked: "blocked";
1624
+ "not-required": "not-required";
1604
1625
  current: "current";
1626
+ stale: "stale";
1605
1627
  missing: "missing";
1606
1628
  }>;
1607
1629
  }, z.core.$strip>>;
@@ -1735,7 +1757,15 @@ interface UpsertFactoryPrStatusCommentResult {
1735
1757
  declare function upsertFactoryPrStatusComment(input: UpsertFactoryPrStatusCommentInput, dependencies?: UpsertFactoryPrStatusCommentDependencies): Promise<UpsertFactoryPrStatusCommentResult>;
1736
1758
  //#endregion
1737
1759
  //#region src/pr-verify-proof-contract.d.ts
1738
- declare const SUPPORTED_PR_VERIFY_SCHEMA_VERSIONS: readonly [1, 2, 3, 4];
1760
+ /**
1761
+ * The pr:verify proof versions a reader accepts: the current one only (#920
1762
+ * item 1). #917 narrowed the pr:ready reader the same way. A pr:verify proof
1763
+ * is per-candidate and short-lived — it is rewritten on every head — so no
1764
+ * stored v1–v3 proof can outlive the release that drops it. Pre-1.0 posture
1765
+ * applies: one current contract, no compat reader. A consumer on an older
1766
+ * factory must adopt this release before HQ ingests its pr:verify proofs.
1767
+ */
1768
+ declare const SUPPORTED_PR_VERIFY_SCHEMA_VERSIONS: readonly [4];
1739
1769
  type PrVerifySchemaVersion = (typeof SUPPORTED_PR_VERIFY_SCHEMA_VERSIONS)[number];
1740
1770
  interface PrVerifyCommandResult {
1741
1771
  command: string;
@@ -1746,11 +1776,11 @@ interface PrVerifyCommandResult {
1746
1776
  * mapping: a `notRequiredCommands` entry must name the target recorded HERE
1747
1777
  * for the same command, so a withholding cannot point at whichever released
1748
1778
  * target happens to be convenient. Absent for a command the profile does
1749
- * not scope, and for v1–v3 proofs, which predate the field.
1779
+ * not scope.
1750
1780
  */
1751
1781
  impactTarget?: string;
1752
1782
  name: string;
1753
- scope: "always" | "docs-only" | "trivial" | "full";
1783
+ scope: "docs-only" | "trivial" | "full";
1754
1784
  }
1755
1785
  interface PrVerifyExecutedCommand {
1756
1786
  command: string;
@@ -1761,7 +1791,7 @@ interface PrVerifyExecutedCommand {
1761
1791
  durationMs: number;
1762
1792
  exitCode: number;
1763
1793
  name: string;
1764
- scope: "always" | "docs-only" | "trivial" | "full";
1794
+ scope: "docs-only" | "trivial" | "full";
1765
1795
  }
1766
1796
  /**
1767
1797
  * Epic #550 wave 3 (#430): a verification command the impact stamp proved this
@@ -1780,8 +1810,7 @@ interface PrVerifyNotRequiredCommand {
1780
1810
  }
1781
1811
  /**
1782
1812
  * Epic #758 (#762): a consumer package a stamp-scoped selection skipped, and
1783
- * why. Bound to the proof's stamp identity — the field is v4-only (the same
1784
- * window that can carry `impactStamp`) and refused when the proof records no
1813
+ * why. Bound to the proof's stamp identity — refused when the proof records no
1785
1814
  * stamp. The factory does not write this list; consumers do.
1786
1815
  */
1787
1816
  interface PrVerifyNotDemandedRecord {
@@ -1790,7 +1819,7 @@ interface PrVerifyNotDemandedRecord {
1790
1819
  }
1791
1820
  interface PrVerifyProof {
1792
1821
  schemaVersion: PrVerifySchemaVersion;
1793
- authoringSession?: string;
1822
+ authoringSession: string;
1794
1823
  base: string;
1795
1824
  baselineFullProofs?: {
1796
1825
  base: string;
@@ -1883,7 +1912,7 @@ declare const trustedImpactStamp: ({
1883
1912
  /**
1884
1913
  * #833: the recorded catch-up recognition, consumed ONLY when it is
1885
1914
  * identity-bound to the current candidate under exactly the rules
1886
- * `trustedImpactStamp` applies — the proof passed, is v4+, and its recorded
1915
+ * `trustedImpactStamp` applies — the proof passed, and its recorded
1887
1916
  * headSha AND patchId both name this candidate. The recognition withdraws
1888
1917
  * review and preview demands, so it earns the same strict double binding and
1889
1918
  * the same fail-closed answer (`undefined`) on every other state.
@@ -2438,7 +2467,8 @@ interface PrReadyGitDependencies {
2438
2467
  fetchOriginRef?: (cwd: string, refName: string) => void;
2439
2468
  currentHeadSha: (cwd: string) => string;
2440
2469
  mergeBaseSha: (cwd: string, base: string) => string;
2441
- objectIdAtRef: (cwd: string, ref: string, absolutePath: string) => string | undefined;
2470
+ /** `repositoryRelativePath` is repository-relative, never cwd-relative. */
2471
+ objectIdAtRef: (cwd: string, ref: string, repositoryRelativePath: string) => string | undefined;
2442
2472
  resolveCommitSha: (cwd: string, ref: string) => string | undefined;
2443
2473
  showFileAtRef: (cwd: string, ref: string, absolutePath: string) => string | undefined;
2444
2474
  stablePatchId: (cwd: string, base: string) => string;
@@ -2478,8 +2508,8 @@ declare const evidenceEnvelopeBaseSchema: z.ZodObject<{
2478
2508
  producer: z.ZodString;
2479
2509
  requestId: z.ZodOptional<z.ZodString>;
2480
2510
  rung: z.ZodOptional<z.ZodEnum<{
2481
- oracle: "oracle";
2482
2511
  "independent-model": "independent-model";
2512
+ oracle: "oracle";
2483
2513
  human: "human";
2484
2514
  }>>;
2485
2515
  schemaVersion: z.ZodLiteral<1>;
@@ -2505,8 +2535,8 @@ declare const evidenceEnvelopeSchema: z.ZodObject<{
2505
2535
  producer: z.ZodString;
2506
2536
  requestId: z.ZodOptional<z.ZodString>;
2507
2537
  rung: z.ZodOptional<z.ZodEnum<{
2508
- oracle: "oracle";
2509
2538
  "independent-model": "independent-model";
2539
+ oracle: "oracle";
2510
2540
  human: "human";
2511
2541
  }>>;
2512
2542
  schemaVersion: z.ZodLiteral<1>;
@@ -2608,10 +2638,10 @@ declare const loadEvidenceEnvelopes: (cwd: string) => LoadedEvidenceEnvelope[];
2608
2638
  //#region src/review-proof-applicability.d.ts
2609
2639
  declare const REVIEW_STATUS_VALUES: readonly ["not-required", "current", "stale", "missing", "blocked"];
2610
2640
  declare const reviewStatusSchema: z.ZodEnum<{
2611
- stale: "stale";
2612
- "not-required": "not-required";
2613
2641
  blocked: "blocked";
2642
+ "not-required": "not-required";
2614
2643
  current: "current";
2644
+ stale: "stale";
2615
2645
  missing: "missing";
2616
2646
  }>;
2617
2647
  type ReviewStatus = z.infer<typeof reviewStatusSchema>;
@@ -2726,8 +2756,8 @@ declare const boundaryCheckProofSchema: z.ZodObject<{
2726
2756
  wave: z.ZodString;
2727
2757
  }, z.core.$strip>>;
2728
2758
  demandedRung: z.ZodOptional<z.ZodEnum<{
2729
- oracle: "oracle";
2730
2759
  "independent-model": "independent-model";
2760
+ oracle: "oracle";
2731
2761
  human: "human";
2732
2762
  }>>;
2733
2763
  epicIssue: z.ZodNumber;
@@ -2742,8 +2772,8 @@ declare const boundaryCheckProofSchema: z.ZodObject<{
2742
2772
  commentUrl: z.ZodOptional<z.ZodString>;
2743
2773
  producer: z.ZodString;
2744
2774
  rung: z.ZodEnum<{
2745
- oracle: "oracle";
2746
2775
  "independent-model": "independent-model";
2776
+ oracle: "oracle";
2747
2777
  human: "human";
2748
2778
  }>;
2749
2779
  sessionId: z.ZodOptional<z.ZodString>;
@@ -2759,8 +2789,8 @@ declare const boundaryCheckProofSchema: z.ZodObject<{
2759
2789
  value: z.ZodString;
2760
2790
  }, z.core.$strip>>;
2761
2791
  status: z.ZodEnum<{
2762
- ready: "ready";
2763
2792
  blocked: "blocked";
2793
+ ready: "ready";
2764
2794
  }>;
2765
2795
  }, z.core.$strip>;
2766
2796
  type BoundaryCheckProofRecord = z.infer<typeof boundaryCheckProofSchema>;
@@ -3272,11 +3302,11 @@ declare const LegacyWorkerCloseoutStatusTraceEventSchema: z.ZodObject<{
3272
3302
  threadId: z.ZodOptional<z.ZodString>;
3273
3303
  workerId: z.ZodOptional<z.ZodString>;
3274
3304
  archiveStatus: z.ZodOptional<z.ZodEnum<{
3305
+ pending: "pending";
3275
3306
  unavailable: "unavailable";
3276
3307
  archived: "archived";
3277
3308
  skipped: "skipped";
3278
3309
  "not-applicable": "not-applicable";
3279
- pending: "pending";
3280
3310
  }>>;
3281
3311
  closeoutReason: z.ZodOptional<z.ZodString>;
3282
3312
  eventType: z.ZodLiteral<"worker-closeout-lessons">;
@@ -3449,8 +3479,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3449
3479
  sessionId: z.ZodOptional<z.ZodString>;
3450
3480
  }, z.core.$strict>>;
3451
3481
  stage: z.ZodEnum<{
3452
- interior: "interior";
3453
3482
  gate: "gate";
3483
+ interior: "interior";
3454
3484
  }>;
3455
3485
  usage: z.ZodOptional<z.ZodObject<{
3456
3486
  estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
@@ -3502,8 +3532,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3502
3532
  sessionId: z.ZodOptional<z.ZodString>;
3503
3533
  }, z.core.$strict>>;
3504
3534
  stage: z.ZodEnum<{
3505
- interior: "interior";
3506
3535
  gate: "gate";
3536
+ interior: "interior";
3507
3537
  }>;
3508
3538
  usage: z.ZodOptional<z.ZodObject<{
3509
3539
  estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
@@ -3546,8 +3576,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3546
3576
  sessionId: z.ZodOptional<z.ZodString>;
3547
3577
  }, z.core.$strict>>;
3548
3578
  stage: z.ZodEnum<{
3549
- interior: "interior";
3550
3579
  gate: "gate";
3580
+ interior: "interior";
3551
3581
  }>;
3552
3582
  usage: z.ZodOptional<z.ZodObject<{
3553
3583
  estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
@@ -3577,7 +3607,7 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3577
3607
  staleRepeats: number;
3578
3608
  };
3579
3609
  observedAt: string;
3580
- stage: "interior" | "gate";
3610
+ stage: "gate" | "interior";
3581
3611
  issue?: number | undefined;
3582
3612
  pr?: number | undefined;
3583
3613
  threadId?: string | undefined;
@@ -3670,11 +3700,11 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3670
3700
  threadId: z.ZodOptional<z.ZodString>;
3671
3701
  workerId: z.ZodOptional<z.ZodString>;
3672
3702
  archiveStatus: z.ZodOptional<z.ZodEnum<{
3703
+ pending: "pending";
3673
3704
  unavailable: "unavailable";
3674
3705
  archived: "archived";
3675
3706
  skipped: "skipped";
3676
3707
  "not-applicable": "not-applicable";
3677
- pending: "pending";
3678
3708
  }>>;
3679
3709
  closeoutReason: z.ZodOptional<z.ZodString>;
3680
3710
  eventType: z.ZodLiteral<"worker-closeout-lessons">;
@@ -3711,11 +3741,11 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3711
3741
  }, z.core.$strict>], "lessonStatus">;
3712
3742
  readonly 2: z.ZodObject<{
3713
3743
  archiveStatus: z.ZodOptional<z.ZodEnum<{
3744
+ pending: "pending";
3714
3745
  unavailable: "unavailable";
3715
3746
  archived: "archived";
3716
3747
  skipped: "skipped";
3717
3748
  "not-applicable": "not-applicable";
3718
- pending: "pending";
3719
3749
  }>>;
3720
3750
  closeoutReason: z.ZodOptional<z.ZodString>;
3721
3751
  lessonStatus: z.ZodOptional<z.ZodEnum<{
@@ -3833,8 +3863,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3833
3863
  interiorCycle: z.ZodOptional<z.ZodNumber>;
3834
3864
  observedAt: z.ZodString;
3835
3865
  purpose: z.ZodEnum<{
3836
- review: "review";
3837
3866
  code: "code";
3867
+ review: "review";
3838
3868
  }>;
3839
3869
  slotResolution: z.ZodObject<{
3840
3870
  effort: z.ZodEnum<{
@@ -3853,8 +3883,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3853
3883
  model: z.ZodString;
3854
3884
  tier: z.ZodEnum<{
3855
3885
  review: "review";
3856
- delegate: "delegate";
3857
3886
  oracle: "oracle";
3887
+ delegate: "delegate";
3858
3888
  workhorse: "workhorse";
3859
3889
  scout: "scout";
3860
3890
  }>;
@@ -3862,8 +3892,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3862
3892
  startedAt: z.ZodString;
3863
3893
  tier: z.ZodEnum<{
3864
3894
  review: "review";
3865
- delegate: "delegate";
3866
3895
  oracle: "oracle";
3896
+ delegate: "delegate";
3867
3897
  workhorse: "workhorse";
3868
3898
  scout: "scout";
3869
3899
  }>;
@@ -3912,8 +3942,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3912
3942
  interiorCycle: z.ZodOptional<z.ZodNumber>;
3913
3943
  observedAt: z.ZodString;
3914
3944
  purpose: z.ZodEnum<{
3915
- review: "review";
3916
3945
  code: "code";
3946
+ review: "review";
3917
3947
  }>;
3918
3948
  slotResolution: z.ZodObject<{
3919
3949
  effort: z.ZodEnum<{
@@ -3932,8 +3962,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3932
3962
  model: z.ZodString;
3933
3963
  tier: z.ZodEnum<{
3934
3964
  review: "review";
3935
- delegate: "delegate";
3936
3965
  oracle: "oracle";
3966
+ delegate: "delegate";
3937
3967
  workhorse: "workhorse";
3938
3968
  scout: "scout";
3939
3969
  }>;
@@ -3941,8 +3971,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3941
3971
  startedAt: z.ZodString;
3942
3972
  tier: z.ZodEnum<{
3943
3973
  review: "review";
3944
- delegate: "delegate";
3945
3974
  oracle: "oracle";
3975
+ delegate: "delegate";
3946
3976
  workhorse: "workhorse";
3947
3977
  scout: "scout";
3948
3978
  }>;
@@ -3982,8 +4012,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3982
4012
  interiorCycle: z.ZodOptional<z.ZodNumber>;
3983
4013
  observedAt: z.ZodString;
3984
4014
  purpose: z.ZodEnum<{
3985
- review: "review";
3986
4015
  code: "code";
4016
+ review: "review";
3987
4017
  }>;
3988
4018
  slotResolution: z.ZodObject<{
3989
4019
  effort: z.ZodEnum<{
@@ -4002,8 +4032,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
4002
4032
  model: z.ZodString;
4003
4033
  tier: z.ZodEnum<{
4004
4034
  review: "review";
4005
- delegate: "delegate";
4006
4035
  oracle: "oracle";
4036
+ delegate: "delegate";
4007
4037
  workhorse: "workhorse";
4008
4038
  scout: "scout";
4009
4039
  }>;
@@ -4011,8 +4041,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
4011
4041
  startedAt: z.ZodString;
4012
4042
  tier: z.ZodEnum<{
4013
4043
  review: "review";
4014
- delegate: "delegate";
4015
4044
  oracle: "oracle";
4045
+ delegate: "delegate";
4016
4046
  workhorse: "workhorse";
4017
4047
  scout: "scout";
4018
4048
  }>;
@@ -4055,17 +4085,17 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
4055
4085
  exitCode: number | null;
4056
4086
  harness: string;
4057
4087
  observedAt: string;
4058
- purpose: "review" | "code";
4088
+ purpose: "code" | "review";
4059
4089
  slotResolution: {
4060
4090
  effort: "high" | "low" | "medium" | "xhigh";
4061
4091
  engine: string;
4062
4092
  layerSource: "committedDefault" | "operatorSession" | "userConfig";
4063
4093
  model: string;
4064
- tier: "review" | "delegate" | "oracle" | "workhorse" | "scout";
4094
+ tier: "review" | "oracle" | "delegate" | "workhorse" | "scout";
4065
4095
  fallbackTier?: "delegate" | undefined;
4066
4096
  };
4067
4097
  startedAt: string;
4068
- tier: "review" | "delegate" | "oracle" | "workhorse" | "scout";
4098
+ tier: "review" | "oracle" | "delegate" | "workhorse" | "scout";
4069
4099
  tokenUsage: {
4070
4100
  source: "cursor-csv" | "codex-json" | "cursor-json" | "claude-json";
4071
4101
  status: "available";
@@ -4394,7 +4424,7 @@ declare const evaluateReadiness: (input: EvaluationInput) => {
4394
4424
  draft: boolean;
4395
4425
  mergeStateStatus: string;
4396
4426
  mergeable: string;
4397
- requiredChecks: "unknown" | "pending" | "passed" | "failed" | "none";
4427
+ requiredChecks: "unknown" | "passed" | "failed" | "pending" | "none";
4398
4428
  unresolvedReviewThreads: number;
4399
4429
  reviewDecision?: string | null | undefined;
4400
4430
  };
@@ -4409,13 +4439,13 @@ declare const evaluateReadiness: (input: EvaluationInput) => {
4409
4439
  reviews: {
4410
4440
  correctness: {
4411
4441
  required: boolean;
4412
- status: "stale" | "not-required" | "blocked" | "current" | "missing";
4442
+ status: "blocked" | "not-required" | "current" | "stale" | "missing";
4413
4443
  reviewedHeadSha?: string | undefined;
4414
4444
  reviewedPatchId?: string | undefined;
4415
4445
  };
4416
4446
  security?: {
4417
4447
  required: boolean;
4418
- status: "stale" | "not-required" | "blocked" | "current" | "missing";
4448
+ status: "blocked" | "not-required" | "current" | "stale" | "missing";
4419
4449
  reviewedHeadSha?: string | undefined;
4420
4450
  reviewedPatchId?: string | undefined;
4421
4451
  } | undefined;
@@ -4478,7 +4508,7 @@ declare const evaluateReadiness: (input: EvaluationInput) => {
4478
4508
  interior: number;
4479
4509
  };
4480
4510
  nextAction: "run-gate-cycle" | "accept-nonblocking-findings" | "escalate-to-triage" | "ready-for-human" | "advance-to-gate" | "run-interior-cycle";
4481
- stage: "interior" | "gate" | "interior-complete";
4511
+ stage: "gate" | "interior" | "interior-complete";
4482
4512
  forcedTransition?: "gate-cap-exhausted" | "interior-cap-reached" | undefined;
4483
4513
  } | undefined;
4484
4514
  reviewRuns?: PrReviewResult[] | undefined;
@@ -4949,6 +4979,12 @@ interface CreateProgramOptions {
4949
4979
  output?: CliOutput;
4950
4980
  }
4951
4981
  declare function createProgram(options?: CreateProgramOptions): Command;
4952
- declare function run(argv?: string[]): Promise<void>;
4982
+ /**
4983
+ * Parse `argv` and run the matching command. `cliEntry` is the path of the
4984
+ * runnable bin module, which follow-up commands spawn; the bin entry passes its
4985
+ * own path. This function never runs itself — `./cli.js` is the only caller
4986
+ * that does (#386).
4987
+ */
4988
+ declare function run(argv?: string[], cliEntry?: string): Promise<void>;
4953
4989
  //#endregion
4954
4990
  export { type AppendFactoryTraceEventResult, type AssembledReviewPrompt, type BatteryCommandDisposition, type BatteryDisposition, type BoundaryCheckArgs, type BoundaryCheckDependencies, type BoundaryCheckProofRecord, type BuildEpicStructureEventInput, type CloudflareAccessServiceToken, type CompletedFactoryCheckSnapshot, CreateProgramOptions, DEFAULT_DEMAND_WAIVER_PATH, DEFAULT_FACTORY_REPOSITORY, DEFAULT_ROOT_SHARED_GLOBS, type DagDocument, type DemandWaiveArgs, type DemandWaiveDependencies, DemandWaiveRefusalError, type DemandWaiver, type DemandWaiverStore, EMPTY_TREE_OBJECT_HASH, EPIC_STRUCTURE_NODE_STATUSES, EPIC_STRUCTURE_SCHEMA_VERSION, type EpicStructureEvent, type EpicStructureGraphPayload, type EpicStructureNodeStatus, EpicStructureValidationError, type EvidenceEmitArgs, type EvidenceEmitDependencies, type EvidenceEmitResult, FACTORY_BASE_REF_ENV, FACTORY_CHANGED_FILES_ENV, FACTORY_CHANGED_FILES_FILE_ENV, type FactoryCliInvocation, FactoryCliInvocationSchema, type FactoryPrStatusCheckName, type FactoryPrStatusSources, type FactoryProjectProfile, type FactoryTraceDiagnostic, type FactoryTraceEnvelope, type FactoryTraceEvent, type FindingDisposition, type FindingLedgerEntry, type FollowUpAction, FollowUpActionSchema, type GitHubCheckRunMergeFreezeApi, type ImpactScopeDecision, type ImpactScopeSurface, type IssueReviewFocus, type LadderDispositionDeclaration, MERGE_FREEZE_APP_SLUG, MERGE_FREEZE_CHECK_NAME, type MergeFreezeAuthority, type MergeFreezeGeneration, type MergeFreezeState, type MergeFreezeStoreInput, type PlanFactoryPrStatusHudInput, type PrPublishArgs, type PrPublishDependencies, PrPublishFollowUpError, type PrPublishFollowUpOutcome, type PrPublishHandoff, type PrPublishResult, type PrReadyArgs, type PrReadyProof, type PresentFactoryPrStatusHudDependencies, type PresentFactoryPrStatusHudInput, type PreviewDisposition, type PreviewLifecyclePlan, type PreviewTargetPlan, type PublishEpicStructureArgs, type PublishEpicStructureResult, type PublishFollowUpPlan, REVIEW_FOCUS_SECTION, type ReadFactoryPrStatusSourcesDependencies, type ReadFactoryPrStatusSourcesInput, type RefreshFactoryPrStatusHudInput, type RenderFactoryPrStatusHudInput, type ReviewGateNotRequiredProof, type ReviewGateTraceIdentity, type ReviewLadderCycle, type ReviewLadderEvaluation, type ReviewLadderPolicy, type ReviewLadderStageEvent, type ReviewLadderTraceIdentity, type ReviewPromptSection, type ReviewPromptSectionProvenance, type ScanFactoryTraceDiagnosticsOptions, type ScanFactoryTraceOptions, type ScanFactoryTraceResult, type ScopedOutCommand, type TraceMirrorDiagnostic, type TraceSink, type TraceWriteResult, type TraceWriteSinks, type VerificationBatteryPlan, type VerificationReuse, type VerificationRunContext, type VerificationRunContextInput, type WaivedDemand, WorkerCheckoutGuardError, type WorkerCloseoutLessonsTraceEvent, appendReviewLadderStageTraceEvent, appendWithTraceSinks, applyDemandWaiver, assembleReviewPrompt, assertFactoryPrStatusIdentity, assertWorkerCheckoutAllowed, authorizeDemandWaiver, batteryScopeSummaryLines, blockingLadderFindings, boundary_manifest_d_exports as boundaryManifest, boundary_review_proof_d_exports as boundaryReviewProof, buildEpicStructureEvent, buildEpicStructurePayload, buildEvidenceEnvelope, buildReviewGateNotRequiredTraceEvent, buildReviewLadderStageTraceEvent, comment_provenance_d_exports as commentProvenance, createGitHubCheckRunMergeFreezeStore, createLocalJsonlTraceSink, createProgram, createVerificationRunContext, doctorProjectProfile, epicStructureEventId, evaluateReviewLadder, evidenceEnvelopeFilename, findingKey, followUpFromArgv, impactStampScopeDecision, inferFixedInThreadDispositions, isProductionHqUrl, loadProjectProfile, normalizeIssueComments, openLadderFindings, planFactoryPrStatusHud, planPreviewLifecycle, planPublishFollowUp, planVerificationBattery, readiness_evaluation_d_exports as prReadinessEvaluation, external_evidence_d_exports as prReadinessExternalEvidence, pr_body_renderer_d_exports as prReadinessPrBodyRenderer, proof_identity_d_exports as prReadinessProofIdentity, review_proof_d_exports as prReadinessReviewProof, status_check_rollup_d_exports as prReadinessStatusChecks, verification_proof_d_exports as prReadinessVerificationProof, presentFactoryPrStatusHud, previewLifecycleTargets, publishEpicStructure, readDemandWaivers, readFactoryPrStatusSources, readPrReadyProof, readPrReviewProof, refreshFactoryPrStatusHud, refreshFactoryPrStatusHudSafely, renderFactoryPrStatusHud, resolveFactoryRepository, resolveFindingBlocking, resolveReviewFindingCategory, resolveReviewFindingSeverity, resolveReviewLadderPolicy, resolveTraceWriteSinks, reviewCycleStateFor, reviewFocusFromIssueBody, reviewPromptSectionSchema, reviewPromptSectionsSchema, run, runBoundaryCheck, runDemandWaive, runEvidenceEmit, runPrPublish, runPrReady, runPrReview, runPrVerify, scanFactoryTraceDiagnostics, scanFactoryTraceEvents, selectWaiversForCandidate, staleRepeatLadderFindings, toFactoryTraceEnvelope, tryAppendReviewGateNotRequiredTraceEvent, tryAppendReviewLadderStageTraceEvent, validateBoundaryCheckProof, validateDagDocument, validateDemandWaiverStore, validateFactoryTraceEvent, validateMergeFreezeState, validatePrReadyProof, validatePrReviewProof, validatePrVerifyProof, validatePreviewLifecyclePlan, waivedDemandNotice, waivedDemandSchema, worktree_scratch_files_d_exports as worktreeScratchFiles };