@homeflare/alchemy 0.32.0 → 0.34.0

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.
Files changed (83) hide show
  1. package/dist/grafana/alerting-provenance.d.ts +80 -0
  2. package/dist/grafana/alerting-provenance.d.ts.map +1 -0
  3. package/dist/grafana/contact-point-fixtures.d.ts +28 -0
  4. package/dist/grafana/contact-point-fixtures.d.ts.map +1 -0
  5. package/dist/grafana/contact-point.d.ts +99 -0
  6. package/dist/grafana/contact-point.d.ts.map +1 -0
  7. package/dist/grafana/dashboard-model.d.ts +47 -0
  8. package/dist/grafana/dashboard-model.d.ts.map +1 -0
  9. package/dist/grafana/dashboard.d.ts +98 -0
  10. package/dist/grafana/dashboard.d.ts.map +1 -0
  11. package/dist/grafana/datasource.d.ts +2 -9
  12. package/dist/grafana/datasource.d.ts.map +1 -1
  13. package/dist/grafana/folder.d.ts +100 -0
  14. package/dist/grafana/folder.d.ts.map +1 -0
  15. package/dist/grafana/index.d.ts +16 -9
  16. package/dist/grafana/index.d.ts.map +1 -1
  17. package/dist/grafana/index.js +325 -16
  18. package/dist/grafana/index.js.map +15 -5
  19. package/dist/grafana/message-template.d.ts +70 -0
  20. package/dist/grafana/message-template.d.ts.map +1 -0
  21. package/dist/grafana/mute-timing.d.ts +112 -0
  22. package/dist/grafana/mute-timing.d.ts.map +1 -0
  23. package/dist/grafana/providers.d.ts +1 -1
  24. package/dist/grafana/providers.d.ts.map +1 -1
  25. package/dist/grafana/provisioned.d.ts +11 -0
  26. package/dist/grafana/provisioned.d.ts.map +1 -0
  27. package/dist/grafana/secret-refs.d.ts +19 -0
  28. package/dist/grafana/secret-refs.d.ts.map +1 -0
  29. package/dist/grafana/subset-match.d.ts +2 -0
  30. package/dist/grafana/subset-match.d.ts.map +1 -0
  31. package/dist/linux/index.d.ts +1 -1
  32. package/dist/linux/index.d.ts.map +1 -1
  33. package/dist/linux/index.js +3 -1
  34. package/dist/linux/index.js.map +1 -1
  35. package/dist/proxmox/index.js +76 -45
  36. package/dist/proxmox/index.js.map +6 -6
  37. package/dist/proxmox/zfs-pool-form.d.ts +124 -0
  38. package/dist/proxmox/zfs-pool-form.d.ts.map +1 -0
  39. package/dist/proxmox/zfs-pool-wire.d.ts +78 -0
  40. package/dist/proxmox/zfs-pool-wire.d.ts.map +1 -0
  41. package/dist/proxmox/zfs-pool.d.ts +27 -52
  42. package/dist/proxmox/zfs-pool.d.ts.map +1 -1
  43. package/docs/grafana-alerting.md +145 -0
  44. package/docs/grafana-folder-dashboard.md +145 -0
  45. package/docs/grafana.md +12 -10
  46. package/docs/upstream-conformance.md +31 -4
  47. package/package.json +1 -1
  48. package/src/grafana/alerting-provenance.ts +109 -0
  49. package/src/grafana/contact-point-fixtures.ts +25 -0
  50. package/src/grafana/contact-point-provenance.test.ts +113 -0
  51. package/src/grafana/contact-point-secrets.test.ts +117 -0
  52. package/src/grafana/contact-point.test.ts +123 -0
  53. package/src/grafana/contact-point.ts +179 -0
  54. package/src/grafana/dashboard-model.test.ts +111 -0
  55. package/src/grafana/dashboard-model.ts +62 -0
  56. package/src/grafana/dashboard.test.ts +232 -0
  57. package/src/grafana/dashboard.ts +161 -0
  58. package/src/grafana/datasource.ts +5 -27
  59. package/src/grafana/folder.test.ts +212 -0
  60. package/src/grafana/folder.ts +161 -0
  61. package/src/grafana/index.ts +42 -9
  62. package/src/grafana/message-template.test.ts +212 -0
  63. package/src/grafana/message-template.ts +114 -0
  64. package/src/grafana/mute-timing.test.ts +227 -0
  65. package/src/grafana/mute-timing.ts +160 -0
  66. package/src/grafana/providers.ts +13 -1
  67. package/src/grafana/provisioned.ts +49 -0
  68. package/src/grafana/secret-refs.ts +48 -0
  69. package/src/grafana/subset-match.ts +71 -0
  70. package/src/linux/index-export.test.ts +25 -0
  71. package/src/linux/index.ts +15 -1
  72. package/src/proxmox/constraints-host-forms.test.ts +1 -1
  73. package/src/proxmox/zfs-pool-adopt.test.ts +26 -0
  74. package/src/proxmox/zfs-pool-form.ts +236 -0
  75. package/src/proxmox/zfs-pool-read-failure.test.ts +118 -0
  76. package/src/proxmox/zfs-pool-wire.ts +132 -0
  77. package/src/proxmox/zfs-pool.ts +106 -76
  78. package/dist/proxmox/zfs-pool-spec.d.ts +0 -27
  79. package/dist/proxmox/zfs-pool-spec.d.ts.map +0 -1
  80. package/dist/proxmox/zfs-pool-write.d.ts +0 -128
  81. package/dist/proxmox/zfs-pool-write.d.ts.map +0 -1
  82. package/src/proxmox/zfs-pool-spec.ts +0 -76
  83. package/src/proxmox/zfs-pool-write.ts +0 -196
