@patronage/factory-ci 1.0.0-alpha.44 → 1.0.0-alpha.46

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.js CHANGED
@@ -1,5 +1,5 @@
1
- import { t as bundleAlchemyEntry } from "./bundle-alchemy-entry-CT5hCphA.js";
2
- import { a as localPreviewStage, c as assertAlchemyBaseline, i as isLocalPreviewStage, n as executeAlchemyEntry, o as parseLocalPreviewStage, s as ALCHEMY_BASELINE, t as EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER } from "./execute-alchemy-entry-C2ZhsNTN.js";
1
+ import { t as bundleAlchemyEntry } from "./bundle-alchemy-entry-Ba1Ebp91.js";
2
+ import { a as localPreviewStage, c as assertAlchemyBaseline, i as isLocalPreviewStage, n as executeAlchemyEntry, o as parseLocalPreviewStage, s as ALCHEMY_BASELINE, t as EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER } from "./execute-alchemy-entry-CxQrjSg8.js";
3
3
  import { createRequire } from "node:module";
4
4
  import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
5
5
  import path from "node:path";
@@ -10,7 +10,7 @@ import { execFileSync, spawn } from "node:child_process";
10
10
  import { once } from "node:events";
11
11
  import { arch, availableParallelism, cpus, platform, release, totalmem } from "node:os";
12
12
  import { performance } from "node:perf_hooks";
13
- //#region src/actions.ts
13
+ // src/actions.ts
14
14
  /**
15
15
  * The canonical Node 24 family shared by factory-project workflows.
16
16
  *
@@ -45,8 +45,7 @@ const UPLOAD_ARTIFACT = {
45
45
  tag: "v4.6.2",
46
46
  uses: "actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02"
47
47
  };
48
- //#endregion
49
- //#region src/candidate-lifecycle.ts
48
+ // src/candidate-lifecycle.ts
50
49
  /**
51
50
  * Pull-request events that can create or refresh a Factory candidate run.
52
51
  *
@@ -71,8 +70,7 @@ const factoryCandidateOrPushCondition = (candidateCondition) => {
71
70
  ...candidateCondition ? [candidateCondition] : []
72
71
  ].join(" && ")})`].join(" || ");
73
72
  };
74
- //#endregion
75
- //#region src/preview-proof-lifecycle.ts
73
+ // src/preview-proof-lifecycle.ts
76
74
  const EMPTY_STATE = Object.freeze({ registrations: Object.freeze([]) });
77
75
  const DETACHED_PROOF_BRANCH = "(detached)";
78
76
  /**
@@ -174,8 +172,7 @@ const previewProofLifecycle = {
174
172
  resolve,
175
173
  transition
176
174
  };
177
- //#endregion
178
- //#region src/github-transport.ts
175
+ // src/github-transport.ts
179
176
  /**
180
177
  * One GitHub JSON request with bounded transport retries (#830, #923).
181
178
  *
@@ -285,18 +282,14 @@ const githubJson$1 = async (options, errors) => {
285
282
  if (outcome.ok) return outcome.value;
286
283
  throw errors.transport(outcome, attempts);
287
284
  };
288
- //#endregion
289
- //#region src/github-app-token.ts
285
+ // src/github-app-token.ts
290
286
  /**
291
287
  * Minting a GitHub App installation token: the RS256 app JWT, the optional
292
288
  * installation lookup, and the token exchange (#617).
293
289
  *
294
- * Two projects had grown the same three steps independently — the factory's
295
- * check-run publisher and paitronage's proof-comment publisher — which is the
296
- * admitted-on-repetition bar. Only the *mechanism* lives here. Where the
297
- * private key comes from, how the app id is configured, and what the token is
298
- * then used for stay with each consumer: this module is handed credentials and
299
- * returns a token.
290
+ * Only the *mechanism* lives here. Where the private key comes from, how the
291
+ * app id is configured, and what the token is then used for stay with each
292
+ * consumer: this module is handed credentials and returns a token.
300
293
  */
301
294
  /** The default request budget, matching the factory's other GitHub writes. */
302
295
  const DEFAULT_TIMEOUT_MS$2 = 5e3;
@@ -385,7 +378,8 @@ const mintInstallationToken = async (input, options = {}) => {
385
378
  if (typeof installation.id !== "number") throw new TypeError("GitHub App installation response omitted id");
386
379
  installationId = installation.id;
387
380
  } else {
388
- const accountLogin = installationAccountLogin(await githubAppJson(request, `https://api.github.com/app/installations/${installationId}`, jwt, "GET", budget));
381
+ const pinned = await githubAppJson(request, `https://api.github.com/app/installations/${installationId}`, jwt, "GET", budget);
382
+ const accountLogin = installationAccountLogin(pinned);
389
383
  if (accountLogin === void 0) throw new TypeError("GitHub App installation response omitted account login");
390
384
  if (accountLogin.toLowerCase() !== input.owner.toLowerCase()) throw new Error(`GitHub App installation ${installationId} belongs to ${accountLogin}, not ${input.owner}; refusing to mint a token for ${input.owner}/${input.repo}`);
391
385
  }
