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

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @patronage/factory-ci
2
2
 
3
- The CI and deploy building blocks that already repeat across Patronage **factory projects** — projects that carry a `software-factory.profile.json`, deploy through Alchemy, and are subject to factory CI and proof gating.
3
+ The CI and deploy building blocks that already repeat across Patronage **factory projects** — projects that carry a `software-factory.profile.json` and are subject to factory CI and proof gating, whatever tool deploys them. Only the helpers that import Alchemy live on the `@patronage/factory-ci/alchemy` subpath; the entry bundler and runner below need no Alchemy import, and a project that deploys with plain Cloudflare tooling uses the rest of the package unchanged.
4
4
 
5
5
  ```bash
6
6
  pnpm add -E @patronage/factory-ci
@@ -483,7 +483,7 @@ The gate is a **step, not a job**, marked `continue-on-error`, with no `set -e`.
483
483
 
484
484
  **Emit the step's `shell` verbatim.** `factoryProofGateStep()` sets `shell: bash --noprofile --norc {0}` (`FACTORY_PROOF_GATE_SHELL`) and a generator that drops it breaks the gate. GitHub's default for `run:` is `bash -e {0}` — errexit arrives from the invocation, not the script, so omitting `set -e` does not achieve it. Under the default the gate dies at the first non-zero command before its single `GITHUB_OUTPUT` write: no verdict, no `reason`, reuse silently collapsed to never while the job looks like healthy full CI. `shell: bash` is not a substitute; it expands to `bash --noprofile --norc -eo pipefail {0}`. The script is written to survive errexit as well, and its tests execute every case under both shells — a harness that runs this script under friendlier flags than the runner does is worse than no harness.
485
485
 
486
- `assertProofReuseCoverage({ commands, skipped, surface })` is the compile-time guard in front of the runtime `incomplete` refusal: hand it the same selection and the command strings the workflow would skip, and it fails the consumer's build when the two drift apart. Coverage is exact executable coverage. The deprecated `equivalents` input remains only for patch-release source compatibility and is ignored; prose cannot authorize a skip. Extracting the skipped strings stays with the consumer — this package never parses workflow source, because establishing trust that way is what killed an earlier attempt.
486
+ `assertProofReuseCoverage({ commands, skipped, surface })` is the compile-time guard in front of the runtime `incomplete` refusal: hand it the same selection and the command strings the workflow would skip, and it fails the consumer's build when the two drift apart. Coverage is exact executable coverage. There is no prose escape hatch: the `equivalents` input was removed before 1.0, so only an executed command can cover a skip. Extracting the skipped strings stays with the consumer — this package never parses workflow source, because establishing trust that way is what killed an earlier attempt.
487
487
 
488
488
  `factoryProofTimingStartStep()` and `factoryProofReuseSummaryStep()` replace consumer-local proof timing summaries without taking over workflow topology. Put the start step immediately after the gate and the summary step after the guarded work. The helpers keep the established `Start CI timing` / `Record proof-reuse timing` names and distinguish proof reuse, full fallback with the gate's reason, and pushes where the gate's step condition kept it off entirely. Reuse links the exact source check and bound head; every path emits a cheap Actions notice. Both steps are `continue-on-error`: missing timing support or an unwritable presentation destination cannot change a required job's conclusion. These helpers change no trust predicate or guard.
489
489
 
@@ -521,7 +521,7 @@ import {
521
521
  import { previewProofLifecycle } from "@patronage/factory-ci";
522
522
  ```
523
523
 
524
- `previewProofLifecycle` owns the commodity preview-proof state machine that two consumers had each written: admit a disposable stage, register envelope-bound proof at the candidate head, and record cleanup. `transition(state, event)` is the only mutation. `recover(state, cleanupEvent)` re-enters that same cleanup event from a failed outcome; it is not a second machine and not a CLI command. `resolve(state, query?)` is the consumer-readable registration read model: stack, stage, head SHA, proof identity, and cleanup status.
524
+ `previewProofLifecycle` owns the commodity preview-proof state machine that two consumers had each written: admit a disposable stage, register envelope-bound proof at the candidate head, and record cleanup. `transition(state, event)` is the only mutation of lifecycle state. The inventory's `persist` (below) is storage, not a transition: it writes whatever schema-valid registration the caller passes, so a caller persists only a registration its own `register` transition produced. `recover(state, cleanupEvent)` re-enters that same cleanup event from a failed outcome; it is not a second machine and not a CLI command. `resolve(state, query?)` is the consumer-readable registration read model: stack, stage, head SHA, proof identity, and cleanup status.
525
525
 
526
526
  Events:
527
527
 
@@ -765,7 +765,7 @@ The optional `entry.envFile` selects the dotenv file for every child, including
765
765
  The sequence, per operation:
766
766
 
767
767
  - **`plan`** takes the stage lease, reads the persisted state, runs `deploy --dry-run`, reads the state again, and refuses with `STATE_CHANGED` if any resource record or the stack output differs — all under the one lease, so no other writer can reach the stage while the child plans. That refusal wins over the child's own exit status, because a planning child that wrote is the more serious finding. On an empty protected stage with a `firstDeploy` policy the result carries `planHash`, the value an operator authorizes.
