@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.
@@ -1,8 +1,9 @@
1
- import { i as isLocalPreviewStage, n as executeAlchemyEntry, r as resolveAlchemyChildCwd, s as ALCHEMY_BASELINE } from "../execute-alchemy-entry-C2ZhsNTN.js";
1
+ import { i as isLocalPreviewStage, n as executeAlchemyEntry, r as resolveAlchemyChildCwd, s as ALCHEMY_BASELINE } from "../execute-alchemy-entry-CxQrjSg8.js";
2
2
  import { createRequire } from "node:module";
3
3
  import path from "node:path";
4
4
  import { createHash } from "node:crypto";
5
5
  import { appendFileSync, closeSync, openSync, readFileSync } from "node:fs";
6
+ import { setTimeout } from "node:timers/promises";
6
7
  import * as Alchemy from "alchemy";
7
8
  import * as Output from "alchemy/Output";
8
9
  import { tryFindProviderByType } from "alchemy/Provider";
@@ -12,7 +13,7 @@ import * as Option from "effect/Option";
12
13
  import { State } from "alchemy/State";
13
14
  import { allStages, deleteState } from "alchemy/State/Tree";
14
15
  import { isDeepStrictEqual } from "node:util";
15
- //#region src/alchemy/evaluate-stack.ts
16
+ // src/alchemy/evaluate-stack.ts
16
17
  var EvaluationProviders = class extends Alchemy.ProviderCollection()("factory-ci/evaluate-stack") {};
17
18
  /** The lifecycle every provider evaluates with: read and list answer "absent"; a plan never applies. */
18
19
  const absentProvider = (type) => ({
@@ -79,8 +80,7 @@ const evaluateStack = ({ name, program, providers, stage }) => {
79
80
  })), Effect.map(toGraph), Effect.provide(Layer.mergeAll(Layer.succeed(Alchemy.Stack, stack), Layer.succeed(Alchemy.Stage, stage), Alchemy.inMemoryState(), evaluationProviders(providers))), Effect.scoped);
80
81
  return Effect.runPromise(evaluation);
81
82
  };
82
- //#endregion
83
- //#region src/alchemy/retained-identity.ts
83
+ // src/alchemy/retained-identity.ts
84
84
  /** Every retained identity that did not hold. */