@@ -400,8 +394,7 @@ const mintInstallationToken = async (input, options = {}) => {
400
394
  if (typeof minted.token !== "string") throw new TypeError("GitHub App token response omitted token");
401
395
  return minted.token;
402
396
  };
403
- //#endregion
404
- //#region src/proof-reuse-gate.ts
397
+ // src/proof-reuse-gate.ts
405
398
  /**
406
399
  * The GitHub-side **proof-reuse gate** (ADR 0022, #309, #317).
407
400
  *
@@ -409,11 +402,7 @@ const mintInstallationToken = async (input, options = {}) => {
409
402
  * reuse the local verification the factory already published for *this exact
410
403
  * head*? It asks that only on a pull request, so every default-branch push
411
404
  * executes the full hosted suite (#863). Refusing runs hosted CI; it never
412
- * fails the candidate. Three
413
- * repositories had independently grown their own answer to that question and
414
- * had already drifted apart, so the answer lives here once, with the App
415
- * identity, check name, step identity, output names, guard, and every trust
416
- * predicate fixed rather than consumer-configurable.
405
+ * fails the candidate.
417
406
  *
418
407
  * What a consumer chooses is only *what its guarded surface requires*: the
419
408
  * plain profile command objects that surface selects. Everything else below is
@@ -522,8 +511,8 @@ const FACTORY_PROOF_GATE_GUARD = `steps.${FACTORY_PROOF_GATE_STEP_ID}.outputs.${
522
511
  */
523
512
  const FACTORY_PROOF_GATE_IF = "github.event_name == 'pull_request'";
524
513
  /**
525
- * The complete refusal vocabulary. Deliberately few, because these are the
526
- * only distinctions the gate can honestly make from its Checks API reads.
514
+ * The complete refusal vocabulary: the only distinctions the gate can make
515
+ * from its Checks API reads.
527
516
  *
528
517
  * - `proven` a covering, passing, unambiguous proof for this exact head
529
518
  * - `none` no App-verified factory check run at this commit
@@ -534,14 +523,11 @@ const FACTORY_PROOF_GATE_IF = "github.event_name == 'pull_request'";
534
523
  * cover every required command
535
524
  * - `ambiguous` two different generations share the newest instant, the
536
525
  * newest repeats another run's verdict with no proof time to
537
- * tell them apart, a run's start time cannot be ranked, or the
538
- * newest pass started before another run at this head was
539
- * posted
526
+ * tell them apart, a run's start time cannot be ranked, the
527
+ * newest pass records no verification start beside another run
528
+ * at this head (#1514), or the newest pass started before
529
+ * another run at this head was posted
540
530
  * - `error` the gate could not reach a decision (fail open)
541
- *
542
- * There is no `reduced`: mode stopped being an authorization condition in
543
- * ADR 0022, so a narrower run that still executed every required command is
544
- * indistinguishable from a full one *for this surface*, which is the point.
545
531
  */
