@patronage/factory-ci 1.0.0-alpha.43 → 1.0.0-alpha.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as BundleAlchemyEntryOptions, i as executeAlchemyEntry, n as ExecuteAlchemyEntryOptions, o as bundleAlchemyEntry, r as ExecuteAlchemyEntryResult, t as EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER } from "./execute-alchemy-entry-B397GSk5.js";
1
+ import { a as BundleAlchemyEntryOptions, i as executeAlchemyEntry, n as ExecuteAlchemyEntryOptions, o as bundleAlchemyEntry, r as ExecuteAlchemyEntryResult, t as EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER } from "./execute-alchemy-entry-BR5dFO9k.js";
2
2
  import { StdioOptions } from "node:child_process";
3
3
 
4
4
  //#region src/alchemy-baseline.d.ts
@@ -12,8 +12,8 @@ import { StdioOptions } from "node:child_process";
12
12
  * `effect`, so it ships from the root entry, not the `./alchemy` subpath.
13
13
  */
14
14
  declare const ALCHEMY_BASELINE: {
15
- readonly alchemy: "2.0.0-beta.83";
16
- readonly effect: "4.0.1";
15
+ readonly alchemy: "2.0.0-beta.84";
16
+ readonly effect: "4.0.6";
17
17
  };
18
18
  /**
19
19
  * The slice of a consumer's `package.json` that carries the pins this
@@ -30,7 +30,9 @@ interface AssertAlchemyBaselineInput {
30
30
  }
31
31
  /**
32
32
  * Fails when the consumer's `alchemy` or `effect` pin differs from
33
- * {@link ALCHEMY_BASELINE}, or when only one of the pair is present.
33
+ * {@link ALCHEMY_BASELINE}, when the pair is incomplete (a pinned Alchemy
34
+ * provider package such as `@alchemy.run/cloudflare` demands both), or when a
35
+ * pinned provider package is not at the baseline `alchemy` version.
34
36
  * Alchemy peers on Effect, so an unpinned auto-installed Effect can drift
35
37
  * outside the baseline while a lone `alchemy` pin would otherwise pass.
36
38
  * Both packages remaining absent is not drift — they are optional peers of
@@ -49,13 +51,6 @@ declare const assertAlchemyBaseline: ({
49
51
  * The GitHub Actions this family's workflow generators use, pinned to full
50
52
  * commit SHAs in one place (#268).
51
53
  *
52
- * Every repository pinned the same *tags* and got different *commits*: this
53
- * repository's `verify.yml` carried `actions/checkout@11d5960a` while
54
- * `hq-deploy.yml` and all of paitronage carried `34e11487`, because gagen
55
- * resolves a floating `@v4` at generation time and the files were generated
56
- * months apart. Naming the SHA here is what makes that class of drift
57
- * impossible: regenerating a workflow can no longer move a pin.
58
- *
59
54
  * `uses` is a bare `owner/repo@<sha>` string, safe to hand straight to a
60
55
  * gagen step. The tag lives in its own field rather than as a `# v7.0.1`
61
56
  * suffix on `uses`, because a `#` inside a YAML scalar forces quoting and
@@ -644,11 +639,7 @@ declare const mintInstallationToken: (input: {
644
639
  * reuse the local verification the factory already published for *this exact
645
640
  * head*? It asks that only on a pull request, so every default-branch push
646
641
  * executes the full hosted suite (#863). Refusing runs hosted CI; it never
647
- * fails the candidate. Three
648
- * repositories had independently grown their own answer to that question and
649
- * had already drifted apart, so the answer lives here once, with the App
650
- * identity, check name, step identity, output names, guard, and every trust
651
- * predicate fixed rather than consumer-configurable.
642
+ * fails the candidate.
652
643
  *
653
644
  * What a consumer chooses is only *what its guarded surface requires*: the
654
645
  * plain profile command objects that surface selects. Everything else below is
@@ -738,8 +729,8 @@ declare const FACTORY_PROOF_GATE_GUARD = "steps.factory-proof.outputs.reuse-proo
738
729
  */
739
730
  declare const FACTORY_PROOF_GATE_IF = "github.event_name == 'pull_request'";
740
731
  /**
741
- * The complete refusal vocabulary. Deliberately few, because these are the
742
- * only distinctions the gate can honestly make from its Checks API reads.
732
+ * The complete refusal vocabulary: the only distinctions the gate can make
733
+ * from its Checks API reads.
743
734
  *
744
735
  * - `proven` a covering, passing, unambiguous proof for this exact head
745
736
  * - `none` no App-verified factory check run at this commit
@@ -750,14 +741,11 @@ declare const FACTORY_PROOF_GATE_IF = "github.event_name == 'pull_request'";
750
741
  * cover every required command
751
742
  * - `ambiguous` two different generations share the newest instant, the
752
743
  * newest repeats another run's verdict with no proof time to
753
- * tell them apart, a run's start time cannot be ranked, or the
754
- * newest pass started before another run at this head was
755
- * posted
744
+ * tell them apart, a run's start time cannot be ranked, the
745
+ * newest pass records no verification start beside another run
746
+ * at this head (#1514), or the newest pass started before
747
+ * another run at this head was posted
756
748
  * - `error` the gate could not reach a decision (fail open)
757
- *
758
- * There is no `reduced`: mode stopped being an authorization condition in
759
- * ADR 0022, so a narrower run that still executed every required command is
760
- * indistinguishable from a full one *for this surface*, which is the point.
761
749
  */
762
750
  declare const FACTORY_PROOF_GATE_REASONS: readonly ["proven", "none", "pending", "failed", "unreadable", "incomplete", "ambiguous", "error"];