@@ -0,0 +1,124 @@
1
+ /**
2
+ * The create lane for `Proxmox.ZfsPool`: the form PVE wants, and the wait for the worker it forks.
3
+ * Split out of zfs-pool.ts (2026-09-24, the distilled migration) — same seam as before, now naming
4
+ * the write side the way storage.ts/storage-form.ts does.
5
+ *
6
+ * ⚠️ `createPool` TAKES THE READ AS A PARAMETER, GENERIC IN ITS ERROR AND REQUIREMENT CHANNELS,
7
+ * rather than importing the read module and coupling to its exact effect shape here. This file
8
+ * answers "how does a declaration become a pool on disks"; zfs-pool-wire.ts answers "what is a
9
+ * zpool, and when has it changed" — the caller (zfs-pool.ts) is what ties the two together, so
10
+ * this file cannot accidentally read the cluster differently from `diff`.
11
+ */
12
+ import * as Effect from 'effect/Effect';
13
+ import * as nodes from '@distilled.cloud/proxmox/nodes';
14
+ import type { ZfsPoolAttributes, ZfsPoolProps } from './zfs-pool.ts';
15
+ import type { NodesNodeDisksZfsPostParams } from './generated/pve.ts';
16
+ export declare const ZFS_POOL_CREATE = "pve:POST /nodes/{node}/disks/zfs";
17
+ /**
18
+ * PVE's layouts, generated (2026-09-23) from `NodesNodeDisksZfsPostParams['raidlevel']`
19
+ * (`generated/pve.ts`, manifest `pve-apidoc` pve-manager 9.2.11 sha256 9def8f13…) rather than
20
+ * hand-typed, per decision 9. ⚠️ Each has a minimum disk count PVE enforces, and `raid10` needs an
21
+ * even one. ⛔ THERE IS NO `stripe` IN THIS ENUM. n1's `speed` pool is one (decision 14 accepts it
22
+ * as-is): `ZfsPoolProps` (zfs-pool.ts) is why a stripe pool is declarable at all — as an
23
+ * ADOPT-ONLY declaration with no `raidlevel`, never as a full one.
24
+ */
25
+ export type ZfsRaidLevel = NonNullable<NodesNodeDisksZfsPostParams['raidlevel']>;
26
+ /** Generated the same way, from `NodesNodeDisksZfsPostParams['compression']`. */
27
+ export type ZfsCompression = NonNullable<NodesNodeDisksZfsPostParams['compression']>;
28
+ /**
29
+ * ★ CHECKED AGAINST THE VENDOR TABLE ONLY FOR A FULL DECLARATION — decision 9's adopt-only mode.
30
+ * `guardCreate` (distilled-guard.ts's `guardWrite`) runs on the FIRST plan of ANY declaration and
31
+ * checks the create form's REQUIRED fields whenever this resolves to the real endpoint key — and
32
+ * PVE marks both `devices` and `raidlevel` required (codegen/constraints's `pve-nodes-disks`
33
+ * row). An adopt-only declaration deliberately omits both, so checking it would refuse a MATCHING
34
+ * adoption at plan time, before `read` ever ran. Returning `undefined` (no key) makes the guard a
35
+ * no-op for an adopt-only declaration, while a FULL one (`devices` and `raidlevel` both present)
36
+ * is checked exactly as before — zfs-pool.ts's `diff` passes this as the `guardWrite` endpoint.
37
+ * ⚠️ THE RUNTIME BACKSTOP IS `createPool` BELOW, NOT THIS FUNCTION. Skipping the plan-time guard
38
+ * for an adopt-only declaration does not skip the check that the pool is actually there —
39
+ * `createPool` refuses before any POST when the read comes back absent and either field is
40
+ * undefined, which is what a genuinely absent adopt-only declaration hits at apply time.
41
+ */
42
+ export declare const zfsPoolCreateEndpoint: (props: ZfsPoolProps) => "pve:POST /nodes/{node}/disks/zfs" | undefined;
43
+ /**
44
+ * The wire form, PVE's own field names — what `guardWrite` (zfs-pool.ts) checks.
45
+ *
46
+ * ⚠️ `devices` IS JOINED IN DECLARED ORDER AND NOT PUT THROUGH `csv()` FROM values.ts. `csv` sorts,
47
+ * and PVE walks this list two at a time to pair `raid10` mirrors — MEASURED in the node's own
48
+ * `PVE::API2::Disks::ZFS` — so sorting it builds a different pool from the one declared. The list
49
+ * is never compared against anything, so it needs no normalisation, only faithful order.
50
+ * ⚠️ AN OMITTED OPTIONAL IS NOT SENT. PVE's own defaults (ashift 12, compression on) are then
51
+ * applied by the node. Sending a guessed default would be indistinguishable here — the values
52
+ * are unreadable afterwards either way — but it would put a number in the request that no
53
+ * declaration asked for, and this is the one call that writes to physical disks.
54
+ * ⚠️ `node` IS NOT IN THE FORM: it is the `nodes/{node}` path label, and a second copy could only
55
+ * disagree with it.
56
+ * ⚠️ EVERY KEY IS OMITTED WHEN ABSENT, `devices` AND `raidlevel` INCLUDED — not just the optional
57
+ * ones. An adopt-only declaration (both undefined, decision 9) must produce a form `createPool`'s
58
+ * own guard can inspect for their absence, and one this function itself does not throw building.
59
+ */
60
+ export declare const createForm: (props: ZfsPoolProps) => Record<string, string>;
61
+ /**
62
+ * Create the pool if it is absent, and otherwise leave it completely alone.
63
+ *
64
+ * ⛔ THE POST ONLY FORKS A WORKER. MEASURED in `/usr/share/perl5/PVE/API2/Disks/ZFS.pm` on node-b:
65
+ * the create handler ends in `$rpcenv->fork_worker('zfscreate', ...)` and its HTTP answer is a
66
+ * UPID returned the instant the worker is forked — before `zpool create` has run, let alone
67
+ * finished. A read-back taken immediately would report a successful create as the failure "the
68
+ * write returned no error but the object is still absent". THAT is why this function polls.
69
+ *
70
+ * ⚠️ THERE IS NO UPDATE BRANCH BECAUSE PVE HAS NO PUT HERE. An existing pool is returned exactly as
71
+ * read, unwritten: the only write this resource ever makes is the create of a pool that is not
72
+ * there. Do not add a "repair" write; there is no field it could set.
73
+ *
74
+ * ⛔ AND IF THE READ IS WRONG, THE POST IS STILL SAFE — measured, not hoped for. `readPool` folds a
75
+ * 403 or an unreachable node into "absent", so a too-narrow lease would send this down the create
76
+ * path over a live pool. PVE's handler calls `get_pool_data()` before it forks anything and dies
77
+ * with "pool '<name>' already exists on node '<node>'", and `assert_disk_unused` refuses every
78
+ * device that pool is holding. A create aimed at a pool that is really there fails loudly rather
79
+ * than wiping it.
80
+ *
81
+ * ⚠️ SHORT POLLS WITH A HARD CAP, NOT ONE LONG WAIT, NOT `@distilled.cloud/proxmox`'s `awaitTask`.
82
+ * `readPool` cannot tell "not yet" from "forbidden" — both fold to `undefined` — so the loop
83
+ * gives up with the UPID rather than retrying forever, and the UPID is the only thing that leads
84
+ * to the worker's real error. Distilled's own task-status poller exists (`Task.ts`) and would
85
+ * remove this ambiguity, but swapping to it changes this resource's OBSERVABLE behaviour (what a
86
+ * caller sees on a slow create) beyond a transport swap — left as a follow-up, not folded into a
87
+ * migration PR silently.
88
+ *
89
+ * ⛔ THE SAME AMBIGUITY MAKES A RE-RUN AFTER THE GIVE-UP DIE GENUINELY UNSAFE, NOT MERELY SLOW TO
90
+ * CONFIRM — FOUND BY ADVERSARIAL REVIEW, 2026-09-24, of THIS migration, though the shape is
91
+ * unchanged from before it (`git blame` shows the same settle-poll pre-dates this PR). "If the
92
+ * read is wrong, the POST is still safe" above is true for the FIRST call into this function —
93
+ * PVE's own `get_pool_data()` refuses a create over a pool it can already see. It is NOT true
94
+ * for a SECOND deploy attempt started while the FIRST worker is still mid-`zpool create`: that
95
+ * worker has not yet made the pool visible to a read, so `existing = yield* read(props)` at the
96
+ * top of THIS call can also fold to `undefined` — not because the pool is gone, but because the
97
+ * first attempt has not finished — and this function would POST a SECOND `zpool create` at the
98
+ * SAME devices while the first is still writing them. There is no lock or marker anywhere in
99
+ * this package that would stop it. The give-up message below says so explicitly and names the
100
+ * task log to check FIRST; that message, and an operator reading it, are the only safeguard.
101
+ *
102
+ * ⛔ THE ADOPT-ONLY GUARD, RIGHT AFTER THE READ AND BEFORE ANYTHING ELSE. Decision 9 (2026-09-23):
103
+ * omitting `devices` and `raidlevel` declares a pool this resource may only ADOPT, for a pool
104
+ * PVE's own schema cannot fully describe — n1's `speed` is a stripe, and `raidlevel`'s enum has
105
+ * no stripe (zfs-pool.ts). `zfsPoolCreateEndpoint` above already keeps the vendor constraint
106
+ * guard from refusing such a declaration at PLAN time; this is the matching refusal at APPLY
107
+ * time, for the one case that guard cannot see — the pool genuinely is not there.
108
+ */
109
+ export declare const createPool: <E, R>(props: ZfsPoolProps, read: (props: ZfsPoolProps) => Effect.Effect<ZfsPoolAttributes | undefined, E, R>) => Effect.Effect<ZfsPoolAttributes, E | Error | import("effect/unstable/http/HttpClientError").HttpClientError | import("./credential-errors.ts").PveCredentialDenied, R | import("effect/unstable/http/HttpClient").HttpClient>;
110
+ /**
111
+ * ⛔ `DELETE /nodes/{node}/disks/zfs/{name}` RUNS `zpool destroy` AND THE DATASETS GO WITH IT. Per
112
+ * S14 (alchemy-provider-standard), it is implemented rather than stubbed — a `delete` that
113
+ * silently does nothing lies to whoever reads the plan — and what keeps an ordinary removed
114
+ * declaration from reaching it is the resource's `defaultRemovalPolicy: 'retain'` (zfs-pool.ts):
115
+ * an orphaned pool is forgotten, not destroyed, unless a caller opts in with
116
+ * `.pipe(RemovalPolicy.destroy())`. See the corrected header in zfs-pool.ts.
117
+ *
118
+ * ⚠️ `cleanup-config`/`cleanup-disks` ARE NOT SENT. The first would additionally remove the PVE
119
+ * storage entry pointing at this pool, which is a different object with its own resource
120
+ * (`Proxmox.Storage`); one resource reaching over to delete another's is how a stack ends up with
121
+ * state describing something that is gone. Neither is offered as a prop, for the same reason.
122
+ */
123
+ export declare const destroyPool: (props: ZfsPoolProps) => Effect.Effect<string, Error | import("./distilled-pve.ts").PveClusterExhausted | import("./credential-errors.ts").PveCredentialDenied | import("effect/Cause").TimeoutError | nodes.ProxmoxOpError, import("effect/unstable/http/HttpClient").HttpClient>;
124
+ //# sourceMappingURL=zfs-pool-form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zfs-pool-form.d.ts","sourceRoot":"","sources":["../../src/proxmox/zfs-pool-form.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,gCAAgC,CAAC;AAKxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,eAAO,MAAM,eAAe,qCAAqC,CAAC;AAElE;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,2BAA2B,CAAC,WAAW,CAAC,CAAC,CAAC;AAEjF,iFAAiF;AACjF,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,2BAA2B,CAAC,aAAa,CAAC,CAAC,CAAC;AAErF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,UAAW,YAAY,mDACmC,CAAC;AAE7F;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,UAAU,UAAW,YAAY,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAOpE,CAAC;AA0BH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,CAAC,SACtB,YAAY,QACb,CAAC,KAAK,EAAE,YAAY,KAAK,MAAM,CAAC,MAAM,CAAC,iBAAiB,GAAG,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,kOA8D/E,CAAC;AAEL;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,UAAW,YAAY,8PAM5C,CAAC"}
@@ -0,0 +1,78 @@
1
+ import * as Effect from 'effect/Effect';
2
+ import type { ZfsPoolProps } from './zfs-pool.ts';
3
+ import { UNREADABLE, type Unreadable } from './unreadable-read.ts';
4
+ /**
5
+ * ⚠️ EVERYTHING HERE IS REPORTED, NOTHING HERE IS COMPARED — see the ⛔ on `matches` below. These
6
+ * exist so a plan and the state store can say what the pool actually is, on a family where the
7
+ * declaration and the live object share no comparable field at all.
8
+ */
9
+ export interface ZfsPoolAttributes {
10
+ /** ★ The value a `Proxmox.Storage` should read to order itself after this pool. */
11
+ name: string;
12
+ node: string;
13
+ /** `ONLINE` | `DEGRADED` | `FAULTED` | … Health, not configuration. */
14
+ state: string;
15
+ /** ZFS's own error summary, e.g. `No known data errors`. */
16
+ errors: string;
17
+ /**
18
+ * The leaf devices ZFS reports, in vdev order, comma-joined.
19
+ *
20
+ * ⚠️ THIS IS WHAT ZFS RESOLVED, NOT WHAT WAS DECLARED, and the two normally differ: PVE rewrites
21
+ * a `/dev/sdb` into a by-id link before creating, and ZFS reports partition paths (`…-part3`)
22
+ * for a pool built on partitions — MEASURED, that is exactly what node-b's `rpool` reports.
23
+ * Never compare it with `props.devices`.
24
+ */
25
+ devices: string;
26
+ }
27
+ /**
28
+ * The device paths at the bottom of PVE's vdev tree, in the order ZFS reports them.
29
+ *
30
+ * ⚠️ "NO CHILDREN" IS THE LEAF TEST, AND IT IS NOT A GUESS — MEASURED in the node's `preparetree`,
31
+ * which sets `leaf` to 0 when there are children and 1 otherwise. Reading the flag would work
32
+ * equally well; recursing on `children` needs no second field to be present and is what makes
33
+ * nested sections (mirrors inside a raid10, `spares`, `cache`) flatten correctly.
34
+ */
35
+ export declare const leafDevices: (children: unknown) => string[];
36
+ /**
37
+ * ★ Default `read` role — `Sys.Audit` on `/` is all this GET checks (zfs-pool.ts's header).
38
+ * ⛔ `{ node: props.node, name: props.name }`, NEVER THE WHOLE `props` — storage.ts's/user.ts's own
39
+ * ⛔, the kit 0.31.1 regression: `GetNodeDiskZfsRequest`'s schema declares only `node` and `name`
40
+ * (both path labels); any OTHER key on the object passed to `nodes.getNodeDiskZfs` is treated by
41
+ * distilled's `buildRequest` as an "unknown key" and JSON-encoded onto this bodyless GET, which a
42
+ * stricter fetch client refuses outright.
43
+ * ⛔ A MISSING POOL IS A 500, NOT A 404 — MEASURED against the live cluster (TB4 n2, 2026-09-24,
44
+ * read-role, read-only probe): `GET /nodes/n2/disks/zfs/hf-measure-nonexistent-pool` answers
45
+ * `{"message":"command '/sbin/zpool status -P hf-measure-nonexistent-pool' failed: exit code
46
+ * 1\n","data":null}` at HTTP 500 — PVE shells out to `zpool status` and reports its exit code
47
+ * as a generic command failure, not a typed "not found". The same shape as user.ts's/group.ts's/
48
+ * storage.ts's own measured 500s. `readPool` below (used by `createPool`'s settle-poll and by
49
+ * `reconcile`/`read`) still folds it, exactly as `readUser`/`readGroup`/`readStorage` do — the
50
+ * whole reason `createPool` can tell "not built yet" from "forbidden" only by giving up after
51
+ * `SETTLE_ATTEMPTS` (zfs-pool-form.ts's own ⚠️ on that); `readPoolOrFail` (used by `diff`) does
52
+ * not fold it, so a genuine transient failure there propagates and fails the plan loudly instead.
53
+ */
54
+ export declare const readPoolOrFail: (props: ZfsPoolProps) => Effect.Effect<typeof UNREADABLE | ZfsPoolAttributes | undefined, import("@distilled.cloud/caddy").BadGateway | import("@distilled.cloud/caddy").BadRequest | import("@distilled.cloud/caddy").ConfigError | Error | import("@distilled.cloud/caddy").GatewayTimeout | import("effect/unstable/http/HttpClientError").HttpClientError | import("@distilled.cloud/caddy").InternalServerError | import("@distilled.cloud/proxmox/Errors").ParameterVerificationFailed | import("@distilled.cloud/proxmox/Errors").ProxmoxParseError | import("./distilled-pve.ts").PveClusterExhausted | import("@distilled.cloud/caddy").ServiceUnavailable | import("effect/Cause").TimeoutError | import("@distilled.cloud/caddy").TooManyRequests | import("@distilled.cloud/caddy").Unauthorized | import("@distilled.cloud/proxmox/Errors").UnknownProxmoxError, import("effect/unstable/http/HttpClient").HttpClient>;
55
+ /**
56
+ * ⛔ FOLDS A GENUINE READ FAILURE TO `undefined` TOO, AND ONLY `createPool`'s settle-poll AND
57
+ * `read`/`reconcile` MAY USE IT — user.ts's `readUser` has the full reasoning. Safe here because
58
+ * a wrongful fold during create costs at most a redundant `createNodeDiskZfs` POST, which PVE
59
+ * refuses loudly ("pool already exists") rather than silently corrupting anything — zfs-pool.ts's
60
+ * own header, measured.
61
+ * ⛔ `zfs-pool.ts`'s `diff` does **NOT** use this — the same bug class as the credential denial fix:
62
+ * folding a TRANSIENT failure into "absent" at PLAN TIME would force a false `update` with
63
+ * nothing compared. `diff` calls `readPoolOrFail` directly, so a genuine failure there propagates
64
+ * and fails the whole plan loudly instead.
65
+ */
66
+ export declare const readPool: (props: ZfsPoolProps) => Effect.Effect<typeof UNREADABLE | ZfsPoolAttributes | undefined, never, import("effect/unstable/http/HttpClient").HttpClient>;
67
+ /** `read`/`reconcile`/`createPool` return `Attributes | undefined`; only `diff` sees `UNREADABLE`. */
68
+ export declare const dropUnreadable: (live: ZfsPoolAttributes | Unreadable | undefined) => ZfsPoolAttributes | undefined;
69
+ /**
70
+ * ⛔ THERE IS NO `matches` FUNCTION HERE — UNLIKE EVERY OTHER MIGRATED FAMILY, AND DELIBERATELY.
71
+ * Every create parameter on this family is write-only (this file's own `attributesOf`), so
72
+ * there is nothing a declaration and a live pool can ever be compared on — a `matches` that
73
+ * invented one would plan a replace (`zpool destroy`, since this family has no PUT) over a
74
+ * difference it could never verify. `zfs-pool.ts`'s `diff` returns `noop` unconditionally once a
75
+ * pool is found, rather than calling a function that would only ever return `true` — found by
76
+ * adversarial review that an earlier draft exported one here anyway, unused by anything.
77
+ */
78
+ //# sourceMappingURL=zfs-pool-wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zfs-pool-wire.d.ts","sourceRoot":"","sources":["../../src/proxmox/zfs-pool-wire.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAoB,MAAM,sBAAsB,CAAC;AAGrF;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,aAAc,OAAO,KAAG,MAAM,EAO9C,CAAC;AAmBT;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,cAAc,UAAW,YAAY,+2BAe/C,CAAC;AAEJ;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,UAAW,YAAY,kIACuB,CAAC;AAEpE,sGAAsG;AACtG,eAAO,MAAM,cAAc,SAAU,iBAAiB,GAAG,UAAU,GAAG,SAAS,kCACvC,CAAC;AAEzC;;;;;;;;GAQG"}
@@ -26,14 +26,14 @@
26
26
  * ⛔ THERE IS NO PUT ON THIS FAMILY AT ALL. MEASURED from the cluster's own published schema