546
532
  const FACTORY_PROOF_GATE_REASONS = [
547
533
  "proven",
@@ -622,31 +608,12 @@ const proofReuseRequiredCommands = (commands) => {
622
608
  return names.toSorted();
623
609
  };
624
610
  /**
625
- * Resolve command *identities* to their `ProofReuseCommand` objects (ADR
626
- * 0021).
627
- *
628
- * Selection by name is deliberately a consumer decision (proof-surfaces.ts in
629
- * software-factory-hq, the `paitronage:verify` filter in paitronage's
630
- * `verify.ts`): only the consumer knows which named commands a guarded
631
- * surface requires. What both of those implementations independently
632
- * hand-rolled is the same lookup — find each name in the profile's command
633
- * catalog, and refuse to silently shrink the required set when a name has no
634
- * entry. That lookup is what this function is: the mechanic, not the
635
- * selection.
636
- *
637
- * Throwing at generation time (rather than returning `undefined` or an empty
638
- * array) is deliberate: a name with no catalog entry is a mistake in the
639
- * generator source, not a runtime condition a consumer should have to check
640
- * for, and a required set that quietly loses an entry is exactly what makes a
641
- * passing proof trivially "covering".
642
- *
643
- * `selectionLabel` names the failure, nothing else: it is not part of the
644
- * selection this function resolves, only prose a consumer supplies for its
645
- * own thrown error (e.g. HQ's surface name, "core" or "docs"). The message
646
- * deliberately says "the profile's command catalog" rather than naming
647
- * `software-factory.profile.json`: a fleet-generic library must not assume
648
- * every consumer's catalog is that exact file, so this wording differs
649
- * on purpose from the HQ-local message it replaced.
611
+ * Resolve command identities to their `ProofReuseCommand` objects (ADR 0021).
612
+ * Which names a surface requires is the consumer's choice; this is only the
613
+ * lookup. A name with no catalog entry throws at generation time, because a
614
+ * required set that quietly loses an entry makes any passing proof covering.
615
+ * The message says "the profile's command catalog" rather than a file name,
616
+ * since not every consumer's catalog is `software-factory.profile.json`.
650
617
  */
651
618
  const resolveProofReuseCommands = (catalog, names, selectionLabel) => names.map((name) => {
652
619
  const command = catalog.find((entry) => entry.name === name);
@@ -1026,15 +993,6 @@ def releaseAuthorized($release; $commands; $stamp):
1026
993
  | map(gsub("[\\r\\n\\t]"; " "))
1027
994
  | join("\n")
1028
995
  `.trim();
1029
- /**
1030
- * Every refusal ends on the same line. `pr:verify` is the command that
1031
- * produces the proof this job looks for, so it is the corrective action
1032
- * whatever the refusal was.
1033
- *
1034
- * It is phrased as an option, not a reprimand. A pull request opened by hand
1035
- * has no factory proof and never will; the full suite running for it is the
1036
- * designed behavior, not a mistake to report.
1037
- */
1038
996
  const CORRECTIVE_LINE = "Run `psf pr:verify` before publishing to reuse local proof and avoid a duplicate server run.";
1039
997
  /**
1040
998
  * Emitted when a consumer's command selection is unusable. Mirrors the
@@ -1319,8 +1277,7 @@ const assertProofReuseCoverage = (input) => {
1319
1277
  const problem = report.requiredCommands.length === 0 ? "selects no usable profile commands, so any passing proof would trivially cover it" : `skips work no selected profile command runs: ${report.uncovered.join(", ")}`;
1320
1278
  throw new Error(`Proof-reuse coverage failed: the ${surface} surface ${problem}. Add the command to software-factory.profile.json (and to this surface's selection), or stop skipping it.`);
1321
1279
  };
1322
- //#endregion
1323
- //#region src/preview-proof-inventory.ts
1280
+ // src/preview-proof-inventory.ts
1324
1281
  /**
1325
1282
  * Hosted preview-proof inventory (#639): persist and list Factory-App
1326
1283
  * registrations, and record cleanup outcomes, without PR comments.
@@ -1716,10 +1673,12 @@ const githubStore = (transport) => {
1716
1673
  const { token } = transport;
1717
1674
  return {
1718
1675
  list: async (input) => {
1719
- return takeNewestRegistrations(await mapPool(await listCommitShasForPull(request, token, timeoutMs, input.owner, input.repo, input.pr), 8, async (sha) => ({
1676
+ const shas = await listCommitShasForPull(request, token, timeoutMs, input.owner, input.repo, input.pr);
1677
+ const runsBySha = await mapPool(shas, 8, async (sha) => ({
1720
1678
  runs: await listCheckRunsOnSha(request, token, timeoutMs, input.owner, input.repo, sha),
1721
1679
  sha
1722
- })), input.pr);
1680
+ }));
1681
+ return takeNewestRegistrations(runsBySha, input.pr);
1723
1682
  },
1724
1683
  put: async (input) => {
1725
1684
  const registration = assertPersistableRegistration(input.registration);
@@ -1809,8 +1768,7 @@ const previewProofInventory = {
1809
1768
  persist,
1810
1769
  recordCleanup
1811
1770
  };
1812
- //#endregion
1813
- //#region src/pinned-action.ts
1771
+ // src/pinned-action.ts
1814
1772
  const PINNED_ACTION_PATTERN = /^[\w.-]+\/[\w.-]+@[0-9a-f]{40}$/u;
1815
1773
  const ACTION_TAG_PATTERN = /^v\d+(?:\.\d+){0,2}$/u;
1816
1774
  const actionRepository = (action) => action.uses.slice(0, action.uses.indexOf("@"));
@@ -1820,9 +1778,8 @@ const assertPinnedAction = (name, action, expectedRepository) => {
1820
1778
  if (expectedRepository && actionRepository(action) !== expectedRepository) throw new Error(`${name} must pin ${expectedRepository}, got ${actionRepository(action)}.`);
1821
1779
  if (!ACTION_TAG_PATTERN.test(action.tag)) throw new Error(`${name} tag must be vN, vN.N, or vN.N.N, got "${action.tag}".`);
1822
1780
  };
1823
- //#endregion
1824
- //#region src/factory-workflow.ts
1825
- const RESERVED_ACTION_NAMES = new Set([
1781
+ // src/factory-workflow.ts
1782
+ const RESERVED_ACTION_NAMES = /* @__PURE__ */ new Set([
1826
1783
  "checkout",
1827
1784
  "setupNode",
1828
1785
  "setupPnpm"
@@ -1935,8 +1892,7 @@ const factoryWorkflow = (options) => {
1935
1892
  })
1936
1893
  });
1937
1894
  };
1938
- //#endregion
1939
- //#region src/cursor-oidc.ts
1895
+ // src/cursor-oidc.ts
1940
1896
  /**
1941
1897
  * Pinned Cursor OIDC trust predicates for the Factory App broker (#949).
1942
1898
  *
@@ -1964,8 +1920,7 @@ const FACTORY_CURSOR_OIDC_MANAGED_RUNTIME = "managed";
1964
1920
  const FACTORY_APP_BROKER_PATH = "/api/factory-app/installation-token";
1965
1921
  /** Production broker origin. The CLI pins this; it is not profile-declared. */
1966
1922
  const FACTORY_APP_BROKER_ORIGIN = "https://hq.patronage.com";
1967
- //#endregion
1968
- //#region src/proof-reuse-presentation.ts
1923
+ // src/proof-reuse-presentation.ts
1969
1924
  /** Generic timing and presentation steps around the proof-reuse gate (#652). */
1970
1925
  const githubExpression = (expression) => `\${{ ${expression} }}`;
1971
1926
  const shellExpansion = (expression) => `\${${expression}}`;
@@ -1995,9 +1950,6 @@ say '## ${label} timing'
1995
1950
  say ''
1996
1951
 
1997
1952
  if [ "${shellExpansion("GITHUB_EVENT_NAME:-")}" = 'push' ] && [ -z "${shellExpansion("PROOF_REASON:-")}" ]; then
1998
- # A push run with no recorded reason is one where the gate step's condition
1999
- # kept it off entirely, so the full suite ran with no reuse decision. The
2000
- # gate runs on pull requests only (#863), so that is every push.
2001
1953
  say '- Path: full execution, no proof consulted'
2002
1954
  say '- Proof-reuse gate: did not run on this ref; the full suite ran.'
2003
1955
  say "- Verified head: \`${shellExpansion("GITHUB_SHA:-unknown")}\`"
@@ -2038,8 +1990,7 @@ const factoryProofReuseSummaryStep = (options) => Object.freeze({
2038
1990
  name: FACTORY_PROOF_TIMING_SUMMARY_STEP_NAME,
2039
1991
  run: factoryProofReuseSummaryScript(options)
2040
1992
  });
2041
- //#endregion
2042
- //#region src/impact-demand-condition.ts
1993
+ // src/impact-demand-condition.ts
2043
1994
  const impactDemandConditions = (options) => {
2044
1995
  const targetOutput = (targetName) => {
2045
1996
  const output = options.targetOutputs[targetName];
@@ -2056,8 +2007,7 @@ const impactDemandConditions = (options) => {
2056
2007
  demandedIfAtStep: (targetName) => condition(`steps.${options.stepId}`, "outcome", targetOutput(targetName))
2057
2008
  });
2058
2009
  };
2059
- //#endregion
2060
- //#region src/runnable-cli.ts
2010
+ // src/runnable-cli.ts
2061
2011
  /**
2062
2012
  * `@patronage/software-factory` publishes two dist entries. `dist/index.js` is
2063
2013
  * the package export: consumers import it, so it runs no command. `dist/cli.js`
@@ -2074,8 +2024,7 @@ const INERT_ENTRY_PATTERN = /(?:^|[/\\])dist[/\\]index\.js(?:["'\s]|$)/u;
2074
2024
  const assertRunnableCli = (name, cli) => {
2075
2025
  if (INERT_ENTRY_PATTERN.test(cli)) throw new Error(`${name} must invoke the software-factory bin, not the package entry dist/index.js, which imports as a library and exits 0 without running the command. Use the bin name (for example "pnpm exec psf") or dist/cli.js. Got "${cli}".`);
2076
2026
  };
2077
- //#endregion
2078
- //#region src/production-impact-workflow.ts
2027
+ // src/production-impact-workflow.ts
2079
2028
  const FACTORY_PRODUCTION_IMPACT_STEP_ID = "production_impact";
2080
2029
  const FACTORY_PRODUCTION_IMPACT_DECISION_OUTPUT = "decision";
2081
2030
  const FACTORY_PRODUCTION_IMPACT_BASIS_OUTPUT = "basis";
@@ -2171,8 +2120,7 @@ const factoryProductionImpactWorkflow = (options) => {
2171
2120
  targetOutputs: Object.freeze(targetOutputs)
2172
2121
  });
2173
2122
  };
2174
- //#endregion
2175
- //#region src/candidate-impact-workflow.ts
2123
+ // src/candidate-impact-workflow.ts
2176
2124
  const FACTORY_CANDIDATE_IMPACT_STEP_ID = "candidate_impact";
2177
2125
  const FACTORY_CANDIDATE_IMPACT_DECISION_OUTPUT = "decision";
2178
2126
  const FACTORY_CANDIDATE_IMPACT_BASIS_OUTPUT = "basis";
@@ -2231,8 +2179,7 @@ const factoryCandidateImpactWorkflow = (options) => {
2231
2179
  targetOutputs: Object.freeze(targetOutputs)
2232
2180
  });
2233
2181
  };
2234
- //#endregion
2235
- //#region src/lifecycle-contract-lane.ts
2182
+ // src/lifecycle-contract-lane.ts
2236
2183
  const FACTORY_LIFECYCLE_CONTRACT_JOB_ID = "factory-contracts";
2237
2184
  const FACTORY_LIFECYCLE_CONTRACT_JOB_NAME = "Factory / Alchemy Contracts";
2238
2185
  const JOB_ID_PATTERN$1 = /^[A-Za-z_][A-Za-z0-9_-]*$/u;
@@ -2298,8 +2245,7 @@ const factoryLifecycleContractLane = (declaration) => {
2298
2245
  steps: Object.freeze([runStep, summaryStep])
2299
2246
  });
2300
2247
  };
2301
- //#endregion
2302
- //#region src/merge-freeze-job.ts
2248
+ // src/merge-freeze-job.ts
2303
2249
  /**
2304
2250
  * The merge-freeze writer job (#356, ADR 0016; #429 for the
2305
2251
  * merge-target namespace; #872 for this package).
@@ -2474,7 +2420,7 @@ const factoryMergeFreezeJob = (options) => {
2474
2420
  env: Object.freeze({
2475
2421
  GH_TOKEN: `\${{ steps.${FACTORY_MERGE_FREEZE_APP_TOKEN_STEP_ID}.outputs.token }}`,
2476
2422
  VERIFY_JOBS: `\${{ toJSON(needs) }}`,
2477
- VERIFY_RESULT: options.verifyResultExpression ?? FACTORY_MERGE_FREEZE_VERIFY_RESULT_EXPRESSION
2423
+ VERIFY_RESULT: options.verifyResultExpression ?? "${{ (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) && 'failure' || 'success' }}"
2478
2424
  }),
2479
2425
  name: "Complete the merge-freeze generation",
2480
2426
  run: factoryMergeFreezeScript()
@@ -2488,8 +2434,7 @@ const factoryMergeFreezeJob = (options) => {
2488
2434
  steps: Object.freeze([mintStep, reportStep])
2489
2435
  });
2490
2436
  };
2491
- //#endregion
2492
- //#region src/pr-status-hud-workflow.ts
2437
+ // src/pr-status-hud-workflow.ts
2493
2438
  const FACTORY_PR_STATUS_HUD_JOB_ID = "status-hud";
2494
2439
  const FACTORY_PR_STATUS_HUD_JOB_NAME = "Present PR status HUD";
2495
2440
  const FACTORY_PR_STATUS_HUD_APP_TOKEN_STEP_ID = "factory-app-token";
@@ -2545,8 +2490,7 @@ const factoryPrStatusHudWorkflow = (options) => {
2545
2490
  presentSteps: Object.freeze([mintStep, presentStep])
2546
2491
  });
2547
2492
  };
2548
- //#endregion
2549
- //#region src/preview-cleanup-topology.ts
2493
+ // src/preview-cleanup-topology.ts
2550
2494
  const FACTORY_PREVIEW_CLEANUP_AUDIT_JOB_ID = "stage-residue-audit";
2551
2495
  const FACTORY_PREVIEW_CLEANUP_AUDIT_JOB_NAME = "Stage residue audit";
2552
2496
  const JOB_ID_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*$/u;
@@ -2598,8 +2542,7 @@ const factoryPreviewCleanupTopology = (options) => {
2598
2542
  destroyJobs: Object.freeze(destroyJobs)
2599
2543
  });
2600
2544
  };
2601
- //#endregion
2602
- //#region src/preview-cleanup.ts
2545
+ // src/preview-cleanup.ts
2603
2546
  const DEFAULT_SWEEP_MAX_TARGETS = 50;
2604
2547
  /** GitHub refuses a matrix with more than 256 entries. */
2605
2548
  const MATRIX_ENTRY_LIMIT$1 = 256;
@@ -2893,8 +2836,7 @@ const readPullRequestStates = async (input, access) => {
2893
2836
  }
2894
2837
  return states;
2895
2838
  };