763
751
  type FactoryProofGateReason = (typeof FACTORY_PROOF_GATE_REASONS)[number];
@@ -788,31 +776,12 @@ interface ProofReuseCommand {
788
776
  */
789
777
  declare const proofReuseRequiredCommands: (commands: readonly ProofReuseCommand[]) => readonly string[] | undefined;
790
778
  /**
791
- * Resolve command *identities* to their `ProofReuseCommand` objects (ADR
792
- * 0021).
793
- *
794
- * Selection by name is deliberately a consumer decision (proof-surfaces.ts in
795
- * software-factory-hq, the `paitronage:verify` filter in paitronage's
796
- * `verify.ts`): only the consumer knows which named commands a guarded
797
- * surface requires. What both of those implementations independently
798
- * hand-rolled is the same lookup — find each name in the profile's command
799
- * catalog, and refuse to silently shrink the required set when a name has no
800
- * entry. That lookup is what this function is: the mechanic, not the
801
- * selection.
802
- *
803
- * Throwing at generation time (rather than returning `undefined` or an empty
804
- * array) is deliberate: a name with no catalog entry is a mistake in the
805
- * generator source, not a runtime condition a consumer should have to check
806
- * for, and a required set that quietly loses an entry is exactly what makes a
807
- * passing proof trivially "covering".
808
- *
809
- * `selectionLabel` names the failure, nothing else: it is not part of the
810
- * selection this function resolves, only prose a consumer supplies for its
811
- * own thrown error (e.g. HQ's surface name, "core" or "docs"). The message
812
- * deliberately says "the profile's command catalog" rather than naming
813
- * `software-factory.profile.json`: a fleet-generic library must not assume
814
- * every consumer's catalog is that exact file, so this wording differs
815
- * on purpose from the HQ-local message it replaced.
779
+ * Resolve command identities to their `ProofReuseCommand` objects (ADR 0021).
780
+ * Which names a surface requires is the consumer's choice; this is only the
781
+ * lookup. A name with no catalog entry throws at generation time, because a
782
+ * required set that quietly loses an entry makes any passing proof covering.
783
+ * The message says "the profile's command catalog" rather than a file name,
784
+ * since not every consumer's catalog is `software-factory.profile.json`.
816
785
  */
817
786
  declare const resolveProofReuseCommands: (catalog: readonly ProofReuseCommand[], names: readonly string[], selectionLabel?: string) => readonly ProofReuseCommand[];
818
787
  interface FactoryProofGateOptions {
@@ -1222,6 +1191,302 @@ declare const previewCleanupDestroyJobId: (stack: string) => string;
1222
1191
  */
1223
1192
  declare const factoryPreviewCleanupTopology: (options: FactoryPreviewCleanupTopologyOptions) => FactoryPreviewCleanupTopology;
1224
1193
  //#endregion
1194
+ //#region src/preview-cleanup.d.ts
1195
+ /**
1196
+ * Closed-PR preview cleanup and the scheduled orphan sweep (#1540).
1197
+ *
1198
+ * This module owns the consumer-neutral decisions: which stages a closed PR
1199
+ * left behind, which stages belong to PRs that are already closed, how a
1200
+ * stack-scoped destroy outcome reaches the inventory, and whether a stage is
1201
+ * still present afterwards. The consumer keeps its stack list, the destroy
1202
+ * command, the residue reader, credentials and protected-stage policy.
1203
+ *
1204
+ * Every destructive target passes through the one disposable-stage grammar
1205
+ * (`local-pr-<pr>-<sha>`) or the consumer's declared hosted grammar
1206
+ * (`<prefix><pr>`). Anything else is retained, never destroyed.
1207
+ */
1208
+ /** One `{ stack, stage }` row from the consumer's residue reader. */
1209
+ interface PreviewCleanupResidue {
1210
+ readonly stack: string;
1211
+ readonly stage: string;
1212
+ }
1213
+ /** One stack-scoped destroy the cleanup workflow runs. */
1214
+ interface PreviewCleanupTarget {
1215
+ /** Present when a registration supplied the head, so the record can bind it. */
1216
+ readonly headSha?: string;
1217
+ readonly pr: number;
1218
+ readonly stack: string;
1219
+ readonly stage: string;
1220
+ }
1221
+ interface PreviewCleanupStackPolicy {
1222
+ /**
1223
+ * The consumer's hosted per-PR stage prefix, such as `"pr-"` for `pr-123`.
1224
+ * Omit it when the consumer has no hosted per-PR stage.
1225
+ */
1226
+ readonly hostedStagePrefix?: string;
1227
+ /**
1228
+ * Other names the inventory or the residue reader uses for a declared stack,
1229
+ * mapped to that stack. A registration recorded as `preview-deploy-website`
1230
+ * resolves to `website` with `{ "preview-deploy-website": "website" }`.
1231
+ */
1232
+ readonly stackAliases?: Readonly<Record<string, string>>;
1233
+ /** The stacks a cleanup destroys, in the consumer's own names. */
1234
+ readonly stacks: readonly string[];
1235
+ }
1236
+ interface DiscoverPreviewCleanupTargetsInput extends PreviewCleanupStackPolicy {
1237
+ readonly pr: number;
1238
+ /** Inventory registrations for the PR, from `previewProofInventory.list`. */
1239
+ readonly registrations: readonly PreviewProofRegistration[];
1240
+ readonly residue: readonly PreviewCleanupResidue[];
1241
+ }
1242
+ type PreviewCleanupPullRequestState = "closed" | "open";
1243
+ interface DiscoverOrphanedPreviewCleanupTargetsInput extends PreviewCleanupStackPolicy {
1244
+ /**
1245
+ * Targets per run; the rest wait for the next sweep. Default 50. A stage's
1246
+ * targets across its stacks are taken whole, so a run exceeds the cap only
1247
+ * when its first stage alone has more stacks than the cap.
1248
+ */
1249
+ readonly maxTargets?: number;
1250
+ /**
1251
+ * The state GitHub reported for each PR the residue names. A PR missing
1252
+ * from the map is unknown, and its stages are retained.
1253
+ */
1254
+ readonly pullRequestStates: ReadonlyMap<number, PreviewCleanupPullRequestState>;
1255
+ readonly residue: readonly PreviewCleanupResidue[];
1256
+ }
1257
+ interface PreviewCleanupSweep {
1258
+ /**
1259
+ * Orphaned targets left for the next sweep. A stage is never split: all of
1260
+ * its stacks are taken or all are deferred.
1261
+ */
1262
+ readonly deferred: number;
1263
+ readonly targets: readonly PreviewCleanupTarget[];
1264
+ }
1265
+ interface RecordPreviewCleanupOutcomeInput {
1266
+ readonly evidence: readonly string[];
1267
+ readonly headSha?: string;
1268
+ readonly outcome: Exclude<PreviewProofCleanupStatus, "pending">;
1269
+ readonly owner: string;
1270
+ readonly pr: number;
1271
+ readonly repo: string;
1272
+ readonly runUrl?: string;
1273
+ readonly stack: string;
1274
+ readonly stackAliases?: Readonly<Record<string, string>>;
1275
+ readonly stage: string;
1276
+ }
1277
+ interface RecordPreviewCleanupOutcomeAccess {
1278
+ /**
1279
+ * Lists registrations. A workflow `GITHUB_TOKEN` with
1280
+ * `PREVIEW_PROOF_INVENTORY_LIST_PERMISSIONS`: the Factory App token has no
1281
+ * contents permission and cannot serve the list (#825).
1282
+ */
1283
+ readonly read: PreviewProofInventoryAccess;
1284
+ /** Writes the outcome. A Factory App installation token. */
1285
+ readonly write: PreviewProofInventoryAccess;
1286
+ }
1287
+ type RecordPreviewCleanupOutcomeResult = {
1288
+ /** Destroyed but never registered: inventory residue or a hosted stage. */readonly kind: "unregistered";
1289
+ } | {
1290
+ readonly kind: "recorded" | "recovered";
1291
+ readonly registration: PreviewProofRegistration;
1292
+ };
1293
+ interface ReadPullRequestStatesInput {
1294
+ readonly owner: string;
1295
+ readonly prs: readonly number[];
1296
+ readonly repo: string;
1297
+ }
1298
+ interface ReadPullRequestStatesAccess {
1299
+ readonly fetch?: typeof fetch;
1300
+ readonly timeoutMs?: number;
1301
+ /** Needs `pull-requests: read`. */
1302
+ readonly token: string;
1303
+ }
1304
+ /** The GitHub-output key a stack's matrix and presence flag use. */
1305
+ declare const previewCleanupStackOutputKey: (stack: string) => string;
1306
+ /**
1307
+ * Validate a stack policy. Throws on an empty or duplicate stack list, a
1308
+ * stack name a shell or GitHub output could misread, an alias to an
1309
+ * undeclared stack, or a hosted prefix that is not `<word>-`.
1310
+ */
1311
+ declare const assertPreviewCleanupStackPolicy: (policy: PreviewCleanupStackPolicy) => void;
1312
+ /** The PR a hosted stage belongs to, or `null` when it is not one. */
1313
+ declare const parseHostedPreviewStage: (stage: string, prefix: string) => number | null;
1314
+ /**
1315
+ * Targets for one closed PR: its inventory registrations united with the
1316
+ * residue the consumer still sees for it. Only the PR's own `local-pr-<pr>-*`
1317
+ * stages and its hosted stage survive, in declared stacks. A registration
1318
+ * wins a collision so its head SHA reaches the cleanup record. A registration
1319
+ * whose cleanup already passed is skipped unless the residue still lists it.
1320
+ */
1321
+ declare const discoverPreviewCleanupTargets: (input: DiscoverPreviewCleanupTargetsInput) => readonly PreviewCleanupTarget[];
1322
+ /**
1323
+ * The PRs whose disposable stages appear in the residue. The sweep reads
1324
+ * their state before it decides anything.
1325
+ */
1326
+ declare const previewCleanupResiduePullRequests: (policy: PreviewCleanupStackPolicy, residue: readonly PreviewCleanupResidue[]) => readonly number[];
1327
+ /**
1328
+ * Targets for the scheduled sweep: disposable residue whose PR GitHub
1329
+ * reports closed. It fails closed. A stage that does not parse as disposable,
1330
+ * a stack the consumer did not declare, and a PR that is open or whose state
1331
+ * is unknown are all retained.
1332
+ */
1333
+ declare const discoverOrphanedPreviewCleanupTargets: (input: DiscoverOrphanedPreviewCleanupTargetsInput) => PreviewCleanupSweep;
1334
+ /**
1335
+ * The `$GITHUB_OUTPUT` lines the cleanup workflow's discover job publishes:
1336
+ * `has_targets`, `targets`, and for each declared stack `has_<key>` and
1337
+ * `<key>_matrix`. A stack with no target still gets `has_<key>=false`, so
1338
+ * its destroy job skips instead of expanding an empty matrix.
1339
+ */
1340
+ declare const previewCleanupGithubOutput: (policy: PreviewCleanupStackPolicy, targets: readonly PreviewCleanupTarget[]) => string;
1341
+ /** Parse untrusted residue JSON: an array of `{ stack, stage }` rows. */
1342
+ declare const parsePreviewCleanupResidue: (value: unknown) => readonly PreviewCleanupResidue[];
1343
+ /**
1344
+ * Parse untrusted target JSON (the discover job's `targets` output). Every
1345
+ * row must still be a disposable stage owned by its own PR, so a tampered
1346
+ * output cannot widen the audit or a record.
1347
+ */
1348
+ declare const parsePreviewCleanupTargets: (policy: PreviewCleanupStackPolicy, value: unknown) => readonly PreviewCleanupTarget[];
1349
+ /**
1350
+ * The whole-stage audit after every destroy. Any residue row whose stage
1351
+ * is a target stage fails it, whatever stack the reader assigned the row,
1352
+ * because a sibling stack's leftovers are the same stage's residue.
1353
+ */
1354
+ declare const assertPreviewCleanupTargetsAbsent: (targets: readonly PreviewCleanupTarget[], residue: readonly PreviewCleanupResidue[]) => void;
1355
+ /**
1356
+ * Record one stack destroy's outcome on the inventory registration it
1357
+ * cleaned up. A stage nothing registered (residue-only, or a hosted stage)
1358
+ * returns `unregistered` without writing. A registration whose last cleanup
1359
+ * failed is recovered through the same cleanup transition.
1360
+ */
1361
+ declare const recordPreviewCleanupOutcome: (input: RecordPreviewCleanupOutcomeInput, access: RecordPreviewCleanupOutcomeAccess) => Promise<RecordPreviewCleanupOutcomeResult>;
1362
+ /**
1363
+ * Ask GitHub for each PR's state. A PR GitHub does not know is left out of
1364
+ * the map, so the sweep retains its stages.
1365
+ */
1366
+ declare const readPullRequestStates: (input: ReadPullRequestStatesInput, access: ReadPullRequestStatesAccess) => Promise<ReadonlyMap<number, PreviewCleanupPullRequestState>>;
1367
+ //#endregion
1368
+ //#region src/preview-cleanup-workflow.d.ts
1369
+ declare const FACTORY_PREVIEW_CLEANUP_DISCOVER_JOB_ID = "discover";
1370
+ declare const FACTORY_PREVIEW_CLEANUP_DISCOVER_JOB_NAME = "Discover preview cleanup targets";
1371
+ declare const FACTORY_PREVIEW_CLEANUP_DISCOVER_STEP_ID = "targets";
1372
+ declare const FACTORY_PREVIEW_CLEANUP_DESTROY_STEP_ID = "destroy";
1373
+ declare const FACTORY_PREVIEW_CLEANUP_APP_TOKEN_STEP_ID = "factory-app-token";
1374
+ declare const FACTORY_PREVIEW_CLEANUP_DEFAULT_SWEEP_CRON = "23 6 * * *";
1375
+ /**
1376
+ * A closed pull request whose head lives in this repository. A fork's head
1377
+ * never reaches a job that holds cleanup credentials.
1378
+ */
1379
+ 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";
1380
+ /**
1381
+ * The sweep: the schedule, which GitHub always runs on the default branch,
1382
+ * or a manual dispatch from the default branch.
1383
+ */
1384
+ 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))";
1385
+ /**
1386
+ * The ref every cleanup job checks out: the default branch's trusted code,
1387
+ * never the closed PR's head. Empty on `schedule`, where the checkout
1388
+ * already defaults to the default branch.
1389
+ */
1390
+ declare const FACTORY_PREVIEW_CLEANUP_CHECKOUT_REF = "${{ github.event.repository.default_branch }}";
1391
+ interface FactoryPreviewCleanupWorkflowOptions extends PreviewCleanupStackPolicy {
1392
+ readonly cli?: string;
1393
+ /**
1394
+ * The workflow's concurrency group for one destroy. It may read
1395
+ * `matrix.stack`, `matrix.stage` and `matrix.pr`. Share it with the
1396
+ * consumer's deploy job when a deploy and a destroy must not race.
1397
+ */
1398
+ readonly concurrencyGroup?: string;
1399
+ /** The pinned `actions/create-github-app-token` the caller declared. */
1400
+ readonly createGithubAppToken: PinnedAction;
1401
+ /**
1402
+ * One shell line that destroys `$FACTORY_PREVIEW_CLEANUP_STAGE` of
1403
+ * `$FACTORY_PREVIEW_CLEANUP_STACK` and exits non-zero when it did not. It
1404
+ * may append evidence lines to `$FACTORY_PREVIEW_CLEANUP_EVIDENCE`.
1405
+ */
1406
+ readonly destroyCommand: string;
1407
+ /**
1408
+ * The GitHub environment every job that holds cleanup credentials runs
1409
+ * in. Its protection rules, not a production deploy flag, gate cleanup.
1410
+ */
1411
+ readonly environment: string;
1412
+ /**
1413
+ * One shell line that prints the consumer's residue as JSON
1414
+ * `[{ "stack": …, "stage": … }]` on stdout: Alchemy state and any physical
1415
+ * resources the consumer can attribute to a stack and stage.
1416
+ */
1417
+ readonly residueCommand: string;
1418
+ /** The scheduled orphan sweep. Pass `false` to generate PR-close cleanup only. */
1419
+ readonly sweep?: false | {
1420
+ /** Defaults to `FACTORY_PREVIEW_CLEANUP_DEFAULT_SWEEP_CRON`. */readonly cron?: string;
1421
+ /**
1422
+ * Targets per sweep run. Defaults to 50. Stages are taken whole, so a
1423
+ * run exceeds it only when its first stage has more stacks than this.
1424
+ */
1425
+ readonly maxTargets?: number;
1426
+ };
1427
+ }
1428
+ interface FactoryPreviewCleanupWorkflowJob {
1429
+ readonly environment: string;
1430
+ readonly if: string;
1431
+ readonly jobId: string;
1432
+ readonly jobName: string;
1433
+ readonly permissions: Readonly<Record<string, "read" | "write">>;
1434
+ /** Append after the caller's setup steps. */
1435
+ readonly steps: readonly WorkflowStep[];
1436
+ }
1437
+ interface FactoryPreviewCleanupWorkflowDiscoverJob extends FactoryPreviewCleanupWorkflowJob {
1438
+ readonly outputs: Readonly<Record<string, string>>;
1439
+ }
1440
+ interface FactoryPreviewCleanupWorkflowDestroyJob extends FactoryPreviewCleanupWorkflowJob {
1441
+ readonly concurrency: {
1442
+ readonly cancelInProgress: false;
1443
+ readonly group: string;
1444
+ };
1445
+ /** Always the discover job's id. */
1446
+ readonly needs: readonly string[];
1447
+ readonly stack: string;
1448
+ readonly strategy: {
1449
+ readonly failFast: false;
1450
+ readonly matrix: {
1451
+ readonly include: string;
1452
+ };
1453
+ };
1454
+ }
1455
+ interface FactoryPreviewCleanupWorkflowAuditJob extends FactoryPreviewCleanupWorkflowJob {
1456
+ /** Merge into the job's own `env` alongside the caller's credentials. */
1457
+ readonly env: Readonly<Record<string, string>>;
1458
+ /** The discover job, then every destroy job. */
1459
+ readonly needs: readonly string[];
1460
+ }
1461
+ interface FactoryPreviewCleanupWorkflow {
1462
+ readonly auditJob: FactoryPreviewCleanupWorkflowAuditJob;
1463
+ /** Pass to the checkout step of every job. */
1464
+ readonly checkoutRef: typeof FACTORY_PREVIEW_CLEANUP_CHECKOUT_REF;
1465
+ readonly destroyJobs: readonly FactoryPreviewCleanupWorkflowDestroyJob[];
1466
+ readonly discoverJob: FactoryPreviewCleanupWorkflowDiscoverJob;
1467
+ readonly on: Readonly<Record<string, unknown>>;
1468
+ readonly permissions: Readonly<{
1469
+ contents: "read";
1470
+ }>;
1471
+ }
1472
+ /**
1473
+ * Generate the factory-owned closed-PR preview cleanup and orphan sweep
1474
+ * (#1540) on top of `factoryPreviewCleanupTopology`:
1475
+ *
1476
+ * - `discover` reads the consumer's residue and, for a closed same-repo PR,
1477
+ * unites it with the PR's inventory registrations; for the sweep, keeps the
1478
+ * residue of PRs GitHub reports closed. It publishes one matrix per stack.
1479
+ * - one destroy job per stack runs the consumer's destroy for each matrix
1480
+ * target, then records the outcome on the inventory with the Factory App.
1481
+ * - one stage-wide audit re-reads the residue after every destroy and fails
1482
+ * if any target stage remains, in any stack.
1483
+ *
1484
+ * Every credentialed job runs in the consumer's GitHub environment, never
1485
+ * behind a production deploy flag. The caller prepends its own setup steps
1486
+ * (checked out at `checkoutRef`), and adds `runsOn` and credential `env`.
1487
+ */
1488
+ declare const factoryPreviewCleanupWorkflow: (options: FactoryPreviewCleanupWorkflowOptions) => FactoryPreviewCleanupWorkflow;
1489
+ //#endregion
1225
1490
  //#region src/preview-receipt-workflow.d.ts