85
85
  var RetainedIdentityError = class extends Error {
86
86
  violations;
@@ -162,20 +162,10 @@ const assertRetainedIdentities = ({ after, before, markers }) => {
162
162
  const violations = markers.map((marker) => violationFor(marker, after, before)).filter((violation) => violation !== void 0);
163
163
  if (violations.length > 0) throw new RetainedIdentityError(violations);
164
164
  };
165
- //#endregion
166
- //#region src/alchemy/credential-preflight.ts
165
+ // src/alchemy/credential-preflight.ts
167
166
  /**
168
167
  * Cloudflare credential preflight for an Alchemy deploy.
169
168
  *
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
169
  * **No credential value is ever printed.** Errors name environment variables and
180
170
  * missing groups from the caller-owned permission requirements. Untrusted API
181
171
  * status, receipt group names, and resource identifiers are never reflected.
@@ -202,7 +192,7 @@ var CloudflareCredentialUnavailableError = class extends Error {
202
192
  }
203
193
  };
204
194
  /** The exact source literals this preflight accepts. */
205
- const CREDENTIAL_SOURCES = new Set(["hosted", "trusted-local"]);
195
+ const CREDENTIAL_SOURCES = /* @__PURE__ */ new Set(["hosted", "trusted-local"]);
206
196
  const present = (environment, name) => Boolean(environment[name]?.trim());
207
197
  const assertCredentialPosture = (source, accountId, environment) => {
208
198
  if (!CREDENTIAL_SOURCES.has(source)) throw new Error("Credential preflight has an unknown credential source.");
@@ -333,17 +323,14 @@ const credentialPreflight = async ({ accountId, environment, fetchImplementation
333
323
  tokenId: verification.id
334
324
  };
335
325
  };
336
- //#endregion
337
- //#region src/alchemy/stage-policy.ts
326
+ // src/alchemy/stage-policy.ts
338
327
  /**
339
328
  * Stage and stack pairing, and protected-stage policy, from a project-supplied
340
329
  * table (#991).
341
330
  *
342
- * Two projects wrote the same three questions twice — is this stage protected,
343
- * is it disposable, and may this stack run it — and each answered them with its
344
- * own stage names hard-coded into the answer. The names differ; the questions
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.
331
+ * This module owns whether a stage is protected, whether it is disposable, and
332
+ * whether a stack may run it. A project supplies the table and gets decisions
333
+ * back, so no project or stack name appears here.
347
334
  *
348
335
  * One stage name does appear: `local`. It names the local emulator rather than
349
336
  * any project's estate, every project spells it the same way, and the question
@@ -461,8 +448,7 @@ const stagePolicy = (table) => {
461
448
  isProtectedStage
462
449
  };
463
450
  };
464
- //#endregion
465
- //#region src/alchemy/local-emulation.ts
451
+ // src/alchemy/local-emulation.ts
466
452
  /**
467
453
  * The child environment a local-emulation Alchemy run needs (#1168).
468
454
  *
@@ -488,9 +474,10 @@ const [ACCOUNT_ID_NAME, API_TOKEN_NAME] = HOSTED_CLOUDFLARE_CREDENTIAL_NAMES;
488
474
  * Alchemy validates the value against `/^[0-9a-f]{32}$/i` and rejects
489
475
  * placeholders such as `""` or `dummy` with an authentication error before any
490
476
  * run starts. The check is `validateAccountId`, in
491
- * `alchemy/lib/Cloudflare/Auth/AuthProvider.js` at 2.0.0-beta.76 and in
492
- * `alchemy/lib/Cloudflare/Auth/AuthConfig.js` at 2.0.0-beta.77. The file name
493
- * moves; the pattern is the same in both. Thirty-two zeros pass that shape
477
+ * `alchemy/lib/Cloudflare/Auth/AuthProvider.js` at 2.0.0-beta.76, in
478
+ * `alchemy/lib/Cloudflare/Auth/AuthConfig.js` at 2.0.0-beta.77, and in
479
+ * `@alchemy.run/cloudflare/lib/Auth/AuthConfig.js` from 2.0.0-beta.84. The
480
+ * file moves; the pattern is the same in all three. Thirty-two zeros pass that shape
494
481
  * check and route to nothing.
495
482
  */
496
483
  const SENTINEL_ACCOUNT_ID = "0".repeat(32);
@@ -528,8 +515,7 @@ const localEmulationEnvironment = (options) => {
528
515
  [API_TOKEN_NAME]: SENTINEL_API_TOKEN
529
516
  };
530
517
  };
531
- //#endregion
532
- //#region src/alchemy/destroy-postcondition.ts
518
+ // src/alchemy/destroy-postcondition.ts
533
519
  /**
534
520
  * Read the state store through the project's reader.
535
521
  *
@@ -566,8 +552,7 @@ const assertDestroyLeftNothing = async ({ stack, stage, stateReader }) => {
566
552
  const remaining = [...listed].toSorted();
567
553
  if (remaining.length > 0) throw new Error(`Alchemy destroy left ${remaining.length} resource registered for ${stack} in ${stage}: ${remaining.join(", ")}`);
568
554
  };
569
- //#endregion
570
- //#region src/alchemy/plan-effects.ts
555
+ // src/alchemy/plan-effects.ts
571
556
  /**
572
557
  * The plan-output adapter (#1077): the one reader of what the installed
573
558
  * Alchemy CLI prints for a plan.
@@ -585,7 +570,7 @@ const assertDestroyLeftNothing = async ({ stack, stage, stateReader }) => {
585
570
  * The renderer logs every line through Effect's pretty console logger, so a
586
571
  * line arrives as `[HH:MM:SS.mmm] INFO (#1): <line>`, and coloured when the
587
572
  * child inherits `FORCE_COLOR`. Both wrappers are stripped before a line is
588
- * read. The captured output under `tests/fixtures/plan-output/beta-83/` is
573
+ * read. The captured output under `tests/fixtures/plan-output/beta-84/` is
589
574
  * the evidence for every shape this file reads.
590
575
  *
591
576
  * The adapter fails on anything it does not recognise: no summary, two
@@ -629,13 +614,13 @@ var PlanEffectsError = class extends Error {
629
614
  }
630
615
  };
631
616
  const ACTION_SET = new Set(PLAN_ACTIONS);
632
- const BINDING_ACTIONS = new Set([
617
+ const BINDING_ACTIONS = /* @__PURE__ */ new Set([
633
618
  "create",
634
619
  "noop",
635
620
  "unbind",
636
621
  "update"
637
622
  ]);
638
- const TASK_ACTIONS = new Set(["drop", "run"]);
623
+ const TASK_ACTIONS = /* @__PURE__ */ new Set(["drop", "run"]);
639
624
  const ansiPattern = new RegExp(`${String.fromCodePoint(27)}\\[[0-?]*[ -/]*[@-~]`, "gu");
640
625
  /**
641
626
  * The prefix Effect's pretty console logger puts before every line the
@@ -930,17 +915,13 @@ const canonicalPlan = (output) => {
930
915
  summary: lines.summary
931
916
  });
932
917
  };
933
- //#endregion
934
- //#region src/alchemy/first-deploy-authorization.ts
918
+ // src/alchemy/first-deploy-authorization.ts
935
919
  /**
936
920
  * First-deploy authorization by plan hash.
937
921
  *
938
922
  * The first deploy of a stack into a stage is the one deploy no earlier state
939
923
  * can constrain: there is nothing to diff against, so the plan is the only
940
- * description of what is about to be created. Paitronage binds that plan to an
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`).
924
+ * description of what is about to be created.
944
925
  *
945
926
  * The generic form keeps the binding and drops the project's stage policy.
946
927
  * Which stages are eligible, and where the authorized hashes are kept, stay
@@ -1030,8 +1011,7 @@ const firstDeployAuthorization = ({ authorizedHashes, planText, sourceSha, stack
1030
1011
  if (!authorized.has(planHash)) throw new Error(`First deploy of ${stack} into ${stage} is not authorized. Reviewed plan hash: ${planHash}`);
1031
1012
  return { planHash };
1032
1013
  };
1033
- //#endregion
1034
- //#region src/alchemy/url-implies-auth.ts
1014
+ // src/alchemy/url-implies-auth.ts
1035
1015
  /** The Alchemy resource type a Cloudflare Worker plans as, at beta.76. */
1036
1016
  const WORKER_TYPE = "Cloudflare.Worker";
1037
1017
  /** The Alchemy resource type a Cloudflare Access application plans as, at beta.76. */
@@ -1147,8 +1127,7 @@ const assertUrlImpliesAuth = (graph, { allowlist = [], authBindingName }) => {
1147
1127
  }
1148
1128
  if (violations.length > 0) throw new UrlImpliesAuthError(violations);
1149
1129
  };