2896
- //#endregion
2897
- //#region src/preview-cleanup-workflow.ts
2839
+ // src/preview-cleanup-workflow.ts
2898
2840
  const FACTORY_PREVIEW_CLEANUP_DISCOVER_JOB_ID = "discover";
2899
2841
  const FACTORY_PREVIEW_CLEANUP_DISCOVER_JOB_NAME = "Discover preview cleanup targets";
2900
2842
  const FACTORY_PREVIEW_CLEANUP_DISCOVER_STEP_ID = "targets";
@@ -3120,8 +3062,7 @@ const factoryPreviewCleanupWorkflow = (options) => {
3120
3062
  permissions: Object.freeze({ contents: "read" })
3121
3063
  });
3122
3064
  };
3123
- //#endregion
3124
- //#region src/preview-receipt-workflow.ts
3065
+ // src/preview-receipt-workflow.ts
3125
3066
  /** Receipt transport only. The consumer owns selection, lifecycle, smoke, and freshness. */
3126
3067
  const factoryPreviewReceiptWorkflow = (options) => {
3127
3068
  if (!/^preview:[a-z][a-z0-9-]*$/u.test(options.target)) throw new Error("Preview receipts require a declared preview target name.");
@@ -3181,18 +3122,12 @@ const factoryPreviewReceiptWorkflow = (options) => {
3181
3122
  })