768
- - **`deploy`** starts with the same leased read-only plan, then admits it under the same lease. An empty protected stage is a first deploy: the plan may only `create` or `adopted` — `adopted` is the create of a resource the provider already finds, and it plans only for a record with no prior state — and its hash must be on `firstDeploy.authorizedHashes`, or the refusal is `FIRST_DEPLOY_UNAUTHORIZED` carrying the hash. A protected stage with state refuses `replace` and `delete` (`EFFECT_NOT_PERMITTED`), and every `retainedIdentities` marker must hold against the recorded values before the apply (`RESOURCE_IDENTITY_MISMATCH`); a protected stage with no markers is `INVALID_POLICY`, because a check with nothing in it must not read as a proof. A disposable stage is constrained by neither. Then the apply child (`--yes`, with `--adopt` when the policy says so), under the same lease. Then, still under it: the persisted state again, which must record every resource the plan created (`DEPLOY_INCOMPLETE`; the result's `created` names their FQNs — a planned create resolves to an FQN that was absent before the apply, or was recorded in flight, `creating` or `deleting`, and is exactly the FQN the create row names — a row carries the FQN, so an interrupted create recovers at any depth; the record must have left the in-flight state) and, on a protected stage, the same identities as before; then a second `deploy --dry-run`, bracketed by the same two-read check as the first so a convergence child that wrote is `STATE_CHANGED`, which must be a no-op (`NOT_CONVERGED`) except an `update` on a persisted FQN named in `nonConvergentResources`: a Worker carrying a write-only secret binding re-plans as `update` on every deploy because the value can never be read back. Only `update`, only on those FQNs. A task row (`run` or `drop`) prints only while the task still has work, so any task row is `NOT_CONVERGED` too.
768
+ - **`deploy`** starts with the same leased read-only plan, then admits it under the same lease. An empty protected stage is a first deploy: the plan may only `create` or `adopted` — `adopted` is the create of a resource the provider already finds, and it plans only for a record with no prior state — and its hash must be on `firstDeploy.authorizedHashes`, or the refusal is `FIRST_DEPLOY_UNAUTHORIZED` carrying the hash. A protected stage with state refuses `replace` and `delete` (`EFFECT_NOT_PERMITTED`), and every `retainedIdentities` marker must hold against the recorded values before the apply (`RESOURCE_IDENTITY_MISMATCH`); a protected stage with no markers is `INVALID_POLICY`, because a check with nothing in it must not read as a proof. A disposable stage is constrained by neither. Then the apply child (`--yes`, with `--adopt` when the policy says so), under the same lease. Then, still under it: the persisted state again, which must record every resource the plan created (`DEPLOY_INCOMPLETE`; the result's `created` names their FQNs — a planned create resolves to an FQN that was absent before the apply, or was recorded in flight, `creating` or `deleting`, and is exactly the FQN the create row names — a row carries the FQN, so an interrupted create recovers at any depth; the record must have left the in-flight state) and, on a protected stage, the same identities as before; then a second `deploy --dry-run`, bracketed by the same two-read check as the first so a convergence child that wrote is `STATE_CHANGED`, which must be a no-op (`NOT_CONVERGED`) except an `update` on a persisted FQN named in `nonConvergentResources`: a Worker carrying a write-only secret binding re-plans as `update` on every deploy because the value can never be read back. Only `update`, only on those FQNs. A task row (`run` or `drop`) prints only while the task still has work, so any task row is `NOT_CONVERGED` too. With `convergenceRetries: { attempts, delayMillis }` set (#1349; `attempts` 1 to 10, `delayMillis` 0 to 60 000 and below an explicit `ownershipTtlMillis`), a post-deploy plan that is only `NOT_CONVERGED` waits and re-plans read-only, up to `attempts` more times, under the same lease. The apply never repeats, every check above runs again on each attempt and stops the deploy at once, and an exhausted run is still `NOT_CONVERGED`. Omitted, there is no retry.
769
769
  - **`destroy`** is refused on a protected stage. Then, under the stage lease, the destroy child, then the atomic stage view must be empty (`DESTROY_RESIDUE`) and the empty output row is removed in the same lease (`cleanup: "removed" | "absent"`). An unreadable store fails with `STATE_STORE_UNAVAILABLE`; it never reads as empty.
770
770
 
771
771
  Ownership follows #1074 and #1107. Each operation runs under **one** stage lease, held from its first read to its last decision, and every child it launches — the dry runs, the apply, the destroy — runs inside that lease: the lifecycle spreads the lease's `childEnvironment()` into the child's environment, and the adapter in the child adopts it. The stage is never unowned while an operation runs, so no other writer can interleave between the admitted plan and the apply, and a second run on the stage is `STAGE_HELD`. Before anything read under the lease is decided on, the lifecycle **renews** the lease: renewal is the adapter's fenced operation, it changes no rows unless this holder's unexpired row is still there, and it fails with `lost` when the lease expired or was taken over — `OWNERSHIP_LOST`, and the decision is not made. Independently of that, every exit from a leased window passes the same fence check, whether the window returned or threw and wherever it threw from: a lease lost anywhere in the window — during the apply child, during a state read, under a child failure — is `OWNERSHIP_LOST` at the phase the run was in, ahead of whatever else was found there. The check sits outside the window's code, so no early return or new failure path inside it can skip acceptance. A fence that holds lets a genuine store or child failure through unchanged. A successful `release` is not that check: the adapter's release is idempotent by design and succeeds when the row is gone or belongs to a later holder, so it proves nothing, and the lifecycle infers nothing from it. A release that _fails_ is a different fact — the store could not be reached and this holder's row may still be there, blocking the stage until it expires — so after a successful operation it is reported as `LEASE_RELEASE_FAILED`; a failure inside the operation is reported ahead of it.
@@ -1,3 +1,3 @@
1
1
  {
2
- "fingerprint": "a51cf2964415d5a6a2320d67ecf574f668811d7a1f49bf006a926ba9ac623c29"
2
+ "fingerprint": "f6183b21fee92f801106a2834d75bde250b5626501a5be8245b67a890a957032"
3
3
  }
@@ -1,11 +1,9 @@
1
- import { n as ExecuteAlchemyEntryOptions } from "../execute-alchemy-entry-BR5dFO9k.js";
1
+ import { n as ExecuteAlchemyEntryOptions } from "../execute-alchemy-entry-D75saOiE.js";
2
2
  import * as Alchemy from "alchemy";
3
3
  import * as Effect from "effect/Effect";
4
4
  import * as Layer from "effect/Layer";
5
5
  import { StateService } from "alchemy/State";
6
6
  import { ProviderServices } from "alchemy/Stack";
7
-
8
- //#region src/alchemy/evaluate-stack.d.ts
9
7
  interface EvaluatedResource {
10
8
  id: string;
11
9
  type: string;
@@ -48,14 +46,7 @@ interface EvaluateStackInput {
48
46
  * Run a stack program at `stage` and build the graph Alchemy would plan, with no state and no network:
49
47
  * `Plan.make` runs under `inMemoryState()` and every provider read and list answers "absent".
50
48
  */
51
- declare const evaluateStack: ({
52
- name,
53
- program,
54
- providers,
55
- stage
56
- }: EvaluateStackInput) => Promise<EvaluatedGraph>;
57
- //#endregion
58
- //#region src/alchemy/retained-identity.d.ts
49
+ export declare const evaluateStack: ({ name, program, providers, stage }: EvaluateStackInput) => Promise<EvaluatedGraph>;
59
50
  /**
60
51
  * Retained-identity asserts over Alchemy state snapshots (#991).
61
52
  *
@@ -121,7 +112,13 @@ interface StateSnapshotScope {
121
112
  interface StateSnapshot {
122
113
  readonly resources: readonly StateSnapshotResource[];
123
114
  }
124
- type RetainedIdentityViolationReason = /** No recorded resource matches the marker's fqn, type, and shape. */"missing" /** The recorded identity is not the value the marker names. */ | "unexpected" /** The identity differs between the two snapshots. */ | "changed";
115
+ type RetainedIdentityViolationReason =
116
+ /** No recorded resource matches the marker's fqn, type, and shape. */
117
+ "missing" |
118
+ /** The recorded identity is not the value the marker names. */
119
+ "unexpected" |
120
+ /** The identity differs between the two snapshots. */
121
+ "changed";
125
122
  interface RetainedIdentityViolation {
126
123
  readonly marker: RetainedIdentityMarker;
127
124
  readonly reason: RetainedIdentityViolationReason;
@@ -131,7 +128,7 @@ interface RetainedIdentityViolation {
131
128
  readonly before?: string;
132
129
  }
133
130
  /** Every retained identity that did not hold. */
134
- declare class RetainedIdentityError extends Error {
131
+ export declare class RetainedIdentityError extends Error {
135
132
  readonly violations: readonly RetainedIdentityViolation[];
136
133
  constructor(violations: readonly RetainedIdentityViolation[]);
137
134
  }
@@ -150,7 +147,7 @@ declare class RetainedIdentityError extends Error {
150
147
  * unambiguously is never treated as a state with nothing in it, because that
151
148
  * reading turns a broken read into a passing assert.
152
149
  */
153
- declare const parseStateSnapshot: (text: string, scope?: StateSnapshotScope) => StateSnapshot;
150
+ export declare const parseStateSnapshot: (text: string, scope?: StateSnapshotScope) => StateSnapshot;
154
151
  interface AssertRetainedIdentitiesOptions {
155
152
  /**
156
153
  * The state the operation would run against. Every marker is checked
@@ -172,13 +169,7 @@ interface AssertRetainedIdentitiesOptions {
172
169
  * against asserts nothing, so it is a `TypeError` rather than a pass. So is an
173
170
  * empty marker list: a check with nothing in it must not read as a proof.
174
171
  */
175
- declare const assertRetainedIdentities: ({
176
- after,
177
- before,
178
- markers
179
- }: AssertRetainedIdentitiesOptions) => void;
180
- //#endregion
181
- //#region src/alchemy/local-emulation.d.ts
172
+ export declare const assertRetainedIdentities: ({ after, before, markers }: AssertRetainedIdentitiesOptions) => void;
182
173
  /**
183
174
  * The child environment a local-emulation Alchemy run needs (#1168).
184
175
  *
@@ -208,16 +199,15 @@ declare const assertRetainedIdentities: ({
208
199
  * a sentinel there would break that deploy, and returning nothing instead
209
200
  * would let a caller believe a local run was protected when it was not.
210
201
  */
211
- declare const localEmulationEnvironment: (options: {
202
+ export declare const localEmulationEnvironment: (options: {
212
203
  /**
213
204
  * Where the opt-in is read from. Defaults to this process's environment. No
214
205
  * other variable is read.
215
206
  */
216
- readonly environment?: Readonly<Record<string, string | undefined>>; /** The Alchemy stage the child runs. */
207
+ readonly environment?: Readonly<Record<string, string | undefined>>;
208
+ /** The Alchemy stage the child runs. */
217
209
  readonly stage: string;
218
210
  }) => Readonly<Record<string, string>>;
219
- //#endregion
220
- //#region src/alchemy/stage-policy.d.ts
221
211
  /**
222
212
  * Stage and stack pairing, and protected-stage policy, from a project-supplied
223
213
  * table (#991).
@@ -241,9 +231,9 @@ declare const localEmulationEnvironment: (options: {
241
231
  */
242
232
  type StageMatcher = readonly string[] | RegExp | ((stage: string) => boolean);
243
233
  /** Every stage the shared disposable grammar recognises. */
244
- declare const LOCAL_PREVIEW_STAGES: StageMatcher;
234
+ export declare const LOCAL_PREVIEW_STAGES: StageMatcher;
245
235
  /** A matcher that accepts a stage any of `matchers` accepts. */
246
- declare const anyStage: (...matchers: readonly StageMatcher[]) => StageMatcher;
236
+ export declare const anyStage: (...matchers: readonly StageMatcher[]) => StageMatcher;
247
237
  /** One stack's claim on stages, in either or both directions. */
248
238
  interface StackStageOwnership {
249
239
  /** The stack this entry describes. */
@@ -262,7 +252,9 @@ interface StackStageOwnership {
262
252
  }
263
253
  interface StagePolicyTable {
264
254
  readonly stages: {
265
- /** Stages that hold real state and refuse destructive operations. */readonly protected: StageMatcher; /** Stages a cleanup sweep may create and delete freely. */
255
+ /** Stages that hold real state and refuse destructive operations. */
256
+ readonly protected: StageMatcher;
257
+ /** Stages a cleanup sweep may create and delete freely. */
266
258
  readonly disposable: StageMatcher;
267
259
  };
268
260
  /**
@@ -272,12 +264,22 @@ interface StagePolicyTable {
272
264
  */
273
265
  readonly stacks?: readonly StackStageOwnership[];
274
266
  }
275
- type StagePolicyErrorCode = /** The stage is neither protected nor disposable. */"UNKNOWN_STAGE" /** The table classifies the stage as both protected and disposable. */ | "AMBIGUOUS_STAGE" /** A destructive operation was asked for on a protected stage. */ | "PROTECTED_STAGE" /** The stack is not in the table's registry. */ | "UNKNOWN_STACK" /** The stack and the stage are not paired by the table. */ | "STAGE_NOT_OWNED";
267
+ type StagePolicyErrorCode =
268
+ /** The stage is neither protected nor disposable. */
269
+ "UNKNOWN_STAGE" |
270
+ /** The table classifies the stage as both protected and disposable. */
271
+ "AMBIGUOUS_STAGE" |
272
+ /** A destructive operation was asked for on a protected stage. */
273
+ "PROTECTED_STAGE" |
274
+ /** The stack is not in the table's registry. */
275
+ "UNKNOWN_STACK" |
276
+ /** The stack and the stage are not paired by the table. */
277
+ "STAGE_NOT_OWNED";
276
278
  /**
277
279
  * A policy refusal. The `code` is the stable part: a project maps it onto its
278
280
  * own lifecycle failure envelope, and the message is for a human.
279
281
  */
280
- declare class StagePolicyError extends Error {
282
+ export declare class StagePolicyError extends Error {
281
283
  readonly code: StagePolicyErrorCode;
282
284
  constructor(code: StagePolicyErrorCode, message: string);
283
285
  }
@@ -310,16 +312,14 @@ interface StagePolicy {
310
312
  * classifies the stages of its own estate, and the emulated stage belongs to
311
313
  * no estate.
312
314
  */
313
- declare const isLocalEmulationStage: (stage: string) => boolean;
315
+ export declare const isLocalEmulationStage: (stage: string) => boolean;
314
316
  /**
315
317
  * Read a project's stage table and answer the stage questions from it.
316
318
  *
317
319
  * A stage the table classifies as both protected and disposable is a table
318
320
  * defect, not a stage a caller may act on, so every query on it throws.
319
321
  */
320
- declare const stagePolicy: (table: StagePolicyTable) => StagePolicy;
321
- //#endregion
322
- //#region src/alchemy/credential-preflight.d.ts
322
+ export declare const stagePolicy: (table: StagePolicyTable) => StagePolicy;
323
323
  /**
324
324
  * Cloudflare credential preflight for an Alchemy deploy.
325
325
  *
@@ -339,7 +339,7 @@ type CloudflareTokenKind = "account" | "user";
339
339
  * project's own secret manager; an ambient token there means the run is not
340
340
  * the run it claims to be.
341
341
  */
342
- declare const HOSTED_CLOUDFLARE_CREDENTIAL_NAMES: readonly ["CLOUDFLARE_ACCOUNT_ID", "CLOUDFLARE_API_TOKEN"];
342
+ export declare const HOSTED_CLOUDFLARE_CREDENTIAL_NAMES: readonly ["CLOUDFLARE_ACCOUNT_ID", "CLOUDFLARE_API_TOKEN"];
343
343
  /** The token and the reviewed policy document that describes it. */
344
344
  interface CloudflareCredential {
345
345
  /**
@@ -393,7 +393,7 @@ interface CredentialPreflightResult {
393
393
  * mismatch: an unreachable API is a transient condition, and a token whose
394
394
  * permissions are wrong is not.
395
395
  */
396
- declare class CloudflareCredentialUnavailableError extends Error {
396
+ export declare class CloudflareCredentialUnavailableError extends Error {
397
397
  constructor(message?: string);
398
398
  }
399
399
  /**
@@ -416,18 +416,7 @@ declare class CloudflareCredentialUnavailableError extends Error {
416
416
  * Cloudflare could not be asked; every other error means the credential is
417
417
  * wrong. Nothing it throws, and nothing it returns, carries a secret value.
418
418
  */
419
- declare const credentialPreflight: ({
420
- accountId,
421
- environment,
422
- fetchImplementation,
423
- requiredPermissionGroups,
424
- resolveCredential,
425
- resourcesFor,
426
- source,
427
- tokenKind
428
- }: CredentialPreflightOptions) => Promise<CredentialPreflightResult>;
429
- //#endregion
430
- //#region src/alchemy/destroy-postcondition.d.ts
419
+ export declare const credentialPreflight: ({ accountId, environment, fetchImplementation, requiredPermissionGroups, resolveCredential, resourcesFor, source, tokenKind }: CredentialPreflightOptions) => Promise<CredentialPreflightResult>;
431
420
  /**
432
421
  * The destroy postcondition: a destroyed stage owns nothing.
433
422
  *
@@ -462,13 +451,7 @@ interface AssertDestroyLeftNothingOptions extends StageStateTarget {
462
451
  * message that carries nothing the reader's own error said. Resource
463
452
  * identifiers are names, never values.
464
453
  */
465
- declare const assertDestroyLeftNothing: ({
466
- stack,
467
- stage,
468
- stateReader
469
- }: AssertDestroyLeftNothingOptions) => Promise<void>;
470
- //#endregion
471
- //#region src/alchemy/first-deploy-authorization.d.ts
454
+ export declare const assertDestroyLeftNothing: ({ stack, stage, stateReader }: AssertDestroyLeftNothingOptions) => Promise<void>;
472
455
  interface FirstDeployPlanHashOptions {
473
456
  /**
474
457
  * The Alchemy CLI's plan output, verbatim. It is canonicalised and hashed
@@ -523,12 +506,7 @@ interface FirstDeployAuthorization {
523
506
  * Throws a `PlanEffectsError` when the plan adapter cannot account for the
524
507
  * output: an unreadable plan is refused, never hashed.
525
508
  */
526
- declare const firstDeployPlanHash: ({
527
- planText,
528
- sourceSha,
529
- stack,
530
- stage
531
- }: FirstDeployPlanHashOptions) => string;
509
+ export declare const firstDeployPlanHash: ({ planText, sourceSha, stack, stage }: FirstDeployPlanHashOptions) => string;
532
510
  /**
533
511
  * Admits a first deploy only when its plan hash is one the project
534
512
  * authorized.
@@ -537,15 +515,7 @@ declare const firstDeployPlanHash: ({
537
515
  * adds to the authorization list after reading the plan. It never carries the
538
516
  * plan text.
539
517
  */
540
- declare const firstDeployAuthorization: ({
541
- authorizedHashes,
542
- planText,
543
- sourceSha,
544
- stack,
545
- stage
546
- }: FirstDeployAuthorizationOptions) => FirstDeployAuthorization;
547
- //#endregion
548
- //#region src/alchemy/url-implies-auth.d.ts
518
+ export declare const firstDeployAuthorization: ({ authorizedHashes, planText, sourceSha, stack, stage }: FirstDeployAuthorizationOptions) => FirstDeployAuthorization;
549
519
  /** One Worker the project has decided may stay reachable without a declared guard. */
550
520
  interface UrlImpliesAuthAllowance {
551
521
  /** The Worker's logical id, as the graph reports it. */
@@ -565,13 +535,17 @@ interface AssertUrlImpliesAuthOptions {
565
535
  readonly allowlist?: readonly UrlImpliesAuthAllowance[];
566
536
  }
567
537
  /** Why one Worker failed the invariant. */
568
- type UrlImpliesAuthViolationReason = /** The Worker is reachable and the graph shows no guard and no allowance. */"unauthenticated" /** An allowlist entry names the Worker but states no reason. */ | "allowance-without-reason";
538
+ type UrlImpliesAuthViolationReason =
539
+ /** The Worker is reachable and the graph shows no guard and no allowance. */
540
+ "unauthenticated" |
541
+ /** An allowlist entry names the Worker but states no reason. */
542
+ "allowance-without-reason";
569
543
  interface UrlImpliesAuthViolation {
570
544
  readonly worker: string;
571
545
  readonly reason: UrlImpliesAuthViolationReason;
572
546
  }
573
547
  /** Every offending Worker in one throw, so a stack is fixed in one pass. */
574
- declare class UrlImpliesAuthError extends Error {
548
+ export declare class UrlImpliesAuthError extends Error {
575
549
  readonly violations: readonly UrlImpliesAuthViolation[];
576
550
  constructor(violations: readonly UrlImpliesAuthViolation[]);
577
551
  }
@@ -586,12 +560,7 @@ declare class UrlImpliesAuthError extends Error {
586
560
  * violation, and every violation in the graph is reported in one
587
561
  * `UrlImpliesAuthError`.
588
562
  */
589
- declare const assertUrlImpliesAuth: (graph: EvaluatedGraph, {
590
- allowlist,
591
- authBindingName
592
- }: AssertUrlImpliesAuthOptions) => void;
593
- //#endregion
594
- //#region src/alchemy/secret-name-policy.d.ts
563
+ export declare const assertUrlImpliesAuth: (graph: EvaluatedGraph, { allowlist, authBindingName }: AssertUrlImpliesAuthOptions) => void;
595
564
  /**
596
565
  * A secret-name redaction policy for `executeAlchemyEntry`'s `redact` hook.
597
566
  *
@@ -606,13 +575,13 @@ declare const assertUrlImpliesAuth: (graph: EvaluatedGraph, {
606
575
  * covers less than the caller believes it covers.
607
576
  */
608
577
  /** What a redacted value is replaced with. */
609
- declare const SECRET_REDACTION_PLACEHOLDER = "[REDACTED]";
578
+ export declare const SECRET_REDACTION_PLACEHOLDER = "[REDACTED]";
610
579
  /**
611
580
  * The shortest value that may be replaced. A short value occurs in ordinary
612
581
  * output by chance, so replacing it would erase unrelated text and hide what
613
582
  * the run actually did.
614
583
  */
615
- declare const MINIMUM_REDACTABLE_SECRET_LENGTH = 8;
584
+ export declare const MINIMUM_REDACTABLE_SECRET_LENGTH = 8;
616
585
  interface SecretNamePolicyOptions {
617
586
  /**
618
587
  * The names of the values to redact. The project owns this list; this
@@ -643,12 +612,7 @@ interface SecretNamePolicyOptions {
643
612
  * and gets no redaction. Empty names beside a populated `values` map is
644
613
  * refused, because that is a caller who meant to declare something.
645
614
  */
646
- declare const secretNamePolicy: ({
647
- names,
648
- values
649
- }: SecretNamePolicyOptions) => ((text: string) => string);
650
- //#endregion
651
- //#region src/alchemy/lifecycle-failure.d.ts
615
+ export declare const secretNamePolicy: ({ names, values }: SecretNamePolicyOptions) => ((text: string) => string);
652
616
  /**
653
617
  * The lifecycle failure envelope (#1077).
654
618
  *
@@ -664,7 +628,17 @@ declare const secretNamePolicy: ({
664
628
  */
665
629
  type AlchemyLifecycleOperation = "plan" | "deploy" | "destroy";
666
630
  /** Where in the sequence the failure was raised. */
667
- type AlchemyLifecyclePhase = /** The request itself or the policy is malformed. */"request" /** A pre-mutation check refused the operation. */ | "admission" /** The state store could not be read or owned. */ | "state" /** The Alchemy child failed. */ | "execution" /** A check after the child ran did not hold. */ | "postcondition";
631
+ type AlchemyLifecyclePhase =
632
+ /** The request itself or the policy is malformed. */
633
+ "request" |
634
+ /** A pre-mutation check refused the operation. */
635
+ "admission" |
636
+ /** The state store could not be read or owned. */
637
+ "state" |
638
+ /** The Alchemy child failed. */
639
+ "execution" |
640
+ /** A check after the child ran did not hold. */
641
+ "postcondition";
668
642
  /**
669
643
  * What the failure says about the target stage. `not-started` means no
670
644
  * child ran. `read-only-started` means only a planning child ran: no child
@@ -677,7 +651,7 @@ type AlchemyLifecycleFailureCode = "INVALID_REQUEST" | "INVALID_POLICY" | "UNSUP
677
651
  * The one sentence each code is reported with. The table is the whole
678
652
  * vocabulary: a message that is not in it cannot be raised.
679
653
  */
680
- declare const LIFECYCLE_FAILURE_MESSAGES: Readonly<Record<AlchemyLifecycleFailureCode, string>>;
654
+ export declare const LIFECYCLE_FAILURE_MESSAGES: Readonly<Record<AlchemyLifecycleFailureCode, string>>;
681
655
  interface AlchemyLifecycleFailureFields {
682
656
  /**
683
657
  * The file the run's child output was being written to, on a child
@@ -696,7 +670,7 @@ interface AlchemyLifecycleFailureFields {
696
670
  readonly planHash?: string;
697
671
  }
698
672
  /** A sanitized lifecycle failure. See the module comment. */
699
- declare class AlchemyLifecycleError extends Error implements AlchemyLifecycleFailureFields {
673
+ export declare class AlchemyLifecycleError extends Error implements AlchemyLifecycleFailureFields {
700
674
  readonly childDiagnosticsPath?: string;
701
675
  readonly code: AlchemyLifecycleFailureCode;
702
676
  readonly mutation: MutationCertainty;
@@ -709,9 +683,7 @@ declare class AlchemyLifecycleError extends Error implements AlchemyLifecycleFai
709
683
  readonly message: string;
710
684
  };
711
685
  }
712
- declare const isAlchemyLifecycleError: (error: unknown) => error is AlchemyLifecycleError;
713
- //#endregion
714
- //#region src/alchemy/plan-effects.d.ts
686
+ export declare const isAlchemyLifecycleError: (error: unknown) => error is AlchemyLifecycleError;
715
687
  /**
716
688
  * The plan-output adapter (#1077): the one reader of what the installed
717
689
  * Alchemy CLI prints for a plan.
@@ -746,13 +718,13 @@ declare const isAlchemyLifecycleError: (error: unknown) => error is AlchemyLifec
746
718
  * reviewed at one moment and deployed at another is the same plan (#1232).
747
719
  */
748
720
  /** The Alchemy version whose plan renderer this adapter reads. */
749
- declare const PLAN_OUTPUT_ALCHEMY_VERSION: string;
721
+ export declare const PLAN_OUTPUT_ALCHEMY_VERSION: string;
750
722
  /**
751
723
  * Every action a resource row can carry. The first six are the actions the
752
724
  * summary counts, in the order the renderer prints them; `noop` rows print
753
725
  * under the summary but are never counted in it.
754
726
  */
755
- declare const PLAN_ACTIONS: readonly ["create", "update", "adopted", "replace", "delete", "orphaned", "noop"];
727
+ export declare const PLAN_ACTIONS: readonly ["create", "update", "adopted", "replace", "delete", "orphaned", "noop"];
756
728
  type PlanAction = (typeof PLAN_ACTIONS)[number];
757
729
  /** One top-level resource row of a plan. */
758
730
  interface PlanResourceEffect {
@@ -786,7 +758,7 @@ interface PlanEffects {
786
758
  }
787
759
  type PlanEffectsRejection = "no-summary" | "multiple-summaries" | "unknown-action" | "summary-unrecognized" | "count-mismatch" | "ambiguous-rows" | "effects-under-no-changes";
788
760
  /** The adapter could not read the output. `reason` is the whole detail. */
789
- declare class PlanEffectsError extends Error {
761
+ export declare class PlanEffectsError extends Error {
790
762
  readonly reason: PlanEffectsRejection;
791
763
  constructor(reason: PlanEffectsRejection);
792
764
  }
@@ -796,9 +768,7 @@ declare class PlanEffectsError extends Error {
796
768
  * Throws `PlanEffectsError` on output the adapter cannot account for. The
797
769
  * output itself never appears in the error.
798
770
  */
799
- declare const parsePlanEffects: (output: string) => PlanEffects;
800
- //#endregion
801
- //#region src/alchemy/child-diagnostics.d.ts
771
+ export declare const parsePlanEffects: (output: string) => PlanEffects;
802
772
  /**
803
773
  * The optional record of what an Alchemy child printed (#1260).
804
774
  *
@@ -849,8 +819,6 @@ interface ChildDiagnostics {
849
819
  */
850
820
  readonly redact: (text: string) => string;
851
821
  }
852
- //#endregion
853
- //#region src/alchemy/lifecycle.d.ts
854
822
  interface AlchemyLifecycleRequest {
855
823
  readonly operation: AlchemyLifecycleOperation;
856
824
  readonly stack: string;
@@ -967,6 +935,24 @@ interface AlchemyLifecyclePolicy {
967
935
  * not converged whatever this list names.
968
936
  */
969
937
  readonly nonConvergentResources?: readonly string[];
938
+ /**
939
+ * Bounded read-only re-plans after the apply (#1349). A provider can
940
+ * report a resource as still changing for a short while after a successful
941
+ * apply. Set, a post-deploy plan that is only `NOT_CONVERGED` waits
942
+ * `delayMillis` and re-plans, up to `attempts` more times, under the same
943
+ * lease. The apply never repeats, and every other check (the state read on
944
+ * both sides of each plan, retained identities, created resources, the
945
+ * lease) runs on every attempt and stops the deploy at once. Exhausted, the
946
+ * deploy is still `NOT_CONVERGED`. Omitted, there is no retry. `attempts`
947
+ * is 1 to 10 and `delayMillis` 0 to 60 000, and below an explicit
948
+ * `ownershipTtlMillis`. That bound is a floor: the lease is renewed after
949
+ * each dry-run, so the delay plus one re-plan must fit inside the lease;
950
+ * keep the delay well under it.
951
+ */
952
+ readonly convergenceRetries?: {
953
+ readonly attempts: number;
954
+ readonly delayMillis: number;
955
+ };
970
956
  }
971
957
  type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
972
958
  /**
@@ -984,7 +970,8 @@ type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K>
984
970
  * which owns its own redactor and its own file.
985
971
  */
986
972
  type AlchemyLifecycleEntry = DistributiveOmit<ExecuteAlchemyEntryOptions, "args" | "onCaptured" | "stdio" | "maxBuffer" | "redact"> & {
987
- /** Explicit dotenv file for every child; omitted preserves Alchemy defaults. */readonly envFile?: string;
973
+ /** Explicit dotenv file for every child; omitted preserves Alchemy defaults. */
974
+ readonly envFile?: string;
988
975
  };
989
976
  interface RunAlchemyLifecycleOptions {
990
977
  readonly request: AlchemyLifecycleRequest;
@@ -1079,9 +1066,7 @@ interface AlchemyLifecycleResult {
1079
1066
  * mutated, and after that is reported as `CHILD_DIAGNOSTICS_UNWRITABLE` once
1080
1067
  * the operation has finished, never in place of its postconditions.
1081
1068
  */
1082
- declare const runAlchemyLifecycle: (options: RunAlchemyLifecycleOptions) => Promise<AlchemyLifecycleResult>;
1083
- //#endregion
1084
- //#region src/alchemy/state-tree.d.ts
1069
+ export declare const runAlchemyLifecycle: (options: RunAlchemyLifecycleOptions) => Promise<AlchemyLifecycleResult>;
1085
1070
  /**
1086
1071
  * The subset of the state layer the record read goes through: the atomic
1087
1072
  * stage view and the per-resource record. `@patronage/alchemy-d1-state`
@@ -1108,7 +1093,7 @@ interface StageFilter {
1108
1093
  * empty result is the store reporting nothing, never a read this module
1109
1094
  * could not make: a state layer that cannot be read fails instead.
1110
1095
  */
1111
- declare const inventoryStages: (state: StateService, filter?: StageFilter) => Promise<readonly StageTarget[]>;
1096
+ export declare const inventoryStages: (state: StateService, filter?: StageFilter) => Promise<readonly StageTarget[]>;
1112
1097
  /**
1113
1098
  * The persisted-state document for one stage, as `parseStateSnapshot` reads
1114
1099
  * it: `{ resources: [{ stack, stage, fqn, state }] }`, ordered by fqn.
@@ -1124,7 +1109,7 @@ declare const inventoryStages: (state: StateService, filter?: StageFilter) => Pr
1124
1109
  * the store cannot read fails. `deleteStageRows` answers an absent stage the
1125
1110
  * other way, because it addresses a path rather than a stage view.
1126
1111
  */
1127
- declare const readStageSnapshot: (state: StageRecordStore, target: StageTarget) => Promise<string>;
1112
+ export declare const readStageSnapshot: (state: StageRecordStore, target: StageTarget) => Promise<string>;
1128
1113
  /**
1129
1114
  * Remove every row the state layer holds for one stage. Other stages of the
1130
1115
  * same stack keep every row.
@@ -1133,9 +1118,7 @@ declare const readStageSnapshot: (state: StageRecordStore, target: StageTarget)
1133
1118
  * reported as removed, so a caller never reads a mistyped stage as a stage
1134
1119
  * that was already empty.
1135
1120
  */
1136
- declare const deleteStageRows: (state: StateService, target: StageTarget) => Promise<void>;
1137
- //#endregion
1138
- //#region src/alchemy/index.d.ts
1121
+ export declare const deleteStageRows: (state: StateService, target: StageTarget) => Promise<void>;
1139
1122
  /**
1140
1123
  * The `@patronage/factory-ci/alchemy` subpath: the only place in this package
1141
1124
  * where `alchemy` or `effect` may be imported (ADR 0031).
@@ -1153,6 +1136,5 @@ declare const deleteStageRows: (state: StateService, target: StageTarget) => Pro
1153
1136
  * both.
1154
1137
  */
1155
1138
  /** The specifier a consumer imports this surface by. */
1156
- declare const ALCHEMY_SUBPATH = "@patronage/factory-ci/alchemy";
1157
- //#endregion
1158
- export { ALCHEMY_SUBPATH, type AlchemyLifecycleEntry, AlchemyLifecycleError, type AlchemyLifecycleFailureCode, type AlchemyLifecycleFailureFields, type AlchemyLifecycleOperation, type AlchemyLifecyclePhase, type AlchemyLifecyclePolicy, type AlchemyLifecycleRequest, type AlchemyLifecycleResult, type AssertDestroyLeftNothingOptions, type AssertRetainedIdentitiesOptions, type AssertUrlImpliesAuthOptions, type AuthBindingNameMatcher, type ChildDiagnostics, type CloudflareCredential, CloudflareCredentialUnavailableError, type CloudflareTokenKind, type CredentialPreflightOptions, type CredentialPreflightResult, type CredentialSource, type EvaluateStackInput, type EvaluatedBinding, type EvaluatedGraph, type EvaluatedResource, type FirstDeployAuthorization, type FirstDeployAuthorizationOptions, type FirstDeployPlanHashOptions, type FirstDeployPolicy, HOSTED_CLOUDFLARE_CREDENTIAL_NAMES, LIFECYCLE_FAILURE_MESSAGES, LOCAL_PREVIEW_STAGES, MINIMUM_REDACTABLE_SECRET_LENGTH, type MutationCertainty, PLAN_ACTIONS, PLAN_OUTPUT_ALCHEMY_VERSION, type PlanAction, type PlanEffects, PlanEffectsError, type PlanEffectsRejection, type PlanResourceEffect, type PlanTaskAction, type PlanTaskEffect, RetainedIdentityError, type RetainedIdentityMarker, type RetainedIdentitySection, type RetainedIdentityViolation, type RetainedIdentityViolationReason, type RunAlchemyLifecycleOptions, SECRET_REDACTION_PLACEHOLDER, type SecretNamePolicyOptions, type StackOutputOccupancy, type StackStageOwnership, type StageCleanupOutcome, type StageLease, type StageMatcher, type StagePolicy, StagePolicyError, type StagePolicyErrorCode, type StagePolicyTable, type StageSnapshotView, type StageStateReader, type StageStateStore, type StageStateTarget, type StageTarget, type StateSnapshot, type StateSnapshotResource, type StateSnapshotScope, type UrlImpliesAuthAllowance, UrlImpliesAuthError, type UrlImpliesAuthViolation, type UrlImpliesAuthViolationReason, anyStage, assertDestroyLeftNothing, assertRetainedIdentities, assertUrlImpliesAuth, credentialPreflight, deleteStageRows, evaluateStack, firstDeployAuthorization, firstDeployPlanHash, inventoryStages, isAlchemyLifecycleError, isLocalEmulationStage, localEmulationEnvironment, parsePlanEffects, parseStateSnapshot, readStageSnapshot, runAlchemyLifecycle, secretNamePolicy, stagePolicy };
1139
+ export declare const ALCHEMY_SUBPATH = "@patronage/factory-ci/alchemy";
1140
+ export type { AlchemyLifecycleEntry, AlchemyLifecycleFailureCode, AlchemyLifecycleFailureFields, AlchemyLifecycleOperation, AlchemyLifecyclePhase, AlchemyLifecyclePolicy, AlchemyLifecycleRequest, AlchemyLifecycleResult, AssertDestroyLeftNothingOptions, AssertRetainedIdentitiesOptions, AssertUrlImpliesAuthOptions, AuthBindingNameMatcher, ChildDiagnostics, CloudflareCredential, CloudflareTokenKind, CredentialPreflightOptions, CredentialPreflightResult, CredentialSource, EvaluateStackInput, EvaluatedBinding, EvaluatedGraph, EvaluatedResource, FirstDeployAuthorization, FirstDeployAuthorizationOptions, FirstDeployPlanHashOptions, FirstDeployPolicy, MutationCertainty, PlanAction, PlanEffects, PlanEffectsRejection, PlanResourceEffect, PlanTaskAction, PlanTaskEffect, RetainedIdentityMarker, RetainedIdentitySection, RetainedIdentityViolation, RetainedIdentityViolationReason, RunAlchemyLifecycleOptions, SecretNamePolicyOptions, StackOutputOccupancy, StackStageOwnership, StageCleanupOutcome, StageLease, StageMatcher, StagePolicy, StagePolicyErrorCode, StagePolicyTable, StageSnapshotView, StageStateReader, StageStateStore, StageStateTarget, StageTarget, StateSnapshot, StateSnapshotResource, StateSnapshotScope, UrlImpliesAuthAllowance, UrlImpliesAuthViolation, UrlImpliesAuthViolationReason };