@patronage/software-factory 1.0.0-alpha.13 → 1.0.0-alpha.15

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/index.d.ts CHANGED
@@ -1,8 +1,97 @@
1
1
  import { existsSync, readFileSync, rmSync } from "node:fs";
2
2
  import { Command } from "commander";
3
3
  import { z } from "zod";
4
- import { readFile } from "node:fs/promises";
5
4
 
5
+ //#region src/review-rungs.d.ts
6
+ declare const EVIDENCE_REVIEW_RUNGS: readonly ["independent-model", "oracle", "human"];
7
+ type EvidenceReviewRung = (typeof EVIDENCE_REVIEW_RUNGS)[number];
8
+ declare namespace boundary_manifest_d_exports {
9
+ export { BOUNDARY_CLOSEOUT_DEFAULT_RUNG, BOUNDARY_MANIFEST_SCHEMA_VERSION, BoundaryManifest, BoundaryManifestExtraction, BoundaryManifestParse, FACTORY_BOUNDARY_FENCE_LANG, boundaryManifestSchema, closeoutRungFor, extractBoundaryManifestBlock, manifestContentHash, parseBoundaryManifest, rungMeetsMinimum, specContentHash };
10
+ }
11
+ declare const FACTORY_BOUNDARY_FENCE_LANG = "factory-boundary";
12
+ declare const BOUNDARY_MANIFEST_SCHEMA_VERSION = 1;
13
+ declare const BOUNDARY_CLOSEOUT_DEFAULT_RUNG: EvidenceReviewRung;
14
+ declare const rungMeetsMinimum: (rung: EvidenceReviewRung, minimum: EvidenceReviewRung) => boolean;
15
+ declare const boundaryManifestBaseSchema: z.ZodObject<{
16
+ boundary: z.ZodString;
17
+ closeout: z.ZodOptional<z.ZodObject<{
18
+ review: z.ZodEnum<{
19
+ oracle: "oracle";
20
+ "independent-model": "independent-model";
21
+ human: "human";
22
+ }>;
23
+ }, z.core.$loose>>;
24
+ declaredBy: z.ZodString;
25
+ integrationBranch: z.ZodOptional<z.ZodString>;
26
+ schemaVersion: z.ZodLiteral<1>;
27
+ topology: z.ZodEnum<{
28
+ flagged: "flagged";
29
+ "each-to-main": "each-to-main";
30
+ stacked: "stacked";
31
+ "each-to-epic": "each-to-epic";
32
+ }>;
33
+ waves: z.ZodArray<z.ZodObject<{
34
+ autoMerge: z.ZodOptional<z.ZodBoolean>;
35
+ issues: z.ZodArray<z.ZodNumber>;
36
+ name: z.ZodString;
37
+ review: z.ZodEnum<{
38
+ oracle: "oracle";
39
+ "independent-model": "independent-model";
40
+ human: "human";
41
+ }>;
42
+ }, z.core.$loose>>;
43
+ }, z.core.$loose>;
44
+ declare const boundaryManifestSchema: z.ZodObject<{
45
+ boundary: z.ZodString;
46
+ closeout: z.ZodOptional<z.ZodObject<{
47
+ review: z.ZodEnum<{
48
+ oracle: "oracle";
49
+ "independent-model": "independent-model";
50
+ human: "human";
51
+ }>;
52
+ }, z.core.$loose>>;
53
+ declaredBy: z.ZodString;
54
+ integrationBranch: z.ZodOptional<z.ZodString>;
55
+ schemaVersion: z.ZodLiteral<1>;
56
+ topology: z.ZodEnum<{
57
+ flagged: "flagged";
58
+ "each-to-main": "each-to-main";
59
+ stacked: "stacked";
60
+ "each-to-epic": "each-to-epic";
61
+ }>;
62
+ waves: z.ZodArray<z.ZodObject<{
63
+ autoMerge: z.ZodOptional<z.ZodBoolean>;
64
+ issues: z.ZodArray<z.ZodNumber>;
65
+ name: z.ZodString;
66
+ review: z.ZodEnum<{
67
+ oracle: "oracle";
68
+ "independent-model": "independent-model";
69
+ human: "human";
70
+ }>;
71
+ }, z.core.$loose>>;
72
+ }, z.core.$loose>;
73
+ type BoundaryManifest = z.infer<typeof boundaryManifestBaseSchema>;
74
+ type BoundaryManifestExtraction = {
75
+ ok: true;
76
+ blockText: string;
77
+ } | {
78
+ ok: false;
79
+ error: string;
80
+ };
81
+ declare const extractBoundaryManifestBlock: (issueBody: string) => BoundaryManifestExtraction;
82
+ declare const manifestContentHash: (blockText: string) => string;
83
+ declare const specContentHash: (issueBody: string) => string;
84
+ type BoundaryManifestParse = {
85
+ ok: true;
86
+ manifest: BoundaryManifest;
87
+ manifestHash: string;
88
+ } | {
89
+ ok: false;
90
+ error: string;
91
+ };
92
+ declare const parseBoundaryManifest: (issueBody: string) => BoundaryManifestParse;
93
+ declare const closeoutRungFor: (manifest: BoundaryManifest) => EvidenceReviewRung;
94
+ //#endregion
6
95
  //#region src/github-issue-comments.d.ts
