@homeflare/alchemy 0.8.0 → 0.10.1
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 +22 -11
- package/dist/caddy/config-lifecycle.d.ts +1 -1
- package/dist/caddy/config.d.ts.map +1 -1
- package/dist/caddy/index.js +221 -53
- package/dist/caddy/index.js.map +13 -9
- package/dist/launchd/fake-runner.d.ts +1 -0
- package/dist/launchd/fake-runner.d.ts.map +1 -1
- package/dist/launchd/fake-sudo.d.ts +1 -0
- package/dist/launchd/fake-sudo.d.ts.map +1 -1
- package/dist/launchd/host-effect.d.ts +9 -18
- package/dist/launchd/host-effect.d.ts.map +1 -1
- package/dist/launchd/host-file-lifecycle.d.ts +14 -1
- package/dist/launchd/host-file-lifecycle.d.ts.map +1 -1
- package/dist/launchd/host-file.d.ts +2 -1
- package/dist/launchd/host-file.d.ts.map +1 -1
- package/dist/launchd/index.js +345 -86
- package/dist/launchd/index.js.map +18 -12
- package/dist/launchd/job-lifecycle.d.ts +8 -1
- package/dist/launchd/job-lifecycle.d.ts.map +1 -1
- package/dist/launchd/job-preflight.d.ts +13 -1
- package/dist/launchd/job-preflight.d.ts.map +1 -1
- package/dist/launchd/job.d.ts +2 -1
- package/dist/launchd/job.d.ts.map +1 -1
- package/dist/launchd/runner.d.ts +7 -0
- package/dist/launchd/runner.d.ts.map +1 -1
- package/dist/launchd/sudo-acl.d.ts +25 -0
- package/dist/launchd/sudo-acl.d.ts.map +1 -0
- package/dist/launchd/sudo-guard.d.ts +31 -4
- package/dist/launchd/sudo-guard.d.ts.map +1 -1
- package/dist/launchd/sudo-runner.d.ts +3 -3
- package/dist/launchd/sudo-runner.d.ts.map +1 -1
- package/dist/launchd/sudo-said.d.ts +10 -0
- package/dist/launchd/sudo-said.d.ts.map +1 -0
- package/dist/openbao/auth-method-reconcile.d.ts +6 -2
- package/dist/openbao/auth-method-reconcile.d.ts.map +1 -1
- package/dist/openbao/auth-method.d.ts.map +1 -1
- package/dist/openbao/auth-role.d.ts.map +1 -1
- package/dist/openbao/cloudflare-role.d.ts.map +1 -1
- package/dist/openbao/fake-bao.d.ts +18 -0
- package/dist/openbao/fake-bao.d.ts.map +1 -1
- package/dist/openbao/fake-core.d.ts +39 -0
- package/dist/openbao/fake-core.d.ts.map +1 -0
- package/dist/openbao/fake-families.d.ts +6 -3
- package/dist/openbao/fake-families.d.ts.map +1 -1
- package/dist/openbao/fake-mounts.d.ts +16 -0
- package/dist/openbao/fake-mounts.d.ts.map +1 -0
- package/dist/openbao/fake-stack.d.ts +5 -1
- package/dist/openbao/fake-stack.d.ts.map +1 -1
- package/dist/openbao/index.js +541 -270
- package/dist/openbao/index.js.map +26 -21
- package/dist/openbao/jwt-config.d.ts.map +1 -1
- package/dist/openbao/jwt-role.d.ts.map +1 -1
- package/dist/openbao/kubernetes-role.d.ts.map +1 -1
- package/dist/openbao/mfa-enforcement.d.ts +6 -2
- package/dist/openbao/mfa-enforcement.d.ts.map +1 -1
- package/dist/openbao/mfa-totp.d.ts +6 -2
- package/dist/openbao/mfa-totp.d.ts.map +1 -1
- package/dist/openbao/mount-reconcile.d.ts +5 -1
- package/dist/openbao/mount-reconcile.d.ts.map +1 -1
- package/dist/openbao/mount.d.ts.map +1 -1
- package/dist/openbao/pki-role.d.ts.map +1 -1
- package/dist/openbao/plugin-reconcile.d.ts +6 -2
- package/dist/openbao/plugin-reconcile.d.ts.map +1 -1
- package/dist/openbao/plugin.d.ts.map +1 -1
- package/dist/openbao/policy.d.ts.map +1 -1
- package/dist/openbao/proxmox-role.d.ts.map +1 -1
- package/dist/openbao/role-reconcile.d.ts +11 -1
- package/dist/openbao/role-reconcile.d.ts.map +1 -1
- package/dist/openbao/ssh-role.d.ts.map +1 -1
- package/dist/ownership/adopt.d.ts +52 -0
- package/dist/ownership/adopt.d.ts.map +1 -0
- package/dist/ownership/probe.d.ts +13 -0
- package/dist/ownership/probe.d.ts.map +1 -0
- package/dist/ownership/resume.d.ts +40 -0
- package/dist/ownership/resume.d.ts.map +1 -0
- package/dist/ownership/rows.d.ts +33 -0
- package/dist/ownership/rows.d.ts.map +1 -0
- package/dist/ownership/whole.d.ts +14 -0
- package/dist/ownership/whole.d.ts.map +1 -0
- package/dist/proxmox/ceph-pool-form.d.ts +3 -3
- package/dist/proxmox/ceph-pool.d.ts.map +1 -1
- package/dist/proxmox/fake-bao-env.d.ts +3 -0
- package/dist/proxmox/fake-bao-env.d.ts.map +1 -0
- package/dist/proxmox/fake-pve-lxc.d.ts +42 -0
- package/dist/proxmox/fake-pve-lxc.d.ts.map +1 -0
- package/dist/proxmox/fake-pve.d.ts +38 -0
- package/dist/proxmox/fake-pve.d.ts.map +1 -0
- package/dist/proxmox/index.d.ts +6 -2
- package/dist/proxmox/index.d.ts.map +1 -1
- package/dist/proxmox/index.js +970 -186
- package/dist/proxmox/index.js.map +22 -9
- package/dist/proxmox/lxc-create-form.d.ts +6 -0
- package/dist/proxmox/lxc-create-form.d.ts.map +1 -0
- package/dist/proxmox/lxc-harness.d.ts +34 -0
- package/dist/proxmox/lxc-harness.d.ts.map +1 -0
- package/dist/proxmox/lxc-identity.d.ts +18 -0
- package/dist/proxmox/lxc-identity.d.ts.map +1 -0
- package/dist/proxmox/lxc-judge.d.ts +46 -0
- package/dist/proxmox/lxc-judge.d.ts.map +1 -0
- package/dist/proxmox/lxc-lifecycle.d.ts +68 -0
- package/dist/proxmox/lxc-lifecycle.d.ts.map +1 -0
- package/dist/proxmox/lxc-props.d.ts +139 -0
- package/dist/proxmox/lxc-props.d.ts.map +1 -0
- package/dist/proxmox/lxc-volume.d.ts +29 -0
- package/dist/proxmox/lxc-volume.d.ts.map +1 -0
- package/dist/proxmox/lxc-wire.d.ts +51 -0
- package/dist/proxmox/lxc-wire.d.ts.map +1 -0
- package/dist/proxmox/lxc.d.ts +27 -47
- package/dist/proxmox/lxc.d.ts.map +1 -1
- package/dist/proxmox/network-apply-read.d.ts +1 -1
- package/dist/proxmox/network-apply-read.d.ts.map +1 -1
- package/dist/proxmox/pbs-datastore.d.ts.map +1 -1
- package/dist/proxmox/resource.d.ts.map +1 -1
- package/dist/proxmox/update-guard.d.ts +27 -0
- package/dist/proxmox/update-guard.d.ts.map +1 -0
- package/dist/verify/args.d.ts +16 -0
- package/dist/verify/args.d.ts.map +1 -0
- package/dist/verify/cli.d.ts +3 -0
- package/dist/verify/cli.d.ts.map +1 -0
- package/dist/verify/cli.js +370 -0
- package/dist/verify/cli.js.map +17 -0
- package/dist/verify/fake-engine.d.ts +65 -0
- package/dist/verify/fake-engine.d.ts.map +1 -0
- package/dist/verify/index.d.ts +16 -0
- package/dist/verify/index.d.ts.map +1 -0
- package/dist/verify/index.js +347 -0
- package/dist/verify/index.js.map +16 -0
- package/dist/verify/plan-scope.d.ts +14 -0
- package/dist/verify/plan-scope.d.ts.map +1 -0
- package/dist/verify/recheck.d.ts +42 -0
- package/dist/verify/recheck.d.ts.map +1 -0
- package/dist/verify/report.d.ts +6 -0
- package/dist/verify/report.d.ts.map +1 -0
- package/dist/verify/rows.d.ts +67 -0
- package/dist/verify/rows.d.ts.map +1 -0
- package/dist/verify/spy.d.ts +43 -0
- package/dist/verify/spy.d.ts.map +1 -0
- package/dist/verify/verify.d.ts +43 -0
- package/dist/verify/verify.d.ts.map +1 -0
- package/docs/adopt-verify.md +119 -0
- package/docs/adopted-deploys.md +85 -0
- package/docs/credentials.md +15 -0
- package/docs/launchd-sudo.md +31 -6
- package/docs/launchd.md +7 -3
- package/docs/ownership.md +113 -0
- package/docs/proxmox-lxc.md +196 -0
- package/docs/proxmox.md +12 -0
- package/package.json +9 -2
- package/src/caddy/adopt-scope.test.ts +1 -1
- package/src/caddy/config-lifecycle.ts +1 -1
- package/src/caddy/config.ts +2 -1
- package/src/launchd/adopt-apply.test.ts +166 -0
- package/src/launchd/fake-runner.ts +26 -4
- package/src/launchd/host-effect.ts +1 -33
- package/src/launchd/host-file-lifecycle.ts +39 -14
- package/src/launchd/host-file.ts +13 -4
- package/src/launchd/job-lifecycle.ts +22 -14
- package/src/launchd/job-preflight.ts +18 -1
- package/src/launchd/job.ts +13 -4
- package/src/launchd/runner.ts +7 -0
- package/src/launchd/sudo-acl.ts +68 -0
- package/src/launchd/sudo-chain.test.ts +121 -0
- package/src/launchd/sudo-guard.ts +89 -10
- package/src/launchd/sudo-modes.test.ts +135 -0
- package/src/launchd/sudo-runner.ts +40 -59
- package/src/launchd/sudo-said.ts +58 -0
- package/src/openbao/README.md +5 -2
- package/src/openbao/REPLACE.md +13 -11
- package/src/openbao/adopt-core.test.ts +119 -0
- package/src/openbao/adopt-families.test.ts +97 -0
- package/src/openbao/adopt-holes.test.ts +168 -0
- package/src/openbao/adopt-recovery.test.ts +71 -0
- package/src/openbao/auth-method-reconcile.ts +15 -3
- package/src/openbao/auth-method.ts +15 -6
- package/src/openbao/auth-role.ts +14 -4
- package/src/openbao/cloudflare-role.ts +17 -4
- package/src/openbao/fake-bao.ts +52 -0
- package/src/openbao/fake-core.ts +141 -0
- package/src/openbao/fake-families.ts +11 -5
- package/src/openbao/fake-mounts.ts +74 -0
- package/src/openbao/fake-stack.ts +17 -4
- package/src/openbao/jwt-config.ts +10 -7
- package/src/openbao/jwt-role.ts +10 -7
- package/src/openbao/kubernetes-role.ts +13 -7
- package/src/openbao/mfa-enforcement.ts +20 -6
- package/src/openbao/mfa-totp.ts +22 -7
- package/src/openbao/mount-move.test.ts +2 -35
- package/src/openbao/mount-reconcile.ts +13 -2
- package/src/openbao/mount.ts +15 -6
- package/src/openbao/pki-role.ts +15 -4
- package/src/openbao/plugin-reconcile.ts +16 -5
- package/src/openbao/plugin.ts +17 -6
- package/src/openbao/policy.ts +17 -4
- package/src/openbao/proxmox-role.ts +13 -4
- package/src/openbao/rename-adoption.test.ts +32 -19
- package/src/openbao/role-reconcile.ts +23 -0
- package/src/openbao/ssh-role.ts +14 -4
- package/src/ownership/adopt.ts +122 -0
- package/src/ownership/ownership.test.ts +200 -0
- package/src/ownership/probe.ts +65 -0
- package/src/ownership/resume.ts +118 -0
- package/src/ownership/rows.ts +117 -0
- package/src/ownership/whole.test.ts +39 -0
- package/src/ownership/whole.ts +60 -0
- package/src/proxmox/adopt-noop.test.ts +112 -0
- package/src/proxmox/ceph-pool-adopt.test.ts +120 -0
- package/src/proxmox/ceph-pool-form.ts +3 -3
- package/src/proxmox/ceph-pool.ts +10 -3
- package/src/proxmox/fake-bao-env.ts +28 -0
- package/src/proxmox/fake-pve-lxc.ts +210 -0
- package/src/proxmox/fake-pve.ts +75 -0
- package/src/proxmox/index.test.ts +6 -6
- package/src/proxmox/index.ts +6 -2
- package/src/proxmox/lxc-adopt.test.ts +170 -0
- package/src/proxmox/lxc-create-form.ts +76 -0
- package/src/proxmox/lxc-create.test.ts +126 -0
- package/src/proxmox/lxc-guards.test.ts +158 -0
- package/src/proxmox/lxc-harness.ts +150 -0
- package/src/proxmox/lxc-identity.ts +43 -0
- package/src/proxmox/lxc-judge.test.ts +175 -0
- package/src/proxmox/lxc-judge.ts +196 -0
- package/src/proxmox/lxc-lifecycle.ts +200 -0
- package/src/proxmox/lxc-ownership.test.ts +159 -0
- package/src/proxmox/lxc-props.ts +215 -0
- package/src/proxmox/lxc-read.test.ts +60 -0
- package/src/proxmox/lxc-volume.test.ts +96 -0
- package/src/proxmox/lxc-volume.ts +153 -0
- package/src/proxmox/lxc-wire.ts +210 -0
- package/src/proxmox/lxc.ts +216 -93
- package/src/proxmox/network-apply-read.ts +3 -1
- package/src/proxmox/pbs-datastore.ts +4 -3
- package/src/proxmox/resource.ts +7 -7
- package/src/proxmox/update-guard.ts +31 -0
- package/src/verify/args.ts +82 -0
- package/src/verify/cli.test.ts +86 -0
- package/src/verify/cli.ts +49 -0
- package/src/verify/fake-engine.ts +182 -0
- package/src/verify/index.ts +37 -0
- package/src/verify/plan-scope.ts +34 -0
- package/src/verify/recheck.test.ts +56 -0
- package/src/verify/recheck.ts +71 -0
- package/src/verify/report.ts +52 -0
- package/src/verify/rows.ts +210 -0
- package/src/verify/spy.test.ts +141 -0
- package/src/verify/spy.ts +160 -0
- package/src/verify/verify.test.ts +146 -0
- package/src/verify/verify.ts +185 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { VerifyOptions, VerifyTarget } from './verify.ts';
|
|
2
|
+
export declare const USAGE = "Usage: hf-adopt-verify --stage <stage> [--config alchemy.run.ts] [options]\n\nPlans the stack with Alchemy's own planner, never writes, and reports each row\nwithout a state row: what the engine planned, the provider's read and its own\ndiff (before Alchemy forces adopted rows to update), and the declared fields\nthat differ from the live object. Exits 0 when every row is a no-op, 1 when\nany is not, 2 when it could not tell.\n\n -c, --config <file> stack entrypoint (default alchemy.run.ts)\n --stage <stage> stage to verify (default $ALCHEMY_STAGE; required)\n --profile <name> Alchemy auth profile\n --env-file <file> .env file layered under the environment\n --all report every declared row and pending deletion\n --json print the report as JSON\n -h, --help this text\n";
|
|
3
|
+
export type Parsed = {
|
|
4
|
+
readonly kind: 'help';
|
|
5
|
+
} | {
|
|
6
|
+
readonly kind: 'error';
|
|
7
|
+
readonly message: string;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'run';
|
|
10
|
+
readonly target: VerifyTarget;
|
|
11
|
+
readonly options: VerifyOptions;
|
|
12
|
+
readonly json: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** Parse argv (without the runtime and script) against the environment. Never throws. */
|
|
15
|
+
export declare const parseVerifyArgs: (argv: readonly string[], env: Readonly<Record<string, string | undefined>>) => Parsed;
|
|
16
|
+
//# sourceMappingURL=args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/verify/args.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE/D,eAAO,MAAM,KAAK,i1BAejB,CAAC;AAEF,MAAM,MAAM,MAAM,GACd;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACpD;IACE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB,CAAC;AAkBN,yFAAyF;AACzF,eAAO,MAAM,eAAe,SACpB,SAAS,MAAM,EAAE,OAClB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,KAChD,MAoBF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/verify/cli.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/verify/cli.ts
|
|
4
|
+
import { runMain } from "alchemy/Util/PlatformServices";
|
|
5
|
+
import * as Cause from "effect/Cause";
|
|
6
|
+
import * as Console from "effect/Console";
|
|
7
|
+
import * as Effect5 from "effect/Effect";
|
|
8
|
+
|
|
9
|
+
// src/verify/args.ts
|
|
10
|
+
import { parseArgs } from "node:util";
|
|
11
|
+
var USAGE = `Usage: hf-adopt-verify --stage <stage> [--config alchemy.run.ts] [options]
|
|
12
|
+
|
|
13
|
+
Plans the stack with Alchemy's own planner, never writes, and reports each row
|
|
14
|
+
without a state row: what the engine planned, the provider's read and its own
|
|
15
|
+
diff (before Alchemy forces adopted rows to update), and the declared fields
|
|
16
|
+
that differ from the live object. Exits 0 when every row is a no-op, 1 when
|
|
17
|
+
any is not, 2 when it could not tell.
|
|
18
|
+
|
|
19
|
+
-c, --config <file> stack entrypoint (default alchemy.run.ts)
|
|
20
|
+
--stage <stage> stage to verify (default $ALCHEMY_STAGE; required)
|
|
21
|
+
--profile <name> Alchemy auth profile
|
|
22
|
+
--env-file <file> .env file layered under the environment
|
|
23
|
+
--all report every declared row and pending deletion
|
|
24
|
+
--json print the report as JSON
|
|
25
|
+
-h, --help this text
|
|
26
|
+
`;
|
|
27
|
+
var parse = (argv) => parseArgs({
|
|
28
|
+
args: [...argv],
|
|
29
|
+
allowPositionals: false,
|
|
30
|
+
options: {
|
|
31
|
+
all: { type: "boolean", default: false },
|
|
32
|
+
config: { type: "string", short: "c", default: "alchemy.run.ts" },
|
|
33
|
+
"env-file": { type: "string" },
|
|
34
|
+
help: { type: "boolean", short: "h", default: false },
|
|
35
|
+
json: { type: "boolean", default: false },
|
|
36
|
+
profile: { type: "string" },
|
|
37
|
+
stage: { type: "string" }
|
|
38
|
+
},
|
|
39
|
+
strict: true
|
|
40
|
+
});
|
|
41
|
+
var parseVerifyArgs = (argv, env) => {
|
|
42
|
+
let parsed;
|
|
43
|
+
try {
|
|
44
|
+
parsed = parse(argv);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
return { kind: "error", message: error instanceof Error ? error.message : String(error) };
|
|
47
|
+
}
|
|
48
|
+
const { values } = parsed;
|
|
49
|
+
if (values.help)
|
|
50
|
+
return { kind: "help" };
|
|
51
|
+
const stage = values.stage ?? env["ALCHEMY_STAGE"];
|
|
52
|
+
if (stage === undefined || stage === "") {
|
|
53
|
+
return { kind: "error", message: "pass --stage (or set ALCHEMY_STAGE): no stage is guessed" };
|
|
54
|
+
}
|
|
55
|
+
const target = {
|
|
56
|
+
entrypoint: values.config,
|
|
57
|
+
stage,
|
|
58
|
+
...values.profile === undefined ? {} : { profile: values.profile },
|
|
59
|
+
...values["env-file"] === undefined ? {} : { envFile: values["env-file"] }
|
|
60
|
+
};
|
|
61
|
+
return { json: values.json, kind: "run", options: { all: values.all }, target };
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/verify/report.ts
|
|
65
|
+
var exitCodeOf = (report) => report.rows.every((row) => row.ok) ? 0 : 1;
|
|
66
|
+
var pad = (text, width) => text.padEnd(width);
|
|
67
|
+
var line = (row, widths) => {
|
|
68
|
+
const head = [
|
|
69
|
+
row.ok ? "ok " : "FAIL",
|
|
70
|
+
pad(row.planned, widths.planned),
|
|
71
|
+
pad(row.diff, 8),
|
|
72
|
+
pad(row.read, 9),
|
|
73
|
+
pad(row.type, widths.type),
|
|
74
|
+
row.fqn
|
|
75
|
+
].join(" ");
|
|
76
|
+
const changed = row.changed.length > 0 ? ` changed: ${row.changed.join(", ")}` : "";
|
|
77
|
+
return row.why === "" ? `${head}${changed}` : `${head}${changed}
|
|
78
|
+
${row.why}`;
|
|
79
|
+
};
|
|
80
|
+
var formatReport = (report, all) => {
|
|
81
|
+
const scope = all ? "every row" : "rows without state";
|
|
82
|
+
const title = `hf-adopt-verify ${report.stack}/${report.stage}: ${String(report.rows.length)} ${scope} (of ${String(report.declared)} declared)`;
|
|
83
|
+
if (report.rows.length === 0) {
|
|
84
|
+
return `${title}
|
|
85
|
+
nothing to verify — every declared row already has state. --all checks those too.
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
const widths = {
|
|
89
|
+
planned: Math.max(7, ...report.rows.map((row) => row.planned.length)),
|
|
90
|
+
type: Math.max(4, ...report.rows.map((row) => row.type.length))
|
|
91
|
+
};
|
|
92
|
+
const header = [" ", pad("planned", widths.planned), pad("diff", 8), pad("read", 9)].concat([pad("type", widths.type), "fqn"]).join(" ");
|
|
93
|
+
const failed = report.rows.filter((row) => !row.ok).length;
|
|
94
|
+
const verdict = failed === 0 ? "every row is a no-op: the deploy writes nothing to them" : `${String(failed)} row(s) are NOT a no-op: the deploy would write, create or delete`;
|
|
95
|
+
return [title, "", header, ...report.rows.map((row) => line(row, widths)), "", verdict, ""].join(`
|
|
96
|
+
`);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// src/verify/verify.ts
|
|
100
|
+
import * as Alchemist from "alchemy/Alchemist";
|
|
101
|
+
import * as Plan from "alchemy/Plan";
|
|
102
|
+
import { State, isActionState } from "alchemy/State";
|
|
103
|
+
import * as Effect4 from "effect/Effect";
|
|
104
|
+
|
|
105
|
+
// src/verify/plan-scope.ts
|
|
106
|
+
import {
|
|
107
|
+
ArtifactStore,
|
|
108
|
+
Artifacts,
|
|
109
|
+
createArtifactStore,
|
|
110
|
+
makeScopedArtifacts
|
|
111
|
+
} from "alchemy/Artifacts";
|
|
112
|
+
import { InstanceId } from "alchemy/InstanceId";
|
|
113
|
+
import * as Effect from "effect/Effect";
|
|
114
|
+
import * as Option from "effect/Option";
|
|
115
|
+
var inPlanScope = (fqn, instanceId) => (effect) => Effect.gen(function* () {
|
|
116
|
+
const store = Option.getOrElse(yield* Effect.serviceOption(ArtifactStore), createArtifactStore);
|
|
117
|
+
return yield* effect.pipe(Effect.provideService(Artifacts, makeScopedArtifacts(store, fqn)), Effect.provideService(InstanceId, instanceId));
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// src/verify/recheck.ts
|
|
121
|
+
import * as Effect3 from "effect/Effect";
|
|
122
|
+
|
|
123
|
+
// src/verify/rows.ts
|
|
124
|
+
import { deepEqual, isResolved } from "alchemy/Diff";
|
|
125
|
+
var changedFields = (declared, live) => {
|
|
126
|
+
if (typeof declared !== "object" || declared === null)
|
|
127
|
+
return [];
|
|
128
|
+
if (typeof live !== "object" || live === null)
|
|
129
|
+
return [];
|
|
130
|
+
const actual = live;
|
|
131
|
+
return Object.entries(declared).filter(([key, value]) => value !== undefined && (key in actual) && isResolved(value)).filter(([key, value]) => !deepEqual(value, actual[key])).map(([key]) => key).sort();
|
|
132
|
+
};
|
|
133
|
+
var STILL_LIVE = new Set(["adopted", "noop"]);
|
|
134
|
+
var isNoop = (planned, diff, stateRow) => STILL_LIVE.has(planned) && (diff === "noop" || diff === "none" && stateRow && planned === "noop");
|
|
135
|
+
var proven = (recheck) => recheck === undefined || recheck === "noop";
|
|
136
|
+
var notes = (row) => [
|
|
137
|
+
row.read === "unowned" ? "unowned: the deploy needs --adopt or adopt(true)" : "",
|
|
138
|
+
row.recheck === "noop" ? `${row.changed.join(", ")} differ, but the diff says noop even given the live values: ` + "the family does not manage them, and the deploy leaves them alone" : ""
|
|
139
|
+
].filter((note) => note !== "").join("; ");
|
|
140
|
+
var reason = (row, ok) => {
|
|
141
|
+
if (ok)
|
|
142
|
+
return notes(row);
|
|
143
|
+
if (isNoop(row.planned, row.diff, row.stateRow)) {
|
|
144
|
+
const live = `the live ${row.changed.join(", ")}`;
|
|
145
|
+
if (row.recheck === "failed") {
|
|
146
|
+
return `asked again with ${live} as recorded props, the provider's diff failed: not proven`;
|
|
147
|
+
}
|
|
148
|
+
if (!proven(row.recheck)) {
|
|
149
|
+
return `the provider's diff compares recorded props, not the live object: given ${live} it ` + `says ${String(row.recheck)}, and the deploy's forced reconcile writes`;
|
|
150
|
+
}
|
|
151
|
+
return `${String(row.bindings)} binding(s) change: the deploy reconciles them though the diff is noop`;
|
|
152
|
+
}
|
|
153
|
+
if (row.planned === "delete")
|
|
154
|
+
return "no longer declared: the deploy deletes it";
|
|
155
|
+
if (row.planned === "orphaned")
|
|
156
|
+
return "no longer declared: the deploy drops its state (retain)";
|
|
157
|
+
if (row.read === "failed")
|
|
158
|
+
return "the verifier's own read of it failed";
|
|
159
|
+
if (row.planned === "create") {
|
|
160
|
+
if (row.stateRow)
|
|
161
|
+
return "an interrupted create: the deploy finishes creating it";
|
|
162
|
+
return row.read === "absent" ? "the read found nothing, so the deploy CREATES it (a lane that cannot see it reads the same)" : "never probed (a prop is an Output of another resource, or the provider has no read): " + "the deploy CREATES it";
|
|
163
|
+
}
|
|
164
|
+
if (row.diff === "update")
|
|
165
|
+
return "the provider's diff says update: the deploy writes";
|
|
166
|
+
if (row.diff === "replace")
|
|
167
|
+
return "the provider's diff says replace: a new one, then a delete";
|
|
168
|
+
if (row.diff === "none") {
|
|
169
|
+
return "the provider has no diff, so the engine compared the declaration with itself";
|
|
170
|
+
}
|
|
171
|
+
return `the engine plans ${row.planned} although the diff says ${row.diff} (a renamed row, changed bindings or --force)`;
|
|
172
|
+
};
|
|
173
|
+
var rowFor = (fqn, node, stateRow, seen) => {
|
|
174
|
+
const observed = seen.get(fqn);
|
|
175
|
+
const recheck = observed?.recheck;
|
|
176
|
+
const base = {
|
|
177
|
+
bindings: (node.bindings ?? []).filter((binding) => binding.action !== "noop").length,
|
|
178
|
+
changed: changedFields(observed?.diff?.news, observed?.read?.attributes),
|
|
179
|
+
diff: observed?.diff?.answer ?? "not-run",
|
|
180
|
+
fqn,
|
|
181
|
+
planned: node.action,
|
|
182
|
+
read: observed?.read?.answer ?? "not-read",
|
|
183
|
+
...recheck === undefined ? {} : { recheck },
|
|
184
|
+
stateRow,
|
|
185
|
+
type: node.resource.Type
|
|
186
|
+
};
|
|
187
|
+
const ok = isNoop(base.planned, base.diff, stateRow) && proven(recheck) && base.bindings === 0;
|
|
188
|
+
return { ...base, ok, why: reason(base, ok) };
|
|
189
|
+
};
|
|
190
|
+
var taskRow = (fqn, task) => ({
|
|
191
|
+
bindings: 0,
|
|
192
|
+
changed: [],
|
|
193
|
+
diff: "not-run",
|
|
194
|
+
fqn,
|
|
195
|
+
ok: task.action === "noop",
|
|
196
|
+
planned: task.action,
|
|
197
|
+
read: "not-read",
|
|
198
|
+
stateRow: task.action !== "run",
|
|
199
|
+
type: task.def.Type,
|
|
200
|
+
why: task.action === "noop" ? "" : `a stack task: the deploy will ${task.action} it`
|
|
201
|
+
});
|
|
202
|
+
var rowsOf = (plan, stateRows, seen, all) => {
|
|
203
|
+
const declared = Object.entries(plan.resources).filter(([fqn]) => all || !stateRows.has(fqn)).map(([fqn, node]) => rowFor(fqn, node, stateRows.has(fqn), seen));
|
|
204
|
+
const removed = all ? Object.entries(plan.deletions).flatMap(([fqn, node]) => node === undefined ? [] : [rowFor(fqn, node, true, seen)]) : [];
|
|
205
|
+
const tasks = Object.entries(plan.actions ?? {}).flatMap(([fqn, task]) => task === undefined || !all && task.action === "noop" ? [] : [taskRow(fqn, task)]);
|
|
206
|
+
return [...declared, ...removed, ...tasks].sort((a, b) => a.fqn.localeCompare(b.fqn));
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// src/verify/spy.ts
|
|
210
|
+
import { Unowned, stripUnowned } from "alchemy/AdoptPolicy";
|
|
211
|
+
import {
|
|
212
|
+
isProviderCollectionService,
|
|
213
|
+
isProviderService
|
|
214
|
+
} from "alchemy/Provider";
|
|
215
|
+
import * as Context from "effect/Context";
|
|
216
|
+
import * as Effect2 from "effect/Effect";
|
|
217
|
+
var seenFor = (seen, fqn) => {
|
|
218
|
+
const existing = seen.get(fqn);
|
|
219
|
+
if (existing !== undefined)
|
|
220
|
+
return existing;
|
|
221
|
+
const fresh = {};
|
|
222
|
+
seen.set(fqn, fresh);
|
|
223
|
+
return fresh;
|
|
224
|
+
};
|
|
225
|
+
var WRITE_REFUSED = "hf-adopt-verify never writes";
|
|
226
|
+
var refuse = (type, operation) => () => Effect2.die(new Error(`${WRITE_REFUSED}: ${type}.${operation} was called during a verification. Alchemy's planner ` + "does not call it, so something other than Plan.make is driving these providers."));
|
|
227
|
+
var readAnswer = (attributes) => attributes === undefined ? "absent" : Unowned.is(attributes) ? "unowned" : "found";
|
|
228
|
+
var diffAnswer = (diff) => {
|
|
229
|
+
const action = diff?.action;
|
|
230
|
+
return action === "noop" || action === "update" || action === "replace" ? action : "none";
|
|
231
|
+
};
|
|
232
|
+
var spyService = (type, service, seen) => {
|
|
233
|
+
const read = service.read;
|
|
234
|
+
const diff = service.diff;
|
|
235
|
+
const modes = service.modes;
|
|
236
|
+
const watched = {
|
|
237
|
+
...service,
|
|
238
|
+
diff: (input) => (diff === undefined ? Effect2.succeed(undefined) : diff(input)).pipe(Effect2.tap((answer) => Effect2.sync(() => {
|
|
239
|
+
seenFor(seen, input.fqn).diff = { answer: diffAnswer(answer), input, news: input.news };
|
|
240
|
+
}))),
|
|
241
|
+
reconcile: refuse(type, "reconcile"),
|
|
242
|
+
delete: refuse(type, "delete")
|
|
243
|
+
};
|
|
244
|
+
if (read !== undefined) {
|
|
245
|
+
watched.read = (input) => read(input).pipe(Effect2.tap((answer) => Effect2.sync(() => {
|
|
246
|
+
const attributes = answer === undefined ? undefined : stripUnowned(answer);
|
|
247
|
+
seenFor(seen, input.fqn).read = { answer: readAnswer(answer), attributes };
|
|
248
|
+
})));
|
|
249
|
+
}
|
|
250
|
+
if (service.precreate !== undefined)
|
|
251
|
+
watched.precreate = refuse(type, "precreate");
|
|
252
|
+
if (modes !== undefined) {
|
|
253
|
+
watched.modes = {
|
|
254
|
+
live: Effect2.map(modes.live, (variant) => spyService(type, variant, seen)),
|
|
255
|
+
local: Effect2.map(modes.local, (variant) => spyService(type, variant, seen))
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
return watched;
|
|
259
|
+
};
|
|
260
|
+
var spyCollection = (collection, seen) => {
|
|
261
|
+
const providers = Object.fromEntries(Object.entries(collection.providers).map(([type, service]) => [
|
|
262
|
+
type,
|
|
263
|
+
spyService(type, service, seen)
|
|
264
|
+
]));
|
|
265
|
+
return { ...collection, get: (type) => providers[type], providers };
|
|
266
|
+
};
|
|
267
|
+
var spyContext = (context, seen) => {
|
|
268
|
+
const services = new Map;
|
|
269
|
+
for (const [key, value] of context.mapUnsafe) {
|
|
270
|
+
services.set(key, isProviderService(value) ? spyService(key, value, seen) : isProviderCollectionService(value) ? spyCollection(value, seen) : value);
|
|
271
|
+
}
|
|
272
|
+
return Context.makeUnsafe(services);
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// src/verify/recheck.ts
|
|
276
|
+
var recheck = (fqn, node, seen) => Effect3.gen(function* () {
|
|
277
|
+
const observed = seen.get(fqn);
|
|
278
|
+
const first = observed?.diff;
|
|
279
|
+
const input = first?.input;
|
|
280
|
+
const diff = node.provider?.diff;
|
|
281
|
+
if (node.action !== "adopted" || first?.answer !== "noop" || input === undefined)
|
|
282
|
+
return;
|
|
283
|
+
const live = observed?.read?.attributes;
|
|
284
|
+
const changed = changedFields(input.news, live);
|
|
285
|
+
if (live === undefined || changed.length === 0)
|
|
286
|
+
return;
|
|
287
|
+
if (diff === undefined || node.state === undefined)
|
|
288
|
+
return;
|
|
289
|
+
const olds = {
|
|
290
|
+
...input.olds,
|
|
291
|
+
...Object.fromEntries(changed.map((key) => [key, live[key]]))
|
|
292
|
+
};
|
|
293
|
+
const asked = diff({ ...input, olds });
|
|
294
|
+
const answer = yield* asked.pipe(inPlanScope(fqn, node.state.instanceId), Effect3.map(diffAnswer), Effect3.catchCause(() => Effect3.succeed("failed")));
|
|
295
|
+
if (observed !== undefined) {
|
|
296
|
+
observed.diff = first;
|
|
297
|
+
observed.recheck = answer;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
// src/verify/verify.ts
|
|
302
|
+
var readWithState = (fqn, node) => Effect4.gen(function* () {
|
|
303
|
+
const read = node.provider?.read;
|
|
304
|
+
if (read === undefined || node.state === undefined)
|
|
305
|
+
return;
|
|
306
|
+
yield* read({
|
|
307
|
+
fqn,
|
|
308
|
+
id: node.resource.LogicalId,
|
|
309
|
+
instanceId: node.state.instanceId,
|
|
310
|
+
olds: node.state.props,
|
|
311
|
+
output: node.state.attr
|
|
312
|
+
}).pipe(inPlanScope(fqn, node.state.instanceId));
|
|
313
|
+
});
|
|
314
|
+
var withState = (stack, nodes) => Effect4.gen(function* () {
|
|
315
|
+
const store = yield* yield* State;
|
|
316
|
+
const found = yield* Effect4.all(Object.entries(nodes).map(([fqn, node]) => store.get({ fqn, stack: stack.name, stage: stack.stage }).pipe(Effect4.map((row) => row === undefined || isActionState(row) || row.instanceId !== node.state?.instanceId ? [] : [fqn]))), { concurrency: 8 });
|
|
317
|
+
return new Set(found.flat());
|
|
318
|
+
});
|
|
319
|
+
var verifySession = (session, options = {}) => {
|
|
320
|
+
const seen = new Map;
|
|
321
|
+
const all2 = options.all === true;
|
|
322
|
+
const plan = Plan.make(session.stack);
|
|
323
|
+
return Effect4.gen(function* () {
|
|
324
|
+
const planned = yield* plan;
|
|
325
|
+
const stateRows = yield* withState(session.stack, planned.resources);
|
|
326
|
+
yield* Effect4.all(Object.entries(planned.resources).map(([fqn, node]) => recheck(fqn, node, seen)), { concurrency: 8 });
|
|
327
|
+
if (all2) {
|
|
328
|
+
const stateful = Object.entries(planned.resources).filter(([fqn]) => stateRows.has(fqn));
|
|
329
|
+
yield* Effect4.all(stateful.map(([fqn, node]) => readWithState(fqn, node).pipe(Effect4.catchCause(() => Effect4.sync(() => {
|
|
330
|
+
const entry = seen.get(fqn) ?? {};
|
|
331
|
+
entry.read = { answer: "failed", attributes: undefined };
|
|
332
|
+
seen.set(fqn, entry);
|
|
333
|
+
})))), { concurrency: 8 });
|
|
334
|
+
}
|
|
335
|
+
return {
|
|
336
|
+
declared: Object.keys(planned.resources).length,
|
|
337
|
+
rows: rowsOf(planned, stateRows, seen, all2),
|
|
338
|
+
stack: session.stack.name,
|
|
339
|
+
stage: session.stack.stage
|
|
340
|
+
};
|
|
341
|
+
}).pipe(Effect4.provide(spyContext(session.context, seen)), Effect4.scoped);
|
|
342
|
+
};
|
|
343
|
+
var verifyStack = (target, options = {}) => Effect4.gen(function* () {
|
|
344
|
+
const session = yield* Alchemist.open(target, { adopt: true });
|
|
345
|
+
return yield* verifySession(session, options);
|
|
346
|
+
}).pipe(Effect4.scoped, Effect4.provide(Alchemist.layer()));
|
|
347
|
+
|
|
348
|
+
// src/verify/cli.ts
|
|
349
|
+
var setExit = (code) => Effect5.sync(() => {
|
|
350
|
+
process.exitCode = code;
|
|
351
|
+
});
|
|
352
|
+
var program = Effect5.gen(function* () {
|
|
353
|
+
const parsed = parseVerifyArgs(process.argv.slice(2), process.env);
|
|
354
|
+
if (parsed.kind === "help")
|
|
355
|
+
return yield* Console.log(USAGE);
|
|
356
|
+
if (parsed.kind === "error") {
|
|
357
|
+
yield* Console.error(`hf-adopt-verify: ${parsed.message}
|
|
358
|
+
|
|
359
|
+
${USAGE}`);
|
|
360
|
+
return yield* setExit(2);
|
|
361
|
+
}
|
|
362
|
+
const report = yield* verifyStack(parsed.target, parsed.options);
|
|
363
|
+
yield* Console.log(parsed.json ? JSON.stringify(report, null, 2) : formatReport(report, parsed.options.all === true));
|
|
364
|
+
yield* setExit(exitCodeOf(report));
|
|
365
|
+
}).pipe(Effect5.catchCause((cause) => Console.error(`hf-adopt-verify: the plan could not be verified
|
|
366
|
+
${Cause.pretty(cause)}`).pipe(Effect5.andThen(setExit(2)))));
|
|
367
|
+
runMain(program);
|
|
368
|
+
|
|
369
|
+
//# debugId=66D8EFB2DE677D6964756E2164756E21
|
|
370
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/verify/cli.ts", "../src/verify/args.ts", "../src/verify/report.ts", "../src/verify/verify.ts", "../src/verify/plan-scope.ts", "../src/verify/recheck.ts", "../src/verify/rows.ts", "../src/verify/spy.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"#!/usr/bin/env node\n/**\n * `hf-adopt-verify` — the bin. Parse, verify, print, exit 0 / 1 / 2.\n *\n * ★ `runMain` IS ALCHEMY'S (alchemy/Util/PlatformServices), so this runs under bun or node the way\n * `alchemy` itself does, and exits once the report is out rather than lingering on keep-alive\n * sockets. Run it where the stack's `alchemy` runs: `bunx --bun hf-adopt-verify …` next to\n * `bun ./node_modules/alchemy/bin/cli.js plan …`, because the entrypoint it imports is\n * TypeScript.\n * ⛔ EXIT 2 IS \"COULD NOT TELL\", NEVER A PASS. A plan that fails — a provider that dies, an\n * `adopt(false)` row that is not ours, a state store it cannot read — prints the cause and exits\n * 2, so a gate reading `!= 0` stops either way.\n */\nimport { runMain } from 'alchemy/Util/PlatformServices';\nimport * as Cause from 'effect/Cause';\nimport * as Console from 'effect/Console';\nimport * as Effect from 'effect/Effect';\nimport { USAGE, parseVerifyArgs } from './args.ts';\nimport { exitCodeOf, formatReport } from './report.ts';\nimport { verifyStack } from './verify.ts';\n\nconst setExit = (code: number) =>\n Effect.sync(() => {\n process.exitCode = code;\n });\n\nconst program = Effect.gen(function* () {\n const parsed = parseVerifyArgs(process.argv.slice(2), process.env);\n if (parsed.kind === 'help') return yield* Console.log(USAGE);\n if (parsed.kind === 'error') {\n yield* Console.error(`hf-adopt-verify: ${parsed.message}\\n\\n${USAGE}`);\n return yield* setExit(2);\n }\n const report = yield* verifyStack(parsed.target, parsed.options);\n yield* Console.log(\n parsed.json\n ? JSON.stringify(report, null, 2)\n : formatReport(report, parsed.options.all === true),\n );\n yield* setExit(exitCodeOf(report));\n}).pipe(\n Effect.catchCause((cause) =>\n Console.error(`hf-adopt-verify: the plan could not be verified\\n${Cause.pretty(cause)}`).pipe(\n Effect.andThen(setExit(2)),\n ),\n ),\n);\n\nrunMain(program);\n",
|
|
6
|
+
"/**\n * `hf-adopt-verify`'s flags — the ones `alchemy plan` takes, so a stack script can swap one\n * command for the other.\n *\n * ★ `node:util` parseArgs, NOT effect's CLI module. Alchemy builds its CLI on\n * `effect/unstable/cli`, but that needs a CliConfig and a Terminal layer to parse six flags; the\n * standard library parses them with no service at all, which keeps this pure and testable.\n * ⛔ `--stage` HAS NO GUESSED DEFAULT. Alchemy falls back to `live_$USER`; a gate that silently\n * verified the wrong stage would pass for the wrong reason. It comes from the flag or from\n * `$ALCHEMY_STAGE`, or the run stops.\n */\nimport { parseArgs } from 'node:util';\nimport type { VerifyOptions, VerifyTarget } from './verify.ts';\n\nexport const USAGE = `Usage: hf-adopt-verify --stage <stage> [--config alchemy.run.ts] [options]\n\nPlans the stack with Alchemy's own planner, never writes, and reports each row\nwithout a state row: what the engine planned, the provider's read and its own\ndiff (before Alchemy forces adopted rows to update), and the declared fields\nthat differ from the live object. Exits 0 when every row is a no-op, 1 when\nany is not, 2 when it could not tell.\n\n -c, --config <file> stack entrypoint (default alchemy.run.ts)\n --stage <stage> stage to verify (default $ALCHEMY_STAGE; required)\n --profile <name> Alchemy auth profile\n --env-file <file> .env file layered under the environment\n --all report every declared row and pending deletion\n --json print the report as JSON\n -h, --help this text\n`;\n\nexport type Parsed =\n | { readonly kind: 'help' }\n | { readonly kind: 'error'; readonly message: string }\n | {\n readonly kind: 'run';\n readonly target: VerifyTarget;\n readonly options: VerifyOptions;\n readonly json: boolean;\n };\n\nconst parse = (argv: readonly string[]) =>\n parseArgs({\n args: [...argv],\n allowPositionals: false,\n options: {\n all: { type: 'boolean', default: false },\n config: { type: 'string', short: 'c', default: 'alchemy.run.ts' },\n 'env-file': { type: 'string' },\n help: { type: 'boolean', short: 'h', default: false },\n json: { type: 'boolean', default: false },\n profile: { type: 'string' },\n stage: { type: 'string' },\n },\n strict: true,\n });\n\n/** Parse argv (without the runtime and script) against the environment. Never throws. */\nexport const parseVerifyArgs = (\n argv: readonly string[],\n env: Readonly<Record<string, string | undefined>>,\n): Parsed => {\n let parsed: ReturnType<typeof parse>;\n try {\n parsed = parse(argv);\n } catch (error) {\n return { kind: 'error', message: error instanceof Error ? error.message : String(error) };\n }\n const { values } = parsed;\n if (values.help) return { kind: 'help' };\n const stage = values.stage ?? env['ALCHEMY_STAGE'];\n if (stage === undefined || stage === '') {\n return { kind: 'error', message: 'pass --stage (or set ALCHEMY_STAGE): no stage is guessed' };\n }\n const target: VerifyTarget = {\n entrypoint: values.config,\n stage,\n ...(values.profile === undefined ? {} : { profile: values.profile }),\n ...(values['env-file'] === undefined ? {} : { envFile: values['env-file'] }),\n };\n return { json: values.json, kind: 'run', options: { all: values.all }, target };\n};\n",
|
|
7
|
+
"/**\n * The verifier's answer, for a terminal and for a gate.\n *\n * ⛔ NAMES, NEVER VALUES. A row lists which declared fields differ from the live object, not what\n * either side holds: the tool runs over any stack, and a prop or an attribute can be a secret.\n * `alchemy plan --detailed` shows declared values; the family's own read shows live ones.\n */\nimport type { AdoptRow } from './rows.ts';\nimport type { AdoptReport } from './verify.ts';\n\n/** 0 when every reported row is a no-op, 1 when any is not. (2 is the CLI's: it could not tell.) */\nexport const exitCodeOf = (report: AdoptReport): 0 | 1 =>\n report.rows.every((row) => row.ok) ? 0 : 1;\n\nconst pad = (text: string, width: number) => text.padEnd(width);\n\nconst line = (row: AdoptRow, widths: { planned: number; type: number }) => {\n const head = [\n row.ok ? 'ok ' : 'FAIL',\n pad(row.planned, widths.planned),\n pad(row.diff, 8),\n pad(row.read, 9),\n pad(row.type, widths.type),\n row.fqn,\n ].join(' ');\n const changed = row.changed.length > 0 ? ` changed: ${row.changed.join(', ')}` : '';\n return row.why === '' ? `${head}${changed}` : `${head}${changed}\\n ${row.why}`;\n};\n\n/** Plain text, one row per line, with the reason under any row that is not a no-op. */\nexport const formatReport = (report: AdoptReport, all: boolean): string => {\n const scope = all ? 'every row' : 'rows without state';\n const title = `hf-adopt-verify ${report.stack}/${report.stage}: ${String(report.rows.length)} ${scope} (of ${String(report.declared)} declared)`;\n if (report.rows.length === 0) {\n return `${title}\\nnothing to verify — every declared row already has state. --all checks those too.\\n`;\n }\n const widths = {\n planned: Math.max(7, ...report.rows.map((row) => row.planned.length)),\n type: Math.max(4, ...report.rows.map((row) => row.type.length)),\n };\n const header = [' ', pad('planned', widths.planned), pad('diff', 8), pad('read', 9)]\n .concat([pad('type', widths.type), 'fqn'])\n .join(' ');\n const failed = report.rows.filter((row) => !row.ok).length;\n const verdict =\n failed === 0\n ? 'every row is a no-op: the deploy writes nothing to them'\n : `${String(failed)} row(s) are NOT a no-op: the deploy would write, create or delete`;\n return [title, '', header, ...report.rows.map((row) => line(row, widths)), '', verdict, ''].join(\n '\\n',\n );\n};\n",
|
|
8
|
+
"/**\n * Prove a deploy's adoptions are no-ops — with Alchemy's own planner, before anything is written.\n *\n * ★ THE ENGINE PLANS, THIS ONLY WATCHES. `verifySession` runs `Plan.make` — the same call\n * `alchemy plan` makes (Alchemist routes/stack.ts) — over the session's context with every\n * provider swapped for a watched copy (spy.ts). Output resolution, the state lookup, rename\n * migrations, the adoption probe and `adopt(…)` all stay the engine's; nothing here re-derives\n * them. What it adds is the provider's own `diff` answer, which Plan.ts overwrites for every\n * adopted row (`forceUpdateAfterAdoption`), and the state-row check that says which rows ARE\n * adoptions.\n *\n * ⛔ READ-ONLY BY CONSTRUCTION. The planner calls `read` and `diff`; spy.ts replaces `reconcile`,\n * `delete` and `precreate` with refusals; nothing here calls `apply`. `--all` adds one `read` per\n * row with state, and recheck.ts one more `diff` for an adopted `noop` whose read differs from\n * the declaration — both still reads by Alchemy's provider contract.\n * ⚠️ READS ARE NOT FREE FOR EVERY FAMILY. A kit PVE/PBS read mints a lease through OpenBao, which\n * creates a short-lived API token on the cluster, exactly as `alchemy plan` does.\n */\nimport * as Alchemist from 'alchemy/Alchemist';\nimport * as Plan from 'alchemy/Plan';\nimport type { ProviderService } from 'alchemy/Provider';\nimport type { CompiledStack } from 'alchemy/Stack';\nimport { State, isActionState } from 'alchemy/State';\nimport type * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport { inPlanScope } from './plan-scope.ts';\nimport { recheck } from './recheck.ts';\nimport { type AdoptRow, type PlanView, rowsOf } from './rows.ts';\nimport { type Observations, spyContext } from './spy.ts';\n\nexport interface VerifyOptions {\n /** Report every declared row and every pending deletion, not only rows without state. */\n readonly all?: boolean;\n}\n\nexport interface AdoptReport {\n readonly stack: string;\n readonly stage: string;\n /** Resources the stack declares. */\n readonly declared: number;\n readonly rows: readonly AdoptRow[];\n}\n\n/** An imported stack and the context it plans under — what `Alchemist.open` returns. */\nexport interface VerifySession {\n readonly stack: CompiledStack<unknown, unknown>;\n readonly context: Context.Context<unknown>;\n}\n\n/** The plan-node fields `--all` needs to read a row that has state, and the recheck to replay a diff. */\ntype StatefulNode = {\n readonly action: string;\n readonly provider?: ProviderService;\n readonly resource: { readonly LogicalId: string };\n readonly state?: {\n readonly instanceId: string;\n readonly props: object;\n readonly attr: object | undefined;\n };\n};\n\n/** ⚠️ In the scope Plan.ts gives its own reads (plan-scope.ts). */\nconst readWithState = (fqn: string, node: StatefulNode) =>\n Effect.gen(function* () {\n const read = node.provider?.read;\n if (read === undefined || node.state === undefined) return;\n yield* read({\n fqn,\n id: node.resource.LogicalId,\n instanceId: node.state.instanceId,\n olds: node.state.props,\n output: node.state.attr,\n }).pipe(inPlanScope(fqn, node.state.instanceId));\n });\n\n/**\n * Which planned rows plan FROM a resource row the stage's state store holds for them.\n *\n * ⚠️ THE ROW MUST BE THE ONE THE NODE PLANS FROM, NOT MERELY A ROW AT THE SAME FQN. Alchemy lets a\n * rename hand its old id to a new resource in the same deploy (Rename.ts: `Bucket(\"Assets\")\n * .pipe(renamedFrom(\"Bucket\"))` beside a fresh `Bucket(\"Bucket\")`). The store still holds the\n * renamer's row at `Bucket`, so a check by FQN alone called the reuser stateful and the default\n * report hid its `create`. Matching the node's `state.instanceId` also sees the renamer, whose\n * row still sits at its FORMER FQN, as a row without state.\n */\nconst withState = (\n stack: CompiledStack<unknown, unknown>,\n nodes: Readonly<Record<string, StatefulNode>>,\n) =>\n Effect.gen(function* () {\n const store = yield* yield* State;\n const found = yield* Effect.all(\n Object.entries(nodes).map(([fqn, node]) =>\n store\n .get({ fqn, stack: stack.name, stage: stack.stage })\n .pipe(\n Effect.map((row) =>\n row === undefined ||\n isActionState(row) ||\n (row as { readonly instanceId?: unknown }).instanceId !== node.state?.instanceId\n ? []\n : [fqn],\n ),\n ),\n ),\n { concurrency: 8 },\n );\n return new Set(found.flat());\n });\n\n/**\n * Plan `session.stack` with watched providers and report each row without state (or, with\n * `all`, every row). Never writes.\n */\nexport const verifySession = (\n session: VerifySession,\n options: VerifyOptions = {},\n): Effect.Effect<AdoptReport, unknown> => {\n const seen: Observations = new Map();\n const all = options.all === true;\n // ⚠️ THE CAST IS AT THE ENGINE'S TYPED BOUNDARY. `Plan.make` declares only `State` and hides the\n // rest behind a ts-expect-error; the session context carries all of it, as in routes/stack.ts.\n const plan = Plan.make(session.stack) as unknown as Effect.Effect<\n PlanView & { readonly resources: Readonly<Record<string, StatefulNode>> },\n unknown\n >;\n return Effect.gen(function* () {\n const planned = yield* plan;\n const stateRows = yield* withState(session.stack, planned.resources);\n // ★ Before the rows are judged: an adopted `noop` beside a differing read is asked again.\n yield* Effect.all(\n Object.entries(planned.resources).map(([fqn, node]) => recheck(fqn, node, seen)),\n { concurrency: 8 },\n );\n if (all) {\n const stateful = Object.entries(planned.resources).filter(([fqn]) => stateRows.has(fqn));\n yield* Effect.all(\n stateful.map(([fqn, node]) =>\n readWithState(fqn, node).pipe(\n Effect.catchCause(() =>\n Effect.sync(() => {\n const entry = seen.get(fqn) ?? {};\n entry.read = { answer: 'failed', attributes: undefined };\n seen.set(fqn, entry);\n }),\n ),\n ),\n ),\n { concurrency: 8 },\n );\n }\n return {\n declared: Object.keys(planned.resources).length,\n rows: rowsOf(planned, stateRows, seen, all),\n stack: session.stack.name,\n stage: session.stack.stage,\n } satisfies AdoptReport;\n }).pipe(Effect.provide(spyContext(session.context, seen)), Effect.scoped);\n};\n\n/** Where the stack lives — the fields `alchemy plan` takes as flags. */\nexport interface VerifyTarget {\n /** The stack entrypoint, e.g. `alchemy.run.ts`. */\n readonly entrypoint: string;\n readonly stage: string;\n readonly profile?: string;\n readonly envFile?: string;\n}\n\n/**\n * Import the stack the way the Alchemy CLI does and verify it.\n *\n * ★ `adopt: true`, ALWAYS, AND IT CANNOT WRITE. Planning is side-effect free (Plan.ts keeps the\n * adopted state in memory, alchemy#793), so the flag only lets an `Unowned` row reach its\n * `diff` instead of failing the plan — the report marks it, because the real deploy then needs\n * `--adopt`. A resource declared `.pipe(adopt(false))` still fails the plan, as it would deploy.\n */\nexport const verifyStack = (\n target: VerifyTarget,\n options: VerifyOptions = {},\n): Effect.Effect<AdoptReport, unknown> =>\n Effect.gen(function* () {\n const session = yield* Alchemist.open(target, { adopt: true });\n return yield* verifySession(session, options);\n }).pipe(Effect.scoped, Effect.provide(Alchemist.layer()));\n",
|
|
9
|
+
"/**\n * The scope Plan.ts gives every provider call it makes, for the calls the verifier makes itself\n * after the plan: `--all`'s reads (verify.ts) and the recheck's diffs (recheck.ts).\n *\n * ⚠️ RE-CREATED, BECAUSE Plan.ts DOES NOT EXPORT IT (`providePlanScope`, alchemy beta.79): a scoped\n * `Artifacts` bag over the run's `ArtifactStore` (a fresh one when none is provided) and the row's\n * `InstanceId`. A kit family that consults either — the ownership helpers do — sees what it\n * would see under `alchemy plan`. Moved here from verify.ts once a second caller needed it.\n */\nimport {\n ArtifactStore,\n Artifacts,\n createArtifactStore,\n makeScopedArtifacts,\n} from 'alchemy/Artifacts';\nimport { InstanceId } from 'alchemy/InstanceId';\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\n\nexport const inPlanScope =\n (fqn: string, instanceId: string) =>\n <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n ): Effect.Effect<A, E, Exclude<R, Artifacts | InstanceId>> =>\n Effect.gen(function* () {\n const store = Option.getOrElse(\n yield* Effect.serviceOption(ArtifactStore),\n createArtifactStore,\n );\n return yield* effect.pipe(\n Effect.provideService(Artifacts, makeScopedArtifacts(store, fqn)),\n Effect.provideService(InstanceId, instanceId),\n );\n }) as Effect.Effect<A, E, Exclude<R, Artifacts | InstanceId>>;\n",
|
|
10
|
+
"/**\n * Ask an adopted row's `diff` a second time, with the live values as its recorded props, when its\n * first `noop` sits beside a read that differs from the declaration.\n *\n * 🔴 WHY (red-teamed 2026-09-21). Plan.ts hands an adopted row's diff `olds: news`, because the\n * adopted state carries `props: news`. A diff that compares the RECORDED props with the\n * declaration therefore answers `noop` whatever the cloud holds, and the forced reconcile then\n * writes. Alchemy's own `Cloudflare.R2Bucket` diff is that shape (beta.79\n * Cloudflare/R2/Bucket.ts, `olds.domains` against `news.domains`). The verifier said `ok`,\n * exited 0, and listed the drift under `changed` on the same line. rows.ts already refused to\n * trust a MISSING diff for this reason; a diff that never looks at the live object is the same\n * blind spot one level down.\n *\n * ★ THE QUESTION IS \"WOULD YOU STILL SAY noop IF STATE HAD RECORDED WHAT THE READ FOUND?\" It is the\n * planner's own input, replayed with one change: `olds` carries the read's value for each field\n * in `changed`. A diff that reads the live object ignores `olds` and answers as before. Every kit\n * PVE/PBS family re-reads (`pveOperations.diff`), so a field its `matches` leaves out, such as\n * CephPool's autoscaled `pg_num`, still passes. A diff that compares `olds` now sees the drift.\n *\n * ⛔ ONLY `diff`, a read by Alchemy's contract, and through the WATCHED provider, so every write\n * path still answers with spy.ts's refusal. The first answer is put back afterwards: the report's\n * `diff` column stays what the planner heard.\n * ⚠️ IT CAN ONLY TURN A PASS INTO A FAIL. It runs on a row that would otherwise pass (adopted,\n * `noop`, something in `changed`), and anything but a second `noop`, a failure included, fails it.\n * ⚠️ SAME-NAMED FIELDS ONLY, like `changed`: a drift in a field whose attribute has another name is\n * invisible to both. Whether a `reconcile` PUTs identical values anyway is still up to the\n * provider (docs/adopt-verify.md, Limits).\n */\nimport type { ProviderService } from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { inPlanScope } from './plan-scope.ts';\nimport { changedFields } from './rows.ts';\nimport { type Observations, type RecheckAnswer, diffAnswer } from './spy.ts';\n\n/** The plan-node fields a recheck needs. */\nexport interface RecheckNode {\n readonly action: string;\n readonly provider?: ProviderService;\n readonly state?: { readonly instanceId: string };\n}\n\n/** Recheck one planned row if it needs it; the answer lands in `seen` as `recheck`. */\nexport const recheck = (fqn: string, node: RecheckNode, seen: Observations): Effect.Effect<void> =>\n Effect.gen(function* () {\n const observed = seen.get(fqn);\n const first = observed?.diff;\n const input = first?.input;\n const diff = node.provider?.diff;\n if (node.action !== 'adopted' || first?.answer !== 'noop' || input === undefined) return;\n const live = observed?.read?.attributes as Record<string, unknown> | undefined;\n const changed = changedFields(input.news, live);\n if (live === undefined || changed.length === 0) return;\n if (diff === undefined || node.state === undefined) return;\n const olds = {\n ...(input.olds as object),\n ...Object.fromEntries(changed.map((key) => [key, live[key]])),\n };\n // ⚠️ THE CAST IS THE ENGINE'S BOUNDARY, as in verify.ts: the diff's requirements are the\n // session's, which verifySession provides around this call.\n const asked = diff({ ...input, olds } as typeof input) as Effect.Effect<unknown>;\n const answer: RecheckAnswer = yield* asked.pipe(\n inPlanScope(fqn, node.state.instanceId),\n Effect.map(diffAnswer),\n Effect.catchCause(() => Effect.succeed('failed' as const)),\n );\n // The watched diff recorded the replay over the planner's answer; put the planner's back.\n if (observed !== undefined) {\n observed.diff = first;\n observed.recheck = answer;\n }\n });\n",
|
|
11
|
+
"/**\n * One report row per planned resource: what the engine planned, what the provider said, and\n * whether that adds up to \"this deploy leaves the object alone\".\n *\n * ★ PURE, SO THE VERDICT IS TESTABLE WITHOUT AN ENGINE. verify.ts gathers the three inputs — the\n * plan, which FQNs have a state row, and what the watched providers answered (spy.ts) — and\n * this file only decides.\n */\nimport { deepEqual, isResolved } from 'alchemy/Diff';\nimport type { DiffAnswer, Observations, ReadAnswer, RecheckAnswer } from './spy.ts';\n\nexport interface AdoptRow {\n readonly fqn: string;\n readonly type: string;\n /**\n * Whether the row plans from a row the state store holds for it (verify.ts `withState`). An\n * adoption is a row without one.\n */\n readonly stateRow: boolean;\n /** The engine's action — what `alchemy plan` prints (`adopted`, `create`, `noop`, …). */\n readonly planned: string;\n /** What the provider's `read` answered, or `not-read` when nothing asked it. */\n readonly read: ReadAnswer;\n /** What the provider's own `diff` answered BEFORE Plan.ts forced it (spy.ts). */\n readonly diff: DiffAnswer;\n /**\n * Declared fields whose live value differs, by NAME only — values can be secrets. Compared on\n * same-named keys of the declaration and the read's attributes, so a family whose attributes\n * rename a field cannot show it here. The diff answer is the verdict; a name here beside an\n * adopted `noop` only makes recheck.ts ask that diff again.\n */\n readonly changed: readonly string[];\n /**\n * What the provider's `diff` answered when asked again with the live values of `changed` as its\n * recorded props (recheck.ts). Absent when it was not asked: only an adopted `noop` with\n * something in `changed` is.\n */\n readonly recheck?: RecheckAnswer;\n /** Bindings the engine will create, update or delete — reconcile applies them even on `noop`. */\n readonly bindings: number;\n readonly ok: boolean;\n /** Why the row is not a no-op, or a note on one that is; empty when there is nothing to say. */\n readonly why: string;\n}\n\n/** The slice of an Alchemy plan node this file reads. */\nexport interface NodeView {\n readonly action: string;\n readonly resource: { readonly Type: string };\n readonly bindings?: readonly { readonly action: string }[];\n}\n\n/** A stack task (an Alchemy action): `run`, `noop` or `delete`. It has no provider to ask. */\nexport interface TaskView {\n readonly action: string;\n readonly def: { readonly Type: string };\n}\n\n/** The slice of an Alchemy `Plan` this file reads. */\nexport interface PlanView {\n readonly resources: Readonly<Record<string, NodeView>>;\n readonly deletions: Readonly<Record<string, NodeView | undefined>>;\n readonly actions?: Readonly<Record<string, TaskView | undefined>>;\n}\n\n/** Same-named, declared, resolved fields where the live value differs. */\nexport const changedFields = (declared: unknown, live: unknown): string[] => {\n if (typeof declared !== 'object' || declared === null) return [];\n if (typeof live !== 'object' || live === null) return [];\n const actual = live as Record<string, unknown>;\n return Object.entries(declared as Record<string, unknown>)\n .filter(([key, value]) => value !== undefined && key in actual && isResolved(value))\n .filter(([key, value]) => !deepEqual(value, actual[key]))\n .map(([key]) => key)\n .sort();\n};\n\nconst STILL_LIVE = new Set(['adopted', 'noop']);\n\n/**\n * ⛔ `adopted` NEEDS THE PROVIDER'S OWN `noop`. With no diff (`none`) the engine compared the\n * declaration with the declaration — an adopted row's state carries `props: news` (Plan.ts) — so\n * its noop proves nothing. A row with state is different: there the engine compared against the\n * props it last deployed, which is the same check `alchemy plan` makes.\n */\nconst isNoop = (planned: string, diff: DiffAnswer, stateRow: boolean) =>\n STILL_LIVE.has(planned) &&\n (diff === 'noop' || (diff === 'none' && stateRow && planned === 'noop'));\n\n/**\n * ⛔ AND A `noop` MUST SURVIVE BEING ASKED WITH THE LIVE VALUES. A diff that compares recorded props\n * answers an adopted row `noop` whatever the cloud holds; recheck.ts asks it again, and only a\n * second `noop` (or no need to ask) proves anything.\n */\nconst proven = (recheck: RecheckAnswer | undefined) => recheck === undefined || recheck === 'noop';\n\n/** Notes on a row that passes: nothing to say is the common case. */\nconst notes = (row: Omit<AdoptRow, 'ok' | 'why'>): string =>\n [\n row.read === 'unowned' ? 'unowned: the deploy needs --adopt or adopt(true)' : '',\n row.recheck === 'noop'\n ? `${row.changed.join(', ')} differ, but the diff says noop even given the live values: ` +\n 'the family does not manage them, and the deploy leaves them alone'\n : '',\n ]\n .filter((note) => note !== '')\n .join('; ');\n\nconst reason = (row: Omit<AdoptRow, 'ok' | 'why'>, ok: boolean): string => {\n if (ok) return notes(row);\n if (isNoop(row.planned, row.diff, row.stateRow)) {\n const live = `the live ${row.changed.join(', ')}`;\n if (row.recheck === 'failed') {\n return `asked again with ${live} as recorded props, the provider's diff failed: not proven`;\n }\n if (!proven(row.recheck)) {\n return (\n `the provider's diff compares recorded props, not the live object: given ${live} it ` +\n `says ${String(row.recheck)}, and the deploy's forced reconcile writes`\n );\n }\n return `${String(row.bindings)} binding(s) change: the deploy reconciles them though the diff is noop`;\n }\n if (row.planned === 'delete') return 'no longer declared: the deploy deletes it';\n if (row.planned === 'orphaned') return 'no longer declared: the deploy drops its state (retain)';\n if (row.read === 'failed') return \"the verifier's own read of it failed\";\n if (row.planned === 'create') {\n if (row.stateRow) return 'an interrupted create: the deploy finishes creating it';\n return row.read === 'absent'\n ? 'the read found nothing, so the deploy CREATES it (a lane that cannot see it reads the same)'\n : 'never probed (a prop is an Output of another resource, or the provider has no read): ' +\n 'the deploy CREATES it';\n }\n if (row.diff === 'update') return \"the provider's diff says update: the deploy writes\";\n if (row.diff === 'replace') return \"the provider's diff says replace: a new one, then a delete\";\n if (row.diff === 'none') {\n return 'the provider has no diff, so the engine compared the declaration with itself';\n }\n return `the engine plans ${row.planned} although the diff says ${row.diff} (a renamed row, changed bindings or --force)`;\n};\n\nexport const rowFor = (\n fqn: string,\n node: NodeView,\n stateRow: boolean,\n seen: Observations,\n): AdoptRow => {\n const observed = seen.get(fqn);\n const recheck = observed?.recheck;\n const base = {\n bindings: (node.bindings ?? []).filter((binding) => binding.action !== 'noop').length,\n changed: changedFields(observed?.diff?.news, observed?.read?.attributes),\n diff: observed?.diff?.answer ?? 'not-run',\n fqn,\n planned: node.action,\n read: observed?.read?.answer ?? 'not-read',\n ...(recheck === undefined ? {} : { recheck }),\n stateRow,\n type: node.resource.Type,\n } satisfies Omit<AdoptRow, 'ok' | 'why'>;\n /**\n * ⚠️ A NOOP DIFF DOES NOT COVER BINDINGS. Plan.ts diffs them separately and hands every\n * non-noop binding to `reconcile`, which an adopted row reaches anyway — a Worker adopted with\n * a new binding writes although its own diff said nothing changed.\n */\n const ok = isNoop(base.planned, base.diff, stateRow) && proven(recheck) && base.bindings === 0;\n return { ...base, ok, why: reason(base, ok) };\n};\n\n/**\n * ⚠️ A TASK THAT RUNS IS A WRITE THE PROVIDERS NEVER SEE, so it is reported in both modes; a task\n * that would not run appears only with `all`.\n */\nconst taskRow = (fqn: string, task: TaskView): AdoptRow => ({\n bindings: 0,\n changed: [],\n diff: 'not-run',\n fqn,\n ok: task.action === 'noop',\n planned: task.action,\n read: 'not-read',\n stateRow: task.action !== 'run',\n type: task.def.Type,\n why: task.action === 'noop' ? '' : `a stack task: the deploy will ${task.action} it`,\n});\n\n/**\n * The rows to report. Without `all`, only rows WITHOUT a state row — the adoptions and creates a\n * deploy would perform — which is the question this tool exists for, plus any task that runs. With\n * `all`, every declared row, every pending deletion and every task.\n */\nexport const rowsOf = (\n plan: PlanView,\n stateRows: ReadonlySet<string>,\n seen: Observations,\n all: boolean,\n): AdoptRow[] => {\n const declared = Object.entries(plan.resources)\n .filter(([fqn]) => all || !stateRows.has(fqn))\n .map(([fqn, node]) => rowFor(fqn, node, stateRows.has(fqn), seen));\n const removed = all\n ? Object.entries(plan.deletions).flatMap(([fqn, node]) =>\n node === undefined ? [] : [rowFor(fqn, node, true, seen)],\n )\n : [];\n const tasks = Object.entries(plan.actions ?? {}).flatMap(([fqn, task]) =>\n task === undefined || (!all && task.action === 'noop') ? [] : [taskRow(fqn, task)],\n );\n return [...declared, ...removed, ...tasks].sort((a, b) => a.fqn.localeCompare(b.fqn));\n};\n",
|
|
12
|
+
"/**\n * The providers a stack registered, wrapped so the plan can be watched and can never write.\n *\n * ★ WHY A WRAPPER AND NOT A LOG LINE. alchemy beta.79 Plan.ts loses the provider's answer on the one\n * path that matters: after the cold-start adoption probe it sets `forceUpdateAfterAdoption` and\n * maps a `noop` diff to `update`, and the node says `adopted` either way. Nothing is logged, and\n * `alchemy plan` has no JSON output — `describePlan` carries only the forced action. The engine\n * resolves every provider from the Effect context by resource type (Provider.ts\n * `tryFindProviderRegistrationByType`), so the one honest place to hear the raw answer is the\n * provider service itself. This hands Alchemy's own `Plan.make` a context whose providers record\n * what `read` and `diff` answered, per FQN, and otherwise behave exactly as registered.\n *\n * ⛔ EVERY WRITE PATH DIES. `reconcile`, `delete` and `precreate` are replaced, not wrapped: the\n * planner never calls them, and a verifier that could reach one by accident is worse than none.\n * `read`, `diff`, `list`, `tail` and `logs` pass through — each is a read by Alchemy's contract.\n *\n * ⚠️ A MISSING `diff` IS WRAPPED AS ONE ANSWERING `undefined`, which is exactly what the planner\n * does without one (`provider?.diff?.(…)` then its own props compare), so behaviour is unchanged\n * and the report can say `none` instead of guessing. A missing `read` stays missing: adding one\n * would make the planner probe where it otherwise would not.\n */\nimport { Unowned, stripUnowned } from 'alchemy/AdoptPolicy';\nimport {\n type ProviderCollectionService,\n type ProviderService,\n isProviderCollectionService,\n isProviderService,\n} from 'alchemy/Provider';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\n\nexport type ReadAnswer = 'found' | 'unowned' | 'absent' | 'failed' | 'not-read';\nexport type DiffAnswer = 'noop' | 'update' | 'replace' | 'none' | 'not-run';\n/** What the diff answered when asked again with the live values as its recorded props (recheck.ts). */\nexport type RecheckAnswer = DiffAnswer | 'failed';\n\n/** Exactly what the planner handed a provider's `diff`. */\nexport type DiffInput = Parameters<NonNullable<ProviderService['diff']>>[0];\n\n/** What one FQN's provider answered during the plan — the LAST answer of each kind. */\nexport interface Seen {\n read?: { readonly answer: ReadAnswer; readonly attributes: unknown };\n /**\n * ★ `input` IS THE WHOLE CALL, NOT ONLY `news`, so recheck.ts can ask the same question again\n * with one field changed. In memory only; the report carries field names, never values. An\n * observation built by hand without it (rows.ts's tests) is simply never rechecked.\n */\n diff?: { readonly answer: DiffAnswer; readonly news: unknown; readonly input?: DiffInput };\n recheck?: RecheckAnswer;\n}\n\n/** Keyed by FQN. Filled while the plan runs; read once it is done. */\nexport type Observations = Map<string, Seen>;\n\nconst seenFor = (seen: Observations, fqn: string): Seen => {\n const existing = seen.get(fqn);\n if (existing !== undefined) return existing;\n const fresh: Seen = {};\n seen.set(fqn, fresh);\n return fresh;\n};\n\n/** The refusal every write path answers with. Exported so a test can match it. */\nexport const WRITE_REFUSED = 'hf-adopt-verify never writes';\n\nconst refuse = (type: string, operation: string) => () =>\n Effect.die(\n new Error(\n `${WRITE_REFUSED}: ${type}.${operation} was called during a verification. Alchemy's planner ` +\n 'does not call it, so something other than Plan.make is driving these providers.',\n ),\n );\n\nconst readAnswer = (attributes: unknown): ReadAnswer =>\n attributes === undefined ? 'absent' : Unowned.is(attributes) ? 'unowned' : 'found';\n\nexport const diffAnswer = (diff: unknown): DiffAnswer => {\n const action = (diff as { action?: unknown } | undefined)?.action;\n return action === 'noop' || action === 'update' || action === 'replace' ? action : 'none';\n};\n\n/**\n * One provider service, watched. ⚠️ The spread keeps `version`, `aliases`, `mode`, `stables`,\n * `list` and the rest exactly as registered — the planner reads several of them.\n */\nexport const spyService = (type: string, service: ProviderService, seen: Observations) => {\n const read = service.read;\n const diff = service.diff;\n const modes = service.modes;\n const watched: ProviderService = {\n ...service,\n diff: (input) =>\n (diff === undefined ? Effect.succeed(undefined) : diff(input)).pipe(\n Effect.tap((answer) =>\n Effect.sync(() => {\n seenFor(seen, input.fqn).diff = { answer: diffAnswer(answer), input, news: input.news };\n }),\n ),\n ),\n reconcile: refuse(type, 'reconcile'),\n delete: refuse(type, 'delete'),\n };\n if (read !== undefined) {\n watched.read = (input) =>\n read(input).pipe(\n Effect.tap((answer) =>\n Effect.sync(() => {\n const attributes = answer === undefined ? undefined : stripUnowned(answer);\n seenFor(seen, input.fqn).read = { answer: readAnswer(answer), attributes };\n }),\n ),\n );\n }\n if (service.precreate !== undefined) watched.precreate = refuse(type, 'precreate');\n // ⚠️ A `ProviderLayer.dual` registration resolves a per-mode variant at plan time\n // (Provider.ts `providerForMode`); wrapping only the registration would miss it.\n if (modes !== undefined) {\n watched.modes = {\n live: Effect.map(modes.live, (variant) => spyService(type, variant, seen)),\n local: Effect.map(modes.local, (variant) => spyService(type, variant, seen)),\n };\n }\n return watched;\n};\n\nconst spyCollection = (\n collection: ProviderCollectionService,\n seen: Observations,\n): ProviderCollectionService => {\n const providers = Object.fromEntries(\n Object.entries(collection.providers).map(([type, service]) => [\n type,\n spyService(type, service, seen),\n ]),\n );\n return { ...collection, get: (type: string) => providers[type] as never, providers };\n};\n\n/**\n * The same context with every provider service — direct or inside a `Provider.collection` —\n * replaced by its watched copy. Everything else (the state store, the stack, credentials) is the\n * very object the session built.\n */\nexport const spyContext = <R>(\n context: Context.Context<R>,\n seen: Observations,\n): Context.Context<R> => {\n const services = new Map<string, unknown>();\n for (const [key, value] of context.mapUnsafe) {\n services.set(\n key,\n isProviderService(value)\n ? spyService(key, value, seen)\n : isProviderCollectionService(value)\n ? spyCollection(value, seen)\n : value,\n );\n }\n return Context.makeUnsafe<R>(services);\n};\n"
|
|
13
|
+
],
|
|
14
|
+
"mappings": ";;;AAaA;AACA;AACA;AACA;;;ACLA;AAGO,IAAM,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BrB,IAAM,QAAQ,CAAC,SACb,UAAU;AAAA,EACR,MAAM,CAAC,GAAG,IAAI;AAAA,EACd,kBAAkB;AAAA,EAClB,SAAS;AAAA,IACP,KAAK,EAAE,MAAM,WAAW,SAAS,MAAM;AAAA,IACvC,QAAQ,EAAE,MAAM,UAAU,OAAO,KAAK,SAA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rE,OAAO,OAAO,QAAQ,CAAC;AAAA,EACzB;AAAA,EACA,MAAM,SAAS,OAAO,YAAY,OAAO,QAAQ,OAAO,OAAO;AAAA,EAC/D,OAAe,YACb,OAAO,OACH,KAAK,UAAU,QAAQ,MAAM,CAAC,IAC9B,aAAa,QAAQ,OAAO,QAAQ,QAAQ,IAAI,CACtD;AAAA,EACA,OAAO,QAAQ,WAAW,MAAM,CAAC;AAAA,CAClC,EAAE,KACM,mBAAW,CAAC,UACT,cAAM;AAAA,EAA0D,aAAO,KAAK,GAAG,EAAE,KAChF,gBAAQ,QAAQ,CAAC,CAAC,CAC3B,CACF,CACF;AAEA,QAAQ,OAAO;",
|
|
15
|
+
"debugId": "66D8EFB2DE677D6964756E2164756E21",
|
|
16
|
+
"names": []
|
|
17
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A test-only stack: Alchemy's real Plan and Apply over an in-memory state store, and a fake family
|
|
3
|
+
* whose "cloud" is a Map — so the verifier runs against the engine's own plans with no network.
|
|
4
|
+
*
|
|
5
|
+
* ★ THE ENGINE, NOT A HAND-BUILT PLAN. What the verifier claims is about alchemy beta.79: that an
|
|
6
|
+
* adopted row's `diff` answer is lost to `forceUpdateAfterAdoption`, that Apply then reconciles
|
|
7
|
+
* it, and that a watched plan never writes. openbao/fake-stack.ts measured the same engine for
|
|
8
|
+
* the Bao families; this one is family-neutral and records every provider call in order.
|
|
9
|
+
* ⛔ TEST-ONLY. No provider imports this file.
|
|
10
|
+
*/
|
|
11
|
+
import * as Alchemy from 'alchemy';
|
|
12
|
+
import * as Effect from 'effect/Effect';
|
|
13
|
+
import * as Layer from 'effect/Layer';
|
|
14
|
+
import { type AdoptReport, type VerifyOptions } from './verify.ts';
|
|
15
|
+
export interface ThingProps {
|
|
16
|
+
name: string;
|
|
17
|
+
comment?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ThingAttributes {
|
|
20
|
+
name: string;
|
|
21
|
+
comment: string;
|
|
22
|
+
}
|
|
23
|
+
export interface Thing extends Alchemy.Resource<'Test.Thing', ThingProps, ThingAttributes> {
|
|
24
|
+
}
|
|
25
|
+
export declare const Thing: Alchemy.ResourceClass<Thing>;
|
|
26
|
+
/** The same object with no `diff`, like a provider that never wrote one. */
|
|
27
|
+
export interface Blind extends Alchemy.Resource<'Test.Blind', ThingProps, ThingAttributes> {
|
|
28
|
+
}
|
|
29
|
+
export declare const Blind: Alchemy.ResourceClass<Blind>;
|
|
30
|
+
/**
|
|
31
|
+
* The same object with a `diff` that compares the RECORDED props with the declaration and never
|
|
32
|
+
* the live object — the shape of Alchemy's own `Cloudflare.R2Bucket` diff (beta.79
|
|
33
|
+
* Cloudflare/R2/Bucket.ts: `olds.domains` against `news.domains`). recheck.ts exists for it.
|
|
34
|
+
*/
|
|
35
|
+
export interface Recorded extends Alchemy.Resource<'Test.Recorded', ThingProps, ThingAttributes> {
|
|
36
|
+
}
|
|
37
|
+
export declare const Recorded: Alchemy.ResourceClass<Recorded>;
|
|
38
|
+
/** The fake cloud: what exists, what is someone else's, and every call made to it, in order. */
|
|
39
|
+
export interface Cloud {
|
|
40
|
+
readonly live: Map<string, string>;
|
|
41
|
+
readonly unowned: Set<string>;
|
|
42
|
+
readonly calls: string[];
|
|
43
|
+
}
|
|
44
|
+
export declare const cloudOf: (live?: Record<string, string>) => Cloud;
|
|
45
|
+
/** Every call that would change the cloud. */
|
|
46
|
+
export declare const writesOf: (cloud: Cloud) => string[];
|
|
47
|
+
/** Both fake families over `cloud` — also what tests/fixtures/verify-stack.ts registers. */
|
|
48
|
+
export declare const thingProviders: (cloud: Cloud) => Layer.Layer<Alchemy.Provider<Blind> | Alchemy.Provider<Recorded> | Alchemy.Provider<Thing>, never, never>;
|
|
49
|
+
/** A stack body: resource declarations, as an `alchemy.run.ts` would write them. */
|
|
50
|
+
export type Body = Effect.Effect<unknown, unknown, unknown>;
|
|
51
|
+
export interface FakeEngine {
|
|
52
|
+
/** Plan and apply `body`, as `alchemy deploy --adopt` would; resolves to the planned actions. */
|
|
53
|
+
readonly deploy: (body: Body) => Promise<Record<string, string>>;
|
|
54
|
+
/** Verify `body` against what the earlier deploys recorded. */
|
|
55
|
+
readonly verify: (body: Body, options?: VerifyOptions) => Promise<AdoptReport>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* One stack over one state store and any providers, shared by every call — a family's own test
|
|
59
|
+
* hands in its real provider over a fake transport (proxmox/ceph-pool-adopt.test.ts).
|
|
60
|
+
* ⚠️ THE CASTS ARE AT THE ENGINE'S TYPED BOUNDARY — openbao/fake-stack.ts has the reasoning.
|
|
61
|
+
*/
|
|
62
|
+
export declare const engineOver: <ROut, E, RIn>(layer: Layer.Layer<ROut, E, RIn>) => FakeEngine;
|
|
63
|
+
/** The fake family over `cloud`. */
|
|
64
|
+
export declare const fakeEngine: (cloud: Cloud) => FakeEngine;
|
|
65
|
+
//# sourceMappingURL=fake-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-engine.d.ts","sourceRoot":"","sources":["../../src/verify/fake-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAKnC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAiB,MAAM,aAAa,CAAC;AAElF,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AACD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,KAAM,SAAQ,OAAO,CAAC,QAAQ,CAAC,YAAY,EAAE,UAAU,EAAE,eAAe,CAAC;CAAG;AAC7F,eAAO,MAAM,KAAK,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AAM,UAAU,GAAI,IAAI,EAAE,CAAC,EAAE,GAAG,SAAS,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,KAAG,UAuC3E,CAAC;AAEF,oCAAoC;AACpC,eAAO,MAAM,UAAU,UAAW,KAAK,KAAG,UAA+C,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@homeflare/alchemy/verify` — prove a deploy's adoptions are no-ops before it runs.
|
|
3
|
+
*
|
|
4
|
+
* ★ ONE TOOL FOR EVERY STACK, NOT A TEST PER REPO. A stack runs `hf-adopt-verify --config
|
|
5
|
+
* alchemy.run.ts --stage live` before a gated deploy, or calls `verifyStack` from its own
|
|
6
|
+
* script; both plan with Alchemy's planner and never write. docs/adopt-verify.md has the why,
|
|
7
|
+
* the report's columns, and what each kit family does on an adopted deploy.
|
|
8
|
+
* ⛔ A SUBPATH OF ITS OWN: it imports the stack module from disk and reads the state store, which
|
|
9
|
+
* is host access, so it never rides along with the runtime-neutral root entry.
|
|
10
|
+
*/
|
|
11
|
+
export { type Parsed, USAGE, parseVerifyArgs } from './args.ts';
|
|
12
|
+
export { exitCodeOf, formatReport } from './report.ts';
|
|
13
|
+
export { type AdoptRow, type NodeView, type PlanView, type TaskView, changedFields, rowsOf, } from './rows.ts';
|
|
14
|
+
export { type DiffAnswer, type Observations, type ReadAnswer, type RecheckAnswer, type Seen, WRITE_REFUSED, spyContext, } from './spy.ts';
|
|
15
|
+
export { type AdoptReport, type VerifyOptions, type VerifySession, type VerifyTarget, verifySession, verifyStack, } from './verify.ts';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/verify/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,aAAa,EACb,MAAM,GACP,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,IAAI,EACT,aAAa,EACb,UAAU,GACX,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAC"}
|