1150
- //#endregion
1151
- //#region src/alchemy/secret-name-policy.ts
1130
+ // src/alchemy/secret-name-policy.ts
1152
1131
  /**
1153
1132
  * A secret-name redaction policy for `executeAlchemyEntry`'s `redact` hook.
1154
1133
  *
@@ -1205,8 +1184,7 @@ const secretNamePolicy = ({ names, values }) => {
1205
1184
  return redacted;
1206
1185
  };
1207
1186
  };
1208
- //#endregion
1209
- //#region src/alchemy/lifecycle-failure.ts
1187
+ // src/alchemy/lifecycle-failure.ts
1210
1188
  /**
1211
1189
  * The one sentence each code is reported with. The table is the whole
1212
1190
  * vocabulary: a message that is not in it cannot be raised.
@@ -1270,8 +1248,7 @@ var AlchemyLifecycleError = class extends Error {
1270
1248
  }
1271
1249
  };
1272
1250
  const isAlchemyLifecycleError = (error) => error instanceof AlchemyLifecycleError;
1273
- //#endregion
1274
- //#region src/alchemy/state-tree.ts
1251
+ // src/alchemy/state-tree.ts
1275
1252
  /**
1276
1253
  * One read and delete surface over a state layer.
1277
1254
  *
@@ -1374,8 +1351,7 @@ const deleteStageRows = async (state, target) => {
1374
1351
  recursive: true
1375
1352
  }));
1376
1353
  };
1377
- //#endregion
1378
- //#region src/alchemy/child-diagnostics.ts
1354
+ // src/alchemy/child-diagnostics.ts
1379
1355
  /**
1380
1356
  * The optional record of what an Alchemy child printed (#1260).
1381
1357
  *
@@ -1383,8 +1359,7 @@ const deleteStageRows = async (state, target) => {
1383
1359
  * else: the child's output is parsed and dropped, so no secret in it can
1384
1360
  * reach a job log or an evidence file through the operation. That is the
1385
1361
  * right default and it stays the default. It also leaves an operator with a
1386
- * failure code and no record of what failed, which twice cost a paitronage
1387
- * investigation its evidence.
1362
+ * failure code and no record of what failed.
1388
1363
  *
1389
1364
  * This is the opt-in other half: a consumer that names a file gets every
1390
1365
  * child's streams appended to it, each stream passed whole through the
@@ -1449,8 +1424,7 @@ const openChildDiagnostics = ({ child, diagnostics, operation, stack, stage }) =
1449
1424
  failure: () => retained
1450
1425
  };
1451
1426
  };
1452
- //#endregion
1453
- //#region src/alchemy/lifecycle.ts
1427
+ // src/alchemy/lifecycle.ts
1454
1428
  /**
1455
1429
  * The shared Alchemy lifecycle operation (#1077).
1456
1430
  *
@@ -1463,18 +1437,20 @@ const openChildDiagnostics = ({ child, diagnostics, operation, stack, stage }) =
1463
1437
  * back a fixed-shape result or an `AlchemyLifecycleError`. It cannot call the
1464
1438
  * steps in another order, because it does not call the steps.
1465
1439
  *
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
1440
  * What stays with the consumer: the resource graph, the credentials and
1473
1441
  * environment the child runs with, the stage table, the retained-identity
1474
1442
  * markers, the first-deploy authorization list, and the state store's own
1475
1443
  * configuration. This module learns none of them.
1476
1444
  */
