@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/README.md +73 -5
- package/dist/.build-fingerprint.json +1 -1
- package/dist/alchemy/index.d.ts +7 -23
- package/dist/alchemy/index.js +12 -32
- package/dist/{bundle-alchemy-entry-CT5hCphA.js → bundle-alchemy-entry-BuMrl5fR.js} +3 -6
- package/dist/{execute-alchemy-entry-B397GSk5.d.ts → execute-alchemy-entry-BR5dFO9k.d.ts} +3 -6
- package/dist/{execute-alchemy-entry-C2ZhsNTN.js → execute-alchemy-entry-CDMdbXIi.js} +14 -8
- package/dist/index.d.ts +316 -51
- package/dist/index.js +611 -115
- package/package.json +4 -3
- 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 +0 -14
- 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 +3 -6
- package/src/disposable-stage.ts +2 -3
- package/src/github-app-token.ts +3 -9
- package/src/index.ts +44 -0
- package/src/preview-cleanup-workflow.ts +422 -0
- package/src/preview-cleanup.ts +688 -0
- package/src/proof-reuse-gate.ts +43 -58
- package/src/proof-reuse-presentation.ts +0 -3
- package/src/push-identity-workflow.ts +1 -5
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ const steps = [
|
|
|
61
61
|
|
|
62
62
|
This selection is stable under a renamed step or an added supported role: `setupStepsForRoles` reads named roles from `setupStepsByRole`, never array shape.
|
|
63
63
|
|
|
64
|
-
Every action is validated as `owner/repo@<full sha>`, with its release tag kept separately. A complete `actionFamily` is required; there is no default that could silently move a consumer between action majors. `NODE_PNPM_ACTION_FAMILY_NODE24` is the canonical family whose checkout, Node setup, and pnpm setup actions all declare a Node 24 JavaScript runtime. Generated workflows read Node from `.nvmrc`. This repository pins 24.
|
|
64
|
+
Every action is validated as `owner/repo@<full sha>`, with its release tag kept separately. A complete `actionFamily` is required; there is no default that could silently move a consumer between action majors. `NODE_PNPM_ACTION_FAMILY_NODE24` is the canonical family whose checkout, Node setup, and pnpm setup actions all declare a Node 24 JavaScript runtime. Generated workflows read Node from `.nvmrc`. This repository pins 24.
|
|
65
65
|
|
|
66
66
|
```ts
|
|
67
67
|
const generated = factoryWorkflow({
|
|
@@ -308,6 +308,72 @@ const jobs = [
|
|
|
308
308
|
|
|
309
309
|
The audit job is `always()` so a failed destroy still runs the stage-wide check. It does not receive a stack name or path filter — per-stack audit filters are rejected because they trade away the whole-stage guarantee (paitronage#1143). `previewCleanupDestroyJobId(stack)` is the same id mapping callers can use when they assemble destroy jobs by hand.
|
|
310
310
|
|
|
311
|
+
### Closed-PR cleanup and the orphan sweep
|
|
312
|
+
|
|
313
|
+
`factoryPreviewCleanupWorkflow` (#1540) builds the whole cleanup on that topology, so each consumer stops carrying its own copy. It owns target discovery, the per-stack destroy matrices, outcome recording and the stage-wide audit. The consumer keeps its stack list, a one-line destroy command, a one-line residue reader, credentials and protected-stage policy.
|
|
314
|
+
|
|
315
|
+
```ts
|
|
316
|
+
import {
|
|
317
|
+
factoryPreviewCleanupWorkflow,
|
|
318
|
+
setupStepsForRoles,
|
|
319
|
+
} from "@patronage/factory-ci";
|
|
320
|
+
|
|
321
|
+
const cleanup = factoryPreviewCleanupWorkflow({
|
|
322
|
+
stacks: ["website", "loop", "flue-agents"],
|
|
323
|
+
stackAliases: { "preview-deploy-website": "website" },
|
|
324
|
+
hostedStagePrefix: "pr-", // omit when there is no hosted pr-N stage
|
|
325
|
+
environment: "preview-cleanup",
|
|
326
|
+
createGithubAppToken: generated.actions.createGithubAppToken,
|
|
327
|
+
residueCommand: "node tools/cleanup-residue.ts",
|
|
328
|
+
destroyCommand:
|
|
329
|
+
'pnpm alchemy:destroy "$FACTORY_PREVIEW_CLEANUP_STACK" "$FACTORY_PREVIEW_CLEANUP_STAGE"',
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
const setup = [
|
|
333
|
+
{
|
|
334
|
+
...generated.setupStepsByRole.checkout,
|
|
335
|
+
with: { ref: cleanup.checkoutRef },
|
|
336
|
+
},
|
|
337
|
+
...setupStepsForRoles(generated, ["setupPnpm", "setupNode", "install"]),
|
|
338
|
+
];
|
|
339
|
+
const discover = job(cleanup.discoverJob.jobId, {
|
|
340
|
+
...cleanup.discoverJob,
|
|
341
|
+
runsOn,
|
|
342
|
+
env: credentials,
|
|
343
|
+
steps: [...setup, ...cleanup.discoverJob.steps],
|
|
344
|
+
});
|
|
345
|
+
const destroys = cleanup.destroyJobs.map((destroy) =>
|
|
346
|
+
job(destroy.jobId, {
|
|
347
|
+
...destroy,
|
|
348
|
+
needs: [discover],
|
|
349
|
+
runsOn,
|
|
350
|
+
env: credentials,
|
|
351
|
+
steps: [...setup, ...destroy.steps],
|
|
352
|
+
})
|
|
353
|
+
);
|
|
354
|
+
const audit = job(cleanup.auditJob.jobId, {
|
|
355
|
+
...cleanup.auditJob,
|
|
356
|
+
needs: [discover, ...destroys],
|
|
357
|
+
runsOn,
|
|
358
|
+
env: { ...credentials, ...cleanup.auditJob.env },
|
|
359
|
+
steps: [...setup, ...cleanup.auditJob.steps],
|
|
360
|
+
});
|
|
361
|
+
workflow({
|
|
362
|
+
on: cleanup.on,
|
|
363
|
+
permissions: cleanup.permissions,
|
|
364
|
+
jobs: [discover, ...destroys, audit],
|
|
365
|
+
});
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
- **Gate.** Every credentialed job runs in the named GitHub `environment`. The discover job runs for a closed PR whose head is this repository (`FACTORY_PREVIEW_CLEANUP_PR_CLOSED_CONDITION`), on the schedule, or on a dispatch from the default branch (`FACTORY_PREVIEW_CLEANUP_SWEEP_CONDITION`). Nothing reads a production deploy flag. Check out `checkoutRef`, the default branch, never the closed head.
|
|
369
|
+
- **Discover.** For a closed PR, the PR's inventory registrations are united with the residue, keeping only `local-pr-<pr>-*` stages and the hosted `<prefix><pr>` stage in declared stacks (`discoverPreviewCleanupTargets`). The sweep keeps the residue of PRs GitHub reports closed (`discoverOrphanedPreviewCleanupTargets`, `readPullRequestStates`). It fails closed: a stage that does not parse as disposable, an undeclared stack, and an open or unknown PR are all retained. A sweep handles up to `sweep.maxTargets` targets (50) per run and leaves the rest for the next one. It takes each stage whole across its stacks, so a run goes over the cap only when its first stage alone has more stacks than the cap. Pass `sweep: false` for PR-close cleanup only.
|
|
370
|
+
- **Residue.** `residueCommand` prints `[{ "stack": …, "stage": … }]`. Map physical resources to a stack and stage before printing them; this package never guesses a resource's owner.
|
|
371
|
+
- **Destroy.** `destroyCommand` reads `$FACTORY_PREVIEW_CLEANUP_STACK` and `$FACTORY_PREVIEW_CLEANUP_STAGE` (and `$FACTORY_PREVIEW_CLEANUP_PR`), exits non-zero when it did not destroy, and may append evidence lines to `$FACTORY_PREVIEW_CLEANUP_EVIDENCE`. Matrix values reach the shell through the environment, never interpolated into the script.
|
|
372
|
+
- **Record.** After each destroy, `recordPreviewCleanupOutcome` lists the registration with the workflow token and writes the passed or failed outcome, with the evidence and run URL, through the Factory App token. A stage nothing registered records nothing. A registration whose last cleanup failed is recovered through the same transition.
|
|
373
|
+
- **Audit.** The audit re-reads the residue after every destroy and fails if any target stage remains under any stack (`assertPreviewCleanupTargetsAbsent`).
|
|
374
|
+
|
|
375
|
+
The invocable half is `psf preview:cleanup --action discover|sweep|record|audit`; the generated steps call it with `cli` (default `pnpm exec psf`).
|
|
376
|
+
|
|
311
377
|
### Merge-freeze writer job
|
|
312
378
|
|
|
313
379
|
```ts
|
|
@@ -545,6 +611,8 @@ import { ALCHEMY_SUBPATH, evaluateStack } from "@patronage/factory-ci/alchemy";
|
|
|
545
611
|
|
|
546
612
|
Install `alchemy` and `effect` yourself before importing it. The published ranges are `>=2.0.0-beta.63 <3` and `>=4.0.0-beta.98 <5`, the same ones `@patronage/alchemy-d1-state` carries, and both are marked optional so an installation that never touches this surface stays quiet.
|
|
547
613
|
|
|
614
|
+
From Alchemy 2.0.0-beta.84 the providers ship as their own packages: a Cloudflare stack imports `@alchemy.run/cloudflare`, not `alchemy/Cloudflare`, and installs it at the same exact version as `alchemy` (it peers on that version). The subpath imports no provider package, so it adds no peer for one; this workspace carries `@alchemy.run/cloudflare` as a devDependency only for the tests that build a Cloudflare stack.
|
|
615
|
+
|
|
548
616
|
The published ranges are wide, but the workspace pins one copy: `alchemy` and `effect` are devDependencies here at the same versions `@patronage/alchemy-d1-state` and `software-factory-hq` pin. Without that pin pnpm resolves the peer range to its newest release for this importer alone, which is a second copy of both in the workspace and a lockfile that no longer installs. `evaluateStack` imports both, so `knip` sees them used.
|
|
549
617
|
|
|
550
618
|
`ALCHEMY_SUBPATH` is the specifier itself. Stage policy, retained-identity asserts, the lifecycle guards, stack evaluation, and the graph invariants ship here. The Alchemy entry helpers named above (`bundleAlchemyEntry`, `executeAlchemyEntry`) stay on the package root, where they belong: they shell out to the consumer's Alchemy CLI and import neither package.
|
|
@@ -752,7 +820,7 @@ const graph = await evaluateStack({
|
|
|
752
820
|
|
|
753
821
|
`evaluateStack` runs a stack program at one stage and returns the graph Alchemy would plan, with no state store and no network. It wraps Alchemy's `Plan.make`: the program registers its resources under a `Stack` service, then the plan builds under `inMemoryState()` at the requested `Stage`. Every provider answers its `read` and `list` probes with "absent", so the cold-adoption probe `Plan.make` makes for a resource with resolved props and no prior state never leaves the process. A stage the program returns from early (paitronage's `placeholder` stage) evaluates to an empty graph.
|
|
754
822
|
|
|
755
|
-
`program` is the effect the consumer hands `Alchemy.Stack`, not the `Alchemy.Stack(...)` value. The value captures the consumer's real `providers` and `state` layers, and at Alchemy 2.0.0-beta.
|
|
823
|
+
`program` is the effect the consumer hands `Alchemy.Stack`, not the `Alchemy.Stack(...)` value. The value captures the consumer's real `providers` and `state` layers, and at Alchemy 2.0.0-beta.84 building `Cloudflare.providers()` (from `@alchemy.run/cloudflare`) is not inert (`ProfileStoreLive` inside `CloudflareApiLive` writes `~/.alchemy/profiles/default`, and the layer needs the `AuthProviders` service), so evaluating the value cannot stay free of side effects. Export the program next to the stack:
|
|
756
824
|
|
|
757
825
|
```ts
|
|
758
826
|
export const program = Effect.gen(function* () {
|
|
@@ -763,7 +831,7 @@ export default Alchemy.Stack("hq", { providers, state }, program);
|
|
|
763
831
|
|
|
764
832
|
Pass `providers` when the program depends on hand-written provider layers. Every provider that layer registers keeps its identity (`stables`, `aliases`, `diff`) and loses its probes; an unregistered resource type still evaluates. Each graph resource carries the `LogicalId`, `Type`, and raw `Props` of its plan node, so a prop may hold an unresolved Alchemy output. `upstreamByProp` names, per top-level prop, the logical ids that prop's value references, which is the only way to read a cross-resource reference out of raw props: an output is a function, so the prop that holds it says nothing on its own. A prop that references nothing carries no key. The references are kept per prop and never pooled into one list, so a caller asking which resources one prop names is never answered with an id a different prop mentioned. Each binding row comes from Alchemy's Worker binding channel: `worker` is the host's logical id, `name` and `type` are the strings Alchemy emits (`d1`, `kv_namespace`, `secrets_store_secret`, and so on), and `target` is the logical id of the resource the row references, when it references one.
|
|
765
833
|
|
|
766
|
-
The caller's `providers` layer is **built** before its probes are stubbed: `evaluateStack` wraps that layer, and Alchemy's own lookup resolves each provider out of it before `read` and `list` are replaced. So any side effect a layer performs at construction — a credential read, a network call, a file write — is the caller's, and happens. This is why `Cloudflare.providers()` must not be passed: at beta.
|
|
834
|
+
The caller's `providers` layer is **built** before its probes are stubbed: `evaluateStack` wraps that layer, and Alchemy's own lookup resolves each provider out of it before `read` and `list` are replaced. So any side effect a layer performs at construction — a credential read, a network call, a file write — is the caller's, and happens. This is why `Cloudflare.providers()` must not be passed: at beta.84 its `CloudflareApiLive` still creates `~/.alchemy/profiles/default` and requires `AuthProviders` when it builds, before there is anything to stub. Beta.77 also resolved credentials there (`Credentials.fromAuthProvider`); beta.81 deferred that to first use and beta.84 still does. The no-network guarantee covers evaluation, not layer construction: pass only layers whose construction is inert.
|
|
767
835
|
|
|
768
836
|
The helper decides nothing about the graph. Invariants over it are separate exports; `assertUrlImpliesAuth` below is the first.
|
|
769
837
|
|
|
@@ -799,9 +867,9 @@ The factory's own security review prompt carries the same rule in prose, so a re
|
|
|
799
867
|
import { ALCHEMY_BASELINE, assertAlchemyBaseline } from "@patronage/factory-ci";
|
|
800
868
|
```
|
|
801
869
|
|
|
802
|
-
`ALCHEMY_BASELINE` is the exact `alchemy` and `effect` pair the fleet moves together on: `{ alchemy: "2.0.0-beta.
|
|
870
|
+
`ALCHEMY_BASELINE` is the exact `alchemy` and `effect` pair the fleet moves together on: `{ alchemy: "2.0.0-beta.84", effect: "4.0.6" }`. It is a plain constant on the root entry — it imports neither package — so any consumer can read it without installing the `./alchemy` subpath's peers.
|
|
803
871
|
|
|
804
|
-
`assertAlchemyBaseline({ packageJson })` is a consumer contract helper: it fails when the consumer's own `dependencies` or `devDependencies` pin `alchemy` or `effect` to anything other than the baseline,
|
|
872
|
+
`assertAlchemyBaseline({ packageJson })` is a consumer contract helper: it fails when the consumer's own `dependencies` or `devDependencies` pin `alchemy` or `effect` to anything other than the baseline, when only one of the pair is present, when `@alchemy.run/cloudflare` is pinned without both of them, or when a pinned `@alchemy.run/cloudflare` is not at the baseline `alchemy` version. Alchemy peers on Effect, so an unpinned auto-installed Effect can drift outside the baseline while a lone `alchemy` pin would otherwise pass. Both packages remaining absent is not drift — they are optional peers of the subpath, so a consumer that never imports it, such as this package's own CLI, carries neither and passes. The pin is exact, not a range: the fleet is pre-1.0 and moves together, so a range would let one project drift silently ahead of or behind the rest. `assertAlchemyBaseline` reads only the object it is handed; it never walks the filesystem or reads a lockfile. Call it from a consumer's own contract test, passing that consumer's parsed `package.json`.
|
|
805
873
|
|
|
806
874
|
The baseline bumps only in a lockstep release: the same commit that bumps `@patronage/factory-ci`'s own `alchemy`/`effect` devDependencies and the `./alchemy` subpath's peer ranges (ADR 0031) also bumps `ALCHEMY_BASELINE`, so the constant a consumer's contract test checks against can never point at a version the subpath itself has moved past.
|
|
807
875
|
|
package/dist/alchemy/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ExecuteAlchemyEntryOptions } from "../execute-alchemy-entry-
|
|
1
|
+
import { n as ExecuteAlchemyEntryOptions } from "../execute-alchemy-entry-BR5dFO9k.js";
|
|
2
2
|
import * as Alchemy from "alchemy";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as Layer from "effect/Layer";
|
|
@@ -222,11 +222,9 @@ declare const localEmulationEnvironment: (options: {
|
|
|
222
222
|
* Stage and stack pairing, and protected-stage policy, from a project-supplied
|
|
223
223
|
* table (#991).
|
|
224
224
|
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
* do not. This module owns the questions. A project supplies the table and gets
|
|
229
|
-
* decisions back, so no project or stack name appears here.
|
|
225
|
+
* This module owns whether a stage is protected, whether it is disposable, and
|
|
226
|
+
* whether a stack may run it. A project supplies the table and gets decisions
|
|
227
|
+
* back, so no project or stack name appears here.
|
|
230
228
|
*
|
|
231
229
|
* One stage name does appear: `local`. It names the local emulator rather than
|
|
232
230
|
* any project's estate, every project spells it the same way, and the question
|
|
@@ -325,15 +323,6 @@ declare const stagePolicy: (table: StagePolicyTable) => StagePolicy;
|
|
|
325
323
|
/**
|
|
326
324
|
* Cloudflare credential preflight for an Alchemy deploy.
|
|
327
325
|
*
|
|
328
|
-
* Two projects built this twice. Paitronage
|
|
329
|
-
* (`scripts/alchemy/credential-preflight.ts` plus
|
|
330
|
-
* `scripts/alchemy/cloudflare-token-policy.ts`) and firedup
|
|
331
|
-
* (`scripts/alchemy/local-credentials.ts`) both resolve a Cloudflare API
|
|
332
|
-
* token, verify it is live, and refuse to deploy unless its permission groups
|
|
333
|
-
* match an exact reviewed list. What repeats is the check. What does not
|
|
334
|
-
* repeat is the account, the permission list, the resource scope, and where
|
|
335
|
-
* the credential comes from, so every one of those is an input.
|
|
336
|
-
*
|
|
337
326
|
* **No credential value is ever printed.** Errors name environment variables and
|
|
338
327
|
* missing groups from the caller-owned permission requirements. Untrusted API
|
|
339
328
|
* status, receipt group names, and resource identifiers are never reflected.
|
|
@@ -444,11 +433,7 @@ declare const credentialPreflight: ({
|
|
|
444
433
|
*
|
|
445
434
|
* Alchemy's `destroy` can exit zero while the state store still lists
|
|
446
435
|
* resources for the stage — a partial destroy, a resource whose delete failed
|
|
447
|
-
* quietly, or a state row that was never removed.
|
|
448
|
-
* store after the child exits rather than trusting the exit code
|
|
449
|
-
* (`runAlchemyLifecycle`, the `"Alchemy destroy left target-stage state
|
|
450
|
-
* registered."` branch). Firedup carries no equivalent, which is exactly the
|
|
451
|
-
* gap this closes.
|
|
436
|
+
* quietly, or a state row that was never removed.
|
|
452
437
|
*
|
|
453
438
|
* Reading the state store is the project's job: only the project knows which
|
|
454
439
|
* store it configured and how to address a stage in it. This function owns the
|
|
@@ -744,7 +729,7 @@ declare const isAlchemyLifecycleError: (error: unknown) => error is AlchemyLifec
|
|
|
744
729
|
* The renderer logs every line through Effect's pretty console logger, so a
|
|
745
730
|
* line arrives as `[HH:MM:SS.mmm] INFO (#1): <line>`, and coloured when the
|
|
746
731
|
* child inherits `FORCE_COLOR`. Both wrappers are stripped before a line is
|
|
747
|
-
* read. The captured output under `tests/fixtures/plan-output/beta-
|
|
732
|
+
* read. The captured output under `tests/fixtures/plan-output/beta-84/` is
|
|
748
733
|
* the evidence for every shape this file reads.
|
|
749
734
|
*
|
|
750
735
|
* The adapter fails on anything it does not recognise: no summary, two
|
|
@@ -821,8 +806,7 @@ declare const parsePlanEffects: (output: string) => PlanEffects;
|
|
|
821
806
|
* else: the child's output is parsed and dropped, so no secret in it can
|
|
822
807
|
* reach a job log or an evidence file through the operation. That is the
|
|
823
808
|
* right default and it stays the default. It also leaves an operator with a
|
|
824
|
-
* failure code and no record of what failed
|
|
825
|
-
* investigation its evidence.
|
|
809
|
+
* failure code and no record of what failed.
|
|
826
810
|
*
|
|
827
811
|
* This is the opt-in other half: a consumer that names a file gets every
|
|
828
812
|
* child's streams appended to it, each stream passed whole through the
|
package/dist/alchemy/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as isLocalPreviewStage, n as executeAlchemyEntry, r as resolveAlchemyChildCwd, s as ALCHEMY_BASELINE } from "../execute-alchemy-entry-
|
|
1
|
+
import { i as isLocalPreviewStage, n as executeAlchemyEntry, r as resolveAlchemyChildCwd, s as ALCHEMY_BASELINE } from "../execute-alchemy-entry-CDMdbXIi.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
@@ -167,15 +167,6 @@ const assertRetainedIdentities = ({ after, before, markers }) => {
|
|
|
167
167
|
/**
|
|
168
168
|
* Cloudflare credential preflight for an Alchemy deploy.
|
|
169
169
|
*
|
|
170
|
-
* Two projects built this twice. Paitronage
|
|
171
|
-
* (`scripts/alchemy/credential-preflight.ts` plus
|
|
172
|
-
* `scripts/alchemy/cloudflare-token-policy.ts`) and firedup
|
|
173
|
-
* (`scripts/alchemy/local-credentials.ts`) both resolve a Cloudflare API
|
|
174
|
-
* token, verify it is live, and refuse to deploy unless its permission groups
|
|
175
|
-
* match an exact reviewed list. What repeats is the check. What does not
|
|
176
|
-
* repeat is the account, the permission list, the resource scope, and where
|
|
177
|
-
* the credential comes from, so every one of those is an input.
|
|
178
|
-
*
|
|
179
170
|
* **No credential value is ever printed.** Errors name environment variables and
|
|
180
171
|
* missing groups from the caller-owned permission requirements. Untrusted API
|
|
181
172
|
* status, receipt group names, and resource identifiers are never reflected.
|
|
@@ -339,11 +330,9 @@ const credentialPreflight = async ({ accountId, environment, fetchImplementation
|
|
|
339
330
|
* Stage and stack pairing, and protected-stage policy, from a project-supplied
|
|
340
331
|
* table (#991).
|
|
341
332
|
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
* do not. This module owns the questions. A project supplies the table and gets
|
|
346
|
-
* decisions back, so no project or stack name appears here.
|
|
333
|
+
* This module owns whether a stage is protected, whether it is disposable, and
|
|
334
|
+
* whether a stack may run it. A project supplies the table and gets decisions
|
|
335
|
+
* back, so no project or stack name appears here.
|
|
347
336
|
*
|
|
348
337
|
* One stage name does appear: `local`. It names the local emulator rather than
|
|
349
338
|
* any project's estate, every project spells it the same way, and the question
|
|
@@ -488,9 +477,10 @@ const [ACCOUNT_ID_NAME, API_TOKEN_NAME] = HOSTED_CLOUDFLARE_CREDENTIAL_NAMES;
|
|
|
488
477
|
* Alchemy validates the value against `/^[0-9a-f]{32}$/i` and rejects
|
|
489
478
|
* placeholders such as `""` or `dummy` with an authentication error before any
|
|
490
479
|
* run starts. The check is `validateAccountId`, in
|
|
491
|
-
* `alchemy/lib/Cloudflare/Auth/AuthProvider.js` at 2.0.0-beta.76
|
|
492
|
-
* `alchemy/lib/Cloudflare/Auth/AuthConfig.js` at 2.0.0-beta.77
|
|
493
|
-
*
|
|
480
|
+
* `alchemy/lib/Cloudflare/Auth/AuthProvider.js` at 2.0.0-beta.76, in
|
|
481
|
+
* `alchemy/lib/Cloudflare/Auth/AuthConfig.js` at 2.0.0-beta.77, and in
|
|
482
|
+
* `@alchemy.run/cloudflare/lib/Auth/AuthConfig.js` from 2.0.0-beta.84. The
|
|
483
|
+
* file moves; the pattern is the same in all three. Thirty-two zeros pass that shape
|
|
494
484
|
* check and route to nothing.
|
|
495
485
|
*/
|
|
496
486
|
const SENTINEL_ACCOUNT_ID = "0".repeat(32);
|
|
@@ -585,7 +575,7 @@ const assertDestroyLeftNothing = async ({ stack, stage, stateReader }) => {
|
|
|
585
575
|
* The renderer logs every line through Effect's pretty console logger, so a
|
|
586
576
|
* line arrives as `[HH:MM:SS.mmm] INFO (#1): <line>`, and coloured when the
|
|
587
577
|
* child inherits `FORCE_COLOR`. Both wrappers are stripped before a line is
|
|
588
|
-
* read. The captured output under `tests/fixtures/plan-output/beta-
|
|
578
|
+
* read. The captured output under `tests/fixtures/plan-output/beta-84/` is
|
|
589
579
|
* the evidence for every shape this file reads.
|
|
590
580
|
*
|
|
591
581
|
* The adapter fails on anything it does not recognise: no summary, two
|
|
@@ -937,10 +927,7 @@ const canonicalPlan = (output) => {
|
|
|
937
927
|
*
|
|
938
928
|
* The first deploy of a stack into a stage is the one deploy no earlier state
|
|
939
929
|
* can constrain: there is nothing to diff against, so the plan is the only
|
|
940
|
-
* description of what is about to be created.
|
|
941
|
-
* operator decision by hashing it and comparing the hash against a reviewed
|
|
942
|
-
* value (`firstDeployPlanSha256` and `assertFirstDeployEntry` in
|
|
943
|
-
* `tools/alchemy/src/internal/lifecycle.ts`).
|
|
930
|
+
* description of what is about to be created.
|
|
944
931
|
*
|
|
945
932
|
* The generic form keeps the binding and drops the project's stage policy.
|
|
946
933
|
* Which stages are eligible, and where the authorized hashes are kept, stay
|
|
@@ -1383,8 +1370,7 @@ const deleteStageRows = async (state, target) => {
|
|
|
1383
1370
|
* else: the child's output is parsed and dropped, so no secret in it can
|
|
1384
1371
|
* reach a job log or an evidence file through the operation. That is the
|
|
1385
1372
|
* right default and it stays the default. It also leaves an operator with a
|
|
1386
|
-
* failure code and no record of what failed
|
|
1387
|
-
* investigation its evidence.
|
|
1373
|
+
* failure code and no record of what failed.
|
|
1388
1374
|
*
|
|
1389
1375
|
* This is the opt-in other half: a consumer that names a file gets every
|
|
1390
1376
|
* child's streams appended to it, each stream passed whole through the
|
|
@@ -1463,12 +1449,6 @@ const openChildDiagnostics = ({ child, diagnostics, operation, stack, stage }) =
|
|
|
1463
1449
|
* back a fixed-shape result or an `AlchemyLifecycleError`. It cannot call the
|
|
1464
1450
|
* steps in another order, because it does not call the steps.
|
|
1465
1451
|
*
|
|
1466
|
-
* Paitronage and HQ each reconstructed this sequence from the guards in
|
|
1467
|
-
* `./` and got parts of it wrong in different ways (paitronage#1917): a
|
|
1468
|
-
* post-child failure reported as not started, an empty-stage cleanup racing
|
|
1469
|
-
* a concurrent write, a plan whose immutability check ignored stack output.
|
|
1470
|
-
* The sequence below is the one both were reaching for.
|
|
1471
|
-
*
|
|
1472
1452
|
* What stays with the consumer: the resource graph, the credentials and
|
|
1473
1453
|
* environment the child runs with, the stage table, the retained-identity
|
|
1474
1454
|
* markers, the first-deploy authorization list, and the state store's own
|
|
@@ -1645,7 +1625,7 @@ var LifecycleRun = class {
|
|
|
1645
1625
|
return;
|
|
1646
1626
|
}
|
|
1647
1627
|
try {
|
|
1648
|
-
const { bundleAlchemyEntry } = await import("../bundle-alchemy-entry-
|
|
1628
|
+
const { bundleAlchemyEntry } = await import("../bundle-alchemy-entry-BuMrl5fR.js").then((n) => n.n);
|
|
1649
1629
|
this.bundledEntry = await bundleAlchemyEntry(this.entry.bundle);
|
|
1650
1630
|
} catch {
|
|
1651
1631
|
throw this.fail("PREPARATION_FAILED", "admission");
|
|
@@ -75,12 +75,9 @@ const assertNoReservedInputs = (inputs) => {
|
|
|
75
75
|
* Pre-bundle an Alchemy entry to a single ESM file, keeping `alchemy` and
|
|
76
76
|
* `effect` external (#268).
|
|
77
77
|
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* matters. Firedup additionally resolved esbuild *through vite* because it had
|
|
82
|
-
* no direct dependency on it; here esbuild is a plain dependency of this
|
|
83
|
-
* package and that hack can be deleted.
|
|
78
|
+
* The Alchemy CLI runs a JavaScript entry, so a TypeScript `alchemy.run.ts`
|
|
79
|
+
* has to be flattened first, and the flattening must not swallow the two
|
|
80
|
+
* packages whose identity matters.
|
|
84
81
|
*
|
|
85
82
|
* Returns the absolute path of the file written.
|
|
86
83
|
*/
|
|
@@ -37,12 +37,9 @@ interface BundleAlchemyEntryOptions {
|
|
|
37
37
|
* Pre-bundle an Alchemy entry to a single ESM file, keeping `alchemy` and
|
|
38
38
|
* `effect` external (#268).
|
|
39
39
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* matters. Firedup additionally resolved esbuild *through vite* because it had
|
|
44
|
-
* no direct dependency on it; here esbuild is a plain dependency of this
|
|
45
|
-
* package and that hack can be deleted.
|
|
40
|
+
* The Alchemy CLI runs a JavaScript entry, so a TypeScript `alchemy.run.ts`
|
|
41
|
+
* has to be flattened first, and the flattening must not swallow the two
|
|
42
|
+
* packages whose identity matters.
|
|
46
43
|
*
|
|
47
44
|
* Returns the absolute path of the file written.
|
|
48
45
|
*/
|
|
@@ -12,13 +12,16 @@ import { spawnSync } from "node:child_process";
|
|
|
12
12
|
* `effect`, so it ships from the root entry, not the `./alchemy` subpath.
|
|
13
13
|
*/
|
|
14
14
|
const ALCHEMY_BASELINE = {
|
|
15
|
-
alchemy: "2.0.0-beta.
|
|
16
|
-
effect: "4.0.
|
|
15
|
+
alchemy: "2.0.0-beta.84",
|
|
16
|
+
effect: "4.0.6"
|
|
17
17
|
};
|
|
18
18
|
const BASELINE_PACKAGE_NAMES = Object.keys(ALCHEMY_BASELINE);
|
|
19
|
+
const ALCHEMY_PROVIDER_PACKAGE_NAMES = ["@alchemy.run/cloudflare"];
|
|
19
20
|
/**
|
|
20
21
|
* Fails when the consumer's `alchemy` or `effect` pin differs from
|
|
21
|
-
* {@link ALCHEMY_BASELINE},
|
|
22
|
+
* {@link ALCHEMY_BASELINE}, when the pair is incomplete (a pinned Alchemy
|
|
23
|
+
* provider package such as `@alchemy.run/cloudflare` demands both), or when a
|
|
24
|
+
* pinned provider package is not at the baseline `alchemy` version.
|
|
22
25
|
* Alchemy peers on Effect, so an unpinned auto-installed Effect can drift
|
|
23
26
|
* outside the baseline while a lone `alchemy` pin would otherwise pass.
|
|
24
27
|
* Both packages remaining absent is not drift — they are optional peers of
|
|
@@ -31,7 +34,7 @@ const BASELINE_PACKAGE_NAMES = Object.keys(ALCHEMY_BASELINE);
|
|
|
31
34
|
const assertAlchemyBaseline = ({ packageJson }) => {
|
|
32
35
|
const drifted = [];
|
|
33
36
|
const pinOf = (name) => packageJson.dependencies?.[name] ?? packageJson.devDependencies?.[name];
|
|
34
|
-
const pairPresent = BASELINE_PACKAGE_NAMES.some((name) => pinOf(name) !== void 0);
|
|
37
|
+
const pairPresent = [...BASELINE_PACKAGE_NAMES, ...ALCHEMY_PROVIDER_PACKAGE_NAMES].some((name) => pinOf(name) !== void 0);
|
|
35
38
|
for (const name of BASELINE_PACKAGE_NAMES) {
|
|
36
39
|
const pinned = pinOf(name);
|
|
37
40
|
const baseline = ALCHEMY_BASELINE[name];
|
|
@@ -41,6 +44,10 @@ const assertAlchemyBaseline = ({ packageJson }) => {
|
|
|
41
44
|
}
|
|
42
45
|
if (pinned !== baseline) drifted.push(`${name}@${pinned} (baseline: ${name}@${baseline})`);
|
|
43
46
|
}
|
|
47
|
+
for (const name of ALCHEMY_PROVIDER_PACKAGE_NAMES) {
|
|
48
|
+
const pinned = pinOf(name);
|
|
49
|
+
if (pinned !== void 0 && pinned !== ALCHEMY_BASELINE.alchemy) drifted.push(`${name}@${pinned} (baseline: ${name}@${ALCHEMY_BASELINE.alchemy})`);
|
|
50
|
+
}
|
|
44
51
|
if (drifted.length > 0) throw new Error(`Alchemy fleet baseline drift: ${drifted.join(", ")}. Bump to match ALCHEMY_BASELINE in @patronage/factory-ci, or wait for the next lockstep release.`);
|
|
45
52
|
};
|
|
46
53
|
//#endregion
|
|
@@ -49,9 +56,8 @@ const assertAlchemyBaseline = ({ packageJson }) => {
|
|
|
49
56
|
* The disposable Alchemy stage a local preview deploy runs in:
|
|
50
57
|
* `local-pr-<pr>-<short sha>` (#268).
|
|
51
58
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* does not match is not disposable, and destructive operations must refuse it.
|
|
59
|
+
* A stage that does not match is not disposable, and destructive operations
|
|
60
|
+
* must refuse it.
|
|
55
61
|
*/
|
|
56
62
|
const LOCAL_PREVIEW_STAGE_PATTERN = /^local-pr-(?<pr>[1-9]\d*)-(?<sha>[0-9a-f]{7,40})$/u;
|
|
57
63
|
/**
|
|
@@ -107,7 +113,7 @@ let spawnImplementation = spawnSync;
|
|
|
107
113
|
const resolveAlchemyChildCwd = (options) => options.cwd ?? options.bundle?.absWorkingDir ?? process.cwd();
|
|
108
114
|
const resolveBundledEntry = async (options) => {
|
|
109
115
|
if (options.bundledEntry === void 0) {
|
|
110
|
-
const { bundleAlchemyEntry } = await import("./bundle-alchemy-entry-
|
|
116
|
+
const { bundleAlchemyEntry } = await import("./bundle-alchemy-entry-BuMrl5fR.js").then((n) => n.n);
|
|
111
117
|
return await bundleAlchemyEntry(options.bundle);
|
|
112
118
|
}
|
|
113
119
|
return path.resolve(options.cwd ?? process.cwd(), options.bundledEntry);
|