27
27
  * (`/usr/share/pve-docs/api-viewer/apidoc.js`, read on node-b 2026-09-13): `/nodes/{node}/disks/zfs`
28
28
  * has GET and POST, `/nodes/{node}/disks/zfs/{name}` has GET and DELETE, and that is the whole
29
- * surface. So `updateForm` is omitted — which, per `resource.ts`, makes any `matches` = false a
30
- * REPLACE. A replace is a delete followed by a create, and on this family the delete is the
31
- * thing above. Read the ⛔ on `matches` before adding anything to it.
29
+ * surface — CONFIRMED again in `@distilled.cloud/proxmox`'s generated `nodes.ts`, which declares
30
+ * no `putNodeDiskZfs` at all. So `matches` (zfs-pool-wire.ts) always answers `true`: there is
31
+ * nothing to plan a replace over, and the family's one write is the create below.
32
32
  *
33
33
  * ⛔ NOT ONE CREATE PARAMETER COMES BACK ON READ, SO `matches` COMPARES NOTHING. MEASURED against
34
- * the live cluster: `GET /nodes/node-b/disks/zfs/rpool` answers exactly
35
- * `{action, children, errors, leaf, name, scan, state, status}` — no `ashift`, no `compression`,
36
- * no `raidlevel`, no `devices`, no `add_storage`. Every create parameter is write-only. There is
34
+ * the live cluster: `GET /nodes/n2/disks/zfs/rpool` answers exactly
35
+ * `{action?, children, errors, name, scan?, state, status?}` — no `ashift`, no `compression`, no
36
+ * `raidlevel`, no `devices`, no `add_storage`. Every create parameter is write-only. There is
37
37
  * therefore no field a declaration and a live pool can both be asked about, and a `matches` that