3182
3123
  });
3183
3124
  };
3184
- //#endregion
3185
- //#region src/push-identity-workflow.ts
3125
+ // src/push-identity-workflow.ts
3186
3126
  /** `owner/repo` slice of the catalog's `UPLOAD_ARTIFACT` pin, derived rather
3187
3127
  * than repeated as a literal, so a repository rename here cannot drift from
3188
3128
  * the pin it validates against. */
3189
3129
  const UPLOAD_ARTIFACT_REPOSITORY = UPLOAD_ARTIFACT.uses.slice(0, UPLOAD_ARTIFACT.uses.indexOf("@"));
3190
3130
  const FACTORY_PUSH_IDENTITY_SCHEMA_VERSION = 1;
3191
- /**
3192
- * The artifact prefix and the five step IDs are module-private. Alpha.13
3193
- * removed them from the public surface (#719). A caller reads a step ID from
3194
- * the builder's returned `steps` (`step.id`) or from `artifactName`.
3195
- */
3196
3131
  const FACTORY_PUSH_IDENTITY_ARTIFACT_PREFIX = "factory-push-identity";
3197
3132
  const FACTORY_PUSH_IDENTITY_RECORD_STEP_ID = "factory_push_identity_record";
3198
3133
  const FACTORY_PUSH_IDENTITY_LOOKUP_STEP_ID = "factory_push_identity_lookup";