1226
1491
  interface FactoryPreviewReceiptWorkflowOptions {
1227
1492
  readonly target: string;
@@ -1688,4 +1953,4 @@ declare const assertWorkflowShellParses: (yaml: string, options: {
1688
1953
  readonly source: string;
1689
1954
  }) => void;
1690
1955
  //#endregion
1691
- export { ALCHEMY_BASELINE, type AlchemyBaselinePackageJson, type AssertAlchemyBaselineInput, type BundleAlchemyEntryOptions, type CheckoutStepOptions, EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER, type ExecuteAlchemyEntryOptions, type ExecuteAlchemyEntryResult, FACTORY_APP_BROKER_ORIGIN, FACTORY_APP_BROKER_PATH, FACTORY_APP_BROKER_TOKEN_PERMISSIONS, FACTORY_CANDIDATE_IMPACT_BASIS_OUTPUT, FACTORY_CANDIDATE_IMPACT_DECISION_OUTPUT, FACTORY_CANDIDATE_IMPACT_INERT_OUTPUT, FACTORY_CANDIDATE_IMPACT_STEP_ID, FACTORY_CANDIDATE_IMPACT_UNSUBSCRIBED_OUTPUT, FACTORY_CANDIDATE_PULL_REQUEST_TYPES, FACTORY_CURSOR_OIDC_AUDIENCE, FACTORY_CURSOR_OIDC_ISSUER, FACTORY_CURSOR_OIDC_JWKS_URL, FACTORY_CURSOR_OIDC_MANAGED_RUNTIME, FACTORY_LIFECYCLE_CONTRACT_JOB_ID, FACTORY_LIFECYCLE_CONTRACT_JOB_NAME, FACTORY_MERGE_FREEZE_APP_TOKEN_STEP_ID, FACTORY_MERGE_FREEZE_CHECK_NAME, FACTORY_MERGE_FREEZE_IF, FACTORY_MERGE_FREEZE_JOB_ID, FACTORY_MERGE_FREEZE_JOB_NAME, FACTORY_MERGE_FREEZE_PERMISSIONS, FACTORY_MERGE_FREEZE_VERIFY_RESULT_EXPRESSION, FACTORY_MERGE_TARGET_REF_CONDITION, FACTORY_PREVIEW_CLEANUP_AUDIT_JOB_ID, FACTORY_PREVIEW_CLEANUP_AUDIT_JOB_NAME, FACTORY_PRODUCTION_IMPACT_BASIS_OUTPUT, FACTORY_PRODUCTION_IMPACT_DECISION_OUTPUT, FACTORY_PRODUCTION_IMPACT_STEP_ID, FACTORY_PRODUCTION_IMPACT_UNSUBSCRIBED_OUTPUT, FACTORY_PROOF_GATE_APP_ID, FACTORY_PROOF_GATE_CHECK_NAME, FACTORY_PROOF_GATE_GUARD, FACTORY_PROOF_GATE_IF, FACTORY_PROOF_GATE_MODE_OUTPUT, FACTORY_PROOF_GATE_OUTPUT, FACTORY_PROOF_GATE_REASONS, FACTORY_PROOF_GATE_REASON_OUTPUT, FACTORY_PROOF_GATE_SHELL, FACTORY_PROOF_GATE_SOURCE_URL_OUTPUT, FACTORY_PROOF_GATE_STEP_ID, FACTORY_PROOF_GATE_STEP_NAME, FACTORY_PR_STATUS_HUD_APP_TOKEN_STEP_ID, FACTORY_PR_STATUS_HUD_CONCURRENCY, FACTORY_PR_STATUS_HUD_IF, FACTORY_PR_STATUS_HUD_JOB_ID, FACTORY_PR_STATUS_HUD_JOB_NAME, FACTORY_PR_STATUS_HUD_PERMISSIONS, FACTORY_PR_STATUS_HUD_PLAN_PATH, FACTORY_PUSH_IDENTITY_SCHEMA_VERSION, type FactoryCandidateImpactWorkflow, type FactoryCandidateImpactWorkflowOptions, type FactoryLifecycleContractLane, type FactoryLifecycleContractLaneOptions, type FactoryMergeFreezeJob, type FactoryMergeFreezeJobOptions, type FactoryPrStatusHudWorkflow, type FactoryPrStatusHudWorkflowOptions, type FactoryPreviewCleanupAuditJob, type FactoryPreviewCleanupDestroyJob, type FactoryPreviewCleanupTopology, type FactoryPreviewCleanupTopologyOptions, type FactoryPreviewReceiptWorkflow, type FactoryPreviewReceiptWorkflowOptions, type FactoryProductionImpactWorkflow, type FactoryProductionImpactWorkflowOptions, type FactoryProofGateOptions, type FactoryProofGateReason, type FactoryProofGateStep, type FactoryProofReusePresentationOptions, type FactoryProofReuseSummaryStep, type FactoryProofTimingStartStep, type FactoryPushIdentityConsumer, type FactoryPushIdentityConsumerOptions, type FactoryPushIdentityDisposition, type FactoryPushIdentityEnvelope, type FactoryPushIdentityProducer, type FactoryPushIdentityProducerOptions, type FactoryRunnerDecision, type FactoryRunnerHome, type FactoryRunnerKind, type FactoryRunnerOverride, type FactoryVerifyRunner, type FactoryVerifyRunnerMismatch, type FactoryVerifyRunnerPolicyInput, type FactoryVerifyRunnerPolicyReport, type FactoryVerifyRunnerTable, type FactoryWorkflowArtifact, type FactoryWorkflowOptions, type FactoryWorkflowSetupOptions, GitHubApiError, GitHubAppTokenTransportError, type GithubAppCredentials, type GithubAppInstallationPermissions, type GithubAppTokenOptions, type InstallStepOptions, type LocalPreviewStage, type LocalPreviewStageOptions, NODE_PNPM_ACTION_FAMILY_NODE24, type NodePnpmActionFamily, PREVIEW_PROOF_INVENTORY_CHECK_NAME, PREVIEW_PROOF_INVENTORY_LIST_PERMISSIONS, type ParseLocalPreviewStageExpected, type ParsedLocalPreviewStage, type PinnedAction, type PreviewProofCandidate, type PreviewProofCleanupOutcome, type PreviewProofCleanupStatus, type PreviewProofEnvelopeEvidence, type PreviewProofInventoryAccess, type PreviewProofInventoryCleanupInput, type PreviewProofInventoryListInput, type PreviewProofInventoryPersistInput, type PreviewProofInventoryStore, type PreviewProofInventoryTransport, type PreviewProofLifecycleEvent, type PreviewProofLifecycleState, type PreviewProofRegistration, type PreviewProofResolveQuery, PreviewProofTransportError, type ProofReuseCommand, type ProofReuseCoverageInput, type ProofReuseCoverageReport, SETUP_STEP_ROLES, type SetupNodeStepOptions, type SetupStepRole, UPLOAD_ARTIFACT, VITEST_PROFILE_SCHEMA_VERSION, VITEST_PROFILE_TOOL, type VitestJsonReport, type VitestProfile, type VitestProfileDependencies, type VitestProfileDurationSummary, type VitestProfileEnvironment, VitestProfileError, type VitestProfileOptions, type VitestProfileReadResult, type VitestProfileSample, type VitestProfileSampleExecution, type VitestTestStatus, type WorkflowShellParseFailure, type WorkflowStep, assertAlchemyBaseline, assertProofReuseCoverage, assertVerifyRunnerPolicy, assertWorkflowShellParses, bundleAlchemyEntry, captureVitestProfileEnvironment, executeAlchemyEntry, factoryCandidateImpactWorkflow, factoryCandidateOrPushCondition, factoryLifecycleContractLane, factoryMergeFreezeJob, factoryMergeFreezeScript, factoryPrStatusHudWorkflow, factoryPreviewCleanupTopology, factoryPreviewReceiptWorkflow, factoryProductionImpactWorkflow, factoryProofGateScript, factoryProofGateStep, factoryProofReuseSummaryStep, factoryProofTimingStartStep, factoryPushIdentityConsumer, factoryPushIdentityProducer, factoryVerifyRunner, factoryWorkflow, githubAppJwt, isLocalPreviewStage, localPreviewStage, mintInstallationToken, normalizeVitestProfileSample, parseLocalPreviewStage, previewCleanupDestroyJobId, previewProofInventory, previewProofLifecycle, productionImpactTargetOutput, proofReuseCoverage, proofReuseRequiredCommands, readVitestProfileDocument, resolveProofReuseCommands, runVitestProfile, setupStepsForRoles, verifyRunnerPolicy, workflowRunBlocks, workflowShellParseFailures, writeVitestProfile };
1956
+ export { ALCHEMY_BASELINE, type AlchemyBaselinePackageJson, type AssertAlchemyBaselineInput, type BundleAlchemyEntryOptions, type CheckoutStepOptions, type DiscoverOrphanedPreviewCleanupTargetsInput, type DiscoverPreviewCleanupTargetsInput, EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER, type ExecuteAlchemyEntryOptions, type ExecuteAlchemyEntryResult, FACTORY_APP_BROKER_ORIGIN, FACTORY_APP_BROKER_PATH, FACTORY_APP_BROKER_TOKEN_PERMISSIONS, FACTORY_CANDIDATE_IMPACT_BASIS_OUTPUT, FACTORY_CANDIDATE_IMPACT_DECISION_OUTPUT, FACTORY_CANDIDATE_IMPACT_INERT_OUTPUT, FACTORY_CANDIDATE_IMPACT_STEP_ID, FACTORY_CANDIDATE_IMPACT_UNSUBSCRIBED_OUTPUT, FACTORY_CANDIDATE_PULL_REQUEST_TYPES, FACTORY_CURSOR_OIDC_AUDIENCE, FACTORY_CURSOR_OIDC_ISSUER, FACTORY_CURSOR_OIDC_JWKS_URL, FACTORY_CURSOR_OIDC_MANAGED_RUNTIME, FACTORY_LIFECYCLE_CONTRACT_JOB_ID, FACTORY_LIFECYCLE_CONTRACT_JOB_NAME, FACTORY_MERGE_FREEZE_APP_TOKEN_STEP_ID, FACTORY_MERGE_FREEZE_CHECK_NAME, FACTORY_MERGE_FREEZE_IF, FACTORY_MERGE_FREEZE_JOB_ID, FACTORY_MERGE_FREEZE_JOB_NAME, FACTORY_MERGE_FREEZE_PERMISSIONS, FACTORY_MERGE_FREEZE_VERIFY_RESULT_EXPRESSION, FACTORY_MERGE_TARGET_REF_CONDITION, FACTORY_PREVIEW_CLEANUP_APP_TOKEN_STEP_ID, FACTORY_PREVIEW_CLEANUP_AUDIT_JOB_ID, FACTORY_PREVIEW_CLEANUP_AUDIT_JOB_NAME, FACTORY_PREVIEW_CLEANUP_CHECKOUT_REF, FACTORY_PREVIEW_CLEANUP_DEFAULT_SWEEP_CRON, FACTORY_PREVIEW_CLEANUP_DESTROY_STEP_ID, FACTORY_PREVIEW_CLEANUP_DISCOVER_JOB_ID, FACTORY_PREVIEW_CLEANUP_DISCOVER_JOB_NAME, FACTORY_PREVIEW_CLEANUP_DISCOVER_STEP_ID, FACTORY_PREVIEW_CLEANUP_PR_CLOSED_CONDITION, FACTORY_PREVIEW_CLEANUP_SWEEP_CONDITION, FACTORY_PRODUCTION_IMPACT_BASIS_OUTPUT, FACTORY_PRODUCTION_IMPACT_DECISION_OUTPUT, FACTORY_PRODUCTION_IMPACT_STEP_ID, FACTORY_PRODUCTION_IMPACT_UNSUBSCRIBED_OUTPUT, FACTORY_PROOF_GATE_APP_ID, FACTORY_PROOF_GATE_CHECK_NAME, FACTORY_PROOF_GATE_GUARD, FACTORY_PROOF_GATE_IF, FACTORY_PROOF_GATE_MODE_OUTPUT, FACTORY_PROOF_GATE_OUTPUT, FACTORY_PROOF_GATE_REASONS, FACTORY_PROOF_GATE_REASON_OUTPUT, FACTORY_PROOF_GATE_SHELL, FACTORY_PROOF_GATE_SOURCE_URL_OUTPUT, FACTORY_PROOF_GATE_STEP_ID, FACTORY_PROOF_GATE_STEP_NAME, FACTORY_PR_STATUS_HUD_APP_TOKEN_STEP_ID, FACTORY_PR_STATUS_HUD_CONCURRENCY, FACTORY_PR_STATUS_HUD_IF, FACTORY_PR_STATUS_HUD_JOB_ID, FACTORY_PR_STATUS_HUD_JOB_NAME, FACTORY_PR_STATUS_HUD_PERMISSIONS, FACTORY_PR_STATUS_HUD_PLAN_PATH, FACTORY_PUSH_IDENTITY_SCHEMA_VERSION, type FactoryCandidateImpactWorkflow, type FactoryCandidateImpactWorkflowOptions, type FactoryLifecycleContractLane, type FactoryLifecycleContractLaneOptions, type FactoryMergeFreezeJob, type FactoryMergeFreezeJobOptions, type FactoryPrStatusHudWorkflow, type FactoryPrStatusHudWorkflowOptions, type FactoryPreviewCleanupAuditJob, type FactoryPreviewCleanupDestroyJob, type FactoryPreviewCleanupTopology, type FactoryPreviewCleanupTopologyOptions, type FactoryPreviewCleanupWorkflow, type FactoryPreviewCleanupWorkflowAuditJob, type FactoryPreviewCleanupWorkflowDestroyJob, type FactoryPreviewCleanupWorkflowDiscoverJob, type FactoryPreviewCleanupWorkflowJob, type FactoryPreviewCleanupWorkflowOptions, type FactoryPreviewReceiptWorkflow, type FactoryPreviewReceiptWorkflowOptions, type FactoryProductionImpactWorkflow, type FactoryProductionImpactWorkflowOptions, type FactoryProofGateOptions, type FactoryProofGateReason, type FactoryProofGateStep, type FactoryProofReusePresentationOptions, type FactoryProofReuseSummaryStep, type FactoryProofTimingStartStep, type FactoryPushIdentityConsumer, type FactoryPushIdentityConsumerOptions, type FactoryPushIdentityDisposition, type FactoryPushIdentityEnvelope, type FactoryPushIdentityProducer, type FactoryPushIdentityProducerOptions, type FactoryRunnerDecision, type FactoryRunnerHome, type FactoryRunnerKind, type FactoryRunnerOverride, type FactoryVerifyRunner, type FactoryVerifyRunnerMismatch, type FactoryVerifyRunnerPolicyInput, type FactoryVerifyRunnerPolicyReport, type FactoryVerifyRunnerTable, type FactoryWorkflowArtifact, type FactoryWorkflowOptions, type FactoryWorkflowSetupOptions, GitHubApiError, GitHubAppTokenTransportError, type GithubAppCredentials, type GithubAppInstallationPermissions, type GithubAppTokenOptions, type InstallStepOptions, type LocalPreviewStage, type LocalPreviewStageOptions, NODE_PNPM_ACTION_FAMILY_NODE24, type NodePnpmActionFamily, PREVIEW_PROOF_INVENTORY_CHECK_NAME, PREVIEW_PROOF_INVENTORY_LIST_PERMISSIONS, type ParseLocalPreviewStageExpected, type ParsedLocalPreviewStage, type PinnedAction, type PreviewCleanupPullRequestState, type PreviewCleanupResidue, type PreviewCleanupStackPolicy, type PreviewCleanupSweep, type PreviewCleanupTarget, type PreviewProofCandidate, type PreviewProofCleanupOutcome, type PreviewProofCleanupStatus, type PreviewProofEnvelopeEvidence, type PreviewProofInventoryAccess, type PreviewProofInventoryCleanupInput, type PreviewProofInventoryListInput, type PreviewProofInventoryPersistInput, type PreviewProofInventoryStore, type PreviewProofInventoryTransport, type PreviewProofLifecycleEvent, type PreviewProofLifecycleState, type PreviewProofRegistration, type PreviewProofResolveQuery, PreviewProofTransportError, type ProofReuseCommand, type ProofReuseCoverageInput, type ProofReuseCoverageReport, type ReadPullRequestStatesAccess, type ReadPullRequestStatesInput, type RecordPreviewCleanupOutcomeAccess, type RecordPreviewCleanupOutcomeInput, type RecordPreviewCleanupOutcomeResult, SETUP_STEP_ROLES, type SetupNodeStepOptions, type SetupStepRole, UPLOAD_ARTIFACT, VITEST_PROFILE_SCHEMA_VERSION, VITEST_PROFILE_TOOL, type VitestJsonReport, type VitestProfile, type VitestProfileDependencies, type VitestProfileDurationSummary, type VitestProfileEnvironment, VitestProfileError, type VitestProfileOptions, type VitestProfileReadResult, type VitestProfileSample, type VitestProfileSampleExecution, type VitestTestStatus, type WorkflowShellParseFailure, type WorkflowStep, assertAlchemyBaseline, assertPreviewCleanupStackPolicy, assertPreviewCleanupTargetsAbsent, assertProofReuseCoverage, assertVerifyRunnerPolicy, assertWorkflowShellParses, bundleAlchemyEntry, captureVitestProfileEnvironment, discoverOrphanedPreviewCleanupTargets, discoverPreviewCleanupTargets, executeAlchemyEntry, factoryCandidateImpactWorkflow, factoryCandidateOrPushCondition, factoryLifecycleContractLane, factoryMergeFreezeJob, factoryMergeFreezeScript, factoryPrStatusHudWorkflow, factoryPreviewCleanupTopology, factoryPreviewCleanupWorkflow, factoryPreviewReceiptWorkflow, factoryProductionImpactWorkflow, factoryProofGateScript, factoryProofGateStep, factoryProofReuseSummaryStep, factoryProofTimingStartStep, factoryPushIdentityConsumer, factoryPushIdentityProducer, factoryVerifyRunner, factoryWorkflow, githubAppJwt, isLocalPreviewStage, localPreviewStage, mintInstallationToken, normalizeVitestProfileSample, parseHostedPreviewStage, parseLocalPreviewStage, parsePreviewCleanupResidue, parsePreviewCleanupTargets, previewCleanupDestroyJobId, previewCleanupGithubOutput, previewCleanupResiduePullRequests, previewCleanupStackOutputKey, previewProofInventory, previewProofLifecycle, productionImpactTargetOutput, proofReuseCoverage, proofReuseRequiredCommands, readPullRequestStates, readVitestProfileDocument, recordPreviewCleanupOutcome, resolveProofReuseCommands, runVitestProfile, setupStepsForRoles, verifyRunnerPolicy, workflowRunBlocks, workflowShellParseFailures, writeVitestProfile };