7
96
  interface GithubIssueCommentApi {
8
97
  body: string;
@@ -127,6 +216,22 @@ declare const selectBoundaryReviewProof: (comments: GithubIssueComment[], bounda
127
216
  declare const boundaryReviewProofAuthorsSeen: (comments: GithubIssueComment[], boundary: string) => string[];
128
217
  declare const undispositionedBlockingFindings: (proof: BoundaryReviewProof) => string[];
129
218
  //#endregion
219
+ //#region src/boundary-membership-graph.d.ts
220
+ /** The boundary-manifest wave demand that applies to one pull request. */
221
+ interface WaveReviewDemand {
222
+ autoMerge: boolean;
223
+ review: EvidenceReviewRung;
224
+ wave: string;
225
+ }
226
+ interface BoundaryPullRequestRef {
227
+ baseRefName?: string;
228
+ headRefOid?: string;
229
+ headRefName?: string;
230
+ mergeCommitOid?: string;
231
+ number: number;
232
+ state: "OPEN" | "CLOSED" | "MERGED";
233
+ }
234
+ //#endregion
130
235
  //#region src/hq-ingest-sink.d.ts
131
236
  interface HqIngestDependencies {
132
237
  /**
@@ -648,9 +753,7 @@ interface LoadUserConfigResult {
648
753
  //#endregion
649
754
  //#region src/github-check-runs.d.ts
650
755
  declare const FACTORY_CHECK_NAMES: {
651
- readonly boundary: "patronage-factory/boundary";
652
756
  readonly "pr-ready": "patronage-factory/pr-ready";
653
- readonly "pr-review": "patronage-factory/pr-review";
654
757
  readonly "pr-verify": "patronage-factory/pr-verify";
655
758
  };
656
759
  type FactoryCheckGate = keyof typeof FACTORY_CHECK_NAMES;
@@ -665,12 +768,6 @@ interface PublishFactoryCheckInput {
665
768
  * `hqLaneRefBaseUrlFromProfile` — the same source as the HQ gate sink.
666
769
  */
667
770
  hqLaneBaseUrl?: string;
668
- /**
669
- * Explicit issue/PR number for the HQ lane ref, used when the check run is not
670
- * PR-scoped (e.g. an epic boundary check keyed by its epic issue). Falls back
671
- * to `pr`, then to the checkout's PR, when omitted.
672
- */
673
- laneRefNumber?: number;
674
771
  owner: string;
675
772
  pr?: number;
676
773
  proof: unknown;
@@ -869,10 +966,6 @@ interface ReviewLadderPolicy {
869
966
  }
870
967
  declare const resolveReviewLadderPolicy: () => ReviewLadderPolicy;
871
968
  //#endregion
872
- //#region src/review-rungs.d.ts
873
- declare const EVIDENCE_REVIEW_RUNGS: readonly ["independent-model", "oracle", "human"];
874
- type EvidenceReviewRung = (typeof EVIDENCE_REVIEW_RUNGS)[number];
875
- //#endregion
876
969
  //#region src/review-ladder-ledger.d.ts
877
970
  type LadderCycleStage = "interior" | "gate";
878
971
  interface LadderCycleRef {
@@ -1156,9 +1249,9 @@ declare const managedReadinessLedgerSchema: z.ZodObject<{
1156
1249
  mergeable: z.ZodString;
1157
1250
  requiredChecks: z.ZodEnum<{
1158
1251
  unknown: "unknown";
1159
- pending: "pending";
1160
1252
  passed: "passed";
1161
1253
  failed: "failed";
1254
+ pending: "pending";
1162
1255
  none: "none";
1163
1256
  }>;
1164
1257
  reviewDecision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -1189,15 +1282,15 @@ declare const managedReadinessLedgerSchema: z.ZodObject<{
1189
1282
  unknown: "unknown";
1190
1283
  critical: "critical";
1191
1284
  high: "high";
1192
- low: "low";
1193
1285
  medium: "medium";
1286
+ low: "low";
1194
1287
  }>>;
1195
1288
  highestOpenSeverity: z.ZodOptional<z.ZodEnum<{
1196
1289
  unknown: "unknown";
1197
1290
  critical: "critical";
1198
1291
  high: "high";
1199
- low: "low";
1200
1292
  medium: "medium";
1293
+ low: "low";
1201
1294
  }>>;
1202
1295
  maxReviewCycles: z.ZodOptional<z.ZodNumber>;
1203
1296
  nonBlockingFindings: z.ZodNumber;
@@ -1225,8 +1318,8 @@ declare const managedReadinessLedgerSchema: z.ZodObject<{
1225
1318
  }>;
1226
1319
  stage: z.ZodEnum<{
1227
1320
  gate: "gate";
1228
- interior: "interior";
1229
1321
  "interior-complete": "interior-complete";
1322
+ interior: "interior";
1230
1323
  }>;
1231
1324
  }, z.core.$strip>>;
1232
1325
  reviewRuns: z.ZodOptional<z.ZodArray<z.ZodType<PrReviewResult, unknown, z.core.$ZodTypeInternals<PrReviewResult, unknown>>>>;
@@ -1241,9 +1334,9 @@ declare const managedReadinessLedgerSchema: z.ZodObject<{
1241
1334
  reviewedHeadSha: z.ZodOptional<z.ZodString>;
1242
1335
  reviewedPatchId: z.ZodOptional<z.ZodString>;
1243
1336
  status: z.ZodEnum<{
1337
+ stale: "stale";
1244
1338
  blocked: "blocked";
1245
1339
  "not-required": "not-required";
1246
- stale: "stale";
1247
1340
  current: "current";
1248
1341
  missing: "missing";
1249
1342
  }>;
@@ -1253,9 +1346,9 @@ declare const managedReadinessLedgerSchema: z.ZodObject<{
1253
1346
  reviewedHeadSha: z.ZodOptional<z.ZodString>;
1254
1347
  reviewedPatchId: z.ZodOptional<z.ZodString>;
1255
1348
  status: z.ZodEnum<{
1349
+ stale: "stale";
1256
1350
  blocked: "blocked";
1257
1351
  "not-required": "not-required";
1258
- stale: "stale";
1259
1352
  current: "current";
1260
1353
  missing: "missing";
1261
1354
  }>;
@@ -1770,9 +1863,9 @@ declare const loadEvidenceEnvelopes: (cwd: string) => LoadedEvidenceEnvelope[];
1770
1863
  //#region src/review-proof-applicability.d.ts
1771
1864
  declare const REVIEW_STATUS_VALUES: readonly ["not-required", "current", "stale", "missing", "blocked"];
1772
1865
  declare const reviewStatusSchema: z.ZodEnum<{
1866
+ stale: "stale";
1773
1867
  blocked: "blocked";
1774
1868
  "not-required": "not-required";
1775
- stale: "stale";
1776
1869
  current: "current";
1777
1870
  missing: "missing";
1778
1871
  }>;
@@ -1871,17 +1964,8 @@ declare const validatePrReviewResult: (value: unknown) => PrReviewResult;
1871
1964
  declare const validatePrReviewProof: (value: unknown) => PrReviewProof;
1872
1965
  declare const readPrReviewProof: (filePath: string) => PrReviewProof;
1873
1966
  declare const PR_REVIEW_PROOF_DESCRIPTOR: ProofDescriptor<PrReviewProof>;
1874
- declare namespace verification_proof_d_exports {
1875
- export { PrVerifyBaselineFullProof, PrVerifyCommandResult, PrVerifyExecutedCommand, PrVerifyNotRequiredCommand, PrVerifyProof, PrVerifySchemaVersion, ResolvedPrVerifyMode, SUPPORTED_PR_VERIFY_SCHEMA_VERSIONS, VerificationHeadShas, VerificationProofState, VerifiedHeadShas, prVerifyFullHeadShasForDiff, prVerifyProofHeadShas, readPrVerifyProof, resolveVerifyProofApplicability, trustedImpactStamp, validatePrVerifyProof, verificationProofApplicabilityFor, verificationProofBlockingReason, verificationProofForReadiness, verificationProofStateFor, verifyProofIdentityMatches, verifyProofPassed };
1876
- }
1877
- interface VerifiedHeadShas {
1878
- docsOnlyVerifiedHeadShas: string[];
1879
- trivialVerifiedHeadShas: string[];
1880
- verifiedHeadShas: string[];
1881
- }
1882
- type VerificationHeadShas = {
1883
- explicitFailure: true;
1884
- } | VerifiedHeadShas;
1967
+ //#endregion
1968
+ //#region src/pr-verify-proof-contract.d.ts
1885
1969
  declare const SUPPORTED_PR_VERIFY_SCHEMA_VERSIONS: readonly [1, 2, 3, 4];
1886
1970
  type PrVerifySchemaVersion = (typeof SUPPORTED_PR_VERIFY_SCHEMA_VERSIONS)[number];
1887
1971
  interface PrVerifyCommandResult {
@@ -1959,317 +2043,6 @@ interface PrVerifyProof {
1959
2043
  }
1960
2044
  type PrVerifyBaselineFullProof = NonNullable<PrVerifyProof["baselineFullProofs"]>[number];
1961
2045
  declare function validatePrVerifyProof(value: unknown): PrVerifyProof;
1962
- declare function readPrVerifyProof(filePath: string): PrVerifyProof;
1963
- declare const verifyProofPassed: (proof: PrVerifyProof) => boolean;
1964
- declare const prVerifyProofHeadShas: (proof: PrVerifyProof | undefined, creditedHeadSha?: string) => VerifiedHeadShas;
1965
- declare const verifyProofIdentityMatches: ({
1966
- currentIdentity,
1967
- proof
1968
- }: {
1969
- currentIdentity?: {
1970
- patchId: string;
1971
- mergeBaseSha?: string;
1972
- };
1973
- proof?: PrVerifyProof;
1974
- }) => boolean;
1975
- /**
1976
- * Wave-2 consumption (#542): the recorded impact stamp, released for demand
1977
- * resolution ONLY when it is identity-bound to the current candidate — the
1978
- * proof passed, and its recorded headSha AND patchId both name exactly this
1979
- * candidate (the same identities the proof already binds). Everything else —
1980
- * no proof, an aborted run, a stale head, a moved patch id, a pre-stamp proof
1981
- * — returns `undefined`, and the consumer keeps today's full-demand floor.
1982
- *
1983
- * Deliberately stricter than verify-once applicability (which tolerates a
1984
- * head-only or patch-id-only match): a stamp narrows external demands, so it
1985
- * is trusted only on an exact double binding, fail closed.
1986
- */
1987
- declare const trustedImpactStamp: ({
1988
- candidate,
1989
- proof
1990
- }: {
1991
- candidate: {
1992
- headSha: string;
1993
- patchId: string;
1994
- };
1995
- proof: PrVerifyProof | undefined;
1996
- }) => ImpactStamp | undefined;
1997
- declare const prVerifyFullHeadShasForDiff: ({
1998
- docsOnlyDeltaAcceptedSince,
1999
- files,
2000
- proof
2001
- }: {
2002
- docsOnlyDeltaAcceptedSince?: (baselineHeadSha: string) => boolean;
2003
- files: string[];
2004
- proof: PrVerifyProof;
2005
- }) => string[];
2006
- type VerificationProofState = {
2007
- kind: "typed-aborted";
2008
- proof: PrVerifyProof;
2009
- } | {
2010
- kind: "typed-missing";
2011
- path: string;
2012
- reason: "enoent" | "invalid";
2013
- message?: string;
2014
- } | {
2015
- kind: "typed";
2016
- headShas: VerifiedHeadShas;
2017
- proof: PrVerifyProof;
2018
- } | {
2019
- kind: "typed-diff-mismatch";
2020
- mode: ResolvedPrVerifyMode;
2021
- };
2022
- declare const verificationProofStateFor: ({
2023
- proof,
2024
- proofMatchesCurrentDiff,
2025
- proofPath
2026
- }: {
2027
- proof?: PrVerifyProof;
2028
- proofMatchesCurrentDiff?: boolean;
2029
- proofPath?: string;
2030
- }) => VerificationProofState;
2031
- declare const verificationProofApplicabilityFor: ({
2032
- docsOnlyDeltaAcceptedSince,
2033
- explicitProof,
2034
- files,
2035
- headSha,
2036
- currentIdentity,
2037
- proof,
2038
- proofPath,
2039
- proofReadError
2040
- }: {
2041
- docsOnlyDeltaAcceptedSince?: (baselineHeadSha: string) => boolean;
2042
- explicitProof: boolean;
2043
- files: string[];
2044
- headSha: string;
2045
- currentIdentity?: {
2046
- patchId: string;
2047
- mergeBaseSha?: string;
2048
- };
2049
- proof?: PrVerifyProof;
2050
- proofPath?: string;
2051
- proofReadError?: unknown;
2052
- }) => {
2053
- fullVerifiedHeadShas: never[];
2054
- verificationProof: VerificationProofState;
2055
- } | {
2056
- fullVerifiedHeadShas: string[];
2057
- verificationProof: {
2058
- headShas: VerifiedHeadShas;
2059
- kind: "typed";
2060
- proof: PrVerifyProof;
2061
- };
2062
- };
2063
- declare const resolveVerifyProofApplicability: ({
2064
- proofPath,
2065
- explicitProof,
2066
- docsOnlyDeltaAcceptedSince,
2067
- files,
2068
- headSha,
2069
- currentVerifyIdentityForBase,
2070
- preread
2071
- }: {
2072
- proofPath: string;
2073
- explicitProof: boolean;
2074
- docsOnlyDeltaAcceptedSince?: (baselineHeadSha: string) => boolean;
2075
- files: string[];
2076
- headSha: string;
2077
- currentVerifyIdentityForBase?: (base: string) => {
2078
- patchId: string;
2079
- mergeBaseSha?: string;
2080
- };
2081
- preread?: {
2082
- proof?: PrVerifyProof;
2083
- error?: unknown;
2084
- };
2085
- }) => {
2086
- fullVerifiedHeadShas: never[];
2087
- verificationProof: VerificationProofState;
2088
- } | {
2089
- fullVerifiedHeadShas: string[];
2090
- verificationProof: {
2091
- headShas: VerifiedHeadShas;
2092
- kind: "typed";
2093
- proof: PrVerifyProof;
2094
- };
2095
- };
2096
- declare const verificationProofForReadiness: (state: VerificationProofState) => VerificationHeadShas;
2097
- declare const verificationProofBlockingReason: (state: VerificationProofState) => string | undefined;
2098
- //#endregion
2099
- //#region src/retro-envelope.d.ts
2100
- /**
2101
- * Versioned retro envelope schema (epic #27 wave 2, issue #34).
2102
- *
2103
- * One envelope per lane, built at `factory:closeout` and delivered through the
2104
- * typed gate-sink as the `retro-envelope` ingest kind. Re-derived in TypeScript
2105
- * from the `spike/telemetry-layer2` S5 scratch schema (reference-only, never
2106
- * merged). This module is the single source of truth for the v1 wire shape
2107
- * and its bounds ({@link RETRO_ENVELOPE_WIRE_BOUNDS}) — producer and consumer
2108
- * alike. HQ imports these exports directly from the Worker-safe
2109
- * `@patronage/software-factory/schemas` subpath
2110
- * (`software-factory-hq/src/contracts/retro-schemas.ts`) instead of
2111
- * maintaining a parallel hand-written copy, so there is exactly one wire
2112
- * contract and no drift-detection machinery is needed (issue #350; formerly
2113
- * a hand-written twin plus a 767-line parity test, #46).
2114
- *
2115
- * DESIGN INVARIANT: cross-family token sums must be UNREPRESENTABLE.
2116
- *
2117
- * The two model families use different tokenizers, prices, and accounting
2118
- * conventions, so any token total that spans Claude and GPT is a lie:
2119
- *
2120
- * 1. There is no combined/total token field anywhere in the envelope.
2121
- * 2. `tokenFamilies` is strict — its only keys are `claude` and `gpt`; data
2122
- * cannot smuggle in a third "all"/"combined" slot.
2123
- * 3. The family BLOCKS are structurally different shapes with DIFFERENT keys
2124
- * (claude is a single flat block keyed on freshInput/cacheReadInput/
2125
- * cacheCreationInput; gpt is `{ roles: [...] }`). The exclusive input-tier
2126
- * COUNTS share no key name across families. The residual names shared
2127
- * between the claude block and a gpt ROLE entry are pinned to exactly
2128
- * {costUsd, model, output} (PR #32 advisory): `costUsd` is deliberate —
2129
- * USD is the one cross-family summable unit (rule 4); `model` is an
2130
- * unsummable label; `output` is the same name at DIFFERENT depths (lane
2131
- * block vs per-role entry), frozen by a tripwire test in
2132
- * `retro-envelope.test.ts` so the overlap cannot grow. Renaming `output`
2133
- * is a schemaVersion-2 wire change, deliberately not spent in v1.
2134
- * 4. Cost is per-family USD and nullable. Combined totals are allowed in USD
2135
- * only, and only as a projection-time sum of per-family USD.
2136
- *
2137
- * Field names also encode the S2/S3 reader lessons: Claude `freshInput` alone
2138
- * is not prompt size (true input context = freshInput + cacheReadInput +
2139
- * cacheCreationInput, requestId-deduped), and codex `inputInclusiveOfCache`
2140
- * already includes `cachedInput`, so `freshInputDerived` (inclusive − cached)
2141
- * is the only value safe to feed a per-token pricer.
2142
- *
2143
- * COMPLETENESS POSTURE: harvest may have no usable native log for a lane, so
2144
- * `tokenFamilies` may legitimately be absent. The closeout build gate demands
2145
- * a valid envelope, not available telemetry. A families-absent envelope keeps
2146
- * its operator-visible data gaps and is a replayable advisory HQ event, so it
2147
- * never substitutes unavailable usage with zero. The wire shape (field names,
2148
- * types, structure) stays byte-parity with HQ v1.
2149
- */
2150
- declare const RETRO_ENVELOPE_SCHEMA_VERSION = 1;
2151
- declare const retroEnvelopeV1Schema: z.ZodObject<{
2152
- agentRunId: z.ZodString;
2153
- archiveRef: z.ZodOptional<z.ZodString>;
2154
- cycles: z.ZodObject<{
2155
- gateRunsToFirstGreen: z.ZodNumber;
2156
- reviewerFixRounds: z.ZodNumber;
2157
- thermoFixRounds: z.ZodNumber;
2158
- }, z.core.$strict>;
2159
- dataGaps: z.ZodDefault<z.ZodArray<z.ZodString>>;
2160
- gates: z.ZodArray<z.ZodObject<{
2161
- cycle: z.ZodNumber;
2162
- duration: z.ZodNumber;
2163
- gate: z.ZodString;
2164
- outcome: z.ZodEnum<{
2165
- pass: "pass";
2166
- fail: "fail";
2167
- skip: "skip";
2168
- }>;
2169
- startedAt: z.ZodISODateTime;
2170
- }, z.core.$strict>>;
2171
- generatedAt: z.ZodISODateTime;
2172
- interventions: z.ZodObject<{
2173
- count: z.ZodNumber;
2174
- }, z.core.$strict>;
2175
- joinKeys: z.ZodObject<{
2176
- claudeSessionIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
2177
- codexThreadIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
2178
- }, z.core.$strict>;
2179
- kind: z.ZodLiteral<"retro-envelope">;
2180
- outcome: z.ZodOptional<z.ZodObject<{
2181
- status: z.ZodEnum<{
2182
- success: "success";
2183
- fail: "fail";
2184
- blocked: "blocked";
2185
- "ship-with-followups": "ship-with-followups";
2186
- }>;
2187
- verdict: z.ZodOptional<z.ZodString>;
2188
- }, z.core.$strict>>;
2189
- phases: z.ZodArray<z.ZodObject<{
2190
- at: z.ZodISODateTime;
2191
- deltaSec: z.ZodOptional<z.ZodNumber>;
2192
- name: z.ZodString;
2193
- }, z.core.$strict>>;
2194
- refs: z.ZodObject<{
2195
- branch: z.ZodOptional<z.ZodString>;
2196
- epic: z.ZodOptional<z.ZodString>;
2197
- headSha: z.ZodOptional<z.ZodString>;
2198
- issue: z.ZodOptional<z.ZodString>;
2199
- prNumber: z.ZodOptional<z.ZodNumber>;
2200
- }, z.core.$strict>;
2201
- repo: z.ZodObject<{
2202
- name: z.ZodString;
2203
- owner: z.ZodString;
2204
- }, z.core.$strict>;
2205
- schemaVersion: z.ZodLiteral<1>;
2206
- tokenFamilies: z.ZodObject<{
2207
- claude: z.ZodOptional<z.ZodObject<{
2208
- cacheCreationInput: z.ZodNumber;
2209
- cacheReadInput: z.ZodNumber;
2210
- costUsd: z.ZodNullable<z.ZodNumber>;
2211
- family: z.ZodLiteral<"claude">;
2212
- freshInput: z.ZodNumber;
2213
- model: z.ZodString;
2214
- output: z.ZodNumber;
2215
- requests: z.ZodNumber;
2216
- }, z.core.$strict>>;
2217
- gpt: z.ZodOptional<z.ZodObject<{
2218
- family: z.ZodLiteral<"gpt">;
2219
- roles: z.ZodArray<z.ZodObject<{
2220
- cachedInput: z.ZodNumber;
2221
- costUsd: z.ZodNullable<z.ZodNumber>;
2222
- freshInputDerived: z.ZodNumber;
2223
- inputInclusiveOfCache: z.ZodNumber;
2224
- model: z.ZodString;
2225
- output: z.ZodNumber;
2226
- reasoningOutput: z.ZodNumber;
2227
- role: z.ZodString;
2228
- threadId: z.ZodOptional<z.ZodString>;
2229
- }, z.core.$strict>>;
2230
- }, z.core.$strict>>;
2231
- }, z.core.$strict>;
2232
- wallClock: z.ZodObject<{
2233
- endTs: z.ZodISODateTime;
2234
- startTs: z.ZodISODateTime;
2235
- totalSec: z.ZodNumber;
2236
- }, z.core.$strict>;
2237
- }, z.core.$strict>;
2238
- type RetroEnvelope = z.infer<typeof retroEnvelopeV1Schema>;
2239
- /**
2240
- * Versioned payload validators, keyed by schema major. Unknown majors never
2241
- * reach these — {@link parseRetroEnvelope} returns them raw and marked
2242
- * degraded, mirroring HQ's ingest skew posture (stored raw, never dropped).
2243
- */
2244
- declare const RETRO_ENVELOPE_VALIDATORS: Record<number, z.ZodType<RetroEnvelope, unknown>>;
2245
- declare const SUPPORTED_RETRO_ENVELOPE_SCHEMA_VERSIONS: readonly number[];
2246
- /** The `schemaVersion` a candidate declares, or undefined when unreadable. */
2247
- declare const retroEnvelopeSchemaVersionOf: (candidate: unknown) => number | undefined;
2248
- type ParsedRetroEnvelope = {
2249
- disposition: "trusted";
2250
- envelope: RetroEnvelope;
2251
- schemaVersion: number;
2252
- } | {
2253
- disposition: "degraded";
2254
- raw: unknown;
2255
- schemaVersion: number | undefined;
2256
- };
2257
- /**
2258
- * Parses a candidate against the versioned validators. A recognized major is
2259
- * validated typed-only (throws on an invalid known-version payload); an unknown
2260
- * major is round-tripped RAW and marked degraded — the retained payload is the
2261
- * exact input object, never a coerced projection. Mirrors the HQ ingest seam so
2262
- * the two sides agree on the skew posture.
2263
- */
2264
- declare const parseRetroEnvelope: (candidate: unknown) => ParsedRetroEnvelope;
2265
- /**
2266
- * Whether harvest recorded at least one token family. This is an operator
2267
- * summary predicate, not a delivery gate: a families-absent envelope remains
2268
- * valid and replayable when its data gaps explain why telemetry is unavailable.
2269
- */
2270
- declare const isRetroEnvelopeWireComplete: (envelope: Pick<RetroEnvelope, "tokenFamilies">) => boolean;
2271
- /** Epic anchor for an envelope: refs.epic, else refs.issue, else the PR. */
2272
- declare const retroEpicReference: (refs: RetroEnvelope["refs"]) => string | undefined;
2273
2046
  //#endregion
2274
2047
  //#region src/schemas.d.ts
2275
2048
  declare const boundaryCheckProofSchema: z.ZodObject<{
@@ -2277,7 +2050,7 @@ declare const boundaryCheckProofSchema: z.ZodObject<{
2277
2050
  boundary: z.ZodOptional<z.ZodString>;
2278
2051
  command: z.ZodLiteral<"patronage-factory boundary:check">;
2279
2052
  coveredSet: z.ZodArray<z.ZodObject<{
2280
- issue: z.ZodOptional<z.ZodNumber>;
2053
+ issue: z.ZodNumber;
2281
2054
  pr: z.ZodNumber;
2282
2055
  sha: z.ZodString;
2283
2056
  state: z.ZodEnum<{
@@ -2327,19 +2100,11 @@ declare const boundaryCheckProofSchema: z.ZodObject<{
2327
2100
  type BoundaryCheckProofRecord = z.infer<typeof boundaryCheckProofSchema>;
2328
2101
  //#endregion
2329
2102
  //#region src/boundary-check.d.ts
2330
- interface BoundaryPullRequestRef {
2331
- baseRefName?: string;
2332
- headRefOid?: string;
2333
- headRefName?: string;
2334
- mergeCommitOid?: string;
2335
- number: number;
2336
- state: "OPEN" | "CLOSED" | "MERGED";
2337
- }
2338
2103
  interface BoundaryCheckGithub {
2339
2104
  fetchIssueBody: (repo: string, issue: number) => string;
2340
2105
  fetchIssueComments: (repo: string, issue: number) => GithubIssueComment[];
2341
2106
  fetchClosingPullRequests: (repo: string, issue: number) => BoundaryPullRequestRef[];
2342
- fetchPullRequest: (repo: string, pr: number) => BoundaryPullRequestRef;
2107
+ fetchPullRequest?: (repo: string, pr: number) => BoundaryPullRequestRef;
2343
2108
  }
2344
2109
  interface BoundaryCheckArgs {
2345
2110
  cwd?: string;
@@ -2404,32 +2169,6 @@ declare const runDemandWaive: (args: DemandWaiveArgs, dependencies?: DemandWaive
2404
2169
  //#region src/commands/demand-waive.d.ts
2405
2170
  type DemandWaiveAction = (args: DemandWaiveArgs) => DemandWaiver;
2406
2171
  //#endregion
2407
- //#region src/hq-credentials.d.ts
2408
- /**
2409
- * Why a reference did not resolve. Each value names a different remedy, and
2410
- * none of them can be inferred from a value-or-nothing result:
2411
- *
2412
- * - `resolver-missing` — no secret-manager binary on PATH.
2413
- * - `resolver-blocked` — a binary exists but this session may not execute it
2414
- * (a sandbox denying exec). The command belongs outside the sandbox.
2415
- * - `resolver-timeout` — the probe expired: a desktop agent waiting on an
2416
- * approval nobody can give here.
2417
- * - `resolver-refused` — the binary ran and produced no value. Its store is
2418
- * unreachable from this session (a sandbox with no keychain access) or the
2419
- * reference is not readable. These two stay one status on purpose: telling
2420
- * them apart would mean reading resolver output.
2421
- */
2422
- type SecretResolutionFailure = "resolver-blocked" | "resolver-missing" | "resolver-refused" | "resolver-timeout";
2423
- /** A structured resolution outcome. The value travels only when resolved. */
2424
- type SecretResolution = {
2425
- status: "resolved";
2426
- value: string;
2427
- } | {
2428
- status: SecretResolutionFailure;
2429
- };
2430
- /** Resolves a secret reference. Injected so tests stay offline. */
2431
- type SecretReferenceResolver = (reference: string) => SecretResolution;
2432
- //#endregion
2433
2172
  //#region src/hq-flush.d.ts
2434
2173
  /**
2435
2174
  * Spool locations this run did not drain because they sit under an earlier
@@ -2474,9 +2213,155 @@ interface PrReviewGitDependencies {
2474
2213
  interface PrReviewDependencies {
2475
2214
  git?: PrReviewGitDependencies;
2476
2215
  hq?: HqIngestDependencies;
2477
- publishCheckRun?: (input: PublishFactoryCheckInput) => void;
2478
2216
  }
2479
2217
  declare function runPrReview(args: PrReviewArgs, dependencies?: PrReviewDependencies): Promise<PrReviewProof>;
2218
+ declare namespace verification_proof_d_exports {
2219
+ export { PrVerifyBaselineFullProof, PrVerifyCommandResult, PrVerifyExecutedCommand, PrVerifyNotRequiredCommand, PrVerifyProof, PrVerifySchemaVersion, ResolvedPrVerifyMode, SUPPORTED_PR_VERIFY_SCHEMA_VERSIONS, VerificationHeadShas, VerificationProofState, VerifiedHeadShas, prVerifyFullHeadShasForDiff, prVerifyProofHeadShas, readPrVerifyProof, resolveVerifyProofApplicability, trustedImpactStamp, validatePrVerifyProof, verificationProofApplicabilityFor, verificationProofBlockingReason, verificationProofForReadiness, verificationProofStateFor, verifyProofIdentityMatches, verifyProofPassed };
2220
+ }
2221
+ interface VerifiedHeadShas {
2222
+ docsOnlyVerifiedHeadShas: string[];
2223
+ trivialVerifiedHeadShas: string[];
2224
+ verifiedHeadShas: string[];
2225
+ }
2226
+ type VerificationHeadShas = {
2227
+ explicitFailure: true;
2228
+ } | VerifiedHeadShas;
2229
+ declare function readPrVerifyProof(filePath: string): PrVerifyProof;
2230
+ declare const verifyProofPassed: (proof: PrVerifyProof) => boolean;
2231
+ declare const prVerifyProofHeadShas: (proof: PrVerifyProof | undefined, creditedHeadSha?: string) => VerifiedHeadShas;
2232
+ declare const verifyProofIdentityMatches: ({
2233
+ currentIdentity,
2234
+ proof
2235
+ }: {
2236
+ currentIdentity?: {
2237
+ patchId: string;
2238
+ mergeBaseSha?: string;
2239
+ };
2240
+ proof?: PrVerifyProof;
2241
+ }) => boolean;
2242
+ /**
2243
+ * Wave-2 consumption (#542): the recorded impact stamp, released for demand
2244
+ * resolution ONLY when it is identity-bound to the current candidate — the
2245
+ * proof passed, and its recorded headSha AND patchId both name exactly this
2246
+ * candidate (the same identities the proof already binds). Everything else —
2247
+ * no proof, an aborted run, a stale head, a moved patch id, a pre-stamp proof
2248
+ * — returns `undefined`, and the consumer keeps today's full-demand floor.
2249
+ *
2250
+ * Deliberately stricter than verify-once applicability (which tolerates a
2251
+ * head-only or patch-id-only match): a stamp narrows external demands, so it
2252
+ * is trusted only on an exact double binding, fail closed.
2253
+ */
2254
+ declare const trustedImpactStamp: ({
2255
+ candidate,
2256
+ proof
2257
+ }: {
2258
+ candidate: {
2259
+ headSha: string;
2260
+ patchId: string;
2261
+ };
2262
+ proof: PrVerifyProof | undefined;
2263
+ }) => ImpactStamp | undefined;
2264
+ declare const prVerifyFullHeadShasForDiff: ({
2265
+ docsOnlyDeltaAcceptedSince,
2266
+ files,
2267
+ proof
2268
+ }: {
2269
+ docsOnlyDeltaAcceptedSince?: (baselineHeadSha: string) => boolean;
2270
+ files: string[];
2271
+ proof: PrVerifyProof;
2272
+ }) => string[];
2273
+ type VerificationProofState = {
2274
+ kind: "typed-aborted";
2275
+ proof: PrVerifyProof;
2276
+ } | {
2277
+ kind: "typed-missing";
2278
+ path: string;
2279
+ reason: "enoent" | "invalid";
2280
+ message?: string;
2281
+ } | {
2282
+ kind: "typed";
2283
+ headShas: VerifiedHeadShas;
2284
+ proof: PrVerifyProof;
2285
+ } | {
2286
+ kind: "typed-diff-mismatch";
2287
+ mode: ResolvedPrVerifyMode;
2288
+ };
2289
+ declare const verificationProofStateFor: ({
2290
+ proof,
2291
+ proofMatchesCurrentDiff,
2292
+ proofPath
2293
+ }: {
2294
+ proof?: PrVerifyProof;
2295
+ proofMatchesCurrentDiff?: boolean;
2296
+ proofPath?: string;
2297
+ }) => VerificationProofState;
2298
+ declare const verificationProofApplicabilityFor: ({
2299
+ docsOnlyDeltaAcceptedSince,
2300
+ explicitProof,
2301
+ files,
2302
+ headSha,
2303
+ currentIdentity,
2304
+ proof,
2305
+ proofPath,
2306
+ proofReadError
2307
+ }: {
2308
+ docsOnlyDeltaAcceptedSince?: (baselineHeadSha: string) => boolean;
2309
+ explicitProof: boolean;
2310
+ files: string[];
2311
+ headSha: string;
2312
+ currentIdentity?: {
2313
+ patchId: string;
2314
+ mergeBaseSha?: string;
2315
+ };
2316
+ proof?: PrVerifyProof;
2317
+ proofPath?: string;
2318
+ proofReadError?: unknown;
2319
+ }) => {
2320
+ fullVerifiedHeadShas: never[];
2321
+ verificationProof: VerificationProofState;
2322
+ } | {
2323
+ fullVerifiedHeadShas: string[];
2324
+ verificationProof: {
2325
+ headShas: VerifiedHeadShas;
2326
+ kind: "typed";
2327
+ proof: PrVerifyProof;
2328
+ };
2329
+ };
2330
+ declare const resolveVerifyProofApplicability: ({
2331
+ proofPath,
2332
+ explicitProof,
2333
+ docsOnlyDeltaAcceptedSince,
2334
+ files,
2335
+ headSha,
2336
+ currentVerifyIdentityForBase,
2337
+ preread
2338
+ }: {
2339
+ proofPath: string;
2340
+ explicitProof: boolean;
2341
+ docsOnlyDeltaAcceptedSince?: (baselineHeadSha: string) => boolean;
2342
+ files: string[];
2343
+ headSha: string;
2344
+ currentVerifyIdentityForBase?: (base: string) => {
2345
+ patchId: string;
2346
+ mergeBaseSha?: string;
2347
+ };
2348
+ preread?: {
2349
+ proof?: PrVerifyProof;
2350
+ error?: unknown;
2351
+ };
2352
+ }) => {
2353
+ fullVerifiedHeadShas: never[];
2354
+ verificationProof: VerificationProofState;
2355
+ } | {
2356
+ fullVerifiedHeadShas: string[];
2357
+ verificationProof: {
2358
+ headShas: VerifiedHeadShas;
2359
+ kind: "typed";
2360
+ proof: PrVerifyProof;
2361
+ };
2362
+ };
2363
+ declare const verificationProofForReadiness: (state: VerificationProofState) => VerificationHeadShas;
2364
+ declare const verificationProofBlockingReason: (state: VerificationProofState) => string | undefined;
2480
2365
  //#endregion
2481
2366
  //#region src/workspace-install-resolution.d.ts
2482
2367
  interface CleanInstallResolutionDependencies {
@@ -2769,11 +2654,11 @@ declare const LegacyWorkerCloseoutStatusTraceEventSchema: z.ZodObject<{
2769
2654
  threadId: z.ZodOptional<z.ZodString>;
2770
2655
  workerId: z.ZodOptional<z.ZodString>;
2771
2656
  archiveStatus: z.ZodOptional<z.ZodEnum<{
2657
+ pending: "pending";
2772
2658
  unavailable: "unavailable";
2773
2659
  archived: "archived";
2774
2660
  skipped: "skipped";
2775
2661
  "not-applicable": "not-applicable";
2776
- pending: "pending";
2777
2662
  }>>;
2778
2663
  closeoutReason: z.ZodOptional<z.ZodString>;
2779
2664
  eventType: z.ZodLiteral<"worker-closeout-lessons">;
@@ -3164,11 +3049,11 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3164
3049
  threadId: z.ZodOptional<z.ZodString>;
3165
3050
  workerId: z.ZodOptional<z.ZodString>;
3166
3051
  archiveStatus: z.ZodOptional<z.ZodEnum<{
3052
+ pending: "pending";
3167
3053
  unavailable: "unavailable";
3168
3054
  archived: "archived";
3169
3055
  skipped: "skipped";
3170
3056
  "not-applicable": "not-applicable";
3171
- pending: "pending";
3172
3057
  }>>;
3173
3058
  closeoutReason: z.ZodOptional<z.ZodString>;
3174
3059
  eventType: z.ZodLiteral<"worker-closeout-lessons">;
@@ -3205,11 +3090,11 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3205
3090
  }, z.core.$strict>], "lessonStatus">;
3206
3091
  readonly 2: z.ZodObject<{
3207
3092
  archiveStatus: z.ZodOptional<z.ZodEnum<{
3093
+ pending: "pending";
3208
3094
  unavailable: "unavailable";
3209
3095
  archived: "archived";
3210
3096
  skipped: "skipped";
3211
3097
  "not-applicable": "not-applicable";
3212
- pending: "pending";
3213
3098
  }>>;
3214
3099
  closeoutReason: z.ZodOptional<z.ZodString>;
3215
3100
  lessonStatus: z.ZodOptional<z.ZodEnum<{
@@ -3333,8 +3218,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3333
3218
  slotResolution: z.ZodObject<{
3334
3219
  effort: z.ZodEnum<{
3335
3220
  high: "high";
3336
- low: "low";
3337
3221
  medium: "medium";
3222
+ low: "low";
3338
3223
  xhigh: "xhigh";
3339
3224
  }>;
3340
3225
  engine: z.ZodString;
@@ -3412,8 +3297,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3412
3297
  slotResolution: z.ZodObject<{
3413
3298
  effort: z.ZodEnum<{
3414
3299
  high: "high";
3415
- low: "low";
3416
3300
  medium: "medium";
3301
+ low: "low";
3417
3302
  xhigh: "xhigh";
3418
3303
  }>;
3419
3304
  engine: z.ZodString;
@@ -3482,8 +3367,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3482
3367
  slotResolution: z.ZodObject<{
3483
3368
  effort: z.ZodEnum<{
3484
3369
  high: "high";
3485
- low: "low";
3486
3370
  medium: "medium";
3371
+ low: "low";
3487
3372
  xhigh: "xhigh";
3488
3373
  }>;
3489
3374
  engine: z.ZodString;
@@ -3551,7 +3436,7 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
3551
3436
  observedAt: string;
3552
3437
  purpose: "review" | "code";
3553
3438
  slotResolution: {
3554
- effort: "high" | "low" | "medium" | "xhigh";
3439
+ effort: "high" | "medium" | "low" | "xhigh";
3555
3440
  engine: string;
3556
3441
  layerSource: "committedDefault" | "operatorSession" | "userConfig";
3557
3442
  model: string;
@@ -3693,74 +3578,6 @@ declare const scanFactoryTraceDiagnostics: ({
3693
3578
  repoRoot,
3694
3579
  to
3695
3580
  }: ScanFactoryTraceDiagnosticsOptions) => FactoryTraceDiagnostic[];
3696
- //#endregion
3697
- //#region src/interior-telemetry/gate-timing.d.ts
3698
- declare const GATE_TIMING_SCHEMA_VERSION = 1;
3699
- type FactoryGateName = "boundary:check" | "factory:closeout" | "pr:ready" | "pr:review" | "pr:verify";
3700
- type GateTimingOutcome = "fail" | "pass";
3701
- interface GateTimingRecord {
3702
- agentRunId: string;
3703
- cycle: number;
3704
- durationMs: number;
3705
- gate: FactoryGateName;
3706
- outcome: GateTimingOutcome;
3707
- schemaVersion: typeof GATE_TIMING_SCHEMA_VERSION;
3708
- startedAt: string;
3709
- startOffsetMs: number;
3710
- }
3711
- //#endregion
3712
- //#region src/retro-envelope-builder.d.ts
3713
- /**
3714
- * Folds a lane's gate-timing ledger (`.factory-memory/gate-timing/<id>.jsonl`,
3715
- * wave-1 PR #33) into a versioned retro envelope at `factory:closeout`.
3716
- *
3717
- * STRUCTURAL INVARIANT (#677 repeat-class rule; PR #35 review cycles 1-2):
3718
- * telemetry CONTENT can never fail the closeout build gate. Every value that
3719
- * reaches the envelope passes through one sanitization seam that makes the
3720
- * output valid BY CONSTRUCTION:
3721
- *
3722
- * - strings are clamped to their wire bounds (truncated, with a data gap when
3723
- * truncation lost information);
3724
- * - numbers must be finite and within plausibility bounds BEFORE any derived
3725
- * arithmetic; an absurd value (1e16 ms duration, year-9999 timestamp) SKIPS
3726
- * its record with a data gap rather than clamping, because clamping would
3727
- * assert a measurement that never happened;
3728
- * - arrays are bounded to their schema maxima (gates[] keeps the most recent);
3729
- * - derived computations (wall clock, cycles) consume only sanitized inputs,
3730
- * so no ledger content can push them outside Date/Number safe ranges.
3731
- *
3732
- * Terminal backstop: the assembled candidate goes through a final schema
3733
- * parse; if that still fails, a minimal-valid envelope (clamped identity,
3734
- * empty gates, a data gap naming the failure) is built and returned instead.
3735
- * `buildRetroEnvelope` therefore never throws for content — the closeout gate
3736
- * can only fail on filesystem errors when persisting.
3737
- */
3738
- interface BuildRetroEnvelopeInput {
3739
- agentRunId: string;
3740
- /** Optional pointer (key/URL) to #8's durable proof archive — never payload. */
3741
- archiveRef?: string;
3742
- dataGaps?: string[];
3743
- generatedAt: Date;
3744
- interventions?: number;
3745
- /** Per-family session identities the lane already records. */
3746
- joinKeys?: {
3747
- claudeSessionIds?: string[];
3748
- codexThreadIds?: string[];
3749
- };
3750
- /** The lane's gate-timing ledger records, in append order. */
3751
- ledger: GateTimingRecord[];
3752
- outcome?: RetroEnvelope["outcome"];
3753
- phases?: RetroEnvelope["phases"];
3754
- refs: RetroEnvelope["refs"];
3755
- repo: RetroEnvelope["repo"];
3756
- /**
3757
- * Token families. They may be absent when native session data is unavailable
3758
- * (valid does not imply available telemetry). When present they satisfy the
3759
- * family invariants.
3760
- */
3761
- tokenFamilies?: RetroEnvelope["tokenFamilies"];
3762
- }
3763
- declare const buildRetroEnvelope: (input: BuildRetroEnvelopeInput) => RetroEnvelope;
3764
3581
  declare namespace comment_provenance_d_exports {
3765
3582
  export { SHA_MATCH_MIN_LENGTH, isBotLogin, sameHeadSha };
3766
3583
  }
@@ -3770,18 +3587,12 @@ declare const sameHeadSha: (left: string, right: string) => boolean;
3770
3587
  //#endregion
3771
3588
  //#region src/doctor-hq-checks.d.ts
3772
3589
  /**
3773
- * Two `doctor` checks that make silent HQ delivery failure loud (#394,
3774
- * epic #389 wave 2).
3775
- *
3776
- * Both consume #414's structured credential resolution rather than inventing
3777
- * a second classification: a sandboxed session that cannot reach the
3778
- * keychain is reported as "cannot resolve credentials here", never as
3779
- * "credentials are wrong" or a silent pass. Both name `psf hq:flush` and
3780
- * `psf pr:publish` as the commands that need a trusted local session.
3590
+ * The `doctor` check that makes silent HQ delivery failure loud (#394,
3591
+ * epic #389 wave 2): the local spool is empty, and no stranded evidence is
3592
+ * waiting under the spool root.
3781
3593
  *
3782
- * Advisory stays advisory: neither check can block anything but doctor's own
3783
- * exit status (epic #389 design decision 4). Absent credentials make the
3784
- * remote check a skip with a printed reason, never a silent pass.
3594
+ * Advisory stays advisory: this check can block nothing but doctor's own exit
3595
+ * status (epic #389 design decision 4).
3785
3596
  */
3786
3597
  type DoctorCheckStatus = "error" | "ok" | "warning";
3787
3598
  interface DoctorCheck {
@@ -3793,12 +3604,6 @@ interface HqSpoolCheckDependencies {
3793
3604
  countSpool?: typeof countHqSpoolWork;
3794
3605
  sweepOrphans?: typeof sweepHqSpoolOrphans;
3795
3606
  }
3796
- interface HqRetroReadbackCheckDependencies {
3797
- fetch?: typeof fetch;
3798
- readFile?: typeof readFile;
3799
- resolve?: SecretReferenceResolver;
3800
- timeoutMs?: number;
3801
- }
3802
3607
  //#endregion
3803
3608
  //#region src/doctor.d.ts
3804
3609
  interface DoctorReport {
@@ -3817,8 +3622,6 @@ interface DoctorProjectProfileInput extends LoadProjectProfileInput {
3817
3622
  base?: string;
3818
3623
  env?: NodeJS.ProcessEnv;
3819
3624
  /** Test seam for the local HQ spool check (#394); production never sets this. */
3820
- hqRetroReadbackDependencies?: HqRetroReadbackCheckDependencies;
3821
- /** Test seam for the remote HQ retro-envelope read-back check (#394). */
3822
3625
  hqSpoolDependencies?: HqSpoolCheckDependencies;
3823
3626
  /**
3824
3627
  * Append the read-only admission checklist (#292): every requirement this
@@ -3907,102 +3710,6 @@ declare const renderPrBodySections: ({
3907
3710
  reviewProof?: PrReviewProof;
3908
3711
  verifyProof?: PrVerifyProof;
3909
3712
  }) => string;
3910
- declare namespace boundary_manifest_d_exports {
3911
- export { BOUNDARY_CLOSEOUT_DEFAULT_RUNG, BOUNDARY_MANIFEST_SCHEMA_VERSION, BoundaryManifest, BoundaryManifestExtraction, BoundaryManifestParse, FACTORY_BOUNDARY_FENCE_LANG, boundaryManifestSchema, closeoutRungFor, extractBoundaryManifestBlock, manifestContentHash, parseBoundaryManifest, rungMeetsMinimum, specContentHash };
3912
- }
3913
- declare const FACTORY_BOUNDARY_FENCE_LANG = "factory-boundary";
3914
- declare const BOUNDARY_MANIFEST_SCHEMA_VERSION = 1;
3915
- declare const BOUNDARY_CLOSEOUT_DEFAULT_RUNG: EvidenceReviewRung;
3916
- declare const rungMeetsMinimum: (rung: EvidenceReviewRung, minimum: EvidenceReviewRung) => boolean;
3917
- declare const boundaryManifestBaseSchema: z.ZodObject<{
3918
- boundary: z.ZodString;
3919
- closeout: z.ZodOptional<z.ZodObject<{
3920
- review: z.ZodEnum<{
3921
- oracle: "oracle";
3922
- "independent-model": "independent-model";
3923
- human: "human";
3924
- }>;
3925
- }, z.core.$loose>>;
3926
- declaredBy: z.ZodString;
3927
- integrationBranch: z.ZodOptional<z.ZodString>;
3928
- prs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
3929
- schemaVersion: z.ZodLiteral<1>;
3930
- topology: z.ZodEnum<{
3931
- flagged: "flagged";
3932
- "each-to-main": "each-to-main";
3933
- stacked: "stacked";
3934
- "each-to-epic": "each-to-epic";
3935
- }>;
3936
- waves: z.ZodArray<z.ZodObject<{
3937
- autoMerge: z.ZodOptional<z.ZodBoolean>;
3938
- issues: z.ZodArray<z.ZodNumber>;
3939
- name: z.ZodString;
3940
- review: z.ZodEnum<{
3941
- oracle: "oracle";
3942
- "independent-model": "independent-model";
3943
- human: "human";
3944
- }>;
3945
- }, z.core.$loose>>;
3946
- }, z.core.$loose>;
3947
- declare const boundaryManifestSchema: z.ZodObject<{
3948
- boundary: z.ZodString;
3949
- closeout: z.ZodOptional<z.ZodObject<{
3950
- review: z.ZodEnum<{
3951
- oracle: "oracle";
3952
- "independent-model": "independent-model";
3953
- human: "human";
3954
- }>;
3955
- }, z.core.$loose>>;
3956
- declaredBy: z.ZodString;
3957
- integrationBranch: z.ZodOptional<z.ZodString>;
3958
- prs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
3959
- schemaVersion: z.ZodLiteral<1>;
3960
- topology: z.ZodEnum<{
3961
- flagged: "flagged";
3962
- "each-to-main": "each-to-main";
3963
- stacked: "stacked";
3964
- "each-to-epic": "each-to-epic";
3965
- }>;
3966
- waves: z.ZodArray<z.ZodObject<{
3967
- autoMerge: z.ZodOptional<z.ZodBoolean>;
3968
- issues: z.ZodArray<z.ZodNumber>;
3969
- name: z.ZodString;
3970
- review: z.ZodEnum<{
3971
- oracle: "oracle";
3972
- "independent-model": "independent-model";
3973
- human: "human";
3974
- }>;
3975
- }, z.core.$loose>>;
3976
- }, z.core.$loose>;
3977
- type BoundaryManifest = z.infer<typeof boundaryManifestBaseSchema>;
3978
- type BoundaryManifestExtraction = {
3979
- ok: true;
3980
- blockText: string;
3981
- } | {
3982
- ok: false;
3983
- error: string;
3984
- };
3985
- declare const extractBoundaryManifestBlock: (issueBody: string) => BoundaryManifestExtraction;
3986
- declare const manifestContentHash: (blockText: string) => string;
3987
- declare const specContentHash: (issueBody: string) => string;
3988
- type BoundaryManifestParse = {
3989
- ok: true;
3990
- manifest: BoundaryManifest;
3991
- manifestHash: string;
3992
- } | {
3993
- ok: false;
3994
- error: string;
3995
- };
3996
- declare const parseBoundaryManifest: (issueBody: string) => BoundaryManifestParse;
3997
- declare const closeoutRungFor: (manifest: BoundaryManifest) => EvidenceReviewRung;
3998
- //#endregion
3999
- //#region src/demand-resolution.d.ts
4000
- /** The boundary-manifest wave demand that applies to one pull request. */
4001
- interface WaveReviewDemand {
4002
- autoMerge: boolean;
4003
- review: EvidenceReviewRung;
4004
- wave: string;
4005
- }
4006
3713
  declare namespace readiness_evaluation_d_exports {
4007
3714
  export { CORRECTNESS_UNTYPED_REVIEW_BLOCKER_REASON, DRAFT_BLOCKER_REASON, EvaluationInput, ManagedReadinessLedger, PENDING_CHECKS_BLOCKER_REASON_PREFIX, READINESS_REPAIR_CODES, ReadinessRepair, ReadinessStatus, SCHEMA_VERSION, SECURITY_UNTYPED_REVIEW_BLOCKER_REASON, evaluateReadiness, managedReadinessLedgerSchema, readinessExitCode, readinessRepairSchema, validateManagedReadinessLedger };
4008
3715
  }
@@ -4059,7 +3766,7 @@ declare const evaluateReadiness: (input: EvaluationInput) => {
4059
3766
  draft: boolean;
4060
3767
  mergeStateStatus: string;
4061
3768
  mergeable: string;
4062
- requiredChecks: "unknown" | "pending" | "passed" | "failed" | "none";
3769
+ requiredChecks: "unknown" | "passed" | "failed" | "pending" | "none";
4063
3770
  unresolvedReviewThreads: number;
4064
3771
  reviewDecision?: string | null | undefined;
4065
3772
  };
@@ -4074,13 +3781,13 @@ declare const evaluateReadiness: (input: EvaluationInput) => {
4074
3781
  reviews: {
4075
3782
  correctness: {
4076
3783
  required: boolean;
4077
- status: "blocked" | "not-required" | "stale" | "current" | "missing";
3784
+ status: "stale" | "blocked" | "not-required" | "current" | "missing";
4078
3785
  reviewedHeadSha?: string | undefined;
4079
3786
  reviewedPatchId?: string | undefined;
4080
3787
  };
4081
3788
  security?: {
4082
3789
  required: boolean;
4083
- status: "blocked" | "not-required" | "stale" | "current" | "missing";
3790
+ status: "stale" | "blocked" | "not-required" | "current" | "missing";
4084
3791
  reviewedHeadSha?: string | undefined;
4085
3792
  reviewedPatchId?: string | undefined;
4086
3793
  } | undefined;
@@ -4119,8 +3826,8 @@ declare const evaluateReadiness: (input: EvaluationInput) => {
4119
3826
  nonBlockingFindings: number;
4120
3827
  openFindings: number;
4121
3828
  windowExhausted: boolean;
4122
- highestBlockingSeverity?: "unknown" | "critical" | "high" | "low" | "medium" | undefined;
4123
- highestOpenSeverity?: "unknown" | "critical" | "high" | "low" | "medium" | undefined;
3829
+ highestBlockingSeverity?: "unknown" | "critical" | "high" | "medium" | "low" | undefined;
3830
+ highestOpenSeverity?: "unknown" | "critical" | "high" | "medium" | "low" | undefined;
4124
3831
  maxReviewCycles?: number | undefined;
4125
3832
  reviewCycle?: number | undefined;
4126
3833
  staleRepeatFindings?: number | undefined;
@@ -4131,7 +3838,7 @@ declare const evaluateReadiness: (input: EvaluationInput) => {
4131
3838
  interior: number;
4132
3839
  };
4133
3840
  nextAction: "run-gate-cycle" | "accept-nonblocking-findings" | "escalate-to-triage" | "ready-for-human" | "advance-to-gate" | "run-interior-cycle";
4134
- stage: "gate" | "interior" | "interior-complete";
3841
+ stage: "gate" | "interior-complete" | "interior";
4135
3842
  forcedTransition?: "gate-cap-exhausted" | "interior-cap-reached" | undefined;
4136
3843
  } | undefined;
4137
3844
  reviewRuns?: PrReviewResult[] | undefined;
@@ -4652,4 +4359,4 @@ interface CreateProgramOptions {
4652
4359
  declare function createProgram(options?: CreateProgramOptions): Command;
4653
4360
  declare function run(argv?: string[]): Promise<void>;
4654
4361
  //#endregion
4655
- export { type AppendFactoryTraceEventResult, type AssembledReviewPrompt, type BatteryCommandDisposition, type BatteryDisposition, type BoundaryCheckArgs, type BoundaryCheckDependencies, type BoundaryCheckProofRecord, type BuildEpicStructureEventInput, type BuildRetroEnvelopeInput, type CloudflareAccessServiceToken, CreateProgramOptions, DEFAULT_DEMAND_WAIVER_PATH, DEFAULT_FACTORY_REPOSITORY, type DagDocument, type DemandWaiveArgs, type DemandWaiveDependencies, DemandWaiveRefusalError, type DemandWaiver, type DemandWaiverStore, EPIC_STRUCTURE_NODE_STATUSES, EPIC_STRUCTURE_SCHEMA_VERSION, type EpicStructureEvent, type EpicStructureGraphPayload, type EpicStructureNodeStatus, EpicStructureValidationError, type EvidenceEmitArgs, type EvidenceEmitDependencies, type EvidenceEmitResult, type FactoryCliInvocation, FactoryCliInvocationSchema, type FactoryProjectProfile, type FactoryTraceDiagnostic, type FactoryTraceEnvelope, type FactoryTraceEvent, type FindingDisposition, type FindingLedgerEntry, type FollowUpAction, FollowUpActionSchema, type ImpactScopeDecision, type ImpactScopeSurface, type IssueReviewFocus, type LadderDispositionDeclaration, MERGE_FREEZE_APP_SLUG, MERGE_FREEZE_CHECK_NAME, type MergeFreezeState, type ParsedRetroEnvelope, type PrPublishArgs, type PrPublishDependencies, PrPublishFollowUpError, type PrPublishFollowUpOutcome, type PrPublishHandoff, type PrPublishResult, type PrReadyArgs, type PrReadyProof, type PreviewDisposition, type PreviewLifecyclePlan, type PreviewTargetPlan, type PublishEpicStructureArgs, type PublishEpicStructureResult, type PublishFollowUpPlan, RETRO_ENVELOPE_SCHEMA_VERSION, RETRO_ENVELOPE_VALIDATORS, REVIEW_FOCUS_SECTION, type RetroEnvelope, type ReviewGateNotRequiredProof, type ReviewGateTraceIdentity, type ReviewLadderCycle, type ReviewLadderEvaluation, type ReviewLadderPolicy, type ReviewLadderStageEvent, type ReviewLadderTraceIdentity, type ReviewPromptSection, type ReviewPromptSectionProvenance, SUPPORTED_RETRO_ENVELOPE_SCHEMA_VERSIONS, type ScanFactoryTraceDiagnosticsOptions, type ScanFactoryTraceOptions, type ScanFactoryTraceResult, type ScopedOutCommand, type TraceMirrorDiagnostic, type TraceSink, type TraceWriteResult, type TraceWriteSinks, type VerificationBatteryPlan, type VerificationReuse, type WaivedDemand, WorkerCheckoutGuardError, type WorkerCloseoutLessonsTraceEvent, appendReviewLadderStageTraceEvent, appendWithTraceSinks, applyDemandWaiver, assembleReviewPrompt, assertWorkerCheckoutAllowed, authorizeDemandWaiver, batteryScopeSummaryLines, blockingLadderFindings, boundary_manifest_d_exports as boundaryManifest, boundary_review_proof_d_exports as boundaryReviewProof, buildEpicStructureEvent, buildEpicStructurePayload, buildEvidenceEnvelope, buildRetroEnvelope, buildReviewGateNotRequiredTraceEvent, buildReviewLadderStageTraceEvent, comment_provenance_d_exports as commentProvenance, createLocalJsonlTraceSink, createProgram, doctorProjectProfile, epicStructureEventId, evaluateReviewLadder, evidenceEnvelopeFilename, findingKey, followUpFromArgv, impactStampScopeDecision, inferFixedInThreadDispositions, isProductionHqUrl, isRetroEnvelopeWireComplete, loadProjectProfile, normalizeIssueComments, openLadderFindings, parseRetroEnvelope, 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, previewLifecycleTargets, publishEpicStructure, readDemandWaivers, readPrReadyProof, readPrReviewProof, resolveFactoryRepository, resolveFindingBlocking, resolveReviewFindingCategory, resolveReviewFindingSeverity, resolveReviewLadderPolicy, resolveTraceWriteSinks, retroEnvelopeSchemaVersionOf, retroEnvelopeV1Schema, retroEpicReference, 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, waivedDemandNotice, waivedDemandSchema, worktree_scratch_files_d_exports as worktreeScratchFiles };
4362
+ export { type AppendFactoryTraceEventResult, type AssembledReviewPrompt, type BatteryCommandDisposition, type BatteryDisposition, type BoundaryCheckArgs, type BoundaryCheckDependencies, type BoundaryCheckProofRecord, type BuildEpicStructureEventInput, type CloudflareAccessServiceToken, CreateProgramOptions, DEFAULT_DEMAND_WAIVER_PATH, DEFAULT_FACTORY_REPOSITORY, type DagDocument, type DemandWaiveArgs, type DemandWaiveDependencies, DemandWaiveRefusalError, type DemandWaiver, type DemandWaiverStore, EPIC_STRUCTURE_NODE_STATUSES, EPIC_STRUCTURE_SCHEMA_VERSION, type EpicStructureEvent, type EpicStructureGraphPayload, type EpicStructureNodeStatus, EpicStructureValidationError, type EvidenceEmitArgs, type EvidenceEmitDependencies, type EvidenceEmitResult, type FactoryCliInvocation, FactoryCliInvocationSchema, type FactoryProjectProfile, type FactoryTraceDiagnostic, type FactoryTraceEnvelope, type FactoryTraceEvent, type FindingDisposition, type FindingLedgerEntry, type FollowUpAction, FollowUpActionSchema, type ImpactScopeDecision, type ImpactScopeSurface, type IssueReviewFocus, type LadderDispositionDeclaration, MERGE_FREEZE_APP_SLUG, MERGE_FREEZE_CHECK_NAME, type MergeFreezeState, type PrPublishArgs, type PrPublishDependencies, PrPublishFollowUpError, type PrPublishFollowUpOutcome, type PrPublishHandoff, type PrPublishResult, type PrReadyArgs, type PrReadyProof, type PreviewDisposition, type PreviewLifecyclePlan, type PreviewTargetPlan, type PublishEpicStructureArgs, type PublishEpicStructureResult, type PublishFollowUpPlan, REVIEW_FOCUS_SECTION, 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 WaivedDemand, WorkerCheckoutGuardError, type WorkerCloseoutLessonsTraceEvent, appendReviewLadderStageTraceEvent, appendWithTraceSinks, applyDemandWaiver, assembleReviewPrompt, 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, createLocalJsonlTraceSink, createProgram, doctorProjectProfile, epicStructureEventId, evaluateReviewLadder, evidenceEnvelopeFilename, findingKey, followUpFromArgv, impactStampScopeDecision, inferFixedInThreadDispositions, isProductionHqUrl, loadProjectProfile, normalizeIssueComments, openLadderFindings, 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, previewLifecycleTargets, publishEpicStructure, readDemandWaivers, readPrReadyProof, readPrReviewProof, 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, waivedDemandNotice, waivedDemandSchema, worktree_scratch_files_d_exports as worktreeScratchFiles };