@@ -3557,8 +3492,7 @@ const factoryPushIdentityConsumer = (options) => {
3557
3492
  usableIf: `steps.${FACTORY_PUSH_IDENTITY_VALIDATE_STEP_ID}.outputs.disposition == 'usable'`
3558
3493
  });
3559
3494
  };
3560
- //#endregion
3561
- //#region src/vitest-profile.ts
3495
+ // src/vitest-profile.ts
3562
3496
  /**
3563
3497
  * Vitest suite profiling — the measurement mechanics behind a CI runner
3564
3498
  * comparison (#640, #647).
@@ -3579,7 +3513,7 @@ const factoryPushIdentityConsumer = (options) => {
3579
3513
  const VITEST_PROFILE_SCHEMA_VERSION = 1;
3580
3514
  /** `tool` discriminator every emitted profile carries. */
3581
3515
  const VITEST_PROFILE_TOOL = "factory-ci-vitest-profile";
3582
- const RUN_TIMEOUT_MS = 15 * 6e4;
3516
+ const RUN_TIMEOUT_MS = 9e5;
3583
3517
  const TERMINATION_GRACE_MS = 5e3;
3584
3518
  /**
3585
3519
  * A sample failed. The partial profile is already on disk; `exitCode` is the
@@ -3879,8 +3813,7 @@ const runVitestProfile = async (options, dependencies = {}) => {
3879
3813
  }
3880
3814
  return profile;
3881
3815
  };
3882
- //#endregion
3883
- //#region src/vitest-profile-reader.ts
3816
+ // src/vitest-profile-reader.ts
3884
3817
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3885
3818
  const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
3886
3819
  const durationSummaryFailure = (value, where) => {
@@ -3993,8 +3926,7 @@ const readVitestProfileDocument = (value) => {
3993
3926
  profile: value
3994
3927
  };
3995
3928
  };
3996
- //#endregion
3997
- //#region src/verify-runner-policy.ts
3929
+ // src/verify-runner-policy.ts
3998
3930
  const DEPOT_LABEL = "depot-ubuntu-24.04";
3999
3931
  const HOSTED_LABEL = "ubuntu-latest";
4000
3932
  const isOverride = (decision) => typeof decision === "object";
@@ -4110,8 +4042,7 @@ const assertVerifyRunnerPolicy = (yaml, input) => {
4110
4042
  if (report.forbiddenKinds.length > 0) details.push(`deploy-credentials is illegal inside Verify: ${report.forbiddenKinds.join(", ")}`);
4111
4043
  throw new Error(`${input.source} Verify runner policy failed:\n${details.map((detail) => ` - ${detail}`).join("\n")}`);
4112
4044
  };
4113
- //#endregion
4114
- //#region src/workflow-shell-lint.ts
4045
+ // src/workflow-shell-lint.ts
4115
4046
  const RUN_KEY = /^(?<indent>\s*)(?:-\s+)?run:(?<inline>.*)$/u;
4116
4047
  /**
4117
4048
  * GitHub evaluates `${{ }}` before bash ever sees the script, and what it
@@ -4146,8 +4077,10 @@ const neutralizeExpressions = (script) => {
4146
4077
  end = scan + 2;
4147
4078
  break;
4148
4079
  }
4149
- } else if (char === quote) if (script[scan + 1] === quote) scan += 1;
4150
- else quote = void 0;
4080
+ } else if (char === quote) {
4081
+ if (script[scan + 1] === quote) scan += 1;
4082
+ else quote = void 0;
4083
+ }
4151
4084
  scan += 1;
4152
4085
  }
4153
4086
  if (end === -1) {
@@ -4298,7 +4231,7 @@ const ASSIGNMENT = /^[A-Za-z_]\w*=/u;
4298
4231
  * Named rather than inferred, so an unfamiliar command fails loudly instead of
4299
4232
  * being skipped as though it had been considered.
4300
4233
  */