38
38
  * invented one would plan a replace — i.e. a `zpool destroy` — over a difference it could never
39
39
  * verify in the first place.
@@ -46,11 +46,20 @@
46
46
  * is compared, and the three churning strings are kept out of the state store entirely rather
47
47
  * than rewriting this resource's row every time somebody writes a file.
48
48
  *
49
- * ⚠️ TWO HANDLERS ARE OVERRIDDEN AND THE OTHER THREE COME FROM THE FACTORY — see the ★ above
50
- * `handlers`. `delete` is the ⛔ above. `reconcile` is because the create is a FORKED WORKER, so
51
- * the factory's immediate read-back would report a successful create as a failure; the measured
52
- * detail, and the adopt-only refusal decision 9 adds, are both in `createPool` in
53
- * zfs-pool-write.ts.
49
+ * ⛔ A MISSING POOL IS A 500, NOT A 404 — MEASURED against the live cluster (TB4 n2, 2026-09-24,
50
+ * read-role, read-only probe): `GET /nodes/n2/disks/zfs/hf-measure-nonexistent-pool` answers a
51
+ * generic shelled-out command failure at HTTP 500, the same shape as every other family this
52
+ * package has migrated. `zfs-pool-wire.ts` carries the same dual-path read PR 239/243
53
+ * established: `readPoolOrFail` (non-folding, used by `diff`) and `readPool` (folding, used by
54
+ * `createPool`'s settle-poll and by `read`/`reconcile`).
55
+ *
56
+ * ★ MIGRATED OFF `client.ts`'s generic `pve()`/`pveOperations` ONTO `@distilled.cloud/proxmox`'s
57
+ * typed `nodes.getNodeDiskZfs`/`createNodeDiskZfs`/`deleteNodeDiskZfs` (2026-09-24, decision
58
+ * 43's proxmox walk-down, nodes/storage sub-area). `distilled-pve.ts`'s `runPve` replaces
59
+ * `pve()`; the cries-wolf fix is wired the same way as every other migrated family. `reconcile`
60
+ * and `delete` are still hand-written (never the factory) for the SAME two reasons as before the
61
+ * migration — the forked-worker settle-poll, and a DELETE that destroys data — now calling
62
+ * `zfs-pool-form.ts`'s `createPool`/`destroyPool` directly instead of through `pveHandlers`.
54
63
  *
55
64
  * ⚠️ PRIVILEGES, FROM THE SCHEMA. Read and diff need `Sys.Audit` on `/` — both GETs check it.
56
65
  * Reconcile needs `Sys.Modify` on `/` for the POST. `Datastore.Allocate` on `/storage` is NOT
@@ -60,26 +69,15 @@
60
69
  * family checks it, not only the POST. MEASURED the same day as the rest of this paragraph:
61
70
  * `ceph-osd.ts`'s own privilege comparison names `disks/zfs` as one of the sibling families
62
71
  * whose write verbs DO carry a `Sys.Modify` check, unlike `ceph/osd`'s create and delete, which
63
- * carry no permissions block at all and 403 for any identity but `root@pam`. This line
64
- * previously said delete "needs nothing at all, since it calls nothing", which repeated the same
65
- * mistake the header above corrects: `delete` calls the DELETE endpoint, so it needs whatever
66
- * that endpoint checks.
72
+ * carry no permissions block at all and 403 for any identity but `root@pam`.
67
73
  */
68
74
  import { Resource } from 'alchemy';
69
75
  import * as Provider from 'alchemy/Provider';
70
- import type { NodesNodeDisksZfsPostParams } from './generated/pve.ts';
71
- import { type PveRequirements, type WithTarget } from './resource.ts';
72
- /**
73
- * PVE's layouts, generated (2026-09-23) from `NodesNodeDisksZfsPostParams['raidlevel']`
74
- * (`generated/pve.ts`, manifest `pve-apidoc` pve-manager 9.2.11 sha256 9def8f13…) rather than
75
- * hand-typed, per decision 9. ⚠️ Each has a minimum disk count PVE enforces, and `raid10` needs an
76
- * even one. ⛔ THERE IS NO `stripe` IN THIS ENUM. n1's `speed` pool is one (decision 14 accepts it
77
- * as-is): `ZfsPoolProps` below is why a stripe pool is declarable at all — as an ADOPT-ONLY
78
- * declaration with no `raidlevel`, never as a full one.
79
- */
80
- export type ZfsRaidLevel = NonNullable<NodesNodeDisksZfsPostParams['raidlevel']>;
81
- /** Generated the same way, from `NodesNodeDisksZfsPostParams['compression']`. */
82
- export type ZfsCompression = NonNullable<NodesNodeDisksZfsPostParams['compression']>;
76
+ import type { PveRequirements, WithTarget } from './resource-spec.ts';
77
+ import type { ZfsPoolAttributes } from './zfs-pool-wire.ts';
78
+ import type { ZfsCompression, ZfsRaidLevel } from './zfs-pool-form.ts';
79
+ export type { ZfsPoolAttributes } from './zfs-pool-wire.ts';
80
+ export type { ZfsCompression, ZfsRaidLevel } from './zfs-pool-form.ts';
83
81
  /**
84
82
  * ⛔ THERE IS NO `add_storage`, `cleanup-config` OR `cleanup-disks` PROP, AND THAT IS NOT AN
85
83
  * OVERSIGHT. The last two belong to the DELETE this resource refuses to make. `add_storage=1`
@@ -116,7 +114,7 @@ export interface ZfsPoolProps extends WithTarget {
116
114
  * both this and `raidlevel` undeclared declares an ADOPT-ONLY pool — one this resource may
117
115
  * read and report but never build. That is the only shape available for a pool PVE's own POST
118
116
  * schema cannot fully describe, such as n1's `speed`, whose layout is a stripe and whose
119
- * `raidlevel` enum (above) has no stripe to declare. `createForm` (zfs-pool-write.ts) omits
117
+ * `raidlevel` enum (above) has no stripe to declare. `createForm` (zfs-pool-form.ts) omits
120
118
  * both keys when they are absent, and `createPool` refuses before any POST if the pool it
121
119
  * would need to build is not already there — an adopt-only declaration never creates. Declare
122
120
  * both fields together for a pool this resource should build from scratch; declaring only one
@@ -145,29 +143,6 @@ export interface ZfsPoolProps extends WithTarget {
145
143
  */
146
144
  'draid-config'?: string;
147
145
  }
148
- /**
149
- * ⚠️ EVERYTHING HERE IS REPORTED, NOTHING HERE IS COMPARED — see the ⛔ on `matches`. These exist
150
- * so a plan and the state store can say what the pool actually is, on a family where the
151
- * declaration and the live object share no comparable field at all.
152
- */
153
- export interface ZfsPoolAttributes {
154
- /** ★ The value a `Proxmox.Storage` should read to order itself after this pool. */
155
- name: string;
156
- node: string;
157
- /** `ONLINE` | `DEGRADED` | `FAULTED` | … Health, not configuration. */
158
- state: string;
159
- /** ZFS's own error summary, e.g. `No known data errors`. */
160
- errors: string;
161
- /**
162
- * The leaf devices ZFS reports, in vdev order, comma-joined.
163
- *
164
- * ⚠️ THIS IS WHAT ZFS RESOLVED, NOT WHAT WAS DECLARED, and the two normally differ: PVE rewrites
165
- * a `/dev/sdb` into a by-id link before creating, and ZFS reports partition paths (`…-part3`)
166
- * for a pool built on partitions — MEASURED, that is exactly what node-b's `rpool` reports. Never
167
- * compare it with `props.devices`.
168
- */
169
- devices: string;
170
- }
171
146
  export interface ProxmoxZfsPool extends Resource<'Proxmox.ZfsPool', ZfsPoolProps, ZfsPoolAttributes, never, PveRequirements> {
172
147
  }
173
148
  /** ★ `retain` by default — a pool holding datasets cannot be rebuilt. See the ★ in resource.ts. */
@@ -1 +1 @@
1
- {"version":3,"file":"zfs-pool.d.ts","sourceRoot":"","sources":["../../src/proxmox/zfs-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAA8B,MAAM,eAAe,CAAC;AAIlG;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,2BAA2B,CAAC,WAAW,CAAC,CAAC,CAAC;AAEjF,iFAAiF;AACjF,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,2BAA2B,CAAC,aAAa,CAAC,CAAC,CAAC;AAErF;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,+FAA+F;IAC/F,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAe,SAAQ,QAAQ,CAC9C,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,KAAK,EACL,eAAe,CAChB;CAAG;AAEJ,mGAAmG;AACnG,eAAO,MAAM,cAAc,iDAEzB,CAAC;AAqBH,eAAO,MAAM,sBAAsB,oIACoD,CAAC"}
1
+ {"version":3,"file":"zfs-pool.d.ts","sourceRoot":"","sources":["../../src/proxmox/zfs-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAI7C,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvE;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,+FAA+F;IAC/F,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAe,SAAQ,QAAQ,CAC9C,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,KAAK,EACL,eAAe,CAChB;CAAG;AAEJ,mGAAmG;AACnG,eAAO,MAAM,cAAc,iDAEzB,CAAC;AAEH,eAAO,MAAM,sBAAsB,oIAyEhC,CAAC"}
@@ -0,0 +1,145 @@
1
+ # Grafana alerting provisioning — `@homeflare/alchemy/grafana`
2
+
3
+ Declares Grafana's alerting-provisioning objects (decision 40: every internal alert lands in one
4
+ place). Ships in three stacked PRs, in the order this file's own history records:
5
+
6
+ 1. **This PR:** `Grafana.ContactPoint`, `Grafana.MuteTiming`, `Grafana.MessageTemplate`.
7
+ 2. Next: `Grafana.AlertRuleGroup`.
8
+ 3. Then: `Grafana.NotificationPolicy` — the singleton policy tree, last on purpose (it references
9
+ contact points, mute timings and templates by name).
10
+
11
+ All three ship on the same `@distilled.cloud/grafana@0.2.0` operations
12
+ [grafana.md](./grafana.md#the-sdk-gap--history-and-what-shipped-on-top-of-the-fix) already
13
+ unblocked (`skipDeprecated` patched false for the 32 alerting-provisioning-write operations). No
14
+ live call was made writing this PR — see "Measured vs inferred" below.
15
+
16
+ ## Foreign-provenance refusal — shared, `alerting-provenance.ts`
17
+
18
+ Every resource in this family reads a `provenance` string off what Grafana returns and refuses to
19
+ write when it names an owner other than this API. **Measured against Grafana's own source**
20
+ (`pkg/services/ngalert/models`, not re-fetched live): `ProvenanceNone = ""` (unclaimed),
21
+ `ProvenanceAPI = "api"` (this API's own writes), `ProvenanceFile = "file"`,
22
+ `ProvenanceConvertedPrometheus = "converted_prometheus"`. `alerting-provenance.ts`'s
23
+ `WRITABLE_PROVENANCES` is an **allowlist** of `{"", "api"}`, not a denylist of the two named
24
+ foreign values — an unnamed future provenance source refuses by default, the safer failure
25
+ direction for a control-plane write. Corroborated by Grafana's docs
26
+ (grafana.com/docs/grafana/v13.1/alerting/set-up/provision-alerting-resources/http-api-provisioning/),
27
+ whose example payloads show exactly `"api"` and `"file"`.
28
+
29
+ This is **defense in depth, not the only guard**: Grafana's alerting provisioning API also enforces
30
+ this server-side (grafana/grafana#103597, "Unable to delete file provisioned alert rules," reports
31
+ the block firing) — unlike the classic folder/dashboard write API `provisioned.ts` guards, which
32
+ has no such server-side check at all. `create` is never at risk for any resource below: it only
33
+ runs when `fetchLive` already found nothing.
34
+
35
+ ⛔ **A missing `provenance` field is treated as foreign, never as `ProvenanceNone` — fixed after an
36
+ adversarial review of this PR found the guard failing OPEN.** The first version mapped
37
+ `live.provenance ?? ''`, collapsing "the field is absent" into "the field is explicitly empty" —
38
+ both writable. `isForeignProvenance`/`refuseIfForeignProvenance` now keep `undefined` as its own
39
+ value: only a field Grafana explicitly reports as `""` or `"api"` is writable. Every resource below
40
+ has a test pinning all three cases (missing refuses, explicit `""` is writable, `"file"` refuses).
41
+
42
+ `X-Disable-Provenance` is **never set** by any resource in this family. Every create/update
43
+ therefore leaves the object at `provenance: "api"` — Grafana's own default for an API write, which
44
+ blocks UI edits afterward. Deliberate: an object this family declares should stay owned by the
45
+ declaration, the "one owner per resource" posture `provisioned.ts` already established for
46
+ folders/dashboards.
47
+
48
+ ## `Grafana.ContactPoint`
49
+
50
+ ```ts
51
+ import { GrafanaContactPoint, grafanaProviders } from '@homeflare/alchemy/grafana';
52
+
53
+ export class OncallSlack extends GrafanaContactPoint('oncall-slack', {
54
+ uid: 'slack-oncall',
55
+ name: 'On-call Slack',
56
+ type: 'slack',
57
+ settings: { recipient: '#oncall' },
58
+ secureSettingsRefs: { url: 'GRAFANA_SLACK_WEBHOOK_URL_ENV' },
59
+ }) {}
60
+ ```
61
+
62
+ - **No by-uid GET route exists** — measured: `services/grafana.ts` has only `routeGetContactpoints`
63
+ (list, optional `name` filter) and its export sibling. Narrowing that GET to the declared `name`
64
+ is not safe either: `name` is a renameable grouping label (Grafana's own doc: "used as grouping
65
+ key in the UI"), so `fetchLive` lists every contact point unfiltered and matches `uid`
66
+ client-side — the same ambiguity `resource.ts`'s header and netbox's `soleMatch` name.
67
+ - **Secrets never appear as a literal prop (S25).** A secure `settings` key (a webhook URL, an API
68
+ key, …) is named in `secureSettingsRefs` (field -> env var NAME), resolved fresh inside
69
+ `create`/`update`'s own effect and merged into `settings` only there. Grafana's plain GET has no
70
+ `decrypt` option (only the export route does, org-admin only) — a secure key always comes back
71
+ redacted, so `matches` excludes every `secureSettingsRefs` key from comparison entirely, even if
72
+ `settings` also names it with a stale placeholder value (`contact-point.test.ts`'s own test for
73
+ this). Non-secret `settings` compares via `subset-match.ts`'s `declaredContentMatches`, tolerating
74
+ a default Grafana injects that the declaration never mentioned.
75
+
76
+ ## `Grafana.MuteTiming`
77
+
78
+ ```ts
79
+ import { GrafanaMuteTiming, grafanaProviders } from '@homeflare/alchemy/grafana';
80
+
81
+ export class Weekends extends GrafanaMuteTiming('weekends-mute', {
82
+ name: 'weekends',
83
+ timeIntervals: [{ weekdays: ['saturday', 'sunday'] }],
84
+ }) {}
85
+ ```
86
+
87
+ - ⚠️ **A genuine, surprising SDK finding, worth restating here.** The generated `MuteTimeInterval`
88
+ type declares only `name`/`time_intervals` — no `provenance`, no `version`, unlike every other
89
+ type this family reads. A first pass assumed the data was gone; empirically it is not:
90
+ `@distilled.cloud/core`'s response decoding is `JSON.parse` + a key-rename pass, never a strict
91
+ schema decode — any key a type doesn't model passes through **verbatim** (`protocol-http.ts`'s
92
+ `mapKeys`, confirmed by calling the real operation with a `provenance`/`version`-bearing response
93
+ through this family's own fake-Grafana harness). `mute-timing.ts` reads both through a small
94
+ local `& { provenance?: string; version?: string }` intersection rather than the SDK's own type.
95
+ The same passthrough applies outbound: `timeIntervals` is typed as an opaque
96
+ `Record<string, unknown>[]`, not the SDK's own too-narrow `TimeInterval` (which is missing the
97
+ real Alertmanager fields — `weekdays`/`times`/`months`/`days_of_month`/`years`/`location` — for
98
+ the same reason), and a real weekday/time entry reaches the wire unchanged. Tracked as a real SDK
99
+ type-generation gap in `docs/upstream-conformance.md` (the S22 fix route) — not a data-loss gap.
100
+ - **`version` rides on `destroy`, not `update`** — measured: `RouteDeleteMuteTimingRequest.version`
101
+ exists for optimistic concurrency; `RoutePutMuteTimingRequest` has no `version` field at all, a
102
+ real Grafana API asymmetry between the two write routes.
103
+
104
+ ## `Grafana.MessageTemplate`
105
+
106
+ ```ts
107
+ import { GrafanaMessageTemplate, grafanaProviders } from '@homeflare/alchemy/grafana';
108
+
109
+ export class SlackBody extends GrafanaMessageTemplate('slack-body-template', {
110
+ name: 'slack-body',
111
+ template: '{{ define "slack-body" }}...{{ end }}',
112
+ }) {}
113
+ ```
114
+
115
+ - **Create and update are the same wire call** — measured: no `routePostTemplate` exists, only
116
+ `routePutTemplate` (`PUT /v1/provisioning/templates/{name}`, upsert by name). Kept as two spec
117
+ functions anyway so the shared engine's `diff` reports a content change as `update`, not the
118
+ `replace` it shows for any resource whose `spec.update` is `undefined` (`resource.ts`).
119
+ `version` rides on `update` when Grafana reports one, for optimistic concurrency.
120
+
121
+ ## Tests
122
+
123
+ Each resource's `*.test.ts` uses the family's `fake-grafana.ts` harness (the real distilled
124
+ protocol, only wire responses faked) and proves: a GET never carries a body; a foreign-provenance
125
+ object — an explicit `"file"` OR a MISSING `provenance` field — refuses update/destroy with no write
126
+ sent, while an explicit `""` is writable; a transient failure (401/403) propagates rather than
127
+ folding to absent; an unchanged declaration is a noop despite Grafana injecting an extra field the
128
+ declaration never mentioned; and — `Grafana.ContactPoint` only — a secret value never appears in the
129
+ attributes a real `reconcile` returns (driven end to end through create and the read-back
130
+ `resource.ts` always does, not just asserted absent from a declaration that never held it).
131
+ `Grafana.ContactPoint`'s tests are split three ways (`contact-point.test.ts`/`-secrets.test.ts`/
132
+ `-provenance.test.ts`, sharing fixtures from `contact-point-fixtures.ts`) to stay under the house's
133
+ 250-line file cap.
134
+
135
+ ## Measured vs inferred (no live call in this PR)
136
+
137
+ **Measured**, against the SDK's generated types and/or Grafana's own docs: the provenance enum and
138
+ its values; the absence of a by-uid contact-point GET; the create/update PUT-only shape for
139
+ templates and the `version`-on-destroy-only shape for mute timings; the response-decode
140
+ verbatim-passthrough behavior (traced into `@distilled.cloud/core`'s own source and confirmed
141
+ against the real operation through this family's fake-Grafana harness — as close to "measured" as
142
+ this PR gets without a live Grafana instance). **Inferred, not measured live:** whether Grafana's
143
+ real server-side provenance enforcement covers every write route this family calls the same way (only
144
+ the alert-rule-deletion case is corroborated by a filed issue); whether a genuine mute-timing
145
+ `version` conflict on delete surfaces as a typed `Conflict` in practice.