1477
- const OPERATIONS = new Set([
1445
+ const MAX_CONVERGENCE_ATTEMPTS = 10;
1446
+ const MAX_CONVERGENCE_DELAY_MILLIS = 6e4;
1447
+ /**
1448
+ * A delay at or above an explicit lease TTL lapses the lease mid-wait, which
1449
+ * would surface late as `OWNERSHIP_LOST`; refuse it up front. This is a floor,
1450
+ * not a guarantee: the re-plan after the wait also runs before the renewal.
1451
+ */
1452
+ const validConvergenceRetries = ({ convergenceRetries: retries, ownershipTtlMillis }) => retries === void 0 || Number.isInteger(retries.attempts) && retries.attempts >= 1 && retries.attempts <= MAX_CONVERGENCE_ATTEMPTS && Number.isInteger(retries.delayMillis) && retries.delayMillis >= 0 && retries.delayMillis <= MAX_CONVERGENCE_DELAY_MILLIS && (ownershipTtlMillis === void 0 || retries.delayMillis < ownershipTtlMillis);
1453
+ const OPERATIONS = /* @__PURE__ */ new Set([
1478
1454
  "plan",
1479
1455
  "deploy",
1480
1456
  "destroy"
@@ -1518,7 +1494,7 @@ const persistedToSnapshot = (target, persisted) => ({ resources: persisted.resou
1518
1494
  * and for a `deleting` one (a delete that was interrupted while the
1519
1495
  * resource is still declared), and both finish at the same FQN.
1520
1496
  */
1521
- const IN_FLIGHT_STATUSES = new Set(["creating", "deleting"]);
1497
+ const IN_FLIGHT_STATUSES = /* @__PURE__ */ new Set(["creating", "deleting"]);
1522
1498
  const statusOf = (record) => isRecord(record.state) ? record.state.status : void 0;
1523
1499
  /**
1524
1500
  * Resolve plan rows onto persisted FQNs. A row's `id` is the FQN Alchemy
@@ -1599,7 +1575,7 @@ var LifecycleRun = class {
1599
1575
  validateRequest() {
1600
1576
  const { operation, stack, stage } = this.request;
1601
1577
  if (!OPERATIONS.has(operation) || typeof stack !== "string" || typeof stage !== "string" || stack.trim() === "" || stage.trim() === "" || stack !== stack.trim() || stage !== stage.trim()) throw this.fail("INVALID_REQUEST", "request");
1602
- if (typeof this.policy.holder !== "string" || this.policy.holder.trim() === "") throw this.fail("INVALID_POLICY", "request");
1578
+ if (typeof this.policy.holder !== "string" || this.policy.holder.trim() === "" || !validConvergenceRetries(this.policy)) throw this.fail("INVALID_POLICY", "request");
1603
1579
  }
1604
1580
  admitStage() {
1605
1581
  let table;
@@ -1632,7 +1608,8 @@ var LifecycleRun = class {
1632
1608
  installedAlchemyVersion() {
1633
1609
  let version;
1634
1610
  try {
1635
- version = alchemyManifestVersion(createRequire(this.entry.from).resolve("alchemy/bin/alchemy.js"));
1611
+ const cli = createRequire(this.entry.from).resolve("alchemy/bin/alchemy.js");
1612
+ version = alchemyManifestVersion(cli);
1636
1613
  } catch {
1637
1614
  throw this.fail("PREPARATION_FAILED", "admission");
1638
1615
  }
@@ -1645,7 +1622,7 @@ var LifecycleRun = class {
1645
1622
  return;
1646
1623
  }
1647
1624
  try {
1648
- const { bundleAlchemyEntry } = await import("../bundle-alchemy-entry-CT5hCphA.js").then((n) => n.n);
1625
+ const { bundleAlchemyEntry } = await import("../bundle-alchemy-entry-Ba1Ebp91.js").then((n) => n.n);
1649
1626
  this.bundledEntry = await bundleAlchemyEntry(this.entry.bundle);
1650
1627
  } catch {
1651
1628
  throw this.fail("PREPARATION_FAILED", "admission");
@@ -1982,7 +1959,8 @@ var LifecycleRun = class {
1982
1959
  const namedByRow = new Set(planned.map(({ id }) => id));
1983
1960
  const priorFqns = new Set(before.resources.map(({ fqn }) => fqn));
1984
1961
  const inFlightBefore = new Set(before.resources.filter((record) => IN_FLIGHT_STATUSES.has(statusOf(record))).map(({ fqn }) => fqn));
1985
- const created = resolveRows(planned, after.resources.filter((record) => !IN_FLIGHT_STATUSES.has(statusOf(record))).filter(({ fqn }) => !priorFqns.has(fqn) || inFlightBefore.has(fqn) && namedByRow.has(fqn)).map(({ fqn }) => fqn));
1962
+ const candidates = after.resources.filter((record) => !IN_FLIGHT_STATUSES.has(statusOf(record))).filter(({ fqn }) => !priorFqns.has(fqn) || inFlightBefore.has(fqn) && namedByRow.has(fqn)).map(({ fqn }) => fqn);
1963
+ const created = resolveRows(planned, candidates);
1986
1964
  if (created === void 0) throw this.fail("DEPLOY_INCOMPLETE", "postcondition");
1987
1965
  return created;
1988
1966
  }
@@ -2007,12 +1985,25 @@ var LifecycleRun = class {
2007
1985
  ...this.stageArgs(),
2008
1986
  "--yes"
2009
1987
  ], lease);
2010
- const post = await this.readOnlyPlan(this.planArgs(false), lease, accept, "postcondition");
2011
- const after = post.before;
2012
- if (after.resources.length === 0) throw this.fail("DEPLOY_INCOMPLETE", "postcondition");
2013
- const createdNow = this.createdFqns(plan.before, after, plan.effects);
2014
- if (isProtected && !admittedFirstDeploy) this.assertRetained(persistedToSnapshot(this.target, after), persistedToSnapshot(this.target, plan.before), "postcondition");
2015
- this.assertConverged(post.effects, after);
1988
+ const converge = async (retriesLeft) => {
1989
+ const post = await this.readOnlyPlan(this.planArgs(false), lease, accept, "postcondition");
1990
+ const after = post.before;
1991
+ if (after.resources.length === 0) throw this.fail("DEPLOY_INCOMPLETE", "postcondition");
1992
+ const createdNow = this.createdFqns(plan.before, after, plan.effects);
1993
+ if (isProtected && !admittedFirstDeploy) this.assertRetained(persistedToSnapshot(this.target, after), persistedToSnapshot(this.target, plan.before), "postcondition");
1994
+ try {
1995
+ this.assertConverged(post.effects, after);
1996
+ } catch (error) {
1997
+ if (retriesLeft === 0 || !(error instanceof AlchemyLifecycleError) || error.code !== "NOT_CONVERGED") throw error;
1998
+ await setTimeout(this.policy.convergenceRetries?.delayMillis ?? 0);
1999
+ return await converge(retriesLeft - 1);
2000
+ }
2001
+ return {
2002
+ createdNow,
2003
+ post
2004
+ };
2005
+ };
2006
+ const { createdNow, post } = await converge(this.policy.convergenceRetries?.attempts ?? 0);
2016
2007
  return {
2017
2008
  convergence: post.effects,
2018
2009
  created: createdNow,
@@ -2118,8 +2109,7 @@ const runAlchemyLifecycle = async (options) => {
2118
2109
  run.assertDiagnosticsWritten();
2119
2110
  return result;
2120
2111
  };
2121
- //#endregion
2122
- //#region src/alchemy/index.ts
2112
+ // src/alchemy/index.ts
2123
2113
  /**
2124
2114
  * The `@patronage/factory-ci/alchemy` subpath: the only place in this package
2125
2115
  * where `alchemy` or `effect` may be imported (ADR 0031).
@@ -2138,5 +2128,4 @@ const runAlchemyLifecycle = async (options) => {
2138
2128
  */
2139
2129
  /** The specifier a consumer imports this surface by. */
2140
2130
  const ALCHEMY_SUBPATH = "@patronage/factory-ci/alchemy";
2141
- //#endregion
2142
2131
  export { ALCHEMY_SUBPATH, AlchemyLifecycleError, CloudflareCredentialUnavailableError, HOSTED_CLOUDFLARE_CREDENTIAL_NAMES, LIFECYCLE_FAILURE_MESSAGES, LOCAL_PREVIEW_STAGES, MINIMUM_REDACTABLE_SECRET_LENGTH, PLAN_ACTIONS, PLAN_OUTPUT_ALCHEMY_VERSION, PlanEffectsError, RetainedIdentityError, SECRET_REDACTION_PLACEHOLDER, StagePolicyError, UrlImpliesAuthError, anyStage, assertDestroyLeftNothing, assertRetainedIdentities, assertUrlImpliesAuth, credentialPreflight, deleteStageRows, evaluateStack, firstDeployAuthorization, firstDeployPlanHash, inventoryStages, isAlchemyLifecycleError, isLocalEmulationStage, localEmulationEnvironment, parsePlanEffects, parseStateSnapshot, readStageSnapshot, runAlchemyLifecycle, secretNamePolicy, stagePolicy };
@@ -2,7 +2,7 @@ import "node:module";
2
2
  import { mkdir } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { build } from "esbuild";
5
- //#region \0rolldown/runtime.js
5
+ // \0rolldown/runtime.js
6
6
  var __defProp = Object.defineProperty;
7
7
  var __exportAll = (all, no_symbols) => {
8
8
  let target = {};
@@ -13,17 +13,21 @@ var __exportAll = (all, no_symbols) => {
13
13
  if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
14
14
  return target;
15
15
  };
16
- //#endregion
17
- //#region src/bundle-alchemy-entry.ts
16
+ // src/bundle-alchemy-entry.ts
18
17
  var bundle_alchemy_entry_exports = /* @__PURE__ */ __exportAll({ bundleAlchemyEntry: () => bundleAlchemyEntry });
19
18
  /**
20
- * Alchemy and Effect must resolve from the *consumer's* node_modules at run
21
- * time, never from the bundle: Alchemy's resource registry and Effect's
22
- * service tags are identity-sensitive, and a second copy silently breaks both.
19
+ * Alchemy, its `@alchemy.run/*` provider packages and Effect must resolve from
20
+ * the *consumer's* node_modules at run time, never from the bundle: Alchemy's
21
+ * resource registry and Effect's service tags are identity-sensitive, and a
22
+ * second copy silently breaks both. Since 2.0.0-beta.84 the providers
23
+ * (`@alchemy.run/cloudflare` and the rest) ship outside core, and they import
24
+ * runtime-only specifiers such as `cloudflare:workers` that no Node bundle can
25
+ * resolve.
23
26
  */
24
27
  const ALCHEMY_EXTERNALS = [
25
28
  "alchemy",
26
29
  "alchemy/*",
30
+ "@alchemy.run/*",
27
31
  "effect",
28
32
  "effect/*"
29
33
  ];
@@ -72,15 +76,12 @@ const assertNoReservedInputs = (inputs) => {
72
76
  if (offenders.length > 0) throw new Error(`bundleAlchemyEntry refused a bundle carrying a second copy of an identity-sensitive package: ${offenders.join(", ")}. Those packages must resolve from the consumer's runtime, so nothing may pull their files into the bundle — an alias that re-exports them by bare specifier stays external and is fine.`);
73
77
  };
74
78
  /**
75
- * Pre-bundle an Alchemy entry to a single ESM file, keeping `alchemy` and
76
- * `effect` external (#268).
79
+ * Pre-bundle an Alchemy entry to a single ESM file, keeping `alchemy`, its
80
+ * `@alchemy.run/*` providers and `effect` external (#268).
77
81
  *
78
- * Both repos that deploy through Alchemy wrote this: the Alchemy CLI runs a
79
- * JavaScript entry, so a TypeScript `alchemy.run.ts` has to be flattened
80
- * first, and the flattening must not swallow the two packages whose identity
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.
82
+ * The Alchemy CLI runs a JavaScript entry, so a TypeScript `alchemy.run.ts`
83
+ * has to be flattened first, and the flattening must not swallow the
84
+ * packages whose identity matters.
84
85
  *
85
86
  * Returns the absolute path of the file written.
86
87
  */
@@ -108,5 +109,4 @@ const bundleAlchemyEntry = async (options) => {
108
109
  assertNoReservedInputs(Object.keys(result.metafile.inputs));
109
110
  return outfile;
110
111
  };
111
- //#endregion
112
112
  export { bundle_alchemy_entry_exports as n, bundleAlchemyEntry as t };
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from "node:module";
2
2
  import path from "node:path";
3
3
  import { spawnSync } from "node:child_process";
4
- //#region src/alchemy-baseline.ts
4
+ // src/alchemy-baseline.ts
5
5
  /**
6
6
  * The Alchemy fleet baseline (#985, #993). Every factory project that
7
7
  * imports `@patronage/factory-ci/alchemy` pins `alchemy` and `effect` to
@@ -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.83",
16
- effect: "4.0.1"
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}, or when only one of the pair is present.
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,17 +44,19 @@ 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
- //#endregion
47
- //#region src/disposable-stage.ts
53
+ // src/disposable-stage.ts
48
54
  /**
49
55
  * The disposable Alchemy stage a local preview deploy runs in:
50
56
  * `local-pr-<pr>-<short sha>` (#268).
51
57
  *
52
- * Two repos invented this grammar independently and then had to agree on it
53
- * anyway, because the same cleanup sweeps delete these stages. A stage that
54
- * does not match is not disposable, and destructive operations must refuse it.
58
+ * A stage that does not match is not disposable, and destructive operations
59
+ * must refuse it.
55
60
  */
56
61
  const LOCAL_PREVIEW_STAGE_PATTERN = /^local-pr-(?<pr>[1-9]\d*)-(?<sha>[0-9a-f]{7,40})$/u;
57
62
  /**
@@ -93,10 +98,9 @@ const localPreviewStage = (options) => {
93
98
  if (!/^[0-9a-f]{40}$/u.test(normalizedHead)) throw new Error(`headSha must be exactly 40 hexadecimal characters, got "${headSha}".`);
94
99
  return `local-pr-${pr}-${normalizedHead.slice(0, shaLength)}`;
95
100
  };
96
- //#endregion
97
- //#region src/execute-alchemy-entry.ts
101
+ // src/execute-alchemy-entry.ts
98
102
  /** Node's spawnSync default is 1 MiB; Alchemy plans routinely exceed that. */
99
- const EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER = 64 * 1024 * 1024;
103
+ const EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER = 67108864;
100
104
  let spawnImplementation = spawnSync;
101
105
  /**
102
106
  * The child's working directory: the caller's `cwd`, then the bundle root,
@@ -107,7 +111,7 @@ let spawnImplementation = spawnSync;
107
111
  const resolveAlchemyChildCwd = (options) => options.cwd ?? options.bundle?.absWorkingDir ?? process.cwd();
108
112
  const resolveBundledEntry = async (options) => {
109
113
  if (options.bundledEntry === void 0) {
110
- const { bundleAlchemyEntry } = await import("./bundle-alchemy-entry-CT5hCphA.js").then((n) => n.n);
114
+ const { bundleAlchemyEntry } = await import("./bundle-alchemy-entry-Ba1Ebp91.js").then((n) => n.n);
111
115
  return await bundleAlchemyEntry(options.bundle);
112
116
  }
113
117
  return path.resolve(options.cwd ?? process.cwd(), options.bundledEntry);
@@ -156,5 +160,4 @@ const executeAlchemyEntry = async (options) => {
156
160
  stdout: captured(result.stdout, options.redact)
157
161
  };
158
162
  };
159
- //#endregion
160
163
  export { localPreviewStage as a, assertAlchemyBaseline as c, isLocalPreviewStage as i, executeAlchemyEntry as n, parseLocalPreviewStage as o, resolveAlchemyChildCwd as r, ALCHEMY_BASELINE as s, EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER as t };
@@ -1,4 +1,3 @@
1
- //#region src/bundle-alchemy-entry.d.ts
2
1
  interface BundleAlchemyEntryOptions {
3
2
  /** The Alchemy entry to bundle, e.g. `alchemy.run.ts`. */
4
3
  readonly entry: string;
@@ -13,7 +12,8 @@ interface BundleAlchemyEntryOptions {
13
12
  * `packages: "external"`. Values are resolved the way esbuild resolves any
14
13
  * import, so give absolute paths or package names — which aliases a repo
15
14
  * needs is the consumer's policy and this package bakes in none. A key on
16
- * `alchemy`, `effect`, or a subpath of either is rejected outright, and the
15
+ * `alchemy`, an `@alchemy.run/*` provider, `effect`, or a subpath of any of
16
+ * them is rejected outright, and the
17
17
  * finished bundle is checked for files from those packages however they were
18
18
  * reached.
19
19
  */
@@ -34,21 +34,16 @@ interface BundleAlchemyEntryOptions {
34
34
  readonly tsconfig?: string;
35
35
  }
36
36
  /**
37
- * Pre-bundle an Alchemy entry to a single ESM file, keeping `alchemy` and
38
- * `effect` external (#268).
37
+ * Pre-bundle an Alchemy entry to a single ESM file, keeping `alchemy`, its
38
+ * `@alchemy.run/*` providers and `effect` external (#268).
39
39
  *
40
- * Both repos that deploy through Alchemy wrote this: the Alchemy CLI runs a
41
- * JavaScript entry, so a TypeScript `alchemy.run.ts` has to be flattened
42
- * first, and the flattening must not swallow the two packages whose identity
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
42
+ * packages whose identity matters.
46
43
  *
47
44
  * Returns the absolute path of the file written.
48
45
  */
49
46
  declare const bundleAlchemyEntry: (options: BundleAlchemyEntryOptions) => Promise<string>;
50
- //#endregion
51
- //#region src/execute-alchemy-entry.d.ts
52
47
  /** Node's spawnSync default is 1 MiB; Alchemy plans routinely exceed that. */
53
48
  declare const EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER: number;
54
49
  interface ExecuteAlchemyEntryCommon {
@@ -101,7 +96,8 @@ interface ExecuteAlchemyEntryCommon {
101
96
  * together, and refuses neither, so no runtime check is needed.
102
97
  */
103
98
  type ExecuteAlchemyEntryOptions = ExecuteAlchemyEntryCommon & ({
104
- /** Bundle the consumer entry before execution. */readonly bundle: BundleAlchemyEntryOptions;
99
+ /** Bundle the consumer entry before execution. */
100
+ readonly bundle: BundleAlchemyEntryOptions;
105
101
  readonly bundledEntry?: never;
106
102
  } | {
107
103
  readonly bundle?: never;
@@ -130,5 +126,4 @@ interface ExecuteAlchemyEntryResult {
130
126
  * convergence or destructive-change policy remain the caller's responsibility.
131
127
  */
132
128
  declare const executeAlchemyEntry: (options: ExecuteAlchemyEntryOptions) => Promise<ExecuteAlchemyEntryResult>;
133
- //#endregion
134
129
  export { BundleAlchemyEntryOptions as a, executeAlchemyEntry as i, ExecuteAlchemyEntryOptions as n, bundleAlchemyEntry as o, ExecuteAlchemyEntryResult as r, EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER as t };