4301
- const NON_SHELL_INTERPRETERS = new Set([
4234
+ const NON_SHELL_INTERPRETERS = /* @__PURE__ */ new Set([
4302
4235
  "cmd",
4303
4236
  "powershell",
4304
4237
  "pwsh",
@@ -4374,5 +4307,4 @@ const assertWorkflowShellParses = (yaml, options) => {
4374
4307
  const detail = failures.map((failure) => ` - ${failure.step ?? "unnamed step"}: ${failure.stderr.replaceAll("\n", "\n ")}`).join("\n");
4375
4308
  throw new Error(`${options.source} emits shell bash cannot parse; the runner would treat it as a no-op:\n${detail}`);
4376
4309
  };
4377
- //#endregion
4378
4310
  export { ALCHEMY_BASELINE, EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER, 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, GitHubApiError, GitHubAppTokenTransportError, NODE_PNPM_ACTION_FAMILY_NODE24, PREVIEW_PROOF_INVENTORY_CHECK_NAME, PREVIEW_PROOF_INVENTORY_LIST_PERMISSIONS, PreviewProofTransportError, SETUP_STEP_ROLES, UPLOAD_ARTIFACT, VITEST_PROFILE_SCHEMA_VERSION, VITEST_PROFILE_TOOL, VitestProfileError, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patronage/factory-ci",
3
- "version": "1.0.0-alpha.44",
3
+ "version": "1.0.0-alpha.46",
4
4
  "description": "Deep CI and deploy building blocks for Patronage factory projects: workflow source artifacts, hosted diff classification, Alchemy entry execution, and disposable-stage semantics",
5
5
  "keywords": [
6
6
  "alchemy",
@@ -35,21 +35,22 @@
35
35
  "tag": "next"
36
36
  },
37
37
  "dependencies": {
38
- "esbuild": "0.28.1"
38
+ "esbuild": "0.28.2"
39
39
  },
40
40
  "devDependencies": {
41
- "@types/node": "24.13.3",
42
- "@vitest/coverage-v8": "4.1.10",
43
- "alchemy": "2.0.0-beta.83",
44
- "effect": "4.0.1",
45
- "knip": "6.27.0",
46
- "oxfmt": "0.59.0",
47
- "oxlint": "1.76.0",
48
- "tsdown": "0.21.10",
49
- "typescript": "5.9.3",
50
- "ultracite": "7.10.5",
51
- "vitest": "4.1.10",
52
- "@patronage/alchemy-d1-state": "0.4.0"
41
+ "@alchemy.run/cloudflare": "2.0.0-beta.84",
42
+ "@patronage/alchemy-d1-state": "0.4.0",
43
+ "@types/node": "24.19.2",
44
+ "@vitest/coverage-v8": "5.0.5",
45
+ "alchemy": "2.0.0-beta.84",
46
+ "effect": "4.0.6",
47
+ "knip": "6.43.0",
48
+ "oxfmt": "0.75.0",
49
+ "oxlint": "1.90.0",
50
+ "tsdown": "0.23.2",
51
+ "typescript": "7.1.0-beta",
52
+ "ultracite": "8.1.0",
53
+ "vitest": "5.0.5"
53
54
  },
54
55
  "peerDependencies": {
55
56
  "alchemy": ">=2.0.0-beta.63 <3",
package/src/actions.ts CHANGED
@@ -2,13 +2,6 @@
2
2
  * The GitHub Actions this family's workflow generators use, pinned to full
3
3
  * commit SHAs in one place (#268).
4
4
  *
5
- * Every repository pinned the same *tags* and got different *commits*: this
6
- * repository's `verify.yml` carried `actions/checkout@11d5960a` while
7
- * `hq-deploy.yml` and all of paitronage carried `34e11487`, because gagen
8
- * resolves a floating `@v4` at generation time and the files were generated
9
- * months apart. Naming the SHA here is what makes that class of drift
10
- * impossible: regenerating a workflow can no longer move a pin.
11
- *
12
5
  * `uses` is a bare `owner/repo@<sha>` string, safe to hand straight to a
13
6
  * gagen step. The tag lives in its own field rather than as a `# v7.0.1`
14
7
  * suffix on `uses`, because a `#` inside a YAML scalar forces quoting and
@@ -5,8 +5,7 @@
5
5
  * else: the child's output is parsed and dropped, so no secret in it can
6
6
  * reach a job log or an evidence file through the operation. That is the
7
7
  * right default and it stays the default. It also leaves an operator with a
8
- * failure code and no record of what failed, which twice cost a paitronage
9
- * investigation its evidence.
8
+ * failure code and no record of what failed.
10
9
  *
11
10
  * This is the opt-in other half: a consumer that names a file gets every
12
11
  * child's streams appended to it, each stream passed whole through the
@@ -1,15 +1,6 @@
1
1
  /**
2
2
  * Cloudflare credential preflight for an Alchemy deploy.
3
3
  *
4
- * Two projects built this twice. Paitronage
5
- * (`scripts/alchemy/credential-preflight.ts` plus
6
- * `scripts/alchemy/cloudflare-token-policy.ts`) and firedup
7
- * (`scripts/alchemy/local-credentials.ts`) both resolve a Cloudflare API
8
- * token, verify it is live, and refuse to deploy unless its permission groups
9
- * match an exact reviewed list. What repeats is the check. What does not
10
- * repeat is the account, the permission list, the resource scope, and where
11
- * the credential comes from, so every one of those is an input.
12
- *
13
4
  * **No credential value is ever printed.** Errors name environment variables and
14
5
  * missing groups from the caller-owned permission requirements. Untrusted API
15
6
  * status, receipt group names, and resource identifiers are never reflected.
@@ -3,11 +3,7 @@
3
3
  *
4
4
  * Alchemy's `destroy` can exit zero while the state store still lists
5
5
  * resources for the stage — a partial destroy, a resource whose delete failed
6
- * quietly, or a state row that was never removed. Paitronage checks the state
7
- * store after the child exits rather than trusting the exit code
8
- * (`runAlchemyLifecycle`, the `"Alchemy destroy left target-stage state
9
- * registered."` branch). Firedup carries no equivalent, which is exactly the
10
- * gap this closes.
6
+ * quietly, or a state row that was never removed.
11
7
  *
12
8
  * Reading the state store is the project's job: only the project knows which
13
9
  * store it configured and how to address a stage in it. This function owns the
@@ -7,10 +7,7 @@ import { canonicalPlan } from "./plan-effects.ts";
7
7
  *
8
8
  * The first deploy of a stack into a stage is the one deploy no earlier state
9
9
  * can constrain: there is nothing to diff against, so the plan is the only
10
- * description of what is about to be created. Paitronage binds that plan to an
11
- * operator decision by hashing it and comparing the hash against a reviewed
12
- * value (`firstDeployPlanSha256` and `assertFirstDeployEntry` in
13
- * `tools/alchemy/src/internal/lifecycle.ts`).
10
+ * description of what is about to be created.
14
11
  *
15
12
  * The generic form keeps the binding and drops the project's stage policy.
16
13
  * Which stages are eligible, and where the authorized hashes are kept, stay