@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/README.md +10 -8
- package/dist/.build-fingerprint.json +1 -1
- package/dist/alchemy/index.d.ts +100 -134
- package/dist/alchemy/index.js +65 -76
- package/dist/{bundle-alchemy-entry-CT5hCphA.js → bundle-alchemy-entry-Ba1Ebp91.js} +15 -15
- package/dist/{execute-alchemy-entry-C2ZhsNTN.js → execute-alchemy-entry-CxQrjSg8.js} +18 -15
- package/dist/{execute-alchemy-entry-B397GSk5.d.ts → execute-alchemy-entry-D75saOiE.d.ts} +9 -14
- package/dist/index.d.ts +175 -257
- package/dist/index.js +59 -127
- package/package.json +15 -14
- package/src/actions.ts +0 -7
- package/src/alchemy/child-diagnostics.ts +1 -2
- package/src/alchemy/credential-preflight.ts +0 -9
- package/src/alchemy/destroy-postcondition.ts +1 -5
- package/src/alchemy/first-deploy-authorization.ts +1 -4
- package/src/alchemy/lifecycle.ts +88 -33
- package/src/alchemy/local-emulation.ts +4 -3
- package/src/alchemy/plan-effects.ts +1 -1
- package/src/alchemy/stage-policy.ts +3 -5
- package/src/alchemy/url-implies-auth.ts +1 -5
- package/src/alchemy-baseline.ts +27 -7
- package/src/bundle-alchemy-entry.ts +21 -13
- package/src/disposable-stage.ts +2 -3
- package/src/github-app-token.ts +3 -9
- package/src/proof-reuse-gate.ts +16 -56
- package/src/proof-reuse-presentation.ts +0 -3
- package/src/push-identity-workflow.ts +1 -5
package/src/alchemy/lifecycle.ts
CHANGED
|
@@ -10,12 +10,6 @@
|
|
|
10
10
|
* back a fixed-shape result or an `AlchemyLifecycleError`. It cannot call the
|
|
11
11
|
* steps in another order, because it does not call the steps.
|
|
12
12
|
*
|
|
13
|
-
* Paitronage and HQ each reconstructed this sequence from the guards in
|
|
14
|
-
* `./` and got parts of it wrong in different ways (paitronage#1917): a
|
|
15
|
-
* post-child failure reported as not started, an empty-stage cleanup racing
|
|
16
|
-
* a concurrent write, a plan whose immutability check ignored stack output.
|
|
17
|
-
* The sequence below is the one both were reaching for.
|
|
18
|
-
*
|
|
19
13
|
* What stays with the consumer: the resource graph, the credentials and
|
|
20
14
|
* environment the child runs with, the stage table, the retained-identity
|
|
21
15
|
* markers, the first-deploy authorization list, and the state store's own
|
|
@@ -25,6 +19,7 @@
|
|
|
25
19
|
import { readFileSync } from "node:fs";
|
|
26
20
|
import { createRequire } from "node:module";
|
|
27
21
|
import path from "node:path";
|
|
22
|
+
import { setTimeout as wait } from "node:timers/promises";
|
|
28
23
|
import { isDeepStrictEqual } from "node:util";
|
|
29
24
|
|
|
30
25
|
import * as Effect from "effect/Effect";
|
|
@@ -193,8 +188,48 @@ export interface AlchemyLifecyclePolicy {
|
|
|
193
188
|
* not converged whatever this list names.
|
|
194
189
|
*/
|
|
195
190
|
readonly nonConvergentResources?: readonly string[];
|
|
191
|
+
/**
|
|
192
|
+
* Bounded read-only re-plans after the apply (#1349). A provider can
|
|
193
|
+
* report a resource as still changing for a short while after a successful
|
|
194
|
+
* apply. Set, a post-deploy plan that is only `NOT_CONVERGED` waits
|
|
195
|
+
* `delayMillis` and re-plans, up to `attempts` more times, under the same
|
|
196
|
+
* lease. The apply never repeats, and every other check (the state read on
|
|
197
|
+
* both sides of each plan, retained identities, created resources, the
|
|
198
|
+
* lease) runs on every attempt and stops the deploy at once. Exhausted, the
|
|
199
|
+
* deploy is still `NOT_CONVERGED`. Omitted, there is no retry. `attempts`
|
|
200
|
+
* is 1 to 10 and `delayMillis` 0 to 60 000, and below an explicit
|
|
201
|
+
* `ownershipTtlMillis`. That bound is a floor: the lease is renewed after
|
|
202
|
+
* each dry-run, so the delay plus one re-plan must fit inside the lease;
|
|
203
|
+
* keep the delay well under it.
|
|
204
|
+
*/
|
|
205
|
+
readonly convergenceRetries?: {
|
|
206
|
+
readonly attempts: number;
|
|
207
|
+
readonly delayMillis: number;
|
|
208
|
+
};
|
|
196
209
|
}
|
|
197
210
|
|
|
211
|
+
const MAX_CONVERGENCE_ATTEMPTS = 10;
|
|
212
|
+
const MAX_CONVERGENCE_DELAY_MILLIS = 60_000;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* A delay at or above an explicit lease TTL lapses the lease mid-wait, which
|
|
216
|
+
* would surface late as `OWNERSHIP_LOST`; refuse it up front. This is a floor,
|
|
217
|
+
* not a guarantee: the re-plan after the wait also runs before the renewal.
|
|
218
|
+
*/
|
|
219
|
+
const validConvergenceRetries = ({
|
|
220
|
+
convergenceRetries: retries,
|
|
221
|
+
ownershipTtlMillis,
|
|
222
|
+
}: AlchemyLifecyclePolicy): boolean =>
|
|
223
|
+
retries === undefined ||
|
|
224
|
+
(Number.isInteger(retries.attempts) &&
|
|
225
|
+
retries.attempts >= 1 &&
|
|
226
|
+
retries.attempts <= MAX_CONVERGENCE_ATTEMPTS &&
|
|
227
|
+
Number.isInteger(retries.delayMillis) &&
|
|
228
|
+
retries.delayMillis >= 0 &&
|
|
229
|
+
retries.delayMillis <= MAX_CONVERGENCE_DELAY_MILLIS &&
|
|
230
|
+
(ownershipTtlMillis === undefined ||
|
|
231
|
+
retries.delayMillis < ownershipTtlMillis));
|
|
232
|
+
|
|
198
233
|
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown
|
|
199
234
|
? Omit<T, K>
|
|
200
235
|
: never;
|
|
@@ -474,8 +509,6 @@ class LifecycleRun {
|
|
|
474
509
|
return { stack: this.request.stack, stage: this.request.stage };
|
|
475
510
|
}
|
|
476
511
|
|
|
477
|
-
// ── request and admission ────────────────────────────────────────────
|
|
478
|
-
|
|
479
512
|
validateRequest(): void {
|
|
480
513
|
const { operation, stack, stage } = this.request;
|
|
481
514
|
if (
|
|
@@ -491,7 +524,8 @@ class LifecycleRun {
|
|
|
491
524
|
}
|
|
492
525
|
if (
|
|
493
526
|
typeof this.policy.holder !== "string" ||
|
|
494
|
-
this.policy.holder.trim() === ""
|
|
527
|
+
this.policy.holder.trim() === "" ||
|
|
528
|
+
!validConvergenceRetries(this.policy)
|
|
495
529
|
) {
|
|
496
530
|
throw this.fail("INVALID_POLICY", "request");
|
|
497
531
|
}
|
|
@@ -561,8 +595,6 @@ class LifecycleRun {
|
|
|
561
595
|
}
|
|
562
596
|
}
|
|
563
597
|
|
|
564
|
-
// ── state ────────────────────────────────────────────────────────────
|
|
565
|
-
|
|
566
598
|
/**
|
|
567
599
|
* Run `body` under one stage lease. The lease is acquired at
|
|
568
600
|
* `acquirePhase`, and every child `body` launches carries it, so no other
|
|
@@ -714,8 +746,6 @@ class LifecycleRun {
|
|
|
714
746
|
return { output: view.output, resources: records };
|
|
715
747
|
}
|
|
716
748
|
|
|
717
|
-
// ── execution ────────────────────────────────────────────────────────
|
|
718
|
-
|
|
719
749
|
private stageArgs(): readonly string[] {
|
|
720
750
|
return ["--stage", this.request.stage];
|
|
721
751
|
}
|
|
@@ -915,8 +945,6 @@ class LifecycleRun {
|
|
|
915
945
|
return { before, effects: this.effectsOf(text, "postcondition"), text };
|
|
916
946
|
}
|
|
917
947
|
|
|
918
|
-
// ── operations ───────────────────────────────────────────────────────
|
|
919
|
-
|
|
920
948
|
private planHashOf(text: string): string | undefined {
|
|
921
949
|
const { firstDeploy } = this.policy;
|
|
922
950
|
if (firstDeploy === undefined) {
|
|
@@ -1177,26 +1205,53 @@ class LifecycleRun {
|
|
|
1177
1205
|
// The convergence dry-run is the same read-only plan as admission's:
|
|
1178
1206
|
// the state read before it is the post-apply state the
|
|
1179
1207
|
// postconditions are checked against, and the read after it refuses
|
|
1180
|
-
// a child that wrote.
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
persistedToSnapshot(this.target, plan.before),
|
|
1208
|
+
// a child that wrote. Every check runs again on each bounded re-plan
|
|
1209
|
+
// (#1349); only a plan that is not converged waits for another.
|
|
1210
|
+
const converge = async (
|
|
1211
|
+
retriesLeft: number
|
|
1212
|
+
): Promise<{
|
|
1213
|
+
readonly createdNow: readonly string[];
|
|
1214
|
+
readonly post: {
|
|
1215
|
+
readonly before: PersistedState;
|
|
1216
|
+
readonly effects: PlanEffects;
|
|
1217
|
+
};
|
|
1218
|
+
}> => {
|
|
1219
|
+
const post = await this.readOnlyPlan(
|
|
1220
|
+
this.planArgs(false),
|
|
1221
|
+
lease,
|
|
1222
|
+
accept,
|
|
1196
1223
|
"postcondition"
|
|
1197
1224
|
);
|
|
1198
|
-
|
|
1199
|
-
|
|
1225
|
+
const after = post.before;
|
|
1226
|
+
if (after.resources.length === 0) {
|
|
1227
|
+
throw this.fail("DEPLOY_INCOMPLETE", "postcondition");
|
|
1228
|
+
}
|
|
1229
|
+
const createdNow = this.createdFqns(plan.before, after, plan.effects);
|
|
1230
|
+
if (isProtected && !admittedFirstDeploy) {
|
|
1231
|
+
this.assertRetained(
|
|
1232
|
+
persistedToSnapshot(this.target, after),
|
|
1233
|
+
persistedToSnapshot(this.target, plan.before),
|
|
1234
|
+
"postcondition"
|
|
1235
|
+
);
|
|
1236
|
+
}
|
|
1237
|
+
try {
|
|
1238
|
+
this.assertConverged(post.effects, after);
|
|
1239
|
+
} catch (error) {
|
|
1240
|
+
if (
|
|
1241
|
+
retriesLeft === 0 ||
|
|
1242
|
+
!(error instanceof AlchemyLifecycleError) ||
|
|
1243
|
+
error.code !== "NOT_CONVERGED"
|
|
1244
|
+
) {
|
|
1245
|
+
throw error;
|
|
1246
|
+
}
|
|
1247
|
+
await wait(this.policy.convergenceRetries?.delayMillis ?? 0);
|
|
1248
|
+
return await converge(retriesLeft - 1);
|
|
1249
|
+
}
|
|
1250
|
+
return { createdNow, post };
|
|
1251
|
+
};
|
|
1252
|
+
const { createdNow, post } = await converge(
|
|
1253
|
+
this.policy.convergenceRetries?.attempts ?? 0
|
|
1254
|
+
);
|
|
1200
1255
|
return {
|
|
1201
1256
|
convergence: post.effects,
|
|
1202
1257
|
created: createdNow,
|
|
@@ -28,9 +28,10 @@ const [ACCOUNT_ID_NAME, API_TOKEN_NAME] = HOSTED_CLOUDFLARE_CREDENTIAL_NAMES;
|
|
|
28
28
|
* Alchemy validates the value against `/^[0-9a-f]{32}$/i` and rejects
|
|
29
29
|
* placeholders such as `""` or `dummy` with an authentication error before any
|
|
30
30
|
* run starts. The check is `validateAccountId`, in
|
|
31
|
-
* `alchemy/lib/Cloudflare/Auth/AuthProvider.js` at 2.0.0-beta.76
|
|
32
|
-
* `alchemy/lib/Cloudflare/Auth/AuthConfig.js` at 2.0.0-beta.77
|
|
33
|
-
*
|
|
31
|
+
* `alchemy/lib/Cloudflare/Auth/AuthProvider.js` at 2.0.0-beta.76, in
|
|
32
|
+
* `alchemy/lib/Cloudflare/Auth/AuthConfig.js` at 2.0.0-beta.77, and in
|
|
33
|
+
* `@alchemy.run/cloudflare/lib/Auth/AuthConfig.js` from 2.0.0-beta.84. The
|
|
34
|
+
* file moves; the pattern is the same in all three. Thirty-two zeros pass that shape
|
|
34
35
|
* check and route to nothing.
|
|
35
36
|
*/
|
|
36
37
|
const SENTINEL_ACCOUNT_ID = "0".repeat(32);
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* The renderer logs every line through Effect's pretty console logger, so a
|
|
16
16
|
* line arrives as `[HH:MM:SS.mmm] INFO (#1): <line>`, and coloured when the
|
|
17
17
|
* child inherits `FORCE_COLOR`. Both wrappers are stripped before a line is
|
|
18
|
-
* read. The captured output under `tests/fixtures/plan-output/beta-
|
|
18
|
+
* read. The captured output under `tests/fixtures/plan-output/beta-84/` is
|
|
19
19
|
* the evidence for every shape this file reads.
|
|
20
20
|
*
|
|
21
21
|
* The adapter fails on anything it does not recognise: no summary, two
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
* Stage and stack pairing, and protected-stage policy, from a project-supplied
|
|
3
3
|
* table (#991).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* do not. This module owns the questions. A project supplies the table and gets
|
|
9
|
-
* decisions back, so no project or stack name appears here.
|
|
5
|
+
* This module owns whether a stage is protected, whether it is disposable, and
|
|
6
|
+
* whether a stack may run it. A project supplies the table and gets decisions
|
|
7
|
+
* back, so no project or stack name appears here.
|
|
10
8
|
*
|
|
11
9
|
* One stage name does appear: `local`. It names the local emulator rather than
|
|
12
10
|
* any project's estate, every project spells it the same way, and the question
|
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
* The url-implies-auth invariant: a Worker the internet can reach declares how
|
|
3
3
|
* it is authenticated (#994).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* publish an unauthenticated admin surface is to add `workersDev: true`, a
|
|
7
|
-
* `domain`, or a route to a Worker that never had one. The Worker still works, nothing
|
|
8
|
-
* fails, and the only record of the decision is a diff nobody re-read. This
|
|
9
|
-
* check reads the evaluated graph instead and demands that every publicly
|
|
5
|
+
* This check reads the evaluated graph and demands that every publicly
|
|
10
6
|
* reachable Worker names its guard.
|
|
11
7
|
*
|
|
12
8
|
* What counts as a guard is the project's call, not this module's. Patronage
|
package/src/alchemy-baseline.ts
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* `effect`, so it ships from the root entry, not the `./alchemy` subpath.
|
|
9
9
|
*/
|
|
10
10
|
export const ALCHEMY_BASELINE = {
|
|
11
|
-
alchemy: "2.0.0-beta.
|
|
12
|
-
effect: "4.0.
|
|
11
|
+
alchemy: "2.0.0-beta.84",
|
|
12
|
+
effect: "4.0.6",
|
|
13
13
|
} as const;
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -31,9 +31,17 @@ const BASELINE_PACKAGE_NAMES = Object.keys(
|
|
|
31
31
|
ALCHEMY_BASELINE
|
|
32
32
|
) as (keyof typeof ALCHEMY_BASELINE)[];
|
|
33
33
|
|
|
34
|
+
// From 2.0.0-beta.84 the providers ship as their own packages, each peering
|
|
35
|
+
// on `alchemy` at the exact same version, and pnpm installs a mismatch with
|
|
36
|
+
// only a warning. A consumer that pins one must pin it at the baseline
|
|
37
|
+
// `alchemy` version.
|
|
38
|
+
const ALCHEMY_PROVIDER_PACKAGE_NAMES = ["@alchemy.run/cloudflare"] as const;
|
|
39
|
+
|
|
34
40
|
/**
|
|
35
41
|
* Fails when the consumer's `alchemy` or `effect` pin differs from
|
|
36
|
-
* {@link ALCHEMY_BASELINE},
|
|
42
|
+
* {@link ALCHEMY_BASELINE}, when the pair is incomplete (a pinned Alchemy
|
|
43
|
+
* provider package such as `@alchemy.run/cloudflare` demands both), or when a
|
|
44
|
+
* pinned provider package is not at the baseline `alchemy` version.
|
|
37
45
|
* Alchemy peers on Effect, so an unpinned auto-installed Effect can drift
|
|
38
46
|
* outside the baseline while a lone `alchemy` pin would otherwise pass.
|
|
39
47
|
* Both packages remaining absent is not drift — they are optional peers of
|
|
@@ -47,11 +55,14 @@ export const assertAlchemyBaseline = ({
|
|
|
47
55
|
packageJson,
|
|
48
56
|
}: AssertAlchemyBaselineInput): void => {
|
|
49
57
|
const drifted: string[] = [];
|
|
50
|
-
const pinOf = (name:
|
|
58
|
+
const pinOf = (name: string): string | undefined =>
|
|
51
59
|
packageJson.dependencies?.[name] ?? packageJson.devDependencies?.[name];
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
// A provider pin counts too: it peers on `effect` with a range, so a lone
|
|
61
|
+
// provider pin would let an auto-installed Effect drift off the baseline.
|
|
62
|
+
const pairPresent = [
|
|
63
|
+
...BASELINE_PACKAGE_NAMES,
|
|
64
|
+
...ALCHEMY_PROVIDER_PACKAGE_NAMES,
|
|
65
|
+
].some((name) => pinOf(name) !== undefined);
|
|
55
66
|
|
|
56
67
|
for (const name of BASELINE_PACKAGE_NAMES) {
|
|
57
68
|
const pinned = pinOf(name);
|
|
@@ -67,6 +78,15 @@ export const assertAlchemyBaseline = ({
|
|
|
67
78
|
}
|
|
68
79
|
}
|
|
69
80
|
|
|
81
|
+
for (const name of ALCHEMY_PROVIDER_PACKAGE_NAMES) {
|
|
82
|
+
const pinned = pinOf(name);
|
|
83
|
+
if (pinned !== undefined && pinned !== ALCHEMY_BASELINE.alchemy) {
|
|
84
|
+
drifted.push(
|
|
85
|
+
`${name}@${pinned} (baseline: ${name}@${ALCHEMY_BASELINE.alchemy})`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
70
90
|
if (drifted.length > 0) {
|
|
71
91
|
throw new Error(
|
|
72
92
|
`Alchemy fleet baseline drift: ${drifted.join(", ")}. Bump to match ALCHEMY_BASELINE in @patronage/factory-ci, or wait for the next lockstep release.`
|
|
@@ -4,11 +4,21 @@ import path from "node:path";
|
|
|
4
4
|
import { build } from "esbuild";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Alchemy and Effect must resolve from
|
|
8
|
-
* time, never from the bundle: Alchemy's
|
|
9
|
-
* service tags are identity-sensitive, and a
|
|
7
|
+
* Alchemy, its `@alchemy.run/*` provider packages and Effect must resolve from
|
|
8
|
+
* the *consumer's* node_modules at run time, never from the bundle: Alchemy's
|
|
9
|
+
* resource registry and Effect's service tags are identity-sensitive, and a
|
|
10
|
+
* second copy silently breaks both. Since 2.0.0-beta.84 the providers
|
|
11
|
+
* (`@alchemy.run/cloudflare` and the rest) ship outside core, and they import
|
|
12
|
+
* runtime-only specifiers such as `cloudflare:workers` that no Node bundle can
|
|
13
|
+
* resolve.
|
|
10
14
|
*/
|
|
11
|
-
const ALCHEMY_EXTERNALS = [
|
|
15
|
+
const ALCHEMY_EXTERNALS = [
|
|
16
|
+
"alchemy",
|
|
17
|
+
"alchemy/*",
|
|
18
|
+
"@alchemy.run/*",
|
|
19
|
+
"effect",
|
|
20
|
+
"effect/*",
|
|
21
|
+
];
|
|
12
22
|
|
|
13
23
|
/**
|
|
14
24
|
* The package names behind `ALCHEMY_EXTERNALS`, derived rather than restated so
|
|
@@ -97,7 +107,8 @@ export interface BundleAlchemyEntryOptions {
|
|
|
97
107
|
* `packages: "external"`. Values are resolved the way esbuild resolves any
|
|
98
108
|
* import, so give absolute paths or package names — which aliases a repo
|
|
99
109
|
* needs is the consumer's policy and this package bakes in none. A key on
|
|
100
|
-
* `alchemy`, `effect`, or a subpath of
|
|
110
|
+
* `alchemy`, an `@alchemy.run/*` provider, `effect`, or a subpath of any of
|
|
111
|
+
* them is rejected outright, and the
|
|
101
112
|
* finished bundle is checked for files from those packages however they were
|
|
102
113
|
* reached.
|
|
103
114
|
*/
|
|
@@ -119,15 +130,12 @@ export interface BundleAlchemyEntryOptions {
|
|
|
119
130
|
}
|
|
120
131
|
|
|
121
132
|
/**
|
|
122
|
-
* Pre-bundle an Alchemy entry to a single ESM file, keeping `alchemy
|
|
123
|
-
* `effect` external (#268).
|
|
133
|
+
* Pre-bundle an Alchemy entry to a single ESM file, keeping `alchemy`, its
|
|
134
|
+
* `@alchemy.run/*` providers and `effect` external (#268).
|
|
124
135
|
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* matters. Firedup additionally resolved esbuild *through vite* because it had
|
|
129
|
-
* no direct dependency on it; here esbuild is a plain dependency of this
|
|
130
|
-
* package and that hack can be deleted.
|
|
136
|
+
* The Alchemy CLI runs a JavaScript entry, so a TypeScript `alchemy.run.ts`
|
|
137
|
+
* has to be flattened first, and the flattening must not swallow the
|
|
138
|
+
* packages whose identity matters.
|
|
131
139
|
*
|
|
132
140
|
* Returns the absolute path of the file written.
|
|
133
141
|
*/
|
package/src/disposable-stage.ts
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* The disposable Alchemy stage a local preview deploy runs in:
|
|
3
3
|
* `local-pr-<pr>-<short sha>` (#268).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* does not match is not disposable, and destructive operations must refuse it.
|
|
5
|
+
* A stage that does not match is not disposable, and destructive operations
|
|
6
|
+
* must refuse it.
|
|
8
7
|
*/
|
|
9
8
|
const LOCAL_PREVIEW_STAGE_PATTERN =
|
|
10
9
|
/^local-pr-(?<pr>[1-9]\d*)-(?<sha>[0-9a-f]{7,40})$/u;
|
package/src/github-app-token.ts
CHANGED
|
@@ -7,21 +7,15 @@ import {
|
|
|
7
7
|
setGithubTransportWaitForTests,
|
|
8
8
|
} from "./github-transport.ts";
|
|
9
9
|
|
|
10
|
-
// The error class lives with the transport primitive because `oxlint`'s
|
|
11
|
-
// max-classes-per-file keeps `GitHubApiError` alone in this file. It is
|
|
12
|
-
// re-exported here so the mint surface stays one import for consumers.
|
|
13
10
|
export { GitHubAppTokenTransportError } from "./github-transport.ts";
|
|
14
11
|
|
|
15
12
|
/**
|
|
16
13
|
* Minting a GitHub App installation token: the RS256 app JWT, the optional
|
|
17
14
|
* installation lookup, and the token exchange (#617).
|
|
18
15
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* private key comes from, how the app id is configured, and what the token is
|
|
23
|
-
* then used for stay with each consumer: this module is handed credentials and
|
|
24
|
-
* returns a token.
|
|
16
|
+
* Only the *mechanism* lives here. Where the private key comes from, how the
|
|
17
|
+
* app id is configured, and what the token is then used for stay with each
|
|
18
|
+
* consumer: this module is handed credentials and returns a token.
|
|
25
19
|
*/
|
|
26
20
|
|
|
27
21
|
/** The default request budget, matching the factory's other GitHub writes. */
|
package/src/proof-reuse-gate.ts
CHANGED
|
@@ -5,11 +5,7 @@
|
|
|
5
5
|
* reuse the local verification the factory already published for *this exact
|
|
6
6
|
* head*? It asks that only on a pull request, so every default-branch push
|
|
7
7
|
* executes the full hosted suite (#863). Refusing runs hosted CI; it never
|
|
8
|
-
* fails the candidate.
|
|
9
|
-
* repositories had independently grown their own answer to that question and
|
|
10
|
-
* had already drifted apart, so the answer lives here once, with the App
|
|
11
|
-
* identity, check name, step identity, output names, guard, and every trust
|
|
12
|
-
* predicate fixed rather than consumer-configurable.
|
|
8
|
+
* fails the candidate.
|
|
13
9
|
*
|
|
14
10
|
* What a consumer chooses is only *what its guarded surface requires*: the
|
|
15
11
|
* plain profile command objects that surface selects. Everything else below is
|
|
@@ -136,8 +132,8 @@ export const FACTORY_PROOF_GATE_GUARD = `steps.${FACTORY_PROOF_GATE_STEP_ID}.out
|
|
|
136
132
|
export const FACTORY_PROOF_GATE_IF = "github.event_name == 'pull_request'";
|
|
137
133
|
|
|
138
134
|
/**
|
|
139
|
-
* The complete refusal vocabulary
|
|
140
|
-
*
|
|
135
|
+
* The complete refusal vocabulary: the only distinctions the gate can make
|
|
136
|
+
* from its Checks API reads.
|
|
141
137
|
*
|
|
142
138
|
* - `proven` a covering, passing, unambiguous proof for this exact head
|
|
143
139
|
* - `none` no App-verified factory check run at this commit
|
|
@@ -148,14 +144,11 @@ export const FACTORY_PROOF_GATE_IF = "github.event_name == 'pull_request'";
|
|
|
148
144
|
* cover every required command
|
|
149
145
|
* - `ambiguous` two different generations share the newest instant, the
|
|
150
146
|
* newest repeats another run's verdict with no proof time to
|
|
151
|
-
* tell them apart, a run's start time cannot be ranked,
|
|
152
|
-
* newest pass
|
|
153
|
-
*
|
|
147
|
+
* tell them apart, a run's start time cannot be ranked, the
|
|
148
|
+
* newest pass records no verification start beside another run
|
|
149
|
+
* at this head (#1514), or the newest pass started before
|
|
150
|
+
* another run at this head was posted
|
|
154
151
|
* - `error` the gate could not reach a decision (fail open)
|
|
155
|
-
*
|
|
156
|
-
* There is no `reduced`: mode stopped being an authorization condition in
|
|
157
|
-
* ADR 0022, so a narrower run that still executed every required command is
|
|
158
|
-
* indistinguishable from a full one *for this surface*, which is the point.
|
|
159
152
|
*/
|
|
160
153
|
export const FACTORY_PROOF_GATE_REASONS = [
|
|
161
154
|
"proven",
|
|
@@ -269,31 +262,12 @@ export const proofReuseRequiredCommands = (
|
|
|
269
262
|
};
|
|
270
263
|
|
|
271
264
|
/**
|
|
272
|
-
* Resolve command
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
* surface requires. What both of those implementations independently
|
|
279
|
-
* hand-rolled is the same lookup — find each name in the profile's command
|
|
280
|
-
* catalog, and refuse to silently shrink the required set when a name has no
|
|
281
|
-
* entry. That lookup is what this function is: the mechanic, not the
|
|
282
|
-
* selection.
|
|
283
|
-
*
|
|
284
|
-
* Throwing at generation time (rather than returning `undefined` or an empty
|
|
285
|
-
* array) is deliberate: a name with no catalog entry is a mistake in the
|
|
286
|
-
* generator source, not a runtime condition a consumer should have to check
|
|
287
|
-
* for, and a required set that quietly loses an entry is exactly what makes a
|
|
288
|
-
* passing proof trivially "covering".
|
|
289
|
-
*
|
|
290
|
-
* `selectionLabel` names the failure, nothing else: it is not part of the
|
|
291
|
-
* selection this function resolves, only prose a consumer supplies for its
|
|
292
|
-
* own thrown error (e.g. HQ's surface name, "core" or "docs"). The message
|
|
293
|
-
* deliberately says "the profile's command catalog" rather than naming
|
|
294
|
-
* `software-factory.profile.json`: a fleet-generic library must not assume
|
|
295
|
-
* every consumer's catalog is that exact file, so this wording differs
|
|
296
|
-
* on purpose from the HQ-local message it replaced.
|
|
265
|
+
* Resolve command identities to their `ProofReuseCommand` objects (ADR 0021).
|
|
266
|
+
* Which names a surface requires is the consumer's choice; this is only the
|
|
267
|
+
* lookup. A name with no catalog entry throws at generation time, because a
|
|
268
|
+
* required set that quietly loses an entry makes any passing proof covering.
|
|
269
|
+
* The message says "the profile's command catalog" rather than a file name,
|
|
270
|
+
* since not every consumer's catalog is `software-factory.profile.json`.
|
|
297
271
|
*/
|
|
298
272
|
export const resolveProofReuseCommands = (
|
|
299
273
|
catalog: readonly ProofReuseCommand[],
|
|
@@ -681,15 +655,8 @@ def releaseAuthorized($release; $commands; $stamp):
|
|
|
681
655
|
| join("\n")
|
|
682
656
|
`.trim();
|
|
683
657
|
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
* produces the proof this job looks for, so it is the corrective action
|
|
687
|
-
* whatever the refusal was.
|
|
688
|
-
*
|
|
689
|
-
* It is phrased as an option, not a reprimand. A pull request opened by hand
|
|
690
|
-
* has no factory proof and never will; the full suite running for it is the
|
|
691
|
-
* designed behavior, not a mistake to report.
|
|
692
|
-
*/
|
|
658
|
+
// Phrased as an option, not a reprimand: a hand-opened pull request has no
|
|
659
|
+
// factory proof, and the full suite running for it is the designed behavior.
|
|
693
660
|
const CORRECTIVE_LINE =
|
|
694
661
|
"Run `psf pr:verify` before publishing to reuse local proof and avoid a duplicate server run.";
|
|
695
662
|
|
|
@@ -980,9 +947,7 @@ export const factoryProofGateStep = (
|
|
|
980
947
|
continueOnError: true as const,
|
|
981
948
|
env: Object.freeze({
|
|
982
949
|
GH_TOKEN: githubExpression("secrets.GITHUB_TOKEN"),
|
|
983
|
-
//
|
|
984
|
-
// never runs on a push, so no reachable path reads the `github.sha`
|
|
985
|
-
// half.
|
|
950
|
+
// The step never runs on a push, so the `github.sha` half is unreachable.
|
|
986
951
|
HEAD_SHA: githubExpression(
|
|
987
952
|
"github.event.pull_request.head.sha || github.sha"
|
|
988
953
|
),
|
|
@@ -999,11 +964,6 @@ export const factoryProofGateStep = (
|
|
|
999
964
|
export interface ProofReuseCoverageInput {
|
|
1000
965
|
/** The same selection handed to the gate for this surface. */
|
|
1001
966
|
readonly commands: readonly ProofReuseCommand[];
|
|
1002
|
-
/**
|
|
1003
|
-
* @deprecated Ignored. Consumer prose cannot authorize executable coverage;
|
|
1004
|
-
* retained only so the 0.2.1 security patch remains source-compatible.
|
|
1005
|
-
*/
|
|
1006
|
-
readonly equivalents?: Readonly<Record<string, string>>;
|
|
1007
967
|
/**
|
|
1008
968
|
* The command strings the consumer's workflow would skip when the gate says
|
|
1009
969
|
* `true`, already resolved to the leaves that actually run. Extracting them
|
|
@@ -60,9 +60,6 @@ say '## ${label} timing'
|
|
|
60
60
|
say ''
|
|
61
61
|
|
|
62
62
|
if [ "${shellExpansion("GITHUB_EVENT_NAME:-")}" = 'push' ] && [ -z "${shellExpansion("PROOF_REASON:-")}" ]; then
|
|
63
|
-
# A push run with no recorded reason is one where the gate step's condition
|
|
64
|
-
# kept it off entirely, so the full suite ran with no reuse decision. The
|
|
65
|
-
# gate runs on pull requests only (#863), so that is every push.
|
|
66
63
|
say '- Path: full execution, no proof consulted'
|
|
67
64
|
say '- Proof-reuse gate: did not run on this ref; the full suite ran.'
|
|
68
65
|
say "- Verified head: \`${shellExpansion("GITHUB_SHA:-unknown")}\`"
|
|
@@ -12,11 +12,7 @@ const UPLOAD_ARTIFACT_REPOSITORY = UPLOAD_ARTIFACT.uses.slice(
|
|
|
12
12
|
);
|
|
13
13
|
|
|
14
14
|
export const FACTORY_PUSH_IDENTITY_SCHEMA_VERSION = 1;
|
|
15
|
-
|
|
16
|
-
* The artifact prefix and the five step IDs are module-private. Alpha.13
|
|
17
|
-
* removed them from the public surface (#719). A caller reads a step ID from
|
|
18
|
-
* the builder's returned `steps` (`step.id`) or from `artifactName`.
|
|
19
|
-
*/
|
|
15
|
+
|
|
20
16
|
const FACTORY_PUSH_IDENTITY_ARTIFACT_PREFIX = "factory-push-identity";
|
|
21
17
|
const FACTORY_PUSH_IDENTITY_RECORD_STEP_ID = "factory_push_identity_record";
|
|
22
18
|
const FACTORY_PUSH_IDENTITY_LOOKUP_STEP_ID = "factory_push_identity_lookup";
|