@patronage/software-factory 1.0.0-alpha.47 → 1.0.0-alpha.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/dist/ci.d.ts +1888 -0
- package/dist/ci.js +4519 -0
- package/dist/cloud/review.sh +76 -0
- package/dist/cloud/run.sh +63 -0
- package/dist/cloud/session-env.sh +80 -0
- package/dist/index.d.ts +125 -403
- package/dist/index.js +7716 -5806
- package/dist/rolldown-runtime-D3KUYPsf.js +12 -0
- package/dist/schemas.d.ts +8 -0
- package/dist/schemas.js +66 -63
- package/package.json +21 -15
- package/dist/rolldown-runtime-D8jQpDG7.js +0 -12
package/dist/ci.d.ts
ADDED
|
@@ -0,0 +1,1888 @@
|
|
|
1
|
+
import { StdioOptions } from "node:child_process";
|
|
2
|
+
/**
|
|
3
|
+
* The GitHub Actions this family's workflow generators use, pinned to full
|
|
4
|
+
* commit SHAs in one place (#268).
|
|
5
|
+
*
|
|
6
|
+
* `uses` is a bare `owner/repo@<sha>` string, safe to hand straight to a
|
|
7
|
+
* gagen step. The tag lives in its own field rather than as a `# v7.0.1`
|
|
8
|
+
* suffix on `uses`, because a `#` inside a YAML scalar forces quoting and
|
|
9
|
+
* gagen's pin pass reads the value with `\S+` — the two together corrupt the
|
|
10
|
+
* emitted `uses:` line. gagen writes the `# <tag>` comment itself.
|
|
11
|
+
*/
|
|
12
|
+
interface PinnedAction {
|
|
13
|
+
/** `owner/repo@<40-char commit sha>`, ready to use as a step's `uses`. */
|
|
14
|
+
readonly uses: string;
|
|
15
|
+
/** The release tag that commit carries, for humans and for bump tooling. */
|
|
16
|
+
readonly tag: string;
|
|
17
|
+
}
|
|
18
|
+
interface NodePnpmActionFamily {
|
|
19
|
+
/** Review-visible identity for the complete, compatible action family. */
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly checkout: PinnedAction;
|
|
22
|
+
readonly setupNode: PinnedAction;
|
|
23
|
+
readonly setupPnpm: PinnedAction;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The canonical Node 24 family shared by factory-project workflows.
|
|
27
|
+
*
|
|
28
|
+
* Consumers must pass this (or their own complete family) to
|
|
29
|
+
* `factoryWorkflow`; there is deliberately no implicit default. Every action
|
|
30
|
+
* in this family declares `runs.using: node24` at the named release.
|
|
31
|
+
*/
|
|
32
|
+
export declare const NODE_PNPM_ACTION_FAMILY_NODE24: {
|
|
33
|
+
readonly checkout: {
|
|
34
|
+
readonly tag: "v7.0.1";
|
|
35
|
+
readonly uses: "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1";
|
|
36
|
+
};
|
|
37
|
+
readonly id: "node-pnpm-node24";
|
|
38
|
+
readonly setupNode: {
|
|
39
|
+
readonly tag: "v7.0.0";
|
|
40
|
+
readonly uses: "actions/setup-node@820762786026740c76f36085b0efc47a31fe5020";
|
|
41
|
+
};
|
|
42
|
+
readonly setupPnpm: {
|
|
43
|
+
readonly tag: "v6.0.9";
|
|
44
|
+
readonly uses: "pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271";
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* The one `actions/upload-artifact` pin every workflow generator shares
|
|
49
|
+
* (#887). Two callers pinned two different commits of the same tag family;
|
|
50
|
+
* naming the pin here makes that drift impossible the same way the Node/pnpm
|
|
51
|
+
* family does. A caller passes this through `factoryWorkflow`'s
|
|
52
|
+
* `additionalActions.uploadArtifact` explicitly — the catalog names the pin,
|
|
53
|
+
* it does not inject the upload step.
|
|
54
|
+
*/
|
|
55
|
+
export declare const UPLOAD_ARTIFACT: {
|
|
56
|
+
readonly tag: "v4.6.2";
|
|
57
|
+
readonly uses: "actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02";
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Pull-request events that can create or refresh a Factory candidate run.
|
|
61
|
+
*
|
|
62
|
+
* GitHub's draft boolean remains the lifecycle authority: these triggers make
|
|
63
|
+
* a run visible, while `factoryCandidateOrPushCondition` keeps substantive
|
|
64
|
+
* jobs idle until the pull request is a candidate.
|
|
65
|
+
*/
|
|
66
|
+
export declare const FACTORY_CANDIDATE_PULL_REQUEST_TYPES: readonly ["opened", "synchronize", "reopened", "ready_for_review"];
|
|
67
|
+
/**
|
|
68
|
+
* Build a GitHub Actions job condition for candidate PRs and merge-target
|
|
69
|
+
* pushes. The caller owns triggers, jobs, runners, permissions, and topology.
|
|
70
|
+
*/
|
|
71
|
+
export declare const factoryCandidateOrPushCondition: (candidateCondition?: string) => string;
|
|
72
|
+
declare const localPreviewStageBrand: unique symbol;
|
|
73
|
+
type LocalPreviewStage = string & {
|
|
74
|
+
readonly [localPreviewStageBrand]: true;
|
|
75
|
+
};
|
|
76
|
+
interface ParsedLocalPreviewStage {
|
|
77
|
+
readonly headShaPrefix: string;
|
|
78
|
+
readonly pr: number;
|
|
79
|
+
readonly stage: LocalPreviewStage;
|
|
80
|
+
}
|
|
81
|
+
interface ParseLocalPreviewStageExpected {
|
|
82
|
+
/** Require the stage to belong to this pull request. */
|
|
83
|
+
readonly pr?: number;
|
|
84
|
+
/** Require the stage prefix to match this full 40-character head SHA. */
|
|
85
|
+
readonly headSha?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Interpret an untrusted stage name through the one disposable-stage grammar.
|
|
89
|
+
* Returns `null` rather than throwing when the value or expected ownership
|
|
90
|
+
* does not match.
|
|
91
|
+
*/
|
|
92
|
+
export declare const parseLocalPreviewStage: (stage: string, expected?: ParseLocalPreviewStageExpected) => ParsedLocalPreviewStage | null;
|
|
93
|
+
/**
|
|
94
|
+
* Whether `stage` is disposable. Pass `pr` to also require PR ownership.
|
|
95
|
+
*/
|
|
96
|
+
export declare const isLocalPreviewStage: (stage: string, pr?: number) => stage is LocalPreviewStage;
|
|
97
|
+
interface LocalPreviewStageOptions {
|
|
98
|
+
/** The pull request number. */
|
|
99
|
+
readonly pr: number;
|
|
100
|
+
/** The full head SHA the preview is tied to. */
|
|
101
|
+
readonly headSha: string;
|
|
102
|
+
/** How much of the SHA to keep. Default 12; the grammar allows 7 to 40. */
|
|
103
|
+
readonly shaLength?: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Build the disposable stage name for a pull request head.
|
|
107
|
+
*
|
|
108
|
+
* Throws when the inputs cannot produce a valid stage, so a caller can never
|
|
109
|
+
* deploy into a name the cleanup sweep will not recognise.
|
|
110
|
+
*/
|
|
111
|
+
export declare const localPreviewStage: (options: LocalPreviewStageOptions) => LocalPreviewStage;
|
|
112
|
+
/**
|
|
113
|
+
* Preview-proof lifecycle: admit a disposable preview, register envelope-bound
|
|
114
|
+
* proof at head, and record cleanup. One `transition` path owns those state
|
|
115
|
+
* changes. Recovery (#766) re-enters cleanup through the same event. Hosted
|
|
116
|
+
* inventory listing and cleanup-outcome persistence live in
|
|
117
|
+
* `previewProofInventory`, which sits on the registration read model `resolve`
|
|
118
|
+
* already returns.
|
|
119
|
+
*
|
|
120
|
+
* Proof sits entirely on one side of GitHub's draft/ready boundary
|
|
121
|
+
* (paitronage#1089): a draft candidate cannot begin or register. Machine
|
|
122
|
+
* evidence is the envelope at head (#355), never a PR comment. The SHA and
|
|
123
|
+
* repository bind that proof (#1312): a detached HEAD or a branch name that
|
|
124
|
+
* differs from the PR head is the same commit, and the registration records
|
|
125
|
+
* `branch: "(detached)"`.
|
|
126
|
+
*/
|
|
127
|
+
type PreviewProofCleanupStatus = "failed" | "passed" | "pending";
|
|
128
|
+
interface PreviewProofCandidate {
|
|
129
|
+
readonly branch: string;
|
|
130
|
+
readonly dirty: boolean;
|
|
131
|
+
readonly headSha: string;
|
|
132
|
+
readonly isDraft: boolean;
|
|
133
|
+
readonly pr: number;
|
|
134
|
+
readonly prHeadRef: string;
|
|
135
|
+
readonly prHeadSha: string;
|
|
136
|
+
readonly prRepository: string;
|
|
137
|
+
readonly prState: "CLOSED" | "MERGED" | "OPEN";
|
|
138
|
+
readonly repository: string;
|
|
139
|
+
}
|
|
140
|
+
interface PreviewProofEnvelopeEvidence {
|
|
141
|
+
readonly check: string;
|
|
142
|
+
readonly headSha: string;
|
|
143
|
+
readonly mergeBaseSha: string;
|
|
144
|
+
readonly outcome: "fail" | "pass";
|
|
145
|
+
readonly patchId: string;
|
|
146
|
+
}
|
|
147
|
+
interface PreviewProofCleanupOutcome {
|
|
148
|
+
readonly evidence: readonly string[];
|
|
149
|
+
readonly outcome: Exclude<PreviewProofCleanupStatus, "pending">;
|
|
150
|
+
readonly runUrl?: string;
|
|
151
|
+
}
|
|
152
|
+
interface PreviewProofRegistration {
|
|
153
|
+
/**
|
|
154
|
+
* Present only when the checkout is detached or its branch name is not the
|
|
155
|
+
* PR head. The `(detached)` sentinel is on the lifecycle registration
|
|
156
|
+
* `transition` returns, and `previewProofInventory` does not persist it.
|
|
157
|
+
* It is not a branch to check out.
|
|
158
|
+
*/
|
|
159
|
+
readonly branch?: "(detached)";
|
|
160
|
+
readonly cleanup: {
|
|
161
|
+
readonly evidence: readonly string[];
|
|
162
|
+
readonly outcome: PreviewProofCleanupStatus;
|
|
163
|
+
readonly runUrl?: string;
|
|
164
|
+
};
|
|
165
|
+
readonly convergence: {
|
|
166
|
+
readonly detail: string;
|
|
167
|
+
readonly status: "passed";
|
|
168
|
+
};
|
|
169
|
+
readonly headSha: string;
|
|
170
|
+
readonly pr: number;
|
|
171
|
+
readonly proof: {
|
|
172
|
+
readonly check: string;
|
|
173
|
+
readonly headSha: string;
|
|
174
|
+
readonly mergeBaseSha: string;
|
|
175
|
+
readonly patchId: string;
|
|
176
|
+
};
|
|
177
|
+
readonly smoke: {
|
|
178
|
+
readonly detail: string;
|
|
179
|
+
readonly outcome: "passed";
|
|
180
|
+
};
|
|
181
|
+
readonly source: "local-self-certified";
|
|
182
|
+
readonly stack: string;
|
|
183
|
+
readonly stage: LocalPreviewStage;
|
|
184
|
+
readonly url: string;
|
|
185
|
+
}
|
|
186
|
+
interface PreviewProofLifecycleState {
|
|
187
|
+
readonly registrations: readonly PreviewProofRegistration[];
|
|
188
|
+
}
|
|
189
|
+
type PreviewProofLifecycleEvent = {
|
|
190
|
+
readonly candidate: PreviewProofCandidate;
|
|
191
|
+
readonly stage: string;
|
|
192
|
+
readonly type: "begin";
|
|
193
|
+
} | {
|
|
194
|
+
readonly candidate: PreviewProofCandidate;
|
|
195
|
+
readonly convergence: {
|
|
196
|
+
readonly detail: string;
|
|
197
|
+
readonly status: "failed" | "passed";
|
|
198
|
+
};
|
|
199
|
+
readonly evidence: PreviewProofEnvelopeEvidence;
|
|
200
|
+
readonly smoke: {
|
|
201
|
+
readonly detail: string;
|
|
202
|
+
readonly outcome: "failed" | "passed";
|
|
203
|
+
};
|
|
204
|
+
readonly stack: string;
|
|
205
|
+
readonly stage: string;
|
|
206
|
+
readonly type: "register";
|
|
207
|
+
readonly url: string;
|
|
208
|
+
} | {
|
|
209
|
+
readonly evidence: readonly string[];
|
|
210
|
+
readonly outcome: Exclude<PreviewProofCleanupStatus, "pending">;
|
|
211
|
+
readonly pr: number;
|
|
212
|
+
readonly runUrl?: string;
|
|
213
|
+
readonly stack: string;
|
|
214
|
+
readonly stage: string;
|
|
215
|
+
readonly type: "cleanup";
|
|
216
|
+
};
|
|
217
|
+
interface PreviewProofResolveQuery {
|
|
218
|
+
readonly pr?: number;
|
|
219
|
+
readonly stack?: string;
|
|
220
|
+
readonly stage?: string;
|
|
221
|
+
}
|
|
222
|
+
declare const empty: () => PreviewProofLifecycleState;
|
|
223
|
+
declare const resolve: (state: PreviewProofLifecycleState, query?: PreviewProofResolveQuery) => readonly PreviewProofRegistration[];
|
|
224
|
+
declare const transition: (state: PreviewProofLifecycleState, event: PreviewProofLifecycleEvent) => PreviewProofLifecycleState;
|
|
225
|
+
declare const recover: (state: PreviewProofLifecycleState, event: Extract<PreviewProofLifecycleEvent, {
|
|
226
|
+
type: "cleanup";
|
|
227
|
+
}>) => PreviewProofLifecycleState;
|
|
228
|
+
export declare const previewProofLifecycle: {
|
|
229
|
+
readonly empty: typeof empty;
|
|
230
|
+
readonly recover: typeof recover;
|
|
231
|
+
readonly resolve: typeof resolve;
|
|
232
|
+
readonly transition: typeof transition;
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Hosted preview-proof inventory (#639): persist and list Factory-App
|
|
236
|
+
* registrations, and record cleanup outcomes, without PR comments.
|
|
237
|
+
*
|
|
238
|
+
* `list` is a read over App-owned commit check-runs and works with a workflow
|
|
239
|
+
* `GITHUB_TOKEN`. `persist` and `recordCleanup` write those check-runs, which
|
|
240
|
+
* GitHub only allows the producing App to update. Pass an installation token
|
|
241
|
+
* the caller minted; this package does not read operator config or hold
|
|
242
|
+
* secrets. Cleanup writes go through `previewProofLifecycle.transition` with
|
|
243
|
+
* `{ type: "cleanup" }`. Outcomes are never inferred from whether a stage
|
|
244
|
+
* still exists.
|
|
245
|
+
*
|
|
246
|
+
* Transient transport failures are retried with bounded backoff and then
|
|
247
|
+
* surface as `PreviewProofTransportError` (#830). A failure from `persist` or
|
|
248
|
+
* `recordCleanup` is an evidence-registration failure, never a failed
|
|
249
|
+
* deployment: the caller retains the healthy disposable stage, records its own
|
|
250
|
+
* proof BLOCKED (never PASS), and re-runs registration at the same head —
|
|
251
|
+
* writes are keyed by stack and stage, so resuming needs no redeploy.
|
|
252
|
+
* Admission stays fail-closed on its own: an unregistered proof never
|
|
253
|
+
* satisfies the preview demand.
|
|
254
|
+
*/
|
|
255
|
+
/** Check-run name that carries one registration JSON payload. Not a gate. */
|
|
256
|
+
export declare const PREVIEW_PROOF_INVENTORY_CHECK_NAME = "patronage-factory/preview-proof";
|
|
257
|
+
/**
|
|
258
|
+
* Least privilege for a job whose `GITHUB_TOKEN` calls `list`. A
|
|
259
|
+
* `permissions` block zeroes every unlisted scope, and `list` reads five
|
|
260
|
+
* endpoints: `pulls/{pr}`, `pulls/{pr}/commits`, and the GraphQL force-push
|
|
261
|
+
* timeline (`pull-requests`), `compare` (`contents`), and
|
|
262
|
+
* `commits/{sha}/check-runs` (`checks`). A job
|
|
263
|
+
* that omits `pull-requests: read` fails with 403 on a same-repository PR
|
|
264
|
+
* and skips every destroy matrix (#859). Give the discovery job this object.
|
|
265
|
+
*/
|
|
266
|
+
export declare const PREVIEW_PROOF_INVENTORY_LIST_PERMISSIONS: Readonly<{
|
|
267
|
+
readonly checks: "read";
|
|
268
|
+
readonly contents: "read";
|
|
269
|
+
readonly "pull-requests": "read";
|
|
270
|
+
}>;
|
|
271
|
+
interface PreviewProofInventoryStore {
|
|
272
|
+
list: (input: {
|
|
273
|
+
owner: string;
|
|
274
|
+
pr: number;
|
|
275
|
+
repo: string;
|
|
276
|
+
}) => Promise<readonly PreviewProofRegistration[]>;
|
|
277
|
+
put: (input: {
|
|
278
|
+
owner: string;
|
|
279
|
+
registration: PreviewProofRegistration;
|
|
280
|
+
repo: string;
|
|
281
|
+
}) => Promise<void>;
|
|
282
|
+
}
|
|
283
|
+
interface PreviewProofInventoryTransport {
|
|
284
|
+
/** Injectable `fetch` (tests, or a caller with its own instrumented one). */
|
|
285
|
+
fetch?: typeof fetch;
|
|
286
|
+
/** Per-request timeout; defaults to five seconds. */
|
|
287
|
+
timeoutMs?: number;
|
|
288
|
+
/**
|
|
289
|
+
* Bearer token. `list` accepts a workflow `GITHUB_TOKEN` (read) and needs
|
|
290
|
+
* commit (contents) read for the force-push timeline; the contents-less
|
|
291
|
+
* Factory App token cannot serve it (#825). `persist` and `recordCleanup`
|
|
292
|
+
* must use a Factory App installation token: GitHub refuses GITHUB_TOKEN
|
|
293
|
+
* writes to App-owned check-runs.
|
|
294
|
+
*/
|
|
295
|
+
token: string;
|
|
296
|
+
}
|
|
297
|
+
interface PreviewProofInventoryAccess {
|
|
298
|
+
fetch?: typeof fetch;
|
|
299
|
+
store?: PreviewProofInventoryStore;
|
|
300
|
+
timeoutMs?: number;
|
|
301
|
+
token?: string;
|
|
302
|
+
}
|
|
303
|
+
interface PreviewProofInventoryListInput {
|
|
304
|
+
owner: string;
|
|
305
|
+
pr: number;
|
|
306
|
+
repo: string;
|
|
307
|
+
stack?: string;
|
|
308
|
+
stage?: string;
|
|
309
|
+
}
|
|
310
|
+
interface PreviewProofInventoryPersistInput {
|
|
311
|
+
owner: string;
|
|
312
|
+
registration: PreviewProofRegistration;
|
|
313
|
+
repo: string;
|
|
314
|
+
}
|
|
315
|
+
interface PreviewProofInventoryCleanupInput {
|
|
316
|
+
evidence: readonly string[];
|
|
317
|
+
headSha?: string;
|
|
318
|
+
outcome: Exclude<PreviewProofCleanupStatus, "pending">;
|
|
319
|
+
owner: string;
|
|
320
|
+
pr: number;
|
|
321
|
+
repo: string;
|
|
322
|
+
runUrl?: string;
|
|
323
|
+
stack: string;
|
|
324
|
+
stage: string;
|
|
325
|
+
}
|
|
326
|
+
/** Reached by callers as `previewProofInventory.memoryStore`. */
|
|
327
|
+
declare const memoryStore: () => PreviewProofInventoryStore;
|
|
328
|
+
/**
|
|
329
|
+
* The transport gave out — a network-level rejection (EPIPE, DNS, an aborted
|
|
330
|
+
* or timed-out request) or a transient HTTP status — and bounded retries did
|
|
331
|
+
* not recover it. GitHub never judged the content, so this is never a
|
|
332
|
+
* validation verdict and never a deployment failure. Only a bounded reason
|
|
333
|
+
* string is retained: the raw transport error can hold the request and its
|
|
334
|
+
* `Authorization` header, so it is deliberately discarded.
|
|
335
|
+
*/
|
|
336
|
+
export declare class PreviewProofTransportError extends Error {
|
|
337
|
+
/** How many transport attempts were made before giving up. */
|
|
338
|
+
readonly attempts: number;
|
|
339
|
+
/** The last transient HTTP status, when the server answered at all. */
|
|
340
|
+
readonly status?: number;
|
|
341
|
+
constructor(reason: string, attempts: number, status?: number);
|
|
342
|
+
}
|
|
343
|
+
/** Reached by callers as `previewProofInventory.githubStore`. */
|
|
344
|
+
declare const githubStore: (transport: PreviewProofInventoryTransport) => PreviewProofInventoryStore;
|
|
345
|
+
declare const list: (input: PreviewProofInventoryListInput, access: PreviewProofInventoryAccess) => Promise<readonly PreviewProofRegistration[]>;
|
|
346
|
+
declare const persist: (input: PreviewProofInventoryPersistInput, access: PreviewProofInventoryAccess) => Promise<void>;
|
|
347
|
+
declare const recordCleanup: (input: PreviewProofInventoryCleanupInput, access: PreviewProofInventoryAccess) => Promise<PreviewProofRegistration>;
|
|
348
|
+
export declare const previewProofInventory: {
|
|
349
|
+
readonly githubStore: typeof githubStore;
|
|
350
|
+
readonly list: typeof list;
|
|
351
|
+
readonly listPermissions: Readonly<{
|
|
352
|
+
readonly checks: "read";
|
|
353
|
+
readonly contents: "read";
|
|
354
|
+
readonly "pull-requests": "read";
|
|
355
|
+
}>;
|
|
356
|
+
readonly memoryStore: typeof memoryStore;
|
|
357
|
+
readonly persist: typeof persist;
|
|
358
|
+
readonly recordCleanup: typeof recordCleanup;
|
|
359
|
+
};
|
|
360
|
+
interface WorkflowStep {
|
|
361
|
+
readonly continueOnError?: boolean;
|
|
362
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
363
|
+
readonly id?: string;
|
|
364
|
+
readonly if?: string;
|
|
365
|
+
readonly name: string;
|
|
366
|
+
readonly uses?: string;
|
|
367
|
+
readonly with?: Readonly<Record<string, string>>;
|
|
368
|
+
readonly run?: string;
|
|
369
|
+
}
|
|
370
|
+
interface CheckoutStepOptions {
|
|
371
|
+
readonly fetchDepth?: number;
|
|
372
|
+
readonly name?: string;
|
|
373
|
+
readonly ref?: string;
|
|
374
|
+
}
|
|
375
|
+
interface SetupNodeStepOptions {
|
|
376
|
+
readonly cacheDependencyPath?: string;
|
|
377
|
+
readonly nodeVersionFile?: string;
|
|
378
|
+
}
|
|
379
|
+
interface InstallStepOptions {
|
|
380
|
+
readonly name?: string;
|
|
381
|
+
readonly run?: string;
|
|
382
|
+
}
|
|
383
|
+
interface FactoryWorkflowSetupOptions {
|
|
384
|
+
readonly checkout?: CheckoutStepOptions;
|
|
385
|
+
readonly install?: InstallStepOptions;
|
|
386
|
+
readonly setupNode?: SetupNodeStepOptions;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Stable identifiers for the setup steps a generated workflow always emits,
|
|
390
|
+
* in emission order. A consumer selects steps by role instead of locating
|
|
391
|
+
* them by display name or by array position/length, so renaming a step or
|
|
392
|
+
* adding a new supported role never breaks role-based composition (#1076).
|
|
393
|
+
*/
|
|
394
|
+
export declare const SETUP_STEP_ROLES: readonly ["checkout", "setupPnpm", "setupNode", "install"];
|
|
395
|
+
type SetupStepRole = (typeof SETUP_STEP_ROLES)[number];
|
|
396
|
+
interface FactoryWorkflowOptions<Additional extends Readonly<Record<string, PinnedAction>>> {
|
|
397
|
+
/**
|
|
398
|
+
* Required complete family. There is no default, so adopting this package
|
|
399
|
+
* cannot silently move a consumer from one action major to another.
|
|
400
|
+
*/
|
|
401
|
+
readonly actionFamily: NodePnpmActionFamily;
|
|
402
|
+
/** Every workflow-specific action source this artifact owns. */
|
|
403
|
+
readonly additionalActions?: Additional;
|
|
404
|
+
readonly generated: {
|
|
405
|
+
/** Generator path relative to the repository root. */
|
|
406
|
+
readonly source: string;
|
|
407
|
+
/** Exact command that regenerates the emitted workflow. */
|
|
408
|
+
readonly regenerate: string;
|
|
409
|
+
};
|
|
410
|
+
readonly setup?: FactoryWorkflowSetupOptions;
|
|
411
|
+
}
|
|
412
|
+
type FamilyActions = Omit<NodePnpmActionFamily, "id">;
|
|
413
|
+
interface FactoryWorkflowArtifact<Additional extends Readonly<Record<string, PinnedAction>>> {
|
|
414
|
+
readonly actionFamilyId: string;
|
|
415
|
+
readonly actions: Readonly<FamilyActions & Additional>;
|
|
416
|
+
/** Checkout → pnpm → Node → install, customized by named role. */
|
|
417
|
+
readonly setupSteps: readonly WorkflowStep[];
|
|
418
|
+
/**
|
|
419
|
+
* The same steps as `setupSteps`, keyed by stable role instead of position.
|
|
420
|
+
* A consumer that needs a subset or a differently-ordered composition (for
|
|
421
|
+
* example, a custom checkout followed by the shared install steps) selects
|
|
422
|
+
* by role here and never destructures `setupSteps` by array shape.
|
|
423
|
+
*/
|
|
424
|
+
readonly setupStepsByRole: Readonly<Record<SetupStepRole, WorkflowStep>>;
|
|
425
|
+
/**
|
|
426
|
+
* Structurally accepted by gagen's `writeOrLint`; this package deliberately
|
|
427
|
+
* has no gagen dependency.
|
|
428
|
+
*/
|
|
429
|
+
readonly writeOptions: {
|
|
430
|
+
readonly header: string;
|
|
431
|
+
readonly pinDeps: false;
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Select setup steps by stable role, in the order the roles are given.
|
|
436
|
+
*
|
|
437
|
+
* This is the supported alternative to destructuring `setupSteps` by array
|
|
438
|
+
* position or asserting its length: a caller names exactly the roles it
|
|
439
|
+
* needs (for example, every role but `checkout`, to follow its own
|
|
440
|
+
* head-pinned checkout with the shared pnpm/Node/install sequence), and that
|
|
441
|
+
* selection survives a renamed step or an added role.
|
|
442
|
+
*/
|
|
443
|
+
export declare const setupStepsForRoles: (artifact: {
|
|
444
|
+
readonly setupStepsByRole: Readonly<Record<SetupStepRole, WorkflowStep>>;
|
|
445
|
+
}, roles: readonly SetupStepRole[]) => readonly WorkflowStep[];
|
|
446
|
+
/**
|
|
447
|
+
* Own one generated workflow source's action pins, setup block, provenance
|
|
448
|
+
* banner, and gagen pinning policy as a single artifact.
|
|
449
|
+
*
|
|
450
|
+
* The caller still owns workflow topology, jobs, runners, permissions, and
|
|
451
|
+
* every deployment policy decision.
|
|
452
|
+
*/
|
|
453
|
+
export declare const factoryWorkflow: <const Additional extends Readonly<Record<string, PinnedAction>> = Record<never, never>>(options: FactoryWorkflowOptions<Additional>) => FactoryWorkflowArtifact<Additional>;
|
|
454
|
+
/**
|
|
455
|
+
* Pinned Cursor OIDC trust predicates for the Factory App broker (#949).
|
|
456
|
+
*
|
|
457
|
+
* The broker verifies a Cursor-managed Cloud Agent JWT and mints a
|
|
458
|
+
* repo-scoped Factory App installation token. Audience, issuer, and JWKS are
|
|
459
|
+
* not consumer settings: a knob that pointed them elsewhere would be the
|
|
460
|
+
* whole mechanism undone, the same reason {@link FACTORY_PROOF_GATE_APP_ID}
|
|
461
|
+
* is pinned.
|
|
462
|
+
*/
|
|
463
|
+
/** Cursor's OIDC issuer. Tokens minted on the agent VM carry this `iss`. */
|
|
464
|
+
export declare const FACTORY_CURSOR_OIDC_ISSUER = "https://api.cursor.com";
|
|
465
|
+
/** JWKS the broker uses to verify RS256 signatures. */
|
|
466
|
+
export declare const FACTORY_CURSOR_OIDC_JWKS_URL = "https://api.cursor.com/keys";
|
|
467
|
+
/**
|
|
468
|
+
* Audience a Cursor-managed VM must mint with. The CLI and the broker share
|
|
469
|
+
* this string; Cursor does not allowlist audiences.
|
|
470
|
+
*/
|
|
471
|
+
export declare const FACTORY_CURSOR_OIDC_AUDIENCE = "Factory";
|
|
472
|
+
/**
|
|
473
|
+
* Runtime claim a Cursor-managed Cloud Agent VM always presents. Self-hosted
|
|
474
|
+
* workers are not this broker's callers.
|
|
475
|
+
*/
|
|
476
|
+
export declare const FACTORY_CURSOR_OIDC_MANAGED_RUNTIME = "managed";
|
|
477
|
+
/** HQ route that exchanges a verified Cursor OIDC JWT for an App token. */
|
|
478
|
+
export declare const FACTORY_APP_BROKER_PATH = "/api/factory-app/installation-token";
|
|
479
|
+
/** Production broker origin. The CLI pins this; it is not profile-declared. */
|
|
480
|
+
export declare const FACTORY_APP_BROKER_ORIGIN = "https://hq.patronage.com";
|
|
481
|
+
/**
|
|
482
|
+
* Bounded transport retries could not reach the GitHub App endpoint (#923).
|
|
483
|
+
* The reason is credential-free, so it is safe to log. Re-exported from
|
|
484
|
+
* `github-app-token.ts`, which owns the mint surface.
|
|
485
|
+
*/
|
|
486
|
+
export declare class GitHubAppTokenTransportError extends Error {
|
|
487
|
+
/** How many transport attempts were made before giving up. */
|
|
488
|
+
readonly attempts: number;
|
|
489
|
+
/** The last transient HTTP status, when the server answered at all. */
|
|
490
|
+
readonly status?: number;
|
|
491
|
+
constructor(reason: string, attempts: number, status?: number);
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* What a consumer must know to mint: the app id, where the private key is, and
|
|
495
|
+
* — when it has been recorded — which installation to mint against.
|
|
496
|
+
*
|
|
497
|
+
* `installationId` is optional because the installation is discoverable from
|
|
498
|
+
* the repository. When it is set, the mint still looks it up to confirm its
|
|
499
|
+
* account owns the repository. `privateKeyPath` is a path rather than key
|
|
500
|
+
* material so no consumer has to hold a secret in memory to call this, and so
|
|
501
|
+
* the key-path convention stays the consumer's.
|
|
502
|
+
*/
|
|
503
|
+
interface GithubAppCredentials {
|
|
504
|
+
appId: number | string;
|
|
505
|
+
installationId?: number;
|
|
506
|
+
privateKeyPath: string;
|
|
507
|
+
}
|
|
508
|
+
/** Carries the HTTP status so a caller can tell a retryable failure apart. */
|
|
509
|
+
export declare class GitHubApiError extends Error {
|
|
510
|
+
readonly status: number;
|
|
511
|
+
constructor(status: number, statusText: string);
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Installation-token permission subset. GitHub only grants permissions the
|
|
515
|
+
* App already has; a caller that wants least privilege names the subset here
|
|
516
|
+
* rather than taking the App's full installation grant (#949).
|
|
517
|
+
*/
|
|
518
|
+
interface GithubAppInstallationPermissions {
|
|
519
|
+
checks?: "read" | "write";
|
|
520
|
+
}
|
|
521
|
+
/** The Factory App broker's token: repo-scoped Checks write, nothing else. */
|
|
522
|
+
export declare const FACTORY_APP_BROKER_TOKEN_PERMISSIONS: {
|
|
523
|
+
readonly checks: "write";
|
|
524
|
+
};
|
|
525
|
+
interface GithubAppTokenOptions {
|
|
526
|
+
/** Injectable `fetch` (tests, or a caller with its own instrumented one). */
|
|
527
|
+
fetch?: typeof fetch;
|
|
528
|
+
/** Wall clock in milliseconds; only the JWT's validity window uses it. */
|
|
529
|
+
now?: () => number;
|
|
530
|
+
/** Injectable key read, so a caller can hold the PEM itself if it must. */
|
|
531
|
+
readPrivateKey?: (privateKeyPath: string) => Buffer | string;
|
|
532
|
+
/** Per-request timeout; defaults to five seconds. */
|
|
533
|
+
timeoutMs?: number;
|
|
534
|
+
/**
|
|
535
|
+
* Total transport attempts per request, the first one included. Defaults to
|
|
536
|
+
* three: a mint that must survive a stale keep-alive socket (#923). A caller
|
|
537
|
+
* whose mint is best-effort and already has a fallback passes 1, because
|
|
538
|
+
* retrying against a deliberately short timeout only delays that fallback
|
|
539
|
+
* (#938). The backoff between attempts is fixed and does not scale with
|
|
540
|
+
* `timeoutMs`; the two dials are unrelated.
|
|
541
|
+
*/
|
|
542
|
+
transportAttempts?: number;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* The signed app JWT GitHub accepts as `Authorization: Bearer` for the App
|
|
546
|
+
* endpoints. `iss` is stringified because GitHub accepts either spelling and a
|
|
547
|
+
* numeric app id must not depend on JSON's number formatting.
|
|
548
|
+
*
|
|
549
|
+
* The signature is produced from the key on disk and returned; the key
|
|
550
|
+
* material itself never leaves this call.
|
|
551
|
+
*/
|
|
552
|
+
export declare const githubAppJwt: (credentials: GithubAppCredentials, options?: Pick<GithubAppTokenOptions, "now" | "readPrivateKey">) => string;
|
|
553
|
+
/**
|
|
554
|
+
* Mint an installation access token for one repository.
|
|
555
|
+
*
|
|
556
|
+
* When the credentials omit `installationId`, the installation is discovered
|
|
557
|
+
* from the repository first — the same call every consumer had written for
|
|
558
|
+
* itself. A pinned `installationId` is looked up instead, and the mint is
|
|
559
|
+
* refused unless that installation's account is the repository owner (GitHub
|
|
560
|
+
* logins compare case-insensitively): a `repositories` restriction names
|
|
561
|
+
* repositories without an owner, so a pin for one account must not mint for
|
|
562
|
+
* a same-named repository under another (#1428). Nothing is cached: the token
|
|
563
|
+
* is returned to the caller and this module keeps no copy.
|
|
564
|
+
*/
|
|
565
|
+
export declare const mintInstallationToken: (input: {
|
|
566
|
+
credentials: GithubAppCredentials;
|
|
567
|
+
owner: string;
|
|
568
|
+
/**
|
|
569
|
+
* Installation permission subset. Omitted, GitHub grants the App's full
|
|
570
|
+
* installation permissions. The Factory App broker passes
|
|
571
|
+
* {@link FACTORY_APP_BROKER_TOKEN_PERMISSIONS}.
|
|
572
|
+
*/
|
|
573
|
+
permissions?: GithubAppInstallationPermissions;
|
|
574
|
+
/**
|
|
575
|
+
* Repository names (not `owner/repo`) to bind the token to. Omitted, the
|
|
576
|
+
* token covers every repository the installation can reach. The broker
|
|
577
|
+
* always names the one repository the Cursor OIDC claim authenticated.
|
|
578
|
+
*/
|
|
579
|
+
repositories?: readonly string[];
|
|
580
|
+
repo: string;
|
|
581
|
+
}, options?: GithubAppTokenOptions) => Promise<string>;
|
|
582
|
+
/**
|
|
583
|
+
* The GitHub-side **proof-reuse gate** (ADR 0022, #309, #317).
|
|
584
|
+
*
|
|
585
|
+
* It answers one question, before checkout and before install: may this job
|
|
586
|
+
* reuse the local verification the factory already published for *this exact
|
|
587
|
+
* head*? On a pull request the head is the PR branch tip. On a push to the
|
|
588
|
+
* default branch, a **merge fallback** extends "this exact head" to "this
|
|
589
|
+
* exact tree": a merge whose tree is byte-identical to the producing pull
|
|
590
|
+
* request's proven head tree reuses that head's proof, but only when the proof
|
|
591
|
+
* is a whole-tree run that *executed* every command the surface requires
|
|
592
|
+
* (#1658). Impact-stamp releases and diff-scoped runs never count on a push,
|
|
593
|
+
* because a merge target is owed the whole tree (#931). Refusing runs hosted
|
|
594
|
+
* CI; it never fails the candidate.
|
|
595
|
+
*
|
|
596
|
+
* What a consumer chooses is only *what its guarded surface requires*: the
|
|
597
|
+
* plain profile command objects that surface selects. Everything else below is
|
|
598
|
+
* the same for every consumer and every surface.
|
|
599
|
+
*/
|
|
600
|
+
/**
|
|
601
|
+
* The check run the gate reads. Fixed: `patronage-factory/pr-verify` is also
|
|
602
|
+
* postable as a *commit status* by any token with write access, so only the
|
|
603
|
+
* Checks API is ever consulted and only under this exact name.
|
|
604
|
+
*/
|
|
605
|
+
export declare const FACTORY_PROOF_GATE_CHECK_NAME = "patronage-factory/pr-verify";
|
|
606
|
+
/**
|
|
607
|
+
* The Patronage Factory GitHub App, pinned (ADR 0022). A runner has no
|
|
608
|
+
* operator user config to read the producing App identity from, and the
|
|
609
|
+
* identity is a trust predicate, so it is not a repository variable a consumer
|
|
610
|
+
* can point somewhere else. Neither the id nor the slug is a secret: GitHub
|
|
611
|
+
* returns `app.id` on every check run it serves.
|
|
612
|
+
*/
|
|
613
|
+
export declare const FACTORY_PROOF_GATE_APP_ID = "4314840";
|
|
614
|
+
/** Step id the guard condition refers to. */
|
|
615
|
+
export declare const FACTORY_PROOF_GATE_STEP_ID = "factory-proof";
|
|
616
|
+
/**
|
|
617
|
+
* Human-visible name of the gate step as the Actions jobs API serves it. A
|
|
618
|
+
* read-only run analyzer (`psf ci:analyze`, #647) matches on this name to
|
|
619
|
+
* classify a run as proof-reuse versus full fallback, so it is exported from
|
|
620
|
+
* exactly the module that writes it — matching on a re-typed copy would drift.
|
|
621
|
+
*/
|
|
622
|
+
export declare const FACTORY_PROOF_GATE_STEP_NAME = "Check for factory proof of this head";
|
|
623
|
+
/**
|
|
624
|
+
* The shell the gate runs under, and it is a correctness requirement rather
|
|
625
|
+
* than a preference.
|
|
626
|
+
*
|
|
627
|
+
* GitHub's default for a `run:` step is `bash -e {0}`: **errexit comes from
|
|
628
|
+
* the invocation, not from the script**, and no `set +e` in the script body
|
|
629
|
+
* can be relied on to express the intent because the abort happens at the
|
|
630
|
+
* failing command. The whole fail-open design below — every path reaching one
|
|
631
|
+
* final `GITHUB_OUTPUT` write, no `set -e` — is void under that default. It
|
|
632
|
+
* was: the gate died at a `read` returning 1 at EOF, two seconds in, with no
|
|
633
|
+
* stdout, no verdict and no `reason`, so reuse collapsed to never *and* the
|
|
634
|
+
* signal built to reveal that could not fire (#319).
|
|
635
|
+
*
|
|
636
|
+
* A `shell:` value containing `{0}` is used verbatim by the runner, so this
|
|
637
|
+
* form supplies no `-e`. The shorthand `shell: bash` must never be used here:
|
|
638
|
+
* it expands to `bash --noprofile --norc -eo pipefail {0}`. `pipefail` is set
|
|
639
|
+
* by the script itself.
|
|
640
|
+
*
|
|
641
|
+
* The script is additionally written to survive errexit anyway. Both layers
|
|
642
|
+
* are deliberate: this one states the contract, that one means a runner which
|
|
643
|
+
* ignores it still gets a decision.
|
|
644
|
+
*/
|
|
645
|
+
export declare const FACTORY_PROOF_GATE_SHELL = "bash --noprofile --norc {0}";
|
|
646
|
+
/** Output the verdict is written to. `true` — and only `true` — skips. */
|
|
647
|
+
export declare const FACTORY_PROOF_GATE_OUTPUT = "reuse-proof";
|
|
648
|
+
/**
|
|
649
|
+
* Machine-readable refusal category. Fleet-status reads this: it is what makes
|
|
650
|
+
* a reuse-collapses-to-never regression visible instead of hidden behind
|
|
651
|
+
* fail-open, which by construction looks exactly like healthy full CI.
|
|
652
|
+
*/
|
|
653
|
+
export declare const FACTORY_PROOF_GATE_REASON_OUTPUT = "reason";
|
|
654
|
+
/**
|
|
655
|
+
* Recorded verification mode, when the gate could read one. Diagnostic
|
|
656
|
+
* metadata only — never an authorization condition (ADR 0022). A reduced-mode
|
|
657
|
+
* proof that executed every command the surface requires is reusable.
|
|
658
|
+
*/
|
|
659
|
+
export declare const FACTORY_PROOF_GATE_MODE_OUTPUT = "mode";
|
|
660
|
+
/** Exact Checks API URL of the proof generation selected by the gate. */
|
|
661
|
+
export declare const FACTORY_PROOF_GATE_SOURCE_URL_OUTPUT = "source-check-url";
|
|
662
|
+
/**
|
|
663
|
+
* The commit whose proof was reused, when the gate reused one. On a pull
|
|
664
|
+
* request it is the head itself; on a merge-target push it is the producing
|
|
665
|
+
* pull request's head, a different commit than the pushed one (#1658). Empty
|
|
666
|
+
* on every refusal.
|
|
667
|
+
*/
|
|
668
|
+
export declare const FACTORY_PROOF_GATE_SOURCE_HEAD_OUTPUT = "source-head";
|
|
669
|
+
/**
|
|
670
|
+
* Guard for every step the gate protects. Deliberately `!= 'true'` and not
|
|
671
|
+
* `== 'false'`: an unset, empty, or garbled output must run the suite.
|
|
672
|
+
*/
|
|
673
|
+
export declare const FACTORY_PROOF_GATE_GUARD = "steps.factory-proof.outputs.reuse-proof != 'true'";
|
|
674
|
+
/**
|
|
675
|
+
* Pull requests, plus pushes to the default branch (#611, #1658) — the gate's
|
|
676
|
+
* single condition.
|
|
677
|
+
*
|
|
678
|
+
* A merge target's guarantee is about the whole tree, not the diff. A squash
|
|
679
|
+
* merge mints a new commit, so no proof is ever written for the merged SHA;
|
|
680
|
+
* the push path exists only for the merge fallback, which reuses the
|
|
681
|
+
* producing pull request's head proof when the merge tree *is* that head's
|
|
682
|
+
* tree and the proof's whole-tree run executed every command the surface
|
|
683
|
+
* requires.
|
|
684
|
+
*
|
|
685
|
+
* #931 is why both conditions are load-bearing. A `main` push once reused an
|
|
686
|
+
* impact-scoped candidate proof, executed no command for an untouched
|
|
687
|
+
* package, and left that package red for three days. An impact-scoped proof
|
|
688
|
+
* is a sound gate for the candidate and an unsound one for the merge target,
|
|
689
|
+
* so a push credits no `notRequiredCommands` release. The same holds for a
|
|
690
|
+
* command that ran but scoped itself to the diff through the run context
|
|
691
|
+
* (`psf affected`): only a proof recording `runScope: "whole-tree"` counts.
|
|
692
|
+
* Anything else runs the full battery.
|
|
693
|
+
*
|
|
694
|
+
* The push side is deliberately the default branch only. Which branches
|
|
695
|
+
* trigger a workflow at all stays repository-owned; this condition only keeps
|
|
696
|
+
* the gate from consulting proof on pushes that are not merges into the
|
|
697
|
+
* default branch.
|
|
698
|
+
*/
|
|
699
|
+
export declare const FACTORY_PROOF_GATE_IF = "github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch))";
|
|
700
|
+
/**
|
|
701
|
+
* The complete refusal vocabulary: the only distinctions the gate can make
|
|
702
|
+
* from its Checks API reads.
|
|
703
|
+
*
|
|
704
|
+
* - `proven` a covering, passing, unambiguous proof for this exact head
|
|
705
|
+
* - `none` no App-verified factory check run at this commit
|
|
706
|
+
* - `pending` the newest generation had not completed when this job read it
|
|
707
|
+
* - `failed` the newest generation records no pass
|
|
708
|
+
* - `unreadable` it passed but carries no binding for this repository and head
|
|
709
|
+
* - `incomplete` its executed plus stamp-authorized released commands do not
|
|
710
|
+
* cover every required command
|
|
711
|
+
* - `ambiguous` two different generations share the newest instant, the
|
|
712
|
+
* newest repeats another run's verdict with no proof time to
|
|
713
|
+
* tell them apart, a run's start time cannot be ranked, the
|
|
714
|
+
* newest pass records no verification start beside another run
|
|
715
|
+
* at this head (#1514), or the newest pass started before
|
|
716
|
+
* another run at this head was posted
|
|
717
|
+
* - `error` the gate could not reach a decision (fail open)
|
|
718
|
+
*/
|
|
719
|
+
export declare const FACTORY_PROOF_GATE_REASONS: readonly ["proven", "none", "pending", "failed", "unreadable", "incomplete", "ambiguous", "error"];
|
|
720
|
+
type FactoryProofGateReason = (typeof FACTORY_PROOF_GATE_REASONS)[number];
|
|
721
|
+
/**
|
|
722
|
+
* One entry of a consumer's `verification.commands` (ADR 0021). Only the two
|
|
723
|
+
* load-bearing fields are declared: `name` is the command *identity* the proof
|
|
724
|
+
* records in `executedCommands`, `command` is the string the static coverage
|
|
725
|
+
* assertion matches against the work a reused proof would skip.
|
|
726
|
+
*/
|
|
727
|
+
interface ProofReuseCommand {
|
|
728
|
+
readonly command: string;
|
|
729
|
+
readonly name: string;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* The command identities a guarded surface requires, derived from the profile
|
|
733
|
+
* command objects that surface selected. This is the single derivation: the
|
|
734
|
+
* gate script and the static coverage assertion both go through it, so a
|
|
735
|
+
* consumer can never have one notion of "required" at generation time and
|
|
736
|
+
* another at assertion time.
|
|
737
|
+
*
|
|
738
|
+
* `undefined` means the selection is unusable — not an array, empty, or
|
|
739
|
+
* carrying an entry whose `command` is blank or whose `name` is not a plain
|
|
740
|
+
* command identity, or carrying duplicate names. A name is the executable
|
|
741
|
+
* authorization identity recorded in proof, so two commands may never collapse
|
|
742
|
+
* behind one. An empty required set would make *every* passing proof trivially
|
|
743
|
+
* covering, so it is never silently treated as "requires nothing"; callers
|
|
744
|
+
* must refuse instead.
|
|
745
|
+
*/
|
|
746
|
+
export declare const proofReuseRequiredCommands: (commands: readonly ProofReuseCommand[]) => readonly string[] | undefined;
|
|
747
|
+
/**
|
|
748
|
+
* Resolve command identities to their `ProofReuseCommand` objects (ADR 0021).
|
|
749
|
+
* Which names a surface requires is the consumer's choice; this is only the
|
|
750
|
+
* lookup. A name with no catalog entry throws at generation time, because a
|
|
751
|
+
* required set that quietly loses an entry makes any passing proof covering.
|
|
752
|
+
* The message says "the profile's command catalog" rather than a file name,
|
|
753
|
+
* since not every consumer's catalog is `software-factory.profile.json`.
|
|
754
|
+
*/
|
|
755
|
+
export declare const resolveProofReuseCommands: (catalog: readonly ProofReuseCommand[], names: readonly string[], selectionLabel?: string) => readonly ProofReuseCommand[];
|
|
756
|
+
interface FactoryProofGateOptions {
|
|
757
|
+
/**
|
|
758
|
+
* The profile command objects this guarded surface selected. A consumer with
|
|
759
|
+
* distinct core and docs jobs selects distinct sets, and each job's gate
|
|
760
|
+
* therefore requires a different coverage.
|
|
761
|
+
*/
|
|
762
|
+
readonly commands: readonly ProofReuseCommand[];
|
|
763
|
+
/** Names the suite in the job summary. Changes no trust decision. */
|
|
764
|
+
readonly surface: string;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* The gate script. Exported so it can be executed directly under test against
|
|
768
|
+
* a stubbed `gh`, rather than only asserted against as workflow text — the
|
|
769
|
+
* script is the security boundary, and asserting on generated YAML would leave
|
|
770
|
+
* its actual decisions untested.
|
|
771
|
+
*
|
|
772
|
+
* Note the deliberate absence of `set -e`: every failure path has to reach the
|
|
773
|
+
* final write, and that write must emit `false`. Omitting it is necessary but
|
|
774
|
+
* not sufficient — the runner supplies `-e` unless the step declares
|
|
775
|
+
* `FACTORY_PROOF_GATE_SHELL` — so the script is also written to reach that
|
|
776
|
+
* write under errexit, and the tests execute it both ways.
|
|
777
|
+
*/
|
|
778
|
+
export declare const factoryProofGateScript: ({ commands, surface }: FactoryProofGateOptions) => string;
|
|
779
|
+
interface FactoryProofGateStep {
|
|
780
|
+
readonly continueOnError: true;
|
|
781
|
+
readonly env: Readonly<{
|
|
782
|
+
GH_TOKEN: string;
|
|
783
|
+
HEAD_SHA: string;
|
|
784
|
+
}>;
|
|
785
|
+
readonly id: typeof FACTORY_PROOF_GATE_STEP_ID;
|
|
786
|
+
readonly if: typeof FACTORY_PROOF_GATE_IF;
|
|
787
|
+
readonly name: string;
|
|
788
|
+
readonly run: string;
|
|
789
|
+
readonly shell: typeof FACTORY_PROOF_GATE_SHELL;
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* The step itself, structurally accepted by gagen's `step()` without adding a
|
|
793
|
+
* gagen runtime dependency. It belongs first in the job it guards: a few API
|
|
794
|
+
* reads with the default `GITHUB_TOKEN`, no checkout, no install, so a proven
|
|
795
|
+
* head costs a runner nothing beyond job startup. A pull request read needs
|
|
796
|
+
* only `checks: read`. The merge fallback on a default-branch push also reads
|
|
797
|
+
* the producing pull request (`pull-requests: read`) and the two commit
|
|
798
|
+
* objects whose tree ids it compares (`contents: read`). A job that grants
|
|
799
|
+
* less loses only the fallback: the failed read degrades to the full suite.
|
|
800
|
+
*
|
|
801
|
+
* A **step, not a job**, and that is not a style preference. A separate gate
|
|
802
|
+
* job that errored would leave the guarded job `skipped`, and a summary job
|
|
803
|
+
* that only fails on `failure`/`cancelled` would still report green — a Checks
|
|
804
|
+
* API outage would silently skip verification. As a step it fails open by
|
|
805
|
+
* construction: the step errors, the output is never written, the guard reads
|
|
806
|
+
* empty, and every command runs.
|
|
807
|
+
*/
|
|
808
|
+
export declare const factoryProofGateStep: (options: FactoryProofGateOptions) => FactoryProofGateStep;
|
|
809
|
+
interface ProofReuseCoverageInput {
|
|
810
|
+
/** The same selection handed to the gate for this surface. */
|
|
811
|
+
readonly commands: readonly ProofReuseCommand[];
|
|
812
|
+
/**
|
|
813
|
+
* The command strings the consumer's workflow would skip when the gate says
|
|
814
|
+
* `true`, already resolved to the leaves that actually run. Extracting them
|
|
815
|
+
* is the consumer's job: this package never parses workflow source, because
|
|
816
|
+
* doing so is what killed #288.
|
|
817
|
+
*/
|
|
818
|
+
readonly skipped: readonly string[];
|
|
819
|
+
/** Names the surface in the failure message. */
|
|
820
|
+
readonly surface?: string;
|
|
821
|
+
}
|
|
822
|
+
interface ProofReuseCoverageReport {
|
|
823
|
+
/** True only when the selection is usable *and* nothing is uncovered. */
|
|
824
|
+
readonly covered: boolean;
|
|
825
|
+
/** Command identities derived from the selection; empty when unusable. */
|
|
826
|
+
readonly requiredCommands: readonly string[];
|
|
827
|
+
/** Skipped command strings no selected profile command accounts for. */
|
|
828
|
+
readonly uncovered: readonly string[];
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* The static coverage assertion, as a report.
|
|
832
|
+
*
|
|
833
|
+
* Runtime command coverage is authoritative — the gate's `incomplete` refusal
|
|
834
|
+
* is the backstop that cannot be bypassed. This is the compile-time guard in
|
|
835
|
+
* front of it: it fails a consumer's build the moment a workflow skips work
|
|
836
|
+
* that no selected profile command runs, rather than letting the drift show up
|
|
837
|
+
* as CI quietly verifying nothing. The drift is real history: #227 wired a
|
|
838
|
+
* workspace member into CI while the profile never learned about it.
|
|
839
|
+
*/
|
|
840
|
+
export declare const proofReuseCoverage: ({ commands, skipped }: ProofReuseCoverageInput) => ProofReuseCoverageReport;
|
|
841
|
+
/** `proofReuseCoverage`, as a build failure. */
|
|
842
|
+
export declare const assertProofReuseCoverage: (input: ProofReuseCoverageInput) => ProofReuseCoverageReport;
|
|
843
|
+
/** Generic timing and presentation steps around the proof-reuse gate (#652). */
|
|
844
|
+
declare const FACTORY_PROOF_TIMING_STEP_ID = "ci-timing";
|
|
845
|
+
declare const FACTORY_PROOF_TIMING_START_STEP_NAME = "Start CI timing";
|
|
846
|
+
declare const FACTORY_PROOF_TIMING_SUMMARY_STEP_NAME = "Record proof-reuse timing";
|
|
847
|
+
interface FactoryProofReusePresentationOptions {
|
|
848
|
+
/** Human-readable name of the guarded suite. */
|
|
849
|
+
readonly surface: string;
|
|
850
|
+
}
|
|
851
|
+
interface FactoryProofTimingStartStep {
|
|
852
|
+
readonly continueOnError: true;
|
|
853
|
+
readonly id: typeof FACTORY_PROOF_TIMING_STEP_ID;
|
|
854
|
+
readonly name: typeof FACTORY_PROOF_TIMING_START_STEP_NAME;
|
|
855
|
+
readonly run: string;
|
|
856
|
+
}
|
|
857
|
+
export declare const factoryProofTimingStartStep: () => FactoryProofTimingStartStep;
|
|
858
|
+
interface FactoryProofReuseSummaryStep {
|
|
859
|
+
readonly continueOnError: true;
|
|
860
|
+
readonly env: Readonly<Record<string, string>>;
|
|
861
|
+
readonly if: "always()";
|
|
862
|
+
readonly name: typeof FACTORY_PROOF_TIMING_SUMMARY_STEP_NAME;
|
|
863
|
+
readonly run: string;
|
|
864
|
+
}
|
|
865
|
+
export declare const factoryProofReuseSummaryStep: (options: FactoryProofReusePresentationOptions) => FactoryProofReuseSummaryStep;
|
|
866
|
+
export declare const FACTORY_CANDIDATE_IMPACT_STEP_ID = "candidate_impact";
|
|
867
|
+
export declare const FACTORY_CANDIDATE_IMPACT_DECISION_OUTPUT = "decision";
|
|
868
|
+
export declare const FACTORY_CANDIDATE_IMPACT_BASIS_OUTPUT = "basis";
|
|
869
|
+
export declare const FACTORY_CANDIDATE_IMPACT_INERT_OUTPUT = "inert_paths";
|
|
870
|
+
export declare const FACTORY_CANDIDATE_IMPACT_UNSUBSCRIBED_OUTPUT = "unsubscribed_paths";
|
|
871
|
+
interface FactoryCandidateImpactWorkflowOptions {
|
|
872
|
+
readonly base?: string;
|
|
873
|
+
readonly cli?: string;
|
|
874
|
+
readonly head?: string;
|
|
875
|
+
readonly profilePath?: string;
|
|
876
|
+
readonly targets: readonly string[];
|
|
877
|
+
}
|
|
878
|
+
interface FactoryCandidateImpactWorkflow {
|
|
879
|
+
/** Outputs for a caller-owned decision job that subsequent jobs may consume. */
|
|
880
|
+
readonly decisionJobOutputs: Readonly<Record<string, string>>;
|
|
881
|
+
readonly decisionStep: WorkflowStep;
|
|
882
|
+
/**
|
|
883
|
+
* A fail-open cross-job condition: only an explicit usable withdrawal skips
|
|
884
|
+
* work. The decision job id is required.
|
|
885
|
+
*/
|
|
886
|
+
readonly demandedIf: (targetName: string, decisionJob: string) => string;
|
|
887
|
+
/** The same fail-open condition for a step in the decision job. */
|
|
888
|
+
readonly demandedIfAtStep: (targetName: string) => string;
|
|
889
|
+
readonly targetOutputs: Readonly<Record<string, string>>;
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Generate the factory-owned candidate routing seam for a consumer
|
|
893
|
+
* pull-request workflow (#741). The decision step calls
|
|
894
|
+
* `psf candidate:impact` with the pull request's exact base/head commits, so
|
|
895
|
+
* the canonical profile impact declarations and dependency graph route the
|
|
896
|
+
* run — never a second path matcher. Consumers retain jobs, surface names,
|
|
897
|
+
* runners, commands, and credentials; this artifact supplies only the
|
|
898
|
+
* decision step and per-target withdrawal conditions. Target output keys are
|
|
899
|
+
* the same stable contract the production decision seam writes.
|
|
900
|
+
*
|
|
901
|
+
* The decision checkout must have the exact head commit checked out and the
|
|
902
|
+
* base commit reachable (`fetchDepth: 0`, `ref` = the head SHA); anything
|
|
903
|
+
* else refuses withdrawal and keeps every target demanded.
|
|
904
|
+
*/
|
|
905
|
+
export declare const factoryCandidateImpactWorkflow: (options: FactoryCandidateImpactWorkflowOptions) => FactoryCandidateImpactWorkflow;
|
|
906
|
+
export declare const FACTORY_LIFECYCLE_CONTRACT_JOB_ID = "factory-contracts";
|
|
907
|
+
export declare const FACTORY_LIFECYCLE_CONTRACT_JOB_NAME = "Factory / Alchemy Contracts";
|
|
908
|
+
interface FactoryLifecycleContractLaneOptions {
|
|
909
|
+
readonly command: string;
|
|
910
|
+
readonly jobId?: string;
|
|
911
|
+
readonly jobName?: string;
|
|
912
|
+
}
|
|
913
|
+
interface FactoryLifecycleContractLane {
|
|
914
|
+
readonly jobId: string;
|
|
915
|
+
readonly jobName: string;
|
|
916
|
+
readonly steps: readonly WorkflowStep[];
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Generate the factory-owned non-credentialed lifecycle-contract lane
|
|
920
|
+
* (#765). Consumers declare the package-script command in
|
|
921
|
+
* `software-factory.profile.json`; this helper never loads that profile.
|
|
922
|
+
* Callers pass the parsed declaration (or omit it) and include or skip the
|
|
923
|
+
* returned job. Setup, runners, topology, and credentials stay with the
|
|
924
|
+
* caller — and this lane must never receive credentials.
|
|
925
|
+
*
|
|
926
|
+
* The generated steps run only the declared package script and write an
|
|
927
|
+
* always() evidence summary of what the lane proves and does not prove.
|
|
928
|
+
* The command must be a package-script invocation: `run <script>`, or a
|
|
929
|
+
* shorthand whose script name contains `:` (`pnpm test:factory`). Optional
|
|
930
|
+
* pnpm `--filter <pkg>` may precede either form. Shell operators, credential
|
|
931
|
+
* env, extra flags, and direct Vitest are refused.
|
|
932
|
+
*/
|
|
933
|
+
export declare const factoryLifecycleContractLane: (declaration?: FactoryLifecycleContractLaneOptions) => FactoryLifecycleContractLane | undefined;
|
|
934
|
+
/**
|
|
935
|
+
* The merge-freeze writer job (#356, ADR 0016; #429 for the
|
|
936
|
+
* merge-target namespace; #872 for this package).
|
|
937
|
+
*
|
|
938
|
+
* A consumer's generated merge-target-push Verify workflow is the ONLY
|
|
939
|
+
* producer of `patronage-factory/merge-freeze` generations: a red
|
|
940
|
+
* push-triggered Verify completes a generation active, a green one completes
|
|
941
|
+
* it inactive, and no command, scheduled job, or second workflow writes this
|
|
942
|
+
* check run. The operator override (`demand:waive --demand merge-freeze`)
|
|
943
|
+
* waives the demand for one candidate during a fix-forward; it never writes
|
|
944
|
+
* here.
|
|
945
|
+
*
|
|
946
|
+
* The write mirrors what the factory package's merge-freeze reader parses:
|
|
947
|
+
* create the run `in_progress` with no `started_at` (GitHub stamps the
|
|
948
|
+
* generation clock — the ordering rule itself is owned by the reader), then
|
|
949
|
+
* PATCH it completed with the reader-shaped state payload in `output.text`.
|
|
950
|
+
* The consumer's workflow test executes this exact script against a stubbed
|
|
951
|
+
* `gh` and parses the emitted payload with `validateMergeFreezeState`, so
|
|
952
|
+
* writer and reader cannot drift silently.
|
|
953
|
+
*
|
|
954
|
+
* Those two API calls are what the reader's two settling phases observe
|
|
955
|
+
* (#890). Before the POST the merge target carries no generation at all, which
|
|
956
|
+
* a reader reports as `awaiting-generation` while the pushed hosted verify run
|
|
957
|
+
* is still pending. Between the POST and the PATCH the generation exists with
|
|
958
|
+
* no `output.text`, which a reader reports as `running-generation`. Only the
|
|
959
|
+
* PATCH writes a verdict, so neither phase is one.
|
|
960
|
+
*
|
|
961
|
+
* Failure posture is deliberately fail-closed and the opposite of the
|
|
962
|
+
* proof-reuse gate's fail-open shell: this step runs under the runner's
|
|
963
|
+
* default `bash -e {0}`, so any API refusal aborts the step, the generation
|
|
964
|
+
* stays absent or `in_progress`, and every `pr:ready` arming-time read of
|
|
965
|
+
* that tip (#477) refuses until a later push writes a green generation.
|
|
966
|
+
*
|
|
967
|
+
* **Ownership line.** This package owns the check name, the App identity, the
|
|
968
|
+
* `create-github-app-token` inputs, the result fold, the merge-target `if`,
|
|
969
|
+
* and the job's `permissions`. The caller owns the runner, the `needs` list
|
|
970
|
+
* of every authoritative verification leaf, the timeout, and any extra env.
|
|
971
|
+
*/
|
|
972
|
+
/** The one check-run name every merge-freeze reader pins. */
|
|
973
|
+
export declare const FACTORY_MERGE_FREEZE_CHECK_NAME = "patronage-factory/merge-freeze";
|
|
974
|
+
export declare const FACTORY_MERGE_FREEZE_JOB_ID = "freeze";
|
|
975
|
+
export declare const FACTORY_MERGE_FREEZE_JOB_NAME = "Report the merge freeze";
|
|
976
|
+
/** Step id the token step exposes its installation token under. */
|
|
977
|
+
export declare const FACTORY_MERGE_FREEZE_APP_TOKEN_STEP_ID = "factory-app-token";
|
|
978
|
+
/**
|
|
979
|
+
* The GitHub Actions expression that folds the needed jobs' results into the
|
|
980
|
+
* one word the script branches on. It mirrors the `verify` summary job's
|
|
981
|
+
* failure condition exactly: any failed or cancelled needed job is a red
|
|
982
|
+
* merge target.
|
|
983
|
+
*/
|
|
984
|
+
export declare const FACTORY_MERGE_FREEZE_VERIFY_RESULT_EXPRESSION = "${{ (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) && 'failure' || 'success' }}";
|
|
985
|
+
/**
|
|
986
|
+
* The literal factory merge-target namespace, as a `github.ref` predicate
|
|
987
|
+
* (#429).
|
|
988
|
+
*
|
|
989
|
+
* `main` plus the repository-owned `epic/**` integration branches, and
|
|
990
|
+
* nothing else. Deliberately literal rather than profile-declared: one
|
|
991
|
+
* implementation per contract, no configuration machinery for a two-element
|
|
992
|
+
* namespace whose second element is a namespace prefix the repository itself
|
|
993
|
+
* owns. `epic/` needs the trailing slash — `startsWith` would otherwise admit
|
|
994
|
+
* `epicness/…`, which is not a merge target.
|
|
995
|
+
*
|
|
996
|
+
* A caller's `push` trigger branch list names the same namespace. That list
|
|
997
|
+
* decides which events produce a run at all; this predicate decides which of
|
|
998
|
+
* those runs may write a generation.
|
|
999
|
+
*/
|
|
1000
|
+
export declare const FACTORY_MERGE_TARGET_REF_CONDITION: string;
|
|
1001
|
+
/**
|
|
1002
|
+
* `always()` is load-bearing: the red path is the whole point, so the job must
|
|
1003
|
+
* run when a needed verification job failed. `github.event_name == 'push'` is
|
|
1004
|
+
* load-bearing twice over: a `pull_request` run must never write a generation
|
|
1005
|
+
* (its `github.sha` is a synthetic merge commit that no base tip is ever read
|
|
1006
|
+
* at), and a `pull_request` trigger with an `epic/**` base list would
|
|
1007
|
+
* otherwise reach this job.
|
|
1008
|
+
*/
|
|
1009
|
+
export declare const FACTORY_MERGE_FREEZE_IF: string;
|
|
1010
|
+
/**
|
|
1011
|
+
* Least privilege for the writer job: no `GITHUB_TOKEN` scope at all.
|
|
1012
|
+
*
|
|
1013
|
+
* Both Checks API calls run under the App installation token minted in the
|
|
1014
|
+
* first step (`GH_TOKEN: steps.factory-app-token.outputs.token`), and the job
|
|
1015
|
+
* never checks out the repository. So the job uses no `GITHUB_TOKEN` scope,
|
|
1016
|
+
* and an empty block is the honest declaration. A `checks: write` here would
|
|
1017
|
+
* hand every adopter an unused write scope (#884).
|
|
1018
|
+
*/
|
|
1019
|
+
export declare const FACTORY_MERGE_FREEZE_PERMISSIONS: Readonly<{}>;
|
|
1020
|
+
/**
|
|
1021
|
+
* The script the freeze step runs. Environment contract:
|
|
1022
|
+
* - `GH_TOKEN`: an installation token for the pinned Patronage Factory App —
|
|
1023
|
+
* the check run must carry that App's identity or every reader rejects it.
|
|
1024
|
+
* - `VERIFY_RESULT`: `success` or `failure` (see the fold expression above).
|
|
1025
|
+
* - `VERIFY_JOBS`: JSON `needs` context; only job results are retained.
|
|
1026
|
+
* - `GITHUB_SHA` / `GITHUB_REPOSITORY` / `GITHUB_SERVER_URL` /
|
|
1027
|
+
* `GITHUB_RUN_ID` / `GITHUB_RUN_ATTEMPT` / `GITHUB_REF_NAME`: runner-provided.
|
|
1028
|
+
*
|
|
1029
|
+
* `GITHUB_REF_NAME` is the merge target this run pushed to — `main` or an
|
|
1030
|
+
* `epic/**` integration branch (#429). The job is gated to `push` events on
|
|
1031
|
+
* exactly those refs, so the branch name is always the short name of a
|
|
1032
|
+
* repository-owned merge target and never a pull-request merge ref. It
|
|
1033
|
+
* appears in recovery guidance because a reader of an epic-targeting
|
|
1034
|
+
* candidate must be told which branch owns the generation. A later green
|
|
1035
|
+
* generation on that branch's current tip clears it, including a rerun.
|
|
1036
|
+
*/
|
|
1037
|
+
export declare const factoryMergeFreezeScript: () => string;
|
|
1038
|
+
interface FactoryMergeFreezeJobOptions<TNeed> {
|
|
1039
|
+
/** The pinned `actions/create-github-app-token` the caller declared. */
|
|
1040
|
+
readonly createGithubAppToken: PinnedAction;
|
|
1041
|
+
/**
|
|
1042
|
+
* Every authoritative verification leaf this generation folds. The elements
|
|
1043
|
+
* are whatever the caller's workflow generator uses for `needs:`; they are
|
|
1044
|
+
* returned unchanged.
|
|
1045
|
+
*/
|
|
1046
|
+
readonly needs: readonly TNeed[];
|
|
1047
|
+
/**
|
|
1048
|
+
* Override the result fold. Defaults to
|
|
1049
|
+
* `FACTORY_MERGE_FREEZE_VERIFY_RESULT_EXPRESSION`, which is what a caller
|
|
1050
|
+
* whose summary job folds `needs.*.result` wants. Supply one only when the
|
|
1051
|
+
* caller's red condition is genuinely different.
|
|
1052
|
+
*/
|
|
1053
|
+
readonly verifyResultExpression?: string;
|
|
1054
|
+
}
|
|
1055
|
+
interface FactoryMergeFreezeJob<TNeed> {
|
|
1056
|
+
readonly if: typeof FACTORY_MERGE_FREEZE_IF;
|
|
1057
|
+
readonly jobId: typeof FACTORY_MERGE_FREEZE_JOB_ID;
|
|
1058
|
+
readonly jobName: typeof FACTORY_MERGE_FREEZE_JOB_NAME;
|
|
1059
|
+
readonly needs: readonly TNeed[];
|
|
1060
|
+
readonly permissions: typeof FACTORY_MERGE_FREEZE_PERMISSIONS;
|
|
1061
|
+
readonly steps: readonly WorkflowStep[];
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Build the merge-freeze writer job.
|
|
1065
|
+
*
|
|
1066
|
+
* An empty `needs` list is refused: a fold over no verification leaf is
|
|
1067
|
+
* always `success`, so such a job would write a green generation for a merge
|
|
1068
|
+
* target nothing verified — the exact failure the freeze exists to prevent.
|
|
1069
|
+
*/
|
|
1070
|
+
export declare const factoryMergeFreezeJob: <TNeed>(options: FactoryMergeFreezeJobOptions<TNeed>) => FactoryMergeFreezeJob<TNeed>;
|
|
1071
|
+
export declare const FACTORY_PR_STATUS_HUD_JOB_ID = "status-hud";
|
|
1072
|
+
export declare const FACTORY_PR_STATUS_HUD_JOB_NAME = "Present PR status HUD";
|
|
1073
|
+
export declare const FACTORY_PR_STATUS_HUD_APP_TOKEN_STEP_ID = "factory-app-token";
|
|
1074
|
+
export declare const FACTORY_PR_STATUS_HUD_PLAN_PATH = ".factory-memory/preview-plan.json";
|
|
1075
|
+
/**
|
|
1076
|
+
* Presentation is independent of deploy demand. Callers who `needs` the jobs
|
|
1077
|
+
* that settle HUD sources (verify, deploy) must keep this `always()` so a
|
|
1078
|
+
* skipped or withdrawn deploy still publishes Skipped rows.
|
|
1079
|
+
*/
|
|
1080
|
+
export declare const FACTORY_PR_STATUS_HUD_IF = "always() && github.event_name == 'pull_request' && github.event.pull_request.draft != true";
|
|
1081
|
+
interface FactoryPrStatusHudWorkflowOptions {
|
|
1082
|
+
readonly cli?: string;
|
|
1083
|
+
readonly createGithubAppToken: PinnedAction;
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Least privilege for the job that runs the present step. The present step
|
|
1087
|
+
* is an inventory `list`, so the job needs exactly the inventory's read
|
|
1088
|
+
* permissions (#825, #859).
|
|
1089
|
+
*/
|
|
1090
|
+
export declare const FACTORY_PR_STATUS_HUD_PERMISSIONS: Readonly<{
|
|
1091
|
+
readonly checks: "read";
|
|
1092
|
+
readonly contents: "read";
|
|
1093
|
+
readonly "pull-requests": "read";
|
|
1094
|
+
}>;
|
|
1095
|
+
export declare const FACTORY_PR_STATUS_HUD_CONCURRENCY: Readonly<{
|
|
1096
|
+
cancelInProgress: false;
|
|
1097
|
+
group: "status-hud-${{ github.repository }}-${{ github.event.pull_request.number }}";
|
|
1098
|
+
}>;
|
|
1099
|
+
interface FactoryPrStatusHudWorkflow {
|
|
1100
|
+
readonly concurrency: typeof FACTORY_PR_STATUS_HUD_CONCURRENCY;
|
|
1101
|
+
readonly if: typeof FACTORY_PR_STATUS_HUD_IF;
|
|
1102
|
+
readonly jobId: typeof FACTORY_PR_STATUS_HUD_JOB_ID;
|
|
1103
|
+
readonly jobName: typeof FACTORY_PR_STATUS_HUD_JOB_NAME;
|
|
1104
|
+
readonly permissions: typeof FACTORY_PR_STATUS_HUD_PERMISSIONS;
|
|
1105
|
+
readonly presentSteps: readonly WorkflowStep[];
|
|
1106
|
+
}
|
|
1107
|
+
export declare const factoryPrStatusHudWorkflow: (options: FactoryPrStatusHudWorkflowOptions) => FactoryPrStatusHudWorkflow;
|
|
1108
|
+
export declare const FACTORY_PREVIEW_CLEANUP_AUDIT_JOB_ID = "stage-residue-audit";
|
|
1109
|
+
export declare const FACTORY_PREVIEW_CLEANUP_AUDIT_JOB_NAME = "Stage residue audit";
|
|
1110
|
+
interface FactoryPreviewCleanupTopologyOptions {
|
|
1111
|
+
readonly audit: {
|
|
1112
|
+
readonly command: string;
|
|
1113
|
+
readonly jobId?: string;
|
|
1114
|
+
readonly jobName?: string;
|
|
1115
|
+
};
|
|
1116
|
+
readonly stacks: readonly string[];
|
|
1117
|
+
}
|
|
1118
|
+
interface FactoryPreviewCleanupDestroyJob {
|
|
1119
|
+
readonly jobId: string;
|
|
1120
|
+
readonly stack: string;
|
|
1121
|
+
}
|
|
1122
|
+
interface FactoryPreviewCleanupAuditJob {
|
|
1123
|
+
readonly if: "always()";
|
|
1124
|
+
readonly jobId: string;
|
|
1125
|
+
readonly jobName: string;
|
|
1126
|
+
readonly needs: readonly string[];
|
|
1127
|
+
readonly steps: readonly WorkflowStep[];
|
|
1128
|
+
}
|
|
1129
|
+
interface FactoryPreviewCleanupTopology {
|
|
1130
|
+
readonly auditJob: FactoryPreviewCleanupAuditJob;
|
|
1131
|
+
readonly destroyJobs: readonly FactoryPreviewCleanupDestroyJob[];
|
|
1132
|
+
}
|
|
1133
|
+
export declare const previewCleanupDestroyJobId: (stack: string) => string;
|
|
1134
|
+
/**
|
|
1135
|
+
* Generate the factory-owned preview-cleanup topology (#764): one destroy
|
|
1136
|
+
* job identity per stack, then exactly one stage-wide residue-audit job
|
|
1137
|
+
* that `needs` every destroy. The audit is whole-stage — this helper never
|
|
1138
|
+
* threads a stack name or path filter into it. Callers own destroy steps,
|
|
1139
|
+
* what counts as residue, credentials, and runners.
|
|
1140
|
+
*/
|
|
1141
|
+
export declare const factoryPreviewCleanupTopology: (options: FactoryPreviewCleanupTopologyOptions) => FactoryPreviewCleanupTopology;
|
|
1142
|
+
/**
|
|
1143
|
+
* Closed-PR preview cleanup and the scheduled orphan sweep (#1540).
|
|
1144
|
+
*
|
|
1145
|
+
* This module owns the consumer-neutral decisions: which stages a closed PR
|
|
1146
|
+
* left behind, which stages belong to PRs that are already closed, how a
|
|
1147
|
+
* stack-scoped destroy outcome reaches the inventory, and whether a stage is
|
|
1148
|
+
* still present afterwards. The consumer keeps its stack list, the destroy
|
|
1149
|
+
* command, the residue reader, credentials and protected-stage policy.
|
|
1150
|
+
*
|
|
1151
|
+
* Every destructive target passes through the one disposable-stage grammar
|
|
1152
|
+
* (`local-pr-<pr>-<sha>`) or the consumer's declared hosted grammar
|
|
1153
|
+
* (`<prefix><pr>`). Anything else is retained, never destroyed.
|
|
1154
|
+
*/
|
|
1155
|
+
/** One `{ stack, stage }` row from the consumer's residue reader. */
|
|
1156
|
+
interface PreviewCleanupResidue {
|
|
1157
|
+
readonly stack: string;
|
|
1158
|
+
readonly stage: string;
|
|
1159
|
+
}
|
|
1160
|
+
/** One stack-scoped destroy the cleanup workflow runs. */
|
|
1161
|
+
interface PreviewCleanupTarget {
|
|
1162
|
+
/** Present when a registration supplied the head, so the record can bind it. */
|
|
1163
|
+
readonly headSha?: string;
|
|
1164
|
+
readonly pr: number;
|
|
1165
|
+
readonly stack: string;
|
|
1166
|
+
readonly stage: string;
|
|
1167
|
+
}
|
|
1168
|
+
interface PreviewCleanupStackPolicy {
|
|
1169
|
+
/**
|
|
1170
|
+
* The consumer's hosted per-PR stage prefix, such as `"pr-"` for `pr-123`.
|
|
1171
|
+
* Omit it when the consumer has no hosted per-PR stage.
|
|
1172
|
+
*/
|
|
1173
|
+
readonly hostedStagePrefix?: string;
|
|
1174
|
+
/**
|
|
1175
|
+
* Other names the inventory or the residue reader uses for a declared stack,
|
|
1176
|
+
* mapped to that stack. A registration recorded as `preview-deploy-website`
|
|
1177
|
+
* resolves to `website` with `{ "preview-deploy-website": "website" }`.
|
|
1178
|
+
*/
|
|
1179
|
+
readonly stackAliases?: Readonly<Record<string, string>>;
|
|
1180
|
+
/** The stacks a cleanup destroys, in the consumer's own names. */
|
|
1181
|
+
readonly stacks: readonly string[];
|
|
1182
|
+
}
|
|
1183
|
+
interface DiscoverPreviewCleanupTargetsInput extends PreviewCleanupStackPolicy {
|
|
1184
|
+
readonly pr: number;
|
|
1185
|
+
/** Inventory registrations for the PR, from `previewProofInventory.list`. */
|
|
1186
|
+
readonly registrations: readonly PreviewProofRegistration[];
|
|
1187
|
+
readonly residue: readonly PreviewCleanupResidue[];
|
|
1188
|
+
}
|
|
1189
|
+
type PreviewCleanupPullRequestState = "closed" | "open";
|
|
1190
|
+
interface DiscoverOrphanedPreviewCleanupTargetsInput extends PreviewCleanupStackPolicy {
|
|
1191
|
+
/**
|
|
1192
|
+
* Targets per run; the rest wait for the next sweep. Default 50. A stage's
|
|
1193
|
+
* targets across its stacks are taken whole, so a run exceeds the cap only
|
|
1194
|
+
* when its first stage alone has more stacks than the cap.
|
|
1195
|
+
*/
|
|
1196
|
+
readonly maxTargets?: number;
|
|
1197
|
+
/**
|
|
1198
|
+
* The state GitHub reported for each PR the residue names. A PR missing
|
|
1199
|
+
* from the map is unknown, and its stages are retained.
|
|
1200
|
+
*/
|
|
1201
|
+
readonly pullRequestStates: ReadonlyMap<number, PreviewCleanupPullRequestState>;
|
|
1202
|
+
readonly residue: readonly PreviewCleanupResidue[];
|
|
1203
|
+
}
|
|
1204
|
+
interface PreviewCleanupSweep {
|
|
1205
|
+
/**
|
|
1206
|
+
* Orphaned targets left for the next sweep. A stage is never split: all of
|
|
1207
|
+
* its stacks are taken or all are deferred.
|
|
1208
|
+
*/
|
|
1209
|
+
readonly deferred: number;
|
|
1210
|
+
readonly targets: readonly PreviewCleanupTarget[];
|
|
1211
|
+
}
|
|
1212
|
+
interface RecordPreviewCleanupOutcomeInput {
|
|
1213
|
+
readonly evidence: readonly string[];
|
|
1214
|
+
readonly headSha?: string;
|
|
1215
|
+
readonly outcome: Exclude<PreviewProofCleanupStatus, "pending">;
|
|
1216
|
+
readonly owner: string;
|
|
1217
|
+
readonly pr: number;
|
|
1218
|
+
readonly repo: string;
|
|
1219
|
+
readonly runUrl?: string;
|
|
1220
|
+
readonly stack: string;
|
|
1221
|
+
readonly stackAliases?: Readonly<Record<string, string>>;
|
|
1222
|
+
readonly stage: string;
|
|
1223
|
+
}
|
|
1224
|
+
interface RecordPreviewCleanupOutcomeAccess {
|
|
1225
|
+
/**
|
|
1226
|
+
* Lists registrations. A workflow `GITHUB_TOKEN` with
|
|
1227
|
+
* `PREVIEW_PROOF_INVENTORY_LIST_PERMISSIONS`: the Factory App token has no
|
|
1228
|
+
* contents permission and cannot serve the list (#825).
|
|
1229
|
+
*/
|
|
1230
|
+
readonly read: PreviewProofInventoryAccess;
|
|
1231
|
+
/** Writes the outcome. A Factory App installation token. */
|
|
1232
|
+
readonly write: PreviewProofInventoryAccess;
|
|
1233
|
+
}
|
|
1234
|
+
type RecordPreviewCleanupOutcomeResult = {
|
|
1235
|
+
/** Destroyed but never registered: inventory residue or a hosted stage. */
|
|
1236
|
+
readonly kind: "unregistered";
|
|
1237
|
+
} | {
|
|
1238
|
+
readonly kind: "recorded" | "recovered";
|
|
1239
|
+
readonly registration: PreviewProofRegistration;
|
|
1240
|
+
};
|
|
1241
|
+
interface ReadPullRequestStatesInput {
|
|
1242
|
+
readonly owner: string;
|
|
1243
|
+
readonly prs: readonly number[];
|
|
1244
|
+
readonly repo: string;
|
|
1245
|
+
}
|
|
1246
|
+
interface ReadPullRequestStatesAccess {
|
|
1247
|
+
readonly fetch?: typeof fetch;
|
|
1248
|
+
readonly timeoutMs?: number;
|
|
1249
|
+
/** Needs `pull-requests: read`. */
|
|
1250
|
+
readonly token: string;
|
|
1251
|
+
}
|
|
1252
|
+
/** The GitHub-output key a stack's matrix and presence flag use. */
|
|
1253
|
+
export declare const previewCleanupStackOutputKey: (stack: string) => string;
|
|
1254
|
+
/**
|
|
1255
|
+
* Validate a stack policy. Throws on an empty or duplicate stack list, a
|
|
1256
|
+
* stack name a shell or GitHub output could misread, an alias to an
|
|
1257
|
+
* undeclared stack, or a hosted prefix that is not `<word>-`.
|
|
1258
|
+
*/
|
|
1259
|
+
export declare const assertPreviewCleanupStackPolicy: (policy: PreviewCleanupStackPolicy) => void;
|
|
1260
|
+
/** The PR a hosted stage belongs to, or `null` when it is not one. */
|
|
1261
|
+
export declare const parseHostedPreviewStage: (stage: string, prefix: string) => number | null;
|
|
1262
|
+
/**
|
|
1263
|
+
* Targets for one closed PR: its inventory registrations united with the
|
|
1264
|
+
* residue the consumer still sees for it. Only the PR's own `local-pr-<pr>-*`
|
|
1265
|
+
* stages and its hosted stage survive, in declared stacks. A registration
|
|
1266
|
+
* wins a collision so its head SHA reaches the cleanup record. A registration
|
|
1267
|
+
* whose cleanup already passed is skipped unless the residue still lists it.
|
|
1268
|
+
*/
|
|
1269
|
+
export declare const discoverPreviewCleanupTargets: (input: DiscoverPreviewCleanupTargetsInput) => readonly PreviewCleanupTarget[];
|
|
1270
|
+
/**
|
|
1271
|
+
* The PRs whose disposable stages appear in the residue. The sweep reads
|
|
1272
|
+
* their state before it decides anything.
|
|
1273
|
+
*/
|
|
1274
|
+
export declare const previewCleanupResiduePullRequests: (policy: PreviewCleanupStackPolicy, residue: readonly PreviewCleanupResidue[]) => readonly number[];
|
|
1275
|
+
/**
|
|
1276
|
+
* Targets for the scheduled sweep: disposable residue whose PR GitHub
|
|
1277
|
+
* reports closed. It fails closed. A stage that does not parse as disposable,
|
|
1278
|
+
* a stack the consumer did not declare, and a PR that is open or whose state
|
|
1279
|
+
* is unknown are all retained.
|
|
1280
|
+
*/
|
|
1281
|
+
export declare const discoverOrphanedPreviewCleanupTargets: (input: DiscoverOrphanedPreviewCleanupTargetsInput) => PreviewCleanupSweep;
|
|
1282
|
+
/**
|
|
1283
|
+
* The `$GITHUB_OUTPUT` lines the cleanup workflow's discover job publishes:
|
|
1284
|
+
* `has_targets`, `targets`, and for each declared stack `has_<key>` and
|
|
1285
|
+
* `<key>_matrix`. A stack with no target still gets `has_<key>=false`, so
|
|
1286
|
+
* its destroy job skips instead of expanding an empty matrix.
|
|
1287
|
+
*/
|
|
1288
|
+
export declare const previewCleanupGithubOutput: (policy: PreviewCleanupStackPolicy, targets: readonly PreviewCleanupTarget[]) => string;
|
|
1289
|
+
/** Parse untrusted residue JSON: an array of `{ stack, stage }` rows. */
|
|
1290
|
+
export declare const parsePreviewCleanupResidue: (value: unknown) => readonly PreviewCleanupResidue[];
|
|
1291
|
+
/**
|
|
1292
|
+
* Parse untrusted target JSON (the discover job's `targets` output). Every
|
|
1293
|
+
* row must still be a disposable stage owned by its own PR, so a tampered
|
|
1294
|
+
* output cannot widen the audit or a record.
|
|
1295
|
+
*/
|
|
1296
|
+
export declare const parsePreviewCleanupTargets: (policy: PreviewCleanupStackPolicy, value: unknown) => readonly PreviewCleanupTarget[];
|
|
1297
|
+
/**
|
|
1298
|
+
* The whole-stage audit after every destroy. Any residue row whose stage
|
|
1299
|
+
* is a target stage fails it, whatever stack the reader assigned the row,
|
|
1300
|
+
* because a sibling stack's leftovers are the same stage's residue.
|
|
1301
|
+
*/
|
|
1302
|
+
export declare const assertPreviewCleanupTargetsAbsent: (targets: readonly PreviewCleanupTarget[], residue: readonly PreviewCleanupResidue[]) => void;
|
|
1303
|
+
/**
|
|
1304
|
+
* Record one stack destroy's outcome on the inventory registration it
|
|
1305
|
+
* cleaned up. A stage nothing registered (residue-only, or a hosted stage)
|
|
1306
|
+
* returns `unregistered` without writing. A registration whose last cleanup
|
|
1307
|
+
* failed is recovered through the same cleanup transition.
|
|
1308
|
+
*/
|
|
1309
|
+
export declare const recordPreviewCleanupOutcome: (input: RecordPreviewCleanupOutcomeInput, access: RecordPreviewCleanupOutcomeAccess) => Promise<RecordPreviewCleanupOutcomeResult>;
|
|
1310
|
+
/**
|
|
1311
|
+
* Ask GitHub for each PR's state. A PR GitHub does not know is left out of
|
|
1312
|
+
* the map, so the sweep retains its stages.
|
|
1313
|
+
*/
|
|
1314
|
+
export declare const readPullRequestStates: (input: ReadPullRequestStatesInput, access: ReadPullRequestStatesAccess) => Promise<ReadonlyMap<number, PreviewCleanupPullRequestState>>;
|
|
1315
|
+
export declare const FACTORY_PREVIEW_CLEANUP_DISCOVER_JOB_ID = "discover";
|
|
1316
|
+
export declare const FACTORY_PREVIEW_CLEANUP_DISCOVER_JOB_NAME = "Discover preview cleanup targets";
|
|
1317
|
+
export declare const FACTORY_PREVIEW_CLEANUP_DISCOVER_STEP_ID = "targets";
|
|
1318
|
+
export declare const FACTORY_PREVIEW_CLEANUP_DESTROY_STEP_ID = "destroy";
|
|
1319
|
+
export declare const FACTORY_PREVIEW_CLEANUP_APP_TOKEN_STEP_ID = "factory-app-token";
|
|
1320
|
+
export declare const FACTORY_PREVIEW_CLEANUP_DEFAULT_SWEEP_CRON = "23 6 * * *";
|
|
1321
|
+
/**
|
|
1322
|
+
* A closed pull request whose head lives in this repository. A fork's head
|
|
1323
|
+
* never reaches a job that holds cleanup credentials.
|
|
1324
|
+
*/
|
|
1325
|
+
export declare const FACTORY_PREVIEW_CLEANUP_PR_CLOSED_CONDITION = "github.event_name == 'pull_request_target' && github.event.action == 'closed' && github.event.pull_request.head.repo.full_name == github.repository";
|
|
1326
|
+
/**
|
|
1327
|
+
* The sweep: the schedule, which GitHub always runs on the default branch,
|
|
1328
|
+
* or a manual dispatch from the default branch.
|
|
1329
|
+
*/
|
|
1330
|
+
export declare const FACTORY_PREVIEW_CLEANUP_SWEEP_CONDITION = "github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch))";
|
|
1331
|
+
/**
|
|
1332
|
+
* The ref every cleanup job checks out: the default branch's trusted code,
|
|
1333
|
+
* never the closed PR's head. Empty on `schedule`, where the checkout
|
|
1334
|
+
* already defaults to the default branch.
|
|
1335
|
+
*/
|
|
1336
|
+
export declare const FACTORY_PREVIEW_CLEANUP_CHECKOUT_REF = "${{ github.event.repository.default_branch }}";
|
|
1337
|
+
interface FactoryPreviewCleanupWorkflowOptions extends PreviewCleanupStackPolicy {
|
|
1338
|
+
readonly cli?: string;
|
|
1339
|
+
/**
|
|
1340
|
+
* The workflow's concurrency group for one destroy. It may read
|
|
1341
|
+
* `matrix.stack`, `matrix.stage` and `matrix.pr`. Share it with the
|
|
1342
|
+
* consumer's deploy job when a deploy and a destroy must not race.
|
|
1343
|
+
*/
|
|
1344
|
+
readonly concurrencyGroup?: string;
|
|
1345
|
+
/** The pinned `actions/create-github-app-token` the caller declared. */
|
|
1346
|
+
readonly createGithubAppToken: PinnedAction;
|
|
1347
|
+
/**
|
|
1348
|
+
* One shell line that destroys `$FACTORY_PREVIEW_CLEANUP_STAGE` of
|
|
1349
|
+
* `$FACTORY_PREVIEW_CLEANUP_STACK` and exits non-zero when it did not. It
|
|
1350
|
+
* may append evidence lines to `$FACTORY_PREVIEW_CLEANUP_EVIDENCE`.
|
|
1351
|
+
*/
|
|
1352
|
+
readonly destroyCommand: string;
|
|
1353
|
+
/**
|
|
1354
|
+
* The GitHub environment every job that holds cleanup credentials runs
|
|
1355
|
+
* in. Its protection rules, not a production deploy flag, gate cleanup.
|
|
1356
|
+
*/
|
|
1357
|
+
readonly environment: string;
|
|
1358
|
+
/**
|
|
1359
|
+
* One shell line that prints the consumer's residue as JSON
|
|
1360
|
+
* `[{ "stack": …, "stage": … }]` on stdout: Alchemy state and any physical
|
|
1361
|
+
* resources the consumer can attribute to a stack and stage.
|
|
1362
|
+
*/
|
|
1363
|
+
readonly residueCommand: string;
|
|
1364
|
+
/** The scheduled orphan sweep. Pass `false` to generate PR-close cleanup only. */
|
|
1365
|
+
readonly sweep?: false | {
|
|
1366
|
+
/** Defaults to `FACTORY_PREVIEW_CLEANUP_DEFAULT_SWEEP_CRON`. */
|
|
1367
|
+
readonly cron?: string;
|
|
1368
|
+
/**
|
|
1369
|
+
* Targets per sweep run. Defaults to 50. Stages are taken whole, so a
|
|
1370
|
+
* run exceeds it only when its first stage has more stacks than this.
|
|
1371
|
+
*/
|
|
1372
|
+
readonly maxTargets?: number;
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
interface FactoryPreviewCleanupWorkflowJob {
|
|
1376
|
+
readonly environment: string;
|
|
1377
|
+
readonly if: string;
|
|
1378
|
+
readonly jobId: string;
|
|
1379
|
+
readonly jobName: string;
|
|
1380
|
+
readonly permissions: Readonly<Record<string, "read" | "write">>;
|
|
1381
|
+
/** Append after the caller's setup steps. */
|
|
1382
|
+
readonly steps: readonly WorkflowStep[];
|
|
1383
|
+
}
|
|
1384
|
+
interface FactoryPreviewCleanupWorkflowDiscoverJob extends FactoryPreviewCleanupWorkflowJob {
|
|
1385
|
+
readonly outputs: Readonly<Record<string, string>>;
|
|
1386
|
+
}
|
|
1387
|
+
interface FactoryPreviewCleanupWorkflowDestroyJob extends FactoryPreviewCleanupWorkflowJob {
|
|
1388
|
+
readonly concurrency: {
|
|
1389
|
+
readonly cancelInProgress: false;
|
|
1390
|
+
readonly group: string;
|
|
1391
|
+
};
|
|
1392
|
+
/** Always the discover job's id. */
|
|
1393
|
+
readonly needs: readonly string[];
|
|
1394
|
+
readonly stack: string;
|
|
1395
|
+
readonly strategy: {
|
|
1396
|
+
readonly failFast: false;
|
|
1397
|
+
readonly matrix: {
|
|
1398
|
+
readonly include: string;
|
|
1399
|
+
};
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1402
|
+
interface FactoryPreviewCleanupWorkflowAuditJob extends FactoryPreviewCleanupWorkflowJob {
|
|
1403
|
+
/** Merge into the job's own `env` alongside the caller's credentials. */
|
|
1404
|
+
readonly env: Readonly<Record<string, string>>;
|
|
1405
|
+
/** The discover job, then every destroy job. */
|
|
1406
|
+
readonly needs: readonly string[];
|
|
1407
|
+
}
|
|
1408
|
+
interface FactoryPreviewCleanupWorkflow {
|
|
1409
|
+
readonly auditJob: FactoryPreviewCleanupWorkflowAuditJob;
|
|
1410
|
+
/** Pass to the checkout step of every job. */
|
|
1411
|
+
readonly checkoutRef: typeof FACTORY_PREVIEW_CLEANUP_CHECKOUT_REF;
|
|
1412
|
+
readonly destroyJobs: readonly FactoryPreviewCleanupWorkflowDestroyJob[];
|
|
1413
|
+
readonly discoverJob: FactoryPreviewCleanupWorkflowDiscoverJob;
|
|
1414
|
+
readonly on: Readonly<Record<string, unknown>>;
|
|
1415
|
+
readonly permissions: Readonly<{
|
|
1416
|
+
contents: "read";
|
|
1417
|
+
}>;
|
|
1418
|
+
}
|
|
1419
|
+
/**
|
|
1420
|
+
* Generate the factory-owned closed-PR preview cleanup and orphan sweep
|
|
1421
|
+
* (#1540) on top of `factoryPreviewCleanupTopology`:
|
|
1422
|
+
*
|
|
1423
|
+
* - `discover` reads the consumer's residue and, for a closed same-repo PR,
|
|
1424
|
+
* unites it with the PR's inventory registrations; for the sweep, keeps the
|
|
1425
|
+
* residue of PRs GitHub reports closed. It publishes one matrix per stack.
|
|
1426
|
+
* - one destroy job per stack runs the consumer's destroy for each matrix
|
|
1427
|
+
* target, then records the outcome on the inventory with the Factory App.
|
|
1428
|
+
* - one stage-wide audit re-reads the residue after every destroy and fails
|
|
1429
|
+
* if any target stage remains, in any stack.
|
|
1430
|
+
*
|
|
1431
|
+
* Every credentialed job runs in the consumer's GitHub environment, never
|
|
1432
|
+
* behind a production deploy flag. The caller prepends its own setup steps
|
|
1433
|
+
* (checked out at `checkoutRef`), and adds `runsOn` and credential `env`.
|
|
1434
|
+
*/
|
|
1435
|
+
export declare const factoryPreviewCleanupWorkflow: (options: FactoryPreviewCleanupWorkflowOptions) => FactoryPreviewCleanupWorkflow;
|
|
1436
|
+
interface FactoryPreviewReceiptWorkflowOptions {
|
|
1437
|
+
readonly target: string;
|
|
1438
|
+
readonly cli?: string;
|
|
1439
|
+
/** Caller-owned PR number expression, passed through the environment. */
|
|
1440
|
+
readonly pr?: string;
|
|
1441
|
+
}
|
|
1442
|
+
interface FactoryPreviewReceiptWorkflow {
|
|
1443
|
+
/** Place before the selected target's first mutation, under its selection guard. */
|
|
1444
|
+
readonly beginStep: WorkflowStep;
|
|
1445
|
+
/** Append after consumer deploy and required smoke steps. Never rename the bind step. */
|
|
1446
|
+
readonly completionSteps: readonly WorkflowStep[];
|
|
1447
|
+
/** Place before cleanup, including cleanup of a failed/unregistered deployment. */
|
|
1448
|
+
readonly invalidateStep: WorkflowStep;
|
|
1449
|
+
readonly permissions: Readonly<{
|
|
1450
|
+
actions: "read";
|
|
1451
|
+
contents: "read";
|
|
1452
|
+
deployments: "write";
|
|
1453
|
+
"pull-requests": "read";
|
|
1454
|
+
}>;
|
|
1455
|
+
}
|
|
1456
|
+
/** Receipt transport only. The consumer owns selection, lifecycle, smoke, and freshness. */
|
|
1457
|
+
export declare const factoryPreviewReceiptWorkflow: (options: FactoryPreviewReceiptWorkflowOptions) => FactoryPreviewReceiptWorkflow;
|
|
1458
|
+
export declare const FACTORY_PRODUCTION_IMPACT_STEP_ID = "production_impact";
|
|
1459
|
+
export declare const FACTORY_PRODUCTION_IMPACT_DECISION_OUTPUT = "decision";
|
|
1460
|
+
export declare const FACTORY_PRODUCTION_IMPACT_BASIS_OUTPUT = "basis";
|
|
1461
|
+
export declare const FACTORY_PRODUCTION_IMPACT_UNSUBSCRIBED_OUTPUT = "unsubscribed_paths";
|
|
1462
|
+
/** Stable GitHub-output key for one declared target. */
|
|
1463
|
+
export declare const productionImpactTargetOutput: (targetName: string) => string;
|
|
1464
|
+
interface FactoryProductionImpactWorkflowOptions {
|
|
1465
|
+
/** The checked-out candidate commit. Defaults to `github.sha`. */
|
|
1466
|
+
readonly candidate?: string;
|
|
1467
|
+
readonly cli?: string;
|
|
1468
|
+
readonly profilePath?: string;
|
|
1469
|
+
/** Deployment stage the receipts are bound to, when the consumer has one. */
|
|
1470
|
+
readonly stage?: string;
|
|
1471
|
+
readonly targets: readonly string[];
|
|
1472
|
+
}
|
|
1473
|
+
interface FactoryProductionImpactWorkflow {
|
|
1474
|
+
/** Outputs for a caller-owned decision job that subsequent jobs may consume. */
|
|
1475
|
+
readonly decisionJobOutputs: Readonly<Record<string, string>>;
|
|
1476
|
+
readonly decisionStep: WorkflowStep;
|
|
1477
|
+
/**
|
|
1478
|
+
* A fail-open cross-job condition: only an explicit usable withdrawal skips
|
|
1479
|
+
* work. The decision job id is required.
|
|
1480
|
+
*/
|
|
1481
|
+
readonly demandedIf: (targetName: string, decisionJob: string) => string;
|
|
1482
|
+
/** The same fail-open condition for a step in the decision job. */
|
|
1483
|
+
readonly demandedIfAtStep: (targetName: string) => string;
|
|
1484
|
+
/** Permissions every job that runs the decision step or a receipt step declares for `github.token`. */
|
|
1485
|
+
readonly permissions: Readonly<{
|
|
1486
|
+
actions: "read";
|
|
1487
|
+
contents: "read";
|
|
1488
|
+
deployments: "write";
|
|
1489
|
+
}>;
|
|
1490
|
+
/**
|
|
1491
|
+
* The receipt steps a deploy job appends after its deploy and health steps,
|
|
1492
|
+
* in order: a success receipt that runs when every earlier step succeeded
|
|
1493
|
+
* and outputs the new deployment id; a bind step whose name carries that id
|
|
1494
|
+
* and whose presence in GitHub's job record is the reader's proof that this
|
|
1495
|
+
* run created that record; and a failure receipt that runs when a step
|
|
1496
|
+
* failed. Only a bound success receipt advances the target's baseline. Do
|
|
1497
|
+
* not rename or reorder them.
|
|
1498
|
+
*/
|
|
1499
|
+
readonly receiptSteps: (targetName: string) => readonly WorkflowStep[];
|
|
1500
|
+
readonly targetOutputs: Readonly<Record<string, string>>;
|
|
1501
|
+
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Generate the small factory-owned decision seam for a consumer production
|
|
1504
|
+
* workflow. Consumers retain jobs, deploy commands, credentials, topology,
|
|
1505
|
+
* health checks, and convergence checks; this artifact supplies the decision
|
|
1506
|
+
* step, per-target withdrawal conditions, and the receipt steps that record
|
|
1507
|
+
* what each deploy job did.
|
|
1508
|
+
*
|
|
1509
|
+
* The decision step resolves each target's demand from its last trusted
|
|
1510
|
+
* successful deployment receipt, never from the push's before commit. The
|
|
1511
|
+
* decision checkout needs full history (`fetchDepth: 0`) so the baseline
|
|
1512
|
+
* commit is reachable; a shallow checkout keeps every target demanded.
|
|
1513
|
+
*/
|
|
1514
|
+
export declare const factoryProductionImpactWorkflow: (options: FactoryProductionImpactWorkflowOptions) => FactoryProductionImpactWorkflow;
|
|
1515
|
+
export declare const FACTORY_PUSH_IDENTITY_SCHEMA_VERSION = 1;
|
|
1516
|
+
/** Versioned document uploaded by a push-triggered verification run. */
|
|
1517
|
+
interface FactoryPushIdentityEnvelope {
|
|
1518
|
+
readonly after: string;
|
|
1519
|
+
readonly before: string;
|
|
1520
|
+
readonly repository: string;
|
|
1521
|
+
readonly runId: string;
|
|
1522
|
+
readonly schemaVersion: typeof FACTORY_PUSH_IDENTITY_SCHEMA_VERSION;
|
|
1523
|
+
}
|
|
1524
|
+
type FactoryPushIdentityDisposition = "refused" | "usable";
|
|
1525
|
+
interface FactoryPushIdentityProducerOptions {
|
|
1526
|
+
/**
|
|
1527
|
+
* Explicit caller-owned upload-artifact pin from its workflow artifact.
|
|
1528
|
+
* Pass factory-ci's `UPLOAD_ARTIFACT` catalog export (or another
|
|
1529
|
+
* `actions/upload-artifact` pin); the caller wires the step, the catalog
|
|
1530
|
+
* only names the pin.
|
|
1531
|
+
*/
|
|
1532
|
+
readonly uploadArtifact: PinnedAction;
|
|
1533
|
+
/** Optional consumer trigger policy combined with the required push event. */
|
|
1534
|
+
readonly if?: string;
|
|
1535
|
+
}
|
|
1536
|
+
interface FactoryPushIdentityProducer {
|
|
1537
|
+
readonly artifactName: string;
|
|
1538
|
+
readonly steps: readonly WorkflowStep[];
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Record and upload the exact push-event identity without changing the Verify
|
|
1542
|
+
* result when transport is unavailable. Place these steps after verification.
|
|
1543
|
+
*/
|
|
1544
|
+
export declare const factoryPushIdentityProducer: (options: FactoryPushIdentityProducerOptions) => FactoryPushIdentityProducer;
|
|
1545
|
+
interface FactoryPushIdentityConsumer {
|
|
1546
|
+
/** Job outputs suitable for a caller-owned decision job and telemetry. */
|
|
1547
|
+
readonly outputs: Readonly<Record<"after" | "before" | "disposition" | "provenance" | "reason", string>>;
|
|
1548
|
+
readonly requiredPermissions: Readonly<{
|
|
1549
|
+
actions: "read";
|
|
1550
|
+
contents: "read";
|
|
1551
|
+
}>;
|
|
1552
|
+
readonly steps: readonly WorkflowStep[];
|
|
1553
|
+
/** Run classification only when exact identity transport is usable. */
|
|
1554
|
+
readonly usableIf: string;
|
|
1555
|
+
}
|
|
1556
|
+
interface FactoryPushIdentityConsumerOptions {
|
|
1557
|
+
/** Explicit caller-owned checkout pin from its action family. */
|
|
1558
|
+
readonly checkout: PinnedAction;
|
|
1559
|
+
/** Explicit caller-owned download-artifact pin from its workflow artifact. */
|
|
1560
|
+
readonly downloadArtifact: PinnedAction;
|
|
1561
|
+
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Download and validate identity from exactly the triggering workflow run in
|
|
1564
|
+
* the current repository. Every failure becomes a typed refusal; consumers
|
|
1565
|
+
* retain deploy policy, credentials, commands, topology, and convergence.
|
|
1566
|
+
*/
|
|
1567
|
+
export declare const factoryPushIdentityConsumer: (options: FactoryPushIdentityConsumerOptions) => FactoryPushIdentityConsumer;
|
|
1568
|
+
/** Schema version of the emitted profile document. */
|
|
1569
|
+
export declare const VITEST_PROFILE_SCHEMA_VERSION = 1;
|
|
1570
|
+
/** `tool` discriminator every emitted profile carries. */
|
|
1571
|
+
export declare const VITEST_PROFILE_TOOL = "factory-ci-vitest-profile";
|
|
1572
|
+
/** Per-assertion status as Vitest's JSON reporter spells it. */
|
|
1573
|
+
type VitestTestStatus = "disabled" | "failed" | "passed" | "pending" | "skipped" | "todo";
|
|
1574
|
+
/** The subset of Vitest's `--reporter=json` document this module reads. */
|
|
1575
|
+
interface VitestJsonReport {
|
|
1576
|
+
numFailedTests: number;
|
|
1577
|
+
numPassedTests: number;
|
|
1578
|
+
numPendingTests: number;
|
|
1579
|
+
numTodoTests: number;
|
|
1580
|
+
numTotalTests: number;
|
|
1581
|
+
numTotalTestSuites: number;
|
|
1582
|
+
success: boolean;
|
|
1583
|
+
testResults: {
|
|
1584
|
+
assertionResults: {
|
|
1585
|
+
duration?: number | null;
|
|
1586
|
+
fullName: string;
|
|
1587
|
+
status: VitestTestStatus;
|
|
1588
|
+
}[];
|
|
1589
|
+
endTime: number;
|
|
1590
|
+
name: string;
|
|
1591
|
+
startTime: number;
|
|
1592
|
+
status: "failed" | "passed";
|
|
1593
|
+
}[];
|
|
1594
|
+
}
|
|
1595
|
+
/** Duration statistics over one population of samples, in milliseconds. */
|
|
1596
|
+
interface VitestProfileDurationSummary {
|
|
1597
|
+
maximum: number;
|
|
1598
|
+
mean: number;
|
|
1599
|
+
median: number;
|
|
1600
|
+
minimum: number;
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* The machine a sample ran on, plus the commit it measured. `cpuModel` is the
|
|
1604
|
+
* field that makes two runs comparable at all: hosted runner pools mix silicon
|
|
1605
|
+
* behind one label.
|
|
1606
|
+
*/
|
|
1607
|
+
interface VitestProfileEnvironment {
|
|
1608
|
+
arch: string;
|
|
1609
|
+
availableParallelism: number;
|
|
1610
|
+
cpuCount: number;
|
|
1611
|
+
cpuModel: string | null;
|
|
1612
|
+
gitDirty: boolean | null;
|
|
1613
|
+
gitHead: string | null;
|
|
1614
|
+
node: string;
|
|
1615
|
+
osRelease: string;
|
|
1616
|
+
platform: string;
|
|
1617
|
+
totalMemoryBytes: number;
|
|
1618
|
+
vitest: string;
|
|
1619
|
+
}
|
|
1620
|
+
/** One complete Vitest run inside a profile. */
|
|
1621
|
+
interface VitestProfileSample {
|
|
1622
|
+
counts: {
|
|
1623
|
+
failed: number;
|
|
1624
|
+
passed: number;
|
|
1625
|
+
pending: number;
|
|
1626
|
+
suites: number;
|
|
1627
|
+
tests: number;
|
|
1628
|
+
todo: number;
|
|
1629
|
+
} | null;
|
|
1630
|
+
durationMs: number;
|
|
1631
|
+
endedAt: string;
|
|
1632
|
+
exitCode: number;
|
|
1633
|
+
failure: string | null;
|
|
1634
|
+
files: {
|
|
1635
|
+
durationMs: number;
|
|
1636
|
+
path: string;
|
|
1637
|
+
status: "failed" | "passed";
|
|
1638
|
+
}[];
|
|
1639
|
+
reportAvailable: boolean;
|
|
1640
|
+
sample: number;
|
|
1641
|
+
startedAt: string;
|
|
1642
|
+
tests: {
|
|
1643
|
+
durationMs: number;
|
|
1644
|
+
file: string;
|
|
1645
|
+
name: string;
|
|
1646
|
+
status: VitestTestStatus;
|
|
1647
|
+
}[];
|
|
1648
|
+
}
|
|
1649
|
+
/** The emitted profile document. */
|
|
1650
|
+
interface VitestProfile {
|
|
1651
|
+
command: string[];
|
|
1652
|
+
endedAt: string;
|
|
1653
|
+
environment: VitestProfileEnvironment;
|
|
1654
|
+
options: {
|
|
1655
|
+
maxWorkers: number;
|
|
1656
|
+
samples: number;
|
|
1657
|
+
slowLimit: number;
|
|
1658
|
+
};
|
|
1659
|
+
rawReportDirectory: string;
|
|
1660
|
+
runs: VitestProfileSample[];
|
|
1661
|
+
schemaVersion: typeof VITEST_PROFILE_SCHEMA_VERSION;
|
|
1662
|
+
startedAt: string;
|
|
1663
|
+
summary: {
|
|
1664
|
+
durationMs: VitestProfileDurationSummary;
|
|
1665
|
+
slowFiles: {
|
|
1666
|
+
durationMs: VitestProfileDurationSummary;
|
|
1667
|
+
path: string;
|
|
1668
|
+
samples: number;
|
|
1669
|
+
}[];
|
|
1670
|
+
slowTests: {
|
|
1671
|
+
durationMs: VitestProfileDurationSummary;
|
|
1672
|
+
file: string;
|
|
1673
|
+
name: string;
|
|
1674
|
+
samples: number;
|
|
1675
|
+
}[];
|
|
1676
|
+
};
|
|
1677
|
+
tool: typeof VITEST_PROFILE_TOOL;
|
|
1678
|
+
}
|
|
1679
|
+
/** What a caller must decide before a profile can run. */
|
|
1680
|
+
interface VitestProfileOptions {
|
|
1681
|
+
/** Directory Vitest runs in; file paths are recorded relative to it. */
|
|
1682
|
+
cwd: string;
|
|
1683
|
+
/** Directory whose Git state is recorded. Defaults to `cwd`. */
|
|
1684
|
+
gitDirectory?: string;
|
|
1685
|
+
/** Vitest `--maxWorkers` for every sample. */
|
|
1686
|
+
maxWorkers: number;
|
|
1687
|
+
/** Absolute path of the profile document to write. */
|
|
1688
|
+
outputPath: string;
|
|
1689
|
+
/** Called before each sample starts. */
|
|
1690
|
+
onSampleStart?: (input: {
|
|
1691
|
+
maxWorkers: number;
|
|
1692
|
+
sample: number;
|
|
1693
|
+
samples: number;
|
|
1694
|
+
}) => void;
|
|
1695
|
+
/** Called after each sample is normalized and persisted. */
|
|
1696
|
+
onSampleComplete?: (input: {
|
|
1697
|
+
result: VitestProfileSample;
|
|
1698
|
+
sample: number;
|
|
1699
|
+
samples: number;
|
|
1700
|
+
}) => void;
|
|
1701
|
+
/** How many serial runs to take. */
|
|
1702
|
+
samples: number;
|
|
1703
|
+
/** How many slow files and slow tests to keep in the summary. */
|
|
1704
|
+
slowLimit: number;
|
|
1705
|
+
/**
|
|
1706
|
+
* `stdio` for the Vitest child. Defaults to `"inherit"`, which is what a
|
|
1707
|
+
* caller printing progress to a terminal wants; a caller whose own stdout is
|
|
1708
|
+
* structured passes `"ignore"` to silence the run.
|
|
1709
|
+
*/
|
|
1710
|
+
stdio?: StdioOptions;
|
|
1711
|
+
}
|
|
1712
|
+
/** Outcome of one Vitest invocation, as `runSample` reports it. */
|
|
1713
|
+
interface VitestProfileSampleExecution {
|
|
1714
|
+
durationMs: number;
|
|
1715
|
+
exitCode: number;
|
|
1716
|
+
failure?: string | null;
|
|
1717
|
+
report: VitestJsonReport | null;
|
|
1718
|
+
}
|
|
1719
|
+
/** Injectable seams; production passes none of them. */
|
|
1720
|
+
interface VitestProfileDependencies {
|
|
1721
|
+
now?: () => Date;
|
|
1722
|
+
runSample?: (input: {
|
|
1723
|
+
cwd: string;
|
|
1724
|
+
maxWorkers: number;
|
|
1725
|
+
reportPath: string;
|
|
1726
|
+
sample: number;
|
|
1727
|
+
stdio: StdioOptions;
|
|
1728
|
+
}) => Promise<VitestProfileSampleExecution>;
|
|
1729
|
+
writeResult?: (outputPath: string, profile: VitestProfile) => Promise<void>;
|
|
1730
|
+
}
|
|
1731
|
+
/**
|
|
1732
|
+
* A sample failed. The partial profile is already on disk; `exitCode` is the
|
|
1733
|
+
* status a caller should exit with.
|
|
1734
|
+
*/
|
|
1735
|
+
export declare class VitestProfileError extends Error {
|
|
1736
|
+
readonly exitCode: number;
|
|
1737
|
+
constructor(message: string, exitCode: number);
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* Fold one Vitest JSON report into a profile sample: file and test timings,
|
|
1741
|
+
* both sorted slowest first, plus the run's counts. A missing report (crash,
|
|
1742
|
+
* timeout, unwritable output) yields a sample with `reportAvailable: false`
|
|
1743
|
+
* rather than nothing at all.
|
|
1744
|
+
*/
|
|
1745
|
+
export declare const normalizeVitestProfileSample: (report: VitestJsonReport | null, input: {
|
|
1746
|
+
cwd: string;
|
|
1747
|
+
durationMs: number;
|
|
1748
|
+
endedAt: Date;
|
|
1749
|
+
exitCode: number;
|
|
1750
|
+
failure?: string | null;
|
|
1751
|
+
sample: number;
|
|
1752
|
+
startedAt: Date;
|
|
1753
|
+
}) => VitestProfileSample;
|
|
1754
|
+
/**
|
|
1755
|
+
* Record the machine and commit a profile was taken on. Vitest's version is
|
|
1756
|
+
* resolved from `cwd`, so it is the consumer's Vitest and not this package's.
|
|
1757
|
+
* Git failures degrade to `null` — an artifact from a tarball checkout is still
|
|
1758
|
+
* a usable measurement.
|
|
1759
|
+
*/
|
|
1760
|
+
export declare const captureVitestProfileEnvironment: (options: {
|
|
1761
|
+
cwd: string;
|
|
1762
|
+
gitDirectory?: string;
|
|
1763
|
+
}) => Promise<VitestProfileEnvironment>;
|
|
1764
|
+
/**
|
|
1765
|
+
* Write a profile document atomically: a partial file must never be readable
|
|
1766
|
+
* as a complete measurement, and the profile is rewritten after every sample.
|
|
1767
|
+
*/
|
|
1768
|
+
export declare const writeVitestProfile: (outputPath: string, profile: VitestProfile) => Promise<void>;
|
|
1769
|
+
/**
|
|
1770
|
+
* Take `samples` serial Vitest runs at one worker count and persist the profile
|
|
1771
|
+
* after each one. Samples never overlap: concurrent runs would measure CPU and
|
|
1772
|
+
* I/O contention instead of the worker count under test. A failing sample
|
|
1773
|
+
* throws `VitestProfileError` with the partial profile already written.
|
|
1774
|
+
*/
|
|
1775
|
+
export declare const runVitestProfile: (options: VitestProfileOptions, dependencies?: VitestProfileDependencies) => Promise<VitestProfile>;
|
|
1776
|
+
/**
|
|
1777
|
+
* Outcome of reading one candidate document. `unrecognized` carries the first
|
|
1778
|
+
* reason the document failed — an analyzer reports it verbatim rather than
|
|
1779
|
+
* treating an unreadable profile as an empty one.
|
|
1780
|
+
*/
|
|
1781
|
+
type VitestProfileReadResult = {
|
|
1782
|
+
kind: "profile";
|
|
1783
|
+
profile: VitestProfile;
|
|
1784
|
+
} | {
|
|
1785
|
+
kind: "unrecognized";
|
|
1786
|
+
reason: string;
|
|
1787
|
+
};
|
|
1788
|
+
/**
|
|
1789
|
+
* Check one parsed JSON document against the profile contract the writer
|
|
1790
|
+
* emits. Returns the typed profile on success and the first mismatch reason
|
|
1791
|
+
* otherwise — never a partially-usable value.
|
|
1792
|
+
*/
|
|
1793
|
+
export declare const readVitestProfileDocument: (value: unknown) => VitestProfileReadResult;
|
|
1794
|
+
declare const DEPOT_LABEL = "depot-ubuntu-24.04";
|
|
1795
|
+
declare const HOSTED_LABEL = "ubuntu-latest";
|
|
1796
|
+
/**
|
|
1797
|
+
* Why a job runs where it does. The two Depot kinds share a label. They stay
|
|
1798
|
+
* distinct so billed-rounding jobs and long compute jobs cannot be confused
|
|
1799
|
+
* in the declaration table.
|
|
1800
|
+
*
|
|
1801
|
+
* `deploy-credentials` is legal to construct (HQ deploy).
|
|
1802
|
+
* `assertVerifyRunnerPolicy` refuses it, because a Verify workflow has no
|
|
1803
|
+
* Cloudflare production secret.
|
|
1804
|
+
*/
|
|
1805
|
+
type FactoryRunnerKind = "sustained-compute" | "rounding-tax" | "app-token" | "deploy-credentials";
|
|
1806
|
+
type FactoryRunnerHome = "depot" | "hosted";
|
|
1807
|
+
interface FactoryRunnerOverride {
|
|
1808
|
+
readonly kind: "override";
|
|
1809
|
+
readonly home: FactoryRunnerHome;
|
|
1810
|
+
readonly why: string;
|
|
1811
|
+
}
|
|
1812
|
+
type FactoryRunnerDecision = FactoryRunnerKind | FactoryRunnerOverride;
|
|
1813
|
+
interface FactoryVerifyRunner {
|
|
1814
|
+
readonly decision: FactoryRunnerDecision;
|
|
1815
|
+
readonly home: FactoryRunnerHome;
|
|
1816
|
+
readonly label: typeof DEPOT_LABEL | typeof HOSTED_LABEL;
|
|
1817
|
+
readonly why?: string;
|
|
1818
|
+
}
|
|
1819
|
+
type FactoryVerifyRunnerTable = Readonly<Record<string, FactoryVerifyRunner>>;
|
|
1820
|
+
interface FactoryVerifyRunnerPolicyInput {
|
|
1821
|
+
readonly source: string;
|
|
1822
|
+
readonly jobs: FactoryVerifyRunnerTable;
|
|
1823
|
+
}
|
|
1824
|
+
interface FactoryVerifyRunnerMismatch {
|
|
1825
|
+
readonly jobId: string;
|
|
1826
|
+
readonly expected: string;
|
|
1827
|
+
readonly actual: string;
|
|
1828
|
+
}
|
|
1829
|
+
interface FactoryVerifyRunnerPolicyReport {
|
|
1830
|
+
readonly ok: boolean;
|
|
1831
|
+
readonly undeclared: readonly string[];
|
|
1832
|
+
readonly missing: readonly string[];
|
|
1833
|
+
readonly mismatches: readonly FactoryVerifyRunnerMismatch[];
|
|
1834
|
+
readonly forbiddenKinds: readonly string[];
|
|
1835
|
+
}
|
|
1836
|
+
export declare const factoryVerifyRunner: (decision: FactoryRunnerDecision) => FactoryVerifyRunner;
|
|
1837
|
+
export declare const verifyRunnerPolicy: (yaml: string, input: FactoryVerifyRunnerPolicyInput) => FactoryVerifyRunnerPolicyReport;
|
|
1838
|
+
export declare const assertVerifyRunnerPolicy: (yaml: string, input: FactoryVerifyRunnerPolicyInput) => FactoryVerifyRunnerPolicyReport;
|
|
1839
|
+
/**
|
|
1840
|
+
* Parse-check the shell embedded in generated workflow YAML (#376).
|
|
1841
|
+
*
|
|
1842
|
+
* The generated-workflow lint validates YAML shape. It never parses the shell
|
|
1843
|
+
* inside a `run:` block, so a script that cannot execute at all — a stray
|
|
1844
|
+
* `fi`, an unclosed quote, a `then` with no `if` — passes every local check
|
|
1845
|
+
* and only fails when the runner reaches it. That is not hypothetical:
|
|
1846
|
+
* paitronage#1090 shipped a stray `fi` into a generated workflow and made
|
|
1847
|
+
* every automated preview destroy a parse-time no-op for five days.
|
|
1848
|
+
*
|
|
1849
|
+
* `bash -n` is the whole control: it parses without executing. It lives here,
|
|
1850
|
+
* once, rather than as a contract test in each consumer, because a guard
|
|
1851
|
+
* copied per repository is a guard that exists in some of them.
|
|
1852
|
+
*/
|
|
1853
|
+
/** One `run:` block that bash refuses to parse. */
|
|
1854
|
+
interface WorkflowShellParseFailure {
|
|
1855
|
+
/** The step's `name:` when the YAML carried one. */
|
|
1856
|
+
readonly step?: string;
|
|
1857
|
+
/** The script as bash saw it, expressions already neutralized. */
|
|
1858
|
+
readonly script: string;
|
|
1859
|
+
/** What bash said. */
|
|
1860
|
+
readonly stderr: string;
|
|
1861
|
+
}
|
|
1862
|
+
/** A `run:` block lifted out of generated YAML, with its step's `shell:`. */
|
|
1863
|
+
interface RunBlock {
|
|
1864
|
+
readonly script: string;
|
|
1865
|
+
readonly shell?: string;
|
|
1866
|
+
readonly step?: string;
|
|
1867
|
+
}
|
|
1868
|
+
/**
|
|
1869
|
+
* Every `run:` block in a generated workflow, paired with the `shell:` its
|
|
1870
|
+
* step declares.
|
|
1871
|
+
*
|
|
1872
|
+
* Deliberately a scanner over the emitted text and not a YAML parse: this
|
|
1873
|
+
* package takes no dependency it does not need, and the emitted shape is one
|
|
1874
|
+
* generator's output, not arbitrary YAML. It reads both block scalars
|
|
1875
|
+
* (`run: |-`) and inline scripts.
|
|
1876
|
+
*/
|
|
1877
|
+
export declare const workflowRunBlocks: (yaml: string) => RunBlock[];
|
|
1878
|
+
/** Every `run:` block its interpreter refuses to parse. Empty means sound. */
|
|
1879
|
+
export declare const workflowShellParseFailures: (yaml: string) => WorkflowShellParseFailure[];
|
|
1880
|
+
/**
|
|
1881
|
+
* Fail the generated-workflow lint when any embedded `run:` block is not
|
|
1882
|
+
* parseable bash. Call it on the YAML a generator is about to write, so the
|
|
1883
|
+
* defect is caught at generation rather than by the runner.
|
|
1884
|
+
*/
|
|
1885
|
+
export declare const assertWorkflowShellParses: (yaml: string, options: {
|
|
1886
|
+
readonly source: string;
|
|
1887
|
+
}) => void;
|
|
1888
|
+
export type { CheckoutStepOptions, DiscoverOrphanedPreviewCleanupTargetsInput, DiscoverPreviewCleanupTargetsInput, FactoryCandidateImpactWorkflow, FactoryCandidateImpactWorkflowOptions, FactoryLifecycleContractLane, FactoryLifecycleContractLaneOptions, FactoryMergeFreezeJob, FactoryMergeFreezeJobOptions, FactoryPrStatusHudWorkflow, FactoryPrStatusHudWorkflowOptions, FactoryPreviewCleanupAuditJob, FactoryPreviewCleanupDestroyJob, FactoryPreviewCleanupTopology, FactoryPreviewCleanupTopologyOptions, FactoryPreviewCleanupWorkflow, FactoryPreviewCleanupWorkflowAuditJob, FactoryPreviewCleanupWorkflowDestroyJob, FactoryPreviewCleanupWorkflowDiscoverJob, FactoryPreviewCleanupWorkflowJob, FactoryPreviewCleanupWorkflowOptions, FactoryPreviewReceiptWorkflow, FactoryPreviewReceiptWorkflowOptions, FactoryProductionImpactWorkflow, FactoryProductionImpactWorkflowOptions, FactoryProofGateOptions, FactoryProofGateReason, FactoryProofGateStep, FactoryProofReusePresentationOptions, FactoryProofReuseSummaryStep, FactoryProofTimingStartStep, FactoryPushIdentityConsumer, FactoryPushIdentityConsumerOptions, FactoryPushIdentityDisposition, FactoryPushIdentityEnvelope, FactoryPushIdentityProducer, FactoryPushIdentityProducerOptions, FactoryRunnerDecision, FactoryRunnerHome, FactoryRunnerKind, FactoryRunnerOverride, FactoryVerifyRunner, FactoryVerifyRunnerMismatch, FactoryVerifyRunnerPolicyInput, FactoryVerifyRunnerPolicyReport, FactoryVerifyRunnerTable, FactoryWorkflowArtifact, FactoryWorkflowOptions, FactoryWorkflowSetupOptions, GithubAppCredentials, GithubAppInstallationPermissions, GithubAppTokenOptions, InstallStepOptions, LocalPreviewStage, LocalPreviewStageOptions, NodePnpmActionFamily, ParseLocalPreviewStageExpected, ParsedLocalPreviewStage, PinnedAction, PreviewCleanupPullRequestState, PreviewCleanupResidue, PreviewCleanupStackPolicy, PreviewCleanupSweep, PreviewCleanupTarget, PreviewProofCandidate, PreviewProofCleanupOutcome, PreviewProofCleanupStatus, PreviewProofEnvelopeEvidence, PreviewProofInventoryAccess, PreviewProofInventoryCleanupInput, PreviewProofInventoryListInput, PreviewProofInventoryPersistInput, PreviewProofInventoryStore, PreviewProofInventoryTransport, PreviewProofLifecycleEvent, PreviewProofLifecycleState, PreviewProofRegistration, PreviewProofResolveQuery, ProofReuseCommand, ProofReuseCoverageInput, ProofReuseCoverageReport, ReadPullRequestStatesAccess, ReadPullRequestStatesInput, RecordPreviewCleanupOutcomeAccess, RecordPreviewCleanupOutcomeInput, RecordPreviewCleanupOutcomeResult, SetupNodeStepOptions, SetupStepRole, VitestJsonReport, VitestProfile, VitestProfileDependencies, VitestProfileDurationSummary, VitestProfileEnvironment, VitestProfileOptions, VitestProfileReadResult, VitestProfileSample, VitestProfileSampleExecution, VitestTestStatus, WorkflowShellParseFailure, WorkflowStep };
|