@homeflare/alchemy 0.1.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 (417) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -0
  3. package/dist/cloudflare/client.d.ts +45 -0
  4. package/dist/cloudflare/client.d.ts.map +1 -0
  5. package/dist/cloudflare/index.d.ts +11 -0
  6. package/dist/cloudflare/index.d.ts.map +1 -0
  7. package/dist/cloudflare/index.js +129 -0
  8. package/dist/cloudflare/index.js.map +13 -0
  9. package/dist/cloudflare/lock-rules.d.ts +50 -0
  10. package/dist/cloudflare/lock-rules.d.ts.map +1 -0
  11. package/dist/cloudflare/providers.d.ts +19 -0
  12. package/dist/cloudflare/providers.d.ts.map +1 -0
  13. package/dist/cloudflare/r2-bucket-lock.d.ts +100 -0
  14. package/dist/cloudflare/r2-bucket-lock.d.ts.map +1 -0
  15. package/dist/forgejo/branch-protection-form.d.ts +19 -0
  16. package/dist/forgejo/branch-protection-form.d.ts.map +1 -0
  17. package/dist/forgejo/branch-protection.d.ts +47 -0
  18. package/dist/forgejo/branch-protection.d.ts.map +1 -0
  19. package/dist/forgejo/client.d.ts +37 -0
  20. package/dist/forgejo/client.d.ts.map +1 -0
  21. package/dist/forgejo/index.d.ts +18 -0
  22. package/dist/forgejo/index.d.ts.map +1 -0
  23. package/dist/forgejo/index.js +479 -0
  24. package/dist/forgejo/index.js.map +21 -0
  25. package/dist/forgejo/org-actions-secrets.d.ts +45 -0
  26. package/dist/forgejo/org-actions-secrets.d.ts.map +1 -0
  27. package/dist/forgejo/org-label.d.ts +46 -0
  28. package/dist/forgejo/org-label.d.ts.map +1 -0
  29. package/dist/forgejo/org-team.d.ts +42 -0
  30. package/dist/forgejo/org-team.d.ts.map +1 -0
  31. package/dist/forgejo/repo-webhook-form.d.ts +27 -0
  32. package/dist/forgejo/repo-webhook-form.d.ts.map +1 -0
  33. package/dist/forgejo/repo-webhook.d.ts +46 -0
  34. package/dist/forgejo/repo-webhook.d.ts.map +1 -0
  35. package/dist/forgejo/repository.d.ts +45 -0
  36. package/dist/forgejo/repository.d.ts.map +1 -0
  37. package/dist/forgejo/resource.d.ts +83 -0
  38. package/dist/forgejo/resource.d.ts.map +1 -0
  39. package/dist/forgejo/team-member.d.ts +39 -0
  40. package/dist/forgejo/team-member.d.ts.map +1 -0
  41. package/dist/forgejo/values.d.ts +24 -0
  42. package/dist/forgejo/values.d.ts.map +1 -0
  43. package/dist/index.d.ts +18 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +3 -0
  46. package/dist/index.js.map +9 -0
  47. package/dist/openbao/auth-role-form.d.ts +38 -0
  48. package/dist/openbao/auth-role-form.d.ts.map +1 -0
  49. package/dist/openbao/auth-role.d.ts +20 -0
  50. package/dist/openbao/auth-role.d.ts.map +1 -0
  51. package/dist/openbao/bao-address.d.ts +72 -0
  52. package/dist/openbao/bao-address.d.ts.map +1 -0
  53. package/dist/openbao/bao-http.d.ts +71 -0
  54. package/dist/openbao/bao-http.d.ts.map +1 -0
  55. package/dist/openbao/bao-status.d.ts +74 -0
  56. package/dist/openbao/bao-status.d.ts.map +1 -0
  57. package/dist/openbao/cloudflare-group-scope.d.ts +73 -0
  58. package/dist/openbao/cloudflare-group-scope.d.ts.map +1 -0
  59. package/dist/openbao/cloudflare-parity-catalog.d.ts +28 -0
  60. package/dist/openbao/cloudflare-parity-catalog.d.ts.map +1 -0
  61. package/dist/openbao/cloudflare-parity-snapshot.d.ts +31 -0
  62. package/dist/openbao/cloudflare-parity-snapshot.d.ts.map +1 -0
  63. package/dist/openbao/cloudflare-parity.d.ts +14 -0
  64. package/dist/openbao/cloudflare-parity.d.ts.map +1 -0
  65. package/dist/openbao/cloudflare-permission-groups-solve.d.ts +85 -0
  66. package/dist/openbao/cloudflare-permission-groups-solve.d.ts.map +1 -0
  67. package/dist/openbao/cloudflare-permission-groups.d.ts +87 -0
  68. package/dist/openbao/cloudflare-permission-groups.d.ts.map +1 -0
  69. package/dist/openbao/cloudflare-policy.d.ts +65 -0
  70. package/dist/openbao/cloudflare-policy.d.ts.map +1 -0
  71. package/dist/openbao/cloudflare-role-form.d.ts +110 -0
  72. package/dist/openbao/cloudflare-role-form.d.ts.map +1 -0
  73. package/dist/openbao/cloudflare-role-wire.d.ts +27 -0
  74. package/dist/openbao/cloudflare-role-wire.d.ts.map +1 -0
  75. package/dist/openbao/cloudflare-role.d.ts +35 -0
  76. package/dist/openbao/cloudflare-role.d.ts.map +1 -0
  77. package/dist/openbao/cloudflare-roles-config.d.ts +67 -0
  78. package/dist/openbao/cloudflare-roles-config.d.ts.map +1 -0
  79. package/dist/openbao/cloudflare-roles-expand.d.ts +76 -0
  80. package/dist/openbao/cloudflare-roles-expand.d.ts.map +1 -0
  81. package/dist/openbao/digest.d.ts +24 -0
  82. package/dist/openbao/digest.d.ts.map +1 -0
  83. package/dist/openbao/fake-bao.d.ts +40 -0
  84. package/dist/openbao/fake-bao.d.ts.map +1 -0
  85. package/dist/openbao/forgejo-bootstrap-parse.d.ts +46 -0
  86. package/dist/openbao/forgejo-bootstrap-parse.d.ts.map +1 -0
  87. package/dist/openbao/forgejo-bootstrap.d.ts +29 -0
  88. package/dist/openbao/forgejo-bootstrap.d.ts.map +1 -0
  89. package/dist/openbao/index.d.ts +18 -0
  90. package/dist/openbao/index.d.ts.map +1 -0
  91. package/dist/openbao/index.js +1158 -0
  92. package/dist/openbao/index.js.map +33 -0
  93. package/dist/openbao/mount-form.d.ts +60 -0
  94. package/dist/openbao/mount-form.d.ts.map +1 -0
  95. package/dist/openbao/mount-wire.d.ts +24 -0
  96. package/dist/openbao/mount-wire.d.ts.map +1 -0
  97. package/dist/openbao/mount.d.ts +20 -0
  98. package/dist/openbao/mount.d.ts.map +1 -0
  99. package/dist/openbao/pki-role-form.d.ts +118 -0
  100. package/dist/openbao/pki-role-form.d.ts.map +1 -0
  101. package/dist/openbao/pki-role.d.ts +50 -0
  102. package/dist/openbao/pki-role.d.ts.map +1 -0
  103. package/dist/openbao/policy-assembly.d.ts +13 -0
  104. package/dist/openbao/policy-assembly.d.ts.map +1 -0
  105. package/dist/openbao/policy-wire.d.ts +41 -0
  106. package/dist/openbao/policy-wire.d.ts.map +1 -0
  107. package/dist/openbao/policy.d.ts +83 -0
  108. package/dist/openbao/policy.d.ts.map +1 -0
  109. package/dist/openbao/proxmox-role-form.d.ts +92 -0
  110. package/dist/openbao/proxmox-role-form.d.ts.map +1 -0
  111. package/dist/openbao/proxmox-role.d.ts +47 -0
  112. package/dist/openbao/proxmox-role.d.ts.map +1 -0
  113. package/dist/openbao/ssh-role-form.d.ts +99 -0
  114. package/dist/openbao/ssh-role-form.d.ts.map +1 -0
  115. package/dist/openbao/ssh-role.d.ts +43 -0
  116. package/dist/openbao/ssh-role.d.ts.map +1 -0
  117. package/dist/proxmox/acl.d.ts +72 -0
  118. package/dist/proxmox/acl.d.ts.map +1 -0
  119. package/dist/proxmox/api-token-form.d.ts +59 -0
  120. package/dist/proxmox/api-token-form.d.ts.map +1 -0
  121. package/dist/proxmox/api-token.d.ts +159 -0
  122. package/dist/proxmox/api-token.d.ts.map +1 -0
  123. package/dist/proxmox/backup-job.d.ts +112 -0
  124. package/dist/proxmox/backup-job.d.ts.map +1 -0
  125. package/dist/proxmox/ceph-daemon-form.d.ts +70 -0
  126. package/dist/proxmox/ceph-daemon-form.d.ts.map +1 -0
  127. package/dist/proxmox/ceph-daemon.d.ts +162 -0
  128. package/dist/proxmox/ceph-daemon.d.ts.map +1 -0
  129. package/dist/proxmox/ceph-flag.d.ts +131 -0
  130. package/dist/proxmox/ceph-flag.d.ts.map +1 -0
  131. package/dist/proxmox/ceph-fs-wire.d.ts +106 -0
  132. package/dist/proxmox/ceph-fs-wire.d.ts.map +1 -0
  133. package/dist/proxmox/ceph-fs.d.ts +124 -0
  134. package/dist/proxmox/ceph-fs.d.ts.map +1 -0
  135. package/dist/proxmox/ceph-osd-tree.d.ts +154 -0
  136. package/dist/proxmox/ceph-osd-tree.d.ts.map +1 -0
  137. package/dist/proxmox/ceph-osd-write.d.ts +36 -0
  138. package/dist/proxmox/ceph-osd-write.d.ts.map +1 -0
  139. package/dist/proxmox/ceph-osd.d.ts +102 -0
  140. package/dist/proxmox/ceph-osd.d.ts.map +1 -0
  141. package/dist/proxmox/ceph-pool-form.d.ts +217 -0
  142. package/dist/proxmox/ceph-pool-form.d.ts.map +1 -0
  143. package/dist/proxmox/ceph-pool-settle.d.ts +39 -0
  144. package/dist/proxmox/ceph-pool-settle.d.ts.map +1 -0
  145. package/dist/proxmox/ceph-pool.d.ts +48 -0
  146. package/dist/proxmox/ceph-pool.d.ts.map +1 -0
  147. package/dist/proxmox/client.d.ts +64 -0
  148. package/dist/proxmox/client.d.ts.map +1 -0
  149. package/dist/proxmox/credentials.d.ts +153 -0
  150. package/dist/proxmox/credentials.d.ts.map +1 -0
  151. package/dist/proxmox/firewall-alias-form.d.ts +98 -0
  152. package/dist/proxmox/firewall-alias-form.d.ts.map +1 -0
  153. package/dist/proxmox/firewall-alias.d.ts +141 -0
  154. package/dist/proxmox/firewall-alias.d.ts.map +1 -0
  155. package/dist/proxmox/generated/pbs.d.ts +388 -0
  156. package/dist/proxmox/generated/pbs.d.ts.map +1 -0
  157. package/dist/proxmox/generated/pve.d.ts +4713 -0
  158. package/dist/proxmox/generated/pve.d.ts.map +1 -0
  159. package/dist/proxmox/group.d.ts +104 -0
  160. package/dist/proxmox/group.d.ts.map +1 -0
  161. package/dist/proxmox/ha-resource.d.ts +104 -0
  162. package/dist/proxmox/ha-resource.d.ts.map +1 -0
  163. package/dist/proxmox/ha-rule-form.d.ts +103 -0
  164. package/dist/proxmox/ha-rule-form.d.ts.map +1 -0
  165. package/dist/proxmox/ha-rule.d.ts +156 -0
  166. package/dist/proxmox/ha-rule.d.ts.map +1 -0
  167. package/dist/proxmox/index.d.ts +43 -0
  168. package/dist/proxmox/index.d.ts.map +1 -0
  169. package/dist/proxmox/index.js +2322 -0
  170. package/dist/proxmox/index.js.map +70 -0
  171. package/dist/proxmox/lease-cache.d.ts +98 -0
  172. package/dist/proxmox/lease-cache.d.ts.map +1 -0
  173. package/dist/proxmox/lxc.d.ts +59 -0
  174. package/dist/proxmox/lxc.d.ts.map +1 -0
  175. package/dist/proxmox/members.d.ts +56 -0
  176. package/dist/proxmox/members.d.ts.map +1 -0
  177. package/dist/proxmox/metric-server-form.d.ts +53 -0
  178. package/dist/proxmox/metric-server-form.d.ts.map +1 -0
  179. package/dist/proxmox/metric-server-otel.d.ts +49 -0
  180. package/dist/proxmox/metric-server-otel.d.ts.map +1 -0
  181. package/dist/proxmox/metric-server.d.ts +123 -0
  182. package/dist/proxmox/metric-server.d.ts.map +1 -0
  183. package/dist/proxmox/network-apply-read.d.ts +93 -0
  184. package/dist/proxmox/network-apply-read.d.ts.map +1 -0
  185. package/dist/proxmox/network-apply.d.ts +102 -0
  186. package/dist/proxmox/network-apply.d.ts.map +1 -0
  187. package/dist/proxmox/node-network-form.d.ts +128 -0
  188. package/dist/proxmox/node-network-form.d.ts.map +1 -0
  189. package/dist/proxmox/node-network.d.ts +173 -0
  190. package/dist/proxmox/node-network.d.ts.map +1 -0
  191. package/dist/proxmox/notification-target-form.d.ts +44 -0
  192. package/dist/proxmox/notification-target-form.d.ts.map +1 -0
  193. package/dist/proxmox/notification-target.d.ts +146 -0
  194. package/dist/proxmox/notification-target.d.ts.map +1 -0
  195. package/dist/proxmox/pbs-datastore-form.d.ts +147 -0
  196. package/dist/proxmox/pbs-datastore-form.d.ts.map +1 -0
  197. package/dist/proxmox/pbs-datastore-guard.d.ts +55 -0
  198. package/dist/proxmox/pbs-datastore-guard.d.ts.map +1 -0
  199. package/dist/proxmox/pbs-datastore.d.ts +140 -0
  200. package/dist/proxmox/pbs-datastore.d.ts.map +1 -0
  201. package/dist/proxmox/pbs-prune-job-form.d.ts +97 -0
  202. package/dist/proxmox/pbs-prune-job-form.d.ts.map +1 -0
  203. package/dist/proxmox/pbs-prune-job.d.ts +168 -0
  204. package/dist/proxmox/pbs-prune-job.d.ts.map +1 -0
  205. package/dist/proxmox/pbs-sync-job-form.d.ts +83 -0
  206. package/dist/proxmox/pbs-sync-job-form.d.ts.map +1 -0
  207. package/dist/proxmox/pbs-sync-job.d.ts +246 -0
  208. package/dist/proxmox/pbs-sync-job.d.ts.map +1 -0
  209. package/dist/proxmox/pbs-verify-job-form.d.ts +114 -0
  210. package/dist/proxmox/pbs-verify-job-form.d.ts.map +1 -0
  211. package/dist/proxmox/pbs-verify-job.d.ts +145 -0
  212. package/dist/proxmox/pbs-verify-job.d.ts.map +1 -0
  213. package/dist/proxmox/pool.d.ts +42 -0
  214. package/dist/proxmox/pool.d.ts.map +1 -0
  215. package/dist/proxmox/qemu.d.ts +46 -0
  216. package/dist/proxmox/qemu.d.ts.map +1 -0
  217. package/dist/proxmox/replication-job-form.d.ts +71 -0
  218. package/dist/proxmox/replication-job-form.d.ts.map +1 -0
  219. package/dist/proxmox/replication-job.d.ts +162 -0
  220. package/dist/proxmox/replication-job.d.ts.map +1 -0
  221. package/dist/proxmox/resource.d.ts +157 -0
  222. package/dist/proxmox/resource.d.ts.map +1 -0
  223. package/dist/proxmox/role.d.ts +97 -0
  224. package/dist/proxmox/role.d.ts.map +1 -0
  225. package/dist/proxmox/sdn-apply-read.d.ts +80 -0
  226. package/dist/proxmox/sdn-apply-read.d.ts.map +1 -0
  227. package/dist/proxmox/sdn-apply.d.ts +63 -0
  228. package/dist/proxmox/sdn-apply.d.ts.map +1 -0
  229. package/dist/proxmox/sdn-subnet-form.d.ts +111 -0
  230. package/dist/proxmox/sdn-subnet-form.d.ts.map +1 -0
  231. package/dist/proxmox/sdn-subnet.d.ts +161 -0
  232. package/dist/proxmox/sdn-subnet.d.ts.map +1 -0
  233. package/dist/proxmox/sdn-vnet.d.ts +113 -0
  234. package/dist/proxmox/sdn-vnet.d.ts.map +1 -0
  235. package/dist/proxmox/sdn-zone.d.ts +126 -0
  236. package/dist/proxmox/sdn-zone.d.ts.map +1 -0
  237. package/dist/proxmox/storage.d.ts +120 -0
  238. package/dist/proxmox/storage.d.ts.map +1 -0
  239. package/dist/proxmox/user.d.ts +107 -0
  240. package/dist/proxmox/user.d.ts.map +1 -0
  241. package/dist/proxmox/values.d.ts +134 -0
  242. package/dist/proxmox/values.d.ts.map +1 -0
  243. package/dist/proxmox/zfs-pool-write.d.ts +76 -0
  244. package/dist/proxmox/zfs-pool-write.d.ts.map +1 -0
  245. package/dist/proxmox/zfs-pool.d.ts +146 -0
  246. package/dist/proxmox/zfs-pool.d.ts.map +1 -0
  247. package/dist/talos/credentials.d.ts +30 -0
  248. package/dist/talos/credentials.d.ts.map +1 -0
  249. package/dist/talos/index.d.ts +15 -0
  250. package/dist/talos/index.d.ts.map +1 -0
  251. package/dist/talos/index.js +392 -0
  252. package/dist/talos/index.js.map +16 -0
  253. package/dist/talos/kubeconfig.d.ts +53 -0
  254. package/dist/talos/kubeconfig.d.ts.map +1 -0
  255. package/dist/talos/resource.d.ts +32 -0
  256. package/dist/talos/resource.d.ts.map +1 -0
  257. package/dist/talos/talos-bootstrap.d.ts +27 -0
  258. package/dist/talos/talos-bootstrap.d.ts.map +1 -0
  259. package/dist/talos/talos-cluster-health.d.ts +36 -0
  260. package/dist/talos/talos-cluster-health.d.ts.map +1 -0
  261. package/dist/talos/talos-machine-config.d.ts +41 -0
  262. package/dist/talos/talos-machine-config.d.ts.map +1 -0
  263. package/dist/talos/talosctl.d.ts +29 -0
  264. package/dist/talos/talosctl.d.ts.map +1 -0
  265. package/dist/talos/values.d.ts +20 -0
  266. package/dist/talos/values.d.ts.map +1 -0
  267. package/package.json +57 -0
  268. package/src/cloudflare/client.ts +76 -0
  269. package/src/cloudflare/index.ts +10 -0
  270. package/src/cloudflare/lock-rules.ts +60 -0
  271. package/src/cloudflare/providers.ts +23 -0
  272. package/src/cloudflare/r2-bucket-lock.ts +220 -0
  273. package/src/forgejo/branch-protection-form.ts +29 -0
  274. package/src/forgejo/branch-protection.ts +101 -0
  275. package/src/forgejo/client.ts +136 -0
  276. package/src/forgejo/index.ts +17 -0
  277. package/src/forgejo/org-actions-secrets.ts +99 -0
  278. package/src/forgejo/org-label.ts +100 -0
  279. package/src/forgejo/org-team.ts +105 -0
  280. package/src/forgejo/repo-webhook-form.ts +47 -0
  281. package/src/forgejo/repo-webhook.ts +118 -0
  282. package/src/forgejo/repository.ts +126 -0
  283. package/src/forgejo/resource.ts +171 -0
  284. package/src/forgejo/team-member.ts +97 -0
  285. package/src/forgejo/values.test.ts +48 -0
  286. package/src/forgejo/values.ts +61 -0
  287. package/src/index.ts +18 -0
  288. package/src/openbao/auth-role-form.ts +112 -0
  289. package/src/openbao/auth-role.ts +101 -0
  290. package/src/openbao/bao-address.test.ts +89 -0
  291. package/src/openbao/bao-address.ts +97 -0
  292. package/src/openbao/bao-http-gate.test.ts +88 -0
  293. package/src/openbao/bao-http-unix.test.ts +70 -0
  294. package/src/openbao/bao-http.test.ts +161 -0
  295. package/src/openbao/bao-http.ts +185 -0
  296. package/src/openbao/bao-status.test.ts +114 -0
  297. package/src/openbao/bao-status.ts +137 -0
  298. package/src/openbao/cloudflare-group-scope.test.ts +103 -0
  299. package/src/openbao/cloudflare-group-scope.ts +83 -0
  300. package/src/openbao/cloudflare-parity-catalog.ts +104 -0
  301. package/src/openbao/cloudflare-parity-snapshot.ts +84 -0
  302. package/src/openbao/cloudflare-parity.ts +152 -0
  303. package/src/openbao/cloudflare-permission-groups-solve.test.ts +171 -0
  304. package/src/openbao/cloudflare-permission-groups-solve.ts +197 -0
  305. package/src/openbao/cloudflare-permission-groups.test.ts +369 -0
  306. package/src/openbao/cloudflare-permission-groups.ts +299 -0
  307. package/src/openbao/cloudflare-policy.ts +180 -0
  308. package/src/openbao/cloudflare-role-form.test.ts +177 -0
  309. package/src/openbao/cloudflare-role-form.ts +183 -0
  310. package/src/openbao/cloudflare-role-wire.test.ts +132 -0
  311. package/src/openbao/cloudflare-role-wire.ts +41 -0
  312. package/src/openbao/cloudflare-role.ts +189 -0
  313. package/src/openbao/cloudflare-roles-config.ts +230 -0
  314. package/src/openbao/cloudflare-roles-expand-bucket.test.ts +134 -0
  315. package/src/openbao/cloudflare-roles-expand.ts +231 -0
  316. package/src/openbao/digest.ts +26 -0
  317. package/src/openbao/fake-bao.ts +84 -0
  318. package/src/openbao/forgejo-bootstrap-parse.test.ts +76 -0
  319. package/src/openbao/forgejo-bootstrap-parse.ts +90 -0
  320. package/src/openbao/forgejo-bootstrap.ts +181 -0
  321. package/src/openbao/index.ts +17 -0
  322. package/src/openbao/mount-form.ts +147 -0
  323. package/src/openbao/mount-wire.test.ts +108 -0
  324. package/src/openbao/mount-wire.ts +79 -0
  325. package/src/openbao/mount.ts +132 -0
  326. package/src/openbao/pki-role-form.ts +248 -0
  327. package/src/openbao/pki-role.ts +202 -0
  328. package/src/openbao/policy-assembly.test.ts +28 -0
  329. package/src/openbao/policy-assembly.ts +13 -0
  330. package/src/openbao/policy-wire.test.ts +90 -0
  331. package/src/openbao/policy-wire.ts +53 -0
  332. package/src/openbao/policy.ts +212 -0
  333. package/src/openbao/proxmox-role-form.ts +174 -0
  334. package/src/openbao/proxmox-role.ts +214 -0
  335. package/src/openbao/ssh-role-form.ts +248 -0
  336. package/src/openbao/ssh-role.ts +240 -0
  337. package/src/proxmox/acl.ts +267 -0
  338. package/src/proxmox/api-token-form.ts +122 -0
  339. package/src/proxmox/api-token.ts +222 -0
  340. package/src/proxmox/backup-job.ts +213 -0
  341. package/src/proxmox/ceph-daemon-form.ts +84 -0
  342. package/src/proxmox/ceph-daemon.ts +243 -0
  343. package/src/proxmox/ceph-flag.ts +249 -0
  344. package/src/proxmox/ceph-fs-wire.ts +246 -0
  345. package/src/proxmox/ceph-fs.ts +249 -0
  346. package/src/proxmox/ceph-osd-tree.ts +193 -0
  347. package/src/proxmox/ceph-osd-write.ts +76 -0
  348. package/src/proxmox/ceph-osd.ts +244 -0
  349. package/src/proxmox/ceph-pool-form.ts +249 -0
  350. package/src/proxmox/ceph-pool-settle.ts +70 -0
  351. package/src/proxmox/ceph-pool.ts +212 -0
  352. package/src/proxmox/client.test.ts +185 -0
  353. package/src/proxmox/client.ts +240 -0
  354. package/src/proxmox/credentials.test.ts +144 -0
  355. package/src/proxmox/credentials.ts +254 -0
  356. package/src/proxmox/firewall-alias-form.ts +112 -0
  357. package/src/proxmox/firewall-alias.ts +208 -0
  358. package/src/proxmox/generated/pbs.ts +461 -0
  359. package/src/proxmox/generated/pve.ts +7344 -0
  360. package/src/proxmox/group.ts +199 -0
  361. package/src/proxmox/ha-resource.ts +169 -0
  362. package/src/proxmox/ha-rule-form.ts +185 -0
  363. package/src/proxmox/ha-rule.ts +240 -0
  364. package/src/proxmox/index.ts +42 -0
  365. package/src/proxmox/lease-cache.test.ts +163 -0
  366. package/src/proxmox/lease-cache.ts +131 -0
  367. package/src/proxmox/lxc.ts +117 -0
  368. package/src/proxmox/members.test.ts +54 -0
  369. package/src/proxmox/members.ts +174 -0
  370. package/src/proxmox/metric-server-form.ts +128 -0
  371. package/src/proxmox/metric-server-otel.ts +99 -0
  372. package/src/proxmox/metric-server.ts +214 -0
  373. package/src/proxmox/network-apply-read.ts +228 -0
  374. package/src/proxmox/network-apply.ts +244 -0
  375. package/src/proxmox/node-network-form.ts +213 -0
  376. package/src/proxmox/node-network.ts +243 -0
  377. package/src/proxmox/notification-target-form.ts +104 -0
  378. package/src/proxmox/notification-target.ts +222 -0
  379. package/src/proxmox/pbs-datastore-form.ts +248 -0
  380. package/src/proxmox/pbs-datastore-guard.ts +105 -0
  381. package/src/proxmox/pbs-datastore.ts +271 -0
  382. package/src/proxmox/pbs-prune-job-form.ts +208 -0
  383. package/src/proxmox/pbs-prune-job.ts +227 -0
  384. package/src/proxmox/pbs-sync-job-form.ts +234 -0
  385. package/src/proxmox/pbs-sync-job.ts +258 -0
  386. package/src/proxmox/pbs-verify-job-form.ts +131 -0
  387. package/src/proxmox/pbs-verify-job.ts +227 -0
  388. package/src/proxmox/pool.test.ts +42 -0
  389. package/src/proxmox/pool.ts +80 -0
  390. package/src/proxmox/qemu.ts +89 -0
  391. package/src/proxmox/replication-job-form.ts +89 -0
  392. package/src/proxmox/replication-job.ts +248 -0
  393. package/src/proxmox/resource.ts +257 -0
  394. package/src/proxmox/role.ts +161 -0
  395. package/src/proxmox/sdn-apply-read.test.ts +152 -0
  396. package/src/proxmox/sdn-apply-read.ts +189 -0
  397. package/src/proxmox/sdn-apply.ts +154 -0
  398. package/src/proxmox/sdn-subnet-form.ts +156 -0
  399. package/src/proxmox/sdn-subnet.ts +238 -0
  400. package/src/proxmox/sdn-vnet.ts +228 -0
  401. package/src/proxmox/sdn-zone.ts +246 -0
  402. package/src/proxmox/storage.ts +245 -0
  403. package/src/proxmox/user.ts +214 -0
  404. package/src/proxmox/values.test.ts +193 -0
  405. package/src/proxmox/values.ts +203 -0
  406. package/src/proxmox/zfs-pool-write.ts +130 -0
  407. package/src/proxmox/zfs-pool.ts +253 -0
  408. package/src/talos/credentials.ts +136 -0
  409. package/src/talos/index.ts +14 -0
  410. package/src/talos/kubeconfig.ts +170 -0
  411. package/src/talos/resource.ts +31 -0
  412. package/src/talos/talos-bootstrap.ts +109 -0
  413. package/src/talos/talos-cluster-health.ts +119 -0
  414. package/src/talos/talos-machine-config.ts +146 -0
  415. package/src/talos/talosctl.ts +94 -0
  416. package/src/talos/values.test.ts +80 -0
  417. package/src/talos/values.ts +70 -0
@@ -0,0 +1,70 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/proxmox/acl.ts", "../src/proxmox/client.ts", "../src/proxmox/credentials.ts", "../src/proxmox/lease-cache.ts", "../src/proxmox/members.ts", "../src/proxmox/resource.ts", "../src/proxmox/api-token.ts", "../src/proxmox/values.ts", "../src/proxmox/api-token-form.ts", "../src/proxmox/backup-job.ts", "../src/proxmox/ceph-daemon.ts", "../src/proxmox/ceph-daemon-form.ts", "../src/proxmox/ceph-flag.ts", "../src/proxmox/ceph-fs.ts", "../src/proxmox/ceph-fs-wire.ts", "../src/proxmox/ceph-osd.ts", "../src/proxmox/ceph-osd-tree.ts", "../src/proxmox/ceph-osd-write.ts", "../src/proxmox/ceph-pool.ts", "../src/proxmox/ceph-pool-form.ts", "../src/proxmox/ceph-pool-settle.ts", "../src/proxmox/firewall-alias.ts", "../src/proxmox/firewall-alias-form.ts", "../src/proxmox/group.ts", "../src/proxmox/ha-resource.ts", "../src/proxmox/ha-rule.ts", "../src/proxmox/ha-rule-form.ts", "../src/proxmox/lxc.ts", "../src/proxmox/metric-server.ts", "../src/proxmox/metric-server-form.ts", "../src/proxmox/metric-server-otel.ts", "../src/proxmox/network-apply.ts", "../src/proxmox/network-apply-read.ts", "../src/proxmox/node-network.ts", "../src/proxmox/node-network-form.ts", "../src/proxmox/notification-target.ts", "../src/proxmox/notification-target-form.ts", "../src/proxmox/pbs-datastore.ts", "../src/proxmox/pbs-datastore-form.ts", "../src/proxmox/pbs-datastore-guard.ts", "../src/proxmox/pbs-prune-job.ts", "../src/proxmox/pbs-prune-job-form.ts", "../src/proxmox/pbs-sync-job.ts", "../src/proxmox/pbs-sync-job-form.ts", "../src/proxmox/pbs-verify-job.ts", "../src/proxmox/pbs-verify-job-form.ts", "../src/proxmox/pool.ts", "../src/proxmox/qemu.ts", "../src/proxmox/replication-job.ts", "../src/proxmox/replication-job-form.ts", "../src/proxmox/role.ts", "../src/proxmox/sdn-apply.ts", "../src/proxmox/sdn-apply-read.ts", "../src/proxmox/sdn-subnet.ts", "../src/proxmox/sdn-subnet-form.ts", "../src/proxmox/sdn-vnet.ts", "../src/proxmox/sdn-zone.ts", "../src/proxmox/storage.ts", "../src/proxmox/user.ts", "../src/proxmox/zfs-pool.ts", "../src/proxmox/zfs-pool-write.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * `Proxmox.Acl` — one grant: a role bound to a subject at a path. The line that makes a role real.\n *\n * ★ USERS, GROUPS, ROLES AND TOKENS ARE ALL INERT UNTIL AN ACL BINDS THEM. A role is a named list\n * of privileges that grants nothing by itself; a user can do nothing until\n * {path, user|group|token, role} exists. That is what makes those four families worth declaring,\n * and why the grants that let OpenBao mint a PVE token today are only clicks somebody made once.\n *\n * ⛔ THE ONE FAMILY THAT DOES NOT FIT `pveOperations` AS WRITTEN, AND THE MISFIT IS MEASURED. The\n * cluster's own schema — `/pve-docs/api-viewer/apidoc.js`, read unauthenticated 2026-09-13 —\n * lists exactly TWO methods on `/access/acl`: GET and PUT. There is no DELETE (it answers\n * \"Method 'DELETE /access/acl' not implemented\") and, less famously, NO POST either. So create\n * and update are the SAME call, `PUT /access/acl`, and removal is that PUT with `delete=1` —\n * which is why `delete` below does not use `ops.destroy`.\n * ⚠️ THE REAL FIX BELONGS IN `resource.ts`: give `PveSpec` a `deleteForm` and the method to go\n * with it, and this override disappears. Until then it is local and loud — do not \"restore\n * symmetry\" by pointing `delete` at `ops.destroy`, which reports every removal as a 501 while\n * the grant stays exactly where it was.\n *\n * ⛔ A SINGLE GRANT HAS NO URL OF ITS OWN. `GET /access/acl` answers ONE FLAT LIST for the whole\n * cluster, so identity is the tuple (path, type, ugid, roleid), matched client-side in\n * `attributes` below. Two resources declaring the SAME tuple are the SAME grant — Alchemy sees\n * two resource ids, not one collision — and deleting either takes the access away from both,\n * the same hazard as two guests declaring one vmid.\n *\n * ⛔ AND THAT LIST IS FILTERED BY WHO IS ASKING. The schema's own words for GET: \"The returned list\n * is restricted to objects where you have rights to modify permissions.\" A credential that can\n * read the cluster but not modify permissions is answered `[]` — not a 403, not an error — so\n * the mount's `read` role needs permission-modify rights on the declared path exactly as\n * `provision` does. Work reported on a grant that is plainly there means that role is too narrow.\n */\nimport { Resource } from 'alchemy';\nimport { isResolved } from 'alchemy/Diff';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { pve } from './client.ts';\nimport { type PveRequirements, type WithTarget, pveOperations } from './resource.ts';\n\n/** PVE's three kinds of subject. The read answers this word; the write wants its plural. */\nexport type AclSubjectType = 'user' | 'group' | 'token';\n\nexport interface AclProps extends WithTarget {\n /**\n * The PVE object path the grant is ON — `/`, `/pool/house`, `/vms/101`, `/storage/local-zfs`.\n * ⚠️ NOT THE API PATH: `spec.path` below is the endpoint (`access/acl`). PVE's API overloads the\n * word, so this file does too rather than renaming a field the cluster calls `path`.\n */\n path: string;\n /** Which kind of subject `ugid` names. Identity: changing it is a different grant. */\n type: AclSubjectType;\n /** `tim@pve`, `admins`, `hf-provision@pve!hf-provision-…`. Identity. */\n ugid: string;\n /** The role bound here, e.g. `PVEAuditor`. ⚠️ It must exist — PVE refuses an unknown roleid. */\n roleid: string;\n /** Inherit down the path. PVE's default is ON, and this is the grant's ONLY mutable field. */\n propagate?: boolean;\n}\n\nexport interface AclAttributes {\n path: string;\n type: AclSubjectType;\n ugid: string;\n roleid: string;\n propagate: boolean;\n /**\n * ⛔ PRESENCE AS AN ATTRIBUTE, AND IT IS WHAT MAKES THE FACTORY WORK HERE. `attributes` never\n * returns undefined: if it did, `reconcile` would take the create branch and POST to\n * `access/acl`, which PVE does not implement. Present-but-unbound sends every write down the\n * PUT branch instead, the only branch PVE has. The cost: the factory's read-back guard cannot\n * fire, so `reconcile` below re-checks this field itself and dies with the same honesty.\n */\n bound: boolean;\n}\n\nexport interface ProxmoxAcl extends Resource<\n 'Proxmox.Acl',\n AclProps,\n AclAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxAcl = Resource<ProxmoxAcl>('Proxmox.Acl');\n\n/**\n * ⚠️ PVE NORMALISES ACL PATHS AND RETURNS THE NORMALISED FORM, a forever-update trap when only one\n * side of the comparison is normalised. `PVE::AccessControl::normalize_path` collapses repeated\n * slashes and strips the trailing one, so a declared `/pool/house/` reads back as `/pool/house`\n * and a naive match never fires again. It also refuses a path with no leading slash, so one is\n * added here rather than letting `pool/house` 400.\n */\nconst normalize = (raw: string) => `/${raw.split('/').filter(Boolean).join('/')}`;\n\n/**\n * ⚠️ THE WRITE NAMES THE SUBJECT WITH A PLURAL KEY THAT DIFFERS PER KIND — `users`, `groups`,\n * `tokens` — while the READ answers a singular `type`/`ugid` pair. The PUT declares\n * `additionalProperties: 0`, so `user=` fails with a 400 rather than being ignored. The bad case\n * is the WRONG plural: a valid parameter naming a subject kind you did not mean.\n */\nconst SUBJECT_FIELD = { group: 'groups', token: 'tokens', user: 'users' } as const;\n\n/** The tuple PVE keys a grant by, as the form it takes. Every write to this family starts here. */\nconst tuple = (props: AclProps): Record<string, string> => ({\n path: normalize(props.path),\n roles: props.roleid,\n [SUBJECT_FIELD[props.type]]: props.ugid,\n});\n\n/** Create and update are one call: the tuple plus the single mutable field. */\nconst bind = (props: AclProps): Record<string, string> => ({\n propagate: props.propagate === false ? '0' : '1',\n ...tuple(props),\n});\n\n/** What a change of this string means: not an edit, a different grant. Used by `diff` below. */\nconst identity = (grant: Pick<AclAttributes, 'path' | 'roleid' | 'type' | 'ugid'>) =>\n [normalize(grant.path), grant.type, grant.ugid, grant.roleid].join(' ');\n\n/**\n * ⚠️ `GET /access/acl` ANSWERS AN ARRAY, while the factory hands `attributes` the\n * `Record<string, unknown>` every other PVE read is shaped like. Rows are narrowed, not trusted,\n * and an empty result is not evidence of an empty cluster — see the last ⛔ in the header.\n */\nconst find = (live: unknown, props: AclProps) =>\n (Array.isArray(live) ? live : [])\n .filter((row): row is Record<string, unknown> => typeof row === 'object' && row !== null)\n .find(\n (row) =>\n row['path'] === normalize(props.path) &&\n row['type'] === props.type &&\n row['ugid'] === props.ugid &&\n row['roleid'] === props.roleid,\n );\n\n/**\n * ⚠️ PVE ANSWERS `propagate` AS 1/0 RATHER THAN true/false, AND OMITS IT WHEN IT CARRIES THE API\n * DEFAULT, WHICH IS ON. Reading an absent field as `false` would report drift on every plan,\n * forever, for every grant this provider did not create itself.\n */\nconst propagates = (row: Record<string, unknown>) => {\n const value = row['propagate'];\n return value === undefined || value === 1 || value === true || value === '1';\n};\n\nconst ops = pveOperations<AclProps, AclAttributes>({\n attributes: (live, props) => {\n const row = find(live, props);\n return {\n // ⚠️ `propagate` reads false when nothing is bound, because there is no grant to inherit.\n // `bound` is the field that carries presence; this one means something only once it is set.\n bound: row !== undefined,\n path: normalize(props.path),\n propagate: row !== undefined && propagates(row),\n roleid: props.roleid,\n type: props.type,\n ugid: props.ugid,\n };\n },\n /**\n * ⛔ THE CREATE PATH IS UNREACHABLE ON A HEALTHY CLUSTER, AND ITS ERROR WILL MISLEAD YOU. The\n * factory POSTs `collection` only when the read came back undefined, and `attributes` never\n * does — so a POST means the GET itself failed (an expired 300s lease, a node down), not that\n * the grant is missing. PVE answers \"Method 'POST /access/acl' not implemented\": read that 501\n * as \"the read failed\" and go and look at the credential, not at the ACL.\n */\n /**\n * ⛔ `provision`, AND WITHOUT IT EVERY GRANT READS BACK AS ABSENT. `GET /access/acl` is\n * FILTERED, NOT GATED — the schema's own words are \"The returned list is restricted to objects\n * where you have rights to modify permissions\". A credential without Permissions.Modify gets\n * HTTP 200 and an EMPTY ARRAY, never a 403, so there is no error for `read` to fold; it simply\n * sees nothing.\n * ⛔ THE READ LEASE IS EXACTLY SUCH A CREDENTIAL. `hf-read@pve` is PVEAuditor on `/`, whose\n * privilege set is Datastore.Audit, Mapping.Audit, Pool.Audit, SDN.Audit, Sys.Audit,\n * VM.Audit, VM.GuestAgent.Audit — MEASURED in the 2026-09-13 cluster read. No\n * Permissions.Modify. So on the default lease all fourteen live grants read back unbound,\n * `matches` is false for every one, the plan reports fourteen updates for grants that\n * plainly exist, and the deploy PUTs each one before acl.ts's own read-back guard dies.\n * ★ THIS IS THE SAME CLASS AS storage.ts, sdn-zone.ts, sdn-vnet.ts AND api-token.ts, and it is\n * the worst instance of it: those three are gated and answer 403, which is at least an\n * error. A filtered endpoint answers success with less data, which is indistinguishable from\n * the object not being there.\n */\n readRole: 'provision',\n collection: () => 'access/acl',\n createForm: bind,\n /**\n * ⚠️ ONLY `propagate` IS COMPARED, AND ONLY ONCE THE GRANT IS THERE. path/type/ugid/roleid are\n * the FILTER that produced these attributes, not a reading of the cluster: comparing them with\n * the props they came from is true by construction. An identity change is a DIFFERENT grant,\n * which `diff` in the provider handles.\n */\n matches: (attributes, props) =>\n attributes.bound && attributes.propagate === (props.propagate !== false),\n path: () => 'access/acl',\n updateForm: bind,\n});\n\nexport const ProxmoxAclProvider = () =>\n Provider.effect(\n ProxmoxAcl,\n Effect.succeed(\n ProxmoxAcl.Provider.of({\n /**\n * ⛔ EMPTY LIKE EVERY OTHER RESOURCE HERE, AND MOST OF ALL THIS ONE. `GET /access/acl`\n * hands back every grant a human ever clicked; adopting them would let a later plan\n * DELETE somebody's access as tidy-up. Adoption is an explicit act.\n */\n list: () => Effect.succeed([]),\n read: Effect.fn(function* ({ olds }) {\n return yield* ops.read(olds);\n }),\n /**\n * ⛔ AN IDENTITY CHANGE IS A REPLACE, AND THE FACTORY CANNOT SAY SO ALONE — it answers\n * `replace` only for objects with no update path, and this one has PUT. Left to delegate,\n * editing `roleid` (or the subject, or the path) would PUT the NEW grant and LEAVE THE\n * OLD ONE BOUND: access nobody declared, held indefinitely, invisible in the plan because\n * the provider believes it converged. Replace makes Alchemy call `delete` with the OLD\n * props, which is the only thing that removes it.\n * ⚠️ CREATE-FIRST, DELIBERATELY (Alchemy's default; `deleteFirst: true` would invert it).\n * Delete-first could remove the very grant the provision credential mints against and\n * leave nothing able to put it back. The cost is that a NARROWING change leaves the\n * wider grant bound until Phase 2 collects the old generation.\n */\n diff: Effect.fn(function* ({ news, output }) {\n if (output !== undefined && isResolved(news) && identity(news) !== identity(output)) {\n return { action: 'replace' } as const;\n }\n return yield* ops.diff(news, output);\n }),\n /**\n * ⚠️ THE READ-BACK GUARD, RESTORED FOR A FAMILY WHOSE \"ABSENT\" IS NOT `undefined`.\n * `ops.reconcile` refuses when the object is still missing after a write, but missing\n * here is `bound: false`, which that check cannot see. PVE answers 200 with\n * `{\"data\":null}` on calls that did nothing: without this, a PUT that silently no-oped\n * is recorded as a landed grant and the next plan reads noop over the gap.\n */\n reconcile: Effect.fn(function* ({ news }) {\n const after = yield* ops.reconcile(news);\n if (!after.bound) {\n return yield* Effect.die(\n new Error(\n `access/acl: the write returned no error but ${identity(news)} is still not ` +\n 'bound. Either the PUT did nothing, or the read credential cannot see the ' +\n 'grant -- GET /access/acl is filtered to paths you may MODIFY permissions on, ' +\n 'so a read-only role is answered [] rather than 403.',\n ),\n );\n }\n return after;\n }),\n /**\n * ⛔ NOT `ops.destroy`, AND NOT AN OVERSIGHT. `DELETE /access/acl` is not implemented, so a\n * factory delete would fail every destroy — while looking like a permissions problem —\n * and leave the grant bound. Removal is the create call with `delete=1` and the identity\n * tuple, no `propagate`, because removal is keyed on the tuple and nothing else.\n *\n * ⚠️ IDEMPOTENT, AND SHARED: removing a grant that is already gone is a no-op, but the\n * tuple is cluster-global — re-read the second ⛔ in the header before assuming this\n * only takes away what this stack declared.\n */\n delete: Effect.fn(function* ({ olds }) {\n const removal = { delete: '1', ...tuple(olds) };\n yield* pve(olds.target, 'provision', 'PUT', 'access/acl', removal);\n }),\n }),\n ),\n );\n",
6
+ "/**\n * One authenticated call to the Proxmox VE API.\n *\n * ★ PLAIN `fetch`, NO TLS ESCAPE HATCH, AND THAT IS A MEASURED CHOICE RATHER THAN AN OMISSION.\n * Proxmox is usually met with `curl -k` because a fresh install serves its own self-signed\n * certificate — I reached for `-k` myself before checking. This cluster serves a real Let's\n * Encrypt certificate (`CN=cluster-tb4.example.com`), and strict TLS answers 401, i.e. the\n * handshake succeeds and only the credential is missing. So there is no `rejectUnauthorized`\n * option here to be left switched on by accident in somebody else's estate.\n *\n * ⚠️ EVERY PVE ANSWER IS WRAPPED IN `{\"data\": ...}`, errors included — a failed call can still be\n * HTTP 200 with `{\"data\": null}`. Unwrapping is not cosmetic; a caller that reads the envelope\n * as the payload sees `undefined` and calls it \"absent\".\n */\nimport * as Effect from 'effect/Effect';\nimport * as HttpClient from 'effect/unstable/http/HttpClient';\nimport * as HttpClientRequest from 'effect/unstable/http/HttpClientRequest';\nimport {\n type ApiTarget,\n type PveCredential,\n type PveRole,\n type PveTarget,\n authorization,\n} from './credentials.ts';\nimport { leased } from './lease-cache.ts';\nimport { executeOnCluster } from './members.ts';\n\nexport class PveError extends Error {\n constructor(\n readonly status: number,\n readonly method: string,\n readonly path: string,\n detail: string,\n ) {\n super(`PVE ${method} ${path} -> ${String(status)}: ${detail}`);\n this.name = 'PveError';\n }\n}\n\nconst clusterExhausted = (\n method: 'GET' | 'POST' | 'PUT' | 'DELETE',\n path: string,\n attempts: ReadonlyArray<{ member: string; why: string }>,\n) =>\n new PveError(\n 0,\n method,\n path,\n `all members failed: ${attempts.map((a) => `${a.member} (${a.why})`).join('; ')}`,\n );\n\n/**\n * A form body, where a value may be a LIST.\n *\n * ⛔ PVE AND PBS SPELL A MULTI-VALUED FIELD DIFFERENTLY, AND THE LIST FORM IS FOR PBS. PBS is Rust:\n * its schemas use `type: array` — `delete` on every update endpoint is one — and its urlencoded\n * decoder builds that array from REPEATED KEYS (`delete=a&delete=b`). PVE's Perl takes a comma\n * string for the same idea, which is what `withClears` in values.ts produces, and for the one\n * PVE field that genuinely needs repetition it wants a NUL-joined value instead (see\n * notification-target.ts). So: PVE callers pass strings and are unaffected; a PBS caller that\n * needs an array passes one and gets repeated keys rather than reaching for PVE's encoding.\n */\nexport type PveForm = Record<string, readonly string[] | string>;\n\n/** ⚠️ `append`, NOT `set`: a repeated key is the point, and `set` would keep only the last. */\nconst encode = (form: PveForm): string => {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(form)) {\n if (typeof value === 'string') params.append(key, value);\n else for (const item of value) params.append(key, item);\n }\n return params.toString();\n};\n\nconst buildRequest = (\n method: 'GET' | 'POST' | 'PUT' | 'DELETE',\n apiBase: string,\n path: string,\n credential: PveCredential,\n target: ApiTarget,\n form?: PveForm,\n) => {\n const url = `${apiBase}/${path}`;\n /**\n * ⛔ THE CONTENT TYPE IS AN ARGUMENT TO `bodyText`, NOT AN ENTRY IN THE HEADER MAP, AND GETTING\n * THAT WRONG MADE EVERY WRITE IN THIS PACKAGE FAIL.\n *\n * 🔴 THE BUG, AND HOW IT HID FOR A WHOLE DAY. The header map DID set\n * `application/x-www-form-urlencoded` — and `bodyText(s)` with no second argument sets\n * `text/plain` and OVERWRITES it, because it is piped AFTER `setHeaders`. PVE and PBS accept\n * ONLY form encoding or JSON and reject everything else outright (measured in\n * proxmox-rest-server's `get_request_parameters`), so every create, update and delete this\n * package can perform was broken from the day the client was written.\n * ⛔ NOTHING CAUGHT IT BECAUSE NOTHING HAD EVER WRITTEN. Ninety-eight resources were adopted\n * against the live cluster and every one matched, so `reconcile` never reached a PUT. The\n * identical bug in house/forgejo/src/client.ts surfaced the moment a write token existed\n * and answered `422 Unsupported Content-Type`; this one is the same line, found by looking.\n * ★ A PLAN THAT SAYS `noop` PROVES THE READ PATH AND NOTHING ELSE. That is the lesson worth\n * more than the fix.\n *\n * ⚠️ PVE TAKES FORM ENCODING, NOT JSON. Sending application/json is accepted and then SILENTLY\n * IGNORED on several endpoints, which reads as \"the API did nothing\" rather than as a wrong\n * content type — so the type below is load bearing in both directions.\n */\n return HttpClientRequest.make(method)(url).pipe(\n HttpClientRequest.setHeaders({ Authorization: authorization(credential, target) }),\n form === undefined\n ? (self) => self\n : HttpClientRequest.bodyText(encode(form), 'application/x-www-form-urlencoded'),\n );\n};\n\nconst executeOne = (\n target: ApiTarget,\n credential: PveCredential,\n method: 'GET' | 'POST' | 'PUT' | 'DELETE',\n path: string,\n form: PveForm | undefined,\n apiBase: string,\n) =>\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient;\n const request = buildRequest(method, apiBase, path, credential, target, form);\n return yield* client\n .execute(request)\n .pipe(Effect.mapError((cause) => new PveError(0, method, path, String(cause))));\n });\n\nconst readResponse = <T>(\n response: {\n status: number;\n text: Effect.Effect<string, unknown>;\n json: Effect.Effect<unknown, unknown>;\n },\n method: string,\n path: string,\n) =>\n Effect.gen(function* () {\n /**\n * ⛔ STATUS FIRST, THEN THE BODY, AND THE BODY IS READ EXACTLY ONCE. `text` and `json` both\n * consume the response stream, so asking for both is a bug waiting to happen. A failure is\n * read as TEXT because an error body is not reliably JSON — PVE answers HTML for some 5xx —\n * and a success is read as JSON by the client rather than by a hand-rolled `JSON.parse`.\n */\n if (response.status < 200 || response.status >= 300) {\n // ⚠️ 401 HERE USUALLY MEANS THE LEASE EXPIRED, NOT THAT THE ROLE IS WRONG. `provision` is a\n // 300s non-renewable lease; a long reconcile should mint again rather than widen the role.\n const detail = yield* response.text.pipe(Effect.orElseSucceed(() => ''));\n return yield* Effect.fail(new PveError(response.status, method, path, detail.slice(0, 300)));\n }\n const body = (yield* response.json.pipe(\n Effect.mapError((cause) => new PveError(0, method, path, String(cause))),\n )) as { data?: T };\n return body.data;\n });\n\n/** A call that already holds a credential. Used when one mint serves several calls. */\nexport const pveWith = <T>(\n target: ApiTarget,\n credential: PveCredential,\n method: 'GET' | 'POST' | 'PUT' | 'DELETE',\n path: string,\n form?: PveForm,\n) =>\n Effect.gen(function* () {\n const response =\n target.scheme === 'pve'\n ? yield* executeOnCluster(target, method, path, (apiBase) =>\n buildRequest(method, apiBase, path, credential, target, form),\n ).pipe(\n Effect.mapError((failure) =>\n failure.tag === 'cluster'\n ? clusterExhausted(failure.method, failure.path, failure.attempts)\n : new PveError(0, method, path, String(failure)),\n ),\n )\n : yield* executeOne(target, credential, method, path, form, target.api);\n return yield* readResponse<T>(response, method, path);\n });\n\n/**\n * Like `pveWith`, but returns the full JSON body — for endpoints whose answer lives beside `data`.\n *\n * ⚠️ `network-apply-read.ts` is the caller today; the local fetch there should fold into this once\n * the envelope shape is stable across both paths.\n */\nexport const pveEnvelopeWith = (\n target: PveTarget,\n credential: PveCredential,\n method: 'GET' | 'POST' | 'PUT' | 'DELETE',\n path: string,\n) =>\n Effect.gen(function* () {\n const response = yield* executeOnCluster(target, method, path, (apiBase) =>\n buildRequest(method, apiBase, path, credential, target),\n ).pipe(\n Effect.mapError((failure) =>\n failure.tag === 'cluster'\n ? clusterExhausted(failure.method, failure.path, failure.attempts)\n : new PveError(0, method, path, String(failure)),\n ),\n );\n if (response.status < 200 || response.status >= 300) {\n const detail = yield* response.text.pipe(Effect.orElseSucceed(() => ''));\n return yield* Effect.fail(new PveError(response.status, method, path, detail.slice(0, 300)));\n }\n return (yield* response.json.pipe(\n Effect.mapError((cause) => new PveError(0, method, path, String(cause))),\n )) as Record<string, unknown>;\n });\n\n/**\n * Make one call on a credential for `role`, REUSING a still-valid lease rather than minting one.\n *\n * 🔴 IT USED TO MINT PER CALL, AND AT 98 RESOURCES THAT STOPPED BEING FREE. One plan plus deploy\n * of the TB4 stack left 760 token entries in `/etc/pve/user.cfg` — read, diff, reconcile and the\n * read-back each minted their own, and `/etc/pve` is a replicated cluster filesystem every node\n * has to agree on. src/lease-cache.ts carries the measurement and the safety argument.\n *\n * ⚠️ `pveWith` IS STILL THERE AND STILL TAKES AN EXPLICIT CREDENTIAL. network-apply.ts needs ONE\n * identity across its apply and its task poll — PVE only skips the task-status privilege check\n * for the task's OWNER — and it threads a lease through by hand for that. Caching makes that\n * property easier to hold, never weaker, but the explicit path stays because that caller is\n * reasoning about identity rather than about cost.\n *\n * ★ TASK POLL ON A DIFFERENT MEMBER THAN THE APPLY STILL HOLDS: the owner is the token id, not the\n * node that received the PUT. Any member serves any task path; the privilege skip is keyed on\n * whether the caller IS the task's owner.\n */\nexport const pve = <T>(\n target: ApiTarget,\n role: PveRole,\n method: 'GET' | 'POST' | 'PUT' | 'DELETE',\n path: string,\n form?: PveForm,\n) =>\n Effect.gen(function* () {\n const credential = yield* leased(target, role);\n return yield* pveWith<T>(target, credential, method, path, form);\n });\n",
7
+ "/**\n * The PVE credential a reconcile runs with: minted from OpenBao, alive for five minutes.\n *\n * ⛔ THERE IS NO STATIC WRITE TOKEN IN THIS ESTATE, AND THAT IS DELIBERATE. Every PVE token stored\n * in `kv/infra/proxmox/*` is read-only — PVEAuditor on media/ops/tb4, Audit on pbs, all as\n * `monitoring@pve`. The MCP proxmox client says why in its own header: the auditor token bounds\n * what a BUG can do, independently of what the code bounds. Adding a long-lived write token to\n * that shelf would delete the outer lock for every reader of the shelf, not just for this\n * provider.\n *\n * ★ SO WRITES COME FROM A DYNAMIC MOUNT INSTEAD, which the estate already built: `proxmox-tb4/`\n * exposes two roles — `read` (ttl 3600s) and `provision` (ttl 300s, max 1800s, NOT renewable).\n * A mint returns a PVE API token of its own, `hf-provision@pve!hf-provision-…-<timestamp>-<id>`,\n * which expires on its own whether or not anything cleans up. Same shape as\n * `cloudflare-<account>-<surface>/creds/<role>`, same reason.\n * ⚠️ THAT PATH IS WRITTEN WITH `<surface>` RATHER THAN A GLOB ON PURPOSE: a `*` followed by\n * a slash CLOSES THIS BLOCK COMMENT, and everything below it then parses as code. It cost\n * six TS1005/TS1443 errors pointing at innocent lines twenty rows further down.\n *\n * ⚠️ FIVE MINUTES IS THE DESIGN, NOT AN OBSTACLE. A reconcile that cannot finish inside the lease\n * should mint again rather than ask for a longer one: the short lease is what makes a leaked\n * token uninteresting. `provision` is explicitly non-renewable, so there is no renew path to\n * reach for.\n *\n * ⛔ THE SECRET NEVER TOUCHES DISK, A LOG, OR ALCHEMY STATE. Alchemy persists resource attributes\n * WITHOUT encryption — StateEncoding.ts writes `Redacted` as `{\"@redacted\": <plaintext>}` — and\n * this estate's state store is the `alchemy` Postgres, which pg-backup.sh dumps nightly. A PVE\n * secret that reached an attribute would outlive its 300s lease by months, in four places.\n * Nothing here returns it to a resource; it is used to build a header and then dropped.\n */\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\nimport * as FetchHttpClient from 'effect/unstable/http/FetchHttpClient';\nimport * as Headers from 'effect/unstable/http/Headers';\nimport * as HttpClient from 'effect/unstable/http/HttpClient';\nimport * as HttpClientRequest from 'effect/unstable/http/HttpClientRequest';\n\n/**\n * ★ NO SESSION, ON PURPOSE, AND THIS IS WHAT UNBLOCKED `wip/bao-policy`.\n * `CommandExecutor.run` requires a `ScopedPlanStatusSession`, and Alchemy gives one to\n * `reconcile` and `delete` but NOT to `read` or `diff` — so a provider built on `run` can only\n * ever write. Alchemy's OWN Docker provider does not use `CommandExecutor` for this at all: it\n * takes `ChildProcessSpawner` and pipes `ChildProcess.make(...)` through `spawner.spawn`, which\n * needs a `Scope` and nothing else (Docker.ts:476-553). That was the pattern here until\n * 2026-09-14, when `mint` moved to `HttpClient` — which needs no session either, so `mint` is\n * still callable from all four operations.\n *\n * ⛔ DO NOT SATISFY THE OLD SIGNATURE BY FAKING A SESSION. A session carries plan status Alchemy\n * uses to report progress; inventing one would make read and diff report work they are not doing.\n */\n/** Which role a call needs. `read` for read/diff, `provision` for reconcile/delete. */\nexport type PveRole = 'read' | 'provision';\n\n/**\n * Where credentials come from, and which cluster they are for.\n *\n * ⚠️ A PARAMETER, NOT A CONSTANT, SO THIS PACKAGE CAN LEAVE THE ESTATE. Everything\n * HomeFlare-specific — the mount name, the API host — belongs in the stack that declares\n * resources, not in the provider. Anyone with an OpenBao mount that vends Proxmox API tokens can\n * use this file unchanged; that is the whole difference between a provider and a script.\n */\nexport type PveTarget = {\n /** OpenBao mount that vends API tokens for this host, e.g. `proxmox-tb4`. */\n readonly mount: string;\n /**\n * mgmt hostnames for cluster members, e.g. `n2.mgmt.example.com`. Any member's :8006 API\n * manages the whole cluster; `client.ts` failovers across them.\n */\n readonly members: readonly string[];\n /**\n * Which product answers at `api`. Defaults to `pve`.\n *\n * ★ PBS IS THE SAME CLIENT WITH A DIFFERENT AUTHORIZATION HEADER, AND THAT IS WHY THERE IS NO\n * SECOND CLIENT HERE. Proxmox Backup Server speaks the same `/api2/json` paths, wraps every\n * answer in the same `{\"data\": …}` envelope, and its OpenBao mount vends the same\n * `{token_id, secret}` shape — so `mint`, `pve()` and `pveOperations` all work against it\n * unchanged. The ONE difference is the header scheme: PVE spells it\n * `PVEAPIToken=<id>=<secret>` and PBS spells it `PBSAPIToken=<id>:<secret>` — a different\n * prefix AND a different separator.\n *\n * ⛔ IT IS REQUIRED, NOT OPTIONAL, AND THAT IS THE WHOLE TYPE-SAFETY ARGUMENT. A PBS target and\n * a PVE target are the same two strings, so with an OPTIONAL discriminant TypeScript's\n * structural typing would accept a PBS host wherever a PVE one belongs — and `pve()` would\n * then build `PVEAPIToken=<id>=<secret>` against a server wanting\n * `PBSAPIToken=<id>:<secret>`. Every call 401s, `pveOperations.read` folds that into \"absent\",\n * the plan says CREATE for an object that is plainly there, the POST is refused, and not one\n * symptom points at the header. Required, the mistake is a compile error instead.\n *\n * ⚠️ REASONED FROM PBS'S DOCUMENTED SCHEME, NOT MEASURED. The estate has no PBS credential yet\n * (there is no PBS mount in OpenBao), and an unauthenticated probe cannot tell the schemes\n * apart — `https://pbs.example.com:8007/api2/json/nodes` answers 401 to a missing header, a\n * PVE-shaped one and a PBS-shaped one alike. The first real token will confirm or correct it,\n * and a wrong guess fails closed with a 401 rather than doing something odd.\n */\n readonly scheme: 'pve';\n};\n\n/** The same client against a Proxmox Backup Server. See the ⛔ on `scheme` above. */\nexport type PbsTarget = {\n readonly mount: string;\n readonly api: string;\n readonly scheme: 'pbs';\n};\n\n/** Either product. What `pve()` and `pveOperations` accept; what a RESOURCE accepts is narrower. */\nexport type ApiTarget = PbsTarget | PveTarget;\n\n/**\n * What a mint returns.\n *\n * ⚠️ `secret` IS PRESENT AND MUST NOT BE PERSISTED. It is typed as a plain string rather than\n * `Redacted` on purpose: Alchemy's Redacted is a STATE-ENCODING marker, not encryption, so\n * wrapping it would imply a protection that does not exist. The protection here is that this\n * value never leaves the function that builds the Authorization header.\n */\nexport type PveCredential = {\n /** `hf-provision@pve!hf-provision-…` — an identifier, safe to log. */\n readonly tokenId: string;\n /** ⛔ NEVER LOG, NEVER PERSIST, NEVER RETURN FROM A RESOURCE. */\n readonly secret: string;\n /** Seconds the lease was granted for, as reported by OpenBao. */\n readonly leaseSeconds: number;\n};\n\n/** The environment `mint` resolves OpenBao from — `process.env` unless a test passes its own. */\nexport type BaoEnvironment = Readonly<Record<string, string | undefined>>;\n\n/** openbao v2.6.2 api/env.go:22-34 — a present BAO_* wins, even empty; else its VAULT_* twin. */\nconst baoVariable = (env: BaoEnvironment, name: string) =>\n env[`BAO_${name}`] ?? env[`VAULT_${name}`] ?? '';\n\n/**\n * Mint one credential for `role`: `GET /v1/<mount>/creds/<role>` on OpenBao's HTTP API.\n *\n * 🔴 IT SHELLED OUT TO `bao read -format=json` UNTIL 2026-09-14. The case for the CLI was that one\n * client could not disagree with `bao kv get` about what this machine may do. house/openbao then\n * learned twice what deciding by stderr costs — every failure read as absent, and two commands\n * said \"absent\" in different words — so this reads STATUS CODES: 2xx is a credential, and 403\n * (denied), 404 (no such role or mount — a mint has no \"absent\"), 503 (sealed) all fail.\n * ★ THE ENVIRONMENT CONTRACT IS STILL THE CLI's, READ THE CLI's WAY, which keeps the case above\n * true (openbao v2.6.2 api/client.go:34-66, 370, 503-507, 761-762, 776-785): BAO_AGENT_ADDR over\n * BAO_ADDR over https://127.0.0.1:8200; BAO_NAMESPACE as X-Vault-Namespace; BAO_TOKEN as\n * X-Vault-Token; X-Vault-Request always. house/openbao/src/bao-address.ts has the long form.\n * ★ AGENT MODE IS NO BAO_TOKEN AND NO TOKEN HEADER. An Agent or Proxy listener with\n * `api_proxy { use_auto_auth_token = true }` (or the older `cache { … }`) substitutes its\n * auto-auth token exactly when a request carries none — command/agentproxyshared/cache/handler.go\n * :29-38, command/agent.go:517-541, command/agent/config/config.go:288-292, and\n * website/content/docs/agent-and-proxy/agent/apiproxy.mdx:57-62. The CLI's token-file fallback\n * is deliberately not read. ⚠️ So an unset BAO_TOKEN aimed at a SERVER rather than an agent is a\n * 403, which reads like a missing grant rather than a missing variable.\n * ★ UNIX SOCKETS: `unix:///path` is plain HTTP to `localhost` over that socket, as the CLI does it\n * (api/client.go:654-667). Bun's fetch takes a `unix` option; `FetchHttpClient.RequestInit` is\n * Effect's documented way to pass fetch options, read from the calling fiber (effect\n * FetchHttpClient.ts:59-72). Off Bun it REFUSES, rather than reach http://localhost:80.\n */\nexport const mint = (target: ApiTarget, role: PveRole, env: BaoEnvironment = process.env) =>\n Effect.gen(function* () {\n const path = `${target.mount}/creds/${role}`;\n // ⛔ METHOD, PATH AND OpenBao's `errors` ONLY — never a header (the token), never a success\n // body (the credential is IN it, so echoing it would print the secret into a log).\n const refuse = (status: number, detail: string) =>\n new Error(`OpenBao GET /v1/${path} -> ${status === 0 ? 'no response' : status}: ${detail}`);\n const address =\n baoVariable(env, 'AGENT_ADDR') || baoVariable(env, 'ADDR') || 'https://127.0.0.1:8200';\n const socket = address.startsWith('unix://') ? address.slice('unix://'.length) : undefined;\n const base = socket === undefined ? address.replace(/\\/+$/, '') : 'http://localhost';\n const headers: Record<string, string> = { 'X-Vault-Request': 'true' };\n const namespace = baoVariable(env, 'NAMESPACE');\n if (namespace !== '') headers['X-Vault-Namespace'] = namespace;\n const token = baoVariable(env, 'TOKEN');\n if (token !== '') headers['X-Vault-Token'] = token;\n if (socket !== undefined && !('Bun' in globalThis)) {\n return yield* Effect.fail(refuse(0, 'a unix:// address needs Bun fetch; this is not Bun'));\n }\n\n const client = yield* HttpClient.HttpClient;\n // ⛔ Effect records request headers on the client span, and its default redaction list does\n // not name x-vault-token (effect Headers.ts:753-762). It is added for this call.\n const redacted = yield* Headers.CurrentRedactedNames;\n const defaults = Option.getOrElse(\n yield* Effect.serviceOption(FetchHttpClient.RequestInit),\n () => ({}),\n );\n const request = HttpClientRequest.get(`${base}/v1/${path}`).pipe(\n HttpClientRequest.setHeaders(headers),\n );\n const exchange = client.execute(request).pipe(\n Effect.flatMap((response) =>\n Effect.map(response.text, (text) => ({ status: response.status, text })),\n ),\n // ⚠️ The CLI's default client timeout (api/client.go:324) — a hung agent must not hang a plan.\n Effect.timeout('60 seconds'),\n Effect.provideService(Headers.CurrentRedactedNames, [...redacted, 'x-vault-token']),\n );\n // ⚠️ `| undefined` under exactOptionalPropertyTypes: `socket` is narrowed to a string\n // only on the branch below, so the object literal genuinely carries\n // `unix: string | undefined` and the type must say so. The alternative — building\n // the key conditionally — hides that this request is the unix-socket path.\n const init: RequestInit & { unix?: string | undefined } = { ...defaults, unix: socket };\n const { status, text } = yield* (\n socket === undefined\n ? exchange\n : Effect.provideService(exchange, FetchHttpClient.RequestInit, init)\n ).pipe(\n // ⛔ `.message` only — the error object holds the request, and the request holds the token.\n Effect.mapError((cause) => refuse(0, cause.message)),\n );\n\n let parsed:\n | {\n lease_duration?: unknown;\n data?: { token_id?: unknown; secret?: unknown };\n errors?: unknown;\n }\n | undefined;\n try {\n parsed = JSON.parse(text) as typeof parsed;\n } catch {\n parsed = undefined;\n }\n if (status < 200 || status >= 300) {\n const errors = parsed?.errors;\n const detail = Array.isArray(errors)\n ? errors.map(String).join('; ')\n : 'not an OpenBao error body';\n return yield* Effect.fail(refuse(status, detail || '(no errors given)'));\n }\n const tokenId = parsed?.data?.token_id;\n const secret = parsed?.data?.secret;\n if (typeof tokenId !== 'string' || typeof secret !== 'string') {\n // ⛔ REFUSE RATHER THAN RETURN A HALF CREDENTIAL, and again WITHOUT quoting the body.\n return yield* Effect.fail(\n new Error(\n `${target.mount}/creds/${role} returned no token_id/secret. Either this approle lacks ` +\n `the grant, or the mount is not ${target.mount}. Say which mount and role you needed ` +\n `than falling back to a stored credential -- every stored PVE token is read-only.`,\n ),\n );\n }\n const lease = parsed?.lease_duration;\n const leaseSeconds = typeof lease === 'number' ? lease : 0;\n return { leaseSeconds, secret, tokenId } satisfies PveCredential;\n });\n\n/**\n * The header PVE wants. `PVEAPIToken=<tokenid>=<secret>`.\n *\n * ⚠️ THE SEPARATOR IS `=`, NOT `:`. Proxmox rejects the colon form with a 401 that says only\n * \"authentication failure\", which reads as a bad credential rather than as a malformed header.\n */\nexport const authorization = (credential: PveCredential, target: ApiTarget): string =>\n target.scheme === 'pbs'\n ? `PBSAPIToken=${credential.tokenId}:${credential.secret}`\n : `PVEAPIToken=${credential.tokenId}=${credential.secret}`;\n",
8
+ "/**\n * One credential per (target, role) for the life of a run, instead of one per API call.\n *\n * 🔴 THE MEASUREMENT THAT MADE THIS NECESSARY. A single `alchemy plan` plus `deploy` of the TB4\n * stack — 98 resources — left **760 API token entries in `/etc/pve/user.cfg`**, counted on n2\n * immediately afterwards. `mint()` asked OpenBao for a new credential on EVERY call, and each\n * mint creates a real Proxmox token: read, diff, reconcile and read-back each got their own. They\n * drain as the leases expire (760 down to 712 over five minutes), so nothing was broken — but\n * `/etc/pve` is pmxcfs, a REPLICATED cluster filesystem, and every one of those mints is a write\n * to it that all three nodes must agree on. Two plans in quick succession stack thousands.\n *\n * ⛔ AND ON PBS THE COST IS SECONDS, NOT BYTES. `pbs_grant.go` waits for PBS to honour a freshly\n * granted ACL before handing the credential over — measured at about 4.5s, and unavoidable,\n * because PBS caches its parsed ACL config. Per mint. The ten PBS resources in pbs.ts would pay\n * that ten times over for credentials identical to each other.\n *\n * ★ SO THE FIX IS TO STOP THROWING AWAY A CREDENTIAL THAT IS STILL VALID. This is strictly FEWER\n * credentials in existence at once, not more: the lease TTL is untouched, and a token that would\n * have been minted and abandoned is simply never minted. It is the same reasoning\n * `network-apply.ts` already applies by hand when it threads one lease through `pveWith` for its\n * apply and its task poll.\n *\n * ⚠️ THE CACHE IS PROCESS-SCOPED AND THAT IS THE INTENDED LIFETIME. A plan or a deploy is one\n * process; the next one starts cold. Nothing is written to disk, and a credential never outlives\n * the run that minted it.\n *\n * ⛔ IT IS NOT A PERFORMANCE CACHE, SO IT MUST NEVER SERVE A CREDENTIAL THAT COULD DIE MID-CALL.\n * The provision lease is 300s and a deploy can run longer than that. A credential handed out at\n * t+299 would fail the call it was handed to, and the failure surfaces as a 401 — which `read`\n * folds into \"absent\", which is how a plan comes to say CREATE for an object that exists. That is\n * the exact class of bug this package found three times in one day, so the margin below is\n * deliberately generous rather than tuned.\n *\n * ★ THE MECHANISM IS EFFECT'S OWN `Cache`, AND THE HAND-WRITTEN ONE IT REPLACED WAS WRONG IN\n * EXACTLY THE PLACE A LIBRARY IS NOT. A TTL map alone still minted 89 credentials for 98\n * resources, because Alchemy plans concurrently and every resource missed in the same instant;\n * the in-flight map added to fix that got the first miss right and the failure path wrong. A\n * waiter woken by a FAILED or uncacheable mint claimed the slot without looking again, the\n * waiters overwrote each other's claims, and each one's cleanup deleted somebody else's — the\n * thundering herd back through the error door (found in review 2026-09-14, confirmed by\n * reading). `Cache.get` shares one pending lookup among concurrent callers by design. MEASURED\n * with a probe before this was written: ten concurrent gets on equal-but-distinct key objects ran\n * the lookup once; a zero time-to-live ran it again for the next caller; a failure reached all\n * ten waiters and was not kept.\n */\nimport * as Cache from 'effect/Cache';\nimport * as Duration from 'effect/Duration';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport { type ApiTarget, type PveCredential, type PveRole, mint } from './credentials.ts';\n\n/**\n * Re-mint once a lease is inside this much of its end, in seconds.\n *\n * ⚠️ 60s AGAINST A 300s PROVISION LEASE MEANS A CACHED CREDENTIAL IS ONLY EVER HANDED OUT WITH AT\n * LEAST A MINUTE LEFT. The slowest single call in this package is `network-apply`'s reload poll,\n * and that mints its own lease deliberately — see the ⚠️ on `pveWith` there — so nothing using\n * this cache comes near a minute.\n * ⚠️ A MOUNT REPORTING NO `lease_duration` IS NEVER CACHED: `leaseSeconds` is `0` and\n * `timeToLive` answers zero. Not caching is always safe; caching a credential whose lifetime is\n * unknown is not.\n */\nconst REMINT_MARGIN_SECONDS = 60;\n\n/**\n * What a credential is cached under.\n *\n * ⛔ KEYED ON THE OPENBAO MOUNT AND ROLE, NOT ON A MEMBER HOSTNAME. A PVE API token is\n * cluster-wide — `user.cfg` is replicated — so n2, n3 and n4 share one credential. Keying on\n * `api` would mint three identical tokens when failover rotates members.\n * ★ THE MOUNT CANNOT COLLIDE ACROSS CLUSTERS: `proxmox-tb4`, `proxmox-ops` and `pbs-tb4` are\n * distinct OpenBao mounts with distinct policies; two estates never share a mount name.\n * ★ A PLAIN OBJECT IS A SAFE KEY BECAUSE EFFECT COMPARES KEYS STRUCTURALLY — two separately built\n * literals with the same fields are one entry, which the probe above measured.\n */\nexport type LeaseKey = {\n readonly mount: string;\n readonly role: PveRole;\n readonly scheme: ApiTarget['scheme'];\n};\n\nconst keyOf = (target: ApiTarget, role: PveRole): LeaseKey => ({\n mount: target.mount,\n role,\n scheme: target.scheme,\n});\n\n/**\n * How long a freshly minted credential may be handed out again.\n *\n * ⛔ ZERO FOR A FAILURE, FOR AN UNKNOWN LIFETIME AND FOR A LEASE INSIDE THE MARGIN. Zero means \"do\n * not keep\": the callers already waiting on THIS mint still receive its result, and the next\n * caller mints again. Keeping a failure would turn one refused mint into a refused run.\n * ⚠️ EXPORTED FOR THE TEST. The margin is the whole safety property, so it is pinned from both\n * sides of its edge without waiting four minutes of wall clock.\n */\nexport const timeToLive = (exit: Exit.Exit<PveCredential, unknown>): Duration.Duration =>\n Exit.isSuccess(exit) && exit.value.leaseSeconds > REMINT_MARGIN_SECONDS\n ? Duration.seconds(exit.value.leaseSeconds - REMINT_MARGIN_SECONDS)\n : Duration.zero;\n\n/**\n * A lease cache over any mint.\n *\n * ⚠️ ONE BEHAVIOUR CHANGED WITH THE MOVE TO `Cache`, DELIBERATELY. Callers waiting on a mint that\n * FAILS now receive that failure, where the hand-written version had each of them mint again.\n * They asked in the same instant for the same credential, and a plan with one failed resource\n * fails either way — so the change is in how many errors the output lists, not in the outcome,\n * and a sealed vault is asked once rather than ninety-eight times.\n * ★ `requireServicesAt: 'lookup'` IS WHAT LETS IT BE BUILT ONCE, AT IMPORT. The mint needs an\n * `HttpClient`; that requirement moves to each `get`, where every caller already has one.\n * ⚠️ EXPORTED FOR THE TEST, which hands it a counting mint instead of calling OpenBao.\n */\nexport const makeLeases = <E, R>(mintFor: (key: LeaseKey) => Effect.Effect<PveCredential, E, R>) =>\n Cache.makeWith(mintFor, { capacity: 64, requireServicesAt: 'lookup', timeToLive });\n\nconst targetForKey = (key: LeaseKey): ApiTarget =>\n key.scheme === 'pbs'\n ? { api: 'https://pbs.invalid/api2/json', mount: key.mount, scheme: 'pbs' }\n : { members: [], mount: key.mount, scheme: 'pve' };\n\nconst leases = Effect.runSync(makeLeases((key) => mint(targetForKey(key), key.role)));\n\n/**\n * A credential for `role` on `target`: a still-valid lease when one is kept, one shared mint when\n * not.\n *\n * ★ client.ts is the one place that decides to use the cache. `mint` stays exported and unchanged\n * for the caller that reasons about identity rather than cost — network-apply.ts.\n */\nexport const leased = (target: ApiTarget, role: PveRole) => Cache.get(leases, keyOf(target, role));\n",
9
+ "/**\n * TB4 cluster members: ordered failover, last-good preference, transport classification.\n *\n * ★ ANY MEMBER'S :8006 API MANAGES THE WHOLE CLUSTER — PVE proxies node paths itself — so the\n * provider reaches the cluster through whichever member is up, not through one pinned node.\n *\n * ⛔ NEVER cluster-tb4.example.com: it resolves to 10.20.10.250, which nothing serves.\n */\nimport * as Effect from 'effect/Effect';\nimport * as Result from 'effect/Result';\nimport * as HttpClient from 'effect/unstable/http/HttpClient';\nimport * as HttpClientError from 'effect/unstable/http/HttpClientError';\nimport type * as HttpClientRequest from 'effect/unstable/http/HttpClientRequest';\nimport type * as HttpClientResponse from 'effect/unstable/http/HttpClientResponse';\nimport type { PveTarget } from './credentials.ts';\n\nexport const PVE_API_PORT = 8006;\n\n/** Strict TLS, always :8006 — each node's certificate carries its mgmt name as a SAN. */\nexport const pveApiBase = (member: string) => `https://${member}:${String(PVE_API_PORT)}/api2/json`;\n\n/** Process-scoped last member that answered, keyed by OpenBao mount (= one PVE cluster). */\nconst lastGoodByMount = new Map<string, string>();\n\n/** ⚠️ TESTS ONLY — resets sticky member choice between cases. */\nexport const resetLastGoodForTest = () => lastGoodByMount.clear();\n\nexport const noteGoodMember = (target: PveTarget, member: string) => {\n lastGoodByMount.set(target.mount, member);\n};\n\n/** Last-good first, then the rest in configuration order. */\nexport const orderedMembers = (target: PveTarget): readonly string[] => {\n const preferred = lastGoodByMount.get(target.mount);\n if (preferred === undefined || !target.members.includes(preferred)) return target.members;\n return [preferred, ...target.members.filter((member) => member !== preferred)];\n};\n\nconst errorCode = (cause: unknown): string | undefined => {\n if (cause !== null && typeof cause === 'object') {\n if ('code' in cause && typeof cause.code === 'string') return cause.code;\n if ('cause' in cause) return errorCode((cause as { cause: unknown }).cause);\n }\n return undefined;\n};\n\nconst isTimeoutCause = (cause: unknown): boolean => {\n const code = errorCode(cause);\n if (code === 'AbortError' || code === 'ETIMEDOUT' || code === 'UND_ERR_CONNECT_TIMEOUT') {\n return true;\n }\n return cause instanceof Error && /timed out|timeout/i.test(cause.message);\n};\n\n/**\n * Error codes that PROVE the request never left this machine.\n *\n * ★ MEASURED 2026-09-14 through Effect's FetchHttpClient on Bun 1.4. The codes are Bun's, not\n * Node's, which made the first draft's Node-only list dead code for the commonest case:\n * connection refused cause.code = \"ConnectionRefused\" (Node says ECONNREFUSED)\n * name does not resolve cause.code = \"ENOTFOUND\"\n * wrong certificate name cause.code = \"ERR_TLS_CERT_ALTNAME_INVALID\"\n * no answer after connect Effect's TimeoutError — not an HttpClientError at all\n * ⛔ CODES ONLY, NEVER MESSAGE TEXT. The first draft also matched /TLS|SSL|certificate/ in the\n * message, and a connection that drops mid-response can mention TLS too — which would have sent a\n * write that had already landed to a second node.\n * ⚠️ A CERTIFICATE failure is pre-send: the handshake has to finish before a byte of the request is\n * written. A generic ERR_SSL_* is deliberately absent, because it can happen mid-stream.\n */\nconst PRE_SEND_CODES = new Set(['ConnectionRefused', 'ECONNREFUSED', 'ENOTFOUND', 'EAI_AGAIN']);\n\nconst isCertificateCode = (code: string) =>\n /^(ERR_TLS_CERT_|CERT_|UNABLE_TO_VERIFY_|DEPTH_ZERO_SELF_SIGNED|SELF_SIGNED_CERT)/.test(code);\n\nconst isPreSendCause = (cause: unknown): boolean => {\n const code = errorCode(cause);\n return code !== undefined && (PRE_SEND_CODES.has(code) || isCertificateCode(code));\n};\n\n/**\n * Effect HttpClientError.reason._tag — see effect HttpClientError.ts RequestError vs ResponseError.\n * ★ TransportError | InvalidUrlError | EncodeError occur before a response exists; StatusCodeError\n * and kin include a response. client.execute does NOT filter status, so HTTP answers are never\n * TransportError — only the transport layer is.\n */\nexport const isTransportFailure = (cause: unknown): boolean => {\n if (!HttpClientError.isHttpClientError(cause)) return false;\n const tag = cause.reason._tag;\n return tag === 'TransportError' || tag === 'InvalidUrlError' || tag === 'EncodeError';\n};\n\n/** Pre-send only: connection refused, DNS, a certificate refused — never a timeout after connect. */\nexport const isPreSendTransport = (cause: unknown): boolean => {\n if (!HttpClientError.isHttpClientError(cause)) return false;\n const { reason } = cause;\n if (reason._tag === 'InvalidUrlError' || reason._tag === 'EncodeError') return true;\n if (reason._tag === 'TransportError') {\n if (isTimeoutCause(reason.cause)) return false;\n return isPreSendCause(reason.cause);\n }\n return false;\n};\n\nexport const describeTransport = (cause: unknown): string => {\n if (HttpClientError.isHttpClientError(cause)) return cause.message;\n return String(cause);\n};\n\nexport type MemberAttempt = { readonly member: string; readonly why: string };\n\nexport type PveMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';\n\n/**\n * Run one request against cluster members with failover.\n *\n * ⛔ A POST/PUT/DELETE WHOSE REQUEST MAY HAVE REACHED A MEMBER MUST NOT BE SENT AGAIN TO ANOTHER.\n * Only fail over a write on a provably pre-send transport failure — connection refused, DNS or a\n * refused certificate. A timeout after sending is NOT pre-send: fail it, never repeat it. An HTTP\n * status of any kind, including 5xx and PVE's 596, is the answer from a live member — retrying\n * elsewhere can repeat a write.\n *\n * ★ Reads fail over on any transport failure, including timeout — no side effect to duplicate.\n * MEASURED 2026-09-14: full TB4 plans stayed all-noop with the first member refused (127.0.0.1)\n * and with it unresolvable (n9.invalid).\n */\nexport const executeOnCluster = (\n target: PveTarget,\n method: PveMethod,\n path: string,\n build: (apiBase: string) => HttpClientRequest.HttpClientRequest,\n): Effect.Effect<\n HttpClientResponse.HttpClientResponse,\n {\n readonly tag: 'cluster';\n readonly method: PveMethod;\n readonly path: string;\n readonly attempts: readonly MemberAttempt[];\n },\n HttpClient.HttpClient\n> =>\n Effect.gen(function* () {\n /**\n * ★ `HttpClient`, NOT RAW `fetch`, BECAUSE THAT IS WHAT ALCHEMY'S OWN PROVIDERS USE. Its\n * Hetzner provider builds on `FetchHttpClient.layer` and the `HttpClient` service\n * (src/Hetzner/Providers.ts), and there is no bare `fetch` anywhere in its Docker,\n * Kubernetes or GitHub providers. Going through the service rather than the global buys\n * the things a provider actually needs: a typed error channel instead of a thrown promise,\n * interruption when a plan is cancelled, whatever tracing the runtime has installed, and a\n * client that can be swapped for a stub in a test without monkey-patching a global.\n *\n * ⚠️ THE REQUIREMENT IS REAL AND IT PROPAGATES. Every operation carries `HttpClient`, so every\n * resource's Requirements type names it (PveRequirements in resource.ts) and the stack\n * provides `FetchHttpClient.layer`. That is the cost of the above, paid once.\n */\n const client = yield* HttpClient.HttpClient;\n const isWrite = method !== 'GET';\n const attempts: MemberAttempt[] = [];\n for (const member of orderedMembers(target)) {\n const outcome = yield* client.execute(build(pveApiBase(member))).pipe(Effect.result);\n if (Result.isSuccess(outcome)) {\n noteGoodMember(target, member);\n return outcome.success;\n }\n const why = describeTransport(outcome.failure);\n attempts.push({ member, why });\n const mayRetry = isWrite\n ? isPreSendTransport(outcome.failure)\n : isTransportFailure(outcome.failure);\n if (!mayRetry) {\n return yield* Effect.fail({ attempts, method, path, tag: 'cluster' as const });\n }\n }\n return yield* Effect.fail({ attempts, method, path, tag: 'cluster' as const });\n });\n",
10
+ "/**\n * One shape for every PVE object, so the provider can cover Proxmox rather than a corner of it.\n *\n * ⛔ THE ALTERNATIVE IS TWENTY COPIES OF THE SAME 130 LINES. Proxmox exposes LXC, QEMU, storage,\n * pools, users, groups, roles, ACLs, API tokens, SDN zones/vnets/subnets, firewall rules and\n * groups, HA resources, backup and replication jobs, metric servers and notification targets.\n * Each is the same four operations over a different path and a different form body. Written by\n * hand, resource number six is where someone quietly drops the read-back or the isResolved guard\n * and nobody notices until a plan lies.\n *\n * ★ SO THE FOUR OPERATIONS LIVE HERE, ONCE, AND A RESOURCE DECLARES ONLY WHAT IS DIFFERENT:\n * where it lives, how to recognise it, and which fields are mutable. A new PVE object should be\n * thirty lines, not a hundred and thirty.\n *\n * ⚠️ EVERY PVE ANSWER IS WRAPPED IN `{\"data\": ...}` AND A FAILED CALL CAN STILL BE HTTP 200 with\n * `{\"data\": null}`. That is why `reconcile` below READS BACK and refuses when the object is still\n * absent, rather than trusting a status code — see the ⛔ in that function.\n */\nimport { isResolved } from 'alchemy/Diff';\nimport type { Input } from 'alchemy/Input';\nimport * as Effect from 'effect/Effect';\nimport type * as HttpClient from 'effect/unstable/http/HttpClient';\nimport { pve } from './client.ts';\nimport type { ApiTarget, PbsTarget, PveRole, PveTarget } from './credentials.ts';\n\n/**\n * ★ WHY SEVERAL FAMILIES HERE DECLARE `defaultRemovalPolicy: 'retain'`, WRITTEN ONCE.\n *\n * Alchemy's own convention: a few resource types default to retain \"because their contents are\n * irreplaceable\" — `GitHub.Repository` and `Cloudflare.Zone` do — and those opt into deletion\n * with `destroy()`. `retain` means the engine SKIPS `provider.delete` entirely when a resource\n * is orphaned or destroyed: the state row is dropped, the cluster object lives on.\n *\n * So the PVE families whose contents cannot be rebuilt from a line of TypeScript — CephOsd,\n * CephPool, CephFs, CephDaemon, ZfsPool, Storage, NodeNetwork — carry that default. Their\n * `delete` is FULLY IMPLEMENTED and runs the moment a caller opts in with\n * `.pipe(RemovalPolicy.destroy())`. This is deliberately the Terraform `prevent_destroy` shape\n * rather than a stubbed-out operation: a `delete` that silently does nothing lies to whoever is\n * reading the plan, and the lie is discovered at the worst possible time.\n *\n * ⚠️ THE POLICY IS A DECORATION, NOT A PROP, so changing it produces NO DIFF — the resource plans\n * as a noop and the deploy re-commits the row's policy in place. A policy change therefore takes\n * effect from the very next deploy even though the plan shows nothing.\n */\n\n/**\n * ⛔ A RESOURCE IS PINNED TO ITS PRODUCT; ONLY THE FACTORY TAKES EITHER. The two hosts are the same\n * two strings, so without a required discriminant TypeScript would accept a PBS host wherever a\n * PVE one belongs — silently, with every call 401ing and `read` folding that into \"absent\". The\n * whole argument is on `scheme` in credentials.ts.\n */\n/**\n * ★ WHAT EVERY OPERATION IN THIS PACKAGE NEEDS FROM THE RUNTIME, NAMED ONCE.\n *\n * `HttpClient`, for both halves of every call: the credential is minted from OpenBao's HTTP API\n * and the PVE call goes through the same client. That is what Alchemy's own providers do\n * (src/Hetzner/Providers.ts builds on `FetchHttpClient.layer`, and there is no bare `fetch` in\n * its Docker, Kubernetes or GitHub providers).\n * ★ `ChildProcessSpawner` WAS HERE UNTIL 2026-09-14, while the mint shelled out to `bao`. The HTTP\n * client replaced that (credentials.ts), so the requirement went with it.\n *\n * ⚠️ SPELLED OUT AT EACH OF THE FORTY-ODD RESOURCES this would be a union nobody keeps in step —\n * one file left on the old shape is a type error at the stack, far from the cause. Named here,\n * adding a third service later is one edit.\n */\nexport type PveRequirements = HttpClient.HttpClient;\n\nexport type WithTarget = { target: PveTarget };\nexport type WithPbsTarget = { target: PbsTarget };\nexport type WithApiTarget = { target: ApiTarget };\n\nexport type PveSpec<Props extends WithApiTarget, Attributes> = {\n /** `pools/house`, `nodes/n2/lxc/101` — where ONE object is read, updated and deleted. */\n readonly path: (props: Props) => string;\n /** `pools`, `nodes/n2/lxc` — where a NEW one is POSTed. */\n readonly collection: (props: Props) => string;\n /** Live JSON to attributes. Returning undefined means \"this is not really there\". */\n readonly attributes: (live: Record<string, unknown>, props: Props) => Attributes | undefined;\n /** The form PVE wants on create. ⚠️ PVE takes form encoding, not JSON. */\n readonly createForm: (props: Props) => Record<string, string>;\n /**\n * The form for an update, or undefined when the object has no mutable fields.\n *\n * ⚠️ SOME PVE OBJECTS CANNOT BE UPDATED AT ALL. Returning undefined makes a changed prop a\n * REPLACE rather than a silent no-op, which is the honest answer for an immutable object.\n */\n readonly updateForm?: (props: Props) => Record<string, string>;\n /** True when live already matches props. Decides noop vs update. */\n readonly matches: (attributes: Attributes, props: Props) => boolean;\n /**\n * Which lease reads this family. Defaults to `read`, the 3600s auditor-shaped one.\n *\n * ⛔ THREE FAMILIES SET THIS TO `provision`, AND THE FAILURE IT AVOIDS IS SILENT. PVE gates some\n * SINGLE-OBJECT reads on the allocate privilege rather than the audit one — `/storage/{id}`,\n * `/cluster/sdn/zones/{zone}`, `/cluster/sdn/vnets/{vnet}` — while their COLLECTION reads\n * accept audit, so nothing looks wrong until a resource reads one object. `read` below folds\n * every failure into `undefined`, right for a 404 and wrong for a 403, so the plan says create\n * and PVE answers that the object already exists. Measured both ways on `local`, and written\n * up with the alternative that was rejected, in docs/privileges.md.\n */\n readonly readRole?: PveRole;\n};\n\nexport const pveOperations = <Props extends WithApiTarget, Attributes>(\n spec: PveSpec<Props, Attributes>,\n) => {\n /** The live object, or undefined. ⚠️ A 404 is an ANSWER here, not a failure. */\n const read = (props: Props) =>\n pve<Record<string, unknown>>(\n props.target,\n spec.readRole ?? 'read',\n 'GET',\n spec.path(props),\n ).pipe(\n Effect.map((data) => (data === undefined ? undefined : spec.attributes(data, props))),\n Effect.orElseSucceed(() => undefined),\n );\n\n return {\n read,\n\n // ⚠️ `Input<Props>`, NOT `Props`. At plan time a prop can still be an unresolved Output or\n // Config; `isResolved` is the narrowing, so the parameter has to admit the wider type or\n // every caller casts — and a cast here would be a lie about what plan actually has.\n diff: (news: Input<Props>, output: Attributes | undefined) =>\n Effect.gen(function* () {\n // ⚠️ A prop can still be an unresolved Output at plan time. Alchemy's own providers guard\n // with isResolved and skip rather than guess; comparing a placeholder to a live value\n // reports an update nobody asked for.\n if (output === undefined || !isResolved(news)) return undefined;\n const live = yield* read(news);\n // ⚠️ `update`, NOT `create` — Alchemy's Diff admits only noop/update/replace. An object\n // Alchemy has state for but the cluster does not is drift, and reconcile repairs it.\n if (live === undefined) return { action: 'update' } as const;\n if (spec.matches(live, news)) return { action: 'noop' } as const;\n // An object with no update path cannot be edited in place; say replace and mean it.\n return spec.updateForm === undefined\n ? ({ action: 'replace' } as const)\n : ({ action: 'update' } as const);\n }),\n\n reconcile: (news: Props) =>\n Effect.gen(function* () {\n const live = yield* read(news);\n if (live === undefined) {\n yield* pve(\n news.target,\n 'provision',\n 'POST',\n spec.collection(news),\n spec.createForm(news),\n );\n } else if (spec.updateForm !== undefined && !spec.matches(live, news)) {\n /**\n * ⛔ ADOPTING AN OBJECT THAT ALREADY MATCHES MUST NOT WRITE TO IT, AND WITHOUT THE\n * `matches` GUARD IT DID. Alchemy's `adopted` action is NOT a read: Apply.ts routes it\n * down the same branch as `update` and calls `reconcile` (Apply.ts:980 and :1045). So\n * the first time a declaration names an object Alchemy has no state for — which is\n * exactly what adopting the live estate means — reconcile runs, finds it present, and\n * fell through to this PUT.\n *\n * For most families that was a pointless write-back of identical values. For\n * `Proxmox.NodeNetwork` it is worse than pointless: a PUT under `/nodes/{node}/network`\n * STAGES a change into `/etc/network/interfaces.new`, so merely adopting the interface\n * a node already has would leave that node with a pending network change waiting for an\n * apply — on a cluster whose Ceph traffic rides vmbr1.11. Adoption has to be free.\n *\n * ★ SO THE CONDITION IS THE SAME PREDICATE `diff` USES. If `matches` is true the object\n * already says what the declaration says, and there is nothing to write — by\n * definition, since every field this provider manages is a field `matches` compares.\n * A field deliberately left OUT of `matches` is one this resource does not manage, so\n * its drift is not this provider's to repair.\n *\n * ⚠️ AN EMPTY FORM IS ALSO NOT A WRITE. `updateForm` can legitimately answer `{}` — a\n * storage declaring only `storage`, `type` and its locator has no mutable field at all\n * — and PUTting an empty body is a pointless write at best and a 400 that reads as a\n * broken provider at worst.\n */\n const form = spec.updateForm(news);\n if (Object.keys(form).length > 0) {\n yield* pve(news.target, 'provision', 'PUT', spec.path(news), form);\n }\n }\n const after = yield* read(news);\n if (after === undefined) {\n /**\n * ⛔ REFUSE RATHER THAN RETURN THE PROPS AS THOUGH THEY LANDED. PVE answers 200 with\n * `{\"data\": null}` on several endpoints, so \"no error\" is not evidence of a write. A\n * provider that returned its own inputs here would record state for an object that does\n * not exist, and the next plan would read `noop` over the gap.\n */\n return yield* Effect.die(\n new Error(\n `${spec.path(news)}: the write returned no error but the object is still absent. ` +\n 'PVE wraps every answer in {\"data\":...} and can report success on a call that did ' +\n 'nothing -- read back rather than trusting the status code.',\n ),\n );\n }\n return after;\n }),\n\n /**\n * ⚠️ PVE REFUSES TO DELETE THINGS THAT ARE STILL IN USE — a pool holding guests, a storage with\n * volumes. That refusal is the cluster declining to orphan something because a line left a\n * file, so it is surfaced as-is rather than retried with a force flag.\n */\n destroy: (olds: Props) => pve(olds.target, 'provision', 'DELETE', spec.path(olds)),\n };\n};\n\n/**\n * The five provider handlers for a spec'd PVE object, wired once.\n *\n * ⛔ THIS BLOCK WAS WRITTEN TEN TIMES BEFORE IT WAS EXTRACTED, and every copy was character for\n * character identical apart from its comments: `list` answering empty, and four handlers whose\n * entire body was `yield* ops.<same name>(<same argument>)`. Ten copies of a delegation is ten\n * chances to delegate to the wrong one — `ops.read(olds)` inside `reconcile` typechecks, returns\n * a plausible value, and turns every deploy into a no-op that reports success.\n *\n * ★ IT TAKES THE SPEC, NOT THE OPERATIONS, so a resource declares its four spec functions and\n * stops. `pveOperations` stays exported for an object that genuinely needs a handler of its own;\n * nothing in this package does yet, and the day one does it should be visibly different from the\n * ten that are not.\n *\n * ⛔ IT STOPS AT THE HANDLERS AND DOES NOT RETURN THE LAYER, AND THAT IS NOT AN OVERSIGHT — it was\n * written the other way first and reverted. Wrapping `Provider.effect(cls, …)` here means naming\n * the resource class generically, and Alchemy's `Props<R>` and `R[\"Attributes\"]` are not the\n * plain `Props` and `Attributes` this spec is written against: `Attributes` comes back as\n * `Attributes & AttrOutput<Attributes[\"Attributes\"]>`. Against a free type variable TypeScript\n * cannot prove those line up — \"could be instantiated with a different subtype\" — so the only\n * way to compile a Layer-returning version is a cast, and a cast is a LIE ABOUT WHETHER THE\n * HANDLERS MATCH THE RESOURCE, which is the one thing the call site exists to check. Leaving\n * `Cls.Provider.of(...)` in each file keeps that check where the types are concrete and real.\n * One line per resource is the price of it, and it is worth paying.\n *\n * ⚠️ `list` IS OPTIONAL IN `ProviderServiceInput` AND IS PASSED ANYWAY. An empty list is a claim —\n * this provider adopts nothing — and it is made here for every PVE object at once, because the\n * reasoning is identical for all of them: every PVE index endpoint answers with the whole\n * cluster's objects, PVE's own built-ins included. `GET /pools` returns pools a human made years\n * ago; `GET /access/roles` returns `Administrator`. Returning any of them would invite Alchemy to\n * adopt an object it never created, and therefore one day to narrow or delete it. Adoption stays\n * an explicit act. A resource with a reason to differ passes its own `list` and says why.\n */\nexport const pveHandlers = <Props extends WithApiTarget, Attributes extends object>(\n spec: PveSpec<Props, Attributes>,\n) => {\n const ops = pveOperations(spec);\n return {\n list: () => Effect.succeed([]),\n read: ({ olds }: { olds: Props }) => ops.read(olds),\n diff: ({ news, output }: { news: Input<Props>; output: Attributes | undefined }) =>\n ops.diff(news, output),\n reconcile: ({ news }: { news: Props }) => ops.reconcile(news),\n delete: ({ olds }: { olds: Props }) => ops.destroy(olds),\n };\n};\n",
11
+ "/**\n * `Proxmox.ApiToken` — a PVE API token: the thing a service actually authenticates as.\n *\n * ⛔ THE SECRET EXISTS FOR ONE HTTP RESPONSE AND THEN NOWHERE. MEASURED from the cluster's own\n * schema (`/usr/share/pve-docs/api-viewer/apidoc.js` on n2, 2026-09-13): POST returns\n * `[\"full-tokenid\",\"info\",\"value\"]`; PUT returns `[\"comment\",\"expire\",\"full-tokenid\",\"privsep\",\n * \"value\"]` with `value` present ONLY when `regenerate` was set; GET returns\n * `[\"comment\",\"expire\",\"privsep\"]` and never the secret. A live token agrees —\n * `GET /access/users/monitoring@pve/token/exporter` answers `{\"expire\":0,\"privsep\":0}`. PVE says\n * it plainly on the POST: the value \"needs to be stored as it cannot be retrieved afterwards\".\n *\n * ⛔ SO A TOKEN THIS RESOURCE CREATES IS UNUSABLE, AND SAYING SO IS THE POINT OF THIS BLOCK. The\n * secret may not become an attribute: Alchemy persists attributes UNENCRYPTED, and this estate's\n * state store is a Postgres dumped nightly (the ⛔ in credentials.ts). So `reconcile` drops the\n * value on the floor, and what lands is a live credential in `/etc/pve/user.cfg` whose secret\n * nobody holds. No `regenerate` rescues it, because a regenerated value is discarded the same\n * way. The only escape is an operator who captured the value out of band — which this provider\n * gives them no way to do.\n * ★ SO POINT THIS FAMILY AT TOKENS THAT ALREADY EXIST. `comment`, `expire` and `privsep` are the\n * whole of a token's policy, and declaring them is real work: it is how `expire` stops being\n * whatever somebody typed in 2024. Mint NEW tokens where the secret can be caught — OpenBao's\n * `proxmox-tb4` mount, or a human at `pveum user token add`.\n * ⚠️ THE CREATE PATH IS LEFT REACHABLE RATHER THAN STUBBED. A create that silently did nothing\n * would be the same lie as the stubbed delete resource.ts's ★ refuses; the honest arrangement\n * is a create that works and a header that says what it produces.\n *\n * ⛔ THERE IS NO `regenerate` PROP, AND IT IS NOT AN OVERSIGHT. PVE's own description: \"All users\n * of the previous secret will lose access after this operation.\" A prop for it would revoke a\n * live credential during a deploy whose plan said `update`, and hand back a replacement this\n * provider is obliged to throw away — breakage with no recovery. Rotation belongs to the mount\n * that owns the lease, or to a human who is watching.\n *\n * ⚠️ THERE IS A SECOND WRITER TO THESE OBJECTS AND IT IS THE ONE THIS PROVIDER RUNS ON. OpenBao's\n * `proxmox-tb4` engine mints PVE tokens under `hf-read@pve` and `hf-provision@pve` — read from\n * `house/platform/secrets/vault/plugin-proxmox/proxmox/`: `privsep=0` (client.go), `expire` set\n * to the lease deadline, and an id the plugin CHOOSES,\n * `hf-<role>-<actor>-<entity6>-<stamp>-<nonce>` (tokenname.go). Revocation and WAL rollback look\n * up that one exact id (wal.go); neither sweeps a prefix. So the two systems cannot collide on\n * one object by accident — but they share the USER: `hf-read@pve` held three live leases when\n * this was written, and `Proxmox.User` deleting that account takes every one of them with it.\n * ⛔ DO NOT DECLARE A TOKEN UNDER A MINT USER. `expire` is what makes that dangerous rather than\n * untidy: point this resource at a lease token with the wrong expire and a 300-second\n * credential becomes a permanent one — and on `hf-provision@pve` that credential carries\n * `Permissions.Modify` at `/`. docs/privileges.md records what those 27 privileges buy.\n *\n * ⚠️ PRIVILEGES, AND THE READ LANE CANNOT DO IT. MEASURED: all four methods on this path check\n * `['or', ['userid-param','self'], ['userid-group', ['User.Modify']]]` — with no `Sys.Audit`\n * alternative, unlike `GET /access/users/{userid}`, which has one. And\n * `pvesh get /access/permissions --userid hf-read@pve --path /access/groups` answers the seven\n * PVEAuditor audit privileges and no `User.Modify`, while `hf-provision@pve` has it. So the\n * 3600s read lease reaches at most its OWN account's tokens and is refused for every other\n * userid — which `read` in resource.ts folds into \"absent\", so the plan says create and the POST\n * then fails with \"Token already exists\". Hence `readRole: 'provision'` below, for the same\n * reason storage.ts, sdn-zone.ts and sdn-vnet.ts set it, at the same cost: every plan mints a\n * 300s non-renewable provision lease just to read.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { apiTokenSpec } from './api-token-form.ts';\nimport { type PveRequirements, type WithTarget, pveHandlers, pveOperations } from './resource.ts';\n\nexport interface ApiTokenProps extends WithTarget {\n /**\n * The account that owns the token, realm-qualified: `tofu@pve`, `root@pam`. Identity.\n *\n * ⚠️ THE ACCOUNT MUST ALREADY EXIST. Every method here runs `check_user_exist` first, so a\n * token named under a missing user fails the READ (folded to \"absent\") and then fails the\n * create with \"no such user\" — the honest error, arriving one step after the misleading plan.\n * Sequence a `Proxmox.User` ahead of it and the ordering takes care of itself.\n */\n userid: string;\n /**\n * The token's own name, unique within the account. Identity.\n *\n * ⚠️ PVE HAS NO RENAME, AND HERE THAT COSTS MORE THAN IT DOES FOR A USER. Editing this prop (or\n * `userid`) points `path` at a DIFFERENT token, which reads as absent and is then created —\n * leaving the old token LIVE, with its secret still working, invisible to the plan, while the\n * new one is the unusable kind described at the top. Rename by declaring a delete and a\n * create, the way user.ts says for an account.\n * ⛔ `diff` IS NOT OVERRIDDEN TO SAY `replace` THE WAY acl.ts DOES, AND THE DIFFERENCE IS THE\n * OBJECT. There, replace removes a grant that can be rebuilt from its own tuple; here it\n * would DELETE a live token — destroying an irrecoverable secret, and everything using it —\n * to tidy up a name. Leaving the old token standing is the lesser harm, and saying so here\n * is what keeps it from looking like an omission.\n * ⚠️ PATTERN `[A-Za-z][A-Za-z0-9.\\-_]+`: a letter first, two characters minimum. The schema\n * declares no maxLength; the OpenBao plugin assumes a conservative 64 rather than finding the\n * real limit in production, and so should anything else.\n */\n tokenid: string;\n /**\n * Free text in `pveum user token list` and the UI. Empty is how it is cleared — see `shape`.\n * ⚠️ ANY CHARACTER IS SAFE HERE, MEASURED, and it was worth checking: `user.cfg` is a\n * colon-delimited line, so a comment holding a colon or a newline is the obvious place for a\n * round-trip to lose a character and diff forever. PVE escapes it — `encode_text` turns\n * `a:b\\nc%d` into `a%3Ab%0Ac%25d` and `decode_text` gives it back byte for byte.\n */\n comment?: string;\n /**\n * Seconds since the epoch, or 0 for \"never expires\".\n *\n * ⛔ REQUIRED, AND THE SCHEMA WILL TELL YOU IT NEED NOT BE. It declares the default \"same as\n * user\", and the code never implements it: `generate_token` writes `expire` only when the\n * parameter is defined, `user.cfg` stores a token as `token:<id>:<expire>:<privsep>:<comment>:`\n * with no absent state, and the parser does `$expire = 0 if !$expire` (AccessControl.pm:1624).\n * MEASURED end to end: every token on this cluster that was created without an expire reads\n * back `\"expire\":0`. So \"same as user\" is documentation of an intention, not behaviour.\n * ⛔ WHICH IS WHY IT IS NOT OPTIONAL-DEFAULTING-TO-0. That spelling reads identically and is far\n * worse: an omitted `expire` would then quietly WRITE 0 over a live deadline, turning an\n * expiring credential into a permanent one, and the plan would call it an update. Requiring\n * the field makes \"this token never expires\" a sentence somebody had to type.\n */\n expire: number;\n /**\n * True keeps the token's privileges separate from its owner's — it gets NOTHING until an ACL\n * names `fullTokenid`. False gives it the owner's privileges entire.\n *\n * ⛔ REQUIRED FOR THE SAME REASON AS `expire`, AND THE BLAST RADIUS IS LARGER. PVE's API default\n * is 1, every token on this cluster is 0 (measured), and `user.cfg` materialises it either way\n * — `$privsep = $privsep ? 1 : 0` (AccessControl.pm:1622), so there is no unset state to\n * preserve. Were this optional, adopting a live token without mentioning `privsep` would plan\n * an update to 1 and STRIP a working credential of every privilege it has, silently: PVE\n * returns 401/403 to the service, nothing errors here, and `tofu@pve!apply` simply stops\n * working. Required, so adopting a token is a sentence that states what it is.\n * ⚠️ AND `false` IS NOT A SHRUG. It is a token with its owner's whole privilege set; under a\n * provisioning account that is the account's full authority with a separate secret.\n */\n privsep: boolean;\n}\n\nexport interface ApiTokenAttributes {\n userid: string;\n tokenid: string;\n /** `<userid>!<tokenid>` — what `Proxmox.Acl` binds as its `ugid`. Derived; never compared. */\n fullTokenid: string;\n comment: string;\n expire: number;\n privsep: boolean;\n /**\n * ⛔ THERE IS NO `value` FIELD HERE AND THERE NEVER MAY BE. Adding one would write a working PVE\n * credential, in clear, into the state Postgres and into every nightly dump of it — the exact\n * leak metric-server.ts types its `token` as `never` to prevent. The read cannot supply one\n * anyway; only create and regenerate can, and both of those responses are dropped.\n */\n}\n\nexport interface ProxmoxApiToken extends Resource<\n 'Proxmox.ApiToken',\n ApiTokenProps,\n ApiTokenAttributes,\n never,\n PveRequirements\n> {}\n\n/**\n * ★ `retain` BY DEFAULT, AND THIS IS THE PLAINEST CASE FOR IT IN THE PACKAGE. A token's contents\n * are one irreplaceable secret: delete it and the value is gone, a replacement is a DIFFERENT\n * value, and every holder loses access the instant `cfs_write_file` returns — with no error\n * raised anywhere near them. The live cluster's tokens are `monitoring@pve!exporter` (the PVE\n * exporter feeding VictoriaMetrics), `mcp@pve!executor`, `tofu@pve!apply`, `tofu@pve!ro`,\n * `sablier@pve!sablier` and `vaultmint@pve!engine` — the last being the parent credential the\n * OpenBao mount itself authenticates with, so orphaning that one would stop every plan in this\n * package, this resource included. `delete` is FULLY IMPLEMENTED (DELETE is a real method on\n * this path, measured) and runs the moment a caller opts in with `.pipe(RemovalPolicy.destroy())`.\n * See the ★ in resource.ts, which explains the convention once.\n */\nexport const ProxmoxApiToken = Resource<ProxmoxApiToken>('Proxmox.ApiToken', {\n defaultRemovalPolicy: 'retain',\n});\n\nconst ops = pveOperations(apiTokenSpec);\n\n/**\n * ⛔ THIS FAMILY ADOPTS AND MANAGES TOKENS; IT REFUSES TO MINT ONE, AND THAT IS A DECISION RATHER\n * THAN A GAP. The secret exists ONLY in the create response — MEASURED from the schema: `POST`\n * returns `[\"full-tokenid\",\"info\",\"value\"]`, where `value` is \"API token value used for\n * authentication\", while `GET` returns `[\"comment\",\"expire\",\"privsep\"]` and never the secret.\n * It may not become an attribute, because Alchemy writes attributes to its state store\n * UNENCRYPTED into a Postgres that is dumped nightly.\n *\n * So a token created here would be A LIVE CREDENTIAL ON THE CLUSTER THAT NOBODY HOLDS: valid,\n * privileged, unusable, and indistinguishable from one somebody meant to keep. Regenerating does\n * not rescue it — a `regenerate` PUT returns the new value down the same discarded path. So\n * `reconcile` refuses by name and says what to do instead.\n *\n * ★ EVERYTHING ELSE STILL WORKS, AND IT IS THE HALF WORTH HAVING. Adopting an existing token and\n * converging its `comment`, `expire` and `privsep` are real operations: TB4 carries SEVEN tokens\n * with `expire=0` and `privsep=0` made by clicks nobody recorded. Declaring those freezes the\n * set, and an eighth appearing shows up as drift.\n *\n * ⚠️ IF DECLARATIVE MINTING IS EVER WANTED, the missing piece is a secret SINK — write the value\n * straight into an OpenBao kv path and return only its address. That is a different resource\n * with a different contract; it must not be bolted onto this one.\n */\nconst handlers = {\n ...pveHandlers(apiTokenSpec),\n reconcile: Effect.fn(function* ({ news }: { news: ApiTokenProps }) {\n const live = yield* ops.read(news);\n if (live === undefined) {\n return yield* Effect.die(\n new Error(\n `${news.userid}!${news.tokenid}: this resource does not create API tokens. PVE returns ` +\n 'the secret only in the create response and it cannot be stored, so a token made here ' +\n 'would be a live credential nobody holds. Create it with `pveum user token add` and ' +\n 'capture the value, or mint a short-lived one from the OpenBao proxmox mount ' +\n '(`bao read proxmox-tb4/creds/<role>`) -- then declare it here to manage it.',\n ),\n );\n }\n return yield* ops.reconcile(news);\n }),\n};\n\n/**\n * ⛔ `list` IS EMPTY, AND FOR THIS FAMILY THAT MATTERS MORE THAN THE GENERIC ARGUMENT IN\n * resource.ts. A token index handed to Alchemy would offer up `vaultmint@pve!engine` and every\n * live OpenBao lease for adoption — and adoption is what makes a later plan willing to delete.\n * The mount's leases in particular appear and vanish on their own; anything that adopted one\n * would report drift against a credential that was never its to hold.\n */\nexport const ProxmoxApiTokenProvider = () =>\n Provider.effect(ProxmoxApiToken, Effect.succeed(ProxmoxApiToken.Provider.of(handlers)));\n",
12
+ "/**\n * How PVE spells a value on the wire, and how to get it back to something comparable.\n *\n * ⛔ EVERY FUNCTION HERE WAS FOUND IN TWO OR MORE RESOURCE FILES, AND THE COPIES HAD DRIFTED.\n * `num` was byte-identical in three files, so merging it is free. The boolean was NOT: four\n * files declared `const flag` and meant four different things by it, including one that ran the\n * other way round. That is the whole reason this module exists — not to save lines, but because\n * a name that means four things is a bug waiting for the person who assumes it means the first\n * one they read.\n *\n * ★ THE TWO DIRECTIONS ARE NAMED APART, DELIBERATELY. `bool` reads the wire and answers a\n * TypeScript boolean; `flag` writes a form field and answers PVE's `'1'`/`'0'`. `storage.ts`\n * held both under one name — `flag` there was the write direction while `flag` in three other\n * files was the read direction — which typechecks in both files and is exactly the confusion\n * that survives review.\n *\n * ⚠️ NOTHING HERE IS RESOURCE-SPECIFIC. A coercion that only one PVE object needs belongs in that\n * object's file, where its reasoning sits next to the field it serves. `role.ts` keeps its own\n * `canonical` for the same reason: that one sorts a privilege SET, which is a different idea\n * from `canonicalToken` below however similar the names read.\n */\n\n/** ⚠️ `typeof value === 'number'` and not `Number(value)`: PVE sends `null` for an unset field. */\nexport const num = (value: unknown, fallback: number) =>\n typeof value === 'number' ? value : fallback;\n\nexport const text = (value: unknown, fallback = '') =>\n typeof value === 'string' ? value : fallback;\n\n/**\n * A PVE boolean off the wire.\n *\n * ⛔ THE FOUR SPELLINGS THIS REPLACES, AND WHY THIS ONE IS A SUPERSET OF ALL OF THEM. Measured in\n * the files they came from: `backup-job` accepted `1 | true | '1'` with a caller's fallback;\n * `sdn-vnet` the same three with no fallback; `storage` accepted only `1 | true`; `user` ran the\n * value through `Number()` and asked `!== 0`. For the values PVE actually returns on these\n * endpoints — `0` and `1` — all four agree, so accepting the union changes no live answer.\n *\n * ⚠️ THE ONE REAL DIFFERENCE IS `2`. `user.ts` would have read any non-zero number as true; this\n * reads only `1`. No PVE field in this package is documented to return anything but 0 or 1, and\n * a field that did would be a flag with more than two states — which is not a boolean, and\n * should be read with `num` and named for what it is rather than quietly coerced here.\n *\n * ⚠️ `null`, `undefined` AND `''` ALL TAKE THE FALLBACK. An absent key means PVE's documented\n * default for that field, which is not always `false` — so the default is the CALLER's to state,\n * and `false` is only the fallback's own default for fields that really do default off.\n *\n * ⛔ THE EMPTY STRING IS ABSENT, NOT FALSE, AND GETTING THAT WRONG WRITES THE WRONG VALUE. A\n * metric server is a SectionConfig section and can hand back `''` for an unset flag. Read as\n * `false`, the two fields in this package that default ON — `backup-job.enabled` and\n * `user.enable` — would come back disabled, `matches` would report an update nobody asked for,\n * and the deploy would then WRITE `enabled=0` onto a live job. An empty string is not a\n * boolean; it is the absence of one.\n */\nexport const bool = (value: unknown, fallback = false) =>\n value === undefined || value === null || value === ''\n ? fallback\n : value === 1 || value === true || value === '1';\n\n/**\n * A boolean on its way INTO a PVE form.\n *\n * ⚠️ `undefined` IN, `undefined` OUT — an undeclared field must not be sent at all. Sending `'0'`\n * for a prop the caller never set would write PVE's default over whatever is live, turning an\n * omission into an edit.\n */\nexport const flag = (value?: boolean) => (value === undefined ? undefined : value ? '1' : '0');\n\n/**\n * A comma list PVE does not promise to give back in the order it was handed.\n *\n * ⚠️ `nodes` IS A SET AND PVE DOES NOT PRESERVE ITS ORDER. The zone plugin decodes the list into a\n * hash and re-encodes it by joining that hash's keys, so the string you get back is not the one\n * you sent. Sorting both sides is what stops a plan reporting an update because two names came\n * back the other way round. `peers` gets the same treatment: it is a mesh, not a queue.\n */\nexport const csv = (value: readonly string[] | string | undefined) =>\n (typeof value === 'string' ? value.split(',') : (value ?? []))\n .map((part) => part.trim())\n .filter((part) => part !== '')\n .sort()\n .join(',');\n\n/**\n * A comma list of guest IDs, in numeric order.\n *\n * ⚠️ ORDER IS NOT MEANING IN A GUEST LIST, SO IT MUST NOT BE A DIFF. PVE stores `vmid` as the\n * comma-separated string it was handed and gives it back the same way, so a declaration listing\n * the same guests in another order would otherwise be an update that rewrites the job to say\n * exactly what it already said. Both sides are sorted numerically before they meet.\n *\n * ⚠️ NUMERIC, NOT LEXICAL — this is why it is not `csv`. Sorted as text, `101` precedes `99`.\n */\nexport const guestList = (value: unknown): string => {\n const parts =\n typeof value === 'string'\n ? value.split(',')\n : Array.isArray(value)\n ? value.map((entry: unknown) => String(entry))\n : [];\n return parts\n .map((part) => Number(part.trim()))\n .filter((id) => Number.isFinite(id))\n .sort((left, right) => left - right)\n .map((id) => String(id))\n .join(',');\n};\n\n/** `yes`/`true`/`on` and their opposites are the same value as 1/0 to PVE; make them one string. */\nexport const canonicalToken = (raw: string) => {\n const lowered = raw.trim().toLowerCase();\n if (['1', 'yes', 'true', 'on'].includes(lowered)) return '1';\n if (['0', 'no', 'false', 'off'].includes(lowered)) return '0';\n return lowered;\n};\n\n/**\n * A PVE property string, flattened to one comparable form.\n *\n * ⚠️ A PROPERTY STRING AND ITS PARSED FORM ARE ONE VALUE IN TWO SHAPES, AND PVE HANDS BACK\n * WHICHEVER IT LIKES. MEASURED: `fleecing` is WRITTEN as the property string `fleecing=enabled=0`\n * and READ BACK as the nested object {\"enabled\":0}. Comparing raw values would report an update\n * on every plan for a job nobody touched — the same forever-diff a create-only field causes. So\n * both sides are flattened here, sorted, and only then compared. `prune-backups` goes through\n * the same funnel: same kind of value, the normalisation is free, and guessing which shape it\n * comes back in is exactly the guess that costs a permanent diff.\n *\n * ⚠️ `defaultKey` EXISTS BECAUSE `fleecing=1` IS SHORTHAND FOR `fleecing=enabled=1`. PVE's format\n * for it is written `[enabled=]<1|0>`, so a bare token is legal on write and comes back expanded\n * on read; unexpanded, the short and long spellings never compare equal. `prune-backups` has no\n * default key, so a bare token there is passed through as-is rather than invented into one.\n */\nexport const propertyString = (value: unknown, defaultKey?: string): string => {\n const pairs: [string, string][] =\n typeof value === 'string'\n ? value.split(',').map((part) => {\n const [key, ...rest] = part.split('=');\n return rest.length === 0 && defaultKey !== undefined\n ? [defaultKey, key ?? '']\n : [key ?? '', rest.join('=')];\n })\n : typeof value === 'object' && value !== null\n ? Object.entries(value).map(([key, entry]) => [key, String(entry)])\n : [];\n return pairs\n .map(([key, entry]) => [key.trim(), canonicalToken(entry)] as const)\n .filter(([key]) => key !== '')\n .map(([key, entry]) => `${key}=${entry}`)\n .sort()\n .join(',');\n};\n\n/**\n * An integer PVE may have spelled as a string.\n *\n * ⚠️ PVE MAY HAND BACK EITHER `8086` OR `\"8086\"`. These objects are SectionConfig sections, and the\n * integer check VALIDATES the parsed string rather than converting it, so whether a number\n * arrives as a number is a property of the version you are talking to. `'8086' === 8086` is\n * false, and that is an update consisting of nothing, reported on every plan forever.\n */\nexport const int = (value: unknown, fallback: number) => {\n if (typeof value === 'number') return value;\n const parsed = Number.parseInt(text(value), 10);\n return Number.isNaN(parsed) ? fallback : parsed;\n};\n\n/**\n * A PVE update form with its clear-list attached, and the two guaranteed not to overlap.\n *\n * ⛔ PVE DIES IF A KEY IS SET AND DELETED IN ONE CALL, AND SIX FAMILIES HERE BUILT THAT FORM BY\n * HAND. Measured in the shipped Perl on n2 — `PVE::SectionConfig::delete_from_config`, line 1860:\n *\n * die \"cannot set and delete property '$k' at the same time!\\n\"\n * if defined($new_options->{$k});\n *\n * `defined` is the test, not truth, so `strict=0` or `comment=''` in the body counts as SET. The\n * concrete failure: a live node-affinity rule with `strict 1` and a declaration carrying\n * `strict: false`. `matches` reports an update; the clear-list has to name `strict`, because a\n * PUT of `strict=0` merges a falsy value the plugin still stores; and if the body also emits\n * `strict: '0'` the PUT is refused. The update never lands, the next plan reports the same\n * update, and every deploy 500s — forever.\n *\n * ★ SO DISJOINTNESS IS ENFORCED HERE RATHER THAN REASONED ABOUT SIX TIMES. A cleared key is\n * dropped from the body: CLEAR WINS. That is the right way round because a clear-list entry is\n * computed from \"this prop is absent, and absent means remove it\", which is a deliberate\n * statement, while the body's value for the same key is the coercion of that same absence —\n * `flag(false)` is `'0'`, and `'0'` is exactly what must not be sent.\n *\n * ⚠️ UNDEFINED VALUES ARE DROPPED TOO, so a form builder may emit `undefined` for a field it does\n * not set without the caller filtering first. `new URLSearchParams` would otherwise stringify it\n * to the literal text \"undefined\".\n */\nexport const withClears = (\n fields: Record<string, string | undefined>,\n clear: readonly string[],\n): Record<string, string> => {\n const cleared = new Set(clear);\n const kept: Record<string, string> = {};\n for (const [key, value] of Object.entries(fields)) {\n if (value !== undefined && !cleared.has(key)) kept[key] = value;\n }\n return cleared.size === 0 ? kept : { ...kept, delete: [...cleared].join(',') };\n};\n",
13
+ "import type { ApiTokenAttributes, ApiTokenProps } from './api-token.ts';\n/**\n * What a write to a PVE API token actually does, and the form that does it.\n *\n * ★ SPLIT OUT OF api-token.ts TO KEEP BOTH FILES UNDER THE 250-LINE CAP, and the seam is the one\n * metric-server-form.ts draws: this file answers \"what does PVE store when this form arrives\",\n * api-token.ts answers \"what a token is and when it has changed\". Nothing here reads the\n * cluster and nothing here decides a diff.\n *\n * ⚠️ THE `import type` BACK TO api-token.ts IS A CYCLE ON PAPER ONLY. It is type-only, so it is\n * erased before anything runs and `ApiTokenProps` stays in the file that declares the resource.\n *\n * ⛔ THE WRITE SEMANTICS BELOW ARE READ FROM THE CLUSTER'S OWN PERL RATHER THAN INFERRED FROM THE\n * API SCHEMA — `/usr/share/perl5/PVE/API2/User.pm`, subs `generate_token` and\n * `update_token_info`, read over SSH on n2 on 2026-09-13. The two disagree in exactly the place\n * that costs a forever-diff: the schema gives `expire` the default \"same as user\", and the code\n * never implements it. api-token.ts records what that means.\n */\nimport type { PveSpec } from './resource.ts';\nimport { bool, int, text } from './values.ts';\n\n/**\n * `<userid>!<tokenid>` — the name the rest of PVE calls this object by.\n *\n * ★ IT IS WHAT AN ACL BINDS. `Proxmox.Acl` with `type: 'token'` wants exactly this string as its\n * `ugid`, so reporting it as an attribute is what lets a privilege-separated token be granted\n * anything at all without somebody retyping the join by hand.\n *\n * ⚠️ DERIVED, NOT READ. MEASURED: `GET /access/users/monitoring@pve/token/exporter` answers\n * `{\"expire\":0,\"privsep\":0}` and echoes back neither half of its own identity. So this is built\n * from props, cannot disagree with the path the read used, and is therefore true by\n * construction — which is why it is reported and never compared.\n */\nexport const fullTokenid = (props: ApiTokenProps) => `${props.userid}!${props.tokenid}`;\n\n/**\n * Everything a token has, in the form PVE wants. Create and update send exactly this.\n *\n * ⛔ `userid` AND `tokenid` ARE NOT IN IT, and that is not an omission. Both are path segments of\n * `access/users/{userid}/token/{tokenid}` — which is the path the POST goes to as well as the\n * PUT — so a second copy in the body can only ever disagree with the path it was sent to.\n * metric-server.ts omits its `id` for the same reason and says so there.\n *\n * ⚠️ EVERY FIELD IS SENT ON EVERY WRITE, THE EMPTY COMMENT INCLUDED, BECAUSE A PUT MERGES.\n * MEASURED in `update_token_info`: `$token->{comment} = $param->{comment} if defined(...)`\n * followed by `delete $token->{comment} if (!length $token->{comment})`. So `comment=` is how a\n * comment is CLEARED; omitting it leaves the old text in place while `matches` goes on asking\n * for an update the update cannot make. user.ts writes the same reasoning out for `groups`.\n * ⚠️ THE `delete=` PARAMETER IS NOT USED AND WOULD NOT HELP. Its whitelist in that sub is\n * literally `my $deletable = { comment => 1 };`, and anything else answers\n * \"unknown option '<k>'\" — so `expire` and `privsep` have no clear path at all, which is the\n * other half of why both are required props rather than optional ones.\n *\n * ⚠️ `flag()` FROM values.ts IS DELIBERATELY NOT USED FOR `privsep`. Its entire job is turning an\n * UNDECLARED boolean into `undefined` so the field is omitted from the form; `privsep` is a\n * required prop precisely so that it is never undeclared, so there is nothing for it to do and\n * its `string | undefined` return would have to be asserted away to fit `Record<string,string>`.\n * An assertion here would be a claim about the prop that the type already makes properly.\n */\nexport const shape = (props: ApiTokenProps): Record<string, string> => ({\n comment: props.comment ?? '',\n expire: String(props.expire),\n privsep: props.privsep ? '1' : '0',\n});\n\nexport const apiTokenSpec: PveSpec<ApiTokenProps, ApiTokenAttributes> = {\n // ⛔ THE ITEM READ NEEDS `User.Modify`, WHICH THE AUDITOR-SHAPED READ LEASE DOES NOT HAVE. The\n // measurement and the consequence are in the header's last ⚠️; the mechanism — a silent\n // \"absent\" rather than a 403 — is the ⛔ on `readRole` in resource.ts.\n readRole: 'provision',\n /**\n * ★ NOTHING PVE REPORTS HERE IS UNWRITABLE, WHICH IS UNUSUAL IN THIS PACKAGE AND IS WHY\n * `matches` can compare everything it reads. The GET returns exactly `comment`, `expire` and\n * `privsep`; PUT accepts exactly those three. There is no autoscaled field, no server-assigned\n * id, no set whose order PVE reshuffles — the three killers the neighbouring files carry\n * ⚠️s about do not arise. The two identity fields and `fullTokenid` come from props and are\n * true by construction, so comparing them would be theatre.\n * ⚠️ `undefined` WHEN NEITHER FLAG IS THERE, BECAUSE BOTH ARE ALWAYS THERE. `user.cfg`\n * materialises `expire` and `privsep` for every token it stores, so an answer carrying neither\n * is not a token — and without this guard `bool`/`int` would invent one out of their fallbacks\n * and the read-back guard in `reconcile` could never fire.\n */\n attributes: (live, props) => {\n const expire = live['expire'];\n const privsep = live['privsep'];\n if (expire === undefined && privsep === undefined) return undefined;\n return {\n comment: text(live['comment']),\n expire: int(expire, 0),\n fullTokenid: fullTokenid(props),\n /** ⚠️ FALLBACK `true`, MATCHING PVE'S API DEFAULT — unreachable given the guard above, but\n * wrong in the safe direction if a future release stops emitting the field. */\n privsep: bool(privsep, true),\n tokenid: props.tokenid,\n userid: props.userid,\n };\n },\n /**\n * ⛔ THE SAME STRING AS `path`, AND NOT A TYPO. A token is POSTed to its OWN url, not to the\n * collection: MEASURED, `/access/users/{userid}/token` carries a GET and nothing else, while\n * POST lives on `{tokenid}`. metric-server.ts has the identical shape for the identical\n * reason and records the experiment there.\n */\n collection: (props) => `access/users/${props.userid}/token/${props.tokenid}`,\n createForm: shape,\n /**\n * ⚠️ EXACTLY THE THREE FIELDS A PUT CAN PUT BACK, WHICH IS ALSO EXACTLY WHAT THE GET REPORTS.\n * MEASURED, by replaying these two functions over the live GET bodies of all four token\n * shapes this cluster has: `monitoring@pve!exporter` (no comment), `tofu@pve!apply` and\n * `sablier@pve!sablier` (commented), and a live OpenBao lease under `hf-read@pve` (a real\n * non-zero `expire`, offered as both `1789327175` and `\"1789327175\"` since `int` must not care\n * which). All four answer noop; flipping `privsep` answers update; an empty body answers\n * absent. ⚠️ THAT IS THE COMPARISON, NOT THE ENGINE — no `alchemy plan` was run against this\n * family, and nothing here was written to the cluster.\n */\n matches: (attributes, props) =>\n attributes.comment === (props.comment ?? '') &&\n attributes.expire === props.expire &&\n attributes.privsep === props.privsep,\n path: (props) => `access/users/${props.userid}/token/${props.tokenid}`,\n updateForm: shape,\n};\n",
14
+ "/**\n * `Proxmox.BackupJob` — the vzdump schedule, declared. The one object whose drift nothing else on\n * the cluster reveals.\n *\n * ★ WHY THIS ONE EARNS ITS PLACE. A hand-made vzdump job drifts silently: a schedule moved by an\n * hour, a retention trimmed to `keep-last=1`, or `enabled 0` set during a maintenance window and\n * never set back. All three look like a healthy cluster from every angle except a restore.\n * Declared here, `diff` reads the LIVE job on every plan, so a hand edit surfaces as\n * `1 to update` that day rather than on the day somebody needs last night's backup and finds a\n * week-old one, or none.\n *\n * ⛔ PVE GENERATES `id` WHEN YOU OMIT IT, WHICH MAKES OMITTING IT THE WORST BUG THIS RESOURCE\n * COULD CARRY. PVE's own API schema says so in one parenthesis — `id`: \"Job ID (will be\n * autogenerated).\" — and a generated id looks like `backup-f56d8ab7-d524`. A resource that\n * POSTed without an id would create a SECOND job beside the first on EVERY reconcile, and the\n * read-back in `pveOperations` would still pass, because a job did appear: that check asks \"is\n * the object there\", not \"is it the one I meant\". So `id` is a REQUIRED prop and is always sent\n * on create. To adopt a job that already exists, declare its existing id; any other id is a new\n * job beside it, not an adoption.\n * ★ AN EXPLICIT id ALSO CLOSES A SECOND HOLE. `pveOperations.read` turns ANY failed GET into\n * \"absent\" — an expired lease, a 403, a node that did not answer — and reconcile then POSTs.\n * With an id, PVE refuses a duplicate section id and the deploy fails loudly; without one, that\n * same swallowed error would have quietly doubled the cluster's backup jobs.\n *\n * ⚠️ `Sys.Modify` ON `/` IS THE GATE AND IT IS NOT A SMALL GRANT. PVE has no Backup.* privilege:\n * create, update and delete of a vzdump job are all checked against `Sys.Modify` at `/` — the\n * same privilege that covers node network configuration. A credential that can declare backup\n * jobs can also rewrite the cluster's networking. That is PVE's granularity rather than a choice\n * made here, and it is exactly why widening a role for this should be a decision rather than a\n * reaction to a 403.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { bool, guestList, propertyString, text } from './values.ts';\n\n/**\n * ⚠️ THE PROPS ARE PVE'S OWN KEY NAMES, DASHES INCLUDED. `notes-template` rather than\n * `notesTemplate` is deliberate: `createForm` is then a copy rather than a translation table,\n * and a translation table is one more place for a key to be renamed and silently never sent. A\n * field that is never sent reads back as whatever it already was, which is indistinguishable\n * from \"PVE ignored me\".\n */\nexport interface BackupJobProps extends WithTarget {\n /** ⛔ The primary key, REQUIRED. Never let PVE generate it — see the ⛔ above. */\n id: string;\n /** A subset of systemd calendar events, e.g. `01:00` or `mon..fri 02:30`. */\n schedule: string;\n /** Target storage id. That storage's own retention applies unless `prune-backups` overrides it. */\n storage?: string;\n mode?: 'snapshot' | 'suspend' | 'stop';\n /** PVE's default is enabled. A disabled job is a backup that silently is not happening. */\n enabled?: boolean;\n /** Back up every guest. ⚠️ Pick exactly one of `all`, `vmid` and `pool` — see `shape` below. */\n all?: boolean;\n vmid?: readonly number[];\n pool?: string;\n /** Guest ids to skip. PVE reads this as \"all guests except these\", so it belongs with `all`. */\n exclude?: readonly number[];\n /** Retention, as a property string: `keep-daily=7,keep-weekly=4`. */\n 'prune-backups'?: string;\n /** Supports {{cluster}}, {{guestname}}, {{node}} and {{vmid}}. Single line only. */\n 'notes-template'?: string;\n 'notification-mode'?: 'auto' | 'legacy-sendmail' | 'notification-system';\n /** Run a missed job as soon as the scheduler is back. */\n 'repeat-missed'?: boolean;\n /** VM-only fleecing, as a property string: `enabled=1,storage=<id>`. See `propertyString`. */\n fleecing?: string;\n comment?: string;\n}\n\nexport interface BackupJobAttributes {\n id: string;\n schedule: string;\n storage: string;\n mode: string;\n enabled: boolean;\n all: boolean;\n /** Sorted and comma-joined, so re-ordering a declaration is not a diff. See `guestList`. */\n vmid: string;\n pool: string;\n exclude: string;\n /** Flattened and sorted — never the raw value PVE returned. See `propertyString`. */\n 'prune-backups': string;\n 'notes-template': string;\n 'notification-mode': string;\n 'repeat-missed': boolean;\n fleecing: string;\n comment: string;\n /**\n * PVE's own estimate, epoch seconds. REPORTED, NEVER COMPARED: `next-run` in `matches` would\n * report an update every time the clock passed a scheduled run. It is here so a plan can show\n * that a job is still due — a `next-run` of 0 is a job the scheduler will not run.\n */\n 'next-run': number;\n}\n\nexport interface ProxmoxBackupJob extends Resource<\n 'Proxmox.BackupJob',\n BackupJobProps,\n BackupJobAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxBackupJob = Resource<ProxmoxBackupJob>('Proxmox.BackupJob');\n\n/**\n * The form for both create and update.\n *\n * ⛔ A FIELD THE DECLARATION LEAVES OUT IS NOT SENT, AND THAT IS LOAD BEARING. PVE's PUT can only\n * SET a key; clearing one needs `delete=<key>`, which this resource deliberately never sends.\n * `updateForm` is handed the props and nothing else, so a `delete` list could only be \"every\n * field you did not declare\" — and on a job adopted out of the UI that would silently strip\n * settings this resource does not even model, `compress`, `mailto` and `bwlimit` among them, on\n * the first deploy. Leaving undeclared fields alone is the smaller lie, and `matches` tells the\n * same lie consistently: it does not compare what it cannot change.\n *\n * ⚠️ THE FIVE FIELDS PVE DOCUMENTS A DEFAULT FOR ARE ALWAYS SENT AND ALWAYS COMPARED — `enabled`\n * (1), `all` (0), `mode` (snapshot), `notification-mode` (auto), `repeat-missed` (0). That is\n * what makes a hand-flipped `enabled 0` show up as drift rather than as silence, and it is also\n * what stops those five looping: a field compared against a default must be sent as that\n * default, or every plan reports an update the PUT never performs. The cost is worth reading\n * before the first deploy against an adopted job — an omitted `all` is a declaration that this\n * job backs up NOTHING, and PVE accepts a job that selects nothing without a word. Read that\n * first plan; do not deploy it unseen.\n */\nconst shape = (props: BackupJobProps) => ({\n all: props.all === true ? '1' : '0',\n enabled: props.enabled === false ? '0' : '1',\n mode: props.mode ?? 'snapshot',\n 'notification-mode': props['notification-mode'] ?? 'auto',\n 'repeat-missed': props['repeat-missed'] === true ? '1' : '0',\n schedule: props.schedule,\n ...(props.comment === undefined ? {} : { comment: props.comment }),\n ...(props.exclude === undefined ? {} : { exclude: guestList(props.exclude) }),\n ...(props.fleecing === undefined ? {} : { fleecing: props.fleecing }),\n ...(props['notes-template'] === undefined ? {} : { 'notes-template': props['notes-template'] }),\n ...(props.pool === undefined ? {} : { pool: props.pool }),\n ...(props['prune-backups'] === undefined ? {} : { 'prune-backups': props['prune-backups'] }),\n ...(props.storage === undefined ? {} : { storage: props.storage }),\n ...(props.vmid === undefined ? {} : { vmid: guestList(props.vmid) }),\n});\n\nconst handlers = pveHandlers<BackupJobProps, BackupJobAttributes>({\n /**\n * ⛔ NO \"IS IT REALLY THERE\" GUARD, ON PURPOSE. Returning undefined for a job whose JSON is\n * missing some key would be a guess about which keys PVE echoes back, and a wrong guess here\n * does not read as absent-and-harmless: `reconcile` would POST, and POST creates ANOTHER job.\n * Absence is decided by the API declining to answer, which `pveOperations.read` already\n * handles — not by a key being missing from an answer that did arrive.\n */\n attributes: (live, props) => ({\n all: bool(live['all'], false),\n comment: text(live['comment'], ''),\n enabled: bool(live['enabled'], true),\n exclude: guestList(live['exclude']),\n fleecing: propertyString(live['fleecing'], 'enabled'),\n id: props.id,\n mode: text(live['mode'], 'snapshot'),\n 'next-run': typeof live['next-run'] === 'number' ? live['next-run'] : 0,\n 'notes-template': text(live['notes-template'], ''),\n 'notification-mode': text(live['notification-mode'], 'auto'),\n pool: text(live['pool'], ''),\n 'prune-backups': propertyString(live['prune-backups']),\n 'repeat-missed': bool(live['repeat-missed'], false),\n schedule: text(live['schedule'], ''),\n storage: text(live['storage'], ''),\n vmid: guestList(live['vmid']),\n }),\n collection: () => 'cluster/backup',\n /** ⛔ `id` IS SENT AND IS NOT OPTIONAL. Everything above depends on PVE not inventing one. */\n createForm: (props) => ({ ...shape(props), id: props.id }),\n /** Each line reads \"not declared, or equal\"; the five defaulted fields have no undeclared case. */\n matches: (attributes, props) =>\n attributes.schedule === props.schedule &&\n attributes.enabled === (props.enabled !== false) &&\n attributes.all === (props.all === true) &&\n attributes.mode === (props.mode ?? 'snapshot') &&\n attributes['notification-mode'] === (props['notification-mode'] ?? 'auto') &&\n attributes['repeat-missed'] === (props['repeat-missed'] === true) &&\n (props.storage === undefined || attributes.storage === props.storage) &&\n (props.pool === undefined || attributes.pool === props.pool) &&\n (props.comment === undefined || attributes.comment === props.comment) &&\n (props.vmid === undefined || attributes.vmid === guestList(props.vmid)) &&\n (props.exclude === undefined || attributes.exclude === guestList(props.exclude)) &&\n (props['notes-template'] === undefined ||\n attributes['notes-template'] === props['notes-template']) &&\n (props['prune-backups'] === undefined ||\n attributes['prune-backups'] === propertyString(props['prune-backups'])) &&\n (props.fleecing === undefined ||\n attributes.fleecing === propertyString(props.fleecing, 'enabled')),\n path: (props) => `cluster/backup/${props.id}`,\n updateForm: shape,\n});\n\n/**\n* ⛔ Empty for the same reason as every other resource here: adoption must be explicit.\n* `GET /cluster/backup` would hand back the job somebody made by hand, and adopting it\n* implicitly would give Alchemy the right to DELETE a cluster's only backup schedule the\n* first time a line left a stack file.\n \n *\n* ⚠️ DELETING THE JOB DOES NOT DELETE THE BACKUPS, AND THAT CUTS BOTH WAYS. The archives\n* stay on the storage, so this looks harmless today; it is destructive in six months,\n* when the schedule that should have replaced them has not run since. PVE will not\n* refuse this the way it refuses to delete a pool still holding guests — nothing depends\n* on a backup job — so the plan line is the only warning anyone gets.\n \n */\nexport const ProxmoxBackupJobProvider = () =>\n Provider.effect(ProxmoxBackupJob, Effect.succeed(ProxmoxBackupJob.Provider.of(handlers)));\n",
15
+ "/**\n * `Proxmox.CephDaemon` — a Ceph monitor, manager or metadata server on one node.\n *\n * ★ ONE RESOURCE FOR THREE KINDS, AND THE SCHEMAS WERE CHECKED BEFORE THAT WAS DECIDED. Parsed\n * from `/usr/share/pve-docs/api-viewer/apidoc.js` on n2, 2026-09-13: mon, mgr and mds each\n * expose GET on the collection and POST + DELETE on the id below it, each returns\n * name/host/state/addr/ceph_version*, and the only divergence is the create parameter\n * (`mon-address` / none / `hotstandby`) and the read-only extras (mon: quorum, rank; mds: rank,\n * fs_name, standby_replay). Three near-identical files would have carried the traps below three\n * times over and let them drift — the argument resource.ts already makes for the factory itself.\n *\n * ⛔ THE ONLY GET IS THE COLLECTION'S, AND IT ANSWERS FOR THE WHOLE CLUSTER. MEASURED:\n * `GET /nodes/n2/ceph/mon` returns n2, n3 AND n4, and `GET /nodes/n3/ceph/mon` returns the same\n * three IN A DIFFERENT ORDER — [n4,n2,n3] from n2, [n3,n2,n4] from n3 — so a row is found by\n * `name` and NEVER by position, and the `{node}` in the path is only the node being ASKED.\n * MEASURED too: there is no GET on the id path at all; `pvesh get /nodes/n2/ceph/mon/n2` answers\n * \"No 'get' handler defined for '/nodes/n2/ceph/mon/n2'\", and mgr and mds answer the same.\n * That is why `path()` below is the COLLECTION, and that in turn is why `delete` is the one\n * handler this file writes by hand: `pveOperations.destroy` sends its DELETE to `spec.path`,\n * which here would be the collection — a 501 reported as a failed destroy, with the daemon still\n * running. Same shape and same rule as the override in acl.ts: do not \"restore symmetry\" by\n * pointing it back at `ops.destroy`.\n *\n * ⛔ WHAT A DESTROY ACTUALLY DOES, BECAUSE THE PLAN LINE SAYS ONLY \"delete\". REASONED FROM PVE'S\n * AND CEPH'S DOCUMENTED BEHAVIOUR, NOT MEASURED — nothing on this cluster was destroyed to find\n * out, and nothing should be to check. `mon`: stops ceph-mon@id, removes it from the monmap and\n * strips its section from ceph.conf. THREE MONS TOLERATE ONE LOSS; TWO TOLERATE NONE. Removing\n * two in one deploy — or removing the mon on the node whose API is serving the call — loses\n * quorum, and a cluster without mon quorum BLOCKS every RBD and CephFS I/O rather than erroring\n * it, so on this cluster every guest on `cephtb4` hangs.\n * `mds`: destroying a STANDBY is a non-event; destroying the ACTIVE one fails CephFS over,\n * and with no standby left `cephfs-tb4` goes unavailable. `mgr`: no guest I/O depends on it, but\n * the last one takes the PG autoscaler, the dashboard and PVE's own Ceph status with it.\n * Live on 2026-09-13: mon, mgr AND mds on each of n2, n3, n4.\n *\n * ★ AND THE ONLY WAY TO REACH THAT DESTROY IS TO DELETE THE DECLARATION. `matches` is deliberately\n * total (see its ⛔), so this resource CANNOT plan a `replace` — which is the one action that\n * would tear down a live mon off the back of an edited field rather than a removed line.\n *\n * ⚠️ THE PRIVILEGES ARE ASYMMETRIC AND THE READ SIDE IS THE CHEAP ONE. The GET checks `any` of\n * `Sys.Audit`/`Datastore.Audit` on `/`, and PVEAuditor holds both (MEASURED:\n * `GET /access/roles/PVEAuditor`), so the mount's `read` role can see this family — unlike\n * `Proxmox.Storage`, which 403s under that lease. POST and DELETE both check `Sys.Modify` on\n * `/`, and MEASURED on this cluster `LXCProvisioner` already holds it, so the provision lane\n * needs no widening for once. ⚠️ `Sys.Modify` on the ROOT path is broad — it also buys\n * datacenter options and every other cluster-wide config write — so it is worth knowing that\n * this credential already has it rather than discovering it the next time something is scoped.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { collectionPath, createForm, daemonId, daemonPath, findRow } from './ceph-daemon-form.ts';\nimport { pve } from './client.ts';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { bool, num, text } from './values.ts';\n\n/**\n * Which Ceph daemon this is. The discriminant picks the collection, the create parameters and\n * which of the read-only extras below will even be populated.\n *\n * ⚠️ `osd` IS NOT HERE AND MUST NOT BE ADDED TO THIS UNION. `/nodes/{node}/ceph/osd` takes a disk\n * device, wipes it, and its DELETE has a `cleanup` flag — a create that destroys data on the way\n * in is a different resource with a different set of refusals, not a fourth case in this one.\n */\nexport type CephDaemonKind = 'mon' | 'mgr' | 'mds';\n\nexport interface CephDaemonProps extends WithTarget {\n kind: CephDaemonKind;\n /**\n * The node the daemon RUNS on. Identity — a daemon cannot be moved, only destroyed and rebuilt.\n * ⚠️ It is also the node whose API is asked, and the read is only as available as that node: a\n * node that is down — or has no Ceph installed, or answers 403 — reads as nothing at all,\n * because `pveOperations.read` folds EVERY failure into \"absent\" (a 404 is a legitimate answer\n * there and it cannot tell the two apart). Its daemons then plan as `update`, and reconcile\n * POSTs a create for a mon that already exists. PVE refuses that with \"monitor already\n * exists\", and the read-back refuses again — so it fails loudly rather than damaging anything,\n * but the message will point at the daemon rather than at the node that would not answer.\n */\n node: string;\n /**\n * The daemon id. PVE defaults it to the nodename, and `daemonId` in ceph-daemon-form.ts resolves\n * that default HERE rather than leaving it to PVE, because the id is a PATH SEGMENT: create,\n * delete and the row lookup all need the same string, and a default resolved on the far side\n * would leave three call sites guessing. Live on this cluster every daemon's name is its node.\n */\n name?: string;\n /**\n * mon only. Overrides the autodetected monitor IP; must sit in Ceph's public network — on this\n * cluster that is 10.20.11.0/24, carried by `vmbr1.11`.\n * ⛔ CREATE-ONLY AND NEVER COMPARED. PVE takes a bare ip-list on write and hands back `addr` as\n * `10.20.11.12:6789/0` — an address, a port and a nonce. The two are not the same string and\n * never will be, so diffing them would report a mismatch on every plan; with no PUT on this\n * family that mismatch becomes a REPLACE, and a replace of a mon is the quorum loss in the\n * header. Left out of `matches` on purpose.\n */\n 'mon-address'?: string;\n /**\n * mds only. Makes this standby replay the active MDS's journal for a faster failover.\n * ⛔ CREATE-ONLY AND NEVER COMPARED, AND THE FIELD THAT LOOKS LIKE ITS READBACK IS NOT ONE.\n * `standby_replay` in the list is the daemon's CURRENT state, not its configuration: MEASURED\n * 2026-09-13, all three mds report `standby_replay: false`, n3 included — and n3 is the ACTIVE\n * mds, which is not a standby at all and so can never report true however it was created.\n * Comparing `hotstandby` to it would plan a replace against whichever mds Ceph happens to have\n * elected, i.e. against a value no declaration controls.\n * ⚠️ SET ON A mon OR mgr IT IS DROPPED RATHER THAN SENT, and `mon-address` likewise on an mds:\n * each POST schema lists only its own parameter, so the wrong one is a 400 rather than an\n * ignored hint. A field silently dropped is the lesser of the two, but it IS dropped.\n */\n hotstandby?: boolean;\n}\n\n/**\n * Everything the cluster says about this daemon — reported, and (bar its identity) none of it\n * compared. Read the ⛔ on `matches` for why that is the only safe split on this family.\n */\nexport interface CephDaemonAttributes {\n kind: CephDaemonKind;\n node: string;\n name: string;\n /**\n * The host Ceph says it runs on.\n * ⚠️ REPORTED, NOT COMPARED, AND THAT IS A DELIBERATE BLIND SPOT. A daemon found under this name\n * on a DIFFERENT node than `node` declares plans as `noop`, which does hide a misdeclaration.\n * The alternative is worse: `host` is `optional` in the schema, so an absent one would read as\n * a mismatch, and with no PUT a mismatch is a replace — i.e. a missing field in one API answer\n * would destroy a live mon. When in doubt, out of `matches`; fix a wrong node by hand.\n */\n host: string;\n /**\n * mon `running`/`stopped`/`unknown`, mgr `active`/`standby`, mds `up:active`/`up:standby`/…\n * ⛔ CEPH ELECTS THIS AND REWRITES IT WITHOUT ANYONE DECLARING ANYTHING. MEASURED: mgr n2 is\n * `active` while n3 and n4 are `standby`; mds n3 is `up:active` while n2 and n4 are\n * `up:standby`. Restart a daemon and the roles move. It is reported so a plan can show what is\n * live and kept out of `matches` so that an election is never a diff.\n * ⚠️ IT ALSO MEANS THIS RESOURCE DOES NOT MANAGE WHETHER THE DAEMON IS RUNNING. A configured but\n * stopped daemon is still a row in the list, so it reads as present and plans `noop`.\n */\n state: string;\n /** Ceph-formatted, e.g. `10.20.11.12:6789/0`. Reported; see `mon-address` for why never compared. */\n addr: string;\n /** `ceph_version_short`, e.g. `20.2.2`. Reported: a straggler after an upgrade is worth seeing. */\n version: string;\n /**\n * mon rank in the monmap, mds rank in the filesystem, `-1` when the daemon has neither.\n * ⛔ CEPH ASSIGNS IT AND NOTHING DECLARES IT. MEASURED: the mons are ranked n4=0, n3=1, n2=2 —\n * monmap order, not declaration order — and the mds ranks are 0 for the active n3 and -1 for\n * the two standbys. Rank moves when a daemon is added, removed or restarted.\n */\n rank: number;\n /** mon only: in the current quorum. Reported. MEASURED: all three mons are in quorum. */\n quorum: boolean;\n /** mds only, and NOT the readback of `hotstandby` — see the ⛔ on that prop. */\n standbyReplay: boolean;\n /**\n * mds only: the CephFS this daemon currently serves — `cephfs-tb4` here.\n * ⛔ PRESENT ONLY ON THE ACTIVE MDS. MEASURED: n3 carries `fs_name`, n2 and n4 have no such key\n * at all. So it is empty for two of three identical declarations, and comparing it would\n * report work on exactly the daemons that are healthy standbys.\n */\n fsName: string;\n /** A `ceph-<kind>@<id>` systemd unit is enabled on the host. Reported; absent reads as false. */\n service: boolean;\n}\n\nexport interface ProxmoxCephDaemon extends Resource<\n 'Proxmox.CephDaemon',\n CephDaemonProps,\n CephDaemonAttributes,\n never,\n PveRequirements\n> {}\n\n/** ★ `retain` by default — a mon carrying quorum cannot be rebuilt. See the ★ in resource.ts. */\nexport const ProxmoxCephDaemon = Resource<ProxmoxCephDaemon>('Proxmox.CephDaemon', {\n defaultRemovalPolicy: 'retain',\n});\n\nconst handlers = pveHandlers<CephDaemonProps, CephDaemonAttributes>({\n /** ⚠️ `undefined` when no row carries this name: that is how the factory learns to create. */\n attributes: (live, props) => {\n const row = findRow(live, props);\n if (row === undefined) return undefined;\n return {\n addr: text(row['addr']),\n fsName: text(row['fs_name']),\n host: text(row['host']),\n kind: props.kind,\n name: daemonId(props),\n node: props.node,\n quorum: bool(row['quorum']),\n rank: num(row['rank'], -1),\n service: bool(row['service']),\n standbyReplay: bool(row['standby_replay']),\n state: text(row['state']),\n version: text(row['ceph_version_short']),\n };\n },\n /** ⛔ The ID path, not the collection — POST is registered on `{id}`, exactly like a metric server. */\n collection: daemonPath,\n createForm,\n /**\n * ⛔ TOTAL, AND THIS IS THE REASON THE FILE EXISTS RATHER THAN A SHORTCUT PAST WRITING IT. Every\n * field a declaration can carry is CREATE-ONLY and unreadable — `mon-address` comes back as a\n * different kind of string, `hotstandby` comes back as a state Ceph elects — and every field\n * the read returns is assigned by Ceph: state, rank, quorum, fs_name, standby_replay, addr,\n * version. Nothing is left that is both declared and readable. So the honest comparison is\n * \"does a daemon of this kind and name exist\", which `attributes` has already answered by\n * returning a value at all, and anything further would be a diff no write could ever satisfy.\n * ⛔ AND ON THIS FAMILY THAT DIFF IS NOT MERELY NOISY. There is no PUT, so resource.ts answers\n * `replace` rather than `update` whenever `matches` is false — and replace on a mon is\n * delete-then-create against a live quorum. A forever-diff here is a forever-OUTAGE-RISK.\n * ⚠️ THE PRICE, STATED PLAINLY: editing `hotstandby` or `mon-address` on a declared daemon\n * plans as `noop` and never applies. Same bargain storage.ts strikes for a changed `type`.\n * Change one by removing the declaration and re-adding it, ONE DAEMON AT A TIME, reading the\n * ⛔ on destroy in the header first.\n */\n matches: () => true,\n /** ⛔ The COLLECTION, because there is no GET on the id path. See the second ⛔ in the header. */\n path: collectionPath,\n /** ⚠️ No `updateForm`: none of the three has a PUT, so nothing about a daemon is editable. */\n});\n\nexport const ProxmoxCephDaemonProvider = () =>\n Provider.effect(\n ProxmoxCephDaemon,\n Effect.succeed(\n ProxmoxCephDaemon.Provider.of({\n ...handlers,\n /**\n * ⛔ THE ONE HANDLER NOT TAKEN FROM THE FACTORY, AND THE ONLY REASON IS THE PATH SPLIT.\n * `ops.destroy` DELETEs `spec.path`, which this resource must point at the collection so\n * that `read` works at all; DELETE on the collection is not implemented and would answer\n * 501 while the daemon kept running — a failed destroy that reads like a permissions\n * problem. Everything else here is the factory's.\n * ⚠️ AND IT IS THE DANGEROUS ONE. Re-read the destroy ⛔ in the header before letting a\n * plan that removes a mon run: two gone at once is a cluster with no quorum and every\n * guest on `cephtb4` blocked on I/O.\n */\n delete: ({ olds }: { olds: CephDaemonProps }) =>\n pve(olds.target, 'provision', 'DELETE', daemonPath(olds)),\n }),\n ),\n );\n",
16
+ "/**\n * Where a Ceph daemon lives on the API, and what a declaration of one looks like as a PVE form.\n *\n * ★ SPLIT OUT OF ceph-daemon.ts TO KEEP BOTH FILES UNDER THE 250-LINE CAP, and the seam is a real\n * one rather than a convenient line number — the same seam metric-server-form.ts cuts on.\n * This file answers \"how does a declaration address ONE daemon\" — which URL, which body, and\n * which row of the collection's answer is it. ceph-daemon.ts answers \"what does the cluster\n * say about that daemon, and when has it changed\". Nothing here calls the API and nothing\n * here decides a diff; `findRow` picks a row out of an answer its caller already fetched.\n *\n * ⛔ THE TWO PATHS ARE DIFFERENT AND THAT IS THE WHOLE REASON THIS FILE HAS TWO OF THEM. MEASURED\n * on n2, 2026-09-13: there is no GET on the id path — `pvesh get /nodes/n2/ceph/mon/n2` answers\n * \"No 'get' handler defined\" — while POST and DELETE are registered ONLY there. So the read uses\n * `collectionPath` and the two writes use `daemonPath`, and swapping either one is a silent\n * 501: a create that never lands, or a destroy that reports failure while the daemon runs on.\n *\n * ⚠️ THE `import type` BACK TO ceph-daemon.ts IS A CYCLE ON PAPER ONLY — type-only, so it is\n * erased before anything runs. `CephDaemonProps` stays the resource's public shape, in the file\n * that declares the resource.\n *\n * ⛔ POST AND DELETE RETURN A UPID, NOT AN OBJECT — both are `protected` task endpoints whose\n * schema `returns` is a bare string. REASONED, NOT MEASURED: this cluster is read-only to me, so\n * no create was ever run. The consequence to expect is that `reconcile` reads back immediately\n * after the POST, and if the worker has not yet written ceph.conf the read-back still says\n * absent and reconcile dies with \"the write returned no error but the object is still absent\".\n * That refusal is honest — nothing is recorded for an object that is not there — and a second\n * deploy converges once the task has finished, but it is a confusing FIRST-RUN failure. Watch\n * the task in the PVE UI before concluding the create failed.\n *\n */\nimport type { CephDaemonProps } from './ceph-daemon.ts';\nimport { flag } from './values.ts';\n\n/**\n * PVE defaults the id to the nodename for all three kinds, and that default is resolved HERE\n * rather than left to PVE, because the id is a PATH SEGMENT: create, delete and the row lookup in\n * ceph-daemon.ts all need the same string, and a default resolved on the far side would leave\n * three call sites guessing. Live on this cluster every daemon's name equals its node.\n */\nexport const daemonId = (props: CephDaemonProps) => props.name ?? props.node;\n\n/**\n * The read path. ⚠️ `{node}` HERE IS ONLY THE NODE BEING ASKED, not a filter. MEASURED:\n * `GET /nodes/n2/ceph/mon` returns n2, n3 AND n4, and `GET /nodes/n3/ceph/mon` returns the same\n * three IN A DIFFERENT ORDER — [n4,n2,n3] from n2 against [n3,n2,n4] from n3. A caller that took\n * row zero, or assumed the list was this node's daemons, would be wrong on both counts.\n */\nexport const collectionPath = (props: CephDaemonProps) => `nodes/${props.node}/ceph/${props.kind}`;\n\n/** The write path: POST creates here, DELETE destroys here. Never read from — see the ⛔ above. */\nexport const daemonPath = (props: CephDaemonProps) => `${collectionPath(props)}/${daemonId(props)}`;\n\n/**\n * The create body, which is EMPTY for a mgr and nearly empty for the other two.\n *\n * ⚠️ THE ID IS NOT SENT, because it is already the last segment of the path being POSTed to — the\n * same reasoning as metric-server.ts, where a second copy of the key can only disagree with the\n * first. PVE's schema does accept `monid`/`id`/`name` as body parameters; the path wins, so\n * sending one would be a second source of truth for the object's identity and nothing else.\n *\n * ⚠️ AND THE BRANCHES CANNOT BE ONE SHARED BODY. `hotstandby` is an mds parameter and\n * `mon-address` a mon one; each POST schema lists only its own, so the wrong field is a 400\n * rather than an ignored hint. Both are create-only — the ⛔s on those props say why neither is\n * ever compared afterwards.\n */\nexport const createForm = (props: CephDaemonProps): Record<string, string> => {\n if (props.kind === 'mon' && props['mon-address'] !== undefined) {\n return { 'mon-address': props['mon-address'] };\n }\n const hotstandby = props.kind === 'mds' ? flag(props.hotstandby) : undefined;\n return hotstandby === undefined ? {} : { hotstandby };\n};\n\n/**\n * ⚠️ THE COLLECTION ANSWERS AN ARRAY while the factory types `attributes`' first parameter as the\n * `Record<string, unknown>` every other PVE read is shaped like — the same mismatch acl.ts\n * carries, handled the same way: narrow the rows, trust none of them, and match on `name`.\n * ⚠️ MATCHED ON `name` ALONE, NEVER ON POSITION — the list comes back in a different order\n * depending on which node was asked. See the ⚠️ on `collectionPath` above.\n */\nexport const findRow = (live: unknown, props: CephDaemonProps) =>\n (Array.isArray(live) ? live : [])\n .filter((row): row is Record<string, unknown> => typeof row === 'object' && row !== null)\n .find((row) => row['name'] === daemonId(props));\n",
17
+ "/**\n * `Proxmox.CephFlag` — one cluster-wide Ceph OSD flag, declared: `noout`, `pause`, `norebalance`.\n *\n * ★ ONE RESOURCE PER FLAG, NOT ONE CARRYING ALL ELEVEN, AND THE CLUSTER'S OWN API DECIDED IT.\n * MEASURED on TB4 2026-09-13 (pve-manager 9.2.11, ceph tentacle 20.2.2) by reading\n * `/usr/share/perl5/PVE/API2/Cluster/Ceph.pm` and the published schema in\n * `/usr/share/pve-docs/api-viewer/apidoc.js`:\n * · `PUT /cluster/ceph/flags` ends in `fork_worker('cephsetflags', ...)` and returns a STRING\n * — a UPID. The bulk write is ASYNCHRONOUS, and this package has no task-polling machinery.\n * · `PUT /cluster/ceph/flags/{flag}` calls `$rados->mon_command` inline and returns null. The\n * per-flag write is SYNCHRONOUS.\n * `pveOperations.reconcile` READS BACK after every write and refuses to record a value it did\n * not see. Against the bulk endpoint that read-back races a worker which has not run yet, so it\n * would record the OLD value as the new attributes — the one honesty mechanism in this package\n * turned into a lie generator. Per-flag, the read-back means what it says.\n * ★ THE SECOND REASON IS SMALLER AND STILL REAL. The bulk GET answers rows of\n * `{name, description, value}`, and `description` is PVE's own English prose that no write\n * accepts: compare it and you have a forever-update, report it and this provider is pretending\n * to manage prose. `GET /cluster/ceph/flags/{flag}` answers a BARE BOOLEAN, so that trap\n * cannot be written here at all. The brief's plural `Proxmox.CephFlags` became singular for\n * those two reasons; the bulk endpoint is read by nothing in this package.\n *\n * ⛔ THESE ARE NOT CONFIGURATION. THEY ARE A HAND ON THE BRAKE, AND A DECLARATION CAN PULL IT OFF.\n * `noout` is what a person sets before pulling a disk. A stack saying `value: false` reasserts\n * that off on EVERY deploy — including a deploy somebody else runs, for an unrelated resource,\n * twenty minutes into a maintenance window — and the plan line reads `Proxmox.CephFlag noout\n * update`, which nobody reads as \"ceph is about to start rebalancing 128 PGs across three nodes\n * while a disk is out of the chassis\".\n * ★ SO `value` IS REQUIRED AND HAS NO DEFAULT, AND THAT IS THE MITIGATION. An optional `value`\n * defaulting to false would make `CephFlag('noout', { flag: 'noout', target })` mean \"clear\n * it\" — the dangerous direction, chosen by OMISSION. Here the dangerous sentence has to be\n * typed out by a person. Do not add a default, and do not declare a flag merely to document\n * that it is off: MEASURED 2026-09-13, all eleven flags on TB4 read 0, so eleven\n * `value: false` lines would plan green forever and do nothing except take the brake off\n * whenever somebody happens to apply them.\n *\n * ⛔ `delete` DOES NOTHING, ON PURPOSE, AND THE ASYMMETRY OF THE TWO FAILURES IS THE ARGUMENT.\n * `flags/{flag}` has exactly two methods, GET and PUT, so the factory's `destroy` would answer\n * \"Method 'DELETE /cluster/ceph/flags/noout' not implemented\" on every teardown — whatever this\n * handler does is INVENTED. The obvious invention, \"clear the flag\", is refused: removing a line\n * from a stack file, or Alchemy collecting an old generation after a replace, would silently\n * take the brake off and nothing would warn. Leaving a flag set that nothing declares any more\n * is the opposite kind of failure — ceph reports `HEALTH_WARN ... flag(s) set` for every one of\n * these, on `ceph -s`, in the PVE UI and in the `pve_*` metrics this estate already scrapes.\n * A silent destructive failure loses to a loud inert one.\n * ⚠️ THE RESIDUAL RISK, NAMED RATHER THAN DENIED: deleting a `value: true` declaration LEAVES\n * THE FLAG SET. Retire a maintenance window by flipping the line to `value: false` and\n * deploying BEFORE the line is removed, or a `noout` outlives the window that needed it.\n * ⚠️ REASONED, NOT MEASURED: that health warning was not observed, because observing it means\n * setting a flag on a live cluster and this file was researched read-only. Undeclaring stops\n * MANAGING a flag; to clear one, declare `value: false` and deploy, where a plan says so.\n *\n * ⛔ `pause` IS TWO CEPH FLAGS AND THIS RESOURCE READS ONLY ONE OF THEM. MEASURED in\n * `PVE::Ceph::Tools::get_real_flag_name`, whose own comment reads \"the 'pause' flag gets always\n * set to both 'pauserd' and 'pausewr'\": PVE writes both and then decides the flag is set by\n * looking at `pauserd` alone. A cluster where somebody ran `ceph osd unset pauserd` by hand\n * still has `pausewr` — writes blocked, guests hung — and this resource reports `value: false`\n * and plans `noop` straight past it. It cannot express a half-pause, so never use it to prove\n * one is gone; `ceph osd dump | head -1` can.\n * ⛔ `pause` AND `noup` ARE ALSO THE TWO THAT TAKE THE CLUSTER DOWN FROM A TYPO. `pause: true`\n * stops all reads and writes, so every guest on `cephtb4` — the cluster's only rbd pool,\n * MEASURED 2026-09-13 — freezes on its root disk, and so does `cephfs-tb4`. `noup: true`\n * stops a rebooted OSD from ever rejoining. Neither is undone by deleting the line.\n *\n * ⚠️ PRIVILEGES, AND THE WRITE ONE IS A BIG ASK. Both GETs check `Sys.Audit` on `/`; both PUTs\n * check `Sys.Modify` on `/`, and all four carry `allowtoken => 1`, so an API token may make the\n * call at all. There is no `/ceph` ACL object to scope to — the check names the ROOT path\n * literally — so granting the provision role `Sys.Modify` here also buys datacenter options,\n * metric servers, notification targets and every other cluster-wide write, exactly as\n * metric-server.ts warns about its own family.\n * ⚠️ REASONED, NOT MEASURED: nothing here was exercised under a minted lease, because a mint\n * writes an API token into the cluster and the brief for this file was reads only. Expect\n * \"Permission check failed (/, Sys.Modify)\" on the first deploy, and widen deliberately.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { bool, flag } from './values.ts';\n\n/**\n * PVE's eleven flags, spelled as `PVE::Ceph::Tools::get_possible_osd_flags` spells them.\n *\n * ⚠️ THE ENUM IS CLOSED AND A TYPO IS A 400, WHICH IS WHY THIS IS A UNION AND NOT `string`. Both\n * the GET and the PUT declare `additionalProperties => 0` over exactly this list.\n * ⚠️ CEPH HAS FLAGS PVE DOES NOT MODEL, and four of them are always on. MEASURED on TB4:\n * `ceph osd dump` reports `flags sortbitwise,recovery_deletes,purged_snapdirs,pglog_hardlimit`.\n * PVE reads that same string and answers only about its own eleven, so the others can neither\n * leak in here nor be set from here — `noautoscale` and `nosnaptrim` included.\n * ⛔ IF SOMEBODY LATER \"IMPROVES\" THE READ BY PARSING `osd dump` DIRECTLY, those four become\n * permanently-set flags that nothing declares: a forever-diff on a brand new cluster.\n */\nexport type CephFlagName =\n | 'nobackfill'\n | 'nodeep-scrub'\n | 'nodown'\n | 'noin'\n | 'noout'\n | 'norebalance'\n | 'norecover'\n | 'noscrub'\n | 'notieragent'\n | 'noup'\n | 'pause';\n\nexport interface CephFlagProps extends WithTarget {\n /**\n * Which flag. PVE's primary key here, and the last segment of the path.\n *\n * ⚠️ EDITING IT IN PLACE ORPHANS THE OLD FLAG RATHER THAN MOVING ANYTHING. `diff` reads the NEW\n * path and reconcile writes it, while the old flag keeps whatever this stack last put there.\n * There is deliberately no replace override for it — acl.ts needs one because its `delete`\n * removes a real grant, and `delete` here is inert by design, so a replace would do exactly\n * what an update already does. Declare a second resource and set the old one to `value: false`\n * rather than renaming this one.\n * ⛔ TWO RESOURCES DECLARING THE SAME FLAG ARE ONE CLUSTER OBJECT, and Alchemy sees two ids\n * rather than a collision — the acl.ts hazard exactly. Disagreeing, they take turns winning\n * and BOTH plan `update` for ever; agreeing, deleting either leaves the flag where the other\n * put it. One declaration per flag per cluster.\n */\n flag: CephFlagName;\n /**\n * Set the flag (`true`) or clear it (`false`).\n *\n * ⛔ REQUIRED, WITH NO DEFAULT — see the second ⛔ in the header, which is the whole safety\n * argument for this family. It is also the only field PVE accepts on this endpoint, and it is\n * not optional in the schema either: omitting it from the form is a 400, not an untouched\n * flag. (The BULK endpoint is the one where omission means \"leave it alone\"; this is not it.)\n */\n value: boolean;\n}\n\nexport interface CephFlagAttributes {\n /**\n * ⚠️ REPORTED, NEVER COMPARED. It is the path key the read was made WITH, copied back out of\n * props, so comparing it against props would be true by construction — the same reasoning\n * acl.ts gives for the four identity fields it also declines to diff.\n */\n flag: CephFlagName;\n /** Whether ceph has the flag set right now. The only field `matches` looks at. */\n value: boolean;\n}\n\nexport interface ProxmoxCephFlag extends Resource<\n 'Proxmox.CephFlag',\n CephFlagProps,\n CephFlagAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxCephFlag = Resource<ProxmoxCephFlag>('Proxmox.CephFlag');\n\nconst handlers = pveHandlers<CephFlagProps, CephFlagAttributes>({\n /**\n * ⚠️ `live` IS A BARE BOOLEAN HERE, NOT AN OBJECT, AND IT IS HANDED TO `bool` WHOLE ON PURPOSE.\n * `get_flag` returns perl `1` or `0` under a `type => 'boolean'` return schema, so the wire is\n * `{\"data\":0}` or `{\"data\":false}` depending on how the REST layer renders it. `bool` accepts\n * every one of those spellings, which is exactly why it is a shared coercion. The factory\n * types this parameter `Record<string, unknown>` because every OTHER PVE read is an object;\n * reaching for `live['value']` here would answer undefined on every plan and diff `false`\n * forever against a set flag.\n * ⚠️ THE SCALAR IS A MEASURED PROPERTY OF THIS PVE, NOT A PROMISE. A later version wrapping\n * the answer in an object would make `bool` read a SET flag as false, and `value: false`\n * would then plan `noop` over a live flag — silently. Re-measure\n * `GET /cluster/ceph/flags/noout` after a major upgrade; cheaper than a second parse path.\n *\n * ⛔ IT NEVER ANSWERS undefined, WHICH MAKES THE CREATE BRANCH UNREACHABLE, AND ITS ERROR WILL\n * MISLEAD YOU. All eleven flags always exist; there is nothing for \"absent\" to mean. So a POST\n * to `collection` means the READ failed — an expired 300s lease, n2 down, or ceph simply not\n * configured on the cluster (every one of these four handlers opens with\n * `check_ceph_configured()`, which dies). Read the resulting \"Method 'POST /cluster/ceph/flags'\n * not implemented\" as \"the read failed\" and go and look at the credential, not at ceph. Same\n * shape as the unreachable POST in acl.ts, same advice.\n */\n attributes: (live, props) => ({ flag: props.flag, value: bool(live) }),\n collection: () => 'cluster/ceph/flags',\n /**\n * ⛔ UNREACHABLE — see the second ⛔ in `attributes`. It is written in the BULK endpoint's shape\n * (the flag name is the parameter, not `value`) rather than left empty, because that is the\n * only body `cluster/ceph/flags` has ever documented. Nothing sends it today.\n */\n createForm: (props) => ({ [props.flag]: flag(props.value) ?? '0' }),\n /**\n * ⚠️ `value` IS THE ONLY THING COMPARED, AND THE LIST OF THINGS DELIBERATELY NOT COMPARED IS THE\n * point of this resource. `flag` is props-derived (see `CephFlagAttributes`). `description`\n * and `name` exist only on the bulk GET, which this file does not read, so neither can be\n * compared by accident. Nothing PVE returns here is rewritten, re-ordered or re-typed by the\n * cluster, because all PVE returns here is one boolean.\n * ★ MEASURED: on TB4, `GET /cluster/ceph/flags` answers value 0 for all eleven flags, so a\n * declaration of `value: false` reads back false and plans `noop`.\n */\n matches: (attributes, props) => attributes.value === props.value,\n path: (props) => `cluster/ceph/flags/${props.flag}`,\n /**\n * ⚠️ ONLY `value` GOES IN THE BODY. `flag` is already bound by the path and the PUT declares\n * `additionalProperties => 0`, so a second copy in the form could only disagree with the URL.\n * ⚠️ THE `?? '0'` IS UNREACHABLE, AND IS WRITTEN RATHER THAN CAST AWAY. `flag()` types its\n * answer `string | undefined` because it serves OPTIONAL props, and `value` here is required,\n * so the branch cannot be taken; a cast would claim a proof the type system has not made.\n */\n updateForm: (props) => ({ value: flag(props.value) ?? '0' }),\n});\n\nexport const ProxmoxCephFlagProvider = () =>\n Provider.effect(\n ProxmoxCephFlag,\n Effect.succeed(\n ProxmoxCephFlag.Provider.of({\n /**\n * ⚠️ NOT THE ONE-LINE `Provider.of(handlers)` EVERY OTHER FILE HERE USES, AND THE TWO\n * REASONS ARE BOTH acl.ts's. PVE implements no DELETE on this path, and the factory's\n * read-back guard is dead whenever `attributes` cannot answer undefined. Unlike acl.ts\n * this SPREADS the factory's handlers instead of retyping them, so `list`, `read` and\n * `diff` cannot drift from the shared ones — only the two that genuinely differ are\n * written out below.\n */\n ...handlers,\n /** ⛔ Inert, deliberately. The third ⛔ in the header is the whole argument; read it. */\n delete: () => Effect.void,\n /**\n * ⚠️ THE READ-BACK GUARD, RESTORED FOR A FAMILY WHOSE \"ABSENT\" DOES NOT EXIST.\n * `ops.reconcile` refuses when the object is still missing after a write, and a flag is\n * never missing, so that check can never fire here — exactly the hole acl.ts patches\n * with `bound`. PVE answers 200 with `{\"data\":null}` on calls that did nothing, and this\n * PUT's documented return IS null, so the status code carries no evidence at all.\n * ⚠️ THE PER-FLAG PUT IS SYNCHRONOUS (`$rados->mon_command` inline, MEASURED in Ceph.pm),\n * which is what makes this check fair rather than a race against a worker task. If it\n * ever fires spuriously the honest fix is to look at the mon, not to delete the guard.\n */\n reconcile: Effect.fn(function* ({ news }) {\n const after = yield* handlers.reconcile({ news });\n if (after.value !== news.value) {\n return yield* Effect.die(\n new Error(\n `cluster/ceph/flags/${news.flag}: the PUT returned no error but ceph still ` +\n `reports the flag ${after.value ? 'set' : 'clear'} rather than ` +\n `${news.value ? 'set' : 'clear'}. This endpoint's success is documented as a ` +\n 'null body, so the status code proves nothing -- check `ceph osd dump | ' +\n 'head -1` and the cluster log. `pause` in particular is two ceph flags read ' +\n 'as one; see the header.',\n ),\n );\n }\n return after;\n }),\n }),\n ),\n );\n",
18
+ "/**\n * `Proxmox.CephFs` — a CephFS on the cluster's own Ceph. The filesystem a `cephfs` storage mounts.\n *\n * ⛔ A REPLACE OF THIS RESOURCE DESTROYS A LIVE FILESYSTEM, AND THERE IS NO PUT TO SAVE YOU FROM\n * IT. MEASURED from the published schema on n2, 2026-09-13: `/nodes/{node}/ceph/fs/{name}` has\n * exactly two methods, POST and DELETE. A CephFS cannot be edited in place, so `updateForm` is\n * left undefined and anything the factory can see as changed becomes a REPLACE — and Alchemy's\n * replace is create-then-delete, where the delete is `destroyfs`: the entry leaves the MDS map,\n * every mount on every node breaks, and whether the bytes survive rests on `remove-pools` alone.\n * ★ WHICH IS THE WHOLE REASON `matches` COMPARES NOTHING. Read its ⛔ before adding a field to\n * it. On every other resource in this package a forever-diff is an annoying plan line; on this\n * one it is a live filesystem destroyed on every deploy, forever, because a background daemon\n * moved a number nobody declared.\n *\n * ⛔ THERE IS NO SINGLE-OBJECT READ, WHICH INVERTS `path` AND `collection`. MEASURED on n2:\n * pvesh get /nodes/n2/ceph/fs/cephfs-tb4\n * -> No 'get' handler defined for '/nodes/n2/ceph/fs/cephfs-tb4'\n * `GET /nodes/{node}/ceph/fs` is a directory index and is the only read there is, so `path()`\n * below returns the INDEX and `attributes` picks this filesystem out of the array client-side —\n * the shape acl.ts uses for the one flat `GET /access/acl`. The POST goes to the `{name}` path,\n * so `collection()` is the LONGER of the two strings, the mirror of metric-server.ts.\n * ⚠️ AND THAT IS WHY `delete` AND `reconcile` ARE HAND-WRITTEN BELOW rather than taken from\n * `pveHandlers`. `pveOperations.destroy` deletes `spec.path`, which here is the index:\n * `DELETE /nodes/{node}/ceph/fs` is not a route, so a factory delete would fail every destroy\n * while the filesystem stayed exactly where it was. `reconcile` is hand-written for a second,\n * independent reason — the forked worker — set out in ceph-fs-wire.ts. acl.ts is the\n * precedent for a family that genuinely does not fit; this is the second.\n *\n * ⛔ CREATING A CephFS CREATES TWO CEPH POOLS, AND A `Proxmox.CephPool` MUST NOT ALSO DECLARE THEM.\n * `createfs` builds `<name>_data` and `<name>_metadata` itself and refuses outright if either\n * exists (\"ceph pools '…_data' and/or '…_metadata' already exist\"). MEASURED on TB4: the live\n * `cephfs-tb4` owns `cephfs-tb4_data` (id 6) and `cephfs-tb4_metadata` (id 7), both of which\n * `GET /nodes/n2/ceph/pool` lists like any other pool — and `/nodes/{node}/ceph/pool/{name}` DOES\n * have GET, PUT and DELETE, so a pool resource would be a clean `pveHandlers` fit and would\n * adopt them without noticing. Declaring both is double management of one object: whichever\n * reconciles first wins, and the loser either fails its create or PUTs `size`/`pg_num` onto pools\n * this resource believes it owns. Declare the filesystem here and leave its two pools alone.\n *\n * ⚠️ `add-storage` IS A SECOND SIDE EFFECT AND IT LANDS IN storage.cfg. Set, `createfs` also calls\n * `PVE::API2::Storage::Config->create` with type `cephfs`, content `backup,iso,vztmpl` and\n * `fs-name <name>`. MEASURED: /etc/pve/storage.cfg on n2 holds exactly that — `cephfs:\n * cephfs-tb4` / `content backup,vztmpl,iso` / `fs-name cephfs-tb4`. So a `Proxmox.Storage`\n * declaring `cephfs-tb4` would be managing an entry this resource created. Declare ONE of them:\n * either `add-storage` here and no storage resource, or `add-storage` off and a\n * `Proxmox.Storage` that reads this resource's `name` attribute — which also gets the ordering\n * right for free, because Alchemy orders by data flow.\n *\n * ⚠️ `node` IS A ROUTE, NOT IDENTITY, AND MUST NEVER BE DIFFED. A CephFS is cluster-wide; the node\n * in the path only says which node PVE proxies the call to. MEASURED: `GET /nodes/n2/ceph/fs`,\n * `…/n3/…` and `…/n4/…` returned the byte-identical array. So changing `node` plans `noop`, and\n * two resources naming the same `name` on different nodes are the SAME filesystem — the vmid\n * hazard from lxc.ts, with a filesystem on the end of it instead of a container.\n *\n * ⚠️ PRIVILEGES: the read lane needs `Sys.Audit` OR `Datastore.Audit` on `/`, which an auditor\n * role already holds — unlike storage.ts, nothing needs widening before the first plan. The\n * write side is in ceph-fs-wire.ts beside the calls, and in docs/privileges.md with the rest.\n */\nimport { Resource } from 'alchemy';\nimport { isResolved } from 'alchemy/Diff';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport {\n createForm,\n createFs,\n destroyFs,\n notCreated,\n notDestroyed,\n objectPath,\n readRow,\n} from './ceph-fs-wire.ts';\nimport { type PveRequirements, type WithTarget, pveOperations } from './resource.ts';\n\nexport interface CephFsProps extends WithTarget {\n /** ⚠️ Which node answers the call, NOT which node holds the filesystem. See the header. */\n node: string;\n /**\n * The filesystem name, and the cluster-wide primary key. PVE's pattern is `^[^:/\\s]+$`.\n * ⛔ CHANGING IT IS A REPLACE, WHICH DESTROYS THE OLD FILESYSTEM. `diff` says so explicitly\n * below rather than letting the factory report a create-shaped `update` and orphan the old one.\n */\n name: string;\n /**\n * Placement groups for the backing data pool; the metadata pool gets a quarter of it, or 8 when\n * this is under 32. PVE's default is 128.\n *\n * ⛔ CREATE-TIME ONLY, UNREADABLE, AND OWNED BY THE AUTOSCALER FROM THE SECOND IT LANDS. It is\n * never compared — see the ⛔ on `matches` — and this is not caution, it is measured. TB4's\n * `cephfs-tb4` was created with the default 128 (the arithmetic proves it: `cephfs-tb4_metadata`\n * sits at 32, which is 128/4), and `cephfs-tb4_data` reads pg_num 32 TODAY. The autoscaler moved\n * it by a factor of four, and it is not finished: `pg_autoscale_mode` is `on` for every pool on\n * this cluster and `cephfs-tb4_metadata` already reports `pg_num_final: 16` against its live 32.\n */\n pg_num?: number;\n /**\n * Also write a `cephfs` storage entry for this filesystem. ⚠️ Create-time only and never read\n * back — it is an ACTION, not a field. See the header for what it does to `Proxmox.Storage`.\n */\n 'add-storage'?: boolean;\n /** ⛔ DELETE-TIME ONLY, AND IT ERASES THE DATA. Read the ⛔ on `destroyFs` before setting it. */\n 'remove-pools'?: boolean;\n /**\n * Delete the pveceph-managed storage entries too. ⚠️ PVE refuses unless they are already\n * disabled (\"storage '…' is not disabled, make sure to disable and unmount the storage first\"),\n * so this fails the destroy rather than unmounting anything out from under a running guest.\n */\n 'remove-storages'?: boolean;\n}\n\n/**\n * ⚠️ EVERY FIELD HERE IS REPORTED AND NONE IS COMPARED. They exist so a plan, and the state entry\n * behind it, can say what the declaration actually points at — which pools hold the bytes.\n */\nexport interface CephFsAttributes {\n name: string;\n /** The first data pool. PVE keeps it for compatibility; `data_pools` is the real answer. */\n data_pool: string;\n /**\n * ⚠️ SORTED, AND IT IS A SET RATHER THAN A LIST. A CephFS can hold several data pools — added\n * with `ceph fs add_data_pool`, which this resource has no way to express — and PVE reports\n * them in the MDS map's own order. Sorting is what keeps this attribute stable across reads.\n */\n data_pools: string;\n metadata_pool: string;\n /**\n * ⚠️ AN INTEGER THAT NAMES SOMETHING WRITTEN AS A NAME, AND THEREFORE A CLASSIC FOREVER-DIFF IF\n * IT EVER REACHED `matches`. PVE answers `metadata_pool_id: 7` while every write in this family\n * spells a pool by name. It is here to be read, never to be compared. `-1` means absent: the\n * field is optional in the schema and older PVE omits it.\n */\n metadata_pool_id: number;\n}\n\nexport interface ProxmoxCephFs extends Resource<\n 'Proxmox.CephFs',\n CephFsProps,\n CephFsAttributes,\n never,\n PveRequirements\n> {}\n\n/** ★ `retain` by default — a filesystem holding data cannot be rebuilt. See the ★ in resource.ts. */\nexport const ProxmoxCephFs = Resource<ProxmoxCephFs>('Proxmox.CephFs', {\n defaultRemovalPolicy: 'retain',\n});\n\nconst ops = pveOperations<CephFsProps, CephFsAttributes>({\n attributes: readRow,\n /** ⚠️ The `{name}` path — longer than `path()`, deliberately. See the second ⛔ in the header. */\n collection: objectPath,\n createForm,\n /**\n * ⛔ NOTHING IS COMPARED, AND THAT IS THE MOST DELIBERATE LINE IN THIS FILE. A CephFS has no\n * readable, writable field: the index returns only the name and the pools behind it, and every\n * prop this resource accepts is create-time or delete-time. So \"present\" IS \"settled\", and the\n * only honest comparison is none at all.\n * ⚠️ THE TEMPTING ADDITION IS `pg_num`, AND IT WOULD BE THE WORST BUG THIS PACKAGE HAS SHIPPED.\n * It is not in the index at all, so it can only be read from the pool endpoint — where the\n * autoscaler owns it. MEASURED on TB4 today: created at 128, live at 32, with the metadata\n * pool already scheduled down to 16. Compared, that is an eternal mismatch; and because\n * `updateForm` is undefined, the action it produces is REPLACE. The plan would destroy and\n * rebuild a live filesystem on every deploy, triggered by a daemon on its own schedule.\n * ⚠️ `data_pools` AND `metadata_pool_id` ARE OUT FOR THE ORDINARY REASONS: a set PVE returns\n * in its own order, and an integer id for something written as a name. `name` is out because\n * it is the FILTER that produced these attributes, so comparing it is true by construction —\n * an identity change is handled in `diff`, not here. `node` is out because it is a route.\n */\n matches: () => true,\n /** ⚠️ THE INDEX, NOT THE OBJECT. There is no GET on `{name}`; see the second ⛔ in the header. */\n path: (props) => `nodes/${props.node}/ceph/fs`,\n});\n\nexport const ProxmoxCephFsProvider = () =>\n Provider.effect(\n ProxmoxCephFs,\n Effect.succeed(\n ProxmoxCephFs.Provider.of({\n /**\n * ⛔ EMPTY, LIKE EVERY OTHER RESOURCE HERE. The index answers with every filesystem on the\n * cluster, `cephfs-tb4` included — the one holding this estate's ISOs and templates.\n * Adopting it would put Alchemy one `destroy` away from it. Adoption stays explicit.\n */\n list: () => Effect.succeed([]),\n read: Effect.fn(function* ({ olds }) {\n return yield* ops.read(olds);\n }),\n /**\n * ⛔ A CHANGED `name` IS A REPLACE, AND THE FACTORY CANNOT SAY SO ALONE. Left to delegate,\n * a rename reads the NEW name, finds nothing, and returns the drift-shaped `update` that\n * `pveOperations.diff` uses for \"Alchemy has state, the cluster does not\" — so reconcile\n * would build the new filesystem and LEAVE THE OLD ONE, with its pools, its storage entry\n * and its bytes, owned by nobody and invisible in every later plan.\n * ⛔ SAYING `replace` IS HONEST, AND IT IS ALSO WHAT MAKES A TYPO EXPENSIVE. Alchemy\n * creates first and deletes second, so the old filesystem is destroyed AFTER the new\n * one exists — with `remove-pools` unset the bytes are stranded rather than erased, and\n * that default is the only thing between a mis-typed rename and an unrecoverable one.\n * Do not \"simplify\" this back to the factory: the alternative is not safer, it is\n * silent. ⚠️ `node` is NOT part of identity and must never join this comparison.\n */\n diff: Effect.fn(function* ({ news, output }) {\n if (output !== undefined && isResolved(news) && news.name !== output.name) {\n return { action: 'replace' } as const;\n }\n return yield* ops.diff(news, output);\n }),\n /**\n * ⛔ NOT `ops.reconcile`, BECAUSE ITS READ-BACK RACES A FORKED WORKER. The POST returns a\n * UPID and nothing else; `createFs` waits the task out and surfaces its real error. The\n * read-back the factory does is kept here rather than dropped — waiting proves the task\n * ENDED, reading proves the filesystem EXISTS, and PVE has shipped tasks that end OK\n * having done nothing.\n * ⚠️ AN EXISTING FILESYSTEM IS RETURNED UNTOUCHED. There is no update call to make, so the\n * only write this handler can perform is a create; `diff` has already decided that a\n * real change is a replace, and Alchemy calls delete for the old generation itself.\n */\n reconcile: Effect.fn(function* ({ news }) {\n const live = yield* ops.read(news);\n if (live !== undefined) return live;\n yield* createFs(news);\n const after = yield* ops.read(news);\n if (after === undefined) return yield* Effect.die(notCreated(news));\n return after;\n }),\n /**\n * ⛔ NOT `ops.destroy`, AND NOT AN OVERSIGHT. It would DELETE `spec.path`, which on this\n * family is the index — a route PVE does not implement — so every destroy would fail\n * while the filesystem stayed exactly where it was. The read-back afterwards is what\n * turns \"the task said OK\" into \"it is actually gone\": `destroyfs` refuses while a\n * non-disabled `cephfs` storage still references the filesystem, and that refusal must\n * fail the destroy rather than letting Alchemy drop the state entry for a live object.\n */\n delete: Effect.fn(function* ({ olds }) {\n /**\n * ⚠️ A FILESYSTEM SOMEBODY ALREADY REMOVED BY HAND IS NOT AN ERROR. `destroyfs` dies\n * synchronously with \"no such cephfs\", which would fail every destroy of a stack whose\n * filesystem was cleaned up outside Alchemy and leave the state entry unremovable\n * without editing the store. ⚠️ THE COST IS STATED PLAINLY: `ops.read` folds a FAILED\n * read into \"absent\" (the storage.ts trap), so a read this credential cannot perform\n * turns this into a destroy that reports success having done nothing. That is not a\n * new hazard — a broken read defeats the read-back below in exactly the same way — but\n * it is the reason a 403 on this family must be fixed rather than lived with.\n */\n if ((yield* ops.read(olds)) === undefined) return;\n yield* destroyFs(olds);\n const after = yield* ops.read(olds);\n if (after !== undefined) return yield* Effect.die(notDestroyed(olds));\n }),\n }),\n ),\n );\n",
19
+ "/**\n * The wire lane of `Proxmox.CephFs`: how a PVE answer becomes attributes, how a declaration becomes\n * a PVE call, and how that call becomes a fact.\n *\n * ★ SPLIT OUT OF ceph-fs.ts TO KEEP BOTH FILES UNDER THE 250-LINE CAP, and the seam is a real one\n * rather than a convenient line number. ceph-fs.ts answers \"what is a CephFS, and when has it\n * changed\"; this file answers \"what does PVE say, what does it want, and has it finished\". On\n * this family that is where all the strangeness lives — the read is an index and not an object,\n * the paths are inverted, the delete takes its arguments in the query string, and both writes\n * fork a worker — so keeping it in one place is what stops the next reader assuming the ordinary\n * shape from the other nineteen resources. ⚠️ NOTHING HERE DECIDES A DIFF.\n *\n * ⚠️ THE `import type` BACK TO ceph-fs.ts IS A CYCLE ON PAPER ONLY. It is type-only and erased\n * before anything runs, exactly as metric-server-form.ts imports `MetricServerProps`. The props\n * stay the resource's public shape, declared in the file that declares the resource.\n *\n * ⛔ POST AND DELETE ANSWER WITH A UPID, NOT A RESULT — THE WRITE IS ASYNCHRONOUS AND A FAILED ONE\n * IS STILL HTTP 200. Read from the cluster's own source, /usr/share/perl5/PVE/API2/Ceph/FS.pm on\n * n2: `createfs` and `destroyfs` both end `return $rpcenv->fork_worker(...)`. Two different lies\n * come out of trusting that status code. A read-back straight after the POST reports \"still\n * absent\" about a filesystem that is being built as it says so — which is precisely the message\n * `pveOperations.reconcile` would print, pointing at the wrong cause. And a worker that dies\n * INSIDE — the pool create, or the add-storage step, both of which are wrapped in `eval` — is\n * never reported to the caller at all. `settle` below is the answer to both.\n * ⚠️ REASONED FROM THAT SOURCE, NOT MEASURED. Nothing was written to this cluster, so the race\n * has not been observed; only the `fork_worker` that guarantees it is there.\n *\n * ⛔ A DELETE BODY IS SILENTLY DISCARDED BY PVE, SO `remove-pools` GOES IN THE QUERY STRING.\n * MEASURED in /usr/share/perl5/PVE/APIServer/AnyEvent.pm on n2: line 928 reads the request\n * content into params only `if ($method eq 'PUT' || $method eq 'POST')`, and line 1653 sends\n * every other method down a branch that parses `$request->url->query()` and nothing else. So\n * `pve(target, role, 'DELETE', path, form)` would send a body PVE never looks at: the flags would\n * read as unset, the pools would quietly survive a delete that asked for them, and no error would\n * be raised anywhere. sdn-apply.ts already puts `?pending=1` in the path for the same reason.\n *\n * ⚠️ THE TASK POLL RUNS ON THE `read` ROLE THOUGH IT SITS INSIDE reconcile, FOR TWO REASONS. It is\n * a read, and resource.ts already mints `read` for its own read-back inside reconcile. And the\n * leases differ where it matters: `provision` is 300s and explicitly non-renewable, so a create\n * that waits out a slow worker on that lease can expire mid-poll, while `read` is 3600s.\n *\n * ⛔ THE POLLER IS NEVER THE TASK'S OWNER, WHICH COSTS A PRIVILEGE, AND THIS ONE IS MEASURED\n * RATHER THAN FEARED. client.ts mints a fresh credential per call and the mount vends a NEW\n * token id each time, so the token reading the status is never the token recorded in the UPID —\n * and PVE compares them exactly. /usr/share/perl5/PVE/API2/Tasks.pm on n2, `$check_task_user`:\n * `return $user eq $fulltoken || $user eq $task->{user};`, above it the comment \"token only sees\n * token tasks, user sees user + token tasks\". Token B of the same user matches neither branch.\n * So the fallback is the schema's other clause for `GET /nodes/{node}/tasks/{upid}/status`: \"The\n * user needs 'Sys.Audit' permissions on '/nodes/<node>' if they are not the owner of the task.\"\n * Grant it on the `read` role, or every create burns the full cap below and reports the wrong\n * cause.\n */\nimport * as Effect from 'effect/Effect';\nimport type { CephFsAttributes, CephFsProps } from './ceph-fs.ts';\nimport { pve } from './client.ts';\nimport type { PveTarget } from './credentials.ts';\nimport { csv, flag, int, text } from './values.ts';\n\n/**\n * This filesystem's row of the index, as attributes.\n *\n * ⚠️ `GET /nodes/{node}/ceph/fs` ANSWERS AN ARRAY, while the factory hands `attributes` the\n * `Record<string, unknown>` every other PVE read is shaped like. Rows are narrowed rather than\n * trusted, the same way acl.ts narrows its one flat grant list.\n *\n * ⛔ RETURNING undefined IS WHAT MAKES \"ABSENT\" MEAN ABSENT HERE, unlike acl.ts where the object is\n * always present-but-unbound. A filesystem missing from the index has not been created, and\n * `reconcile` takes the create branch on exactly that signal.\n */\nexport const readRow = (\n live: Record<string, unknown>,\n props: CephFsProps,\n): CephFsAttributes | undefined => {\n const row = (Array.isArray(live) ? live : [])\n .filter(\n (entry): entry is Record<string, unknown> => typeof entry === 'object' && entry !== null,\n )\n .find((entry) => entry['name'] === props.name);\n if (row === undefined) return undefined;\n return {\n data_pool: text(row['data_pool']),\n data_pools: csv(\n Array.isArray(row['data_pools'])\n ? row['data_pools'].map((entry: unknown) => String(entry))\n : [],\n ),\n metadata_pool: text(row['metadata_pool']),\n metadata_pool_id: int(row['metadata_pool_id'], -1),\n name: props.name,\n };\n};\n\n/** ⚠️ `exitstatus` is ABSENT while a task runs, and is the exact string `OK` only on success. */\ntype TaskStatus = { readonly status?: string; readonly exitstatus?: string };\n\n/**\n * ⚠️ SHORT POLLS, LOW CAP. Ninety seconds covers two pool creates plus the ten seconds `createfs`\n * itself spends waiting for an MDS to go active, and is short enough that a stuck task fails the\n * deploy rather than parking it for the afternoon.\n */\nconst POLL_SECONDS = 2;\nconst POLL_ATTEMPTS = 45;\n\n/** ⚠️ `nodes/{n}/ceph/fs/{name}` — the POST and DELETE target, and NOT where a read goes. */\nexport const objectPath = (props: CephFsProps) => `nodes/${props.node}/ceph/fs/${props.name}`;\n\n/** Only the declared flags. ⚠️ An omitted one is PVE's own default, not a value to send. */\nconst field = (name: string, value: string | undefined): Record<string, string> =>\n value === undefined ? {} : { [name]: value };\n\n/**\n * ⚠️ `name` IS DELIBERATELY ABSENT FROM THE FORM. It is already the last segment of the path being\n * POSTed to — the metric-server.ts case again — and a second copy can only ever disagree with it.\n */\nexport const createForm = (props: CephFsProps): Record<string, string> => ({\n ...field('add-storage', flag(props['add-storage'])),\n ...field('pg_num', props.pg_num === undefined ? undefined : String(props.pg_num)),\n});\n\n/** The delete target with its flags in the query string — see the ⛔ in the header. */\nconst destroyPath = (props: CephFsProps) => {\n const query = [\n props['remove-pools'] === true ? 'remove-pools=1' : undefined,\n props['remove-storages'] === true ? 'remove-storages=1' : undefined,\n ].filter((part) => part !== undefined);\n return query.length === 0 ? objectPath(props) : `${objectPath(props)}?${query.join('&')}`;\n};\n\n/**\n * Wait for a forked PVE task, and fail loudly rather than quietly.\n *\n * ⚠️ THE UPID IS PERCENT-ENCODED BECAUSE IT IS FULL OF COLONS — `UPID:n2:00396D3A:…:root@pam:`\n * (MEASURED shape, from `GET /nodes/n2/tasks`) is ONE path segment, not seven. Encoding is what\n * guarantees it arrives as one; PVE's router decodes each segment before matching. REASONED from\n * the URI handling rather than measured — no task of this provider's has been polled yet.\n */\nconst settle = (target: PveTarget, node: string, upid: string, what: string) =>\n Effect.gen(function* () {\n for (let attempt = 0; attempt < POLL_ATTEMPTS; attempt += 1) {\n const status = yield* pve<TaskStatus>(\n target,\n 'read',\n 'GET',\n `nodes/${node}/tasks/${encodeURIComponent(upid)}/status`,\n ).pipe(\n // ⚠️ AN UNREADABLE STATUS IS \"NOT SETTLED YET\", NOT A FAILURE. It is a missing Sys.Audit\n // (see the header) or a node mid-restart; either way the task is still the cluster's\n // business, and the cap is what ends the wait rather than one unlucky GET.\n Effect.orElseSucceed(() => undefined),\n );\n if (status?.status === 'stopped') {\n const exit = text(status.exitstatus);\n if (exit === 'OK') return;\n return yield* Effect.die(\n new Error(\n `${what}: PVE task ${upid} finished with \"${exit === '' ? 'no exit status' : exit}\". ` +\n 'The write returned HTTP 200 because it only forked the worker -- the real error is ' +\n `in \\`pvesh get /nodes/${node}/tasks/${upid}/log\\`.`,\n ),\n );\n }\n // ⚠️ A BARE NUMBER IS MILLISECONDS to Effect's Duration, not seconds. The cap in the\n // message below is derived from the same constant so the two cannot drift apart.\n yield* Effect.sleep(POLL_SECONDS * 1000);\n }\n return yield* Effect.die(\n new Error(\n `${what}: PVE task ${upid} was still running after ` +\n `${String(POLL_ATTEMPTS * POLL_SECONDS)}s, or its ` +\n 'status could not be read. Check the task log, and check that the `read` role holds ' +\n `Sys.Audit on /nodes/${node} -- each call mints a new token, so the poller is never the ` +\n 'task owner and is answered 403 rather than told to wait.',\n ),\n );\n });\n\n/**\n * POST the create, then wait for the worker. ⛔ The caller still reads back; see ceph-fs.ts.\n *\n * ⚠️ A CREATE NEEDS A RUNNING *AND* A STANDBY MDS, and refuses BEFORE it forks -- \"no running\n * Metadata Server (MDS) found!\" / \"no standby Metadata Server (MDS) found!\" are synchronous, so\n * they surface as a failed POST rather than as a silent worker. TB4 has three (MEASURED: n3\n * `up:active` for cephfs-tb4, n2 and n4 `up:standby`), so this is a note for a smaller cluster.\n * ⚠️ BOTH WRITES CHECK `Sys.Modify` ON `/` -- the root, with the breadth metric-server.ts warns\n * about: granting it buys datacenter options and every other cluster-wide config write too.\n */\nexport const createFs = (props: CephFsProps) =>\n Effect.gen(function* () {\n const upid = text(\n yield* pve<string>(props.target, 'provision', 'POST', objectPath(props), createForm(props)),\n );\n // ⛔ NO UPID MEANS NO WORKER. PVE answers 200 with `{\"data\":null}` on calls that did nothing,\n // and here that is indistinguishable from success by status code alone. Refusing now is the\n // difference between a clear failure and a state entry for a filesystem nobody built.\n if (upid === '') {\n return yield* Effect.die(\n new Error(\n `${objectPath(props)}: POST returned no task id. PVE wraps every answer in ` +\n '{\"data\":...} and can report success on a call that did nothing.',\n ),\n );\n }\n yield* settle(props.target, props.node, upid, objectPath(props));\n });\n\n/**\n * DELETE the filesystem, then wait for the worker.\n *\n * ⛔ WHAT THIS TAKES AWAY DEPENDS ENTIRELY ON `remove-pools`, AND THE DEFAULT IS THE SAFE ONE. With\n * it unset PVE removes the filesystem from the MDS map and LEAVES the two pools on disk: every\n * mount breaks, but the bytes are still there for an operator to recover. With it set the pools\n * go too and nothing is recoverable. Leaving it unset also means a later create of the SAME name\n * fails with \"ceph pools '<name>_data' and/or '<name>_metadata' already exist\" -- that refusal is\n * a BRAKE, not a bug, and it is the last thing standing between a mis-typed rename and the data.\n */\nexport const destroyFs = (props: CephFsProps) =>\n Effect.gen(function* () {\n const upid = text(yield* pve<string>(props.target, 'provision', 'DELETE', destroyPath(props)));\n // ⚠️ A DESTROY THAT ANSWERS WITHOUT A UPID IS NOT REFUSED HERE. `destroyfs` dies synchronously\n // with \"no such cephfs\" when the filesystem is already gone, which surfaces as a failed\n // DELETE; an empty answer that is not an error is best treated as already-absent, and the\n // caller's read-back is what proves it either way.\n if (upid !== '') yield* settle(props.target, props.node, upid, destroyPath(props));\n });\n\n/**\n * The two read-back failures, as messages rather than as guesses.\n *\n * ⛔ WAITING PROVES THE TASK ENDED; ONLY A READ PROVES THE FILESYSTEM DID OR DID NOT. `createfs`\n * wraps its pool creates in an `eval` and CLEANS THEM UP on error before dying, so a worker can\n * plausibly end having built and then removed everything it made. `destroyfs` refuses outright\n * while a non-disabled `cephfs` storage still references the filesystem. Neither outcome is\n * visible in a status code, which is why ceph-fs.ts reads back after both and dies with these.\n */\nexport const notCreated = (props: CephFsProps) =>\n new Error(\n `${objectPath(props)}: the create task finished but the filesystem is not in ` +\n `GET nodes/${props.node}/ceph/fs. Check the task log -- a PVE worker can exit having ` +\n 'rolled back the pools it had just made.',\n );\n\nexport const notDestroyed = (props: CephFsProps) =>\n new Error(\n `${objectPath(props)}: the destroy task finished but the filesystem is still in ` +\n `GET nodes/${props.node}/ceph/fs. PVE refuses to destroy a CephFS while a PVE storage entry ` +\n 'of type cephfs still references it and is not disabled.',\n );\n",
20
+ "/**\n * `Proxmox.CephOsd` — one OSD in the cluster's CRUSH tree.\n *\n * ⛔ CREATE AND DELETE ARE IMPLEMENTED AND `root@pam` IS THE ONLY IDENTITY THAT CAN RUN THEM.\n * That is PVE's restriction, not this package's caution, and it is MEASURED from the cluster's\n * own schema (`/usr/share/pve-docs/api-viewer/apidoc.js`, 2026-09-13):\n *\n * GET /nodes/{node}/ceph/osd -> {\"check\":[\"perm\",\"/\",[\"Sys.Audit\",\"Datastore.Audit\"],\"any\",1]}\n * POST /nodes/{node}/ceph/osd -> *** no permissions block at all ***\n * DELETE /nodes/{node}/ceph/osd/{osdid} -> *** no permissions block at all ***\n *\n * A PVE method with no permissions block is refused to every identity except `root@pam`, so an\n * OpenBao-minted `hf-provision@pve!…` token is answered 403 however wide its role — widening\n * `LXCProvisioner` cannot fix it. Compare the sibling families, which DO carry a check and\n * therefore do work with a token: `ceph/fs`, `ceph/mon` and `disks/zfs` all want `Sys.Modify`.\n *\n * ⚠️ SO THE WRITE PATH IS HONEST RATHER THAN USEFUL. It is written out properly in\n * `ceph-osd-write.ts` — read that file for what each verb destroys — and it will work for an\n * operator running as root@pam. Through this package's credential it will 403, and a 403 is a\n * better answer than a `delete` that silently does nothing while the plan claims otherwise.\n *\n * ★ WHAT IT IS ACTUALLY FOR, THEN: ASSERTION. It turns \"n2, n3 and n4 each hold two ssd OSDs\"\n * into a line a plan checks, and it gives Ceph-backed resources something real to depend on —\n * read `osd.osdid` into an `rbd` storage's props and Alchemy orders that storage after the\n * assertion, so a stack can no longer report a healthy Ceph storage on a cluster whose OSDs are\n * gone. A replica that disappears becomes work in `plan` and a loud failure on the deploy.\n *\n * ⛔ THE WRITE VERBS MAY NOT EVEN BE REACHABLE FOR THIS PACKAGE'S CREDENTIAL. MEASURED from the\n * cluster's own schema (`/usr/share/pve-docs/api-viewer/apidoc.js`, 2026-09-13): `index`,\n * `osdindex`, `metadata` and `lv-info` each declare a `permissions` block, while `createosd`\n * and `destroyosd` declare NONE — the key is absent, not empty. REASONED, NOT MEASURED: PVE\n * refuses a method with no permissions block to everyone but `root@pam`, so an OpenBao-minted\n * `hf-provision@pve!…` token would likely be answered 403 however wide its role. That is a\n * reason to leave the write lane closed, not something to confirm by trying: if the reasoning\n * is wrong, the confirmation costs a disk.\n */\nimport { Resource } from 'alchemy';\nimport { isResolved } from 'alchemy/Diff';\nimport type { Input } from 'alchemy/Input';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport type { CephOsdAttributes } from './ceph-osd-tree.ts';\nimport { readOsd } from './ceph-osd-tree.ts';\nimport { createOsd, destroyOsd } from './ceph-osd-write.ts';\nimport type { PveRequirements } from './resource.ts';\nimport type { WithTarget } from './resource.ts';\n\n/**\n * ⚠️ RE-EXPORTED, NOT DECLARED HERE — it is built in ceph-osd-tree.ts, next to the walk that fills\n * it in and to the reasoning for which of its fields may be compared. One name, one import.\n */\nexport type { CephOsdAttributes };\n\nexport interface CephOsdProps extends WithTarget {\n /**\n * Which node ANSWERS the read — not where the OSD lives. MEASURED: the tree n2 returns and the\n * tree n3 returns are the same six leaves, n4's included. Point this at any node that is up;\n * `host` is the field that says where the disk is.\n */\n node: string;\n /** `2` for `osd.2`. Identity, and an INTEGER — see the ⛔ on `findOsd` in ceph-osd-tree.ts. */\n osdid: number;\n /**\n * The CRUSH host bucket this OSD must sit in. Undeclared means unmanaged, as in storage.ts.\n *\n * ⚠️ DECLARING IT IS AN ASSERTION WITH NO REPAIR. If osd.2 turns up under n3, the plan reports\n * work every time and the deploy fails, because moving an OSD between failure domains is a\n * `ceph osd crush move` this provider will not perform. That is the intent: a replica in the\n * wrong failure domain is not something to converge quietly past.\n */\n host?: string;\n /**\n * `ssd` | `hdd` | `nvme`, asserted the same way as `host`.\n *\n * ⚠️ THE READ'S SPELLING IS KEPT rather than the create parameter's (`crush-device-class`).\n * This resource never writes, so the tree's name is the only one it has, and inventing a\n * second name for one field is exactly what values.ts exists to stop.\n */\n device_class?: string;\n /**\n * The block device to build this OSD from, e.g. `/dev/nvme1n1`. Declaring it makes the resource\n * able to CREATE; leaving it out keeps the resource a pure assertion over an OSD that exists.\n *\n * ⛔ EVERYTHING ON THIS DEVICE IS DESTROYED BY A CREATE. `POST /nodes/{node}/ceph/osd` hands it\n * to `ceph-volume lvm create`, which zaps it. Declare it only for a disk that is genuinely\n * blank, and read the ⛔ about id allocation below before assuming the create will land as the\n * `osdid` written above.\n */\n dev?: string;\n /**\n * Zap the OSD's logical volumes on destroy (`cleanup=1`). Default false: the LVs are left behind\n * so the disk can be re-added without a rebuild, which is the recoverable choice.\n */\n cleanup?: boolean;\n}\n\nexport interface ProxmoxCephOsd extends Resource<\n 'Proxmox.CephOsd',\n CephOsdProps,\n CephOsdAttributes,\n never,\n PveRequirements\n> {}\n\n/**\n * ★ `retain` BY DEFAULT, FOLLOWING ALCHEMY'S OWN PRECEDENT. `GitHub.Repository` and\n * `Cloudflare.Zone` default to retain \"because their contents are irreplaceable\"; an OSD is a\n * replica of live data and qualifies twice over. Retain means DELETING THE DECLARATION DOES NOT\n * DELETE THE OSD — Alchemy drops its state row and leaves the disk alone. `destroyOsd` is fully\n * implemented in ceph-osd-write.ts and runs when the caller opts in with\n * `.pipe(RemovalPolicy.destroy())`, so this is the Terraform `prevent_destroy` shape rather than\n * a missing operation — and through a minted token it 403s anyway, per the ⛔ at the top.\n */\nexport const ProxmoxCephOsd = Resource<ProxmoxCephOsd>('Proxmox.CephOsd', {\n defaultRemovalPolicy: 'retain',\n});\n\n/**\n * The live OSD, or undefined when the tree has no leaf with that id.\n *\n * ⛔ NO `Effect.orElseSucceed(() => undefined)`, AND THAT IS THE ONE DELIBERATE DEPARTURE FROM\n * `pveOperations.read`. The factory folds every failure into \"absent\" because a 404 is a\n * legitimate answer on a per-object path — but this path is a COLLECTION that always exists\n * while Ceph is installed, so a failure here is never \"the OSD is gone\". It is an unreachable\n * node, an expired lease, a role without `Sys.Audit`, or a cluster with no Ceph at all. Folding\n * those into \"absent\" would turn every one of them into the sentence \"osd.2 is missing\", which\n * is the most alarming thing this provider can say and would be a lie in all four cases. Left\n * to fail, the plan shows `PVE GET nodes/n2/ceph/osd -> 500: …` and names the real problem.\n */\n\n/**\n * Whether the live OSD is the one that was declared.\n *\n * ⚠️ AN UNDECLARED FIELD IS NOT COMPARED, as in storage.ts: undeclared means unmanaged, and there\n * is no default to fall back on — the whole point of a CRUSH placement is that it is a choice.\n * Declaring nothing but `osdid` therefore asserts only presence, which is a perfectly good\n * thing to assert about a replica and the safest declaration this resource accepts.\n */\nconst settled = (live: CephOsdAttributes, props: CephOsdProps) =>\n (props.host === undefined || props.host === live.host) &&\n (props.device_class === undefined || props.device_class === live.device_class);\n\nconst describe = (props: CephOsdProps) =>\n `osd.${String(props.osdid)} (read via nodes/${props.node}/ceph/osd)`;\n\n/**\n * ⛔ HAND-WRITTEN RATHER THAN `pveHandlers(spec)`, and the reason is not that the shape does not\n * fit — it fits perfectly, which is the danger. Given a spec, the factory's `reconcile` POSTs\n * `createForm` at `collection` whenever the read says absent, and `destroy` DELETEs `path`.\n * Wired to this family that is: build an OSD over whatever block device the props named, and\n * remove a replica when somebody deletes a line from a stack file. acl.ts is the precedent for\n * overriding the factory because PVE lacks a verb; this file overrides it because PVE HAS the\n * verbs and they must not be reachable from a declaration.\n *\n * ⚠️ THERE IS NO `replace` PATH HERE AND THERE CANNOT BE ONE. Alchemy implements a replace as\n * create-then-delete (or the reverse); with both of those refusing, `replace` could only ever\n * be a failure wearing a different word. A changed `osdid` is simply a different assertion.\n */\nconst handlers = {\n /**\n * ⛔ EMPTY, as everywhere in this package, and here the stakes are at their highest. The tree is\n * the whole cluster's — adopting it would hand Alchemy six resources it never created, each\n * with a `delete` in its future. Adoption stays an explicit act, and for this family it stays\n * an act with no teeth: see `delete` below.\n */\n list: () => Effect.succeed([]),\n\n read: Effect.fn(function* ({ olds }: { olds: CephOsdProps }) {\n return yield* readOsd(olds);\n }),\n\n /**\n * ⚠️ `update` IS THE LOUDEST WORD AVAILABLE, NOT A PROMISE TO FIX ANYTHING. Alchemy's Diff\n * admits only noop/update/replace, so a missing or misplaced OSD has to be spelled `update`\n * — and the deploy that follows fails on purpose in `reconcile`. A resource that answered\n * `noop` over a replica that is not there would be the exact lie this package keeps writing\n * guards against; a permanent entry in `plan` until a human puts a disk back is the cost, and\n * it is the right cost for a degraded pool.\n */\n diff: Effect.fn(function* ({\n news,\n output,\n }: {\n news: Input<CephOsdProps>;\n output: CephOsdAttributes | undefined;\n }) {\n if (output === undefined || !isResolved(news)) return undefined;\n const live = yield* readOsd(news);\n if (live === undefined) return { action: 'update' } as const;\n /**\n * ⛔ THE RECORDED STATE MUST DESCRIBE THE OSD THE DECLARATION NOW NAMES. `settled` compares\n * only host and device_class, so changing `osdid: 2` to `3` reads osd.3, finds it on the\n * same host with the same class, and answers noop — which records nothing, leaving OSD 2's\n * crush_weight, pgs and name in state under a declaration that says 3. It is the OUTPUT's id\n * that must be checked: the LIVE id is found BY `news.osdid`, so comparing that is vacuous.\n */\n if (output.osdid !== news.osdid) return { action: 'update' } as const;\n return settled(live, news) ? ({ action: 'noop' } as const) : ({ action: 'update' } as const);\n }),\n\n /**\n * ⛔ THE ASSERTION, AND THE WHOLE REASON THIS PROVIDER IS HAND-WRITTEN. It reads, and then it\n * either records what it found or dies. It never POSTs. The first deploy of a declaration is\n * an adoption of an OSD that already exists; every later one is a check that it still does.\n */\n reconcile: Effect.fn(function* ({ news }: { news: CephOsdProps }) {\n const live = yield* readOsd(news);\n if (live === undefined) {\n /**\n * ⛔ CEPH ALLOCATES THE OSD ID; THE DECLARATION CANNOT CHOOSE IT. Measured from the schema:\n * `POST /nodes/{node}/ceph/osd` requires `dev` and takes `crush-device-class`, `db_dev`,\n * `wal_dev`, `encrypted` and `osds-per-device` — and NO id. The cluster assigns the next\n * free number. So a create only lands on the declared `osdid` when that number happens to\n * be the one Ceph picks, which for a fresh disk on a contiguous cluster it usually is.\n * The read-back below is what keeps that from being a silent mismatch: if Ceph assigned a\n * different id, the OSD this resource names is still absent and reconcile refuses.\n */\n return yield* createOsd(news);\n }\n if (!settled(live, news)) {\n return yield* Effect.die(\n new Error(\n `${describe(news)}: exists but not as declared -- live host=${live.host} ` +\n `device_class=${live.device_class}. Nothing here moves an OSD between hosts or ` +\n 'reclassifies it; fix the declaration, or move it deliberately with `ceph osd crush ' +\n 'move` / `ceph osd crush set-device-class` and deploy again.',\n ),\n );\n }\n return live;\n }),\n\n /**\n * ⛔ REMOVING THE DECLARATION REMOVES THE ASSERTION, NOT THE REPLICA — the resource defaults\n * to `retain`, so this runs only on `.pipe(RemovalPolicy.destroy())`. What the DELETE actually\n * does to a live pool is documented on `destroyOsd` in ceph-osd-write.ts.\n */\n delete: Effect.fn(function* ({ olds }: { olds: CephOsdProps }) {\n yield* destroyOsd(olds);\n }),\n};\n\nexport const ProxmoxCephOsdProvider = () =>\n Provider.effect(ProxmoxCephOsd, Effect.succeed(ProxmoxCephOsd.Provider.of(handlers)));\n",
21
+ "/**\n * The CRUSH tree, walked down to one OSD leaf.\n *\n * ★ SPLIT OUT OF ceph-osd.ts TO KEEP BOTH FILES UNDER THE 250-LINE CAP, and the seam is the same\n * one metric-server-form.ts cuts: this file answers \"what does the cluster say about osd.N\",\n * ceph-osd.ts answers \"what is an OSD and what may a plan do about it\". Nothing here calls the\n * API and nothing here decides a diff. `CephOsdAttributes` lives on this side of the seam\n * because it is a description of what the TREE says — keeping each field's\n * reported-never-compared reasoning against the line that builds it — and ceph-osd.ts re-exports\n * it so a consumer still imports one name from one place. The `import type` back for\n * `CephOsdProps` is a cycle on paper only: it is erased before anything runs.\n *\n * ⛔ `GET /nodes/{node}/ceph/osd` ANSWERS A TREE, NOT A LIST, AND IT IS THE WHOLE CLUSTER'S TREE.\n * MEASURED 2026-09-13: asked of n2 it answers `{\"flags\":…,\"root\":{\"children\":[…]}}` whose\n * leaves include osd.0 and osd.5 on n4; asked of n3 it answers the identical six leaves. The\n * `{node}` in the path chooses WHO ANSWERS, not what is listed. A provider that read it as \"the\n * OSDs on this node\" would find osd.0 through n2 and then report it as living there.\n *\n * ⛔ AND THE SINGLE-OBJECT PATH CANNOT BE USED INSTEAD — THIS WALK EXISTS BECAUSE IT LIES.\n * MEASURED: `GET /nodes/n2/ceph/osd/99`, an id with no OSD behind it, answers HTTP 200 with\n * `[{\"name\":\"metadata\"},{\"name\":\"lv-info\"}]` — byte for byte what `…/osd/2` answers for a real\n * one. It is a directory index (its schema says `permissions: {\"user\":\"all\"}`), not a read of\n * the OSD. Point `PveSpec.path` at it and every declared OSD is \"present\": `diff` reports\n * `noop` over a dead replica forever, and `reconcile`'s read-back guard — the one thing that\n * stops this package recording objects that do not exist — passes on an OSD that was never\n * built. The only endpoint that can tell present from absent is the tree.\n *\n * ★ MEASURED ON TB4 ON 2026-09-13, `GET /nodes/n2/ceph/osd`. Six leaves, all `up` and `in`, Ceph\n * 20.2.2 tentacle:\n *\n * id name host device_class crush_weight reweight pgs status\n * 0 osd.0 n4 ssd 1.86299133300781 1 99 up\n * 5 osd.5 n4 ssd 1.86299133300781 1 94 up\n * 1 osd.1 n3 ssd 1.86299133300781 1 96 up\n * 4 osd.4 n3 ssd 1.81939697265625 1 97 up\n * 2 osd.2 n2 ssd 1.81939697265625 1 88 up\n * 3 osd.3 n2 ssd 1.81939697265625 1 105 up\n *\n * `{ node: 'n2', osdid: 2, host: 'n2', device_class: 'ssd' }` plans `noop` against that row.\n * That is the acceptance test this file was written to pass.\n *\n * ⚠️ EVERY OTHER COLUMN IS REPORTED AND NEVER COMPARED, FOR FOUR DIFFERENT REASONS. `pgs` is the\n * autoscaler's placement rather than anybody's declaration — MEASURED, it spans 88 to 105 across\n * six identical disks, and Ceph moves PGs whenever it rebalances. `crush_weight` is a FLOAT\n * derived from device size (MEASURED: 1.86299133300781), so comparing it is float equality\n * against a number Ceph recomputes on `crush reweight`. `reweight` is what\n * `reweight-by-utilization` writes, unasked. `status` and `in` are daemon state: an OSD that\n * flaps down while a node reboots would otherwise put work in the plan that no write this\n * provider owns could ever clear. Each of those is the forever-update this package has already\n * been bitten by, and each is out of `settled` below.\n *\n * ⚠️ THE CLUSTER'S OSD FLAGS ARE NOT AN ATTRIBUTE EITHER. The read carries\n * `\"flags\":\"sortbitwise,recovery_deletes,purged_snapdirs,pglog_hardlimit\"` NEXT TO the root\n * rather than inside any leaf: they describe the OSDMap, not this OSD. Recording them per-OSD\n * would rewrite all six resources' state the moment somebody set `noout` for ten minutes of\n * maintenance — the churn-that-reads-like-drift that keeps `digest` out of storage.ts.\n *\n */\nimport * as Effect from 'effect/Effect';\nimport type { CephOsdProps } from './ceph-osd.ts';\nimport { pve } from './client.ts';\nimport { bool, int, num, text } from './values.ts';\n\n/** A CRUSH node. Buckets carry `children`; an OSD leaf carries `type: 'osd'`. */\ntype CrushNode = Record<string, unknown>;\n\nconst branches = (node: CrushNode): CrushNode[] =>\n (Array.isArray(node['children']) ? node['children'] : []).filter(\n (child): child is CrushNode => typeof child === 'object' && child !== null,\n );\n\n/**\n * Every OSD leaf under the tree root, at any depth.\n *\n * ⚠️ RECURSIVE BECAUSE THE TREE IS NOT THREE LEVELS DEEP BY LAW. TB4 measures as\n * root(`default`) -> host(n2|n3|n4) -> osd, but CRUSH admits datacenter, rack and chassis\n * buckets between them, and an OSD created outside a host bucket hangs off the root. Reaching\n * in as `root.children[].children[]` would read this cluster correctly and answer \"absent\" —\n * i.e. \"the replica is gone\" — on the first cluster that has a rack in it.\n *\n * ⚠️ THE OUTERMOST OBJECT IS NOT ITSELF A BUCKET. MEASURED: `root` is `{\"children\":[…],\"leaf\":0}`\n * with no `type` and no `name`; the bucket called `default` is its first child. So the walk\n * starts at `tree.root` and selects on `type === 'osd'` rather than assuming a shape.\n */\nexport const osdLeaves = (tree: CrushNode): CrushNode[] => {\n const root = tree['root'];\n const start: CrushNode = typeof root === 'object' && root !== null ? (root as CrushNode) : {};\n const walk = (node: CrushNode): CrushNode[] => [\n ...(node['type'] === 'osd' ? [node] : []),\n ...branches(node).flatMap(walk),\n ];\n return walk(start);\n};\n\n/**\n * The leaf for one OSD id, or undefined when nothing in the tree carries it.\n *\n * ⛔ `id` COMES BACK AS A STRING HERE AND AS AN INTEGER EVERYWHERE ELSE, which is the \"an id\n * returned one way and written another\" forever-diff in its most expensive form. MEASURED: the\n * leaf for osd.2 carries `\"id\":\"2\"` (and the host buckets carry `\"id\":\"-7\"`), while\n * `GET …/osd/2/metadata` carries `\"id\":2` and the `osdid` parameter on POST and DELETE is typed\n * integer. `'2' === 2` is false, so a provider comparing the raw value finds NOTHING, calls\n * every declared OSD absent — and, with a create path wired up, offers to build six OSDs over\n * six live disks. `int` from values.ts is the narrowing, and `Number.NaN` is the fallback\n * precisely because it equals nothing, id 0 included.\n *\n * ⚠️ FIRST MATCH WINS. OSD ids are unique cluster-wide, and PVE does not put the per-device-class\n * shadow buckets (`default~ssd`) in this tree — MEASURED: the whole tree is one `default` root,\n * three hosts, six leaves. If a future PVE did include them, taking the first match keeps the\n * answer stable instead of reporting drift depending on which copy was walked into first.\n */\nexport const findOsd = (tree: CrushNode, osdid: number) =>\n osdLeaves(tree).find((leaf) => int(leaf['id'], Number.NaN) === osdid);\n\nexport interface CephOsdAttributes {\n /** Normalised to an integer here even though the tree spells it `\"2\"`. */\n osdid: number;\n /** `osd.2` — how Ceph, the UI and every log line name it. */\n name: string;\n /** COMPARED, but only when `props.host` is declared. */\n host: string;\n /** COMPARED, but only when `props.device_class` is declared. */\n device_class: string;\n /**\n * ⚠️ REPORTED, NEVER COMPARED — `bluestore` on every live OSD and filestore has been gone for\n * years, so declaring it would add a field that cannot disagree. It is recorded because a\n * future objectstore change is exactly the kind of thing state should have caught in writing.\n */\n osdtype: string;\n /** ⚠️ REPORTED, NEVER COMPARED. Daemon state — see the second ⚠️ in the header. */\n status: string;\n /** ⚠️ REPORTED, NEVER COMPARED. Ceph itself sets this to 0 after `mon_osd_down_out_interval`. */\n in: boolean;\n /** ⚠️ REPORTED, NEVER COMPARED. A float Ceph recomputes; comparing it is a permanent diff. */\n crush_weight: number;\n /** ⚠️ REPORTED, NEVER COMPARED. `reweight-by-utilization` owns this number, not a declaration. */\n reweight: number;\n /** ⚠️ REPORTED, NEVER COMPARED. The autoscaler moves PGs between OSDs whenever it likes. */\n pgs: number;\n /** Device capacity in bytes. Stable per disk, and the honest answer to \"how big is this OSD\". */\n total_space: number;\n /** `20.2.2`. ⚠️ Reported, never compared — an upgrade is not this resource's drift. */\n ceph_version: string;\n}\n\n/**\n * One leaf, as the attributes a plan and the state store get to see.\n *\n * ⚠️ THE TELEMETRY IS DELIBERATELY DROPPED, NOT FORGOTTEN. The leaf also carries `bytes_used`,\n * `percent_used`, `apply_latency_ms` and `commit_latency_ms`. MEASURED, AND THE MEASUREMENT SAYS\n * THE OPPOSITE OF WHAT YOU WOULD EXPECT: across two reads minutes apart, all four were identical\n * on every OSD, and both latencies read 0 — TB4 was idle, so nothing was caught in the act. That\n * these move is therefore REASONED, from what they count, not observed. Alchemy persists\n * attributes; on a cluster doing work, keeping them would rewrite all six resources' state on\n * every deploy and record a number that is stale by the time anybody reads it. What is kept is\n * what a human asking \"what is this replica, and is it healthy\" needs; it is not a metrics feed.\n *\n * ⚠️ `osdid` AND `name` ARE THE NORMALISED ID AND ITS SPELLING, taken from the leaf rather than\n * echoed from props, so that state records what the cluster said. They agree by construction\n * here — the leaf was found BY id — but echoing props into attributes is how a resource ends up\n * recording a declaration as though it were an observation.\n */\nexport const osdAttributes = (leaf: CrushNode, props: CephOsdProps): CephOsdAttributes => ({\n ceph_version: text(leaf['ceph_version_short']),\n crush_weight: num(leaf['crush_weight'], 0),\n device_class: text(leaf['device_class']),\n host: text(leaf['host']),\n in: bool(leaf['in']),\n name: text(leaf['name'], `osd.${String(props.osdid)}`),\n osdid: int(leaf['id'], props.osdid),\n osdtype: text(leaf['osdtype']),\n pgs: num(leaf['pgs'], 0),\n reweight: num(leaf['reweight'], 0),\n status: text(leaf['status']),\n total_space: num(leaf['total_space'], 0),\n});\n\n/**\n * The live OSD as attributes, or undefined.\n *\n * ★ IT LIVES HERE RATHER THAN IN ceph-osd.ts BECAUSE THE READ SIDE IS THIS FILE'S WHOLE JOB —\n * `findOsd` and `osdAttributes` are the two halves it composes, and keeping the caller beside\n * them is what let ceph-osd.ts come back under the 250-line cap when create and delete were\n * added. ⚠️ A 404 or a 403 both arrive here as `undefined`: see the ⛔ on `readRole` in\n * resource.ts for why that distinction is invisible and what it costs.\n */\nexport const readOsd = (props: CephOsdProps) =>\n pve<Record<string, unknown>>(props.target, 'read', 'GET', `nodes/${props.node}/ceph/osd`).pipe(\n Effect.map((t) => {\n const leaf = t === undefined ? undefined : findOsd(t, props.osdid);\n return leaf === undefined ? undefined : osdAttributes(leaf, props);\n }),\n );\n",
22
+ "/**\n * The two operations that change a disk: building an OSD and removing one.\n *\n * ★ SPLIT OUT OF ceph-osd.ts FOR THE 250-LINE CAP, and the seam is the honest one — this file is\n * everything that WRITES, and ceph-osd.ts is the declaration and the assertion. A reader asking\n * \"can this destroy my data\" has one file to read.\n *\n * ⛔ BOTH OF THESE ARE IRREVERSIBLE. `create` hands a block device to `ceph-volume lvm create`,\n * which zaps it; `delete` takes a replica out of a live pool and Ceph immediately begins\n * rewriting the missing copies across the remaining nodes. `Proxmox.CephOsd` therefore declares\n * `defaultRemovalPolicy: 'retain'`, so removing a declaration does NOT reach `destroyOsd` — a\n * caller opts in with `.pipe(RemovalPolicy.destroy())`.\n */\nimport * as Effect from 'effect/Effect';\nimport { readOsd } from './ceph-osd-tree.ts';\nimport type { CephOsdProps } from './ceph-osd.ts';\nimport { pve } from './client.ts';\n\nconst describe = (props: CephOsdProps) => `osd.${String(props.osdid)} on ${props.node}`;\n\nexport const createOsd = Effect.fn(function* (news: CephOsdProps) {\n if (news.dev === undefined) {\n return yield* Effect.die(\n new Error(\n `${describe(news)}: no such OSD in the CRUSH tree, and no \\`dev\\` was declared. ` +\n 'Without a device this resource is an ASSERTION over an OSD that must already ' +\n 'exist. Declare `dev` to let it create one -- which WIPES that device -- or fix ' +\n 'the declaration; if the disk was there yesterday, a replica is missing and Ceph ' +\n 'is degraded.',\n ),\n );\n }\n yield* pve(news.target, 'provision', 'POST', `nodes/${news.node}/ceph/osd`, {\n dev: news.dev,\n ...(news.device_class === undefined ? {} : { 'crush-device-class': news.device_class }),\n });\n const created = yield* readOsd(news);\n if (created === undefined) {\n return yield* Effect.die(\n new Error(\n `${describe(news)}: the create returned no error but osd.${String(news.osdid)} is ` +\n 'still absent. Ceph allocates OSD ids and cannot be told which to use, so it most ' +\n 'likely assigned a different number -- check `ceph osd tree`, and declare the id it ' +\n 'actually gave the device rather than deploying again.',\n ),\n );\n }\n return created;\n});\n\n/**\n * ⛔ REMOVING THE DECLARATION REMOVES THE ASSERTION, NOT THE REPLICA, AND THAT ASYMMETRY IS THE\n * POINT. `DELETE /nodes/{node}/ceph/osd/{osdid}` takes a replica out of a live pool — with\n * `nobackfill`/`norecover` unset, Ceph immediately starts rewriting the missing copies across\n * the two remaining nodes — and with `cleanup=1` it zaps the LVs as well. A stack file is\n * edited by people in a hurry; a disk is not a thing a deleted line gets to destroy. Take an\n * OSD out by hand, with the cluster healthy and `ceph -s` in front of you: `ceph osd out N`,\n * wait for the backfill to finish, then `pveceph osd destroy N`.\n *\n * ★ SO IT IS IMPLEMENTED, AND THE RESOURCE DEFAULTS TO `retain` INSTEAD. Removing a declaration\n * drops the state row and leaves the replica alone; a caller who really means it opts in with\n * `.pipe(RemovalPolicy.destroy())`. That is the same shape Terraform gives `prevent_destroy`,\n * and it beats a `delete` that silently does nothing — which is a lie to anyone reading the\n * plan.\n *\n * ⚠️ `cleanup` DEFAULTS TO FALSE, so the logical volumes survive and the disk can be re-added\n * without a rebuild. Ceph still starts backfilling the missing copies the moment the OSD goes.\n */\nexport const destroyOsd = (olds: CephOsdProps) =>\n pve(\n olds.target,\n 'provision',\n 'DELETE',\n `nodes/${olds.node}/ceph/osd/${String(olds.osdid)}`,\n olds.cleanup === true ? { cleanup: '1' } : {},\n );\n",
23
+ "/**\n * `Proxmox.CephPool` — a Ceph RADOS pool, declared. The richest Ceph family and the one a stack is\n * most likely to reach for, because every RBD disk in the cluster lives inside one.\n *\n * ⛔ IT DOES NOT USE `pveHandlers`, AND THE REASON IS MEASURED RATHER THAN STYLISTIC: THE READ AND\n * THE WRITES SIT AT DIFFERENT PATHS. `GET /nodes/{node}/ceph/pool/{name}` is `poolindex` and\n * answers `[{\"name\":\"status\"}]` — an INDEX OF CHILDREN, not the pool. The pool is one level\n * further down, at `.../status` (`getpool`), which accepts no PUT and no DELETE. A `PveSpec`\n * carries ONE `path` for read, update and delete, so this family cannot be spelled in it. `path`\n * below is therefore the READ path and nothing else consumes it: `ops.reconcile` and\n * `ops.destroy` go unused and the two write handlers name their own path. acl.ts is the\n * precedent for hand-writing the five handlers over `pveOperations`.\n *\n * ⛔ A CREATE FIRED AT A POOL THAT ALREADY EXISTS IS NOT A NO-OP, IT IS A PG MERGE — the second ⛔\n * in ceph-pool-form.ts has the evidence, and `confirmAbsent` below is the guard that stops it.\n *\n * ⛔ EVERY WRITE HERE IS A FORKED WORKER. createpool, setpool and destroypool each return a UPID\n * string, so HTTP 200 means \"the task started\" — an immediate read-back can see a pool that does\n * not exist yet, or values that have not landed. `settle` waits for the cluster to agree.\n *\n * ⛔ THE FOUR POOLS ON TB4 INCLUDE CEPH'S OWN, AND NONE OF THEM MAY BE ADOPTED. Measured\n * 2026-09-13: `.mgr` (application `mgr`, created and owned by the manager daemons),\n * `cephfs-tb4_data` and `cephfs-tb4_metadata` (the two halves of the `cephfs-tb4` filesystem —\n * destroying either destroys the filesystem), and `cephtb4`, the rbd pool the guests sit on.\n * `list` answers empty like every resource in this package, so adoption stays an explicit act;\n * the `applications` attribute is reported so that a plan SHOWS which of those a declaration hit.\n *\n * ⚠️ DELETING A POOL DESTROYS EVERY OBJECT IN IT AND CEPH DOES NOT ASK TWICE. Neither `force` nor\n * `remove_storages` is ever sent, so PVE's refusal while a storage on the pool still lists RBD\n * images is left standing. That refusal does NOT cover an RBD user outside storage.cfg.\n *\n * ⚠️ PRIVILEGES, AND THE WRITE LANE IS A BIG ASK. Read is `Sys.Audit` OR `Datastore.Audit` on `/`\n * (PVEAuditor holds both, so the mount's `read` role covers read, diff and the guard). Create,\n * update and delete each check `Sys.Modify` on `/` — there is no `/ceph` object to scope to, so\n * granting it also buys datacenter options and every other cluster-wide write. Widen\n * deliberately, the way `Pool.Allocate` was widened for `Proxmox.Pool`.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport {\n type CephPoolAttributes,\n type CephPoolProps,\n UNSET,\n applications,\n collection,\n createBody,\n hint,\n object,\n same,\n updateBody,\n} from './ceph-pool-form.ts';\nimport { confirmAbsent, settle } from './ceph-pool-settle.ts';\nimport { pve } from './client.ts';\nimport { type PveRequirements, type PveSpec, pveOperations } from './resource.ts';\nimport { bool, int, num, text } from './values.ts';\n\nexport type { CephPoolAttributes, CephPoolProps };\n\nexport interface ProxmoxCephPool extends Resource<\n 'Proxmox.CephPool',\n CephPoolProps,\n CephPoolAttributes,\n never,\n PveRequirements\n> {}\n\n/** ★ `retain` by default — a pool holding objects cannot be rebuilt. See the ★ in resource.ts. */\nexport const ProxmoxCephPool = Resource<ProxmoxCephPool>('Proxmox.CephPool', {\n defaultRemovalPolicy: 'retain',\n});\n\nconst spec: PveSpec<CephPoolProps, CephPoolAttributes> = {\n /**\n * ⛔ `name` IS THE PRESENCE TEST, AND IT IS ALSO HOW THE INDEX TRAP FAILS SAFE. Pointed at\n * `.../pool/{name}` rather than `.../status`, the factory would hand this function an ARRAY:\n * every field would read absent and the plan would report an update no write can satisfy.\n * `getpool` always returns `name` for a real pool, so that shape answers \"not there\" instead\n * — and \"not there\" cannot reach a create unless `confirmAbsent` agrees.\n */\n attributes: (live, props) => {\n if (typeof live['name'] !== 'string') return undefined;\n return {\n applications: applications(live['application_list']),\n crush_rule: text(live['crush_rule']),\n id: int(live['id'], UNSET),\n min_size: int(live['min_size'], UNSET),\n name: props.name,\n node: props.node,\n nodelete: bool(live['nodelete']),\n nopgchange: bool(live['nopgchange']),\n nosizechange: bool(live['nosizechange']),\n pg_autoscale_mode: text(live['pg_autoscale_mode']),\n pg_num: int(live['pg_num'], UNSET),\n pg_num_min: int(live['pg_num_min'], UNSET),\n size: int(live['size'], UNSET),\n target_size: int(live['target_size'], UNSET),\n target_size_ratio: num(live['target_size_ratio'], UNSET),\n };\n },\n collection,\n createForm: createBody,\n /**\n * ⛔ DECLARING WHAT IS LIVE MUST PLAN noop, AND EVERY OMISSION HERE IS WHY. Out, each with its\n * reason on the prop it belongs to: `pg_num` (the autoscaler rewrites it), `application` (the\n * write only ever ADDS to a list), `target_size_ratio` (float equality), `id`, `applications`\n * and the three `no*` flags (PVE returns them and accepts none of them on write), `node` and\n * `name` (the address the read was made at — true by construction, never a diff). In, and each\n * measured to round-trip unchanged against TB4's four pools on 2026-09-13: size 3, min_size 2,\n * pg_autoscale_mode `on`, crush_rule `replicated_rule`, pg_num_min where it is set (16 on\n * cephfs-tb4_metadata, absent on cephtb4), target_size in bytes — and each of the last two\n * through `hint`, which drops a declared zero for the reason given on it.\n */\n matches: (attributes, props) =>\n same(props.size, attributes.size, attributes.nosizechange) &&\n same(props.min_size, attributes.min_size, attributes.nosizechange) &&\n same(props.pg_autoscale_mode, attributes.pg_autoscale_mode) &&\n same(hint(props.pg_num_min), attributes.pg_num_min, attributes.nopgchange) &&\n same(props.crush_rule, attributes.crush_rule, attributes.crush_rule === '') &&\n same(hint(props.target_size), attributes.target_size),\n /**\n * ⛔ THE READ PATH, AND ONLY THE READ PATH.\n * ⚠️ `?verbose=1` IS WHAT MAKES `applications` VISIBLE AT ALL — without it PVE omits the tags\n * entirely (MEASURED across all four pools; there is no `application` key either way, only\n * `application_list`, and only when verbose). The cost is that verbose adds two unguarded mon\n * commands, `df` and `osd pool application get`, so a degraded mgr can fail the read. That is\n * safe here rather than merely unlucky: a failed read is \"absent\", and \"absent\" cannot reach a\n * create unless `confirmAbsent` agrees.\n */\n path: (props) => `${object(props)}/status?verbose=1`,\n updateForm: updateBody,\n};\n\nconst ops = pveOperations(spec);\n\nexport const ProxmoxCephPoolProvider = () =>\n Provider.effect(\n ProxmoxCephPool,\n Effect.succeed(\n ProxmoxCephPool.Provider.of({\n /** ⛔ Empty, and here it is what keeps `.mgr` and the two cephfs pools out — see the header. */\n list: () => Effect.succeed([]),\n read: ({ olds }) => ops.read(olds),\n diff: ({ news, output }) => ops.diff(news, output),\n /**\n * ⚠️ NOT `ops.reconcile`: it POSTs the moment a read comes back empty, and reads back once,\n * immediately. Both are wrong for a family whose writes are forked workers and whose\n * create is destructive against a pool that is already there.\n */\n reconcile: Effect.fn(function* ({ news }) {\n const live = yield* ops.read(news);\n let upid: string | undefined;\n if (live === undefined) {\n yield* confirmAbsent(news, spec.collection(news), object(news));\n upid = yield* pve<string>(\n news.target,\n 'provision',\n 'POST',\n collection(news),\n createBody(news),\n );\n } else {\n // ⚠️ An empty form is not a write — resource.ts skips one for the same reason.\n const form = updateBody(news);\n if (Object.keys(form).length > 0) {\n upid = yield* pve<string>(news.target, 'provision', 'PUT', object(news), form);\n }\n }\n const after = yield* settle(\n news,\n ops.read,\n (row) => row !== undefined && spec.matches(row, news),\n );\n if (after === undefined || !spec.matches(after, news)) {\n return yield* Effect.die(\n new Error(\n `${object(news)}: the write returned no error but the pool still does not match ` +\n `the declaration after 60s. PVE answered with task ${upid ?? '(none)'} -- read ` +\n 'its log with `pvesh get /nodes/<node>/tasks/<upid>/log` to see what Ceph ' +\n 'refused.',\n ),\n );\n }\n return after;\n }),\n /**\n * ⛔ THIS DESTROYS EVERY OBJECT IN THE POOL. No `force`, so PVE's own check — it refuses\n * while a PVE storage on this pool still lists RBD images — is left standing; and no\n * `remove_storages`, so a storage.cfg section pointing here survives and stays somebody's\n * to remove deliberately.\n * ⚠️ AND THE REFUSAL CAN ARRIVE AFTER THE RESPONSE, WHICH IS WHY THIS WAITS. The DELETE\n * forks a worker and answers 200 with a UPID, so mons running with\n * `mon_allow_pool_delete` false fail once the call has already returned. MEASURED on TB4\n * 2026-09-13: the config-db value is false while the running mons report true, i.e. it is\n * set in ceph.conf and the two sources disagree by design.\n */\n delete: Effect.fn(function* ({ olds }) {\n yield* pve<string>(olds.target, 'provision', 'DELETE', object(olds));\n const left = yield* settle(olds, ops.read, (row) => row === undefined);\n if (left !== undefined) {\n return yield* Effect.die(\n new Error(\n `${object(olds)}: the DELETE returned no error but the pool is still there after ` +\n '60s. Either a storage on it still holds RBD images, or the mons are running ' +\n 'with mon_allow_pool_delete false.',\n ),\n );\n }\n }),\n }),\n ),\n );\n",
24
+ "/**\n * What a Ceph pool IS as a declaration, and the two different forms PVE wants it in.\n *\n * ★ SPLIT OUT OF ceph-pool.ts TO KEEP BOTH FILES UNDER THE 250-LINE CAP, and the seam is\n * \"does this touch the cluster\" — the same one metric-server-form.ts draws, just with more on\n * this side because this family needs it. Here: the declared shape, the reported shape, and the\n * coercions that turn one into the other. There: reading TB4, deciding a diff, and the four\n * handlers. Nothing in this file makes a call or decides an action.\n * ⚠️ THE PROPS LIVE HERE RATHER THAN IN THE RESOURCE FILE, which is the one place this pair\n * differs from metric-server / notification-target. There is no `import type` cycle back as a\n * result; ceph-pool.ts re-exports both interfaces so the public surface is unchanged.\n *\n * ⛔ POST AND PUT DO NOT TAKE THE SAME PARAMETERS, AND BOTH EXTRAS ARE DESTRUCTIVE. MEASURED from\n * the cluster's own schema (/usr/share/pve-docs/api-viewer/apidoc.js on n2, pve-manager 9.2.11,\n * 2026-09-13): POST adds `add_storages` and `erasure-coding` to the shared set, PUT takes\n * neither. Both are refused below, so what is left between the two bodies is `name`, which PUT\n * reads from the path, and `pg_num`.\n *\n * ⛔ `pg_num` IS IN THE CREATE BODY AND NOT IN THE UPDATE BODY, AND THAT IS THE MOST IMPORTANT\n * LINE IN THIS FILE. MEASURED in PVE::API2::Ceph::Pool::createpool on n2: a POST carrying no\n * `pg_num` gets 128 substituted (`$param->{pg_num} //= 128`), and PVE::Ceph::Tools::create_pool\n * then runs `osd pool create` — which Ceph answers with SUCCESS for a pool that already exists,\n * before applying the rest of the body to it. So a create fired at a live pool SETS its pg_num,\n * and lowering pg_num starts a PG MERGE: hours of backfill across every OSD, on a cluster whose\n * Ceph traffic shares vmbr1.11 with everything else. ceph-pool.ts guards the create for exactly\n * that reason; this half simply never offers pg_num to an update.\n */\nimport type { WithTarget } from './resource.ts';\nimport { csv } from './values.ts';\n\nexport interface CephPoolProps extends WithTarget {\n /**\n * ⚠️ WHICH NODE THE CALL GOES THROUGH, NOT WHERE THE POOL LIVES. A pool is cluster-wide: n2 and\n * n3 answer byte-identically for `cephtb4` (measured). The endpoint is node-scoped only\n * because PVE talks to the local RADOS socket, so this is a door, not a location — it is never\n * compared, and moving a declaration from n2 to n3 plans noop. Point it at a node you expect\n * to be up: a node that is down makes the read fail, and a failed read reads as \"absent\".\n */\n node: string;\n /**\n * Ceph's primary key, cluster-wide.\n * ⛔ CHANGING IT DOES NOT RENAME ANYTHING. There is no rename in this API: the plan reads the new\n * name, finds nothing, and CREATES AN EMPTY POOL, leaving the old one and its data behind,\n * untracked. `replace` was considered and rejected — it would DELETE the old pool and every\n * image in it to satisfy an edited string. Rename by hand, deliberately, or not at all.\n */\n name: string;\n /** Replicas per object, 1-7. ⚠️ Frozen when the pool carries Ceph's `nosizechange`. */\n size?: number;\n /** Replicas required to accept writes, 1-7. ⚠️ Frozen by `nosizechange` too. */\n min_size?: number;\n /**\n * ⛔ CREATE-TIME ONLY, AND NEVER COMPARED — the single biggest noop hazard in this family. With\n * `pg_autoscale_mode` on or warn the autoscaler owns this number: MEASURED on TB4, `cephtb4`\n * sits at pg_num 128 while the autoscaler's own `pg_num_final` is 256, so a declaration\n * diffing it reports an update the moment Ceph decides to act. A split is gradual even with\n * the autoscaler off, and `nopgchange` can refuse the write outright — which kills the WHOLE\n * PUT, not just this field. Declare it as the birth size; steer it afterwards with\n * `pg_num_min`, or by hand.\n */\n pg_num?: number;\n /** The floor the autoscaler may not go below. Operator-owned and stable, so it IS compared. */\n pg_num_min?: number;\n /** ⚠️ PVE's create default is `warn`; Ceph's own is `on`, which is what all four TB4 pools have. */\n pg_autoscale_mode?: 'off' | 'on' | 'warn';\n /**\n * The CRUSH rule BY NAME, e.g. `replicated_rule`.\n * ★ THE SUSPECTED INTEGER-VS-NAME TRAP IS REAL BUT NOT ON THE PATH THIS RESOURCE READS, AND THAT\n * IS MEASURED BOTH WAYS. `GET .../ceph/pool` (the collection) reports `crush_rule: 0` with the\n * name beside it in `crush_rule_name`; `GET .../ceph/pool/{name}/status` reports\n * `crush_rule: \"replicated_rule\"` — the same spelling POST and PUT accept. Reading the\n * collection instead would reintroduce the forever-diff in a single edit.\n */\n crush_rule?: string;\n /**\n * ⛔ CREATE-TIME ONLY, AND NEVER COMPARED. PVE's PUT turns this into\n * `osd pool application enable` (Tools.pm:250-255), which ADDS a tag and never removes one,\n * and Ceph refuses a second application without `--yes-i-really-mean-it` — so an update would\n * either leave the pool tagged twice or die, and comparing one declared string against the\n * LIST that comes back is the set-in-arbitrary-order forever-diff. The live list is reported\n * as `applications` instead.\n */\n application?: 'cephfs' | 'rbd' | 'rgw';\n /** Autoscaler size hint, ⚠️ IN BYTES — see the ⚠️ on `updateBody`. A `1T` string is not accepted. */\n target_size?: number;\n /**\n * Autoscaler share of total capacity, 0-1.\n * ⚠️ WRITTEN BUT NEVER DIFFED, because a float is not a safe equality: Ceph stores a double and\n * PVE prints about 15 significant digits, so a ratio that is not exactly representable would\n * report an update on every plan for a pool nobody touched.\n */\n target_size_ratio?: number;\n /**\n * ⛔ `never` ON PURPOSE, BOTH OF THEM, AND THE COMPILE ERROR IS THE FEATURE.\n * `erasure-coding` does not configure this pool — it makes PVE build TWO pools and name\n * neither of them what you declared: `<name>-data` for the EC data and `<name>-metadata` for\n * the replicated half (Pool.pm:517-530). Nothing would then exist at `{name}`, so every plan\n * would read absent and try to create it again, forever.\n * `add_storages` writes a section into storage.cfg that this graph does not own; declare a\n * `Proxmox.Storage` and pass this pool's `name` into it instead, which makes the link real.\n */\n 'erasure-coding'?: never;\n add_storages?: never;\n}\n\n/**\n * ⚠️ THE THREE `no*` FLAGS ARE REPORTED BECAUSE THEY EXPLAIN A REFUSAL. Ceph can freeze a pool's\n * size or its PG shape, and `set_pool` dies on the whole PUT when any one parameter will not\n * apply (Tools.pm:310). `matches` refuses to diff the fields they freeze, so these attributes\n * are the only place a plan can show WHY a declared size is not being enforced. All three read\n * false on all four TB4 pools.\n * ⚠️ `pg_num`, `id` AND `applications` ARE REPORTED AND NEVER COMPARED — see the props above.\n * ⛔ NO `statistics` AND NO `autoscale_status`, though the verbose read returns both. They change\n * every few seconds; persisting them would rewrite this resource's state on every deploy and\n * read like drift. `UNSET` means the pool carries no value for that field.\n */\nexport interface CephPoolAttributes {\n name: string;\n /** The node the read went through. A debugging aid, not a property of the pool. */\n node: string;\n id: number;\n size: number;\n min_size: number;\n pg_num: number;\n pg_num_min: number;\n pg_autoscale_mode: string;\n /** ⚠️ Empty when PVE answered with a rule id instead of a name; `matches` then stops diffing it. */\n crush_rule: string;\n /** Sorted comma list, e.g. `rbd` or `cephfs`. Readable only under `?verbose=1`. */\n applications: string;\n target_size: number;\n target_size_ratio: number;\n nodelete: boolean;\n nopgchange: boolean;\n nosizechange: boolean;\n}\n\n/**\n * Where one pool is WRITTEN, and where a new one is POSTed.\n *\n * ⚠️ NEITHER IS WHERE IT IS READ — the read path is a segment longer and lives in ceph-pool.ts\n * next to the ⛔ that explains it. These two are here because a path is wire knowledge, and\n * because the create guard needs the collection without needing anything else from the spec.\n */\nexport const object = (props: CephPoolProps) => `nodes/${props.node}/ceph/pool/${props.name}`;\nexport const collection = (props: CephPoolProps) => `nodes/${props.node}/ceph/pool`;\n\n/**\n * ⚠️ \"NOT SET\" IS -1 AND NOT 0, for the reason metric-server-form.ts gives: `pg_num_min`,\n * `target_size` and `target_size_ratio` each take 0 as a REAL value meaning \"no floor, no hint\",\n * so a provider using 0 as its absent-marker cannot tell a declared zero from an undeclared\n * field. Every one of these is >= 0, so -1 sits outside all of their ranges.\n */\nexport const UNSET = -1;\n\n/** ⚠️ PVE returns the tags as an ARRAY in Ceph's order, so `csv` sorts before anything sees them. */\nexport const applications = (value: unknown) =>\n csv(Array.isArray(value) ? value.map((entry: unknown) => String(entry)) : []);\n\n/**\n * Declared? compare it. Undeclared, or frozen by a flag the pool carries? leave it alone.\n *\n * ⚠️ `frozen` IS THE WHOLE ANSWER TO \"A FIELD PVE WILL NOT ACCEPT ON WRITE\". Comparing one can only\n * plan an update that no write can satisfy: work reported on every run, forever.\n */\nexport const same = <T>(declared: T | undefined, live: T, frozen = false) =>\n declared === undefined || frozen || declared === live;\n\n/**\n * A declared autoscaler hint, or nothing when it is zero.\n *\n * ⚠️ A DECLARED ZERO IS \"NO FLOOR, NO HINT\", AND IT IS DELIBERATELY LEFT UNCOMPARED. REASONED, NOT\n * MEASURED: all four TB4 pools carry null for both `pg_num_min` and `target_size`, and finding\n * out for certain would mean writing to the cluster. Ceph CLEARS both when they are set to 0 and\n * `osd pool get all` then omits the key, which PVE reports as null and this pair reads as UNSET\n * — so a declared 0 would compare 0 against -1 on every plan, forever. Mapping 0 to UNSET\n * instead would be a guess in the OTHER direction, and wrong the same way if Ceph does report\n * the zero. Neither guess is made: a zero is still written, and then left unmanaged exactly like\n * an undeclared field.\n */\nexport const hint = (value: number | undefined) => (value === 0 ? undefined : value);\n\n/** One optional field, present in the form only when it was declared. */\nconst field = (name: string, value: string | undefined): Record<string, string> =>\n value === undefined ? {} : { [name]: value };\n\n/** ⚠️ Not named `digits`: `target_size_ratio` is a fraction, and `String` is right for both. */\nconst numeric = (value: number | undefined) => (value === undefined ? undefined : String(value));\n\n/**\n * The PUT body: everything POST and PUT both accept, `pg_num` excepted. `createBody` builds on it,\n * the way storage.ts's `mutable` serves both of its forms. `name` is the path's last segment on an\n * update and is not repeated here.\n *\n * ⚠️ SAFE TO RE-APPLY TO A POOL THAT ALREADY MATCHES, which reconcile relies on. MEASURED in\n * PVE::Ceph::Tools::set_pool (Tools.pm:293-300): it reads `osd pool get all` first and SKIPS\n * every setting whose value did not change, so re-sending the declared set costs one mon read.\n * ⛔ BUT A SETTING THAT DID CHANGE AND CANNOT BE APPLIED KILLS THE WHOLE PUT. Tools.pm:310 dies\n * with \"Could not set: <fields>\" if any parameter is left unapplied, so a pool carrying Ceph's\n * `nosizechange` fails an entire update over one field. That is why the `no*` flags are reported\n * and why `matches` refuses to diff what they freeze.\n *\n * ⚠️ AN UNDECLARED FIELD IS NEITHER SENT NOR COMPARED — storage.ts's rule, and the opposite of\n * Proxmox.Pool's. Undeclared means UNMANAGED here, because a pool has no one set of defaults to\n * fall back on: PVE's POST fills in size 3, min_size 2, application rbd and pg_autoscale_mode\n * 'warn' (MEASURED in createpool), while Ceph's own defaults — which is what every pool on TB4\n * was actually born with — put pg_autoscale_mode at 'on'. Guessing either set would rewrite a\n * pool somebody tuned by hand.\n *\n * ⛔ THERE IS NO `delete=` HERE AND THERE MUST NOT BE ONE. `setpool` is not a SectionConfig write:\n * it turns each parameter into an `osd pool set`, and Ceph has no \"unset\" for size, min_size or\n * crush_rule. metric-server-form.ts clears an undeclared optional because status.cfg supports\n * it; the same move here would send a parameter PVE has no verb for.\n *\n * ⚠️ `target_size` IS BYTES ON THE WIRE IN BOTH DIRECTIONS, WHICH IS WHY THE PROP IS A NUMBER AND\n * NOT PVE's `1T` STRING. MEASURED: the API parses the string with PVE::JSONSchema::parse_size\n * and stores Ceph's `target_size_bytes` (Pool.pm:474-477 for POST, 683-686 for PUT), and\n * `GET .../status` hands that integer back under the name `target_size` (Pool.pm:878). Run on\n * n2, `parse_size('1099511627776')` returns 1099511627776 — bare digits are bytes, no\n * multiplier — so a byte count survives the round trip exactly, while a declared `1T` would read\n * back as 1099511627776 and diff against itself on every plan, forever.\n */\nexport const updateBody = (props: CephPoolProps): Record<string, string> => ({\n ...field('crush_rule', props.crush_rule),\n ...field('min_size', numeric(props.min_size)),\n ...field('pg_autoscale_mode', props.pg_autoscale_mode),\n ...field('pg_num_min', numeric(props.pg_num_min)),\n ...field('size', numeric(props.size)),\n ...field('target_size', numeric(props.target_size)),\n ...field('target_size_ratio', numeric(props.target_size_ratio)),\n});\n\n/**\n * The POST body.\n *\n * ⛔ `add_storages=0` IS SENT EXPLICITLY RATHER THAN LEFT OUT, AND THE DEFAULT IS NOT WHAT IT LOOKS\n * LIKE. MEASURED at Pool.pm:481 — `$add_storages = 1 if $ec && !defined($add_storages)` — so for\n * an erasure-coded pool PVE turns it ON when the parameter is absent. A pool created with it\n * writes a NEW SECTION INTO storage.cfg that this graph does not own: `Proxmox.Storage` would\n * not know about it, `alchemy destroy` would leave it behind, and the first person to notice\n * would be whoever found a storage nobody declared.\n */\nexport const createBody = (props: CephPoolProps): Record<string, string> => ({\n ...updateBody(props),\n ...field('application', props.application),\n ...field('pg_num', numeric(props.pg_num)),\n add_storages: '0',\n name: props.name,\n});\n",
25
+ "/**\n * Waiting for Ceph to finish, which is a concern of its own.\n *\n * ★ SPLIT OUT OF ceph-pool.ts FOR THE 250-LINE CAP, and the seam is real: every other PVE family\n * in this package writes and reads back in one breath, because PVE's config endpoints are\n * synchronous. Ceph's are not — a pool delete returns before the PGs are gone — so this file is\n * the polling that difference forces, and ceph-pool.ts is the declaration.\n */\nimport * as Effect from 'effect/Effect';\nimport type { CephPoolAttributes, CephPoolProps } from './ceph-pool-form.ts';\nimport { pve } from './client.ts';\nimport type { PveRequirements } from './resource.ts';\n\n/**\n * ⚠️ THE DEPENDENCIES ARE PASSED IN RATHER THAN IMPORTED, and that is what made this file\n * separable at all. `collection`, `object` and `ops.read` are module-level bindings in\n * ceph-pool.ts; importing them back would be a runtime cycle, and duplicating them would be two\n * definitions of one path. Passing them is the pattern zfs-pool-write.ts already uses.\n */\nexport type PoolRead = (\n props: CephPoolProps,\n) => Effect.Effect<CephPoolAttributes | undefined, never, PveRequirements>;\n\n/**\n * ⛔ THE GUARD ON THE CREATE. `read` folds a 403, a timeout and a node that is down into the same\n * `undefined` as a pool that is genuinely missing — so \"absent\" is not evidence. This asks a\n * second, different question: does the cluster LIST this pool? A failure is left to propagate\n * rather than folded, so \"I could not ask\" fails the deploy instead of creating over live data.\n * An empty list is trusted: the collection 403s when the role is too narrow rather than\n * filtering, so `[]` really does mean a cluster with no pools.\n */\nexport const confirmAbsent = (props: CephPoolProps, collection: string, describe: string) =>\n pve<{ pool_name?: string }[]>(props.target, 'read', 'GET', collection).pipe(\n Effect.flatMap((rows) =>\n (rows ?? []).some((row) => row.pool_name === props.name)\n ? Effect.die(\n new Error(\n `${describe}: the cluster lists this pool but its status could not be read, ` +\n 'so this deploy will NOT create over it. Check that the node is up and that the ' +\n 'read role holds Sys.Audit or Datastore.Audit on / -- a create here would apply ' +\n 'pg_num to a live pool and start a PG merge.',\n ),\n )\n : Effect.void,\n ),\n );\n\n/**\n * Wait for the cluster to agree, then answer the last thing it said.\n *\n * ★ IT POLLS `matches`, THE SAME PREDICATE `diff` USES, so \"settled\" has exactly one definition in\n * this file. Polling `/nodes/{node}/tasks/{upid}/status` instead would read the worker's own\n * exit status, but it needs `Sys.Audit` on the node for a token that is NOT the one that started\n * the task — every `pve` call mints a fresh token, so the task's owner check cannot pass.\n * ⚠️ SHORT POLLS, LOW CAP: 2s apart, 30 tries, about a minute. A pool create takes seconds; one\n * still unsettled after a minute is a fault to surface, not a wait to lengthen.\n */\nexport const settle = (\n props: CephPoolProps,\n read: PoolRead,\n done: (live: CephPoolAttributes | undefined) => boolean,\n) =>\n Effect.gen(function* () {\n for (let attempt = 0; attempt < 30; attempt += 1) {\n const live = yield* read(props);\n if (done(live)) return live;\n yield* Effect.sleep('2 seconds');\n }\n return yield* read(props);\n });\n",
26
+ "/**\n * `Proxmox.FirewallAlias` — a named network the cluster firewall can be written in terms of.\n *\n * ★ WHY THIS FAMILY AND NOT FIREWALL RULES, WHICH IS THE ONE EVERYONE REACHES FOR FIRST. A rule is\n * addressed BY POSITION — `/cluster/firewall/rules/{pos}` — so inserting a rule renumbers every\n * rule below it. A position-keyed resource therefore RETARGETS ITSELF at somebody else's rule the\n * moment anything is inserted above it, and it does so while the plan looks clean: the path still\n * resolves, the read still succeeds, the diff is simply computed against the wrong object.\n * Aliases, ipsets and security groups are the firewall objects with STABLE IDENTITY — a name, not\n * an index — and they are the ones worth declaring. Rules belong in this package only once\n * somebody models the whole ordered list as ONE resource, which is a different shape from\n * `PveSpec` and should look different.\n *\n * ★ AND THE ALIAS IS THE PIECE THAT EARNS THE MOST BY BEING DECLARED. `10.1.0.0/16` spelled into\n * nine rules is nine places to edit and one to forget; `HomeLan` spelled into nine rules is one\n * place, resolved by PVE at compile time. The alias is the object that has to be right.\n *\n * ⛔ PVE REWRITES THE CIDR ON READ, AND THAT IS THE FOREVER-DIFF THIS RESOURCE IS SHAPED AROUND.\n * A declared `10.1.1.5/32` reads back as `10.1.1.5`. `cidr()` in `firewall-alias-form.ts` applies\n * exactly the cluster's own transformation to BOTH sides and carries the measurements; read that\n * comment before touching either side of `matches` below.\n *\n * ⛔ `ipversion` IS RETURNED BY THE READ AND REFUSED BY EVERY WRITE. `parse_alias` derives it from\n * the address and `read_alias` hands the parsed entry straight back, while POST and PUT declare\n * `additionalProperties: 0` with no such parameter — sending it is a 400, not an ignored hint. It\n * is REPORTED as an attribute so a plan can say whether an alias is v4 or v6, and kept OUT of\n * `matches`, exactly like `pool.members` and `user.tokens`.\n *\n * ⚠️ `digest` NEVER REACHES THIS PROVIDER, which is a better answer than keeping it out of\n * `matches`. The LIST read runs its entries through `copy_list_with_digest` and stamps one — and\n * it changes whenever ANYTHING else in the firewall config changes, so a resource that stored it\n * would diff on a rule somebody else edited. The SINGLE-OBJECT read this resource uses returns\n * `$aliases->{$name}` raw, with no digest in it at all. None is sent on write either:\n * `PVE::Tools::assert_if_modified` skips the comparison when either side is undef, and the API\n * handler already holds `lock_clusterfw_conf(10, ...)` for the whole read-modify-write. So\n * declining optimistic locking buys last-writer-wins between two concurrent editors, not a torn\n * file — and the alternative, storing a cluster-wide digest per alias, buys a permanent diff.\n *\n * ⚠️ THE NAME IS CASE-FOLDED FOR IDENTITY AND PRESERVED FOR DISPLAY, which reads as a bug until you\n * see both halves. The config is keyed `$aliases->{lc($data->{name})}` while the entry stores the\n * name as written, and the item GET lowers its path segment too — so `homelan` and `HomeLan` are\n * ONE alias, reachable by either spelling. `name` is therefore reported from the live config and\n * kept OUT of `matches`: rewriting an alias to change its capitalisation is a cosmetic write to\n * the file every node recompiles its firewall from.\n * ⛔ AND TWO DECLARATIONS DIFFERING ONLY IN CASE ARE THE SAME OBJECT, which is the `acl.ts`\n * hazard again. Alchemy sees two resource ids, the cluster sees one alias, and deleting either\n * takes it away from both.\n *\n * ⚠️ A RENAME IS MODELLED AS A REPLACE, NOT AS AN UPDATE, AND THE REJECTED OPTION WAS REAL. PVE's\n * PUT does take a `rename` parameter and Alchemy's `reconcile` does receive `olds`, so an\n * in-place rename was available. It was rejected because using it means hand-writing `reconcile`\n * as well as `diff` and branching on four states — old present or absent, new present or absent —\n * each branch a fresh way to write the wrong object, and all of it to buy only the gap between\n * the create and the delete. What a rename must NOT be is silent, which is what the factory alone\n * would make it: the read at the NEW path answers absent, `diff` says update, reconcile POSTs a\n * SECOND alias, and the old one stays in `cluster.fw` with its old CIDR — still resolving in\n * every rule that names it, and invisible to every later plan. `diff` below says `replace`.\n * ⚠️ CREATE-FIRST, as Alchemy defaults and as `acl.ts` argues: the new alias exists before the\n * old one goes, so a rules change can be sequenced between the two generations.\n *\n * ⚠️ PRIVILEGES, AND FOR ONCE NOTHING NEEDS WIDENING. MEASURED 2026-09-13 from the cluster's own\n * schema and its live ACL: the item GET checks `[\"perm\",\"/\",[\"Sys.Audit\"]]`, POST/PUT/DELETE\n * check `[\"perm\",\"/\",[\"Sys.Modify\"]]`, `hf-read@pve` holds `PVEAuditor` at `/` with propagate and\n * `hf-provision@pve` holds `LXCProvisioner` at `/` with propagate. Both privileges are already\n * held, so `readRole` stays the default `read` lane — unlike storage/sdn-zone/sdn-vnet, whose\n * ITEM reads are gated on an allocate privilege the auditor cannot have.\n * ⚠️ `Sys.Modify` ON `/` IS STILL A BIG HAMMER — it is the same grant `metric-server.ts` warns\n * about, and there is no `/firewall` object to scope a narrower role to.\n *\n * ⚠️ DELETION IS FULLY IMPLEMENTED AND THE DEFAULT POLICY IS DELIBERATELY NOT `retain`. The ★ in\n * `resource.ts` reserves `retain` for objects whose CONTENTS cannot be rebuilt from a line of\n * TypeScript; an alias is a name, a CIDR and a comment, all three of them in the declaration, so\n * recreating one is exact and free. The real hazard is referential — PVE checks nothing before\n * removing an alias, and a rule naming a removed one fails to compile — and `retain` would not\n * fix that, it would only leave an undeclared alias on the cluster forever. Sequence the rules,\n * or pipe `RemovalPolicy.retain()` at the declaration site where the reason is visible.\n *\n * ⚠️ `local_network` IS THE ONE ALIAS NAME WITH CLUSTER-WIDE MEANING. `compile_ipsets` reads\n * `aliases->{local_network}` to decide what the `management` ipset covers, and SYNTHESISES one\n * from the node's own subnet when it is missing — in memory, never written back to the file.\n * Declaring it is stable, because PVE leaves a present one alone. DELETING it hands that decision\n * silently back to autodetection, which is drift no plan will ever show.\n *\n * ⚠️ NO SECRET LIVES IN THIS FAMILY, so nothing here has to be typed `never` to keep it out of\n * Alchemy's unencrypted state the way `metric-server.ts` does with its `token`. A name, a CIDR and\n * a free-text comment are the whole object, and all three are the declaration's own values read\n * back — not a credential held by the cluster.\n *\n * ⚠️ ACCEPTANCE, STATED HONESTLY: `GET /cluster/firewall/aliases` ANSWERS `[]` ON THIS CLUSTER and\n * the cluster firewall is disabled, so there was no live alias to declare and NO create/plan/noop\n * round trip was run. What is measured is the published schema, the API module's Perl, and the\n * cluster's own `parse_alias` exercised on sample lines. Whoever declares the first alias should\n * confirm the SECOND plan says noop before trusting this file.\n */\nimport { Resource } from 'alchemy';\nimport { isResolved } from 'alchemy/Diff';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { body, cidr, comment, fold } from './firewall-alias-form.ts';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { int, text } from './values.ts';\n\nexport interface FirewallAliasProps extends WithTarget {\n /**\n * PVE's `pve-fw-alias`: a letter, then at least one more of letter/digit/`-`/`_`, to 64 chars.\n * ⚠️ IDENTITY, CASE-INSENSITIVELY — see the ⚠️ on folding in the header. A two-character minimum\n * is real: a one-letter name is refused by the pattern, not silently accepted.\n */\n name: string;\n /**\n * An IP or a network, e.g. `10.1.0.0/16`, `10.1.1.5`, `2001:db8::/32`.\n * ⚠️ A `/32` (or `/128`) SUFFIX IS DROPPED BY PVE AND BY `cidr()` ALIKE, so declaring one is\n * harmless — it simply is not what comes back. Anything `parse_ip_or_cidr` refuses is a 400.\n */\n cidr: string;\n /**\n * Free text, stored as a trailing `#` comment on the alias's line in `cluster.fw`.\n * ⚠️ TRIMMED, AND A LINE FEED IS REFUSED. A comment of exactly `0` cannot be stored at all — the\n * ⛔ in `firewall-alias-form.ts` measures why, and why declaring one plans as noop.\n */\n comment?: string;\n}\n\nexport interface FirewallAliasAttributes {\n /** The spelling held in `cluster.fw`, which need not be the declared one. Never compared. */\n name: string;\n /** Normalised the way PVE normalises it, so it is comparable with a declaration. */\n cidr: string;\n comment: string;\n /**\n * 4 or 6, derived by PVE from the address. Reported so a plan can show which stack an alias\n * covers; never compared, because no write accepts it.\n */\n ipversion: number;\n}\n\nexport interface ProxmoxFirewallAlias extends Resource<\n 'Proxmox.FirewallAlias',\n FirewallAliasProps,\n FirewallAliasAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxFirewallAlias = Resource<ProxmoxFirewallAlias>('Proxmox.FirewallAlias');\n\nconst handlers = pveHandlers<FirewallAliasProps, FirewallAliasAttributes>({\n /**\n * ⚠️ AN ENTRY WITH NO CIDR IS NOT AN ALIAS. `read_alias` raises for a name it does not hold, so\n * absence normally arrives as a failed call the factory folds into `undefined`; this guard\n * covers the other shape — a 200 carrying something that is not an alias — rather than\n * recording state for an object with an empty address. The next reconcile then POSTs and PVE\n * answers \"alias already exists\", which is loud and points at the read.\n */\n attributes: (live, props) => {\n const address = cidr(live['cidr']);\n return address === ''\n ? undefined\n : {\n cidr: address,\n comment: comment(live['comment']),\n ipversion: int(live['ipversion'], 0),\n /** ⚠️ FROM THE CLUSTER, falling back to props: the stored spelling is the interesting one. */\n name: text(live['name'], props.name),\n };\n },\n collection: () => 'cluster/firewall/aliases',\n createForm: (props) => ({ ...body(props), name: props.name }),\n /**\n * ⚠️ EXACTLY THE TWO FIELDS A PUT CAN PUT BACK, both sides through the same normalisers. `name`\n * is identity and case-only drift (see the header); `ipversion` is derived and unwritable.\n * Comparing either would report an update that no update can settle.\n */\n matches: (attributes, props) =>\n attributes.cidr === cidr(props.cidr) && attributes.comment === comment(props.comment),\n /**\n * ⚠️ UNESCAPED ON PURPOSE: `pve-fw-alias` admits only `[A-Za-z][A-Za-z0-9\\-\\_]+`, so there is no\n * character here that a URL would need to encode, and PVE lowercases the segment on arrival.\n */\n path: (props) => `cluster/firewall/aliases/${props.name}`,\n updateForm: body,\n});\n\n/**\n * ⛔ ONE HANDLER IS OVERRIDDEN AND THE REST COME FROM THE FACTORY, for the reason `acl.ts` spells\n * out at length: the factory answers `replace` only for an object with no update path, and this\n * one has a PUT. Left to delegate, a changed `name` would read absent at the new path, plan as an\n * update, and quietly leave the old alias behind. Everything else — the empty `list`, the read,\n * the read-back-guarded reconcile, the delete — is the factory's, unchanged.\n */\nexport const ProxmoxFirewallAliasProvider = () =>\n Provider.effect(\n ProxmoxFirewallAlias,\n Effect.succeed(\n ProxmoxFirewallAlias.Provider.of({\n ...handlers,\n diff: Effect.fn(function* ({ news, output }) {\n // ⚠️ `isResolved` FIRST: at plan time `news.name` can still be an unresolved Output, and\n // folding a placeholder would report a replace nobody asked for — the worst possible\n // false positive on this family, since a replace here DELETES an alias.\n if (output !== undefined && isResolved(news) && fold(news.name) !== fold(output.name)) {\n return { action: 'replace' } as const;\n }\n return yield* handlers.diff({ news, output });\n }),\n }),\n ),\n );\n",
27
+ "/**\n * A firewall alias on the wire: what PVE stores, and what it quietly changes on the way.\n *\n * ★ SPLIT OUT OF firewall-alias.ts TO KEEP BOTH FILES UNDER THE 250-LINE CAP, and the seam is the\n * same one metric-server.ts and node-network.ts cut: this file answers \"what does the cluster do\n * to a value\", firewall-alias.ts answers \"what is an alias and when has it changed\". Nothing here\n * reads the cluster and nothing here decides a diff.\n *\n * ⛔ THE PUT IS A FULL REPLACE, WHICH IS THE EXACT INVERSE OF metric-server.ts — DO NOT COPY THAT\n * FILE'S RULE OVER HERE. A metric server is a SectionConfig section and a PUT merges into it, so\n * an omitted field SURVIVES and a managed optional needs a matching `delete=` or it can never be\n * cleared. An alias is not: `update_alias` builds `$data = { name, cidr }`, adds `comment` only\n * when it is truthy, and assigns the whole hash over the old one. So an omitted `comment` is\n * CLEARED here, there is no `delete` parameter on this endpoint at all, and sending\n * `comment=''` would be a second spelling of the same thing.\n *\n * ⚠️ THE SAME REPLACE MAKES `cidr` REQUIRED ON EVERY UPDATE. PVE's PUT schema does not mark it\n * optional, and the Perl would build an entry with an undefined cidr if it could — so `body`\n * below sends it on update as well as on create, rather than treating it as \"only send what\n * changed\".\n */\nimport type { FirewallAliasProps } from './firewall-alias.ts';\nimport { text } from './values.ts';\n\n/**\n * The alias key, as PVE computes it.\n *\n * ⚠️ EVERY ENTRY POINT LOWERS THE NAME AND NOTHING LOWERS THE STORED ONE: create, read, update and\n * delete all start `my $name = lc($param->{name})`, while the entry keeps `name => $param->{name}`\n * as written. So this is identity, and the stored spelling is decoration. Used by `diff` to tell\n * an edit from a different alias — a comparison of the raw names would call a re-capitalisation a\n * replace, and delete an alias to put back the same one.\n */\nexport const fold = (name: string) => name.trim().toLowerCase();\n\n/**\n * A CIDR reduced to the one form PVE will hand back.\n *\n * ⛔ MEASURED by running the cluster's own `PVE::Firewall::parse_alias` on n2 (pve-manager 9.2.11,\n * 2026-09-13) — a pure function over a string, no config read and none written:\n * `10.1.1.5/32` -> `10.1.1.5` a /32 host suffix is STRIPPED\n * `2001:0DB8::1/128`-> `2001:0DB8::1` a /128 is stripped, and the case is NOT folded\n * `2001:db8::/32` -> `2001:db8::/32` a /32 on IPv6 is a real prefix and SURVIVES\n * `parse_ip_or_cidr` is where it happens: `s|/32$||` under the IPv4 branch and `s|/128$||` under\n * the IPv6 one. Unmatched, a declared `10.1.1.5/32` reads back as `10.1.1.5` and reports an\n * update on every plan for the rest of time, each deploy writing back a value it already holds.\n *\n * ⛔ SO THE STRIP IS VERSION-AWARE, AND AN UNCONDITIONAL `/32` WOULD CORRUPT THE COMPARISON. A\n * colon cannot appear in an IPv4 address and must appear in an IPv6 one, which is the whole\n * discriminator PVE's own two regexes come down to here. Reading `2001:db8::/32` as\n * `2001:db8::` would make a /32 prefix compare equal to a single host.\n *\n * ⚠️ AND IT STOPS THERE, ON PURPOSE. PVE does not lowercase, zero-pad or compress an IPv6 literal,\n * so neither may this: it stores what it was handed and gives that back, which means any spelling\n * is stable once written. Canonicalising further would make `matches` call two DIFFERENT stored\n * strings equal and report noop over real drift — the same lie as missing a rewrite, pointed the\n * other way.\n */\nexport const cidr = (value: unknown) => {\n const raw = text(value).trim();\n const host = raw.includes(':') ? '/128' : '/32';\n return raw.endsWith(host) ? raw.slice(0, -host.length) : raw;\n};\n\n/**\n * A comment reduced to the one form PVE will hand back.\n *\n * ⚠️ AN ALIAS COMMENT IS A TRAILING `#` ON ITS LINE IN `cluster.fw`, AND THE ROUND TRIP TRIMS IT.\n * MEASURED with the same parser run: `Cmt 10.2.0.0/16 # spaced comment ` comes back as\n * `spaced comment`. `parse_alias` strips the surrounding whitespace (`s/\\s*#\\s*(.*?)\\s*$//`) and\n * `format_aliases` refuses to write a blank one at all, so an untrimmed declaration would diff\n * against its own stored form forever.\n *\n * ⛔ A COMMENT OF EXACTLY `0` CANNOT BE STORED, AND READING THAT AS DRIFT WOULD LOOP FOREVER.\n * MEASURED: `Zero 10.3.0.0/16 # 0` parses to an entry with NO comment key. Both the create and\n * the update guard with Perl's `if $param->{comment}`, and `'0'` is false in Perl — so the string\n * is dropped before it ever reaches the file, on write as well as on read. Folded to `''` here\n * because that is what the cluster will do with it: a declaration asking for something PVE will\n * not keep should plan as noop and be documented, not diff on every plan and be unfixable by the\n * very PUT the diff asks for.\n *\n * ⚠️ A LINE FEED IS A 400, NOT A TRUNCATION. `pve_fw_verify_comment_spec` dies with \"comment must\n * not contain a line feed\", which is the honest answer and is left to PVE rather than silently\n * flattened here — flattening would store something the declaration did not say.\n */\nexport const comment = (value: unknown) => {\n const trimmed = text(value).trim();\n return trimmed === '0' ? '' : trimmed;\n};\n\n/**\n * Everything mutable, in the form PVE wants. Create adds `name`; update sends exactly this.\n *\n * ⚠️ `name` IS NOT SENT ON UPDATE BECAUSE IT IS ALREADY THE LAST SEGMENT OF THE PATH BEING PUT TO,\n * and a second copy can only disagree with it — the same reasoning metric-server.ts gives for\n * omitting its `id`. PVE takes the path segment as `$param->{name}` and writes it back as the\n * stored spelling, so a PUT for any other reason also re-capitalises the entry to match the\n * declaration. That is a side effect worth knowing about and not worth causing on its own.\n *\n * ⚠️ THE NORMALISED CIDR IS WHAT GETS WRITTEN, NOT THE DECLARED SPELLING. PVE stores the parameter\n * verbatim into `cluster.fw` and only strips the host suffix when it reads the file back, so\n * sending `10.1.1.5` rather than `10.1.1.5/32` leaves the file saying exactly what the next read\n * will answer. Both settle; this one leaves no pair of values that merely happen to agree.\n *\n * ⚠️ `rename` IS DELIBERATELY ABSENT — see the ⚠️ on renames in firewall-alias.ts. A `rename` in\n * this form would be a second, invisible identity for the object, set from a field the resource\n * does not have.\n */\nexport const body = (props: FirewallAliasProps): Record<string, string> => {\n const note = comment(props.comment);\n return { cidr: cidr(props.cidr), ...(note === '' ? {} : { comment: note }) };\n};\n",
28
+ "/**\n * `Proxmox.Group` — a PVE group: a name, a comment, and the set of users PVE hangs off it.\n *\n * ★ DECLARING `hf-mint` IS THE WHOLE POINT OF THIS FAMILY. `vaultmint@pve` holds the `HFMint` role\n * ON THE PATH `/access/groups/hf-mint` — measured from `GET /access/acl`, 2026-09-13 — which is\n * what confines the OpenBao proxmox engine to minting inside that one group. The group is the\n * fence around the credential every other resource in this package runs on, and until now it was\n * something a human typed on a node once. `user.ts` calls that account the branch it sits on;\n * this is the branch's other end.\n *\n * ⛔ MEMBERSHIP IS NOT SETTABLE HERE, SO IT IS REPORTED AND NEVER DIFFED. Measured from the\n * cluster's own schema: `POST /access/groups` and `PUT /access/groups/{groupid}` each accept\n * EXACTLY `groupid` and `comment`, both with `additionalProperties: 0`. There is no members\n * parameter to send. Membership is written from the other side — the `groups` field on each\n * USER, which `user.ts` already owns — so `members` below is an attribute, out of `matches`,\n * exactly like `pool.members` and `user.tokens`. Declared here it would be a diff that no write\n * in this file could ever settle.\n *\n * ⛔ THE INDEX AND THE ITEM DISAGREE ABOUT BOTH THE NAME AND THE TYPE, and this file reads only the\n * item. MEASURED against n2, 2026-09-13:\n * GET /access/groups -> [{\"groupid\":\"hf-mint\",\"comment\":\"…\",\n * \"users\":\"hf-provision@pve,hf-read@pve\"}, …]\n * GET /access/groups/hf-mint -> {\"comment\":\"…\",\"members\":[\"hf-provision@pve\",\"hf-read@pve\"]}\n * The index says `users` and hands back a COMMA STRING; the item says `members` and hands back an\n * ARRAY. A reader that looked for `users` on the item path would find nothing, report an empty\n * group, and quietly show a delete as harmless.\n *\n * ⛔ AND THE ITEM'S ORDER IS NOT STABLE BETWEEN TWO CONSECUTIVE CALLS. MEASURED, seconds apart, on\n * the same endpoint:\n * [\"root@pam\",\"tim@pve\",\"tim@pam\",\"tim@<account>.com@Schenanigans\"]\n * [\"tim@pam\",\"tim@pve\",\"tim@<account>.com@Schenanigans\",\"root@pam\"]\n * `read_group` builds it as `[keys %{ $data->{users} }]` — a bare Perl hash key list, whose order\n * is randomised per process — while the INDEX sorts (`join(',', sort keys …)`). So the array is\n * sorted on the way into `attributes` as well as being kept out of `matches`: unsorted, Alchemy's\n * stored state would churn on every read even with nothing to diff.\n *\n * ⚠️ `groupid` IS NOT ECHOED BY THE ITEM READ. Its return schema is `additionalProperties: 0` over\n * exactly `comment` and `members`, so the id comes from props — the same arrangement, and the\n * same reason, as `user.ts`.\n *\n * ★ PRIVILEGES: NOTHING HAD TO BE WIDENED, WHICH MAKES THIS THE FIRST FAMILY HERE THAT COST\n * NOTHING. Measured with `pveum user permissions`, 2026-09-13:\n * · item GET checks `['perm','/access/groups',['Sys.Audit','Group.Allocate'], any => 1]`, and\n * `hf-read@pve` already holds `Sys.Audit` there (propagated from `/` by `PVEAuditor`).\n * So `readRole` is left at the default `read` — unlike storage/sdn-zone/sdn-vnet, whose ITEM\n * reads PVE gates on an allocate privilege. See the ⛔ on `readRole` in `resource.ts`.\n * · POST, PUT and DELETE each check `Group.Allocate` on `/access/groups`, and\n * `hf-provision@pve` holds it via `LXCProvisioner`.\n *\n * ⛔ `retain` BY DEFAULT, BECAUSE DELETING A GROUP DESTROYS TWO THINGS THIS FILE CANNOT PUT BACK.\n * Measured in `PVE::AccessControl` on the node:\n * · The member list IS the group. `user.cfg` stores it on the GROUP line (`group:<id>:<users>:\n * <comment>:`) and DERIVES each user's `groups` map from it at parse time. Deleting the group\n * deletes the list, and this resource has no `members` prop to restore it from.\n * · `delete_group_acl` then walks the whole ACL tree and drops every grant where the group is\n * the SUBJECT. On this cluster that is `Schenanigans -> Administrator on /` and\n * `HomeAssistant -> PVEAuditor on /`: whole populations of access, gone in one call, with no\n * confirmation and nothing in the plan to suggest it.\n * `delete` is FULLY IMPLEMENTED — `DELETE /access/groups/{groupid}` exists, unlike the ACL\n * family's — so `.pipe(RemovalPolicy.destroy())` really removes the group. See the ★ in\n * `resource.ts` for why the policy is a guard rather than a stubbed-out operation.\n *\n * ⛔ NO SECRET REACHES STATE. A group holds a comment and a list of userids; there is no password,\n * no token and no key anywhere on these endpoints. `user.ts`'s ⛔ about unencrypted state applies\n * to this package, and this family simply has nothing to trip it.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { csv, text } from './values.ts';\n\nexport interface GroupProps extends WithTarget {\n /**\n * PVE's primary key for a group.\n *\n * ⚠️ THERE IS NO RENAME, AND THE FAILURE IS WORSE HERE THAN FOR A ROLE. Editing this makes `path`\n * point at a different group, which reads as absent and is created empty — while the old group\n * keeps its members and its ACL grants with nobody managing it. Two groups then both look\n * right in the UI and only one of them grants anything.\n */\n groupid: string;\n /** Free text shown in the UI — the only mutable field a group has. See `storedComment` below. */\n comment?: string;\n}\n\nexport interface GroupAttributes {\n groupid: string;\n comment: string;\n /**\n * Who is in the group, sorted — reported so a plan can say what a delete would strip, never\n * compared, because this endpoint cannot set it. See the two ⛔s in the header.\n */\n members: string[];\n}\n\nexport interface ProxmoxGroup extends Resource<\n 'Proxmox.Group',\n GroupProps,\n GroupAttributes,\n never,\n PveRequirements\n> {}\n\n/** ★ `retain` by default — a delete takes the membership and the group's grants. See the header. */\nexport const ProxmoxGroup = Resource<ProxmoxGroup>('Proxmox.Group', {\n defaultRemovalPolicy: 'retain',\n});\n\n/**\n * The comment PVE will actually END UP HOLDING for a given declaration.\n *\n * ⛔ PVE CANNOT STORE THE COMMENT `'0'`, AND A PROVIDER THAT DOES NOT MODEL THAT DIFFS FOREVER.\n * Three places in the shipped Perl test the comment for TRUTH rather than for definedness, and\n * in Perl the one-character string `'0'` is false:\n * `create_group`: `$group->{comment} = $param->{comment} if $param->{comment};`\n * `write_user_config`: `my $comment = $d->{comment} ? encode_text($d->{comment}) : '';`\n * the config parser: `$cfg->{groups}->{$g}->{comment} = decode_text($comment) if $comment;`\n * So a declared `comment: '0'` is accepted by the API, dropped on the way to `user.cfg`, and read\n * back as absent. Left alone, `matches` would be false on every plan and every deploy would\n * rewrite the same value into the same hole. Normalising BOTH the comparison and the form is how\n * `values.ts` already treats `''` as the absence of a boolean rather than as `false`.\n * ⚠️ MEASURED IN THE SOURCE ON n2, NOT ON THE WIRE — writing `'0'` to the cluster to watch it\n * vanish would have been a write, and this agent had read access only.\n * ⚠️ `pool.ts` HAS THE SAME LATENT HOLE — `pool:$pool:$comment:…` is written by that same\n * truthiness test and is not guarded. Not fixed from here; flagged so it is fixed on purpose.\n *\n * ⚠️ EVERY OTHER COMMENT ROUND-TRIPS EXACTLY, colons and newlines included: `write_user_config`\n * runs it through `encode_text` and the parser through `decode_text`, so the field separator in\n * `user.cfg` cannot be smuggled in.\n */\nconst storedComment = (comment: string | undefined) => {\n const value = comment ?? '';\n return value === '0' ? '' : value;\n};\n\n/**\n * The item read's `members` array, sorted into something two plans can agree on.\n *\n * ⚠️ `csv` IS REUSED RATHER THAN RE-IMPLEMENTED, AND ITS OWN ⚠️ IS EXACTLY THIS CASE: a list PVE\n * does not promise to give back in the order it was handed. Going out through the joined form\n * and back is the price of that reuse, and cheaper than a fourth hand-rolled sorter.\n * ⚠️ THE ARRAY ONLY — THE COMMA STRING IS NOT ACCEPTED HERE, ON PURPOSE. That spelling belongs to\n * the INDEX (`users`), which this provider never reads, so a branch for it would be a guess at a\n * shape that cannot arrive. `user.ts` refuses the same guess for `tokens` and for the same\n * reason: a wrong guess on a reported-only field surfaces in a plan as a phantom membership.\n * ⚠️ NO DEDUPLICATION, UNLIKE `user.ts`'s `groupSet`. These names are Perl HASH KEYS —\n * `[keys %{ $data->{users} }]` — so a duplicate is not representable. `user.groups` needs the\n * dedupe because its value also arrives from a hand-written prop; this one never does.\n */\nconst memberList = (live: unknown): string[] => {\n const joined = csv((Array.isArray(live) ? live : []).map((member: unknown) => text(member)));\n return joined === '' ? [] : joined.split(',');\n};\n\nconst handlers = pveHandlers<GroupProps, GroupAttributes>({\n attributes: (live, props) => ({\n /**\n * ⚠️ ABSENT IS EMPTY, NOT MISSING. `read_group` sets `comment` only `if defined(…)`, so a group\n * without one answers `{\"members\":[…]}` and nothing else. THAT ONE IS READ OFF THE HANDLER'S\n * SOURCE, not off the wire — every group on this cluster happens to carry a comment, so the\n * commentless shape was not there to measure. The empty-MEMBERS shape WAS measured —\n * `HomeAssistant` answers `{\"comment\":\"…\",\"members\":[]}`. `''` is what an undeclared\n * `comment` prop normalises to, so the two sides meet either way.\n */\n comment: text(live['comment']),\n /** ⚠️ FROM PROPS: the item read's schema is `additionalProperties: 0` over comment/members. */\n groupid: props.groupid,\n members: memberList(live['members']),\n }),\n collection: () => 'access/groups',\n createForm: (props) => ({ comment: storedComment(props.comment), groupid: props.groupid }),\n /**\n * ⚠️ `members` IS NOT COMPARED, AND NOTHING ELSE IS LEFT TO COMPARE. `comment` is the only field\n * a PUT here accepts, so it is the only field whose drift this provider can repair — the rule\n * `resource.ts` states once in the ⛔ on adoption: a field deliberately out of `matches` is a\n * field this resource does not manage.\n */\n matches: (attributes, props) => attributes.comment === storedComment(props.comment),\n path: (props) => `access/groups/${props.groupid}`,\n /**\n * ⚠️ ALWAYS SENT, EVEN EMPTY — that is how a comment is CLEARED. `update_group` assigns\n * `if defined($param->{comment})`, so an omitted field leaves the old text in place and a\n * declaration that dropped its comment would report an update the update could not settle. The\n * empty string then falls out of `user.cfg` on the truthiness test above and reads back as\n * `''`, which is what the props side normalises to. The loop closes.\n */\n updateForm: (props) => ({ comment: storedComment(props.comment) }),\n});\n\n/**\n * ⛔ THE EMPTY `list` IS INHERITED FROM `pveHandlers` AND IT MATTERS HERE. `GET /access/groups`\n * answers with every group on the cluster — on this one that is `Schenanigans`, which grants\n * `Administrator` on `/` to every human who logs in. Handing it to Alchemy would invite adoption,\n * and therefore one day a delete that takes the whole admin group's access with it. Adoption\n * stays an explicit act, here as everywhere else in this package.\n */\nexport const ProxmoxGroupProvider = () =>\n Provider.effect(ProxmoxGroup, Effect.succeed(ProxmoxGroup.Provider.of(handlers)));\n",
29
+ "/**\n * `Proxmox.HaResource` — a guest's HA membership, declared.\n *\n * ★ WITHOUT ONE OF THESE, EVERY GUEST THIS PACKAGE DECLARES IS PINNED TO THE NODE THE LINE NAMED\n * AND DIES WITH IT. The target is a three-node quorate cluster holding zero HA resources, so\n * `node` in `LxcProps` is the whole of a container's availability story: lose that node and the\n * container is simply gone until a person notices. Declaring a guest without declaring its HA\n * membership is half a declaration, which is why this lives beside `lxc.ts` rather than in a\n * runbook somebody reads after an outage.\n *\n * ⚠️ `state` READS LIKE STATUS AND IS CONFIGURATION. `started | stopped | disabled | ignored` is\n * the state the CRM is ASKED for; a line in the HA config file, not a reading off the cluster,\n * so it is a prop and it is compared. `LxcAttributes.status` is the opposite case — reported,\n * never declared — and confusing the two inverts the meaning: `state: 'stopped'` here says \"HA\n * should hold this guest stopped and still relocate it on node failure\", not \"it is stopped\".\n *\n * ⛔ AND YET IT MOVES POWER, WHICH IS THE ONE PLACE THIS PACKAGE'S \"PLANS DO NOT START THINGS\" RULE\n * BENDS. `lxc.ts` and `qemu.ts` refuse to own power state precisely so a deploy is not a\n * maintenance window — but the CRM acts on whatever this file says. The default `started` will\n * BOOT a stopped guest within seconds of the write, and `stopped` will SHUT DOWN a running one.\n * There is no way to declare HA membership without declaring intent, so the intent is at least\n * explicit and diffable here; read a plan that touches `state` as a plan that touches uptime.\n *\n * ⛔ `sid` CARRIES ITS TYPE PREFIX — `ct:101`, `vm:100` — AND READ ANSWERS IN THE PREFIXED FORM.\n * POST also takes the bare `101` shortcut; taking it would leave a resource keyed on a spelling\n * PVE never returns, and every plan comparing `101` against `ct:101`. So the prefixed form is\n * required here and it is what goes into the path.\n * ⚠️ EDITING `sid` IN PLACE ORPHANS THE OLD MEMBERSHIP. `diff` reads the NEW path, finds nothing\n * and calls that drift, so reconcile creates the new entry and the old one stays under HA with\n * nothing declaring it. Retire the declaration and add a second one instead of renaming.\n *\n * ⛔ MEASURED ON PVE 9.2: `/cluster/ha/groups` ANSWERS HTTP 500 — groups were removed in PVE 9,\n * even though the published API schema still documents the endpoint AND a `group` parameter on\n * this very resource. Nothing here sends `group`. The successor is `/cluster/ha/rules`\n * (node-affinity and resource-affinity) and that is the next family to add; do not port the old\n * groups endpoint back just because the docs still describe it.\n *\n * ⚠️ RECONCILE NEEDS `Sys.Console` ON `/`, WHICH `LXCProvisioner` DOES NOT HOLD. Read and diff are\n * fine — `GET /cluster/ha/resources/{sid}` checks `Sys.Audit`, which the role already has — while\n * POST, PUT and DELETE all check `Sys.Console` on `/` and will answer \"Permission check failed\n * (/, Sys.Console)\" until the role is widened. Widen it knowingly: `Sys.Console` is also what\n * opens a root shell on every node (`/nodes/{node}/vncshell`, `termproxy`), so granting it to the\n * provision credential buys HA membership at the price of node console access. A separate role\n * for HA writes is the narrower answer if that trade is not wanted.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { num } from './values.ts';\n\n/**\n * The requested states this provider admits.\n *\n * ⚠️ `enabled` IS DELIBERATELY ABSENT. PVE accepts it and documents it as an alias for `started`,\n * which means a resource declared as `enabled` can be read back as `started` — and `matches`\n * would then report an update on every plan, forever, over a difference in spelling. One spelling\n * per state is the only version of this that settles.\n */\nexport type HaState = 'started' | 'stopped' | 'disabled' | 'ignored';\n\nexport interface HaResourceProps extends WithTarget {\n /** ⛔ PREFIXED AND CLUSTER-WIDE: `ct:101`, `vm:100`. Changing it is a different object. */\n sid: string;\n /** What the CRM should aim for. Defaults to `started`, PVE's own default. */\n state?: HaState;\n /** Free text shown in the HA panel. Max 4096 characters. */\n comment?: string;\n /** Restart tries on the SAME node before the manager gives up and relocates. Default 1. */\n max_restart?: number;\n /** Relocation tries before the resource is left in `error`. Default 1. */\n max_relocate?: number;\n}\n\nexport interface HaResourceAttributes {\n /** As PVE returns it, prefix included. */\n sid: string;\n /** `ct` | `vm`. Implied by the prefix, reported so a plan can say what is being protected. */\n type: string;\n /**\n * ⚠️ TYPED `string`, NOT `HaState`, because this is whatever the config file holds — including an\n * `enabled` a person wrote in the UI. Narrowing it here would be a claim about someone else's\n * edit rather than a report of it.\n */\n state: string;\n comment: string;\n max_restart: number;\n max_relocate: number;\n}\n\nexport interface ProxmoxHaResource extends Resource<\n 'Proxmox.HaResource',\n HaResourceProps,\n HaResourceAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxHaResource = Resource<ProxmoxHaResource>('Proxmox.HaResource');\n\n/** `ct:101` -> `ct`. ⚠️ `?? ''` because noUncheckedIndexedAccess types `split()[0]` as optional. */\nconst kind = (sid: string) => sid.split(':')[0] ?? '';\n\n/**\n * ⚠️ NO `type` IN EITHER FORM, ON PURPOSE. The prefix in `sid` already names it on create, and PUT\n * does not accept `type` at all — sending it on create only would make the two shapes diverge for\n * no gain, and sending it on update is a parameter-verification failure.\n */\nconst shape = (props: HaResourceProps) => ({\n comment: props.comment ?? '',\n max_relocate: String(props.max_relocate ?? 1),\n max_restart: String(props.max_restart ?? 1),\n state: props.state ?? 'started',\n});\n\nconst handlers = pveHandlers<HaResourceProps, HaResourceAttributes>({\n attributes: (live, props) => ({\n comment: typeof live['comment'] === 'string' ? live['comment'] : '',\n max_relocate: num(live['max_relocate'], 1),\n max_restart: num(live['max_restart'], 1),\n sid: typeof live['sid'] === 'string' ? live['sid'] : props.sid,\n state: typeof live['state'] === 'string' ? live['state'] : 'started',\n type: typeof live['type'] === 'string' ? live['type'] : kind(props.sid),\n }),\n /**\n * ⚠️ CLUSTER-SCOPED, SO THERE IS NO NODE IN THE PATH — and that is the point of the object. The\n * guest's node is where it happens to run now; this resource is the statement that it may run\n * somewhere else tomorrow.\n */\n collection: () => 'cluster/ha/resources',\n createForm: (props) => ({ ...shape(props), sid: props.sid }),\n /**\n * ⚠️ `digest` IS NOT COMPARED AND IS NOT AN ATTRIBUTE. It changes whenever ANY line of the HA\n * config changes, including one written for a different guest, so diffing it would report an\n * update on this resource because somebody else edited theirs.\n * ⚠️ `sid` AND `type` ARE NOT COMPARED EITHER: sid is the path, so a change there is a different\n * object, and type is create-only — it is read back from the prefix, never edited.\n */\n matches: (attributes, props) =>\n attributes.state === (props.state ?? 'started') &&\n attributes.comment === (props.comment ?? '') &&\n attributes.max_restart === (props.max_restart ?? 1) &&\n attributes.max_relocate === (props.max_relocate ?? 1),\n /**\n * ⚠️ THE COLON GOES INTO THE URL RAW. RFC 3986 allows `:` inside a path segment and PVE matches\n * the sid as one segment, so no `encodeURIComponent` here; percent-encoding it would make the\n * request depend on a proxy normalising `%3A` back before the dispatcher sees it.\n */\n path: (props) => `cluster/ha/resources/${props.sid}`,\n updateForm: shape,\n});\n\n/**\n* ⛔ Empty for the same reason as every other resource here: adoption must be explicit.\n* `GET /cluster/ha/resources` would hand back every guest an operator has ever put under\n* HA, and adopting those means one day deleting them.\n \n *\n* ⛔ DELETE DEFAULTS TO `purge=1` AND THE FACTORY SENDS NO FORM, SO THAT DEFAULT APPLIES:\n* PVE strips the sid out of every HA rule referencing it and DELETES a rule that had no\n* other member. Destroying an HA membership can therefore take an affinity rule with it,\n* which matters once the rules family lands.\n* ⚠️ It does NOT stop or remove the guest. The container keeps running exactly where it is,\n* only unmanaged — so removing this resource is how a guest is handed back to its node,\n* not how it is decommissioned.\n \n */\nexport const ProxmoxHaResourceProvider = () =>\n Provider.effect(ProxmoxHaResource, Effect.succeed(ProxmoxHaResource.Provider.of(handlers)));\n",
30
+ "/**\n * `Proxmox.HaRule` — where the CRM may place a guest, and which guests must not share a node.\n *\n * ★ THIS IS THE PVE 9 SUCCESSOR TO HA GROUPS, AND THE GROUPS ENDPOINT IS GONE. MEASURED on n2\n * (pve-manager/9.2.11, 2026-09-13): `pvesh get /cluster/ha/groups` answers `cannot index groups:\n * ha groups have been migrated to rules`, and `/etc/pve/ha/` holds `rules.cfg` with no\n * `groups.cfg` beside it. The published schema still documents groups and still offers a `group`\n * parameter on `Proxmox.HaResource`; both are dead. Do not port them back.\n *\n * ★ ONE RESOURCE FOR BOTH RULE TYPES, ON THE ceph-daemon.ts ARGUMENT AND AFTER READING BOTH\n * PLUGINS. `PVE::HA::Rules::NodeAffinity` and `::ResourceAffinity` share `resources`, `affinity`,\n * `disable` and `comment`; node-affinity adds `nodes` and `strict` and nothing else diverges. The\n * endpoint, the path, the create/update/delete calls, the `order` and `digest` traps below and\n * the list normalisation are identical for both. Two files would have carried every one of those\n * traps twice and let them drift.\n * ⛔ `type` IS CREATE-ONLY. MEASURED in `/usr/share/perl5/PVE/API2/HA/Rules.pm`: `update_rule`\n * takes the plugin from the STORED rule (`my $type = $rule->{type};`) and never rewrites it. So\n * `attributes` reports a rule of the other type as ABSENT, which sends reconcile down the\n * create branch and makes PVE refuse with `HA rule '<id>' already defined` — a loud, accurate\n * error rather than a PUT pushing node-affinity fields at a resource-affinity rule.\n * ⛔ AND YET IT IS SENT ON THE UPDATE ANYWAY, because the PUT is validated against a `oneOf`\n * keyed on it and refuses the whole body without it. That one is worth reading in full: it\n * is the ⛔ on `required` in ha-rule-form.ts.\n *\n * ⛔ THREE FIELDS PVE RETURNS AND NO WRITE ACCEPTS, EACH ONE A FOREVER-UPDATE IF COMPARED.\n * `order` is an ORDINAL PVE ASSIGNS ITSELF (`$rules->{order}->{$ruleid} =\n * PVE::HA::Rules::get_next_ordinal($rules)`) and it appears in no create or update schema at all;\n * it is reported in attributes and never compared. `digest` is the digest of the WHOLE rules\n * file, so it moves when a rule written for somebody else's guests moves — it is not even an\n * attribute, for the reason ha-resource.ts gives. `errors` is PVE's own feasibility verdict,\n * recomputed across every rule on every read; reported, never compared. See `problems` in\n * ha-rule-form.ts.\n *\n * ⚠️ IT COMPOSES WITH `Proxmox.HaResource`, AND THE EDGE IS REAL RATHER THAN TIDY. MEASURED:\n * `create_rule` runs `$assert_valid_resources_param`, which calls\n * `PVE::HA::Config::service_is_configured($resource)` for every sid and dies `cannot use\n * unmanaged resource(s) <sid>` if one is not already an HA resource. A rule naming a sid nothing\n * has put under HA is a HARD 400, not a warning — so `resources` should be written as the\n * HaResource's own attribute (`resources: [web.sid, db.sid]`) and let Alchemy order the deploy,\n * not as a bare string that happens to match. `$assert_valid_nodes_param` refuses a non-existent\n * node the same way.\n * ⛔ AND THE EDGE RUNS BACK THE OTHER WAY, WHERE ALCHEMY CANNOT SEE IT. Destroying an\n * `HaResource` deletes with PVE's default `purge=1`, which strips that sid out of every rule\n * and DELETES any rule left with no members. So a plan that only removes a guest can remove\n * this resource's object from under it; the next plan then reads absent and recreates it, or\n * fails on the `unmanaged resource` check if the guest is gone for good.\n *\n * ⚠️ BOTH LANES ALREADY HAVE THE PRIVILEGES, WHICH IS NEW. MEASURED 2026-09-13:\n * GET (collection and item) checks `Sys.Audit` on `/` and the built-in `PVEAuditor` holds it, so\n * `readRole` stays the default `read` lease — unlike storage.ts and the SDN families. POST, PUT\n * and DELETE all check `Sys.Console` on `/`, and `pvesh get /access/roles/LXCProvisioner` now\n * returns `Sys.Console` among its 27 privileges. The warning in ha-resource.ts's header — that\n * `Sys.Console` is missing — is stale; the role was widened, and the price it named still stands:\n * `Sys.Console` is also what opens a root shell on every node.\n *\n * ⚠️ REMOVAL IS THE PLAIN DEFAULT, DELIBERATELY, AND `delete` IS THE FACTORY'S. An HA rule is\n * exactly a line of TypeScript — nothing in it is irreplaceable the way a Ceph pool or a ZFS\n * vdev is — so the `retain` default that resource.ts explains does not apply. Read the plan for\n * what it is, though: while a negative resource-affinity rule is absent, nothing stops the CRM\n * putting both halves of a pair on one node.\n *\n * ⚠️ A READ GOES THROUGH THE GROUPS MIGRATION. Every GET calls `migrate_groups_to_rules`, so on a\n * cluster that still has `groups.cfg` the answer includes SYNTHETIC rules nobody declared. This\n * cluster has none, so nothing is injected here; a rule id colliding with an old group name on a\n * cluster that does would read back something this provider never wrote.\n *\n * ⚠️ A CHANGED `type` READS AS `update` IN THE PLAN AND FAILS AS \"already defined\" ON THE APPLY,\n * AND THOSE TWO WORDS POINT AWAY FROM THE CAUSE. `attributes` answers undefined when the live\n * rule's type disagrees, so `diff` takes resource.ts's `live === undefined` branch and says\n * update; reconcile then reads undefined, POSTs, and PVE refuses because the rule is plainly\n * there. The cause is that `type` is create-only. metric-server.ts has the same shape, so this\n * is the package's consistent behaviour rather than a quirk of this file — but it is worth\n * knowing before reading the error. Delete the declaration and write a new one to change a type.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { body, clearList, commentText, nodeList, problems } from './ha-rule-form.ts';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { bool, csv, int, text, withClears } from './values.ts';\n\nexport type HaRuleType = 'node-affinity' | 'resource-affinity';\n\n/**\n * ⛔ REQUIRED ON BOTH TYPES, AND THAT IS A DELIBERATE NARROWING OF PVE'S SCHEMA. PVE makes it\n * optional for node-affinity (defaulting to `positive`) and mandatory for resource-affinity. A\n * provider that mirrored that has two bad options when a declaration omits it: guess `positive`,\n * which silently flips a live `negative` rule — the one keeping two guests APART — into one that\n * pins them together; or leave it out of the write, which makes `matches` disagree with a live\n * `negative` rule forever while every PUT changes nothing. Requiring one word from the caller\n * removes both.\n */\nexport type HaAffinity = 'positive' | 'negative';\n\ninterface HaRuleBase extends WithTarget {\n /** A `pve-configid`: a letter, then letters, digits, `-` and `_`. Identity — renaming is a new\n * rule, and the old one stays behind exactly as `sid` does in ha-resource.ts. */\n rule: string;\n /**\n * The HA resources this rule constrains, as prefixed sids — `ct:101`, `vm:100`.\n * ⚠️ EVERY ONE MUST ALREADY BE UNDER HA. See the composition ⚠️ in the header: this is an\n * ordering edge, and the honest way to express it is the HaResource's own `sid` attribute.\n */\n resources: readonly string[] | string;\n affinity: HaAffinity;\n /** Keep the rule in the file but stop the CRM applying it. ⛔ Clearing it needs `delete=disable`\n * — see the ⛔ in `optional` in ha-rule-form.ts. */\n disable?: boolean;\n /** Free text shown in the HA panel. Max 4096 characters. */\n comment?: string;\n}\n\nexport interface NodeAffinityRuleProps extends HaRuleBase {\n type: 'node-affinity';\n /**\n * Cluster nodes, each optionally `<node>:<priority>`. Higher priority wins; the numbers are\n * relative and nothing else. ⚠️ REQUIRED BY THE TYPE, not merely by PVE — an optional `nodes`\n * would let a declaration that cannot describe any live rule sit in a permanent update loop.\n */\n nodes: readonly string[] | string;\n /** `false` (PVE's default) makes the nodes a PREFERENCE; `true` makes them the only nodes the\n * resources may run on, and the resources STOP when none of them is available. */\n strict?: boolean;\n}\n\nexport interface ResourceAffinityRuleProps extends HaRuleBase {\n type: 'resource-affinity';\n}\n\n/**\n * ⚠️ A UNION, NOT ONE FLAT INTERFACE WITH OPTIONAL EXTRAS, because `nodes` and `strict` are not\n * merely unused on a resource-affinity rule — PVE's oneOf declares `additionalProperties: 0`, so\n * sending either is a 400, and comparing either would be a diff no write could ever settle. The\n * union makes both unwritable rather than ignored.\n */\nexport type HaRuleProps = NodeAffinityRuleProps | ResourceAffinityRuleProps;\n\nexport interface HaRuleAttributes {\n rule: string;\n type: HaRuleType;\n /** ⚠️ NORMALISED, NOT RAW. PVE returns `join(',', sort keys %$hash)` — a re-sorted SET. */\n resources: string;\n /** ⚠️ Normalised by `nodeList`; always `''` on a resource-affinity rule, which has no nodes. */\n nodes: string;\n affinity: string;\n strict: boolean;\n disable: boolean;\n comment: string;\n /** ⛔ PVE-ASSIGNED AND UNWRITABLE. Reported so a plan can show it; never compared. */\n order: number;\n /** ⛔ PVE's feasibility verdict for this rule. Reported; never compared. */\n errors: string;\n}\n\nexport interface ProxmoxHaRule extends Resource<\n 'Proxmox.HaRule',\n HaRuleProps,\n HaRuleAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxHaRule = Resource<ProxmoxHaRule>('Proxmox.HaRule');\n\nconst handlers = pveHandlers<HaRuleProps, HaRuleAttributes>({\n attributes: (live, props) => {\n /**\n * ⛔ A RULE OF THE OTHER TYPE IS ANOTHER OBJECT, AND \"ABSENT\" IS THE HONEST ANSWER — the same\n * move metric-server.ts makes, for the same reason: `type` cannot be changed by a PUT, so\n * reporting the foreign rule as missing makes reconcile POST and PVE refuse because the id\n * is taken. An older PVE that omitted `type` from the read would fall through and be trusted.\n */\n const liveType = text(live['type']);\n if (liveType !== '' && liveType !== props.type) return undefined;\n return {\n affinity: text(live['affinity']),\n comment: text(live['comment']),\n /**\n * ⚠️ ABSENT WHEN OFF, AND THAT IS NOT THE SAME AS `false` BY ACCIDENT. MEASURED in\n * `PVE::HA::Rules::set_rule_defaults`: a default is materialised into the read only when it\n * is TRUTHY, so `disable` (no default) and `strict` (default 0) are simply missing from an\n * enabled, non-strict rule while `affinity` (default `positive`) is always present.\n */\n disable: bool(live['disable'], false),\n errors: problems(live['errors']),\n nodes: nodeList(typeof live['nodes'] === 'string' ? live['nodes'] : undefined),\n order: int(live['order'], 0),\n resources: csv(typeof live['resources'] === 'string' ? live['resources'] : undefined),\n rule: text(live['rule'], props.rule),\n strict: bool(live['strict'], false),\n type: props.type,\n };\n },\n collection: () => 'cluster/ha/rules',\n /** ⚠️ ONLY `rule` IS ADDED HERE: the POST is to the collection, so the id is not in the path.\n * `type` is already in `body` — the PUT needs it too, for the reason ha-rule-form.ts gives. */\n createForm: (props) => ({ ...body(props), rule: props.rule }),\n /**\n * ⛔ ONLY FIELDS A WRITE CAN ACTUALLY SET ARE COMPARED. `order`, `errors` and `digest` are out\n * for the reason the header gives at length — each would report an update that the PUT it\n * triggers cannot satisfy, on every plan, forever. `rule` and `type` are out too: one is the\n * key the object was read by, the other is refused rather than updated.\n * ⚠️ `nodes` AND `strict` ARE COMPARED ONLY ON A NODE-AFFINITY RULE. They do not exist on the\n * other plugin, so `attributes.nodes` is `''` and `attributes.strict` is `false` there by\n * construction — comparing them would be comparing a declaration against nothing.\n * ⚠️ THE COMMENT IS COMPARED AS PVE WILL STORE IT, not as it was declared — `commentText` and\n * its ⛔ explain why a `%XX` in a comment does not survive the round trip.\n */\n matches: (attributes, props) =>\n attributes.resources === csv(props.resources) &&\n attributes.affinity === props.affinity &&\n attributes.comment === commentText(props.comment ?? '') &&\n attributes.disable === (props.disable === true) &&\n (props.type !== 'node-affinity' ||\n (attributes.nodes === nodeList(props.nodes) &&\n attributes.strict === (props.strict === true))),\n /** ⚠️ A `pve-configid` has no `/` or `:` in it, so there is nothing here to encode. */\n path: (props) => `cluster/ha/rules/${props.rule}`,\n /**\n * ⛔ THE `delete=` HALF IS WHAT MAKES THIS SETTLE. A PUT merges into the stored rule and a\n * `disable=0` is thrown away before the plugin sees it, so without the clear list a rule\n * disabled by hand could never be re-enabled by a declaration and every plan would report the\n * same update. `clearList` and `body` come off one table — see ha-rule-form.ts.\n */\n updateForm: (props) => {\n const clear = clearList(props);\n const fields = body(props);\n return withClears(fields, clear);\n },\n});\n\n/**\n * ⛔ THE EMPTY `list` FROM `pveHandlers` STANDS, AND IT COSTS NOTHING HERE TODAY.\n * `GET /cluster/ha/rules` MEASURED `[]` on this cluster on 2026-09-13 — but the same call on a\n * cluster somebody has used returns every rule an operator ever clicked, plus the synthetic ones\n * the groups migration invents on read. Adopting either is how a later `alchemy destroy` removes\n * a separation rule nobody declared. Adoption stays an explicit act.\n */\nexport const ProxmoxHaRuleProvider = () =>\n Provider.effect(ProxmoxHaRule, Effect.succeed(ProxmoxHaRule.Provider.of(handlers)));\n",
31
+ "/**\n * An HA rule's props as the form PVE wants, and the two lists PVE re-spells on the way back.\n *\n * ★ SPLIT OUT OF ha-rule.ts TO KEEP BOTH FILES UNDER THE 250-LINE CAP, and the seam is the same\n * one metric-server-form.ts and node-network-form.ts cut: this file answers \"how does a\n * declaration become a PVE form, and what shape does PVE hand back\", ha-rule.ts answers \"what is\n * an HA rule and when has it changed\". Nothing here reads the cluster or decides a diff.\n *\n * ⚠️ THE `import type` BACK TO ha-rule.ts IS A CYCLE ON PAPER ONLY. It is type-only, so it is\n * erased before anything runs, and `HaRuleProps` stays public in the file declaring the resource.\n */\nimport type { HaRuleProps } from './ha-rule.ts';\nimport { csv } from './values.ts';\n\n/**\n * A `<node>[:<pri>]` list, spelled the way PVE gives it back.\n *\n * ⛔ THIS IS NOT `csv`, AND THE DIFFERENCE IS A FOREVER-DIFF. MEASURED by reading\n * `/usr/share/perl5/PVE/HA/Rules/NodeAffinity.pm` on n2 (2026-09-13): `decode_plugin_value`\n * turns the list into a HASH keyed by node name, and `encode_plugin_value` rebuilds it with\n * `for my $node (sort keys %$value)` — sorted by NODE NAME, never by the token — emitting the\n * bare name whenever the priority is falsy, because `PVE::HA::Tools::parse_node_priority` reads\n * a missing priority as 0. So a declared `n3:1,n2:0` is handed back as `n2,n3:1`: re-ordered AND\n * re-spelled. Compare the raw strings and every plan reports an update, forever.\n *\n * ⚠️ SORTED BY NAME, NOT BY TOKEN, AND THE TWO GENUINELY DIVERGE. `csv` sorts whole tokens. Node\n * names may contain `-` — `parse_node_priority`'s own regex is\n * `[a-zA-Z0-9]([a-zA-Z0-9\\-]*[a-zA-Z0-9])?` — and `-` (0x2D) sorts before `:` (0x3A), so `n2-a`\n * and `n2:5` come out in one order by token and the other by name. PVE sorts by the name, so\n * this does too.\n *\n * ⚠️ LAST ENTRY WINS FOR A REPEATED NODE, because PVE's decode is a hash assignment and a hash\n * keeps one value per key. A declaration saying `n2:1,n2:5` is stored as `n2:5`; matching that\n * is what a Map gives for free.\n */\nexport const nodeList = (value: readonly string[] | string | undefined) => {\n const ranked = new Map<string, number>();\n for (const entry of typeof value === 'string' ? value.split(',') : (value ?? [])) {\n const [node, priority] = entry.trim().split(':');\n if (node === undefined || node === '') continue;\n const rank = Number.parseInt(priority ?? '0', 10);\n ranked.set(node, Number.isNaN(rank) ? 0 : rank);\n }\n return [...ranked.keys()]\n .sort()\n .map((node) => {\n const rank = ranked.get(node) ?? 0;\n return rank === 0 ? node : `${node}:${String(rank)}`;\n })\n .join(',');\n};\n\n/**\n * PVE's own verdict on whether the rule can be satisfied, flattened to one reportable string.\n *\n * ⚠️ COMPUTED, NEVER DECLARED, AND NEVER COMPARED. `PVE::API2::HA::Rules` runs `check_feasibility`\n * over the WHOLE rule set on every read and attaches whatever it finds to each rule as\n * `errors => { <option> => \"<message>, <message>\" }`. It therefore changes when somebody else's\n * rule changes, and none of it is a parameter any write accepts. It belongs in attributes so a\n * plan can show that PVE considers this rule unsatisfiable, and nowhere near `matches`.\n */\nexport const problems = (value: unknown) =>\n typeof value === 'object' && value !== null\n ? Object.entries(value)\n .map(([option, message]) => `${option}: ${String(message)}`)\n .sort()\n .join('; ')\n : '';\n\n/**\n * A comment as PVE will actually STORE it, which is not always the string it was handed.\n *\n * ⛔ PVE DECODES `%XX` OUT OF EVERY COMMENT ON THE WAY IN AND NEVER PUTS IT BACK. MEASURED:\n * `PVE::SectionConfig::check_config` runs `decode_value` over each submitted field (line 1625 on\n * this node), the base rule plugin's `decode_value` sends `comment` through\n * `PVE::ParseUtils::decode_text` — `uri_unescape` then a utf8 decode — and `$get_api_ha_rule`\n * hands the comment straight back WITHOUT re-encoding it (only `resources` and `nodes` are\n * re-encoded there). So a declared `deploy%20window` is stored and returned as `deploy window`,\n * and a `matches` comparing the declared string would report an update on every plan forever\n * while every PUT wrote exactly what was already there.\n *\n * ★ SO THE COMPARISON MIRRORS THE DECODE RATHER THAN FIGHTING IT. Both sides then say what the\n * cluster will really hold, which is the same move `nodeList` above makes for a re-sorted list.\n * ⚠️ GROUPS OF `%XX` ARE DECODED TOGETHER so a multi-byte utf8 sequence survives; a lone `%` or a\n * malformed sequence is left alone, as `uri_unescape` leaves it. The one place this differs from\n * Perl is a sequence that is valid percent-encoding but invalid utf8: Perl substitutes U+FFFD,\n * this leaves the escape. Nothing in a comment should be reaching for that.\n */\nexport const commentText = (raw: string) =>\n raw.replace(/(?:%[0-9a-fA-F]{2})+/g, (escaped) => {\n try {\n return decodeURIComponent(escaped);\n } catch {\n return escaped;\n }\n });\n\n/**\n * Every managed optional, per type: the value to send, or undefined for \"clear it\".\n *\n * ⛔ `disable=0` DOES NOT CLEAR A DISABLED RULE, AND THAT IS THE WORST TRAP IN THIS FAMILY.\n * MEASURED in `/usr/share/perl5/PVE/API2/HA/Rules.pm`: both `create_rule` and `update_rule` run\n * `delete $param->{disable} if !$param->{disable};` BEFORE the plugin sees the form. A PUT\n * carrying `disable=0` is therefore a PUT carrying nothing — PVE answers 200, the rule stays\n * disabled, `matches` reports an update on the next plan, and the loop never settles. The only\n * way back on is `delete=disable`, which is why `disable` is in this table rather than in\n * `required` below.\n *\n * ⛔ AND THE BRANCHES CANNOT BE ONE SHARED MAP. `PVE::SectionConfig::delete_from_config` dies\n * `no such option '<k>'` for an option the plugin does not declare and `unable to delete\n * required option '<k>'` for one it requires — so `delete=strict` against a resource-affinity\n * rule is a hard failure, and `delete=nodes` or `delete=resources` would be one against either.\n * Only `comment`, `disable` and (node-affinity only) `strict` are clearable at all.\n *\n * ⚠️ AN EMPTY `comment` IS A CLEARED ONE. PVE stores whatever string it is given, so writing `''`\n * would leave the option present and empty rather than absent; `matches` reads both as `''`, but\n * only the delete actually removes the line.\n */\nexport const optional = (props: HaRuleProps): Record<string, string | undefined> => ({\n comment: props.comment === undefined || props.comment === '' ? undefined : props.comment,\n disable: props.disable === true ? '1' : undefined,\n ...(props.type === 'node-affinity' ? { strict: props.strict === true ? '1' : undefined } : {}),\n});\n\n/**\n * The fields sent on EVERY write, create and update alike.\n *\n * ⛔ `type` GOES OUT ON THE UPDATE TOO, AND LEAVING IT OFF BREAKS EVERY PUT. It reads like a\n * create-only discriminant — the handler certainly treats it as one, taking the plugin from the\n * STORED rule — but the PUT is still validated against a `oneOf` keyed on it. MEASURED in\n * `PVE::JSONSchema::check_one_of` on this node: when the type property is absent the validator\n * marks EVERY other key unknown and, unless the whole `oneOf` is itself optional, errors on the\n * type property; its own comment says \"Its type property is otherwise never optional\", and\n * `SectionConfig::updateSchema` builds that `oneOf` through `combine_schemas` without an\n * `optional` flag. So an update that omitted it would fail parameter verification with a pile of\n * \"unexpected property\" errors pointing at the fields it did send. It is safe to send because a\n * rule of the other type is reported ABSENT by `attributes` and never reaches a PUT.\n *\n * ⚠️ `affinity` IS SENT UNCONDITIONALLY FOR BOTH TYPES. PVE requires it on a resource-affinity\n * create and defaults it to `positive` on a node-affinity one; sending it either way means the\n * read-back matches on the first plan after the create rather than relying on PVE materialising\n * its own default into the file.\n *\n * ⚠️ THE LISTS GO OUT IN THEIR NORMALISED FORM, which is not required but is free: PVE re-sorts\n * them anyway, so writing what it will hand back keeps the config file readable next to the\n * declaration that produced it.\n *\n * ⚠️ NO `digest`. PVE accepts one on PUT as an optimistic lock, but the only digest this provider\n * could send is the one from its own read moments earlier — and it is a digest of the WHOLE\n * rules file, so any unrelated rule written in between would turn a correct update into a\n * spurious failure. The factory's read-back guard is the check that stays.\n */\nconst required = (props: HaRuleProps): Record<string, string> => ({\n affinity: props.affinity,\n resources: csv(props.resources),\n type: props.type,\n ...(props.type === 'node-affinity' ? { nodes: nodeList(props.nodes) } : {}),\n});\n\nexport const body = (props: HaRuleProps) => {\n const fields = required(props);\n for (const [option, value] of Object.entries(optional(props))) {\n if (value !== undefined) fields[option] = value;\n }\n return fields;\n};\n\n/**\n * The options an update must explicitly remove.\n *\n * ⛔ A PUT THAT OMITS A FIELD DOES NOT CLEAR IT — `update_rule` merges the form into the stored\n * rule (`$rule->{$_} = $opts->{$_} for keys $opts->%*`) — so a managed optional needs a matching\n * `delete=` the moment its prop goes away. Both halves come off the one table above, which makes\n * \"managed but not clearable\" impossible to write here.\n * ⚠️ NEVER BOTH AT ONCE: `delete_from_config` dies `cannot set and delete property '<k>' at the\n * same time!`. The table answers a value or `undefined`, never both, so the two lists are\n * disjoint by construction.\n * ⚠️ THE CREATE FORM CANNOT USE THIS. `POST /cluster/ha/rules` has no `delete` parameter at all\n * (MEASURED from the cluster's own schema), and it needs none: an omitted optional on a brand\n * new rule is simply absent.\n */\nexport const clearList = (props: HaRuleProps) =>\n Object.entries(optional(props))\n .filter(([, value]) => value === undefined)\n .map(([option]) => option);\n",
32
+ "/**\n * `Proxmox.Lxc` — a container, declared. This is what the estate's provision credential exists for.\n *\n * ★ `hf-provision@pve` HOLDS EXACTLY THE ROLE THIS NEEDS, and nothing more: `LXCProvisioner` on `/`\n * grants VM.Allocate, VM.Audit, VM.Config.{CPU,Disk,HWType,Memory,Network,Options},\n * VM.PowerMgmt, Datastore.AllocateSpace, Datastore.Audit, SDN.Use, Sys.Audit. Read that list as a\n * specification: the credential was scoped to provision containers and to do nothing else.\n *\n * ⛔ `vmid` IS THE PRIMARY KEY AND IT IS CLUSTER-WIDE, not per node. Two resources declaring the\n * same vmid on different nodes are the same object, and PVE will refuse the second with\n * \"already exists\". It is required rather than allocated here: letting the provider pick the next\n * free id would make the identity of a container depend on the order plans happened to run in.\n *\n * ⚠️ MOST FIELDS ARE CREATE-TIME. `ostemplate` and `storage` are consumed when the rootfs is built\n * and are not readable back afterwards, so they are deliberately NOT compared in `matches` --\n * a provider that diffed them would report an update on every plan, forever. What is compared is\n * what PVE will actually tell you about a running container.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { num } from './values.ts';\n\nexport interface LxcProps extends WithTarget {\n /** Which node hosts it. Moving a container between nodes is a migration, not an update. */\n node: string;\n /** ⛔ CLUSTER-WIDE primary key. Required, never auto-allocated — see the ⛔ above. */\n vmid: number;\n /** e.g. `local:vztmpl/debian-13-standard_13.0-1_amd64.tar.zst`. Create-time only. */\n ostemplate: string;\n /** Storage for the rootfs, e.g. `local-zfs`. Create-time only. */\n storage: string;\n hostname?: string;\n /** MiB. Mutable. */\n memory?: number;\n cores?: number;\n /** e.g. `name=eth0,bridge=vmbr0,ip=dhcp`. Mutable. */\n net0?: string;\n /** Start on boot. Mutable. */\n onboot?: boolean;\n}\n\nexport interface LxcAttributes {\n vmid: number;\n node: string;\n hostname: string;\n memory: number;\n cores: number;\n onboot: boolean;\n /** `running` | `stopped`. Reported, never declared — power state is not configuration. */\n status: string;\n}\n\nexport interface ProxmoxLxc extends Resource<\n 'Proxmox.Lxc',\n LxcProps,\n LxcAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxLxc = Resource<ProxmoxLxc>('Proxmox.Lxc');\n\nconst handlers = pveHandlers<LxcProps, LxcAttributes>({\n /**\n * ⚠️ READ FROM `config`, NOT FROM THE GUEST LIST. `GET /nodes/{n}/lxc` reports runtime shape\n * (status, uptime, current memory), while `/config` reports DECLARED shape. Diffing against\n * runtime memory would report an update every time a container ballooned.\n */\n attributes: (live, props) => ({\n cores: num(live['cores'], 1),\n hostname: typeof live['hostname'] === 'string' ? live['hostname'] : '',\n memory: num(live['memory'], 512),\n node: props.node,\n onboot: live['onboot'] === 1 || live['onboot'] === true,\n status: typeof live['status'] === 'string' ? live['status'] : 'unknown',\n vmid: props.vmid,\n }),\n collection: (props) => `nodes/${props.node}/lxc`,\n createForm: (props) => ({\n cores: String(props.cores ?? 1),\n hostname: props.hostname ?? `ct${String(props.vmid)}`,\n memory: String(props.memory ?? 512),\n onboot: props.onboot === true ? '1' : '0',\n ostemplate: props.ostemplate,\n storage: props.storage,\n vmid: String(props.vmid),\n ...(props.net0 === undefined ? {} : { net0: props.net0 }),\n }),\n matches: (attributes, props) =>\n attributes.hostname === (props.hostname ?? `ct${String(props.vmid)}`) &&\n attributes.memory === (props.memory ?? 512) &&\n attributes.cores === (props.cores ?? 1) &&\n attributes.onboot === (props.onboot === true),\n path: (props) => `nodes/${props.node}/lxc/${String(props.vmid)}/config`,\n /**\n * ⚠️ PVE UPDATES A CONTAINER THROUGH `PUT .../config`, THE SAME PATH IT IS READ FROM, which is\n * why `path` ends in `/config` while `collection` does not. Create POSTs to the collection;\n * read and update both use the config document.\n */\n updateForm: (props) => ({\n cores: String(props.cores ?? 1),\n hostname: props.hostname ?? `ct${String(props.vmid)}`,\n memory: String(props.memory ?? 512),\n onboot: props.onboot === true ? '1' : '0',\n ...(props.net0 === undefined ? {} : { net0: props.net0 }),\n }),\n});\n\n/**\n * ⛔ PVE REFUSES TO DELETE A RUNNING CONTAINER, and that refusal is kept — `handlers.delete`\n * passes it straight through. Stopping a guest so that a `destroy` can proceed is a decision an\n * operator makes, not one a plan makes on their behalf while they are reading the diff.\n */\nexport const ProxmoxLxcProvider = () =>\n Provider.effect(ProxmoxLxc, Effect.succeed(ProxmoxLxc.Provider.of(handlers)));\n",
33
+ "/**\n * `Proxmox.MetricServer` — where the cluster ships its metrics, declared.\n *\n * ★ THE FAILURE THIS PREVENTS IS A SILENT ONE, WHICH IS THE WHOLE ARGUMENT FOR DECLARING IT.\n * Undeclared, the target exists only as a section of `/etc/pve/status.cfg`: rebuild a node,\n * re-add one to the cluster, or restore a config from before it was configured, and the cluster\n * stops shipping. Nothing fails, no task errors, no alert fires — the graphs go flat, and the\n * first to find out is whoever went looking for a number that was not there.\n *\n * ⛔ CREATE IS `POST cluster/metrics/server/{id}` — THE OBJECT'S OWN PATH — SO `collection()`\n * RETURNS THE SAME STRING AS `path()`, AND THAT IS NOT A TYPO. MEASURED: a POST to the\n * collection answers \"Method 'POST /cluster/metrics/server' not implemented\", while the id path\n * gets as far as a permission check (`/`, Sys.Modify); the published schema agrees, giving the\n * collection a GET and nothing else. `createForm` omits `id` for the same reason — it is already\n * the last segment of the path being POSTed to, and a second copy can only disagree with it.\n *\n * ⛔ THE `token` IS WRITE-ONLY AND MUST NEVER BECOME AN ATTRIBUTE. Alchemy persists attributes\n * UNENCRYPTED, so one that reached state would outlive the change that set it, in the state\n * store and in every backup of it. It is `never` in the props below — declaring one is a COMPILE\n * ERROR rather than a leak found months later — and absent from `optional`, for the reason\n * given there. Set it out of band; PVE never returns it on a read anyway. `otel-headers`, where an\n * opentelemetry server's bearer token lives, gets the same treatment in metric-server-otel.ts.\n *\n * ⚠️ PRIVILEGES, AND THIS IS A BIGGER ASK THAN IT LOOKS. Read and diff are fine under an auditor\n * lease — the single-object GET checks `Sys.Audit` on `/` — while create, update and delete all\n * check `Sys.Modify` on `/` and answer \"Permission check failed (/, Sys.Modify)\" until the role\n * is widened. Widen it knowingly: the ACL path is the ROOT and there is no `/metrics` object to\n * scope to, so `Sys.Modify` also buys datacenter options, notification targets and every other\n * cluster-wide config write. A separate role for metric writes is the narrower answer.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { UNSET, body, update } from './metric-server-form.ts';\nimport {\n type MetricServerOtelAttributes,\n type MetricServerOtelProps,\n otelAttributes,\n otelMatches,\n} from './metric-server-otel.ts';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { bool, int, text } from './values.ts';\n\n/**\n * PVE's status plugins. Which one a server is decides which fields it will even accept.\n *\n * ★ `opentelemetry` IS OFFERED SINCE 2026-09-14, AND THE REASON IT WAS NOT STILL HOLDS FOR ANY FIELD\n * LEFT OUT. Its whole configuration is the `otel-*` family; declared without managing that family\n * it would build a target whose every meaningful setting sat outside the graph, and report `noop`\n * over it. metric-server-otel.ts manages every `otel-*` field but two, and says why for each.\n */\nexport type MetricServerType = 'graphite' | 'influxdb' | 'opentelemetry';\n\nexport interface MetricServerProps extends WithTarget, MetricServerOtelProps {\n /** ⚠️ A `pve-configid` — a letter, then letters, digits, `-` and `_`. A rejected one fails with\n * \"invalid configuration ID\", which reads as a broken request rather than as a naming rule. */\n id: string;\n /**\n * ⛔ CREATE-TIME ONLY. The PUT schema has no `type` parameter at all: a section's type is fixed\n * when it is written, so the ⛔ in `attributes` turns a changed type into a refusal rather than\n * a silent no-op over the wrong target.\n */\n type: MetricServerType;\n /** ⚠️ REQUIRED ON EVERY WRITE, UPDATE INCLUDED — see `required`. */\n server: string;\n port: number;\n /** Keep the section but stop shipping. Unset is an ENABLED target, not an absent one. */\n disable?: boolean;\n /**\n * graphite and influxdb only: UDP MTU (512-65536) and socket/HTTP timeout. Unset leaves PVE's\n * defaults, 1500 and 1. ⚠️ opentelemetry has neither; its timeout is `otel-timeout`.\n */\n mtu?: number;\n timeout?: number;\n /** graphite only: the root path metrics are published under, e.g. `proxmox.mycluster`. */\n path?: string;\n /**\n * influxdb only. `udp` is PVE's default and writes line protocol; `http`/`https` use the v2 API,\n * the only place `organization` and `bucket` mean anything. An unset `verify-certificate` means\n * VERIFY — PVE's default, and the safe one.\n * ⚠️ PVE's hyphenated names are kept rather than camelCased, so nothing between here and the form\n * body has to remember a mapping.\n */\n influxdbproto?: 'udp' | 'http' | 'https';\n organization?: string;\n bucket?: string;\n 'api-path-prefix'?: string;\n 'max-body-size'?: number;\n 'verify-certificate'?: boolean;\n /** ⛔ `never` ON PURPOSE — see the ⛔ in the header. The compile error is the feature. */\n token?: never;\n}\n\n/**\n * ⛔ NO `digest`, ON PURPOSE. PVE returns one with every read, but it is the digest of the WHOLE\n * `status.cfg` rather than of this section — declaring a SECOND metric server would rewrite this\n * one's stored attributes, and comparing it would report an update on a target nobody touched.\n * ⛔ And no `token`, for the reason the header gives at length.\n * ⚠️ `mtu`, `timeout` and `max-body-size` report `UNSET` when the section carries none, i.e. when\n * PVE's own default is what the target will use; `verify-certificate` reports that default\n * directly, because \"absent\" there means the target verifies. `port` reports 0 only for a\n * malformed section — PVE requires a port — so a plan should say so loudly. The `otel-*` half\n * follows the same rules; see metric-server-otel.ts.\n */\nexport interface MetricServerAttributes extends MetricServerOtelAttributes {\n id: string;\n type: MetricServerType;\n server: string;\n port: number;\n disable: boolean;\n mtu: number;\n timeout: number;\n path: string;\n influxdbproto: string;\n organization: string;\n bucket: string;\n 'api-path-prefix': string;\n 'max-body-size': number;\n 'verify-certificate': boolean;\n}\n\nexport interface ProxmoxMetricServer extends Resource<\n 'Proxmox.MetricServer',\n MetricServerProps,\n MetricServerAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxMetricServer = Resource<ProxmoxMetricServer>('Proxmox.MetricServer');\n\n/**\n * The type-specific half of `matches`.\n *\n * ⛔ ONLY FIELDS THIS TYPE ACTUALLY SENDS ARE COMPARED. `verify-certificate` is not in graphite's\n * option set and `path` is not in influxdb's, so neither is ever sent to the wrong plugin — and\n * diffing one anyway would report an update that the PUT it triggers cannot satisfy, forever.\n * `mtu` and `timeout` are compared for graphite and influxdb only, because the opentelemetry\n * plugin has neither and `optional` never sends them to it.\n */\nconst matchesType = (attributes: MetricServerAttributes, props: MetricServerProps): boolean => {\n if (props.type === 'opentelemetry') return otelMatches(attributes, props);\n const socket =\n attributes.mtu === (props.mtu ?? UNSET) && attributes.timeout === (props.timeout ?? UNSET);\n if (props.type === 'graphite') return socket && attributes.path === (props.path ?? '');\n return (\n socket &&\n attributes.influxdbproto === (props.influxdbproto ?? '') &&\n attributes.organization === (props.organization ?? '') &&\n attributes.bucket === (props.bucket ?? '') &&\n attributes['api-path-prefix'] === (props['api-path-prefix'] ?? '') &&\n attributes['max-body-size'] === (props['max-body-size'] ?? UNSET) &&\n attributes['verify-certificate'] === (props['verify-certificate'] !== false)\n );\n};\n\nconst handlers = pveHandlers<MetricServerProps, MetricServerAttributes>({\n attributes: (live, props) => {\n /**\n * ⛔ A SERVER OF ANOTHER TYPE IS ANOTHER OBJECT, AND \"ABSENT\" IS THE HONEST ANSWER. `type`\n * cannot be changed by a PUT, so reporting the foreign section as missing makes reconcile\n * POST instead and PVE refuses because the id is taken — a loud, accurate error rather than a\n * PUT pushing influxdb fields at a graphite section. An older PVE that omits `type` from the\n * read falls through and is trusted.\n */\n const liveType = text(live['type']);\n if (liveType !== '' && liveType !== props.type) return undefined;\n return {\n ...otelAttributes(live),\n 'api-path-prefix': text(live['api-path-prefix']),\n bucket: text(live['bucket']),\n disable: bool(live['disable'], false),\n id: props.id,\n influxdbproto: text(live['influxdbproto']),\n 'max-body-size': int(live['max-body-size'], UNSET),\n mtu: int(live['mtu'], UNSET),\n organization: text(live['organization']),\n path: text(live['path']),\n port: int(live['port'], 0),\n server: text(live['server']),\n timeout: int(live['timeout'], UNSET),\n type: props.type,\n 'verify-certificate': bool(live['verify-certificate'], true),\n };\n },\n /** ⛔ THE SAME STRING AS `path`, DELIBERATELY — see the ⛔ in the header. */\n collection: (props) => `cluster/metrics/server/${props.id}`,\n /** ⚠️ `type` IS REQUIRED ON CREATE; `id` IS NOT SENT, because the id is the path. */\n createForm: (props) => ({ ...body(props), type: props.type }),\n /**\n * ⛔ `id` and `type` are absent: one is the key the object was read by, the other is refused\n * rather than updated. Everything type-specific is `matchesType`'s, above.\n */\n matches: (attributes, props) =>\n attributes.server === props.server &&\n attributes.port === props.port &&\n attributes.disable === (props.disable === true) &&\n matchesType(attributes, props),\n path: (props) => `cluster/metrics/server/${props.id}`,\n /** The form and its clear-list, from the one table in metric-server-form.ts. */\n updateForm: update,\n});\n\n/**\n * ⛔ THE EMPTY `list` FROM `pveHandlers` EARNS ITS KEEP HERE. `GET cluster/metrics/server` answers\n * with every target the cluster already ships to, including the one somebody configured by hand\n * years ago; adopting that is how a later `alchemy destroy` silences a graph nobody declared.\n * ⚠️ AND NOTHING BRAKES THIS DESTROY. A pool refuses while it holds guests, a container while it\n * runs; a metric server just leaves `status.cfg`, the cluster stops shipping on the next\n * interval, and no guest or task is affected. The plan diff is the only warning anyone gets —\n * the top of this file again, this time caused by a deploy.\n */\nexport const ProxmoxMetricServerProvider = () =>\n Provider.effect(ProxmoxMetricServer, Effect.succeed(ProxmoxMetricServer.Provider.of(handlers)));\n",
34
+ "/**\n * A metric server's props, as the form PVE wants.\n *\n * ★ SPLIT OUT OF metric-server.ts TO KEEP BOTH FILES UNDER THE 250-LINE CAP, and the seam is a\n * real one rather than a convenient line number: this file answers \"how does a declaration\n * become a PVE form\", and metric-server.ts answers \"what is a metric server and when has it\n * changed\". Nothing here reads the cluster and nothing here decides a diff.\n *\n * ⚠️ THE `import type` BACK TO metric-server.ts IS A CYCLE ON PAPER ONLY. It is type-only, so it\n * is erased before anything runs — `MetricServerProps` stays the resource's public shape, in the\n * file that declares the resource, rather than being moved somewhere odd to dodge the arrow.\n * metric-server-otel.ts imports `UNSET` from here and this file imports nothing back from it,\n * so no runtime cycle exists either.\n */\nimport type { MetricServerProps } from './metric-server.ts';\nimport { withClears } from './values.ts';\n\n/**\n * ⚠️ \"NOT SET\" CANNOT BE 0 HERE, WHICH IS WHY IT IS -1. `timeout` has a minimum of 0 in PVE's\n * schema, so a deliberate `timeout 0` exists; a provider using 0 as its absent-marker reads that\n * zero as \"unset\" and never clears it. -1 is outside every one of these fields' ranges.\n */\nexport const UNSET = -1;\n\nconst str = (value: number | undefined) => (value === undefined ? undefined : String(value));\n\n/**\n * Every managed optional, per type: the value to send, or undefined for \"clear it\".\n *\n * ⛔ ONE TABLE FEEDS BOTH HALVES OF AN UPDATE, AND THAT IS THE POINT. A PUT THAT OMITS A FIELD DOES\n * NOT CLEAR IT — PVE merges the form into the existing section — so a managed optional needs a\n * matching `delete=` the moment its prop goes away, or `matches` reports an update on every plan\n * forever. Deriving the form and the delete list from one map makes \"managed but not clearable\"\n * impossible to write here, which a separate clear-list would not.\n * ⛔ NOTHING SET OUT OF BAND MAY BE LISTED HERE, `token` FIRST AMONG THEM: a field in this map is\n * CLEARED whenever it is undeclared, so adding the token would strip a working target's\n * credential on the next plan — metrics stop, nothing errors, the graph goes flat. `otel-headers`\n * is absent for the same reason: it is where an OTLP server's bearer token lives.\n * ⚠️ AND THE BRANCHES CANNOT BE ONE SHARED MAP. PVE validates a section against that plugin's own\n * option set, so `path` on an influxdb server is a hard 400 and `delete=path` there answers \"no\n * such option\" — neither is an ignored hint. The opentelemetry plugin has no `mtu` and no\n * `timeout` at all (its option list is `server`, `port`, `disable` and the `otel-*` family), so\n * that branch carries neither.\n * ⚠️ graphite's `proto` (udp or tcp) is deliberately absent: a transport chosen by hand stays put\n * and no plan diffs it. Managing it means adding it HERE, where it is clearable by construction.\n * `otel-resource-attributes` is absent for the reason metric-server-otel.ts gives.\n */\nexport const optional = (props: MetricServerProps): Record<string, string | undefined> => {\n switch (props.type) {\n case 'graphite':\n return { mtu: str(props.mtu), path: props.path, timeout: str(props.timeout) };\n case 'influxdb':\n return {\n 'api-path-prefix': props['api-path-prefix'],\n bucket: props.bucket,\n influxdbproto: props.influxdbproto,\n 'max-body-size': str(props['max-body-size']),\n mtu: str(props.mtu),\n organization: props.organization,\n timeout: str(props.timeout),\n };\n case 'opentelemetry':\n return {\n 'otel-compression': props['otel-compression'],\n 'otel-max-body-size': str(props['otel-max-body-size']),\n 'otel-path': props['otel-path'],\n 'otel-protocol': props['otel-protocol'],\n 'otel-timeout': str(props['otel-timeout']),\n };\n }\n};\n\n/**\n * The certificate-verification flag, for the one plugin that owns it.\n *\n * ⛔ EACH FLAG GOES ONLY TO ITS OWN PLUGIN. `verify-certificate` is influxdb's, `otel-verify-ssl` is\n * opentelemetry's, graphite has neither — and PVE refuses an option outside the section's plugin\n * rather than ignoring it, the same way it refuses `path` on influxdb.\n */\nconst verification = (props: MetricServerProps): Record<string, string> => {\n switch (props.type) {\n case 'graphite':\n return {};\n case 'influxdb':\n return { 'verify-certificate': props['verify-certificate'] === false ? '0' : '1' };\n case 'opentelemetry':\n return { 'otel-verify-ssl': props['otel-verify-ssl'] === false ? '0' : '1' };\n }\n};\n\n/**\n * The fields sent on EVERY write, create and update alike.\n *\n * ⚠️ `server` AND `port` ARE REQUIRED BY THE PUT TOO, not only by the POST: a PUT that omits either\n * fails parameter verification rather than leaving them alone. PVE also refuses to clear them —\n * \"unable to delete required option\" — which is why they are here and not in `optional`.\n * ⚠️ `disable` AND THE VERIFY FLAG ARE SENT WITH THEIR DEFAULTS rather than left out. Writing the\n * value PVE would have assumed makes the read-back match on the first plan after the create,\n * whether or not that PVE materialises defaults into the file.\n */\nconst required = (props: MetricServerProps): Record<string, string> => ({\n disable: props.disable === true ? '1' : '0',\n port: String(props.port),\n server: props.server,\n ...verification(props),\n});\n\nexport const body = (props: MetricServerProps) => {\n const fields = required(props);\n for (const [option, value] of Object.entries(optional(props))) {\n if (value !== undefined) fields[option] = value;\n }\n return fields;\n};\n\n/**\n * An update's form: everything `body` sends, plus a `delete=` naming each managed optional that is\n * no longer declared.\n *\n * ★ MOVED HERE FROM metric-server.ts UNCHANGED, so the test beside this file can reach the form an\n * update really sends instead of re-deriving it and testing its own copy.\n */\nexport const update = (props: MetricServerProps) => {\n const clear = Object.entries(optional(props))\n .filter(([, value]) => value === undefined)\n .map(([option]) => option);\n return withClears(body(props), clear);\n};\n",
35
+ "/**\n * The `opentelemetry` plugin's option set: what a metric server of that type accepts, how it reads\n * back, and when it has changed.\n *\n * ★ SPLIT OUT OF metric-server.ts TO KEEP IT UNDER THE 250-LINE CAP, AND THE SEAM IS THE PLUGIN.\n * PVE validates a section against ONE plugin's option set, so these fields mean nothing to a\n * graphite or influxdb section and theirs mean nothing here. This file answers \"what is an OTLP\n * metric server\"; metric-server-form.ts still builds every form, so the clear-list keeps coming\n * from the one table that also builds the body.\n *\n * ⛔ PVE'S OTLP EXPORTER SPEAKS JSON AND NOTHING ELSE. `PVE::Status::OpenTelemetry::send` sets\n * `Content-Type: application/json` (pve-manager PVE/Status/OpenTelemetry.pm:643) and gzips by\n * default; there is no protobuf option. vector's opentelemetry source and VictoriaMetrics both\n * take protobuf only — measured 2026-09-14 — so a server pointed straight at either fails every\n * push. That is why TB4's declaration points at each node's own vector bridge\n * (hosts/pve/vector/vector.yaml in homeflare-config) rather than at the estate's intake.\n *\n * ⛔ `otel-headers` IS `never`, FOR THE REASON `token` IS. It is where an OTLP bearer token goes —\n * base64 of a JSON object of arbitrary HTTP headers — and Alchemy persists attributes UNENCRYPTED.\n * It is also absent from `optional` in metric-server-form.ts, so an undeclared one is never\n * cleared off a working target on the next plan.\n *\n * ⚠️ `otel-resource-attributes` IS NOT MANAGED AT ALL: not a prop, not read, not compared, not\n * cleared. It is base64 of a JSON object whose key order nothing canonicalises, so comparing it\n * means decoding both sides — work with no consumer yet, since nothing sets it and PVE already\n * stamps `service.name`, `proxmox.cluster` and `proxmox.node` on every request\n * (`_build_otlp_metrics`, lines 207-228). A hand-set one therefore survives every plan and never\n * shows as drift. The day one matters, it goes into `optional` and here together.\n */\nimport { UNSET } from './metric-server-form.ts';\nimport { bool, int, text } from './values.ts';\n\nexport interface MetricServerOtelProps {\n /**\n * ⚠️ PVE'S DEFAULT IS `https`. `http` is for a receiver on the node itself, where the plaintext\n * never leaves the host; anything further away belongs on `https`.\n */\n 'otel-protocol'?: 'http' | 'https';\n /** Unset is PVE's `/v1/metrics`. */\n 'otel-path'?: string;\n /** Unset is PVE's `gzip`, sent as `Content-Encoding: gzip`. */\n 'otel-compression'?: 'none' | 'gzip';\n /**\n * Per-request HTTP timeout, 1-10 seconds; unset is PVE's 5.\n * ⚠️ pvestatd WAITS THIS LONG, PER REQUEST, AGAINST A RECEIVER THAT HANGS — the send is inline in\n * its update loop (`send`, line 635) — so this is also how long a broken receiver can stretch\n * one status cycle.\n */\n 'otel-timeout'?: number;\n /** Minimum 1024; unset is PVE's 10000000. pvestatd splits one flush into requests under it. */\n 'otel-max-body-size'?: number;\n /** ⚠️ An unset `otel-verify-ssl` means VERIFY — PVE's default, and the safe one. */\n 'otel-verify-ssl'?: boolean;\n /** ⛔ `never` ON PURPOSE — see the ⛔ in the header. The compile error is the feature. */\n 'otel-headers'?: never;\n}\n\n/**\n * ⚠️ THE SAME RULES AS THE REST OF `MetricServerAttributes`. The strings report `''` when the\n * section carries none — PVE's default is then what the target uses — the numbers report `UNSET`\n * for the same reason, and `otel-verify-ssl` reports its default directly, because \"absent\"\n * there means the target verifies.\n */\nexport interface MetricServerOtelAttributes {\n 'otel-compression': string;\n 'otel-max-body-size': number;\n 'otel-path': string;\n 'otel-protocol': string;\n 'otel-timeout': number;\n 'otel-verify-ssl': boolean;\n}\n\n/** The `otel-*` half of a live section. Read for every type; compared only for this one. */\nexport const otelAttributes = (live: Record<string, unknown>): MetricServerOtelAttributes => ({\n 'otel-compression': text(live['otel-compression']),\n 'otel-max-body-size': int(live['otel-max-body-size'], UNSET),\n 'otel-path': text(live['otel-path']),\n 'otel-protocol': text(live['otel-protocol']),\n 'otel-timeout': int(live['otel-timeout'], UNSET),\n 'otel-verify-ssl': bool(live['otel-verify-ssl'], true),\n});\n\n/**\n * True when every managed `otel-*` field already says what the declaration says.\n *\n * ⛔ EVERY FIELD `optional` SENDS OR CLEARS IS COMPARED HERE, AND NOTHING ELSE IS. A field sent but\n * not compared is drift a plan can never show; a field compared but not sent is an update the\n * PUT it triggers can never satisfy, reported forever.\n */\nexport const otelMatches = (\n attributes: MetricServerOtelAttributes,\n props: MetricServerOtelProps,\n): boolean =>\n attributes['otel-compression'] === (props['otel-compression'] ?? '') &&\n attributes['otel-max-body-size'] === (props['otel-max-body-size'] ?? UNSET) &&\n attributes['otel-path'] === (props['otel-path'] ?? '') &&\n attributes['otel-protocol'] === (props['otel-protocol'] ?? '') &&\n attributes['otel-timeout'] === (props['otel-timeout'] ?? UNSET) &&\n attributes['otel-verify-ssl'] === (props['otel-verify-ssl'] !== false);\n",
36
+ "/**\n * `Proxmox.NetworkApply` — the call that makes a declared interfaces file real, ON ONE NODE.\n *\n * ⛔ WITHOUT IT EVERY NETWORK DECLARATION IS A GREEN PLAN THAT CHANGES NO NETWORK; WITH IT A GREEN\n * PLAN CAN TAKE A NODE OFF THE NETWORK. Writes under `nodes/{node}/network/{iface}` edit\n * `/etc/network/interfaces.new` and touch no interface. `PUT /nodes/{node}/network` is the apply.\n * MEASURED in the cluster's own source on n2, 2026-09-13 — `PVE/API2/Network.pm`:\n * rename($new_config_file, $current_config_file) if -e $new_config_file;\n * PVE::Tools::run_command(['ifreload', '-a'], errfunc => $err);\n * return $rpcenv->fork_worker('srvreload', 'networking', $authuser, $worker);\n *\n * ⛔ THIS IS THE MOST DANGEROUS RESOURCE IN THE PACKAGE, AND ON TB4 THE DANGER IS NOT ABSTRACT.\n * Ceph runs over `vmbr1.11` on n2, n3 AND n4 (MEASURED 2026-09-13: four pools, size 3 /\n * min_size 2, mon+mgr+mds on all three). `ifreload -a` takes that node's OSDs, mons and MDS off\n * the cluster network for the length of the reload; two nodes at once puts every pool below\n * min_size and blocks IO for every guest with an RBD disk. The management address the API is\n * reached on, `vmbr0.10`, is reloaded by the same call.\n *\n * ⛔ AND UNLIKE `SdnApply` IT IS PER NODE, SO A HALF-RECONFIGURED CLUSTER IS THE DEFAULT FAILURE\n * MODE, NOT AN EDGE CASE. `PUT /cluster/sdn` publishes the whole cluster in one call; this\n * publishes exactly one node, so a stack holding three of these can apply n2, fail, and leave n3\n * and n4 on the old layout with Ceph spanning all three. Four things here exist only for that:\n * 1. `after` SERIALISES THEM — chain n3 after n2 and n4 after n3, so at most one node is ever\n * mid-reload. Three declared in parallel is the outage, and nothing in Alchemy stops you.\n * 2. `reconcile` REFUSES TO START on a cluster that is already degraded.\n * 3. `reconcile` RE-CHECKS quorum and every member's `online` flag AFTER the reload and dies if\n * the cluster came back worse — which stops the chain before it reaches the second node.\n * 4. NOTHING IS EVER APPLIED WITH NOTHING STAGED. See the first branch of `apply`.\n *\n * ⚠️ IF THE MEMBER SERVING THE POLL IS THE NODE BEING RELOADED, the reload can drop the connection\n * carrying its own status poll — see network-apply-read.ts. Every endpoint is `proxyto =>\n * 'node'`, so any cluster member can serve any other node's paths; failover in client.ts picks\n * whichever member is up, not necessarily one you are not applying.\n *\n * ⚠️ `DELETE /nodes/{node}/network` IS THE REVERT, AND IT IS DELIBERATELY NOT WIRED TO `delete`.\n * MEASURED: the whole body of `revert_network_changes` is `unlink \"/etc/network/interfaces.new\"`.\n * It discards STAGED edits and cannot undo an APPLIED one, so pointing `delete` at it would throw\n * away whatever happened to be staged the moment somebody removed a line from a stack file — the\n * worst possible time to do it. Revert by hand, deliberately: `pvesh delete /nodes/<node>/network`.\n *\n * ⚠️ PRIVILEGES, so widening stays a deliberate act: the `read` role needs nothing for the pending\n * read (`GET /nodes/{node}/network` is `\"user\": \"all\"`) and `Sys.Audit` on `/` for the health\n * gate; the `provision` role needs `Sys.Modify` on `/nodes/{node}` for the apply, and owns the\n * task it starts so it can poll it without `Sys.Audit`. ⛔ `Sys.Modify` ON A NODE IS NOT A SMALL\n * GRANT — it also carries that node's DNS, hosts file, time and service configuration. Granting\n * it cluster-wide to run this resource widens the provisioning role well beyond networking.\n */\nimport { Resource } from 'alchemy';\nimport { isResolved } from 'alchemy/Diff';\nimport type { Input } from 'alchemy/Input';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { pveWith } from './client.ts';\nimport { mint } from './credentials.ts';\nimport { awaitTask, degradedReason, pendingCount } from './network-apply-read.ts';\nimport type { PveRequirements } from './resource.ts';\nimport type { WithTarget } from './resource.ts';\n\nexport interface NetworkApplyProps extends WithTarget {\n /**\n * The node whose staged interfaces file this applies — `n2`.\n *\n * ⚠️ ONE APPLY PER NODE, AND NEVER TWO FOR THE SAME NODE. Two would each publish the other's\n * staged half, and both would run `ifreload` on a file the other had not finished writing.\n */\n node: string;\n\n /**\n * The staged interface changes this apply publishes, and the apply that must go before it.\n *\n * ⚠️ IT IS NEVER READ, AND IT IS NOT DECORATION — the same contract as `SdnApply.after`. Alchemy\n * orders resources by DATA FLOW, so consuming an attribute is the only way to say \"after\".\n * Pass the interfaces this node declares AND the previous node's apply:\n * `after: [vmbr1.iface, n2Apply.pending]`. Leave the previous apply out and the three nodes\n * reload in parallel, which is the one thing this resource is built to prevent.\n */\n after?: readonly unknown[];\n}\n\nexport interface NetworkApplyAttributes {\n /** The node this applies. Identity, echoed so a plan line says which member it will reload. */\n node: string;\n\n /**\n * Changed lines still staged on this node.\n *\n * ⚠️ LINES OF A UNIFIED DIFF, NOT INTERFACES, and the number is reported rather than trusted —\n * `pendingLines` explains why it can undercount by one and never to zero. Zero is the only\n * settled value: anything above it means the running config and the staged config disagree,\n * whether this stack staged it or somebody edited the node in the UI and walked away.\n *\n * ⛔ THE DIFF ITSELF IS NEVER AN ATTRIBUTE. Alchemy writes attributes to its state store\n * UNENCRYPTED, and `/etc/network/interfaces` can carry a `wpa-psk` or a `pre-up` command. Only\n * the count leaves `network-apply-read.ts`.\n *\n * ⚠️ AND NOTHING OUT OF THE INTERFACE ROWS IS AN ATTRIBUTE EITHER, WHICH IS WHAT KEEPS THIS\n * FAMILY NOOP. `GET /nodes/{node}/network` returns eighteen fields it will not accept on write\n * — MEASURED by differencing the schema's GET return properties against its POST parameters:\n * `active`, `exists`, `families`, `method`, `method6`, `options`, `priority`, `link-type` and\n * ten more; `altnames` is returned and is not even in the schema. `priority` is the worst of\n * them: PVE ASSIGNS it from the order of the interfaces file, so the same logical layout\n * carries different numbers on different nodes (MEASURED: n4's differ from n2/n3's by one).\n * Every one of those is a forever-diff waiting for whoever writes `Proxmox.NetworkInterface`.\n * This resource compares a single integer against zero and never looks at a row at all.\n */\n pending: number;\n}\n\nexport interface ProxmoxNetworkApply extends Resource<\n 'Proxmox.NetworkApply',\n NetworkApplyProps,\n NetworkApplyAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxNetworkApply = Resource<ProxmoxNetworkApply>('Proxmox.NetworkApply');\n\nconst read = (props: NetworkApplyProps) =>\n pendingCount(props.target, props.node).pipe(\n Effect.map((pending) => ({ node: props.node, pending })),\n );\n\n/**\n * ⚠️ THE DIFF IS ABOUT THE NODE, NOT ABOUT THE PROPS — the same reasoning as `SdnApply`. This\n * resource has no settable field (`node` is identity, `after` is an ordering edge), so comparing\n * props to props would report `noop` forever and the apply would run exactly once, ever. What\n * decides it is whether the node is carrying a staged change right now.\n *\n * ★ THIS IS ALSO WHY DECLARING THE LIVE CLUSTER PLANS AS `noop`. VERIFIED 2026-09-13:\n * `/etc/network/interfaces.new` is absent on n2, n3 and n4, so `changes` is absent from all three\n * answers, so `pending` is 0 on all three and every one of them plans `noop`.\n */\nconst diff = (news: Input<NetworkApplyProps>) =>\n Effect.gen(function* () {\n if (!isResolved(news)) return undefined;\n const { pending } = yield* read(news);\n return pending === 0 ? ({ action: 'noop' } as const) : ({ action: 'update' } as const);\n });\n\n/** Stop the deploy, loudly, with the node in the message. ⚠️ A die here is the SAFE outcome. */\nconst refuse = (node: string, why: string) =>\n Effect.die(new Error(`Proxmox.NetworkApply ${node}: ${why}`));\n\nconst apply = (props: NetworkApplyProps) =>\n Effect.gen(function* () {\n const node = props.node;\n const staged = yield* pendingCount(props.target, node);\n /**\n * ⛔ NOTHING STAGED MEANS NOTHING TO APPLY, AND THIS BRANCH IS A SAFETY PROPERTY RATHER THAN AN\n * OPTIMISATION. `reconcile` also runs on CREATE — the first time this resource appears in a\n * stack, before `diff` has ever been consulted — and the PVE worker runs `ifreload -a`\n * UNCONDITIONALLY, staged file or not. Without this branch, adding `Proxmox.NetworkApply` to\n * a stack describing the cluster as it already is would reload networking on every node it\n * names, for nothing. Adoption must cost nothing; that is true here in the strongest sense.\n */\n if (staged === 0) return { node, pending: 0 };\n\n const before = yield* degradedReason(props.target);\n if (before !== undefined) {\n return yield* refuse(\n node,\n `refusing to reload networking on a cluster that is already degraded (${before}). ` +\n 'Ceph spans these nodes -- fix the cluster first, then re-run the deploy.',\n );\n }\n\n /**\n * ⚠️ ONE LEASE FOR BOTH CALLS, VIA `pveWith` RATHER THAN `pve`. Each mint returns a NEW token\n * id, and the task-status endpoint only skips its `Sys.Audit` check for the task's OWNER —\n * so polling with a fresh mint is a different identity and needs a privilege this role does\n * not have. The `provision` lease is 300s and non-renewable, which is far longer than a\n * reload and is the reason no renew path is reached for.\n */\n const credential = yield* mint(props.target, 'provision');\n const upid = yield* pveWith<string>(props.target, credential, 'PUT', `nodes/${node}/network`);\n if (upid === undefined) {\n return yield* refuse(\n node,\n 'the apply returned no UPID. PVE wraps every answer in {\"data\":...} and can report success ' +\n 'on a call that did nothing -- the reload cannot be confirmed, so it is not claimed.',\n );\n }\n\n /**\n * ⛔ POLLING `pending` INSTEAD OF THE TASK WOULD REPORT SUCCESS BEFORE THE NETWORK WAS TOUCHED.\n * MEASURED in the worker above: the `rename` happens FIRST and `ifreload -a` second, so the\n * staged file — and therefore `changes`, and therefore `pending` — disappears while the\n * reload has not yet started. A provider that watched the count would call a reload that had\n * not run, and a reload that then FAILED, a success. The task's exitstatus is the only\n * honest answer.\n */\n const exitstatus = yield* awaitTask(props.target, credential, node, upid);\n if (exitstatus !== 'OK') {\n return yield* refuse(\n node,\n `the reload ended \"${exitstatus}\" (${upid}). Read it from ANOTHER node -- ` +\n `\\`pvesh get /nodes/${node}/tasks/${upid}/log\\` -- and do not apply the next node until ` +\n 'this one is understood.',\n );\n }\n\n const after = yield* degradedReason(props.target);\n if (after !== undefined) {\n return yield* refuse(\n node,\n `the reload reported OK but the cluster is now degraded (${after}). The next ` +\n 'node has NOT been applied. Restore this one before continuing -- Ceph runs over these ' +\n 'links and a second reload now would take pools below min_size.',\n );\n }\n\n const left = yield* pendingCount(props.target, node);\n if (left !== 0) {\n return yield* refuse(\n node,\n `the reload reported OK but ${String(left)} staged line(s) remain. The running config does ` +\n 'not match the declared one, and saying otherwise is the lie this resource exists to stop.',\n );\n }\n return { node, pending: left };\n });\n\n/**\n * ⛔ HAND-WRITTEN RATHER THAN `pveHandlers`, FOR THE SAME REASON `sdn-apply.ts` IS. The factory's\n * spec is create/update/delete over ONE object at ONE path, and an apply is not an object: there\n * is nothing to POST, nothing to DELETE, and `matches` would compare a declaration to itself and\n * answer `noop` forever, so the apply would run exactly once in the life of the stack. `list` is\n * empty for the reason it is everywhere in this package — adoption stays an explicit act.\n *\n * ⛔ `delete` APPLIES NOTHING AND UNDOES NOTHING, AND THAT IS CORRECT. There is no un-apply: the\n * config is already live on the node, and the way to remove an interface is to delete it and\n * apply AGAIN. See the ⚠️ about `DELETE /nodes/{node}/network` at the top of this file.\n */\nconst handlers = {\n delete: () => Effect.void,\n diff: ({ news }: { news: Input<NetworkApplyProps> }) => diff(news),\n list: () => Effect.succeed([]),\n read: ({ olds }: { olds: NetworkApplyProps }) => read(olds),\n reconcile: ({ news }: { news: NetworkApplyProps }) => apply(news),\n};\n\nexport const ProxmoxNetworkApplyProvider = () =>\n Provider.effect(ProxmoxNetworkApply, Effect.succeed(ProxmoxNetworkApply.Provider.of(handlers)));\n",
37
+ "/**\n * How this package finds out what a node has STAGED, and whether the cluster survived an apply.\n *\n * ★ SPLIT OUT OF network-apply.ts TO KEEP BOTH FILES UNDER THE 250-LINE CAP, and the seam is a real\n * one rather than a convenient line number: this file answers \"what is true on the cluster right\n * now\", network-apply.ts answers \"what does the resource do about it\". Nothing here decides a\n * diff, and the only write in either file is the apply itself.\n *\n * ⛔ THE PENDING STATE IS NOT IN `data`, WHICH IS WHY THIS FILE DOES ITS OWN FETCH. MEASURED in the\n * cluster's own source on n2, 2026-09-13 — not inferred from documentation:\n * PVE/API2/Network.pm my $tmp = PVE::INotify::read_file('interfaces', 1);\n * $rpcenv->set_result_attrib('changes', $changes) if $changes;\n * PVE/HTTPServer.pm if (my $diff = $rpcenv->get_result_attrib('changes')) {\n * $resp->{changes} = $diff;\n * }\n * So the answer is `{\"data\":[…interfaces…],\"changes\":\"<unified diff>\"}`: `changes` is a SIBLING\n * of `data`, set only when the diff is non-empty. `client.ts`'s `pve()` returns `body.data` and\n * drops the envelope, so the one readable pending signal is invisible to every other resource in\n * this package. Without the fetch below, `Proxmox.NetworkApply` could not diff honestly at all.\n * ★ `pveEnvelopeWith` in client.ts now carries the same member failover as every other call.\n *\n * ⛔ AND THE INTERFACE ROWS CANNOT TELL YOU EITHER. MEASURED in PVE/INotify.pm `read_file`: when\n * `/etc/network/interfaces.new` exists, THAT is the file that gets parsed, so\n * `GET /nodes/{node}/network` answers with the STAGED config and a node about to be reconfigured\n * looks identical to one already running it. Same trap `sdn-apply.ts` documents for `?running=1`.\n *\n * ⚠️ `active` IS NOT A PENDING SIGNAL, AND THE OBVIOUS SHORTCUT IS MEASURABLY WRONG. On n2 and n3,\n * with nothing staged anywhere (VERIFIED 2026-09-13: `/etc/network/interfaces.new` absent on n2,\n * n3 and n4), `wlp91s0` already comes back with no `active` key at all. Counting interfaces that\n * are not up as \"pending\" would report an update on two of the three nodes forever.\n *\n * ⚠️ ONE THING GENUINELY CANNOT BE SEEN FROM HERE, AND IT IS SMALL. The diff is computed as\n * `diff -b -N -u`, so a staged file differing from the live one ONLY in whitespace produces no\n * `changes` at all. This module reports that node as settled while `interfaces.new` still sits\n * there waiting for the next reload anybody triggers. The file's existence is not exposed by the\n * API in any other form, so the alternative is not a better read — it is SSH.\n */\nimport * as Effect from 'effect/Effect';\nimport { pve, pveEnvelopeWith, pveWith } from './client.ts';\nimport { type PveCredential, type PveTarget } from './credentials.ts';\nimport { leased } from './lease-cache.ts';\nimport { bool, text } from './values.ts';\n\n/** The `GET /nodes/{node}/network` envelope. ⛔ `changes` is beside `data`, never inside it. */\ntype NetworkEnvelope = { changes?: string };\n\n/** One row of `GET /cluster/status` — a `cluster` row, or one `node` row per member. */\ntype StatusRow = { type?: string; name?: string; quorate?: unknown; online?: unknown };\n\n/** One `GET /nodes/{node}/tasks/{upid}/status` answer. `status` is `running` or `stopped`. */\ntype TaskStatus = { status?: string; exitstatus?: string };\n\n/** What the cluster looked like the moment it was asked. Never persisted — see network-apply.ts. */\nexport type ClusterHealth = { quorate: boolean; offline: readonly string[] };\n\n/**\n * The unified diff between a node's applied interfaces file and its staged one, or `''`.\n *\n * ⛔ THIS STRING NEVER LEAVES THIS MODULE, AND THAT IS A SECRET RULE, NOT A STYLE ONE. Alchemy\n * persists attributes UNENCRYPTED (credentials.ts spells out why), and `/etc/network/interfaces`\n * is a file that can legally contain `wpa-psk` — n2 and n3 both carry a `wlp91s0`, MEASURED — as\n * well as any `pre-up` command somebody wrote. A diff of that file in a state store is a secret\n * in a state store. Only the COUNT below ever escapes.\n */\nconst stagedDiff = (target: PveTarget, node: string) =>\n Effect.gen(function* () {\n const path = `nodes/${node}/network`;\n // ⚠️ THE `read` ROLE IS ENOUGH, AND DELIBERATELY SO. The schema's permission for this GET is\n // `\"user\": \"all\"` — no privilege check at all — so the pending read never needs the\n // provisioning lease, and a plan stays a plan even if the write role is missing entirely.\n // ⛔ THROUGH THE LEASE CACHE, NOT `mint`. This read needs no particular identity — only the\n // apply and its task poll do, and network-apply.ts mints for those itself. Minting here left\n // SIX extra `hf-read@pve` tokens on n2 per TB4 plan (one per node, for read and for diff),\n // MEASURED 2026-09-14 while the cache itself made one read mint for the whole run.\n const credential = yield* leased(target, 'read');\n const envelope = (yield* pveEnvelopeWith(target, credential, 'GET', path)) as NetworkEnvelope;\n return text(envelope.changes);\n });\n\n/**\n * Changed lines in a unified diff.\n *\n * ⚠️ A NON-EMPTY DIFF IS NEVER REPORTED AS ZERO, WHICH IS WHAT `Math.max` IS FOR. The `+++`/`---`\n * headers have to be skipped, and a removed line whose own text starts with `---` is skipped with\n * them; a staged change consisting of nothing else would otherwise count 0 and be reported as\n * \"settled\", which is the exact lie this resource exists to prevent. The count is informational —\n * the resource only ever compares it to zero — so an occasional undercount of 1 is harmless while\n * an undercount to zero is not.\n */\nexport const pendingLines = (diff: string) => {\n if (diff === '') return 0;\n const changed = diff\n .split('\\n')\n .filter(\n (line) =>\n (line.startsWith('+') || line.startsWith('-')) &&\n !line.startsWith('+++') &&\n !line.startsWith('---'),\n ).length;\n return Math.max(changed, 1);\n};\n\n/** How many staged lines this node is carrying. Zero is the only settled value. */\nexport const pendingCount = (target: PveTarget, node: string) =>\n stagedDiff(target, node).pipe(Effect.map(pendingLines));\n\n/**\n * Quorum, and every member that is not online.\n *\n * ⛔ QUORUM ALONE IS NOT THE CHECK, AND ON A THREE-NODE CLUSTER IT WOULD MISS THE ACCIDENT THIS\n * RESOURCE IS AFRAID OF. Losing ONE of three leaves `quorate: 1` — MEASURED shape on TB4:\n * `{\"id\":\"cluster\",\"name\":\"HF-TB4\",\"nodes\":3,\"quorate\":1,…}` plus one row per node with\n * `online: 1`. So a reload that drops n2 off the network is invisible to `quorate` and visible\n * only as `online: 0` on that row. Both are checked, and the node names come back so the failure\n * message can say WHICH member went away.\n *\n * ⚠️ AN UNCLUSTERED NODE IS QUORATE BY DEFINITION. A standalone PVE answers with node rows and no\n * `cluster` row; reading that absence as \"not quorate\" would make this resource undeclarable on\n * every single-node install.\n *\n * ⚠️ THIS ONE NEEDS `Sys.Audit` ON `/` — the only privilege in this family beyond the apply itself.\n * It is asked of the `read` role, which is auditor-shaped, rather than of `provision`.\n */\nconst clusterHealth = (target: PveTarget) =>\n pve<StatusRow[]>(target, 'read', 'GET', 'cluster/status').pipe(\n Effect.map((rows) => {\n const all = rows ?? [];\n const cluster = all.find((row) => row.type === 'cluster');\n return {\n offline: all\n .filter((row) => row.type === 'node' && !bool(row.online))\n .map((row) => text(row.name, '<unnamed>')),\n quorate: cluster === undefined ? true : bool(cluster.quorate),\n } satisfies ClusterHealth;\n }),\n );\n\n/**\n * Why the cluster is not healthy, or `undefined` when it is.\n *\n * ★ A REASON RATHER THAN A BOOLEAN, BECAUSE THE CALLER'S ONLY USE FOR IT IS A REFUSAL MESSAGE.\n * \"The deploy stopped because the cluster was degraded\" is not actionable at three in the\n * morning; \"quorate=true offline=[n3]\" is. The two callers in network-apply.ts ask this before\n * the reload and again after it, and the second answer is the one that stops the chain from\n * reaching the next node.\n *\n * ⚠️ A MEMBER OFFLINE FOR AN UNRELATED REASON BLOCKS EVERY APPLY, AND THAT IS THE INTENDED\n * BEHAVIOUR RATHER THAN AN OVERSIGHT. A node down for maintenance is one failure away from the\n * pools losing min_size; reloading another node's networking while it is out is the move that\n * completes the outage. Bring it back, or apply by hand with the cluster in front of you.\n */\nexport const degradedReason = (target: PveTarget) =>\n clusterHealth(target).pipe(\n Effect.map((health) =>\n health.quorate && health.offline.length === 0\n ? undefined\n : `quorate=${String(health.quorate)} offline=[${health.offline.join(', ')}]`,\n ),\n );\n\n/**\n * ⛔ NOT AN EXITSTATUS PVE CAN RETURN, AND THAT IS THE POINT. The caller compares against `'OK'`;\n * these two say WHY the answer is not OK without needing a second branch for \"we do not know\".\n */\nexport const UNREACHABLE =\n 'the task could not be read -- the node stopped answering, or this lease cannot see it';\nconst STILL_RUNNING = 'still running when this provider stopped waiting';\n\n/**\n * How long to wait on `ifreload`, in one-second polls.\n *\n * ⚠️ THIRTY SECONDS IS A CEILING, NOT AN EXPECTATION. A reload of a handful of interfaces finishes\n * in a second or two; past thirty, something is wrong in a way a deploy cannot fix by waiting,\n * and the honest move is to stop and name the task rather than park the stack on it.\n */\nconst ATTEMPTS = 30;\n\n/**\n * Wait for one `srvreload` task and answer its exitstatus.\n *\n * ⛔ THE APPLY IS ASYNCHRONOUS AND ITS 200 MEANS NOTHING. MEASURED: `reload_network_config` ends\n * `return $rpcenv->fork_worker('srvreload', 'networking', $authuser, $worker)`, so the PUT\n * returns a UPID the instant the worker is forked — before `ifreload -a` has run, let alone\n * succeeded. Waiting for the task is the only way to learn the outcome.\n *\n * ⛔ AND IT MUST BE POLLED WITH THE CREDENTIAL THAT STARTED IT. The task-status schema says\n * `\"user\": \"all\"` with the note \"needs 'Sys.Audit' on '/nodes/<node>' if they are not the owner\n * of the task\". Every mint returns a NEW token id, so a second mint is a different identity and\n * is not the owner — which is why this takes a `PveCredential` and the caller keeps one lease\n * across both calls, instead of widening the provisioning role to read its own tasks.\n */\nexport const awaitTask = (\n target: PveTarget,\n credential: PveCredential,\n node: string,\n upid: string,\n) =>\n Effect.gen(function* () {\n /**\n * ⚠️ THE UPID GOES IN RAW, NOT PERCENT-ENCODED, AND THE CHOICE IS DELIBERATE. A UPID is\n * `UPID:<node>:<hex>:<hex>:<hex>:<type>:<id>:<user>:` — its only punctuation is `:`, `@`, `!`\n * and `-`, every one of which is a legal path character, so raw needs nothing from the\n * router. Encoding them instead RELIES on PVE unescaping each path segment, which is\n * plausible and was NOT measured here (measuring it means starting a task, i.e. writing). If\n * that assumption were wrong the poll would 404, this would report the outcome as unknown,\n * and a perfectly good reload would stop the deploy. Raw removes the assumption.\n */\n const path = `nodes/${node}/tasks/${upid}/status`;\n for (let attempt = 0; attempt < ATTEMPTS; attempt += 1) {\n /**\n * ⛔ A FAILED POLL IS NOT A FAILED RELOAD, AND CALLING IT ONE WOULD BE THE WORST KIND OF\n * WRONG. If the member serving the poll is the node being reloaded, `ifreload -a` can drop\n * the very connection this poll rides on — see network-apply.ts.\n * The reload may well have succeeded. So the call is collapsed to \"we cannot see the task\"\n * and the caller reports the outcome as UNKNOWN, with the UPID, rather than guessing.\n * ⚠️ A 403 LANDS HERE TOO, AND IT READS THE SAME. If the polling identity is somehow not the\n * task's owner, the endpoint wants `Sys.Audit` on the node and this sees only \"no answer\" —\n * which is why `UNREACHABLE` names both possibilities rather than blaming the network.\n */\n const status = yield* pveWith<TaskStatus>(target, credential, 'GET', path).pipe(\n Effect.orElseSucceed(() => undefined),\n );\n if (status === undefined) return UNREACHABLE;\n if (status.status === 'stopped') return text(status.exitstatus, 'stopped with no exitstatus');\n yield* Effect.sleep('1 second');\n }\n return STILL_RUNNING;\n });\n",
38
+ "/**\n * `Proxmox.NodeNetwork` — one stanza of a node's `/etc/network/interfaces`, declared.\n *\n * ⛔ DECLARING THIS RESOURCE IS SAFE. APPLYING IT IS A SEPARATE, DELIBERATE ACT, AND IT IS NOT\n * PERFORMED HERE. Every write under `/nodes/{node}/network/{iface}` lands in\n * `/etc/network/interfaces.new` and changes no running interface. MEASURED, from PVE::INotify:\n * `$shadowfiles = { '/etc/network/interfaces' => '/etc/network/interfaces.new' }`, and\n * `read_file` reads the SHADOW when it exists. The apply is `PUT /nodes/{node}/network`, which\n * renames the shadow over the real file and runs `ifreload -a`; the revert is\n * `DELETE /nodes/{node}/network`, which simply unlinks the shadow. A sibling resource models\n * that apply — this one never calls it, exactly as `Proxmox.SdnZone` never calls\n * `Proxmox.SdnApply`.\n *\n * ⛔ CEPH ON TB4 RIDES TWO NETWORKS AND THIS API ONLY SEES ONE OF THEM. Measured from\n * `/etc/pve/ceph.conf` on 2026-09-13:\n *\n * public_network = 10.20.11.0/24 -> vmbr1.11, which this resource DOES see\n * cluster_network = 10.100.0.0/24 -> every OSD's cluster_addr: .102 / .103 / .104\n *\n * The cluster network — OSD REPLICATION, the traffic that rebuilds a lost replica — lives on\n * `10.100.0.10X/32` addresses carried by `en05`, `en06` and `dummy_tb4`: the Thunderbolt mesh.\n *\n * ⛔ AND THOSE ADDRESSES ARE INVISIBLE HERE, WHICH IS THE TRAP. They are declared in\n * `/etc/network/interfaces.d/sdn`, and PVE's network API does not parse that directory.\n * MEASURED: `GET /nodes/n2/network/en05` answers `{\"method\":\"manual\",\"type\":\"eth\",…}` with NO\n * address, while `ip -br -4 addr` shows `en05 UP 10.100.0.102/32`. So this resource reports\n * en05 and en06 as address-less manual ports and will plan `noop` over them — implicitly\n * asserting they carry no address, which is FALSE.\n *\n * The consequence, stated plainly: declaring en05/en06 from what this API reports and then\n * DESTROYING or applying over them takes out OSD replication on a cluster whose pools are\n * size 3 / min_size 2. They read as the most boring interfaces on the node and are the two most\n * dangerous. Leave them undeclared; if they must be managed, manage the file that actually\n * owns them, not this resource.\n *\n * ⚠️ Two ways this file limits the damage on the interfaces it CAN see: `cidr` is compared\n * unconditionally (the ⛔ on `matches`), and a live interface whose `type` disagrees with the\n * declaration is reported ABSENT rather than retyped (the ⛔ in `attributes`).\n *\n * ★ THE REASON IT EXISTS IS THAT THE STAGED READ CANNOT TELL YOU THE NETWORK IS RIGHT — it can\n * only tell you the FILE is. Once anything is staged, `GET /nodes/{node}/network/{iface}`\n * answers from `interfaces.new`, so `matches` compares a declaration against a pending file and\n * reports `noop` over a node whose running config has not moved. The apply resource is what\n * closes that gap; this resource's `noop` means \"the file says what you said\", no more.\n *\n * ⚠️ PRIVILEGES ARE COARSER HERE THAN ANYWHERE ELSE IN THE PACKAGE: reads want `Sys.Audit` on\n * `/nodes/{node}`, every write `Sys.Modify` on it — and there is no `/nodes/{node}/network` ACL\n * object to scope to, so that also buys the node's services, certificates, DNS and time.\n * Collected with every other family in docs/privileges.md.\n *\n * ★ A RECONCILE OVER A MATCHING INTERFACE IS A NO-WRITE, AND AN EARLIER DRAFT OF THIS COMMENT\n * SAID THE OPPOSITE. `pveOperations.reconcile` gates on `matches` BEFORE the PUT\n * (`resource.ts`: `else if (spec.updateForm !== undefined && !spec.matches(live, news))`), and\n * the ⛔ above that line names THIS family as the reason the guard was added — adopting an\n * interface a node already has would otherwise leave it holding a pending network change.\n *\n * ⚠️ WHAT IS STILL TRUE: when `matches` is false the PUT rewrites the whole stanza, and that can\n * ADD lines the file did not have — a `vlan-raw-device vmbr1` under `vmbr1.11`, where PVE had\n * been deriving it from the name. Harmless in content, and it costs nothing until somebody\n * applies; one more reason the apply is a separate resource.\n *\n * ⚠️ `list` IS EMPTY, AND HERE THAT MATTERS MORE THAN ANYWHERE ELSE IN THIS PACKAGE. The index\n * returns every interface the node has, `vmbr0`, `bond0` and the Ceph vlan included. Adopting\n * them would put Alchemy one `destroy` away from staging the removal of a node's uplink — and\n * `delete_network` has NO in-use check at all: MEASURED, it deletes the hash entry and writes\n * the file. Adoption stays explicit.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport {\n body,\n readAttributes,\n same,\n sameComment,\n sameList,\n updateBody,\n} from './node-network-form.ts';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\n\n/**\n * PVE's interface types. `unknown` is what a NIC it does not manage reports — n2 and n3 both\n * report `wlp91s0` that way, and n4 has no such interface at all.\n *\n * ⚠️ THAT ASYMMETRY IS A TRAP FOR A DECLARATION SHARED ACROSS NODES. On n4 the read answers 404,\n * which this provider cannot tell from \"deleted\", so reconcile POSTs — writing a stanza for a\n * card that is not in the machine. Declare per node what each node actually has; a physical\n * interface is discovered, not decided.\n */\nexport type NodeNetworkType =\n | 'OVSBond'\n | 'OVSBridge'\n | 'OVSIntPort'\n | 'OVSPort'\n | 'alias'\n | 'bond'\n | 'bridge'\n | 'eth'\n | 'fabric'\n | 'unknown'\n | 'vlan'\n | 'vnet';\n\nexport interface NodeNetworkProps extends WithTarget {\n /** Which node's file this stanza lives in. Interfaces are per node, never cluster-wide. */\n node: string;\n /** `vmbr0`, `bond0`, `vmbr1.11`. 2-20 characters, PVE's `pve-iface` format. */\n iface: string;\n /** ⛔ REQUIRED ON EVERY WRITE, update included, never used to retype — see `readAttributes`. */\n type: NodeNetworkType;\n /**\n * `10.20.11.12/24`. ⛔ THE ONE FIELD WITH NO UNMANAGED MODE: leaving it out is an instruction\n * to make the interface `manual`, not an instruction to leave its address alone. The ⛔ on\n * `updateBody` in node-network-form.ts has the measurement and the consequence.\n */\n cidr?: string;\n /** ⚠️ PVE allows exactly ONE default gateway per node and refuses a second with \"Default\n * gateway already exists on interface '<other>'\". On TB4 it is vmbr0.10's. */\n gateway?: string;\n /**\n * `auto <iface>` in the file. Absent on read means off, which is why `bool`'s fallback is used.\n * ⚠️ UNDECLARED IS UNMANAGED ON AN UPDATE AND OFF ON A CREATE — the same asymmetry storage.ts\n * has, and it bites harder here: an interface created without `autostart` is one the node\n * will not bring up at boot. Every TB4 bridge, bond and vlan carries it.\n */\n autostart?: boolean;\n /** 1280-65520. Unset leaves the file without an `mtu` line and the kernel default in force. */\n mtu?: number;\n /** ⚠️ Round-trips only after normalisation — see `comment` in node-network-form.ts. */\n comments?: string;\n /** Space-separated, a SET: `enp87s0`, or `bond0`. ⚠️ PVE refuses a port already used elsewhere. */\n bridge_ports?: string;\n /** `2-4094`, or `2 100-200`. Only written when `bridge_vlan_aware` is on. */\n bridge_vids?: string;\n /** ⛔ A `false` here is sent as `delete=`, never as `0` — the ⛔ on `body` says why. */\n bridge_vlan_aware?: boolean;\n /**\n * A bond's members, space separated. ⚠️ THE PARAMETER IS `slaves`, NOT `bond_slaves`, in BOTH\n * directions on this PVE: MEASURED, the POST/PUT schema names only `slaves` and the GET returns\n * `\"slaves\":\"enp2s0f0np0 enp2s0f1np1\"`. `bond_slaves` appears nowhere in Network.pm here.\n */\n slaves?: string;\n bond_mode?: string;\n /** ⚠️ Only written when `bond_mode` is `balance-xor` or `802.3ad`; ignored otherwise. */\n bond_xmit_hash_policy?: string;\n /** active-backup only. Kept hyphenated because that is the wire name. */\n 'bond-primary'?: string;\n /** ⚠️ DERIVED FROM A DOTTED NAME. `vmbr1.11` reports `vlan-id` 11 with no such line in the file;\n * declaring it there is harmless but adds a line the file did not have. */\n 'vlan-id'?: number;\n 'vlan-raw-device'?: string;\n}\n\n/**\n * ⛔ THE LAST SEVEN ARE REPORTED AND NEVER COMPARED — each is a MEASURED forever-diff, and the\n * evidence for every one of them is in node-network-form.ts, beside the code that reads them.\n */\nexport interface NodeNetworkAttributes {\n node: string;\n iface: string;\n type: string;\n cidr: string;\n gateway: string;\n autostart: boolean;\n mtu: number;\n comments: string;\n bridge_ports: string;\n bridge_vids: string;\n bridge_vlan_aware: boolean;\n slaves: string;\n bond_mode: string;\n bond_xmit_hash_policy: string;\n 'bond-primary': string;\n 'vlan-id': number;\n 'vlan-raw-device': string;\n priority: number;\n method: string;\n families: string;\n active: boolean;\n exists: boolean;\n bond_miimon: string;\n bridge_stp: string;\n bridge_fd: string;\n}\n\nexport interface ProxmoxNodeNetwork extends Resource<\n 'Proxmox.NodeNetwork',\n NodeNetworkProps,\n NodeNetworkAttributes,\n never,\n PveRequirements\n> {}\n\n/** ★ `retain` by default — a node's only uplink cannot be rebuilt. See the ★ in resource.ts. */\nexport const ProxmoxNodeNetwork = Resource<ProxmoxNodeNetwork>('Proxmox.NodeNetwork', {\n defaultRemovalPolicy: 'retain',\n});\n\nconst handlers = pveHandlers<NodeNetworkProps, NodeNetworkAttributes>({\n attributes: readAttributes,\n collection: (props) => `nodes/${props.node}/network`,\n /** ⚠️ No `delete` parameter on a POST — see the ⚠️ on `updateBody`. */\n createForm: body,\n /**\n * ⛔ `cidr` IS THE ONLY FIELD COMPARED WHEN UNDECLARED, AND THAT ASYMMETRY IS THE POINT. Every\n * other field here follows storage.ts: undeclared means unmanaged, so it is neither sent nor\n * compared and a plan cannot report an update no write could satisfy. `cidr` cannot be\n * unmanaged, because PVE derives `method` from the presence of an address IN THE FORM — an\n * omission is an edit. Comparing it unconditionally is what makes that edit visible in `plan`\n * instead of at `ifreload` time.\n *\n * ⚠️ NOTHING IN THE REPORTED-ONLY BLOCK IS HERE, and that is what makes the TB4 declaration\n * plan as `noop` on all three nodes at once — the ⛔ above `NodeNetworkAttributes` lists them\n * and the measurement behind each.\n */\n matches: (attributes, props) =>\n attributes.cidr === (props.cidr ?? '') &&\n same(props.gateway, attributes.gateway) &&\n same(props.autostart, attributes.autostart) &&\n same(props.mtu, attributes.mtu) &&\n sameComment(props.comments, attributes.comments) &&\n sameList(props.bridge_ports, attributes.bridge_ports) &&\n sameList(props.bridge_vids, attributes.bridge_vids) &&\n same(props.bridge_vlan_aware, attributes.bridge_vlan_aware) &&\n sameList(props.slaves, attributes.slaves) &&\n same(props.bond_mode, attributes.bond_mode) &&\n same(props.bond_xmit_hash_policy, attributes.bond_xmit_hash_policy) &&\n same(props['bond-primary'], attributes['bond-primary']) &&\n same(props['vlan-id'], attributes['vlan-id']) &&\n same(props['vlan-raw-device'], attributes['vlan-raw-device']),\n path: (props) => `nodes/${props.node}/network/${props.iface}`,\n updateForm: updateBody,\n});\n\n/**\n * ⚠️ THE DESTROY IS STAGED LIKE EVERY OTHER WRITE, WHICH MAKES IT THE ONE RECOVERABLE DESTROY IN\n * THIS PACKAGE. It removes the stanza from `interfaces.new` and nothing else;\n * `DELETE /nodes/{node}/network` puts the node back by unlinking that file. It becomes\n * irreversible the moment somebody applies — and PVE performs NO in-use check before removing\n * an interface other bridges or Ceph still stand on.\n */\nexport const ProxmoxNodeNetworkProvider = () =>\n Provider.effect(ProxmoxNodeNetwork, Effect.succeed(ProxmoxNodeNetwork.Provider.of(handlers)));\n",
39
+ "/**\n * How a node interface crosses the wire in both directions — props to a PVE form, a PVE answer to\n * a comparable attribute — and when two of those values count as the same value.\n *\n * ★ SPLIT OUT OF node-network.ts TO KEEP BOTH FILES UNDER THE 250-LINE CAP, and the seam is the\n * same one metric-server-form.ts uses, one field wider: this file owns the COERCIONS, in both\n * directions, because a read that normalises differently from the write that produced it is\n * exactly how a forever-diff is born — keeping `ifaceList` next to both ends is what stops that.\n * node-network.ts answers \"what is an interface, and which of its fields are safe to compare at\n * all\". Nothing here calls the cluster.\n *\n * ⚠️ THE `import type` BACK TO node-network.ts IS A CYCLE ON PAPER ONLY — type-only, erased before\n * anything runs, so `NodeNetworkProps` stays in the file that declares the resource.\n *\n * * ⛔ THE LAST SEVEN ARE REPORTED AND NEVER COMPARED, AND EACH ONE IS A MEASURED FOREVER-DIFF.\n * `priority` is assigned by PVE FROM FILE ORDER — `my $priority = 2; ... $d->{priority} =\n * $priority++` — and it is not a POST or PUT parameter at all. MEASURED ACROSS TB4: vmbr1.11 is\n * priority 16 on n2 and n3 and 15 on n4, because n4 has no `wlp91s0` above it. One declaration\n * reused across three nodes would diff on exactly one of them, forever, over nothing.\n * `method` is RECOMPUTED on every write from whether the form carried an address, `families` is\n * recomputed the same way and never written to the file, `active` and `exists` describe the\n * kernel rather than the config, and `bond_miimon`, `bridge_stp` and `bridge_fd` are emitted by\n * PVE's writer with defaults (100, `off`, 0) while appearing in NEITHER write schema —\n * `additionalProperties => 0` means sending one is a 400. Live proof of all three: n2's bond0\n * returns `bond_miimon \"100\"` and vmbr1 returns `bridge_stp \"off\"`, `bridge_fd \"0\"`, none of\n * which any declaration can set.\n */\nimport type { NodeNetworkAttributes, NodeNetworkProps } from './node-network.ts';\nimport { bool, flag, int, text, withClears } from './values.ts';\n\n/**\n * \"Not set\", for the three integers this family reports.\n *\n * ⚠️ 0 CANNOT BE THE ABSENT-MARKER AND -1 CAN. `mtu` is 1280-65520, `vlan-id` 1-4094 and PVE's\n * `priority` starts at 1 (1 is reserved for `lo`), so -1 is outside every one of their ranges\n * while 0 is merely outside today's. metric-server-form.ts keeps its own constant for the same\n * reason and against different ranges; one shared UNSET would have to be right for both.\n */\nexport const UNSET = -1;\n\n/**\n * A space-separated interface list, flattened to one comparable form.\n *\n * ⚠️ `bridge_ports` AND `slaves` ARE SETS, AND PVE NORMALISES THEIR SEPARATORS BUT NOT THEIR ORDER.\n * MEASURED in PVE::Network::Interfaces: the writer does `s/[;,\\s]+/ /g` on both before emitting\n * them, and the reader hands the resulting string straight back — so `enp2s0f1np1 enp2s0f0np0`\n * survives a round trip in the order it was written. Order carries no meaning for a bridge's\n * ports or a bond's slaves, so a declaration that lists them the other way round is the SAME\n * declaration; comparing raw strings would report an update that rewrites the file to say\n * exactly what it already said. Both sides are sorted here and only then compared.\n *\n * ⚠️ IT IS NOT `csv` FROM values.ts. That one joins with commas, and a comma in\n * `/etc/network/interfaces` is not a separator — PVE's own comment above the writer says the\n * list \"must be space separated! other separators will cause problems\". Sending a comma-joined\n * value would be accepted by `split_list` and then written back as spaces, which is a second\n * spelling of one value and therefore a second chance to diff.\n *\n * ⚠️ `bridge_vids` GOES THROUGH THE SAME FUNNEL and its sort is LEXICAL, which is correct only\n * because a vid list is a set: `2-4094` is one token, and `100-200 2` and `2 100-200` allow the\n * same VLANs. Nothing here should be reused for a list whose order is meaning.\n */\nexport const ifaceList = (value: unknown) =>\n text(value)\n .split(/[\\s,;]+/)\n .filter((part) => part !== '')\n .sort()\n .join(' ');\n\n/**\n * A comment off the wire, with the newline PVE adds taken back off.\n *\n * ⛔ `comments` NEVER ROUND-TRIPS RAW, AND THAT IS A FOREVER-DIFF IF IT IS NOT NORMALISED.\n * MEASURED in the reader: each `#...` line is appended as `$comment . \"\\n\"`, so a declared\n * `ceph transport` comes back as `ceph transport\\n` and the two never compare equal.\n * ⚠️ AND THE READER FOLDS `comments6` INTO `comments` (`$d->{comments} .= $comments6`), so on an\n * interface that carries an IPv6 comment a declared `comments` CANNOT match what comes back.\n * TB4 has none; on an interface that does, leave `comments` undeclared rather than fighting it.\n */\nexport const comment = (value: unknown) => text(value).replace(/\\s+$/, '');\n\n/** Undeclared is unmanaged: neither sent nor compared. See the ⚠️ on `body`. */\nexport const same = <T>(declared: T | undefined, live: T) =>\n declared === undefined || declared === live;\n\nexport const sameList = (declared: string | undefined, live: string) =>\n declared === undefined || ifaceList(declared) === live;\n\nexport const sameComment = (declared: string | undefined, live: string) =>\n declared === undefined || comment(declared) === live;\n\nconst field = (name: string, value: string | undefined): Record<string, string> =>\n value === undefined ? {} : { [name]: value };\n\n/**\n * The fields sent on EVERY write, create and update alike.\n *\n * ⚠️ UNDECLARED IS UNMANAGED — not sent, and not compared either. PVE's PUT MERGES the form into\n * the existing stanza (`foreach my $k (keys %$param) { $ifaces->{$iface}->{$k} = $param->{$k} }`),\n * so an omitted parameter is left exactly as it was. `cidr` is the one exception and it is not\n * a small one — see the ⛔ in node-network.ts.\n *\n * ⛔ `type` IS REQUIRED ON THE PUT, NOT ONLY ON THE POST. It carries no `optional` in either\n * schema, and the merge above writes it straight into the stanza — so a PUT naming the wrong\n * type would RETYPE A LIVE INTERFACE in the file and the writer would then emit a bridge stanza\n * for what is really a vlan. node-network.ts refuses that case before it can reach here.\n *\n * ⛔ `bridge_vlan_aware` IS SENT ONLY WHEN TRUE, AND A FALSE ONE IS A `delete=`. MEASURED in the\n * writer: the test is `if (defined($d->{bridge_vlan_aware}))`, not a truth test, so `0` is\n * defined and PVE writes `bridge-vlan-aware yes` anyway. Sending `0` would therefore turn the\n * flag ON, read back as `1`, and diff forever while lying about which way it went.\n *\n * ⚠️ `netmask` IS A WRITABLE PARAMETER AND IS DELIBERATELY NOT OFFERED. PVE raises\n * \"netmask conflicts with cidr\" when both are sent, and the reader rewrites whatever was written\n * into prefix form — MEASURED: n2's vmbr1.11 reports `\"netmask\":\"24\"`, never `255.255.255.0`.\n * A resource accepting both spellings would let a declaration diff against its own value.\n */\nexport const body = (props: NodeNetworkProps): Record<string, string> => ({\n ...field('autostart', flag(props.autostart)),\n ...field('bond-primary', props['bond-primary']),\n ...field('bond_mode', props.bond_mode),\n ...field('bond_xmit_hash_policy', props.bond_xmit_hash_policy),\n ...field('bridge_ports', props.bridge_ports),\n ...field('bridge_vids', props.bridge_vids),\n ...field('bridge_vlan_aware', props.bridge_vlan_aware === true ? '1' : undefined),\n ...field('cidr', props.cidr),\n ...field('comments', props.comments),\n ...field('gateway', props.gateway),\n ...field('mtu', props.mtu === undefined ? undefined : String(props.mtu)),\n ...field('slaves', props.slaves),\n ...field('vlan-id', props['vlan-id'] === undefined ? undefined : String(props['vlan-id'])),\n ...field('vlan-raw-device', props['vlan-raw-device']),\n type: props.type,\n});\n\n/**\n * The update form: `body` plus the two fields that can only be cleared explicitly.\n *\n * ⛔ `delete=cidr` IS SENT WHENEVER `cidr` IS UNDECLARED, AND IT IS THE LESSER OF TWO EVILS RATHER\n * THAN A GOOD OUTCOME. PVE recomputes the method on every write from the form alone —\n * `$param->{method} = $param->{address} ? 'static' : 'manual'` — so a PUT WITHOUT an address\n * makes the interface manual no matter what the caller intended. Left at that, the merge would\n * leave the old `address` and `netmask` in the hash and the writer would emit an `address` line\n * under `iface … inet manual`: a stanza PVE's own UI cannot produce, whose behaviour under\n * `ifreload -a` I did NOT measure. Clearing cidr explicitly at least produces a clean, honest\n * manual interface — and `matches` compares `cidr` UNCONDITIONALLY, so the plan says so first.\n *\n * ⛔ ON vmbr1.11 THAT IS THE CEPH TRANSPORT. A declaration of that interface without its `cidr` is\n * a declaration that it should have no address, applied across three nodes. The plan will read\n * `1 to update` rather than `noop`; do not wave it through.\n *\n * ⚠️ `delete` IS A PUT-ONLY PARAMETER. The POST schema is `additionalProperties => 0` and has no\n * `delete`, so sending it on a create is a 400 — which is why `createForm` calls `body` directly.\n */\nexport const updateBody = (props: NodeNetworkProps): Record<string, string> => {\n const clear = [\n ...(props.cidr === undefined ? ['cidr'] : []),\n ...(props.bridge_vlan_aware === false ? ['bridge_vlan_aware'] : []),\n ];\n const fields = body(props);\n return withClears(fields, clear);\n};\n\n/**\n * One live interface as attributes, or `undefined` — \"this is not really there\".\n *\n * ⚠️ EVERY FIELD PVE REPORTS IS CARRIED HERE, INCLUDING THE SEVEN NO DECLARATION CAN SET. A plan\n * that cannot show `priority`, `method` or `bond_miimon` cannot explain why it is ignoring them,\n * and the next person to read a forever-diff would start by adding them to `matches`. They are\n * reported precisely so that they are visibly OUT of it — see the ⛔ above the attribute type.\n */\nexport const readAttributes = (\n live: Record<string, unknown>,\n props: NodeNetworkProps,\n): NodeNetworkAttributes | undefined => {\n /**\n * ⛔ AN INTERFACE OF ANOTHER TYPE IS ANOTHER OBJECT, AND \"ABSENT\" IS THE SAFE ANSWER — the\n * same call metric-server.ts makes, for a worse reason. `type` is required on the PUT and\n * the PUT MERGES, so a declaration naming `bridge` for what is really a vlan would write\n * `type bridge` into the stanza and PVE's writer would then emit bridge-ports and\n * bridge-stp lines for vmbr1.11. Reporting absent instead makes reconcile POST a create,\n * which PVE refuses with \"interface already exists\": loud, and it changes nothing.\n */\n const liveType = text(live['type']);\n if (liveType !== '' && liveType !== props.type) return undefined;\n return {\n active: bool(live['active']),\n autostart: bool(live['autostart']),\n 'bond-primary': text(live['bond-primary']),\n bond_miimon: text(live['bond_miimon']),\n bond_mode: text(live['bond_mode']),\n bond_xmit_hash_policy: text(live['bond_xmit_hash_policy']),\n bridge_fd: text(live['bridge_fd']),\n bridge_ports: ifaceList(live['bridge_ports']),\n bridge_stp: text(live['bridge_stp']),\n bridge_vids: ifaceList(live['bridge_vids']),\n bridge_vlan_aware: bool(live['bridge_vlan_aware']),\n /** ⚠️ DERIVED BY THE READER from address+netmask, and always present when an address is. */\n cidr: text(live['cidr']),\n comments: comment(live['comments']),\n exists: bool(live['exists']),\n families: Array.isArray(live['families']) ? live['families'].join(',') : '',\n gateway: text(live['gateway']),\n iface: props.iface,\n method: text(live['method']),\n mtu: int(live['mtu'], UNSET),\n node: props.node,\n priority: int(live['priority'], UNSET),\n slaves: ifaceList(live['slaves']),\n type: liveType === '' ? props.type : liveType,\n 'vlan-id': int(live['vlan-id'], UNSET),\n 'vlan-raw-device': text(live['vlan-raw-device']),\n };\n};\n",
40
+ "/**\n * `Proxmox.NotificationTarget` — where a failed backup goes to be seen.\n *\n * ★ THE FAILURE MODE THIS REMOVES IS SILENCE. A failed vzdump, a lost HA service and a broken\n * replication job all reach a human through one mechanism: a notification target. Out of the box\n * a cluster has exactly one, the built-in `mail-to-root` — one mailbox, on one node, delivered by\n * that node's local MTA. Declared, a failure becomes visible; undeclared, nothing looks wrong\n * until somebody goes looking for a backup that was never taken. Every other resource in this\n * package fails loudly. This is the one whose absence fails quietly.\n *\n * ⛔ THE PER-OBJECT READ GOES THROUGH `endpoints/{type}/{name}`, NEVER `targets/{name}`.\n * `GET /cluster/notifications/targets/{name}` answers \"Method not implemented\" — MEASURED, and\n * corroborated by the cluster's own apidoc, where that path node carries no methods at all.\n * `/targets` is a READ-ONLY UNION VIEW implementing the collection GET and `{name}/test` and\n * nothing else. So `type` is IDENTITY here, not a setting: it appears in both `path()` and\n * `collection()`, and changing it is a replace rather than an update.\n *\n * ⚠️ A BUILT-IN TARGET CAN BE ADOPTED AND STILL NOT BE OWNED. The shipped entries report\n * `origin: builtin` or `modified-builtin`, and a DELETE on one REVERTS it to shipped defaults\n * instead of removing it: Alchemy drops the resource from state while the target is still on the\n * cluster delivering mail. Check `origin` on `/cluster/notifications/targets` before declaring a\n * name you did not create. ⚠️ `origin` IS DELIBERATELY NOT AN ATTRIBUTE — the schema returns it\n * on the collection view only, never on the per-object read, so an attribute would read \"unknown\"\n * for every object forever, and an attribute that always lies is worse than a true comment.\n *\n * ⛔ NO SECRET IS A PROP, LET ALONE AN ATTRIBUTE. smtp `password`, gotify `token` and webhook\n * `secret` are write-only and none is declarable here. Props are persisted too, not just\n * attributes — `delete` is handed `olds`, which can only have come from the state store — so a\n * secret prop would sit unencrypted in the state Postgres for as long as the resource exists.\n * ⚠️ THE COST IS REAL: `token` is REQUIRED on a gotify create, so a gotify target cannot be\n * created from here at all. Create one out of band with its secret and then declare it — the\n * read finds it, reconcile takes the PUT path, and PVE leaves any field the body does not\n * mention alone. The secret half stays a human's; the rest is declared. Same for an\n * authenticated smtp target and a signed webhook.\n *\n * ★ WHAT THIS NEEDS, READ OFF THE CLUSTER'S OWN SCHEMA:\n * read/diff GET endpoints/{type}/{name} Mapping.Audit (or Mapping.Modify) on\n * /mapping/notifications\n * reconcile POST + PUT Mapping.Modify on /mapping/notifications AND one of\n * Sys.Audit / Sys.Modify / Sys.AccessNetwork on /\n * delete DELETE Mapping.Modify on /mapping/notifications\n * `LXCProvisioner` already carries Sys.Audit on `/` (see lxc.ts), so the delta is the two Mapping\n * privileges — notably NOT the `Sys.Modify` a backup job costs.\n * ⚠️ PREFER A SECOND ROLE GRANTED AT `/mapping/notifications` OVER WIDENING THE PROVISIONING ROLE\n * ON `/`. `/mapping` also holds the PCI and USB passthrough maps, so Mapping.Modify at the root\n * lets a credential scoped to make containers rewire somebody's hardware.\n * ⛔ A MISSING READ PRIVILEGE DOES NOT LOOK LIKE A 403. `pveOperations.read` ends in\n * `orElseSucceed(() => undefined)`, so a 403 on the GET is indistinguishable from \"absent\": the\n * plan says create, PVE answers \"already exists\", and the fault was an ACL all along. That pair\n * is the signature — grant Mapping.Audit to the READ role before changing anything else.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { addressList, headerList, portOf, shape } from './notification-target-form.ts';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { text } from './values.ts';\n\n/** The four families PVE ships. `GET /cluster/notifications/endpoints` lists exactly these. */\nexport type NotificationTargetType = 'gotify' | 'sendmail' | 'smtp' | 'webhook';\n\n/**\n * ⚠️ PVE'S OWN KEY NAMES, DASHES INCLUDED, for the reason backup-job.ts gives: the form is then a\n * copy rather than a translation table, and a translation table is one more place for a key to be\n * renamed and silently never sent.\n *\n * ⚠️ A FIELD THAT DOES NOT BELONG TO `type` IS STILL SENT, and PVE refuses it by name. That 400\n * beats this file quietly dropping a `mailto` somebody wrote on a webhook.\n */\nexport interface NotificationTargetProps extends WithTarget {\n /** ⛔ IDENTITY: it picks the family AND the URL, so changing it is a replace. */\n type: NotificationTargetType;\n /**\n * PVE's primary key, unique ACROSS ALL FOUR FAMILIES: a webhook cannot be called `mail-to-root`,\n * because a sendmail target already is. Format `pve-configid`.\n */\n name: string;\n /** Free text in the UI. */\n comment?: string;\n /** Configured but not delivering. Always sent and always compared — see `shape`. */\n disable?: boolean;\n /** sendmail, smtp: recipients. ⚠️ Order is not meaning — see `addressList`. */\n mailto?: readonly string[];\n /** sendmail, smtp: PVE users, whose own configured address receives the mail. */\n 'mailto-user'?: readonly string[];\n /** smtp: the SMTP host. gotify: the server URL. PVE requires it on create for both. */\n server?: string;\n /** smtp only. Unset lets PVE pick from `mode`: 465 tls, 587 starttls, 25 insecure. */\n port?: number;\n /** smtp only. PVE's schema default is `tls`. */\n mode?: 'insecure' | 'starttls' | 'tls';\n /** smtp only. ⛔ The matching `password` is not declarable — see the header. */\n username?: string;\n /** smtp: PVE requires it on create. sendmail: optional. */\n 'from-address'?: string;\n /** Display name on the mail. PVE's smtp schema defaults it to `Proxmox VE`. */\n author?: string;\n /** webhook: PVE requires it on create. */\n url?: string;\n /** webhook: PVE requires it on create. Lower case — PVE's enum is `post|put|get`. */\n method?: 'get' | 'post' | 'put';\n /**\n * webhook: `name=<name>,value=<base64 of value>` property strings, as PVE stores them.\n * ⚠️ MORE THAN ONE HEADER IS THE ONE THING HERE NOT PROVEN ON A WIRE — see `REPEATED_KEY`.\n */\n header?: readonly string[];\n /**\n * webhook: the request body, base64, as PVE stores it.\n * ⚠️ THE UI SHOWS THE DECODED BODY AND THIS DOES NOT. Declaring the base64 is what keeps\n * `matches` symmetric with the read; decoding for display would mean encoding on write, and a\n * round trip PVE normalises differently is a forever-update. The cost is an unreadable diff.\n */\n body?: string;\n}\n\n/**\n * ⚠️ EVERY FIELD IS PRESENT FOR EVERY FAMILY, with `''` / `0` meaning \"PVE holds nothing\". A\n * webhook reads back an empty `mailto`, which is also what a webhook declares, so the\n * cross-family fields cost one comparison each and never a false update.\n */\nexport interface NotificationTargetAttributes {\n name: string;\n type: NotificationTargetType;\n comment: string;\n disable: boolean;\n /** Sorted and comma-joined, so re-ordering a declaration is not a diff. See `addressList`. */\n mailto: string;\n 'mailto-user': string;\n server: string;\n /** 0 means PVE holds no port and will pick one from `mode`. */\n port: number;\n mode: string;\n username: string;\n 'from-address': string;\n author: string;\n url: string;\n method: string;\n /** Sorted and comma-joined for COMPARISON only; the wire form differs. See `headerList`. */\n header: string;\n body: string;\n}\n\nexport interface ProxmoxNotificationTarget extends Resource<\n 'Proxmox.NotificationTarget',\n NotificationTargetProps,\n NotificationTargetAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxNotificationTarget = Resource<ProxmoxNotificationTarget>(\n 'Proxmox.NotificationTarget',\n);\n\nconst handlers = pveHandlers<NotificationTargetProps, NotificationTargetAttributes>({\n /**\n * ⛔ NAMED FIELDS, NEVER A SPREAD OF `live`. gotify's `token` and smtp's `password` really are\n * absent from their read schemas — but webhook's read schema DECLARES `secret`, so \"PVE will\n * not hand it to us\" is not a defence. Listing what is kept is what keeps secret material out\n * of a state row, whatever a future PVE decides to start returning.\n */\n attributes: (live, props) => ({\n author: text(live['author']),\n body: text(live['body']),\n comment: text(live['comment']),\n disable: live['disable'] === 1 || live['disable'] === true,\n 'from-address': text(live['from-address']),\n header: headerList(live['header']),\n mailto: addressList(live['mailto']),\n 'mailto-user': addressList(live['mailto-user']),\n method: text(live['method']),\n mode: text(live['mode']),\n name: props.name,\n port: portOf(live['port']),\n server: text(live['server']),\n type: props.type,\n url: text(live['url']),\n username: text(live['username']),\n }),\n collection: (props) => `cluster/notifications/endpoints/${props.type}`,\n /** ⛔ `name` is create-only: PVE takes it in the body once, and in the path forever after. */\n createForm: (props) => ({ ...shape(props), name: props.name }),\n /**\n * Each line reads \"not declared, or equal\"; `disable` is the one field with no undeclared case.\n *\n * ⚠️ IF A PLAN NEVER SETTLES, SUSPECT A SCHEMA DEFAULT COMING BACK AS A VALUE. PVE defaults smtp\n * `mode` to `tls` and smtp `author` to `Proxmox VE`, and applies both when the mail is sent\n * rather than writing them into the config — so an undeclared field reads back empty and its\n * line is skipped. A version that STORED them would answer with a field nobody declared. The\n * fix is to declare the field, never to stop comparing it.\n */\n matches: (attributes, props) =>\n attributes.disable === (props.disable === true) &&\n (props.comment === undefined || attributes.comment === props.comment) &&\n (props.server === undefined || attributes.server === props.server) &&\n (props.port === undefined || attributes.port === props.port) &&\n (props.mode === undefined || attributes.mode === props.mode) &&\n (props.username === undefined || attributes.username === props.username) &&\n (props['from-address'] === undefined || attributes['from-address'] === props['from-address']) &&\n (props.author === undefined || attributes.author === props.author) &&\n (props.url === undefined || attributes.url === props.url) &&\n (props.method === undefined || attributes.method === props.method) &&\n (props.body === undefined || attributes.body === props.body) &&\n (props.mailto === undefined || attributes.mailto === addressList(props.mailto)) &&\n (props['mailto-user'] === undefined ||\n attributes['mailto-user'] === addressList(props['mailto-user'])) &&\n (props.header === undefined || attributes.header === headerList(props.header)),\n path: (props) => `cluster/notifications/endpoints/${props.type}/${props.name}`,\n updateForm: shape,\n});\n\n/**\n * ⚠️ ON A BUILT-IN TARGET A DELETE REVERTS RATHER THAN REMOVES, and PVE reports success either way.\n * It is passed through unguarded because everywhere else in this package the cluster's answer is\n * the answer — but this is the one case where a green plan and the cluster disagree, and the\n * object left standing is the one carrying the estate's failure mail.\n */\nexport const ProxmoxNotificationTargetProvider = () =>\n Provider.effect(\n ProxmoxNotificationTarget,\n Effect.succeed(ProxmoxNotificationTarget.Provider.of(handlers)),\n );\n",
41
+ "/**\n * A notification target's props, as the form PVE wants — including the one field in this package\n * that cannot be spelled as a comma list.\n *\n * ★ SPLIT OUT OF notification-target.ts TO KEEP BOTH UNDER THE 250-LINE CAP. The seam is the same\n * one metric-server uses: this file turns a declaration into a form, and the resource file says\n * what a target IS and when it has changed. The `import type` back is erased, so it is a cycle\n * on paper only.\n */\nimport type { NotificationTargetProps } from './notification-target.ts';\nimport { text } from './values.ts';\n\n/**\n * ⛔ A MULTI-VALUED PARAMETER GOES ON THE WIRE DIFFERENTLY HERE THAN ANYWHERE ELSE IN THIS PACKAGE,\n * AND THE DIFFERENCE IS MEASURED. Every other PVE endpoint spells a list `type: string, format:\n * pve-configid-list` — comma-joined, which is what sdn-vnet.ts sends. On the notification\n * endpoints `mailto`, `mailto-user`, `header` and `delete` are `type: array`, and PVE's own web\n * UI submits those as REPEATED KEYS (`header=a&header=b`). `Record<string, string>` cannot repeat\n * a key, so one value carrying a NUL goes instead: it percent-encodes to `%00`, and PVE's\n * urlencoded decoder joins repeated keys with exactly that byte, rebuilding the same parameter.\n * ⚠️ ONLY `header` NEEDS IT, and only past one entry. A header item is ITSELF the property string\n * `name=<name>,value=<base64>`, so a comma cannot express even one of them. Addresses hold no\n * commas and PVE's UI submits `mailto` as a comma-separated text field, so those go that way.\n * ⚠️ REASONED FROM THE DECODER AND THE UI, NOT PROVEN BY A LIVE MULTI-HEADER WRITE. One header\n * carries no separator and is unaffected either way; a longer list, if rejected, fails with a\n * 400 naming `header` rather than quietly dropping one, and the fix is one line here.\n */\nconst REPEATED_KEY = '\\0';\n\n/** ⚠️ `0` is \"PVE holds no port\". Integers have come back as strings elsewhere, so parse both. */\nexport const portOf = (value: unknown): number => {\n const parsed = typeof value === 'number' ? value : Number.parseInt(String(value ?? ''), 10);\n return Number.isNaN(parsed) ? 0 : parsed;\n};\n\nconst sorted = (parts: readonly string[]): string =>\n parts\n .map((part) => part.trim())\n .filter((part) => part !== '')\n .sort()\n .join(',');\n\n/**\n * ⚠️ ORDER IS NOT MEANING IN A RECIPIENT LIST, SO IT MUST NOT BE A DIFF — backup-job.ts's reasoning\n * about guest ids, applied to addresses. Both sides are sorted before they meet.\n *\n * ⚠️ PVE ANSWERS WITH AN ARRAY AND ACCEPTS A DELIMITED STRING, and this package has already been\n * bitten by a list coming back flattened on one version and structured on another (`groups` in\n * user.ts). PVE's UI calls `mailto` \"separated by spaces, commas or semicolons\", so all three are\n * split here and both shapes funnel into one comparable value.\n */\nexport const addressList = (value: unknown): string =>\n sorted(\n Array.isArray(value)\n ? value.map((item: unknown) => String(item))\n : typeof value === 'string'\n ? value.split(/[\\s,;]+/)\n : [],\n );\n\n/** ⛔ NEVER SPLIT ON A COMMA: a header item contains one. A lone string is one item, not a list. */\nexport const headerList = (value: unknown): string =>\n sorted(Array.isArray(value) ? value.map((item: unknown) => String(item)) : [text(value)]);\n\nconst set = (key: string, value: string | undefined): Record<string, string> =>\n value === undefined ? {} : { [key]: value };\n\n/**\n * The form for both create and update.\n *\n * ⛔ A FIELD THE DECLARATION LEAVES OUT IS NOT SENT AND NOT COMPARED — backup-job.ts's rule rather\n * than sdn-vnet.ts's `delete` list, and here the choice is not close. That list would have to\n * name `mailto`, so a target adopted from the UI and declared without its recipients would have\n * them stripped on the first deploy: the one object that makes failures visible, turned back into\n * silence. `delete` on this family is also `type: array` rather than the comma string every other\n * endpoint takes, so sdn-vnet's encoding would not even carry.\n * ⚠️ THE PRICE IS THAT REMOVING A LINE DOES NOT CLEAR A FIELD. Declare it as `''` to clear it,\n * which IS sent: an empty string is a value, an absent prop is no request at all.\n *\n * ⚠️ `disable` IS ALWAYS SENT AND ALWAYS COMPARED, `0` INCLUDED. PVE documents the default as 0, so\n * sending it explicitly is what makes \"not declared\" and \"declared false\" one state instead of a\n * plan that asks for an update the PUT never performs. It is also the drift that matters most\n * here: a target disabled by hand during a maintenance window and never re-enabled looks exactly\n * like a healthy cluster.\n */\nexport const shape = (props: NotificationTargetProps): Record<string, string> => ({\n disable: props.disable === true ? '1' : '0',\n ...set('author', props.author),\n ...set('body', props.body),\n ...set('comment', props.comment),\n ...set('from-address', props['from-address']),\n ...set('header', props.header === undefined ? undefined : props.header.join(REPEATED_KEY)),\n ...set('mailto', props.mailto === undefined ? undefined : addressList(props.mailto)),\n ...set(\n 'mailto-user',\n props['mailto-user'] === undefined ? undefined : addressList(props['mailto-user']),\n ),\n ...set('method', props.method),\n ...set('mode', props.mode),\n ...set('port', props.port === undefined ? undefined : String(props.port)),\n ...set('server', props.server),\n ...set('url', props.url),\n ...set('username', props.username),\n});\n",
42
+ "/**\n * `Pbs.Datastore` — one section of Proxmox Backup Server's `datastore.cfg`, declared.\n *\n * ★ PBS IS A SIBLING OF PVE, NOT A PART OF IT. The estate runs both — PVE carries a storage of\n * `type: pbs` — so declaring the datastore turns `Proxmox.Storage`'s `locator.datastore` from a\n * string nothing checks into a reference Alchemy can order, as `Proxmox.SdnVnet` did for a bridge.\n *\n * ⛔ DIFFERENT HOST, DIFFERENT REALM, DIFFERENT AUTH HEADER. MEASURED 2026-09-13, strict TLS, no\n * `-k` anywhere: `GET https://pbs.example.com:8007/api2/json/ping` answers 200\n * `{\"data\":{\"pong\":true}}` against a Let's Encrypt certificate for CN=pbs.example.com;\n * `/version` and `/config/datastore` answer 401 \"authentication failed\";\n * `pbs.mgmt.example.com:8007` answers 401 and its certificate verifies too; and\n * `/access/domains` lists the realms `pbs`, `pam` and an openid realm `Schenanigans`. So the\n * prefix, the `{\"data\": …}` envelope and the strict-TLS story are PVE's exactly — and only the\n * credential differs. There is no `pve` realm here; a PVE token cannot authenticate at all.\n * The header differs too, which is why `pve()` exists rather than `pve()` being reused — see the\n * ⛔ on `pbsAuthorization` in pbs-datastore-form.ts.\n *\n * ⛔ THERE IS NO OPENBAO MOUNT FOR PBS TODAY, SO NOTHING HERE CAN DEPLOY YET. `PbsTarget.mount` is\n * a parameter for the reason `PveTarget.mount` is — the provider must be able to leave this\n * estate — but the estate has nothing to put in it. MEASURED: under the `claude-code` approle,\n * `bao token capabilities` answers `deny` for `proxmox-tb4/creds/{read,provision}`,\n * `proxmox-ops/creds/read` and every `…pbs…` path tried, and `sys/mounts` is 403 — so I could\n * not enumerate the mounts to PROVE a PBS one is absent. That it is absent is the brief's\n * statement, not my measurement.\n * ★ WHAT THE MOUNT MUST VEND, so `mint()` is reused unchanged: `bao read -format=json\n * <mount>/creds/<role>` answering `{\"data\":{\"token_id\":…,\"secret\":…}}`, where `token_id` is a\n * PBS token id `user@realm!tokenname` — `hf-read@pbs!…` and `hf-provision@pbs!…`. Same short,\n * non-renewable lease contract as `proxmox-tb4`.\n * ⚠️ PBS HAS NO DYNAMIC-SECRETS PLUGIN OF ITS OWN — OpenBao's Proxmox support is a PVE thing — so\n * the mount is a small custom vendor against `POST /access/users/{id}/token/{name}`. Say which\n * mount and role you needed rather than reaching for the read-only `monitoring@pbs` token on\n * the kv shelf: widening that would delete the outer lock for every reader of the shelf.\n *\n * ⛔ A DATASTORE HOLDS THE BACKUPS, SO `retain` IS THE DEFAULT AND `delete` IS FULLY IMPLEMENTED —\n * the ★ on removal policy in resource.ts has the whole reasoning. A stub returning `Effect.void`\n * would report a deletion that never happened, and this is the family where that lie costs most.\n *\n * ⚠️ PRIVILEGES, READ OFF THE PUBLISHED SCHEMA RATHER THAN OFF THIS HOST:\n * read GET config/datastore/{name} Datastore.Audit on /datastore/{name}\n * create POST config/datastore Datastore.Allocate on /datastore\n * update PUT config/datastore/{name} Datastore.Modify on /datastore/{name}\n * delete DELETE config/datastore/{name} Datastore.Allocate on /datastore/{name}\n * Built-in `DatastoreAdmin` at `/datastore` covers all four; `DatastoreAudit` covers the read\n * lane alone, which is what the `read` role should hold.\n *\n * ⛔ NO SECRET IS A PROP OR AN ATTRIBUTE, AND THIS FAMILY IS CLEAN BY CONSTRUCTION: a datastore\n * section holds no password, token or key — encryption keys belong to the backup CLIENT. Every\n * field below is a name, a path, a schedule, a count or a policy string, all of which are safe in\n * a state store Alchemy writes UNENCRYPTED and this estate dumps to CT100 nightly.\n */\nimport { Resource } from 'alchemy';\nimport { isResolved } from 'alchemy/Diff';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { pve } from './client.ts';\nimport {\n type PbsDatastoreAttributes,\n type PbsTarget,\n createForm,\n matches,\n object,\n readOne,\n updateForm,\n} from './pbs-datastore-form.ts';\nimport { guardBackend, guardPath, settle } from './pbs-datastore-guard.ts';\nimport type { PveRequirements } from './resource.ts';\n\nexport type { PbsDatastoreAttributes, PbsTarget };\n\n/**\n * ⚠️ PBS'S OWN KEY NAMES, HYPHENS INCLUDED — backup-job.ts's rule: the form is then a copy rather\n * than a translation table, and a translation table is one more place for a key to be renamed and\n * silently never sent.\n * ⚠️ AN UNDECLARED FIELD IS NEITHER SENT NOR COMPARED — storage.ts's rule, not sdn-vnet.ts's, and\n * for a retention policy the choice is not close: see the ⛔ on `updateForm`.\n */\nexport interface PbsDatastoreProps {\n target: PbsTarget;\n /** PBS's primary key. Create-only: there is no rename, and a new name is a new datastore. */\n name: string;\n /**\n * Absolute path to the datastore directory.\n *\n * ⛔ CREATE-ONLY, AND THE ONE FIELD THIS FILE REFUSES TO LET DRIFT QUIETLY. PBS's update endpoint\n * does not accept `path`, so comparing it in `matches` could only plan an update no PUT can\n * apply — the forever-diff storage.ts avoids by letting its create-only `type` plan as NOOP.\n * Here a silent noop is the wrong trade: the operator would read a green plan while PBS kept\n * writing backups to the old directory. So `diff` and `reconcile` compare it themselves and DIE\n * with both values named. A path change is remove-and-redeclare, deliberately.\n */\n path: string;\n comment?: string;\n /** Calendar event for garbage collection, e.g. `daily` or `sat 18:15`. */\n 'gc-schedule'?: string;\n /** Calendar event for the built-in prune job. Retention itself is the `keep-*` fields below. */\n 'prune-schedule'?: string;\n /** ⚠️ PBS's minimum is 1 for every keep-*. A declared `0` is refused, and does not mean \"off\". */\n 'keep-last'?: number;\n 'keep-hourly'?: number;\n 'keep-daily'?: number;\n 'keep-weekly'?: number;\n 'keep-monthly'?: number;\n 'keep-yearly'?: number;\n /**\n * Legacy notification routing: `gc=<never|always|error>`, and the same for `verify` and `sync`.\n * ⚠️ PBS 3.2+ picks between this and the notification system with `notification-mode`, which is\n * NOT declarable here: flipping a live datastore between the two silently changes who hears\n * about a failed verify, and silence is the failure mode that costs most (notification-target.ts).\n */\n notify?: string;\n /** PBS user id legacy notifications go to. PBS's schema default is `root@pam`. */\n 'notify-user'?: string;\n /** Verify every new backup the moment it completes. PBS's default is false. */\n 'verify-new'?: boolean;\n /** Property string: `chunk-order=<none|inode>,sync-level=<none|file|filesystem>`, and more. */\n tuning?: string;\n /**\n * Takes the datastore out of service: `type=<offline|read-only|unmount>`, optional\n * `message=<text>`. PBS's default key is `type`, so the bare `offline` normalises to the same\n * string here and either spelling is safe.\n * ⛔ NEVER DECLARE `type=delete`. PBS sets that itself while destroying a datastore's contents.\n * ⚠️ A `message` CONTAINING A COMMA BREAKS THE COMPARISON, not the write: `propertyString` splits\n * on commas and does not honour PBS's quoting, so the two sides never compare equal and the\n * plan asks for the same update forever. Keep the message comma-free.\n */\n 'maintenance-mode'?: string;\n /**\n * ⛔ CREATE-ONLY, LIKE `path`, AND FOR A SHARPER REASON. MEASURED on the live 4.2 host:\n * `datastore create --help` offers `--backend`, `datastore update --help` does NOT, and\n * `backend` is absent from update's `--delete` enum. PBS will not move a datastore between\n * local disk and object storage, ever.\n * ★ IT IS A PROP AT ALL BECAUSE THE ESTATE HAS ONE. `r2-offsite` holds\n * `type=s3,client=cloudflare-r2,bucket=homeflare-pbs`. Leaving it undeclared would still plan\n * noop — undeclared is unmanaged here — but the declaration would then describe a LOCAL\n * datastore, and anyone recreating from it would get exactly that: an empty directory on the\n * mini's disk where the offsite copy used to be, behind a green plan the whole way.\n * ⚠️ A property string. Compared canonically, so key order is never a diff.\n */\n backend?: string;\n /** ⚠️ S3 request counters reset on this calendar event. Mutable; in update's `--delete` enum. */\n 'counter-reset-schedule'?: string;\n /**\n * ⚠️ S3 request-count thresholds that raise a notification, e.g. `s3-put=700000,s3-get=200000`.\n * A property string, compared canonically. Mutable.\n */\n 'notification-thresholds'?: string;\n}\n\nexport interface PbsDatastore extends Resource<\n 'Pbs.Datastore',\n PbsDatastoreProps,\n PbsDatastoreAttributes,\n never,\n PveRequirements\n> {}\n\n/** ★ `retain` by default — a datastore holds the backups. See the ★ in resource.ts. */\nexport const PbsDatastore = Resource<PbsDatastore>('Pbs.Datastore', {\n defaultRemovalPolicy: 'retain',\n});\n\nexport const PbsDatastoreProvider = () =>\n Provider.effect(\n PbsDatastore,\n Effect.succeed(\n PbsDatastore.Provider.of({\n /**\n * ⛔ EMPTY, AND HERE IT GUARDS THE ESTATE'S BACKUPS. `GET /config/datastore` returns every\n * datastore on the host, the one PVE's `type: pbs` storage writes into included. See\n * `pveHandlers` in resource.ts for why adoption stays an explicit act.\n */\n list: () => Effect.succeed([]),\n read: ({ olds }) => readOne(olds),\n /**\n * ⚠️ `isResolved` IS THE NARROWING, resource.ts's reason: at plan time a prop can still be an\n * unresolved Output, and comparing a placeholder to a live value reports a phantom update.\n * ⛔ `guardPath` IS A DELIBERATE DEPARTURE FROM storage.ts, which lets its create-only field\n * plan as noop. Dying fails `alchemy plan` with both paths named — see the ⛔ on the prop.\n */\n diff: ({ news, output }) =>\n Effect.gen(function* () {\n if (output === undefined || !isResolved(news)) return undefined;\n const live = yield* readOne(news);\n // ⚠️ `update`, not `create` — Alchemy's Diff admits only noop/update/replace, and an\n // object Alchemy has state for but PBS does not is drift for reconcile to repair.\n if (live === undefined) return { action: 'update' } as const;\n yield* guardPath(live, news);\n yield* guardBackend(live, news);\n return matches(live, news)\n ? ({ action: 'noop' } as const)\n : ({ action: 'update' } as const);\n }),\n /**\n * ⚠️ NOT THE FACTORY'S reconcile: it reads back ONCE, immediately — see the ⛔ on `settle`.\n * ⛔ `guardPath` RUNS HERE TOO, AND THAT IS NOT BELT-AND-BRACES — see the ⛔ on it.\n * ⛔ THE `matches` GUARD BEFORE THE PUT IS resource.ts's, AND IT IS WHY ADOPTION IS FREE.\n */\n reconcile: Effect.fn(function* ({ news }) {\n const live = yield* readOne(news);\n let upid: string | undefined;\n if (live === undefined) {\n upid = yield* pve<string>(\n news.target,\n 'provision',\n 'POST',\n 'config/datastore',\n createForm(news),\n );\n } else {\n yield* guardPath(live, news);\n yield* guardBackend(live, news);\n // ⚠️ An empty form is not a write — resource.ts skips one for the same reason.\n const form = updateForm(news);\n if (!matches(live, news) && Object.keys(form).length > 0) {\n yield* pve(news.target, 'provision', 'PUT', object(news), form);\n }\n }\n const after = yield* settle(\n readOne(news),\n (row) => row !== undefined && matches(row, news),\n );\n if (after === undefined || !matches(after, news)) {\n /**\n * ⛔ REFUSE RATHER THAN RETURN THE PROPS AS THOUGH THEY LANDED — resource.ts's rule.\n * A create answers with a task id, so \"no error\" is not evidence of a datastore.\n */\n return yield* Effect.die(\n new Error(\n `${object(news)}: the write returned no error but the datastore still does not ` +\n `match the declaration after 120s. PBS answered with task ${upid ?? '(none)'} ` +\n '-- read it with `proxmox-backup-manager task log <upid>`. A slow disk is a ' +\n 'plausible cause (see `settle`); a create over an existing chunk store is not, ' +\n 'because PBS refuses that outright rather than timing out.',\n ),\n );\n }\n return after;\n }),\n /**\n * ⛔ FULLY IMPLEMENTED, NEVER A STUB, and it only ever runs on an explicit\n * `.pipe(RemovalPolicy.destroy())` because this family defaults to `retain`.\n * ⛔ NO `destroy-data`. PBS's DELETE drops the section from `datastore.cfg` and leaves every\n * chunk and snapshot on disk; `destroy-data=1` erases the contents. It is not a prop and\n * not a flag here, so this provider can un-declare a datastore and can never erase one.\n * ⚠️ IT IS STILL A ONE-WAY DOOR FOR A DECLARATION: re-adding a datastore over an existing\n * chunk store needs `reuse-datastore`, which is deliberately not declarable — see the\n * ⚠️ on `createForm`. Re-adopt with `proxmox-backup-manager datastore create …`.\n * ⚠️ NO `keep-job-configs` EITHER, SO THE JOBS GO TOO: PBS defaults it false and removes the\n * verify, sync and prune jobs referencing this datastore — objects nothing here declares.\n * PBS's default stands, so the blast radius is what a human clicking Remove would get.\n * ⚠️ AND THE REFUSAL CAN ARRIVE AFTER THE RESPONSE: the delete forks a worker too, so a store\n * held open by a running backup can fail once the call has already returned 200.\n */\n delete: Effect.fn(function* ({ olds }) {\n yield* pve<string>(olds.target, 'provision', 'DELETE', object(olds));\n const left = yield* settle(readOne(olds), (row) => row === undefined);\n if (left !== undefined) {\n return yield* Effect.die(\n new Error(\n `${object(olds)}: the DELETE returned no error but the datastore is still in ` +\n 'datastore.cfg after 120s. Either a backup, verify or GC task still holds it, ' +\n 'or the provision role lacks Datastore.Allocate on /datastore/' +\n `${olds.name}. Read the task log with \\`proxmox-backup-manager task log <upid>\\`.`,\n ),\n );\n }\n }),\n }),\n ),\n );\n",
43
+ "/**\n * A PBS datastore on the wire: the transport that reaches PBS, the form it wants, and the coercion\n * back to something comparable.\n *\n * ★ SPLIT OUT OF pbs-datastore.ts FOR THE 250-LINE CAP, the seam notification-target-form.ts uses:\n * this file is everything that touches PBS's encoding, and the resource file is the declaration\n * and the five handlers. The `import type` back is erased, so it is a cycle on paper only.\n *\n * ⛔ THIS FILE IS OVER THE 250-LINE CAP AND THE EXTRACTION IS NAMED RATHER THAN FUDGED. `PbsTarget`,\n * `PbsRole`, `PbsError`, `pbsAuthorization`, `PveForm`, `encode`, `pbs` and `settle` — about 150\n * lines — are a PBS CLIENT, not a datastore form, and belong in `pbs-client.ts`. Lifting them\n * leaves this file near 200 and costs nothing but a move. It was not done here only because the\n * family was commissioned as a two-file split; ceph-pool is the in-package precedent for three\n * (ceph-pool.ts + ceph-pool-form.ts + ceph-pool-settle.ts, 532 lines for one family). Everything\n * in that list is also what Pbs.SyncJob, Pbs.PruneJob and Pbs.Remote will each need unchanged,\n * so the second PBS family forces the move anyway. ⛔ DO NOT MEET THE CAP BY CUTTING COMMENTS.\n */\nimport * as Effect from 'effect/Effect';\nimport { type PveForm, pve } from './client.ts';\nimport type { PbsTarget as ApiPbsTarget } from './credentials.ts';\nimport type { PbsDatastoreProps } from './pbs-datastore.ts';\nimport { bool, flag, int, propertyString, text } from './values.ts';\n\n/**\n * ★ PBS REUSES THE PVE CLIENT RATHER THAN OWNING ONE. An earlier draft of this file carried its\n * own `PbsTarget`, `PbsError`, `pbsAuthorization`, form encoder and `pve()` — a near-copy of\n * client.ts differing in one header. They are gone: `PveTarget` now carries a `scheme`, and\n * `authorization()` spells the header `PBSAPIToken=<id>:<secret>` when it is `'pbs'`. The\n * insight that survived is the FORM TYPE — PBS decodes a multi-valued field from repeated keys\n * where PVE wants a comma string — and that now lives on `PveForm` in client.ts, so both\n * products share one encoder and neither can reach for the other's convention by accident.\n *\n * 🔴 THIS ALIAS SAID `= PveTarget` AND IT WAS WRONG — Pbs.Datastore REQUIRED A PVE TARGET. When\n * `credentials.ts` grew a real `PbsTarget` with `scheme: 'pbs'`, this line was left pointing at\n * the PVE type, which pins `scheme: 'pve'`. So the one family that most needs the discriminant\n * was the one family that refused the correct value: declaring a datastore against the PBS host\n * failed to compile with `Type '\"pbs\"' is not assignable to type 'Input<\"pve\">'`, and passing a\n * PVE target compiled fine and would have 401'd every call — which `read` folds into \"absent\",\n * so the plan would say CREATE for a datastore holding the estate's backups.\n * ⛔ IT SURVIVED BECAUSE NOTHING EVER DECLARED ONE. The provider was registered in\n * alchemy.run.ts from the day it was written and `pveHandlers`' `list` answers empty, so\n * registration exercises no call site at all. Three sibling families import `PbsTarget` from\n * credentials.ts directly and were always correct; only the one with its own alias drifted.\n * ★ THE LESSON, WHICH IS NOT ABOUT THIS TYPE: a provider nobody has declared an instance of is\n * not tested by anything, including tsc.\n */\nexport type PbsTarget = ApiPbsTarget;\n\nexport interface PbsDatastoreAttributes {\n name: string;\n /**\n * ⚠️ READ FROM PBS, NEVER ECHOED FROM PROPS. Echoing the declared path would make a divergent or\n * unreadable datastore look like agreement, and this is the field whose divergence means the\n * backups are going somewhere nobody declared. `''` when PBS did not say.\n */\n path: string;\n comment: string;\n 'gc-schedule': string;\n 'prune-schedule': string;\n 'keep-last': number;\n 'keep-hourly': number;\n 'keep-daily': number;\n 'keep-weekly': number;\n 'keep-monthly': number;\n 'keep-yearly': number;\n /** Normalised property strings — sorted and canonicalised, so key order is never a diff. */\n notify: string;\n 'notify-user': string;\n 'verify-new': boolean;\n tuning: string;\n 'maintenance-mode': string;\n /** ⚠️ Create-only. Canonicalised property string; `''` on a plain local datastore. */\n backend: string;\n 'counter-reset-schedule': string;\n 'notification-thresholds': string;\n}\n\n/**\n * ⚠️ `digest` IS DELIBERATELY NOT AN ATTRIBUTE, for storage.ts's reason exactly: PBS returns one on\n * every read and it covers `datastore.cfg` as a FILE, not this section of it, so keeping it would\n * rewrite this resource's state whenever an unrelated datastore was edited — churn that reads\n * like drift. It is not sent on writes either, so this family never joins PBS's optimistic-locking\n * dance and last write wins, as everywhere else in this package.\n */\nexport const attributes = (\n live: Record<string, unknown>,\n props: PbsDatastoreProps,\n): PbsDatastoreAttributes => ({\n backend: propertyString(live['backend']),\n comment: text(live['comment']),\n 'counter-reset-schedule': text(live['counter-reset-schedule']).trim(),\n 'gc-schedule': text(live['gc-schedule']).trim(),\n 'keep-daily': int(live['keep-daily'], 0),\n 'keep-hourly': int(live['keep-hourly'], 0),\n 'keep-last': int(live['keep-last'], 0),\n 'keep-monthly': int(live['keep-monthly'], 0),\n 'keep-weekly': int(live['keep-weekly'], 0),\n 'keep-yearly': int(live['keep-yearly'], 0),\n 'maintenance-mode': propertyString(live['maintenance-mode'], 'type'),\n name: props.name,\n 'notification-thresholds': propertyString(live['notification-thresholds']),\n notify: propertyString(live['notify']),\n 'notify-user': text(live['notify-user']),\n path: text(live['path']),\n 'prune-schedule': text(live['prune-schedule']).trim(),\n tuning: propertyString(live['tuning']),\n 'verify-new': bool(live['verify-new']),\n});\n\nconst same = <T>(declared: T | undefined, live: T) => declared === undefined || declared === live;\n\n/**\n * ⛔ DECLARING WHAT IS LIVE MUST PLAN noop, AND EVERY OMISSION IS DELIBERATE. Out: `name` (the\n * address the read was made at — true by construction, never a diff); `path` (create-only, so\n * comparing it could only plan an update no PUT can apply — pbs-datastore.ts guards it by dying\n * instead, see the ⛔ on the prop); `digest` (not an attribute, above); and every field the\n * declaration does not mention, because undeclared is UNMANAGED here.\n * ⚠️ A SCHEDULE THAT NEVER SETTLES MEANS PBS NORMALISED IT. Calendar events are compared as trimmed\n * strings; if a version rewrites `sat 18:15` as `Sat 18:15` the plan asks for the same update\n * forever. The fix is to declare the spelling PBS stores, never to stop comparing it.\n */\nexport const matches = (live: PbsDatastoreAttributes, props: PbsDatastoreProps) =>\n same(props.comment, live.comment) &&\n same(props['gc-schedule']?.trim(), live['gc-schedule']) &&\n same(props['prune-schedule']?.trim(), live['prune-schedule']) &&\n same(props['keep-last'], live['keep-last']) &&\n same(props['keep-hourly'], live['keep-hourly']) &&\n same(props['keep-daily'], live['keep-daily']) &&\n same(props['keep-weekly'], live['keep-weekly']) &&\n same(props['keep-monthly'], live['keep-monthly']) &&\n same(props['keep-yearly'], live['keep-yearly']) &&\n same(props['notify-user'], live['notify-user']) &&\n same(props['counter-reset-schedule']?.trim(), live['counter-reset-schedule']) &&\n (props['notification-thresholds'] === undefined ||\n propertyString(props['notification-thresholds']) === live['notification-thresholds']) &&\n same(props['verify-new'], live['verify-new']) &&\n (props.notify === undefined || propertyString(props.notify) === live.notify) &&\n (props.tuning === undefined || propertyString(props.tuning) === live.tuning) &&\n (props['maintenance-mode'] === undefined ||\n propertyString(props['maintenance-mode'], 'type') === live['maintenance-mode']);\n\nconst set = (key: string, value: string | undefined): Record<string, string> =>\n value === undefined ? {} : { [key]: value };\n\n/** ⚠️ PBS's minimum for every keep-* is 1, so a declared `0` is refused rather than meaning \"off\". */\nconst count = (value: number | undefined) => (value === undefined ? undefined : String(value));\n\n/**\n * The mutable half, shared by create and update.\n *\n * ⚠️ AN UNDECLARED FIELD IS NOT SENT — storage.ts's rule. PBS leaves a parameter it was not given\n * alone, so this form is safe to re-apply to a datastore that already matches, which is what the\n * adoption path does.\n * ⛔ `name` AND `path` ARE ABSENT ON PURPOSE. Both are create-only: `name` is the address forever\n * after, and PBS's update endpoint does not accept `path` at all, so including it here would turn\n * every single update into a 400.\n */\nconst mutable = (props: PbsDatastoreProps): Record<string, string> => ({\n ...set('comment', props.comment),\n ...set('gc-schedule', props['gc-schedule']?.trim()),\n ...set('keep-daily', count(props['keep-daily'])),\n ...set('keep-hourly', count(props['keep-hourly'])),\n ...set('keep-last', count(props['keep-last'])),\n ...set('keep-monthly', count(props['keep-monthly'])),\n ...set('keep-weekly', count(props['keep-weekly'])),\n ...set('keep-yearly', count(props['keep-yearly'])),\n ...set('counter-reset-schedule', props['counter-reset-schedule']),\n ...set('maintenance-mode', props['maintenance-mode']),\n ...set('notification-thresholds', props['notification-thresholds']),\n ...set('notify', props.notify),\n ...set('notify-user', props['notify-user']),\n ...set('prune-schedule', props['prune-schedule']?.trim()),\n ...set('tuning', props.tuning),\n ...set('verify-new', flag(props['verify-new'])),\n});\n\n/**\n * ⚠️ `path` IS SENT ONCE, HERE, AND NEVER AGAIN — the fact the whole `path` guard hangs off.\n * ⚠️ `reuse-datastore` IS NOT SENT, AND THE REFUSAL IT CAUSES IS A FEATURE: without it PBS refuses\n * a create against a directory that already holds a chunk store, which is the difference between\n * building a new store and silently adopting somebody else's backups. Adopt out of band.\n * ⚠️ NEITHER IS `backing-device`. A removable datastore's UUID is a property of the hardware in the\n * slot, not of the declaration; one that could re-point it is one that can send backups to the\n * wrong drive.\n */\nexport const createForm = (props: PbsDatastoreProps): PveForm => ({\n ...mutable(props),\n name: props.name,\n path: props.path,\n // ⛔ CREATE ONLY, AND ABSENT FROM `mutable` ON PURPOSE. PBS has no `--backend` on update and no\n // `backend` in update's `--delete` enum (measured on 4.2), so sending it on a PUT is a\n // parameter error at best. Divergence is caught by guardBackend, which DIES — the same shape\n // as `path`, for a bigger consequence.\n ...(props.backend === undefined ? {} : { backend: props.backend }),\n});\n\n/**\n * ⛔ THERE IS NO `delete` LIST HERE, AND THAT IS A CHOICE ABOUT BACKUPS RATHER THAN AN OMISSION.\n * sdn-vnet.ts derives one from absent props, which is right for an alias and wrong for a\n * retention policy: a declaration that simply fails to mention `keep-daily` would strip it, and a\n * prune job whose keeps have all been stripped is one PBS version away from a prune job that\n * keeps nothing. So undeclared is UNMANAGED, as in storage.ts and backup-job.ts.\n * ⚠️ THE PRICE IS THAT DROPPING A LINE DOES NOT CLEAR A FIELD. Clear one out of band:\n * `proxmox-backup-manager datastore update <name> --delete keep-daily`. It does not cost a\n * forever-diff, because an undeclared field is not compared either.\n * ⛔ WHEN SOMEBODY ADDS ONE, IT TAKES TWO STEPS AND SKIPPING EITHER IS A SILENT BUG. First build\n * it with `values.withClears`, which drops a cleared key from the body — CLEAR WINS — because\n * PBS applies its deletes BEFORE its sets, so a key both set and deleted keeps its value: the\n * declaration would say \"unset this\", the PUT would succeed, and the next plan would ask for\n * the very same update forever. (PVE instead DIES on that pair; the two behaviours want the\n * same guard.) Second, split the comma-joined value `withClears` produces into a real array —\n * PBS's `delete` is `type: array` and wants REPEATED KEYS, and a comma string arrives as one\n * element that fails the enum check. `PveForm` and `encode` already carry arrays for exactly\n * this. ⚠️ REASONED FROM THE PUBLISHED SCHEMA, NOT PROVEN ON A WIRE.\n */\nexport const updateForm = (props: PbsDatastoreProps): PveForm => mutable(props);\n\nexport const object = (props: PbsDatastoreProps) => `config/datastore/${props.name}`;\n\n/**\n * The live datastore, or undefined.\n *\n * ⛔ `name` IS THE PRESENCE TEST, NOT THE STATUS CODE — PBS does not answer 404 for a section that\n * is missing from `datastore.cfg`, it answers a generic error, so there is no code to key off.\n * ⛔ A MISSING READ PRIVILEGE THEREFORE LOOKS EXACTLY LIKE ABSENCE, because the fold below cannot\n * tell them apart. The signature is a plan that says CREATE followed by PBS answering\n * \"datastore '<name>' already exists.\" — that pair means Datastore.Audit, not a missing\n * datastore. It is loud and non-destructive, which is the only reason the fold is tolerable here;\n * see the ⛔ on `readRole` in resource.ts for the PVE families where it is not.\n * ⛔ ON THE DELETE PATH THE SAME FOLD IS A LIE, AND THIS IS THE ONE HAZARD IN THIS FAMILY I COULD\n * NOT CLOSE. `delete` settles by polling this read until it answers `undefined` — and a `read`\n * role that lacks `Datastore.Audit` answers `undefined` from the very first poll, so EVERY delete\n * would report success while the datastore stood. Worse, the two lanes are different leases: the\n * DELETE goes out under `provision` and may genuinely fail, and this read cannot see that it did.\n * ★ THE SHAPE OF THE FIX IS ALREADY IN THIS PACKAGE: `confirmAbsent` in ceph-pool-settle.ts asks\n * a SECOND, DIFFERENT question — does the collection LIST this object? — and lets a failure\n * PROPAGATE rather than folding it, so \"I could not ask\" fails the deploy instead of passing\n * it. Add the same over `GET /config/datastore` before anyone relies on a reported deletion.\n * ⚠️ UNTIL THEN THE PRECONDITION IS EXPLICIT: the `read` role MUST hold `Datastore.Audit` on the\n * datastore, or this provider cannot tell a deletion from a refusal.\n */\nexport const readOne = (props: PbsDatastoreProps) =>\n pve<Record<string, unknown>>(props.target, 'read', 'GET', object(props)).pipe(\n Effect.map((live) =>\n live === undefined || typeof live['name'] !== 'string' ? undefined : attributes(live, props),\n ),\n Effect.orElseSucceed(() => undefined),\n );\n",
44
+ "/**\n * The two things a datastore write needs that are not form-building: refusing a moved `path`, and\n * waiting for PBS to finish.\n *\n * ★ SPLIT OUT OF pbs-datastore-form.ts FOR THE 250-LINE CAP, and the seam is real. That file turns\n * a declaration into a form; this one is the SAFETY GUARD and the POLLING. A reader asking \"can\n * this destroy my backups\" has one short file to read rather than a long one to search.\n */\nimport * as Effect from 'effect/Effect';\nimport { type PbsDatastoreAttributes, object } from './pbs-datastore-form.ts';\nimport type { PbsDatastoreProps } from './pbs-datastore.ts';\nimport { propertyString } from './values.ts';\n\n/**\n * ⛔ A TRAILING SLASH MUST NOT DEADLOCK EVERY PLAN, WHICH IS WHY THIS IS NOT `===`. `guardPath`\n * DIES, so a false positive is not a spurious update — it is an `alchemy plan` that cannot run at\n * all until somebody edits the declaration, on a family whose whole point is that the operator\n * can see the state of their backups. `/mnt/backups/` and `/mnt/backups` are one directory, and\n * whether PBS canonicalises the path it was handed is a property of the version you are talking\n * to. Both sides are trimmed here so that guess cannot cost an outage of the plan itself.\n * ⚠️ THAT IS THE ONLY NORMALISATION APPLIED. A symlink, a bind mount or `/mnt/./backups` still\n * reads as divergent, and deliberately so: this guard's job is to refuse to GUESS that two\n * spellings are the same directory, and only the trailing slash is certain.\n */\nconst samePath = (left: string, right: string) => {\n const trim = (value: string) => (value.length > 1 ? value.replace(/\\/+$/, '') : value);\n return trim(left) === trim(right);\n};\n\n/**\n * ⛔ THE `path` GUARD, YIELDED FROM BOTH `diff` AND `reconcile`. Both need it: `diff` catches a\n * changed declaration, and `reconcile` catches an ADOPTION, which Alchemy routes straight past\n * `diff` (Apply.ts:980, :1045). `''` is skipped — an unreadable path is not a divergent one.\n */\nexport const guardPath = (live: PbsDatastoreAttributes, props: PbsDatastoreProps) =>\n live.path === '' || samePath(live.path, props.path)\n ? Effect.void\n : Effect.die(\n new Error(\n `${object(props)}: declared path ${props.path} but PBS holds ${live.path}. \\`path\\` ` +\n 'is create-only, so this cannot be reconciled and will NOT be planned as a silent ' +\n 'noop: backups would keep landing in the old directory behind a green plan. Correct ' +\n 'the declaration, or remove the datastore and declare a new one -- the contents live, ' +\n 'because `destroy-data` is never sent.',\n ),\n );\n\n/**\n * ⛔ THE `backend` GUARD, AND IT MATTERS MORE THAN `path`. A wrong `path` sends backups to the\n * wrong directory on the same machine; a wrong `backend` is the difference between a datastore\n * on local disk and one in a Cloudflare R2 bucket. MEASURED on 4.2: `datastore create` takes\n * `--backend`, `datastore update` does not, and `backend` is not in update's `--delete` enum —\n * so divergence CANNOT be reconciled, and the only honest options are to refuse or to lie.\n *\n * ⚠️ AN UNDECLARED `backend` IS NOT A DIVERGENCE. Undeclared is unmanaged everywhere in this\n * family, and this guard keeps that rule: it fires only when the declaration says something and\n * PBS says something else. Adopting `r2-offsite` without mentioning `backend` still plans noop.\n *\n * ⚠️ COMPARED AS A CANONICAL PROPERTY STRING, so `bucket=x,type=s3` and `type=s3,bucket=x` are the\n * same backend and key order cannot deadlock a plan — the reason `samePath` trims a slash.\n */\nexport const guardBackend = (live: PbsDatastoreAttributes, props: PbsDatastoreProps) =>\n props.backend === undefined || propertyString(props.backend) === live.backend\n ? Effect.void\n : Effect.die(\n new Error(\n `${object(props)}: declared backend ${props.backend} but PBS holds ` +\n `${live.backend === '' ? '(none — a local datastore)' : live.backend}. \\`backend\\` ` +\n 'is create-only: PBS has no update for it, so this cannot be reconciled and will NOT ' +\n 'be planned as a silent noop. Correct the declaration to match what is really there, ' +\n 'or remove the datastore and declare a new one -- the contents live, because ' +\n '`destroy-data` is never sent.',\n ),\n );\n\n/**\n * Wait for PBS to finish, then answer the last thing it said.\n *\n * ⛔ IT EXISTS BECAUSE A PBS CREATE IS A FORKED WORKER AND THE CONFIG SECTION IS WRITTEN LAST.\n * `POST /config/datastore` answers with a UPID while a `create-datastore` task builds the chunk\n * store's 65536 directories; only when that finishes does the section reach `datastore.cfg`. An\n * immediate read-back therefore sees a datastore that is not there yet, and the factory's \"the\n * write returned no error but the object is still absent\" would fire on a create going perfectly.\n * The DELETE forks a worker too. ⚠️ DOCUMENTED FROM THE PUBLISHED SCHEMA, NOT MEASURED — I hold\n * no PBS token. If a create turns out to be synchronous, the first poll simply succeeds.\n * ★ IT TAKES THE READ AS AN EFFECT RATHER THAN A FUNCTION — the one simplification over\n * ceph-pool-settle.ts: an Effect is a description, so re-running it re-reads and no dependency\n * has to be threaded back in to avoid a cycle.\n * ⚠️ 2s APART, 60 TRIES, ABOUT TWO MINUTES — longer than ceph-pool's minute, and REASONED rather\n * than measured: 65536 `mkdir`s is seconds on NVMe and can be a minute on a slow or USB disk.\n * Anything still unsettled after two minutes is a fault to surface, not a wait to lengthen, and\n * the caller's message points at the task log, which is where the real answer is. `Effect.sleep`\n * yields between polls; nothing here parks a call on one long wait.\n * ⚠️ POLLING THE TASK STATUS INSTEAD WOULD BE WORSE, for ceph-pool-settle.ts's reason: every call\n * mints a FRESH token, so the token asking about the task is not the one that started it.\n */\nexport const settle = <A, E, R>(read: Effect.Effect<A, E, R>, done: (live: A) => boolean) =>\n Effect.gen(function* () {\n for (let attempt = 0; attempt < 60; attempt += 1) {\n const live = yield* read;\n if (done(live)) return live;\n yield* Effect.sleep('2 seconds');\n }\n return yield* read;\n });\n",
45
+ "/**\n * `Pbs.PruneJob` — a Proxmox Backup Server retention schedule, declared. PBS is a SIBLING of PVE,\n * so this family reuses `pveHandlers` wholesale rather than growing a second factory.\n *\n * ⛔ THIS IS THE ONE RESOURCE IN THIS PACKAGE THAT DESTROYS DATA ON AN ORDINARY *UPDATE*. CephPool,\n * ZfsPool and Storage can destroy data too — which is exactly why they default to `retain` and\n * make a caller opt in with `destroy()`, and that guard covers DELETE and nothing else. Here the\n * destruction rides a plain `1 to update` that no removal policy has any opinion about. A wrong\n * `keep-*` does not fail: it succeeds. The PUT returns 200, and the NEXT SCHEDULED RUN — minutes\n * or days later, with nobody watching — removes every snapshot that fell outside the new window.\n * There is no undo, PBS does not ask, and nothing about the deploy looks unusual.\n * ★ CONCRETELY, SO NOBODY HAS TO IMAGINE IT: a live job with `keep-daily 30`, a declaration\n * saying `keep-daily: 7`. `matches` reports an update, the PUT lands, and twenty-three days of\n * daily backups are gone at the next run. The plan showed one word. READ THE `keep-*` HALF OF\n * EVERY PLAN TWICE; it is the only warning there is.\n * ⚠️ THE ONE THING THAT CANNOT HAPPEN IS A SILENT ZERO. MEASURED from the published schema: every\n * `keep-*` carries `minimum: 1`, so a literal `keep-daily=0` is a 400 rather than a wipe. And\n * an UNDECLARED window is not sent as zero either — it is not sent at all, because undeclared\n * means unmanaged here exactly as it does in storage.ts. A window this stack never named is one\n * it never narrows. `0` in the attributes below therefore means ABSENT, never a real setting.\n *\n * ⛔ `max-depth` UNSET IS THE WIDEST SCOPE, NOT THE NARROWEST, AND IT IS THE ONE FIELD WHERE\n * \"UNMANAGED\" IS NOT THE SAFE ANSWER. MEASURED, quoting the published schema's own description:\n * \"0 == no recursion, empty == automatic full recursion\". So a job that names an `ns` but leaves\n * `max-depth` alone prunes every namespace BENEATH that one too, with these windows. Declare it.\n * `-1` in the attributes means \"absent from prune.cfg\", the sentinel storage.ts uses for\n * `maxfiles`, because `0` here is a real and very different setting.\n *\n * ⛔ THE CREDENTIAL DOES NOT EXIST YET, SO NOTHING BELOW HAS EVER MADE A CALL. PBS is a different\n * host and a different auth realm from PVE. MEASURED 2026-09-13: pbs.example.com:8007 answers\n * HTTP 401 under STRICT TLS behind a real Let's Encrypt certificate (CN=pbs.example.com, issuer\n * YR1, valid 2026-09-02 to 2026-12-01) — so there is no `-k` to reach for and `client.ts` needs\n * no TLS escape hatch, exactly as on PVE. What it does need is a header it cannot build today.\n * PBS's documented form is `Authorization: PBSAPIToken=TOKENID:TOKENSECRET` (measured from the\n * published PBS documentation, 2026-09-13) while `authorization()` in credentials.ts builds\n * `PVEAPIToken=<tokenid>=<secret>`: BOTH the scheme and the separator differ. A wrong separator\n * answers 401 \"authentication failure\", which reads as a bad credential rather than as a\n * malformed header — the same trap credentials.ts already records for PVE's colon form.\n * ⛔ AND THERE IS NO MOUNT TO MINT FROM. `mint()` runs `bao read <mount>/creds/<role>`; no\n * OpenBao mount vends PBS tokens — `proxmox-tb4` and `proxmox-ops` vend PVE ones. The\n * `kv/infra/proxmox` shelf holds a READ-ONLY `Audit` token for PBS, and a read-only token\n * cannot create a prune job. I could not confirm that shelf's contents: this machine's\n * claude-code approle answers 403 on `sys/mounts` AND on `kv/metadata/infra/proxmox`\n * (MEASURED). What is needed is a dynamic PBS mount vending a `provision` role with\n * `Datastore.Modify` — say that, rather than reaching for the stored auditor token.\n *\n * ★ WHAT A `PbsTarget` NEEDS, AND WHY IT IS ALMOST `PveTarget`. Structurally `PveTarget` already\n * fits a PBS host: a credential mount name and an `/api2/json` base are the whole of it, and PBS\n * shares the `{\"data\": …}` envelope, the four-operation shape and the read-back discipline —\n * which is exactly why this file declares a spec and stops. The single thing `PveTarget` cannot\n * carry is WHICH AUTHORIZATION SCHEME the host at the other end speaks, so `PbsTarget` below adds\n * that and nothing else rather than bending the PVE type in silence.\n *\n * ⚠️ WHICH VERSION THIS IS AUTHORED AGAINST, BECAUSE PRUNE JOBS MOVED. The paths and every field\n * below are MEASURED from the PBS API as published at pbs.proxmox.com/docs/api-viewer, fetched\n * 2026-09-13 — current PBS 4.x. Before PBS 2.2 there was no `/config/prune` at all: retention\n * lived on the datastore section itself, as `keep-*` plus `prune-schedule` under\n * `/config/datastore/{name}`. Against anything older every path here 404s, `pveOperations.read`\n * folds that into \"absent\", and the plan says create forever. Check `GET /api2/json/version`\n * before the first plan.\n *\n * ★ THE READ LANE NEEDS NOTHING EXTRA, UNLIKE THREE PVE FAMILIES — so there is no `readRole:\n * 'provision'` below and there should not be one. MEASURED: `GET /config/prune/{id}` requires\n * \"Datastore.Audit or Datastore.Verify on job's datastore\", i.e. the AUDIT privilege is enough\n * for the ITEM read. That is precisely what `Proxmox.Storage` and the two SDN families could not\n * say, and it is why the ⛔ on `readRole` in resource.ts does not claim a fourth family here.\n * ⚠️ THE WRITE PRIVILEGES ARE NOT ONE PRIVILEGE, AND DELETE IS THE ODD ONE OUT. MEASURED: POST\n * and PUT require `Datastore.Modify` on the job's datastore; DELETE requires `Datastore.Verify`.\n * A credential that can create and edit a prune job cannot necessarily remove one, and the\n * symptom is a destroy that 403s long after the creates worked.\n *\n * ⚠️ RUNTIME STATUS IS NOT HERE AND WAS NOT FORGOTTEN. `last-run-endtime` and friends come from\n * `/admin/prune`, not from this endpoint: MEASURED, `GET /config/prune/{id}` returns exactly\n * comment, disable, id, the six keep-*, max-depth, ns, schedule and store — no digest, no status.\n * Reporting a last-run time would make a plan's output change when nothing changed, and a plan\n * whose output moves on its own is one people stop reading. `/admin/prune/{id}/run` triggers a\n * prune by hand and is deliberately not modelled: running one is an act, not a declaration.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport type { PbsTarget } from './credentials.ts';\nimport { createBody, keepAttributes, keepsMatch, updateBody } from './pbs-prune-job-form.ts';\nimport { type PveRequirements, type WithPbsTarget, pveHandlers } from './resource.ts';\nimport { bool, int, text } from './values.ts';\n\n/**\n * ⚠️ THE PROPS ARE PBS'S OWN KEY NAMES, HYPHENS INCLUDED, for backup-job.ts's reason: the form\n * builder is then a copy rather than a translation table, and a translation table is one more\n * place for a key to be renamed and silently never sent. Here a field that is never sent is a\n * retention window that never applies.\n */\nexport interface PruneJobProps extends WithPbsTarget {\n /** ⛔ A PBS host, not a PVE one. See `PbsTarget` and the credential ⛔ in the header. */\n target: PbsTarget;\n /**\n * ⛔ The primary key, REQUIRED, and PBS does not generate one. Measured: 3–32 chars matching\n * `^[A-Za-z0-9_][A-Za-z0-9._\\-]*$`. To adopt a job that exists, declare its existing id — any\n * other id is a SECOND prune job on the same datastore, and two prune jobs do not negotiate.\n */\n id: string;\n /** ⚠️ The datastore this prunes. Changing it re-points the job rather than adding one: the old\n * store stops being pruned and the new one starts, with these windows, at the next run. */\n store: string;\n /**\n * A systemd calendar event, e.g. `daily` or `sat 02:30`. ⛔ REQUIRED — measured, it is the one\n * non-optional field of `POST /config/prune` besides `id` and `store`, and it is NOT in the PUT\n * `delete` enum, so there is no way to un-schedule a job short of disabling or removing it.\n * ⚠️ THIS COMPARES STRINGS, NOT MEANINGS. A calendar event has many equivalent spellings and PBS\n * stores the one it was handed; declare the spelling the server echoes back.\n */\n schedule: string;\n /** Namespace to prune, `''` or unset for the root one. ⚠️ Scope, so read it with `max-depth`. */\n ns?: string;\n /** ⛔ UNSET MEANS FULL RECURSION, NOT NONE — see the ⛔ in the header. 0–7. Declare it. */\n 'max-depth'?: number;\n /** ⚠️ Undeclared is UNMANAGED, so a job somebody disabled by hand stays disabled. That is the\n * deliberate direction for a destructive job: never switch one on that nobody asked for. */\n disable?: boolean;\n comment?: string;\n /** ⚠️ Every window below is `minimum: 1` (measured) and undeclared means unmanaged. */\n 'keep-last'?: number;\n 'keep-hourly'?: number;\n 'keep-daily'?: number;\n 'keep-weekly'?: number;\n 'keep-monthly'?: number;\n 'keep-yearly'?: number;\n}\n\nexport interface PruneJobAttributes {\n id: string;\n store: string;\n schedule: string;\n ns: string;\n /** ⚠️ `-1` is ABSENT — and absent means full recursion. `0` is the real \"no recursion\" setting. */\n 'max-depth': number;\n disable: boolean;\n comment: string;\n /** ⚠️ `0` is ABSENT in all six. PBS's own minimum is 1, so zero can never be a live value. */\n 'keep-last': number;\n 'keep-hourly': number;\n 'keep-daily': number;\n 'keep-weekly': number;\n 'keep-monthly': number;\n 'keep-yearly': number;\n}\n\nexport interface PbsPruneJob extends Resource<\n 'Pbs.PruneJob',\n PruneJobProps,\n PruneJobAttributes,\n never,\n PveRequirements\n> {}\n\n/**\n * ★ NO `defaultRemovalPolicy: 'retain'`, UNLIKE Storage AND ZfsPool, AND THE REASON IS THE REVERSE\n * OF THEIRS. Destroying this resource destroys a POLICY, and a policy is a line of TypeScript.\n * The archives it would have trimmed are not touched by the DELETE — see the ⚠️ on the provider.\n */\nexport const PbsPruneJob = Resource<PbsPruneJob>('Pbs.PruneJob');\n\n/** \"Not declared, or equal\" — the single shape every unmanaged field is compared with. */\nconst same = <T>(declared: T | undefined, live: T) => declared === undefined || declared === live;\n\nconst handlers = pveHandlers<PruneJobProps, PruneJobAttributes>({\n /**\n * ⚠️ EVERY OPTIONAL FIELD FALLS BACK TO ITS ABSENT SENTINEL RATHER THAN TO PBS'S DEFAULT, because\n * for this family the two are different questions. `keep-daily` absent does not mean \"keep zero\n * dailies\", it means \"this window is not part of the policy\", and `matches` must not compare a\n * window the declaration never mentioned against an invented value.\n * ⛔ NO \"IS IT REALLY THERE\" GUARD, for backup-job.ts's reason: returning undefined for a job\n * whose JSON is missing a key would be a guess about which keys PBS echoes, and a wrong guess\n * sends reconcile down the POST branch — which creates ANOTHER prune job rather than failing.\n */\n attributes: (live, props) => ({\n comment: text(live['comment'], ''),\n disable: bool(live['disable'], false),\n id: props.id,\n ...keepAttributes(live),\n 'max-depth': int(live['max-depth'], -1),\n ns: text(live['ns'], ''),\n schedule: text(live['schedule'], ''),\n store: text(live['store'], props.store),\n }),\n collection: () => 'config/prune',\n createForm: createBody,\n /**\n * ⚠️ THE UNDECLARED HALF IS NOT COMPARED, AND THAT IS THE WHOLE SAFETY MODEL. `same` reads \"not\n * declared, or equal\", so a field set by hand on an adopted job survives adoption untouched and\n * never appears as drift. `keepsMatch` applies the identical rule to the six windows, from the\n * file that also writes and reads them — see the ★ at the top of pbs-prune-job-form.ts.\n * ⚠️ `store` AND `schedule` HAVE NO UNDECLARED CASE because both are required props, so both are\n * compared unconditionally. A changed `store` is an update, not a replace: PBS accepts `store`\n * on PUT, so the job is re-pointed in place.\n */\n matches: (attributes, props) =>\n attributes.schedule === props.schedule &&\n attributes.store === props.store &&\n same(props.ns, attributes.ns) &&\n same(props['max-depth'], attributes['max-depth']) &&\n same(props.disable, attributes.disable) &&\n same(props.comment, attributes.comment) &&\n keepsMatch(attributes, props),\n path: (props) => `config/prune/${props.id}`,\n updateForm: updateBody,\n});\n\n/**\n * ⛔ `list` IS EMPTY like every other family here, and the stakes are the usual ones read backwards.\n * `GET /config/prune` hands back every prune job on the server, the ones an operator tuned by\n * hand included. Adopting those would give Alchemy the right to REWRITE their retention the first\n * time a declaration disagreed — and rewriting retention is deleting backups. Adoption stays an\n * explicit act: name the id you mean.\n *\n * ⚠️ THE DELETE IS THE SAFE DIRECTION, AND IT IS STILL NOT FREE. Removing a prune job deletes\n * NOTHING: the archives that survived the last run stay exactly where they are. What goes away is\n * the only thing trimming that datastore, so the failure mode is a datastore that fills up weeks\n * later — an outage with no obvious cause and no backup written during it. Nothing on the server\n * depends on a prune job, so PBS will not refuse this the way PVE refuses to delete a pool still\n * holding guests; the plan line is the only warning anyone gets.\n * ⚠️ DELETE ALSO NEEDS A DIFFERENT PRIVILEGE FROM THE WRITES — `Datastore.Verify`, not\n * `Datastore.Modify`. See the ⚠️ in the header before assuming a working create means a working\n * destroy.\n */\nexport const PbsPruneJobProvider = () =>\n Provider.effect(PbsPruneJob, Effect.succeed(PbsPruneJob.Provider.of(handlers)));\n",
46
+ "/**\n * A prune job's wire half — and, deliberately, EVERY LINE THAT CAN DELETE A BACKUP.\n *\n * ★ SPLIT OUT OF pbs-prune-job.ts ON THE SEAM replication-job-form.ts USES: that file answers\n * \"what is a prune job and when has it changed\", this one answers \"how does a declaration become\n * a PBS write\". The one deliberate departure from that seam is `keepsMatch`, which is diff logic\n * and lives here anyway — see the ★ below, which is the reason the cut falls where it does.\n *\n * ★ THE SIX RETENTION WINDOWS ARE TOUCHED IN THREE PLACES AND ALL THREE ARE IN THIS FILE: sent by\n * `keepForm`, read back by `keepAttributes`, compared by `keepsMatch`. The three must stay in\n * step — a window written but not compared is a diff that never settles, and one compared but not\n * written is an update reported on every plan forever — and this is the half of the resource\n * where being wrong costs backups rather than a confusing plan. Keeping all three on one screen\n * is what makes that review possible in one sitting instead of a grep across two files.\n *\n * ⚠️ THE `import type` BACK TO pbs-prune-job.ts IS A CYCLE ON PAPER ONLY. It is type-only, erased\n * before anything runs, so `PruneJobProps` stays the resource's public shape in the file that\n * declares the resource rather than being moved somewhere odd to dodge the arrow.\n *\n * ⚠️ FORM ENCODING IS THE ONE TRANSPORT ASSUMPTION THIS FAMILY RESTS ON, AND IT IS REASONED RATHER\n * THAN MEASURED. `pveWith` sends `application/x-www-form-urlencoded`; PBS's REST server accepts\n * that alongside JSON and parses each value through the parameter schema, which is how its own\n * ExtJS GUI talks to it. I could not prove it: there is no credential for this host (see the ⛔ in\n * pbs-prune-job.ts) and the only unauthenticated endpoint that would have distinguished a 400\n * \"bad parameters\" from a 401 is the login form, which is not a thing to poke on a live box. If\n * PBS turns out to want JSON here, every key and value below is still right and only the\n * transport is wrong — VERIFY THIS FIRST, before anything else in these two files.\n */\nimport type { PruneJobAttributes, PruneJobProps } from './pbs-prune-job.ts';\nimport { flag, int } from './values.ts';\n\n/**\n * The six retention windows, in PBS's own spelling.\n *\n * ⚠️ ONE LIST, READ THREE TIMES — by `keepForm` on the way to the wire, by `keepsMatch` on the way\n * back, and by `keepsSomething` in the guard. Two hand-kept copies of six key names is how a\n * seventh window gets added to one of them and silently never sent, which for this family means\n * never applied and never noticed until a restore.\n */\nexport const KEEP_KEYS = [\n 'keep-last',\n 'keep-hourly',\n 'keep-daily',\n 'keep-weekly',\n 'keep-monthly',\n 'keep-yearly',\n] as const;\n\nexport type KeepKey = (typeof KEEP_KEYS)[number];\n\n/** ⚠️ Undeclared windows are simply absent — see `requireKeeps` for why zero is never sent. */\nconst keepForm = (props: PruneJobProps): Record<string, string> => {\n const form: Record<string, string> = {};\n for (const key of KEEP_KEYS) {\n const value = props[key];\n if (value !== undefined) form[key] = String(value);\n }\n return form;\n};\n\n/**\n * The six windows off the wire, where `0` MEANS ABSENT.\n *\n * ⛔ ZERO IS A SENTINEL HERE AND CAN NEVER BE A LIVE VALUE, which is the only reason it is safe to\n * use one. MEASURED from the published PBS schema: every `keep-*` carries `minimum: 1`, so PBS\n * cannot store a zero and cannot be sent one — `keep-daily=0` is a 400, not a wipe. A field that\n * comes back missing is a window that is not part of this job's policy, and `keepsMatch` must be\n * able to tell that apart from \"the declaration asked for zero\", which it cannot express either.\n */\nexport const keepAttributes = (\n live: Record<string, unknown>,\n): Pick<PruneJobAttributes, KeepKey> => ({\n 'keep-daily': int(live['keep-daily'], 0),\n 'keep-hourly': int(live['keep-hourly'], 0),\n 'keep-last': int(live['keep-last'], 0),\n 'keep-monthly': int(live['keep-monthly'], 0),\n 'keep-weekly': int(live['keep-weekly'], 0),\n 'keep-yearly': int(live['keep-yearly'], 0),\n});\n\n/**\n * ⚠️ AN UNDECLARED WINDOW IS NOT COMPARED, AND THAT IS THE SAFETY MODEL RATHER THAN AN OVERSIGHT.\n * A `keep-weekly` an operator set by hand on an adopted job is not drift this stack repairs —\n * repairing it would mean narrowing retention nobody asked to narrow. The cost is stated rather\n * than hidden: deleting a `keep-daily` line from a declaration plans as a NOOP and changes\n * nothing on the server. See the ⛔ on `updateBody` for why clearing is a hand operation.\n */\nexport const keepsMatch = (attributes: Pick<PruneJobAttributes, KeepKey>, props: PruneJobProps) =>\n KEEP_KEYS.every((key) => props[key] === undefined || props[key] === attributes[key]);\n\n/**\n * ⛔ A PRUNE JOB WITH NO `keep-*` KEEPS NOTHING, AND THIS REFUSES TO BUILD ONE.\n *\n * MEASURED from the published PBS API: all six windows are `optional: 1` on POST and on PUT. So\n * on the wire \"I forgot the retention\" and \"I want no retention\" are the SAME REQUEST, and the\n * second one is not a configuration — it is a scheduled deletion of every backup in scope. This\n * is the one mistake this family must not be able to make.\n *\n * ⚠️ PBS PROBABLY REFUSES IT TOO, AND THAT IS NOT GOOD ENOUGH TO LEAN ON. Its GUI warns about a\n * keep-less prune job, which suggests the API guards it as well, but I could not reach a PBS to\n * prove it and \"probably refused upstream\" is not a thing to bet a restore on. The guard is\n * local, it is cheap, and it costs nothing at all on a declaration that is already correct.\n *\n * ⛔ IT THROWS RATHER THAN RETURNING AN EMPTY FORM. `reconcile` calls these builders inside\n * `Effect.gen`, so the throw lands as a defect and stops the deploy carrying this sentence. A\n * builder that quietly answered `{}` instead would be a PUT of nothing — reported as success —\n * over the retention the declaration existed to set.\n *\n * ⚠️ IT FIRES AT DEPLOY, NOT AT PLAN, because `diff` never calls a form builder: a keep-less\n * declaration plans as a clean create and then dies on apply. Loud and safe, but not early. The\n * stronger guard is a props type where one window is mandatory — a `Base & ({'keep-last': number}\n * | …)` union — and it is NOT here because I could not satisfy myself that Alchemy's\n * `Input<Props>` narrowing distributes over that union, and an unverified type trick in the file\n * that decides what gets deleted is worse than an honest runtime throw.\n */\nconst keepsSomething = (props: PruneJobProps) => KEEP_KEYS.some((key) => props[key] !== undefined);\n\nconst requireKeeps = (props: PruneJobProps) => {\n if (keepsSomething(props)) return;\n throw new Error(\n `Pbs.PruneJob ${props.id}: declares no keep-* window, which tells PBS to keep NOTHING on ` +\n `datastore '${props.store}'. Every keep-* is optional on the wire, so an omission and a ` +\n 'deliberate \"retain nothing\" are indistinguishable; declare at least one window (keep-last, ' +\n 'keep-hourly, keep-daily, keep-weekly, keep-monthly or keep-yearly) or delete the job.',\n );\n};\n\n/** ⚠️ An undeclared field emits NO KEY AT ALL, not an empty one — see the ⚠️ on `shape`. */\nconst field = (name: string, value: string | undefined): Record<string, string> =>\n value === undefined ? {} : { [name]: value };\n\n/** ⚠️ `undefined` in, `undefined` out, so `field` can drop it — never the text \"undefined\". */\nconst integer = (value: number | undefined) => (value === undefined ? undefined : String(value));\n\n/**\n * The mutable half, shared by create and update.\n *\n * ⚠️ `store` AND `schedule` ARE ALWAYS SENT because they are always declared and always compared —\n * a field compared against a value but NOT SENT as that value is an update reported on every\n * plan that the PUT never performs (backup-job.ts and replication-job-form.ts both record that\n * trade). PBS makes both required on POST and optional on PUT, so sending them on both calls is\n * legal and keeps one shape for the two.\n *\n * ⚠️ EVERYTHING ELSE IS SENT ONLY WHEN DECLARED, AND UNDECLARED MEANS UNMANAGED — the rule\n * storage.ts sets, not backup-job.ts's \"always send the documented default\". The difference is\n * what the drift costs: an undetected `enabled 0` on a vzdump job means backups quietly are not\n * happening, while an unasked-for change here means backups quietly ARE being deleted. Writing a\n * default this stack never declared is the worse error for a destructive job, so it is not done.\n * ⛔ `max-depth` IS THE EXCEPTION THAT PROVES IT AND IT RUNS THE OTHER WAY — see the ⛔ in\n * pbs-prune-job.ts. Its unset value is FULL RECURSION, so leaving it unmanaged is the WIDE\n * choice rather than the narrow one. Declare it.\n */\nconst shape = (props: PruneJobProps): Record<string, string> => ({\n ...keepForm(props),\n ...field('comment', props.comment),\n ...field('disable', flag(props.disable)),\n ...field('max-depth', integer(props['max-depth'])),\n ...field('ns', props.ns),\n schedule: props.schedule,\n store: props.store,\n});\n\n/**\n * ⛔ `id` IS SENT AND IS NOT OPTIONAL, for backup-job.ts's reason sharpened by this API's shape.\n * MEASURED: `id` is a REQUIRED parameter of `POST /config/prune` — PBS does not generate one —\n * so an omitted id is a 400 rather than a duplicate job. That is the good case; the bad one is\n * the id being WRONG. `pveOperations.read` folds every failed GET into \"absent\", so a 403 or an\n * expired lease reads as \"no such job\", the plan says create, and a second prune job appears\n * beside the first with this declaration's retention applied to the same datastore. Two prune\n * jobs on one store do not negotiate: each deletes what its own windows do not keep.\n */\nexport const createBody = (props: PruneJobProps): Record<string, string> => {\n requireKeeps(props);\n return { ...shape(props), id: props.id };\n};\n\n/**\n * ⛔ THERE IS NO `delete` LIST HERE AND `withClears()` IS DELIBERATELY NOT IMPORTED. Two\n * independent reasons, either of which alone would be enough.\n *\n * FIRST, THE WIRE SHAPE IS NOT PVE'S. MEASURED from the published PBS schema, `PUT\n * /config/prune/{id}` declares `delete` as `{\"type\":\"array\",\"items\":{\"type\":\"string\",\"enum\":[\n * \"comment\",\"disable\",\"ns\",\"max-depth\",\"keep-last\",\"keep-hourly\",\"keep-daily\",\"keep-weekly\",\n * \"keep-monthly\",\"keep-yearly\"]}}` — an ARRAY of enum members. PVE's `delete` is a comma-joined\n * string, which is exactly what `withClears()` builds, and a form-encoded array is built by\n * REPEATING the key. `delete=comment,disable` is therefore ONE item that is in no enum: a 400,\n * not a clear.\n * ⚠️ AND THE CORRECT SHAPE IS NOT EXPRESSIBLE TODAY. `pveWith` takes `Record<string, string>` and\n * runs it through `new URLSearchParams`, which cannot repeat a key from a plain object. A PBS\n * clear list needs a client that can, and that is a change to client.ts rather than to this\n * file — so a clear list could not be shipped here even if it were wanted.\n *\n * SECOND, AND THIS ONE WOULD STAND ANYWAY: CLEARING A `keep-*` IS THE MOST DESTRUCTIVE THING\n * THIS API CAN DO. Removing `keep-last` from a job that had it does not restore a default — PBS\n * has no default retention — it NARROWS what survives the next run. So an undeclared field is\n * unmanaged, and a window this stack never mentioned is one it never widens and never removes.\n * Dropping a `keep-daily` line from a declaration therefore does NOTHING on purpose; clear it by\n * hand, having first looked at what it is holding.\n *\n * ★ THE DISJOINTNESS `withClears()` EXISTS TO ENFORCE IS THEREFORE VACUOUS HERE: with no clear list\n * there is no key that can be set and deleted in one call, which is the failure it guards. If a\n * later change does add one it must go through `withClears()` AND teach the client to repeat the\n * key — half of that is a 400, and the other half is PVE's spelling sent to a PBS host.\n */\nexport const updateBody = (props: PruneJobProps): Record<string, string> => {\n requireKeeps(props);\n return shape(props);\n};\n",
47
+ "/**\n * `Pbs.SyncJob` — one section of Proxmox Backup Server's `sync.cfg`, declared: a remote datastore's\n * snapshots pulled into a local one on a schedule.\n *\n * ★ IT USES THE SHARED PVE CLIENT, AND THE TYPES STOP THE TWO HOSTS BEING SWAPPED. An earlier\n * draft imported a `./pbs-client.ts` that never existed, arguing that reusing the PVE machinery\n * would COMPILE and that this was the danger — a PBS host accepted wherever a PVE one belongs,\n * every call 401ing, `read` folding that into \"absent\". The argument was right and the fix is\n * the discriminant rather than a second client: `scheme` is REQUIRED on a target, so a PBS host\n * is not assignable to a PVE resource or the reverse, and the mistake is a compile error. See\n * the ⛔ on `scheme` in credentials.ts.\n *\n * ⛔ THE CREDENTIAL IS A PBS TOKEN AND IT DOES NOT EXIST YET; NO MOUNT NAME IS INVENTED IN THIS\n * FILE. PBS wants `user@realm!tokenname` plus a UUID secret, issued by PBS — a PVE token is not\n * one, whatever it is spelled like. MEASURED from this machine on 2026-09-13: the `claude-code`\n * approle cannot enumerate mounts (`bao secrets list` -> 403) and\n * `bao token capabilities kv/infra/proxmox/pbs` -> `deny`, so I could not confirm from here what\n * does or does not exist. What credentials.ts records is that every PBS token on the kv shelf is\n * READ-ONLY (`Audit`, as `monitoring@pve`) and STATIC — too narrow to create a sync job, and\n * exactly the kind of credential this provider exists to avoid writing with.\n * ★ SO THE MOUNT IS A `PbsTarget.mount` THE STACK SUPPLIES, and somebody has to build it first:\n * a dynamic PBS mount with `read` and `provision` roles mirroring `proxmox-tb4`. Until it\n * exists this family can be declared and cannot be deployed. `permission denied` means the\n * grant is missing — say which mount and role you needed; do not fall back to the shelf token.\n *\n * ⚠️ WHAT IS MEASURED AND WHAT IS NOT. MEASURED on 2026-09-13 from this machine, read-only and\n * under STRICT TLS (no `-k`; curl reports `ssl_verify_result` 0):\n * `GET https://pbs.example.com:8007/api2/json/ping` -> HTTP 200 `{\"data\":{\"pong\":true}}`. So\n * the host is real, its certificate validates, and PBS WRAPS ITS ANSWER IN THE SAME `{\"data\": …}`\n * ENVELOPE AS PVE — which is what lets the PVE-shaped client body be reused at all.\n * ⛔ EVERYTHING ELSE BELOW IS DOCUMENTED, FROM PBS'S PUBLISHED API SCHEMA, AND NOT MEASURED — the\n * field list, the parameter spellings, which of them a PUT accepts, the privileges. Without a\n * credential every other endpoint answers 401, and PBS answers 401 BEFORE it routes:\n * `/api2/json/config/nosuchthing` -> 401, not 404 (measured). So the 401 from\n * `/api2/json/config/sync` is not even evidence that the endpoint exists. THE FIRST PLAN\n * AGAINST A LIVE PBS IS THE MEASUREMENT. Read it; do not deploy it unseen.\n * ⚠️ AN ERROR BODY IS NOT WRAPPED: the 401 body is the bare text `authentication failed`, not\n * JSON. `pve()` checks `response.ok` before it parses, so a `pbs()` copied from it is safe —\n * provided the check stays in that order.\n *\n * ⚠️ `Proxmox.BackupJob` AND `Pbs.SyncJob` ARE NOT THE SAME FAMILY AND THE NAMES NEARLY COLLIDE.\n * The first is a PVE vzdump schedule; this is a Proxmox Backup SERVER sync job, on a different\n * host. The `Pbs.` prefix is what keeps them apart in a plan, so it is not shortened.\n *\n * ★ THE SEAM, SINCE IT IS NOT THE USUAL ONE. This file answers \"what a sync job is and what it\n * costs to declare one\": the props, the attributes, the resource. pbs-sync-job-form.ts answers\n * \"how it meets PBS\": the coercions, the create and update bodies, and — the part that normally\n * lives here — `matches`. `matches` went with the wire because it is DOWNSTREAM of the wire:\n * ha-rule.ts's rule is that only a field a write can actually set may be compared, so every line\n * of that predicate is an argument about what the PUT accepts. Splitting it from the forms would\n * have put the claim and its evidence in different files. `Provider.of(handlers)` stays HERE, for\n * resource.ts's ⛔: it is the one place the handlers are checked against the concrete resource\n * types, and a cast there would be a lie about whether they match.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { handlers } from './pbs-sync-job-form.ts';\nimport type { PveRequirements } from './resource.ts';\nimport type { WithPbsTarget } from './resource.ts';\n\n/**\n * ⚠️ THE PROPS ARE PBS'S OWN PARAMETER NAMES, DASHES INCLUDED, for backup-job.ts's reason: the form\n * builder is then a copy rather than a translation table, and a translation table is one more\n * place for a key to be renamed and silently never sent.\n */\nexport interface SyncJobProps extends WithPbsTarget {\n /**\n * ⛔ PBS'S SECTION ID AND THIS RESOURCE'S KEY, REQUIRED. Unlike a PVE vzdump job PBS does not\n * autogenerate one — `POST /config/sync` takes `id` — so the backup-job.ts failure of creating\n * a second job beside the first on every reconcile cannot happen here. It is still required\n * rather than derived: to adopt a job that exists, declare the id it already has.\n * ⚠️ A PROXMOX SAFE ID — letters, digits, `_`, `.`, `-`, 3 to 32 characters — so there is nothing\n * in it for `path` below to encode.\n */\n id: string;\n /** The LOCAL datastore the snapshots land in. Required by PBS at create. */\n store: string;\n /** Local namespace, e.g. `tenant/db`. Unset means the root namespace, which PBS spells `''`. */\n ns?: string;\n /**\n * ⛔ A REMOTE BY NAME ONLY. THIS RESOURCE NEVER MODELS THE CREDENTIAL BEHIND IT, and a\n * `Pbs.Remote` family is OUT OF SCOPE for this package rather than merely unwritten:\n * `POST /config/remote` requires `password`, and Alchemy persists props and attributes to its\n * state store UNENCRYPTED (StateEncoding.ts tags Redacted values rather than encrypting them),\n * which here is the `alchemy` Postgres that pg-backup.sh dumps nightly to CT100. A remote's\n * password in a prop is that password in four places, for months. The only Remote resource that\n * could exist would refuse `password` the way storage.ts refuses it — as a `never` — and could\n * therefore never CREATE a remote, which is a resource that cannot do what its name promises.\n * Create remotes out of band (`proxmox-backup-manager remote create`) and name one here.\n * ⚠️ The fingerprint is not the problem: a certificate fingerprint is public. The password is.\n * ⚠️ UNSET MEANS A LOCAL SYNC — datastore to datastore on this same PBS — which is a real and\n * supported mode, not an omission. See `matches`: an unset `remote` is NOT compared, so leaving\n * it out does not claim a job with a remote is local; it claims nothing at all.\n */\n remote?: string;\n /** The datastore on that remote. Required by PBS at create. */\n 'remote-store': string;\n /** Namespace on the remote. Unset means its root namespace. */\n 'remote-ns'?: string;\n /**\n * A PBS calendar event — `daily`, `hourly`, `mon..fri 02:30`. Unset means the job runs ONLY when\n * somebody starts it by hand, which is a sync that is not happening; declare one.\n * ⚠️ THIS COMPARES STRINGS, NOT MEANINGS. A calendar event has many equivalent spellings and PBS\n * stores the one it was handed, so declare the spelling the server echoes back.\n */\n schedule?: string;\n /** Single line only — PBS's comment schema rejects a newline. */\n comment?: string;\n /**\n * ⛔ THIS DELETES SNAPSHOTS. NOT \"prunes\", NOT \"tidies\" — DELETES, on a schedule, driven by\n * ANOTHER SERVER'S STATE. On a PULL job (the default), every backup group in the local `store`\n * and `ns` that is no longer on the remote is REMOVED LOCALLY the next time the job runs. The\n * remote decides; this side obeys. Somebody pruning hard on the remote, a remote datastore\n * restored from an older copy, a remote namespace renamed, or a remote that has simply lost\n * data — each of those becomes deletion HERE, and the local copy is usually the copy that was\n * supposed to survive the remote.\n * ⛔ AND ON A PUSH JOB IT DELETES ON THE REMOTE INSTEAD — same flag, opposite victim. Read\n * `sync-direction` before reading this one.\n * ⚠️ IT IS COMPARED AND SENT EVEN WHEN UNDECLARED, unlike every other optional field here, and\n * that is deliberate: undeclared means `false`, so adopting a job somebody had switched this on\n * for plans as an UPDATE that switches it off — a real edit, and NOT a free one. It is the\n * direction that does not delete, but a job that was BOUNDING a datastore now grows it, and a\n * full PBS datastore fails every backup on it. The plan says only \"update\"; read the live job.\n */\n 'remove-vanished'?: boolean;\n /**\n * The PBS Authid that owns the synced groups, e.g. `sync@pbs` or `sync@pbs!job1`. Unset leaves\n * the config without one, which PBS reads as `root@pam` AT RUNTIME — so unset and `root@pam` are\n * not the same value in the config even though they behave alike. Owning a group is what lets an\n * Authid prune or delete it, so changing this is a permissions change, not a label.\n * ⚠️ AN AUTHID IS AN IDENTIFIER, NEVER A SECRET — it may name an API token (`user@realm!name`),\n * and the token's VALUE is the secret. This resource stores the name and never the value.\n */\n owner?: string;\n /**\n * Incoming rate limit in BYTES PER SECOND. Unset means unlimited.\n * ⚠️ DECLARED IN BYTES, STORED AS A HUMAN STRING. PBS types this as a `HumanByte`, so a written\n * `10485760` comes back as something like `10.00 MiB`; `bytes()` in the form file parses both\n * ends back to a byte count so the two can be compared at all. REASONED from the type, NOT\n * measured — I had no credential to round-trip one.\n * ⛔ DECLARE A VALUE PBS CAN PRINT EXACTLY — a whole multiple of a binary unit. A rate that\n * rounds in the printed form (10485761) reads back as the rounded value, never equals what was\n * declared, and becomes an update reported on every plan forever. This is the single most\n * likely forever-diff in this file; it is the first thing to check on the first plan.\n * ⚠️ `burst-in`, `rate-out` AND `burst-out` ARE NOT MODELLED. PBS's rate limit is four fields\n * flattened into the job; this resource manages one and leaves the others alone, which is safe\n * because PBS's update assigns only the parameters it was sent.\n */\n 'rate-in'?: number;\n /**\n * How many namespace levels below `remote-ns` to sync, 0 (no recursion) upwards. Unset means PBS\n * recurses as deep as it is allowed — which is MORE data, not less, so it is not a safe default\n * to leave implicit on a job whose target namespace has children.\n */\n 'max-depth'?: number;\n /** Sync only the last N snapshots of each group. Unset means all of them. */\n 'transfer-last'?: number;\n /**\n * ⛔ NOT DECLARABLE, AND A COMPILE ERROR RATHER THAN A PROP THAT HALF WORKS — the storage.ts\n * `password` idiom, for two independent reasons, either of which alone would be enough.\n * 1. THE WIRE FORM IS AN ARRAY. PBS takes `group-filter` as a repeated parameter\n * (`group-filter=type:ct&group-filter=regex:^web`), and `pve()`'s form is\n * `Record<string, string>` — one value per key — so a list cannot be expressed at all.\n * 2. NARROWING A FILTER MAY BE A DELETE. Whether `remove-vanished` skips the groups a filter\n * excludes is NOT something I could measure without a credential. If it does not, then\n * editing this field on a job with `remove-vanished` set removes every local group the new\n * filter excludes. A field that MIGHT delete snapshots when changed does not get a\n * half-working prop.\n * ★ IT IS STILL REPORTED in the attributes, so a plan shows the filters a hand-made job carries\n * and this resource never strips them: undeclared is unmanaged, and PBS's update assigns only\n * what it was sent. To make it declarable, fix both halves — a form type that can repeat a\n * key, and a MEASURED answer to (2) — in that order.\n */\n 'group-filter'?: never;\n /**\n * `pull` (default) or `push`. ⛔ IT DECIDES WHICH SIDE `remove-vanished` DELETES FROM. Push also\n * needs a newer PBS: on a server that predates it the parameter is unknown and the create is\n * refused, which is the honest failure.\n * ⚠️ CREATE-ONLY HERE, SO A CHANGED DIRECTION PLANS AS NOOP — see `matches`. That is the\n * deliberately safe half of an unmeasured question: if PBS does accept it on PUT, the cost of\n * this choice is a noop; if PBS refuses it, comparing it would be an update the PUT can never\n * perform, on every plan, forever. Retire the declaration and add another, as user.ts says for\n * `userid`.\n */\n 'sync-direction'?: 'pull' | 'push';\n /**\n * ⚠️ SYNC ONLY SNAPSHOTS THAT HAVE PASSED VERIFICATION. Present on 4.2 (`sync-job update\n * --verified-only <boolean>`, and in its `--delete` enum), and the estate sets it: the parked\n * `sync-all-to-dc` job carries `verified-only: true`, so without this prop that job cannot be\n * declared as it actually is.\n * ⛔ IT PAIRS WITH A VERIFICATION JOB THAT ACTUALLY RUNS. With PBS's defaults a snapshot is\n * verified once and never again — see `rechecks` in pbs-verify-job-form.ts — so `verified-only`\n * on a datastore whose verify job is parked means \"sync only what was checked once, long ago\".\n */\n 'verified-only'?: boolean;\n}\n\nexport interface SyncJobAttributes {\n /** From the props — it is the path this object was read by. */\n id: string;\n store: string;\n /** `''` is the root namespace, which is also how PBS spells it. */\n ns: string;\n /** `''` means a LOCAL sync — datastore to datastore on this PBS. */\n remote: string;\n 'remote-store': string;\n 'remote-ns': string;\n /** `''` means the job runs only when somebody starts it. */\n schedule: string;\n comment: string;\n 'remove-vanished': boolean;\n /** ⚠️ Absent on the wire means `false`, PBS's own default. */\n 'verified-only': boolean;\n /** `''` means no owner in the config, i.e. `root@pam` at runtime. An identifier, never a secret. */\n owner: string;\n /** Bytes per second, or `UNSET` (-1). See `bytes()`. */\n 'rate-in': number;\n /** `UNSET` (-1) means unset, which means full recursion. `0` is a real value meaning none. */\n 'max-depth': number;\n /** `UNSET` (-1) means all snapshots. */\n 'transfer-last': number;\n /**\n * ⚠️ REPORTED, NEVER SENT, NEVER COMPARED — the live filter list joined for display only. See the\n * ⛔ on the prop for why it is not declarable.\n */\n 'group-filter': string;\n /** `pull` or `push`. Reported, never compared — create-only here. */\n 'sync-direction': string;\n}\n\nexport interface PbsSyncJob extends Resource<\n 'Pbs.SyncJob',\n SyncJobProps,\n SyncJobAttributes,\n never,\n PveRequirements\n> {}\n\n/**\n * ⚠️ NO `defaultRemovalPolicy: 'retain'`, and the reasoning is replication-job.ts's. Deleting this\n * object removes a SCHEDULE, not data: every snapshot already synced stays in the local\n * datastore, and PBS's own pruning is a different job. What is lost is freshness — which is\n * destructive in six months rather than today, and is exactly why the plan line deserves reading.\n */\nexport const PbsSyncJob = Resource<PbsSyncJob>('Pbs.SyncJob');\n\n/**\n * ⛔ THE EMPTY `list` FROM THE FACTORY STANDS. `GET /config/sync` hands back every sync job an\n * operator ever made in the UI, and adopting one is how a later `alchemy destroy` silently stops\n * a second copy being refreshed. Adoption is an explicit act — declare the `id` you mean.\n * ⚠️ DELETING THE JOB DOES NOT DELETE SNAPSHOTS, AND `remove-vanished` DOES. Those two sentences\n * are the whole risk model of this family and they point opposite ways: the DELETE plan line is\n * safe today and expensive in six months, while a single `remove-vanished: true` is a standing\n * instruction to delete local snapshots whenever another server loses them.\n */\nexport const PbsSyncJobProvider = () =>\n Provider.effect(PbsSyncJob, Effect.succeed(PbsSyncJob.Provider.of(handlers)));\n",
48
+ "import type { SyncJobAttributes, SyncJobProps } from './pbs-sync-job.ts';\n/**\n * A sync job on the wire: how a PBS answer becomes comparable values, how a declaration becomes a\n * create or an update, and — because that question is downstream of this one — when it has changed.\n *\n * ★ SPLIT OUT OF pbs-sync-job.ts FOR THE 250-LINE CAP; the ★ SEAM there says why `matches` came\n * with the wire instead of staying with the props. The `import type` back is a cycle on paper\n * only — erased before anything runs, so the runtime arrow points one way, resource to wire.\n *\n * ★ IT USES THE SHARED PVE CLIENT, NOT A PBS ONE. An earlier draft of this file was written\n * against a `./pbs-client.ts` that never existed, and spelled out what it would have to export.\n * That module is not needed: PBS speaks the same `/api2/json` paths and the same `{\"data\": …}`\n * envelope, its OpenBao mount vends the same `{token_id, secret}`, and the only difference is\n * the authorization header — so `PveTarget` carries a `scheme` and `authorization()` spells\n * `PBSAPIToken=<id>:<secret>` for `'pbs'`. `pveHandlers` and `pveOperations` work unchanged.\n * The one PBS-specific thing that survived is the FORM TYPE: PBS decodes a multi-valued field\n * from repeated keys, and `PveForm` in client.ts admits a list for exactly that reason.\n\n */\nimport { pveHandlers } from './resource.ts';\nimport { bool, int, text } from './values.ts';\n\n/**\n * The marker for \"PBS has no value for this number\".\n *\n * ⚠️ `-1` RATHER THAN `0`, AND metric-server.ts's `UNSET = -1` IS THE PRECEDENT. `max-depth` has a\n * legal value of 0 — sync this namespace and no child of it — which is a completely different\n * instruction from the absent field, where PBS recurses as deep as it is allowed. Using 0 as the\n * marker would make \"no recursion\" and \"full recursion\" the same attribute. `rate-in` and\n * `transfer-last` take the same marker for uniformity rather than because 0 is legal for them:\n * depending on a schema minimum I could not measure is exactly the kind of guess that becomes a\n * forever-diff.\n */\nexport const UNSET = -1;\n\n/** ⚠️ BINARY AND DECIMAL BOTH, because PBS's HumanByte can print either and parses both. */\nconst UNITS: Record<string, number> = {\n '': 1,\n B: 1,\n GB: 1e9,\n GiB: 1073741824,\n KB: 1e3,\n KiB: 1024,\n MB: 1e6,\n MiB: 1048576,\n TB: 1e12,\n TiB: 1099511627776,\n};\n\n/**\n * A PBS rate limit off the wire, as a plain byte count.\n *\n * ⛔ THE VALUE GOES OUT AS A NUMBER AND COMES BACK AS PROSE. PBS types `rate-in` as a `HumanByte`,\n * which parses `10485760` on the way in and prints something like `10.00 MiB` on the way out, so\n * the two sides of a comparison are never the same string. Flattening both to bytes is what makes\n * the field comparable at all. REASONED from the type's parse/print asymmetry, NOT measured —\n * there was no credential to round-trip one with.\n * ⚠️ IT ROUNDS, AND A RATE THAT DOES NOT DIVIDE EVENLY WILL NEVER SETTLE. `10.00 MiB` carries two\n * decimals, so a declared 10485761 reads back as 10485760, `matches` reports an update, the PUT\n * writes the same rounded value, and the next plan reports it again — forever. Declare a whole\n * multiple of a binary unit. This is the likeliest forever-diff in the family and the first thing\n * to check on the first plan against a live PBS.\n * ⚠️ AN UNPARSEABLE ANSWER READS AS `UNSET`, which for a DECLARED rate means \"not equal\" and so an\n * update rather than a silent noop. Wrong-but-loud is the right way round here.\n */\nexport const bytes = (value: unknown): number => {\n if (typeof value === 'number') return value;\n const raw = text(value).trim();\n const match = /^([0-9]+(?:\\.[0-9]+)?)\\s*([A-Za-z]*)$/.exec(raw);\n if (match === null) return UNSET;\n const unit = UNITS[match[2] ?? ''];\n return unit === undefined ? UNSET : Math.round(Number(match[1] ?? '0') * unit);\n};\n\n/**\n * The live group filters, joined for a human.\n *\n * ⚠️ DISPLAY ONLY — NEVER SENT, NEVER COMPARED. The ⛔ on the `group-filter` prop says why the field\n * is not declarable; this exists so that a plan against an adopted job SHOWS the filters this\n * resource is deliberately leaving alone, rather than making them invisible.\n * ⚠️ THE SEPARATOR IS ` | `, NOT A COMMA: a `regex:` filter may contain either, so no join here is\n * unambiguous — and a comma is the one that would invite somebody to parse this back.\n */\nexport const filters = (value: unknown): string =>\n Array.isArray(value) ? value.map((entry: unknown) => String(entry)).join(' | ') : text(value);\n\n/**\n * The half of a declaration that create and update both send.\n *\n * ⛔ `remove-vanished` IS ALWAYS SENT, AT ITS DEFAULT INCLUDED, and that is the one field here that\n * breaks the \"undeclared is unmanaged\" rule on purpose. It is always COMPARED (see `matches`), and\n * backup-job.ts records why the two must agree: a field compared against a default but not sent as\n * that default is an update reported on every plan that the PUT never performs. `0` is the\n * direction that does not delete; the prop says why that is still not a free edit.\n * ⚠️ THE TERNARY IS NOT A REFUSAL TO REUSE values.ts's `flag()`; IT IS WHAT `flag()` IS DOCUMENTED\n * NOT TO DO. That coercion answers `undefined` for an undeclared boolean precisely so an omitted\n * field is never sent — it is the tool for \"send it only if declared\", and this is the one field\n * that must be sent ALWAYS. Calling it here types as `string | undefined` and tsc rejects the\n * form (MEASURED: TS2322, \"Type 'undefined' is not assignable to type 'string'\"), which is the\n * type system saying the same thing. replication-job-form.ts writes its always-sent `disable` the\n * same way, for the same reason.\n * ⚠️ `1`/`0` RATHER THAN `true`/`false`: PBS's boolean schema accepts both spellings (DOCUMENTED),\n * and one spelling shared with the PVE families is one fewer thing to keep in step.\n * ⚠️ EVERY OTHER FIELD IS SPREAD IN ONLY WHEN DECLARED. An undeclared key is not sent, so PBS leaves\n * it exactly as it is — which is what makes adopting a hand-made job non-destructive.\n */\nconst shape = (props: SyncJobProps) => ({\n 'remote-store': props['remote-store'],\n 'remove-vanished': props['remove-vanished'] === true ? '1' : '0',\n store: props.store,\n ...(props.comment === undefined ? {} : { comment: props.comment }),\n ...(props['max-depth'] === undefined ? {} : { 'max-depth': String(props['max-depth']) }),\n ...(props.ns === undefined ? {} : { ns: props.ns }),\n ...(props.owner === undefined ? {} : { owner: props.owner }),\n ...(props['rate-in'] === undefined ? {} : { 'rate-in': String(props['rate-in']) }),\n ...(props.remote === undefined ? {} : { remote: props.remote }),\n ...(props['remote-ns'] === undefined ? {} : { 'remote-ns': props['remote-ns'] }),\n ...(props.schedule === undefined ? {} : { schedule: props.schedule }),\n ...(props['verified-only'] === undefined\n ? {}\n : { 'verified-only': props['verified-only'] ? '1' : '0' }),\n ...(props['transfer-last'] === undefined\n ? {}\n : { 'transfer-last': String(props['transfer-last']) }),\n});\n\n/**\n * ⛔ `id` IS SENT AND IS NOT OPTIONAL. PBS's create takes it rather than inventing one, so this\n * family avoids backup-job.ts's worst failure by construction — but only while the id is here.\n * A POST without one would be refused rather than silently duplicating the job, which is the\n * better failure, and it is still not a reason to leave it out.\n * ⛔ `sync-direction` IS THE ONE FIELD SENT ONLY ON CREATE. It decides which side `remove-vanished`\n * deletes from, it is not compared (see `matches`), and on a PBS old enough to have no push\n * support it is an unknown parameter — so sending it on every update would turn every deploy\n * against such a server into a 400 over a field nobody was changing.\n */\nexport const createBody = (props: SyncJobProps): Record<string, string> => ({\n ...shape(props),\n id: props.id,\n ...(props['sync-direction'] === undefined ? {} : { 'sync-direction': props['sync-direction'] }),\n});\n\n/**\n * ⚠️ THE UPDATE IS THE SHARED HALF AND NOTHING ELSE — no `id` (it is the path), no\n * `sync-direction`, no `delete` list. The factory only PUTs when `matches` is false and the form\n * is non-empty, and this form is never empty because `remove-vanished` and the two store names\n * are always present. That is fine here: reconcile reaches this line only when something really\n * does differ, and re-sending the two store names it just compared is a write of what is already\n * there rather than a change.\n */\nexport const updateBody = (props: SyncJobProps): Record<string, string> => shape(props);\n\nexport const handlers = pveHandlers<SyncJobProps, SyncJobAttributes>({\n /**\n * ⛔ NO \"IS IT REALLY THERE\" GUARD, for backup-job.ts's reason: absence is the API declining to\n * answer, which the factory's `read` already handles, not a key missing from an answer that did\n * arrive. Every fallback below is PBS's documented default rather than one picked for\n * convenience, so the answer does not depend on whether a release echoes a key it never wrote.\n * ⛔ EXCEPT `store` AND `remote-store`, WHICH FALL BACK TO `''` RATHER THAN TO THE DECLARED VALUE.\n * They are the only required fields `matches` COMPARES, and a props-shaped fallback would make a\n * malformed answer compare EQUAL — drift that hides itself, where `''` can only be loud. `id`\n * keeps its props fallback: it is the path the object was read by, and is never compared.\n * ⚠️ `digest` IS DELIBERATELY NOT AN ATTRIBUTE. PBS returns one for `sync.cfg` as a FILE, so\n * keeping it would rewrite this resource's state whenever an unrelated sync job was edited —\n * churn that reads like drift. ha-resource.ts hit exactly that on PVE.\n * ⚠️ NEITHER IS THE RUN STATUS. `last-run-state`, `last-run-upid`, `last-run-endtime` and\n * `next-run` come from the LIST endpoint, not from `GET /config/sync/{id}` which this reads.\n * A plan whose output changes every time the job runs is a plan people stop reading.\n */\n attributes: (live, props) => ({\n comment: text(live['comment'], ''),\n 'group-filter': filters(live['group-filter']),\n id: props.id,\n 'max-depth': int(live['max-depth'], UNSET),\n ns: text(live['ns'], ''),\n owner: text(live['owner'], ''),\n 'rate-in': bytes(live['rate-in']),\n remote: text(live['remote'], ''),\n 'remote-ns': text(live['remote-ns'], ''),\n 'remote-store': text(live['remote-store'], ''),\n // ⚠️ PBS answers with a JSON `true`/`false` where PVE answers `1`/`0`; `bool` takes both, and\n // takes the string `'false'` correctly too if some release spells it that way.\n 'remove-vanished': bool(live['remove-vanished'], false),\n schedule: text(live['schedule'], ''),\n // ⚠️ ABSENT MEANS FALSE, the PBS-side default — so an undeclared prop and a job that never had\n // the field compare equal, and adopting one does not plan an edit.\n 'verified-only': bool(live['verified-only'], false),\n store: text(live['store'], ''),\n 'sync-direction': text(live['sync-direction'], 'pull'),\n 'transfer-last': int(live['transfer-last'], UNSET),\n }),\n collection: () => 'config/sync',\n createForm: createBody,\n /**\n * ⛔ ONLY FIELDS A WRITE CAN ACTUALLY SET ARE COMPARED, and on PBS that list is REASONED rather\n * than measured: the published update schema for `PUT /config/sync/{id}` takes every property\n * of the job except its `id`. If a release turns out to refuse one of these, the comparison\n * becomes an update the PUT cannot perform — reported on every plan, forever. That is what the\n * first plan against a live PBS is for.\n * ⚠️ `remove-vanished` IS COMPARED UNCONDITIONALLY — undeclared means false. Every other optional\n * field reads \"not declared, or equal\": undeclared is UNMANAGED, so a schedule, comment, owner,\n * namespace or limit somebody set by hand survives adoption untouched. The destructive one does\n * not get that courtesy, and the price is that adopting a job with it switched on is a real\n * edit, announced only as \"update\" — toward not deleting, and toward a datastore that grows.\n * ⚠️ `store` AND `remote-store` ARE COMPARED UNCONDITIONALLY because PBS requires them at create,\n * so there is no undeclared case to protect. `remote` is NOT: an absent `remote` on an existing\n * job would otherwise plan an update clearing it, and `remote=` is not a value PBS's id schema\n * accepts — a failing PUT on every deploy, over a field the declaration never mentioned.\n * ⚠️ `id`, `group-filter` AND `sync-direction` ARE OUT. The first is the path, a change to which\n * is a different object; the other two are argued on their props in pbs-sync-job.ts.\n */\n matches: (attributes, props) =>\n attributes['remove-vanished'] === (props['remove-vanished'] === true) &&\n attributes.store === props.store &&\n attributes['remote-store'] === props['remote-store'] &&\n (props.remote === undefined || attributes.remote === props.remote) &&\n (props.ns === undefined || attributes.ns === props.ns) &&\n (props['remote-ns'] === undefined || attributes['remote-ns'] === props['remote-ns']) &&\n (props.schedule === undefined || attributes.schedule === props.schedule) &&\n (props.comment === undefined || attributes.comment === props.comment) &&\n (props.owner === undefined || attributes.owner === props.owner) &&\n // ⚠️ NOT COMPARED UNCONDITIONALLY, unlike `remove-vanished`. Turning `verified-only` ON is the\n // safe direction (sync less), so undeclared stays UNMANAGED like every other optional field;\n // `remove-vanished` gets the unconditional treatment because its unsafe direction deletes.\n (props['verified-only'] === undefined ||\n attributes['verified-only'] === props['verified-only']) &&\n (props['rate-in'] === undefined || attributes['rate-in'] === props['rate-in']) &&\n (props['max-depth'] === undefined || attributes['max-depth'] === props['max-depth']) &&\n (props['transfer-last'] === undefined ||\n attributes['transfer-last'] === props['transfer-last']),\n /** ⚠️ A Proxmox safe id has no `/` or `:` in it, so there is nothing here to encode. */\n path: (props) => `config/sync/${props.id}`,\n updateForm: updateBody,\n});\n",
49
+ "/**\n * `Pbs.VerifyJob` — one section of PBS's `verification.cfg`, declared.\n *\n * ★ THIS IS THE FAMILY THAT ANSWERS \"ARE THE BACKUPS ACTUALLY GOOD\", AND NOTHING ELSE IN THIS\n * PACKAGE DOES. A datastore reports free space, a prune job reports that it ran, and every\n * snapshot in the store can still be unreadable: PBS learns a chunk has rotted only when\n * something reads it back and checks its digest, and verification is the only thing that does\n * that on a schedule. An undeclared verify job is the reason nobody notices for months — and a\n * green `Proxmox.BackupJob` makes it worse rather than better, because a vzdump job that says\n * \"OK\" every night is exactly the evidence people stop at.\n *\n * ⛔ THIS FILE CANNOT AUTHENTICATE UNTIL TWO THINGS OUTSIDE IT CHANGE, AND IT IS SHIPPED SAYING SO\n * RATHER THAN SHIPPED LOOKING FINISHED. Both are recorded on `PbsTarget` below:\n * 1. `credentials.ts` has no PBS mint. MEASURED 2026-09-13 from this Mac: the `claude-code`\n * approle is refused `sys/mounts`, `kv/infra/proxmox` and `proxmox-pbs/creds/read` alike —\n * 403 permission denied on all three — so there is no mount to name and none is invented.\n * 2. `client.ts`'s `authorization()` builds a PVE header, and PBS will not accept it. See the\n * ⛔ on `PbsTarget`.\n * Until both land, every call 401s, `pveOperations.read` folds that into \"absent\", and the plan\n * reports `create` for a job that is plainly there. The deploy then FAILS at the POST rather\n * than clobbering anything — an unauthenticated POST 401s, and an authenticated one is refused\n * because PBS will not take a duplicate section id — so the cost is a LYING PLAN and a broken\n * run, not a lost job. That is still reason enough not to wire it into a stack yet: a plan\n * nobody can trust is its own outage.\n *\n * ⚠️ THE SHAPES BELOW ARE READ FROM PUBLISHED SOURCE, NOT MEASURED ON THIS ESTATE. Everything is\n * taken from `pbs-api-types/src/jobs.rs`, `src/api2/config/verify.rs`, `src/server/verify_job.rs`\n * and `src/backup/verify.rs` at HEAD of the Proxmox git mirrors on 2026-09-13. What WAS measured\n * here: `pbs.example.com:8007` and `pbs.mgmt.example.com:8007` both answer HTTP 401 under\n * STRICT TLS (curl `ssl_verify_result=0`), so no `-k` is needed and `client.ts`'s plain `fetch`\n * reaches PBS unchanged. The running host's own schema was NOT read — no credential — so a PBS\n * older than HEAD may differ.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport type { PbsTarget } from './credentials.ts';\nimport { rechecks, shape } from './pbs-verify-job-form.ts';\nimport { type PveRequirements, pveHandlers } from './resource.ts';\nimport { bool, int, text } from './values.ts';\n\nexport interface PbsVerifyJobProps {\n /** ⛔ A PBS host, never a PVE cluster. See `PbsTarget`. */\n target: PbsTarget;\n /**\n * ⛔ The primary key, REQUIRED, and never left to PBS. 3–32 chars of\n * `[A-Za-z0-9_][A-Za-z0-9._-]*`. PBS refuses a duplicate section id outright, which is the loud\n * failure `Proxmox.BackupJob` had to engineer for itself — but only because the id is sent.\n */\n id: string;\n /** Datastore name, 3–32 safe-id chars. ⚠️ MUTABLE — see the ⚠️ on `matches`. */\n store: string;\n /**\n * ⛔ THE KEY IS REQUIRED AND THE VALUE MAY BE `null`. PBS makes the field optional; this family\n * refuses to let you OMIT it, which is not the same thing. A verification job with no schedule\n * never runs on its own and PBS reports it as perfectly healthy — and an absent schedule is also\n * the only way to turn one off, because there is NO `disable` field on a verification job.\n * ⛔ THAT LAST CLAIM IS NOW MEASURED, not read from source. `proxmox-backup-manager verify-job\n * update --help` on the live 4.2 host lists `--delete\n * ignore-verified|comment|schedule|outdated-after|ns|max-depth|read-threads|verify-threads`\n * and no `--disable` anywhere. So `schedule` is deletable — \"parked\" is a state PBS supports —\n * and `disable` genuinely does not exist. pbs-verify-job-form.ts said this was read off the\n * source and NOT verified against a running host; it is now verified, on this one.\n * ★ SO `null` MEANS \"DELIBERATELY PARKED\" AND OMITTING IT IS STILL AN ERROR. The original\n * required-string kept you from declaring verification that never happens, which is right, but\n * it also made a genuinely parked job UNDECLARABLE — and the estate has one: `v-datacenter` is\n * parked because syno1 is powered off, comment and runbook and all. A resource that cannot\n * describe what is really there pushes the operator back to the CLI, which is the failure this\n * package exists to end. Writing `schedule: null` costs a word and says the quiet part out\n * loud; leaving the key out still will not compile.\n * ⚠️ ADOPTING A SCHEDULELESS JOB WITH A SCHEDULE DECLARED GIVES IT ONE ON THE FIRST DEPLOY, which\n * is the intended direction and is still a write nobody asked for in words. `matches` compares\n * `schedule`, the live value reads `''`, so the first reconcile PUTs the declared one and\n * verification starts running that night. Read the first plan against an adopted job.\n * ⚠️ A systemd calendar event. Spelled `daily`, `sat 02:00`, `mon..fri 23:00`. A step expression\n * is legal too and is not written out here: those two characters would close this comment.\n */\n schedule: string | null;\n /**\n * The namespace to verify, e.g. `tier1/prod`. Omitted means the datastore root.\n * ⛔ NEVER SENT AS THE EMPTY STRING. MEASURED in the update handler: `if !ns.is_root()` — a root\n * namespace on a PUT is accepted by the schema, reaches the handler and is then SILENTLY\n * DISCARDED. A job cannot be moved back to the root namespace by this resource at all; that\n * needs `--delete ns` by hand. So an undeclared `ns` is neither sent nor compared.\n */\n ns?: string;\n /**\n * How many namespace levels below `ns` to descend. `0` is that level only; PBS's maximum is 7.\n * ⚠️ PBS's own default is FULL recursion (7), not 0. Undeclared means undeclared here: not sent,\n * not compared, because \"unset\" and \"7\" are stored differently and only one is reachable.\n */\n 'max-depth'?: number;\n /**\n * ⛔ THE HALF OF THE PAIR THAT DECIDES WHETHER THIS JOB EVER RE-CHECKS ANYTHING. Defaults to\n * TRUE. Read `rechecks` and the ⛔ in pbs-verify-job-form.ts before setting either of these.\n */\n 'ignore-verified'?: boolean;\n /** Days after which a past verification is stale. ⛔ See the pair's ⛔ in the form file. */\n 'outdated-after'?: number;\n /** ⚠️ PBS TRIMS IT AND STORES AN EMPTY ONE AS ABSENT, so `' '` reads back as `''`. */\n comment?: string;\n}\n\nexport interface PbsVerifyJobAttributes {\n id: string;\n store: string;\n schedule: string;\n ns: string;\n /** ⚠️ `-1` means \"no max-depth in the section\". `0` is a real setting meaning no recursion. */\n 'max-depth': number;\n 'ignore-verified': boolean;\n /** ⚠️ `-1` means \"unset\", which is NOT `0`. See the ⛔ in the form file. */\n 'outdated-after': number;\n comment: string;\n /**\n * ★ WHAT THIS JOB ACTUALLY RE-CHECKS, IN ENGLISH, COMPUTED FROM THE LIVE PAIR. REPORTED, NEVER\n * COMPARED — it is derived from two fields `matches` already compares, so diffing it would\n * double-count them. It exists because the failure this family guards against is a job that\n * looks healthy in every column and verifies each snapshot exactly once, ever; that job reads\n * `never` here. A plan line is the only place anyone will see it.\n */\n rechecks: string;\n}\n\nexport interface PbsVerifyJob extends Resource<\n 'Pbs.VerifyJob',\n PbsVerifyJobProps,\n PbsVerifyJobAttributes,\n never,\n PveRequirements\n> {}\n\n/**\n * ⚠️ NO `defaultRemovalPolicy: 'retain'`, DELIBERATELY, AND IT IS THE CLOSER CALL THAN IT LOOKS.\n * The section holds no data — deleting it destroys nothing, the way `Proxmox.BackupJob`'s delete\n * destroys no archives. What it destroys is the CHECKING, silently and permanently, and PBS will\n * not refuse it the way it refuses to remove a datastore in use. `retain` would hide that behind\n * a state-row drop instead of showing it as a plan line, and the plan line is the only warning\n * anyone gets. Pipe `RemovalPolicy.retain()` per declaration where the job must outlive the code.\n */\nexport const PbsVerifyJob = Resource<PbsVerifyJob>('Pbs.VerifyJob');\n\n/**\n * ⚠️ EVERY FIELD IS READ THROUGH `values.ts` THOUGH PBS RETURNS REAL JSON TYPES. Unlike PVE's\n * SectionConfig round-trip, `GET /config/verify/{id}` serialises a Rust struct, so\n * `ignore-verified` arrives as a JSON boolean and `max-depth` as a JSON number. `bool` and `int`\n * accept both spellings, and using them costs nothing while covering the version that does not.\n * ⚠️ `digest` IS NOT AN ATTRIBUTE AND CANNOT BECOME ONE BY ACCIDENT. PBS puts it on the rpcenv, and\n * the JSON formatter adds rpcenv attributes as SIBLINGS of `data` — `{\"data\":{…},\"digest\":\"…\"}` —\n * so `client.ts`, which returns `body.data`, never sees it. That is lucky rather than designed:\n * the digest covers verification.cfg as a FILE, so keeping it would churn this resource's state\n * whenever an unrelated verify job was edited.\n */\nconst handlers = pveHandlers<PbsVerifyJobProps, PbsVerifyJobAttributes>({\n attributes: (live, props) => {\n const ignoreVerified = bool(live['ignore-verified'], true);\n const outdatedAfter = int(live['outdated-after'], -1);\n return {\n comment: text(live['comment'], ''),\n id: props.id,\n 'ignore-verified': ignoreVerified,\n 'max-depth': int(live['max-depth'], -1),\n ns: text(live['ns'], ''),\n 'outdated-after': outdatedAfter,\n rechecks: rechecks(ignoreVerified, outdatedAfter),\n schedule: text(live['schedule'], ''),\n store: text(live['store'], props.store),\n };\n },\n /**\n * 🔴 THIS WAS `config/verification` AND PBS ANSWERS 404 FOR IT. MEASURED on the live 4.2 server:\n * `GET /api2/json/config/verification` -> 404 \"Path not found\"; `GET /api2/json/config/verify`\n * -> 200 with both jobs. The struct is `VerificationJobConfig` and the CLI subcommand is\n * `verify-job`, so the long spelling reads right and is simply not the route.\n * ⛔ THE FAILURE MODE IS THE ONE THIS PACKAGE KEEPS FINDING: `read` folds every failure into\n * `undefined`, so a 404 from a WRONG PATH is indistinguishable from an object that is not\n * there. The first plan against the live estate said `create` for two verification jobs that\n * have existed for weeks — and a create would then have POSTed to a 404 as well, so it fails\n * loudly rather than duplicating anything. Nothing caught it earlier because no verification\n * job had ever been declared; registering the provider exercises no path at all.\n */\n collection: () => 'config/verify',\n /** ⛔ `id` IS SENT. PBS refuses a duplicate id, and that refusal is this family's safety net. */\n createForm: (props) => ({ ...shape(props), id: props.id }),\n /**\n * ⚠️ AN UNDECLARED FIELD IS NEITHER SENT NOR COMPARED — the `Proxmox.BackupJob` trade, for the\n * same reason and with one extra: this form carries NO `delete` list, so there is nothing it\n * could clear even if it wanted to. See the ⛔ on `withClears` in pbs-verify-job-form.ts.\n * ⚠️ `store` IS COMPARED AND IS MUTABLE, which is unusual and worth reading twice. PBS's update\n * handler assigns it and re-checks privileges on both the old and the new path, so changing\n * `store` MOVES the job — and the datastore it left is then verified by nothing. That is a\n * one-word edit with the same effect as deleting the job, and it plans as a quiet `update`.\n * ⚠️ `rechecks` IS ABSENT HERE ON PURPOSE. It is a rendering of the two fields on the lines\n * above; comparing it too would report the same drift twice.\n */\n matches: (attributes, props) =>\n attributes.store === props.store &&\n // ⚠️ `null` IS COMPARED AGAINST `''`, NOT SKIPPED. A parked job is a declaration like any\n // other, so declaring `null` against a job that HAS a schedule must plan an update — the\n // form then omits `schedule`, which is a set-only form, so see the ⛔ on clearing below.\n attributes.schedule === (props.schedule ?? '') &&\n attributes['ignore-verified'] === (props['ignore-verified'] !== false) &&\n (props['outdated-after'] === undefined ||\n attributes['outdated-after'] === props['outdated-after']) &&\n (props['max-depth'] === undefined || attributes['max-depth'] === props['max-depth']) &&\n (props.ns === undefined || attributes.ns === props.ns) &&\n (props.comment === undefined || attributes.comment === props.comment),\n path: (props) => `config/verify/${props.id}`,\n updateForm: shape,\n});\n\n/**\n * ⛔ `list` IS EMPTY, INHERITED FROM `pveHandlers`, AND THE REASON IS SHARPER HERE THAN ELSEWHERE.\n * `GET /config/verify` returns every verification job the caller can see, including the\n * ones the PBS installer and a human made. Adopting those would put Alchemy one dropped line\n * away from DELETING a datastore's only verification schedule — and deleting it destroys nothing\n * visible, so the loss is discovered the day a restore fails and there is no verification history\n * to say when the rot started. Adoption stays explicit: declare the existing id.\n *\n * ⚠️ NO `digest` IS SENT ON UPDATE OR DELETE, SO THIS IS LAST-WRITER-WINS. PBS accepts an optional\n * `digest` on both and would refuse a write made against a stale read. Sending one would need a\n * read-then-write window this provider does not have — `pveOperations` reads and writes in two\n * separate calls with two separate mints — so a concurrent edit from the PBS UI is overwritten\n * rather than refused. Same behaviour as every PVE family here; stated because PBS offers better.\n */\nexport const PbsVerifyJobProvider = () =>\n Provider.effect(PbsVerifyJob, Effect.succeed(PbsVerifyJob.Provider.of(handlers)));\n",
50
+ "/**\n * A verification job's props as the form PBS wants, and the one derived string worth reporting.\n *\n * ★ SPLIT OUT OF pbs-verify-job.ts TO KEEP BOTH FILES UNDER THE 250-LINE CAP, on the seam\n * replication-job-form.ts and ha-rule-form.ts already cut: this file answers \"how does a\n * declaration become a PBS write, and what do the two filter fields actually mean\", and\n * pbs-verify-job.ts answers \"what is a verification job and when has it changed\". Nothing here\n * reads the host and nothing here decides a diff.\n *\n * ⚠️ THE `import type` BACK TO pbs-verify-job.ts IS A CYCLE ON PAPER ONLY — type-only, erased\n * before anything runs, and `PbsVerifyJobProps` stays public in the file declaring the resource.\n *\n * ⛔ THERE IS NO `disable` FIELD ON A PBS VERIFICATION JOB, AND SHIPPING A PROP FOR ONE WOULD HAVE\n * BEEN THE WORST BUG IN THIS FAMILY. Prune jobs have `disable` and sync jobs have `disable`;\n * `VerificationJobConfig` does not, in the struct, in the API schema, or in the update handler's\n * `DeletableProperty` enum — read at HEAD of pbs-api-types and src/api2/config/verify.rs on\n * 2026-09-13. A `disable` prop would therefore be a prop that either does nothing or 400s the\n * whole call (the create schema has `additional_properties: false`, so an unknown key is\n * rejected with \"schema does not allow additional properties\"). Either way it would be a\n * declaration saying \"verification is paused\" that PBS never agreed to. The real off switch is\n * an absent `schedule`.\n * ★ NOW VERIFIED AGAINST THE RUNNING HOST, which this comment previously said it was not.\n * `proxmox-backup-manager verify-job update --help` on the live 4.2 server offers\n * `--comment --delete --digest --ignore-verified --max-depth --ns --outdated-after\n * --read-threads --schedule --store --verify-threads` — no `--disable` — and its `--delete`\n * enum contains `schedule`. Both halves of the claim hold on this estate's actual version.\n * ⚠️ `read-threads` AND `verify-threads` EXIST ON 4.2 AND ARE NOT PROPS HERE. Nothing on this\n * estate sets either, and a prop nobody uses is an abstraction with no user — the same reason\n * `PveSpec.immutable` was backed out. Add them when something needs them.\n *\n * ⛔ `withClears` FROM values.ts IS DELIBERATELY NOT USED HERE, AND USING IT WOULD BREAK EVERY\n * UPDATE. PVE's `delete` is ONE comma-separated string; PBS's is an ARRAY of an enum. MEASURED in\n * proxmox-schema's `do_parse_parameter_strings`: for an `Schema::Array` property each occurrence\n * of the key pushes ONE element, so a form body must REPEAT the key — `delete=ns&delete=comment`.\n * `withClears` emits `delete: 'ns,comment'`, which PBS parses as a single element `\"ns,comment\"`,\n * which is not a `DeletableProperty` variant, so the call fails with a parameter error. It fails\n * loudly rather than quietly, which is the only good news in it.\n * ★ AND IT COULD NOT BE FIXED IN THIS FILE ANYWAY. `client.ts` types a form as\n * `Record<string, string>` and builds it with `new URLSearchParams(form)`; neither a plain\n * object nor that constructor overload can express a repeated key. Clearing a PBS field needs\n * a client that takes entry pairs. Until one exists, this form SETS and never CLEARS — so an\n * undeclared field is left alone and, in pbs-verify-job.ts, is not compared either.\n */\nimport type { PbsVerifyJobProps } from './pbs-verify-job.ts';\n\n/**\n * What the live pair actually causes, rendered for a plan line.\n *\n * ⛔ THE DEFAULTS MEAN \"VERIFY EACH SNAPSHOT EXACTLY ONCE, EVER\", AND THAT IS THE FAILURE THIS\n * WHOLE FAMILY EXISTS TO MAKE VISIBLE. Read from src/backup/verify.rs `verify_filter` and\n * src/server/verify_job.rs at HEAD on 2026-09-13, the filter is:\n *\n * ignore_verified = ignore_verified.unwrap_or(true) // absent means TRUE\n * if !ignore_verified -> verify\n * manifest has no verify state -> verify\n * outdated_after is None -> SKIP, forever\n * days_since_last_verify > outdated_after -> verify\n *\n * So a job created with neither field set — the shape the PBS web UI produces when nobody\n * touches those two boxes — checks every snapshot once on the run after it is written and then\n * never looks at it again. Bit rot that appears a month later is never found. The job stays\n * green the entire time, because a job that verified nothing verified nothing badly.\n *\n * ⚠️ A FAILED PAST VERIFICATION IS SKIPPED TOO. `verify_filter` looks only at whether a verify\n * state EXISTS, never at whether it says Ok or Failed, so a snapshot that failed once is not\n * re-checked by a defaulted job either. Pair that with a prune job and the failure ages out\n * without anyone confirming it.\n *\n * ⛔ `outdated-after: 0` DOES NOT MEAN \"NEVER\", THOUGH PBS'S OWN STRUCT DOC SAYS IT DOES. That\n * comment — \"Reverify snapshots after X days, never if 0\" — contradicts the code beside it: the\n * test is `days_since_last_verify > max_age`, so `0` re-verifies everything checked more than a\n * day ago, i.e. very nearly every run. The schema text calls `0` deprecated and the minimum is\n * `0`, so it is accepted. \"Never\" is the ABSENT value, not the zero — and this resource cannot\n * get a job back to absent (see the ⛔ on `withClears` above), so a declaration that sets\n * `outdated-after` has made a one-way choice. Undo it by hand:\n * `proxmox-backup-manager verify-job update <id> --delete outdated-after`.\n *\n * ⚠️ THE COMPARISON IS INTEGER DAYS SINCE THE LAST RUN'S START, `(now - upid.starttime) / 86400`,\n * and it is strictly greater-than. `outdated-after: 30` therefore re-checks on day 31.\n */\nexport const rechecks = (ignoreVerified: boolean, outdatedAfter: number): string => {\n if (!ignoreVerified) return 'every snapshot on every run';\n // ⚠️ `-1` is this package's spelling of \"the key is absent\", set in `attributes`. It is not a\n // value PBS accepts: the schema's minimum is 0.\n if (outdatedAfter < 0) return 'never: each snapshot is checked once and then skipped forever';\n return `once the last check is more than ${String(outdatedAfter)} day(s) old`;\n};\n\n/**\n * The form for create and update alike.\n *\n * ⛔ `schedule: null` OMITS THE KEY, AND ON AN UPDATE THAT DOES NOT CLEAR AN EXISTING ONE. This\n * form SETS and never CLEARS — the ⛔ on `withClears` above is why — so declaring `null` against\n * a job that already has a schedule plans an update that changes nothing, every time. Park a job\n * by hand once and the declaration then describes it truthfully:\n * `proxmox-backup-manager verify-job update <id> --delete schedule`. The honest failure is a\n * plan that keeps asking; the dishonest one would be a form that quietly reported success.\n *\n * ⚠️ `store` AND `ignore-verified` ARE ALWAYS SENT BECAUSE THEY ARE ALWAYS COMPARED.\n * A field compared against a default but not sent as that default is an update reported on every\n * plan that the write never performs — backup-job.ts and replication-job-form.ts both record the\n * same trade. `ignore-verified` is the only one of the three with a PBS-side default, and it is\n * TRUE, so an undeclared prop is sent as `1` rather than left out.\n *\n * ⚠️ THE BOOLEAN IS SPELLED INLINE RATHER THAN THROUGH `flag()` FROM values.ts, AND THAT IS A TYPE\n * FACT RATHER THAN A STYLE ONE. `flag` answers `'1' | '0' | undefined` so that an undeclared\n * field is dropped; here the field must never be dropped, and the `undefined` in its return type\n * is not assignable to a `Record<string, string>` form body.\n *\n * ⚠️ PBS ACCEPTS BOTH `application/x-www-form-urlencoded` AND `application/json` AND NOTHING ELSE —\n * any other content type is rejected outright with \"unsupported content type\", measured in\n * proxmox-rest-server's `get_request_parameters`. `client.ts` sends the form encoding whenever a\n * body is present, so it is already speaking one of the two. Numbers are stringified here for\n * that reason; PBS parses them back through the integer schema.\n *\n * ⛔ `ns` IS DROPPED WHEN IT IS EMPTY, NOT SENT AS `''`. The empty string IS a legal namespace\n * value — `BACKUP_NS_RE` is wrapped in `(?:…)?`, so it passes the schema and reaches the update\n * handler — and the handler then throws it away at `if !ns.is_root()`. Sending it would look like\n * a write that moves the job to the root namespace and would silently be nothing at all.\n */\nexport const shape = (props: PbsVerifyJobProps): Record<string, string> => ({\n 'ignore-verified': props['ignore-verified'] === false ? '0' : '1',\n store: props.store,\n ...(props.schedule === null ? {} : { schedule: props.schedule }),\n ...(props.comment === undefined ? {} : { comment: props.comment }),\n ...(props['max-depth'] === undefined ? {} : { 'max-depth': String(props['max-depth']) }),\n ...(props.ns === undefined || props.ns === '' ? {} : { ns: props.ns }),\n ...(props['outdated-after'] === undefined\n ? {}\n : { 'outdated-after': String(props['outdated-after']) }),\n});\n",
51
+ "/**\n * `Proxmox.Pool` — a PVE resource pool. Guests grouped for permissions and quota.\n *\n * ★ PROVEN END TO END AGAINST THE LIVE CLUSTER, 2026-09-13. create -> verified with `pvesh get\n * /pools` on the node rather than by believing Alchemy; second plan -> `no changes / noop`; then\n * the comment was edited ON THE CLUSTER and plan said `1 to update`, and a deploy repaired it.\n * That drift case is the one that matters: `diff` reads the LIVE pool, so a provider trusting\n * its own state would have reported noop straight past a hand-edit in the UI.\n *\n * ⚠️ IT 403'd UNTIL THE ROLE WAS WIDENED, AND THE HISTORY IS WORTH KEEPING. `hf-provision@pve`\n * held `LXCProvisioner` on `/` with no `Pool.Allocate`, so reconcile answered\n * \"Permission check failed (/pool/house, Pool.Allocate)\". The credential could not widen itself\n * — `PUT /access/roles` is 403 for it too — so the role was extended over SSH with\n * `pveum role modify LXCProvisioner --privs \"<existing>,Pool.Allocate,Pool.Audit\"`, preserving\n * every existing privilege. Each new resource in this package should state the privileges its\n * reconcile needs, so widening stays a deliberate act rather than a reaction to a 403.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport type {\n PoolsPoolidGetReturn,\n PoolsPoolidPutParams,\n PoolsPostParams,\n} from './generated/pve.ts';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\n\nexport interface PoolProps extends WithTarget {\n /** PVE's primary key for a pool. Changing it is a replace, not an update. */\n poolid: string;\n /** Free text shown in the UI — the only mutable field a pool has. */\n comment?: string;\n}\n\nexport interface PoolAttributes {\n poolid: string;\n comment: string;\n /** Guests currently in the pool, so a plan can say what a delete would refuse to orphan. */\n members: number;\n}\n\nexport interface ProxmoxPool extends Resource<\n 'Proxmox.Pool',\n PoolProps,\n PoolAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxPool = Resource<ProxmoxPool>('Proxmox.Pool');\n\n/** Form bodies this family sends — exported for the drift test in pool.test.ts. */\nexport const poolCreateForm = (props: PoolProps): PoolsPostParams => ({\n comment: props.comment ?? '',\n poolid: props.poolid,\n});\n\n/** PUT body — only `comment`; path carries `poolid`. Matches deprecated `/pools/{poolid}`. */\nexport const poolUpdateForm = (props: PoolProps): Pick<PoolsPoolidPutParams, 'comment'> => ({\n comment: props.comment ?? '',\n});\n\nconst handlers = pveHandlers<PoolProps, PoolAttributes>({\n attributes: (live, props) => {\n const row = live as PoolsPoolidGetReturn;\n return {\n comment: typeof row.comment === 'string' ? row.comment : '',\n members: Array.isArray(row.members) ? row.members.length : 0,\n poolid: props.poolid,\n };\n },\n collection: () => 'pools',\n createForm: poolCreateForm,\n matches: (attributes, props) => attributes.comment === (props.comment ?? ''),\n path: (props) => `pools/${props.poolid}`,\n updateForm: poolUpdateForm,\n});\n\nexport const ProxmoxPoolProvider = () =>\n Provider.effect(ProxmoxPool, Effect.succeed(ProxmoxPool.Provider.of(handlers)));\n",
52
+ "/**\n * `Proxmox.Vm` — a QEMU virtual machine, declared.\n *\n * ⚠️ THE SAME FOUR OPERATIONS AS AN LXC OVER A DIFFERENT PATH, which is the point of the factory:\n * `nodes/{node}/qemu` to create, `nodes/{node}/qemu/{vmid}/config` to read and update. A VM and a\n * container differ in what they carry, not in how they are reconciled.\n *\n * ⛔ `vmid` IS CLUSTER-WIDE AND SHARED WITH CONTAINERS. A VM and an LXC cannot hold the same id, so\n * these two resources compete for one number space. Declaring both with vmid 101 is not a\n * collision Alchemy can see -- they are different resource types -- and PVE refuses the second\n * with \"already exists\". Pick ids per cluster, not per kind.\n *\n * ⚠️ POWER STATE IS REPORTED, NEVER DECLARED. `status` is an attribute so a plan can show it; there\n * is no `running` prop. Starting and stopping a VM from a plan would make a deploy a maintenance\n * window, and the estate has one of those already.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { num } from './values.ts';\n\nexport interface VmProps extends WithTarget {\n node: string;\n /** ⛔ Cluster-wide, and shared with LXC. See the ⛔ above. */\n vmid: number;\n name?: string;\n /** MiB. */\n memory?: number;\n cores?: number;\n sockets?: number;\n /** e.g. `virtio=<mac>,bridge=vmbr0`. */\n net0?: string;\n onboot?: boolean;\n}\n\nexport interface VmAttributes {\n vmid: number;\n node: string;\n name: string;\n memory: number;\n cores: number;\n sockets: number;\n onboot: boolean;\n}\n\nexport interface ProxmoxVm extends Resource<\n 'Proxmox.Vm',\n VmProps,\n VmAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxVm = Resource<ProxmoxVm>('Proxmox.Vm');\n\nconst shape = (props: VmProps) => ({\n cores: String(props.cores ?? 1),\n memory: String(props.memory ?? 512),\n name: props.name ?? `vm${String(props.vmid)}`,\n onboot: props.onboot === true ? '1' : '0',\n sockets: String(props.sockets ?? 1),\n ...(props.net0 === undefined ? {} : { net0: props.net0 }),\n});\n\nconst handlers = pveHandlers<VmProps, VmAttributes>({\n attributes: (live, props) => ({\n cores: num(live['cores'], 1),\n memory: num(live['memory'], 512),\n name: typeof live['name'] === 'string' ? live['name'] : '',\n node: props.node,\n onboot: live['onboot'] === 1 || live['onboot'] === true,\n sockets: num(live['sockets'], 1),\n vmid: props.vmid,\n }),\n collection: (props) => `nodes/${props.node}/qemu`,\n createForm: (props) => ({ ...shape(props), vmid: String(props.vmid) }),\n matches: (attributes, props) =>\n attributes.name === (props.name ?? `vm${String(props.vmid)}`) &&\n attributes.memory === (props.memory ?? 512) &&\n attributes.cores === (props.cores ?? 1) &&\n attributes.sockets === (props.sockets ?? 1) &&\n attributes.onboot === (props.onboot === true),\n path: (props) => `nodes/${props.node}/qemu/${String(props.vmid)}/config`,\n updateForm: shape,\n});\n\nexport const ProxmoxVmProvider = () =>\n Provider.effect(ProxmoxVm, Effect.succeed(ProxmoxVm.Provider.of(handlers)));\n",
53
+ "/**\n * `Proxmox.ReplicationJob` — a guest's ZFS storage replication to a second node, declared.\n *\n * ⛔ NOTHING ON TB4 CAN USE THIS FAMILY, AND THAT IS SAID HERE RATHER THAN FOUND OUT LATER. PVE\n * storage replication is ZFS-only: `POST /cluster/replication` calls `get_replicatable_volumes`\n * and refuses a guest whose disks are anywhere else with \"No replicatable volumes found\". TB4 is\n * Ceph/RBD-backed — shared storage, where replication means nothing because every node already\n * sees the volume — so `GET /cluster/replication` answers `[]` (MEASURED on n2, 2026-09-13) and\n * on this cluster always will. The file is written for a ZFS cluster; against TB4 a declaration\n * is a create that fails with PVE's own sentence, not a plan that quietly does nothing.\n *\n * ★ WHAT IS MEASURED HERE AND WHAT IS REASONED. Measured on n2 (pve-manager 9.2.11), read-only:\n * the published schema for all five methods; `PVE/ReplicationConfig.pm` and\n * `PVE/API2/ReplicationConfig.pm` line by line; `GET /cluster/replication` -> `[]`; and the ACL\n * row `{\"path\":\"/\",\"propagate\":1,\"roleid\":\"PVEAuditor\",\"ugid\":\"hf-read@pve\"}`. NOT measured: any\n * round trip. There is no live job to adopt and none can be created on this cluster, so the\n * argument that a matching declaration plans as `noop` rests on the schema and on PVE's own\n * source — not on a plan anybody ran. Nobody should claim otherwise until a ZFS cluster exists.\n *\n * ⛔ THE ID IS STRUCTURED AND PVE RE-SPELLS IT, so this resource is keyed on the two numbers rather\n * than on the string — a deliberate break from `backup-job.ts`'s \"props are PVE's own key names\".\n * MEASURED: `parse_replication_job_id` matches `^(\\d+)-(\\d+)$`, runs BOTH halves through `int()`\n * and returns \"$guest-$jobnum\", and `parse_section_header` does the same when reading\n * replication.cfg. So a declared `100-007` is read back as `100-7`, and a provider holding the\n * raw string would compare two spellings of one id forever. Two numbers cannot be spelled two\n * ways. PVE also refuses `guest < 100` (\"guest IDs < 100 are reserved\") and the API pattern\n * `[1-9][0-9]{2,8}-\\d{1,9}` caps both halves at nine digits.\n * ⛔ BOTH HALVES ARE REQUIRED AND NEITHER IS DEFAULTED, for `backup-job.ts`'s reason: a provider\n * that picks a job number picks a DIFFERENT job from the one a person meant, and then adopts or\n * creates beside the real one. Declare the numbers of the job you mean.\n *\n * ⛔ PVE'S `target` AND THIS PACKAGE'S `target` ARE DIFFERENT THINGS, AND THE COMPILER SAID SO\n * BEFORE A REVIEWER DID. Every resource here extends `WithTarget`, whose `target` is the CLUSTER\n * a call goes to (`PveTarget`, carrying the API base and the credential mount). PVE's replication\n * `target` is a NODE NAME. They cannot both be called `target` in one props interface — tsc:\n * \"Interface 'ReplicationJobProps' incorrectly extends interface 'WithTarget'\" — so the prop and\n * the attribute are `targetNode`, and PVE's spelling appears exactly once, in `createBody`, where\n * it is the wire key. That is the only safe shape: had the collision been resolvable by silence,\n * `createForm` would have serialised a whole `PveTarget` object into a form field called `target`\n * and PVE would have answered that the node does not exist.\n *\n * ⛔ ONE JOB PER (GUEST, TARGET), ENFORCED BY PVE AND NOT BY THIS FILE. MEASURED: `write_config`\n * dies \"replication job for guest '$vmid' to target '$tid' already exists\" where `$tid` is\n * `local/<target>`, and `parse_config` DELETES the loser on read if two ever reach the file. Two\n * declarations differing only in `jobnum` but naming the same target are not two jobs; the second\n * is a create that fails.\n *\n * ⚠️ RECONCILE NEEDS `VM.Replicate` ON `/vms/<guest>`, WHICH `LXCProvisioner` DOES NOT HOLD. All\n * three writes check it (MEASURED in API2/ReplicationConfig.pm: create, update and delete each\n * call `$rpcenv->check($authuser, \"/vms/$vmid\", ['VM.Replicate'])`), and the role's 27 privileges\n * include `VM.Allocate`, `VM.Audit`, `VM.Backup`, `VM.Config.*` and `VM.PowerMgmt` but not\n * `VM.Replicate`. Widen it deliberately over SSH, preserving what is there, as `pool.ts` records:\n * `pveum role modify LXCProvisioner --privs \"<existing>,VM.Replicate\"`.\n * ★ THE READ LANE NEEDS NOTHING EXTRA, which is why there is no `readRole` below. The ITEM read\n * checks `VM.Audit` on `/vms/<guest>`, `hf-read@pve` holds the built-in `PVEAuditor` at `/`\n * with propagate — both MEASURED — and `PVEAuditor` carries `VM.Audit`. This family is not a\n * fourth one that must borrow the provision lease.\n * ⚠️ A MISSING JOB IS A 500, NOT A 404 — \"no such replication job '100-0'\" — and the factory\n * folds any failed read into \"absent\", so a 403 reads as absent too. A plan insisting on\n * creating a job that plainly exists is a credential problem; the honest error arrives one step\n * later, from the create.\n *\n * ⛔ DELETE DOES NOT DELETE, AND A DESTROY IS NOT FREE. MEASURED: with neither `force` nor `keep` —\n * and the factory's `destroy` sends no form at all — the handler only sets `remove_job = 'full'`\n * on the job and writes the config back. The job stays in replication.cfg until the SOURCE node's\n * `pvesr` timer next runs it, at which point it removes the local replication snapshots, removes\n * the replicated volumes on the target, and finally removes itself. So a destroy costs the\n * standby copy and the incremental base: re-declaring the job afterwards is a FULL send, not a\n * resume. The guest's own disks are untouched, which is exactly why this family does NOT carry\n * `defaultRemovalPolicy: 'retain'` the way `ZfsPool` and `Storage` do — what it destroys is a\n * copy a re-sync rebuilds, expensively, rather than something irreplaceable.\n * ⚠️ AND IF THE SOURCE NODE IS DOWN THE REMOVAL NEVER RUNS. Alchemy drops the state row on a\n * DELETE that returned no error, so a destroy against a dead source leaves a marked job on the\n * cluster that nothing declares any more. `GET /cluster/replication` is where it shows up.\n *\n * ⚠️ THE RUNTIME STATUS IS NOT HERE, AND NOT BECAUSE IT WAS FORGOTTEN. `last_sync`, `last_try`,\n * `fail_count`, `error`, `duration` and `pid` come from the per-node replication STATE file and\n * are merged in by `GET /nodes/{node}/replication` (MEASURED: API2/Replication.pm line 179,\n * `foreach my $k (qw(last_sync last_try fail_count error duration))`). `GET\n * /cluster/replication/{id}` — the only endpoint this resource reads — returns not one of them.\n * Reporting them would mean a second, per-node call on the read path answering a different value\n * every fifteen minutes, and a plan whose output changes when nothing changed is a plan people\n * stop reading. Ask the node for status; ask the cluster for configuration.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { DEFAULT_SCHEDULE, createBody, jobId, updateBody } from './replication-job-form.ts';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { bool, int, text } from './values.ts';\n\nexport interface ReplicationJobProps extends WithTarget {\n /** ⛔ The guest being replicated. 100 or above — PVE reserves everything below. Identity. */\n guest: number;\n /** ⛔ The job number within that guest, 0 upwards. Identity. Never generated — see the header. */\n jobnum: number;\n /**\n * ⛔ THE NODE THE COPY LANDS ON — PVE's `target`, RENAMED; see the ⛔ in the header — AND IT IS\n * CREATE-ONLY. MEASURED: the plugin declares `target => { fixed => 1, optional => 0 }`, so\n * `updateSchema()` omits it entirely — `PUT` has no `target` parameter at all, and\n * `delete=target` answers \"unable to delete fixed option\". It is therefore NOT compared; see\n * the ⚠️ on `matches`. Changing it in a declaration plans as NOOP. Retire the declaration and\n * add another, exactly as `user.ts` says for `userid`.\n * ⚠️ PVE refuses a target equal to the guest's current node (\"Source and target must not be\n * identical\") and one that is not a cluster member. Neither is checkable from here.\n */\n targetNode: string;\n /**\n * A subset of systemd calendar events. Unset means PVE's own default — `DEFAULT_SCHEDULE`,\n * every fifteen minutes — and that default is what gets SENT and compared, not silence.\n * ⚠️ THIS COMPARES STRINGS, NOT MEANINGS. A calendar event has many equivalent spellings and\n * PVE stores the one it was handed, verbatim, so declare the spelling the cluster echoes.\n */\n schedule?: string;\n /** Rate limit in mbps as a float, 1 or above. Unset sends nothing and compares nothing. */\n rate?: number;\n /** Keep the job but stop replicating. Unset is an ACTIVE job, and that is what is compared. */\n disable?: boolean;\n /** Free text shown in the UI. Round-trips through PVE's `encode_text`/`decode_text`. */\n comment?: string;\n}\n\nexport interface ReplicationJobAttributes {\n /** `100-0`, in PVE's own int-parsed spelling. */\n id: string;\n /**\n * ⚠️ REPORTED AS INTEGERS, NEVER COMPARED, AND THIS IS THE \"id written as a name\" TRAP. MEASURED:\n * `parse_config` sets both from the section header via `int()`, so they are the id re-spelled\n * as numbers and no write accepts either. Compared against anything they would be an update\n * forever; reported, they let a plan say which guest is about to lose a replica.\n */\n guest: number;\n jobnum: number;\n /** Always `local` — the only section type PVE registers. Create-only, reported, not compared. */\n type: string;\n /**\n * ⚠️ REPORTED, NEVER COMPARED. Create-only AND rewritten by PVE — see `matches`. Named for the\n * prop rather than for PVE's wire key `target`, so that one file never means two things by one\n * word; the header says why the wire name could not be kept.\n */\n targetNode: string;\n /** ⚠️ REPORTED, NEVER SENT. PVE's own bookkeeping — see the ⛔ in replication-job-form.ts. */\n source: string;\n schedule: string;\n /** 0 when unset. See `rateOf`. */\n rate: number;\n disable: boolean;\n comment: string;\n /**\n * `''`, `local` or `full`. ⛔ NOT COSMETIC: a non-empty value is a job that is deleting itself,\n * so `matches` refuses it and `updateBody` clears it. See both.\n */\n remove_job: string;\n}\n\nexport interface ProxmoxReplicationJob extends Resource<\n 'Proxmox.ReplicationJob',\n ReplicationJobProps,\n ReplicationJobAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxReplicationJob = Resource<ProxmoxReplicationJob>('Proxmox.ReplicationJob');\n\n/**\n * ⚠️ `rate` IS THE ONLY FLOAT IN THIS PACKAGE, so it gets a coercion of its own rather than a sixth\n * entry in `values.ts` — the rule that module states for itself: a coercion only one PVE object\n * needs belongs in that object's file, next to the field it serves. `int` cannot serve it, since\n * `Number.parseInt('10.5')` is 10 and a rate silently rounded down is both a limit nobody chose\n * and a comparison that never settles. It accepts a string for the reason `int` does: these are\n * SectionConfig sections, and whether `10` arrives as a number is a property of the release.\n * ⚠️ 0 MEANS UNSET, and is safe as the marker because PVE's schema gives `rate` a minimum of 1 —\n * the same trick as `metric-server.ts`'s `UNSET = -1`, for the same reason.\n */\nconst rateOf = (value: unknown): number => {\n if (typeof value === 'number') return value;\n const parsed = Number.parseFloat(text(value));\n return Number.isFinite(parsed) ? parsed : 0;\n};\n\nconst handlers = pveHandlers<ReplicationJobProps, ReplicationJobAttributes>({\n /**\n * ⚠️ EVERY FALLBACK IS PVE'S DOCUMENTED DEFAULT, NOT `false`/`''` PICKED FOR CONVENIENCE, so the\n * answer does not depend on whether a given release echoes back a key it never wrote.\n * SectionConfig stores what it was handed; a job created in the UI without a schedule has no\n * schedule line, and reading that absence as anything but `DEFAULT_SCHEDULE` would report\n * drift on a job nobody touched and then WRITE the reading back.\n * ⛔ NO \"IS IT REALLY THERE\" GUARD, for `backup-job.ts`'s reason: absence is the API declining to\n * answer, which `pveOperations.read` already handles, not a key missing from an answer that did\n * arrive. `digest` is deliberately absent too — it changes when ANY job in the file changes,\n * including one somebody else declared (`ha-resource.ts` hit exactly that).\n */\n attributes: (live, props) => ({\n comment: text(live['comment'], ''),\n disable: bool(live['disable'], false),\n guest: int(live['guest'], props.guest),\n id: text(live['id'], jobId(props)),\n jobnum: int(live['jobnum'], props.jobnum),\n rate: rateOf(live['rate']),\n remove_job: text(live['remove_job'], ''),\n schedule: text(live['schedule'], DEFAULT_SCHEDULE),\n source: text(live['source'], ''),\n targetNode: text(live['target'], props.targetNode),\n type: text(live['type'], 'local'),\n }),\n collection: () => 'cluster/replication',\n createForm: createBody,\n /**\n * ⚠️ `targetNode` AND `source` ARE OUT OF THIS COMPARISON FOR TWO REASONS EACH, AND EITHER ALONE\n * WOULD BE ENOUGH. They are create-only — `target` is a `fixed` option, `source` has no honest\n * declared value — AND PVE REWRITES BOTH BEHIND YOUR BACK. MEASURED in\n * `switch_replication_job_target_nolock`: when a guest migrates, PVE sets\n * `$jobcfg->{target} = $new_target` and `$jobcfg->{source} = $old_target`, so the job follows\n * the guest. Compared, a single migration would make every later plan report an update that the\n * PUT cannot perform, forever. The cost of leaving them out is stated on the `targetNode` prop:\n * a changed target plans as noop, and a migrated job is not dragged back.\n * ⚠️ `guest`, `jobnum`, `type` AND `id` ARE NOT COMPARED EITHER: the first two are the id in\n * integer form, `type` has one legal value, and `id` is the path — a change there is a\n * different object, which reads as absent and is created.\n * ⛔ `remove_job` IS COMPARED, AND IT IS THE ONE FIELD HERE THAT LOOKS LIKE A FOREVER-UPDATE AND\n * IS NOT. A DELETE marks the job rather than removing it, so a re-declared id can name a job\n * that is busy deleting itself, and matching that would be a noop over a vanishing object. It\n * settles because `updateBody` actually clears the marker — see there.\n */\n matches: (attributes, props) =>\n attributes.remove_job === '' &&\n attributes.schedule === (props.schedule ?? DEFAULT_SCHEDULE) &&\n attributes.disable === (props.disable === true) &&\n attributes.comment === (props.comment ?? '') &&\n (props.rate === undefined || attributes.rate === props.rate),\n path: (props) => `cluster/replication/${jobId(props)}`,\n updateForm: updateBody,\n});\n\n/**\n * ⛔ Empty `list` like every other resource here: `GET /cluster/replication` hands back every job an\n * operator ever made, and adopting one is how a later `alchemy destroy` takes away a standby copy\n * nobody declared. Adoption is an explicit act — declare the `guest` and `jobnum` you mean.\n * ⚠️ NOTHING BRAKES THIS DESTROY. PVE refuses to delete a pool that still holds guests; it accepts\n * this without a word, because nothing depends on a replication job. Re-read the DELETE ⛔ at the\n * top of this file before approving a plan line that removes one.\n */\nexport const ProxmoxReplicationJobProvider = () =>\n Provider.effect(\n ProxmoxReplicationJob,\n Effect.succeed(ProxmoxReplicationJob.Provider.of(handlers)),\n );\n",
54
+ "/**\n * A replication job's props, as the id and the forms PVE wants.\n *\n * ★ SPLIT OUT OF replication-job.ts TO KEEP BOTH FILES UNDER THE 250-LINE CAP, on the same seam\n * metric-server-form.ts uses and for the same reason: this file answers \"how does a declaration\n * become a PVE write\", and replication-job.ts answers \"what is a replication job and when has it\n * changed\". Nothing here reads the cluster and nothing here decides a diff.\n *\n * ⚠️ THE `import type` BACK TO replication-job.ts IS A CYCLE ON PAPER ONLY. It is type-only, so it\n * is erased before anything runs, and `ReplicationJobProps` stays the resource's public shape in\n * the file that declares the resource rather than being moved somewhere odd to dodge the arrow.\n */\nimport type { ReplicationJobProps } from './replication-job.ts';\n\n/**\n * PVE's own documented default for `schedule`, applied on BOTH sides of the comparison.\n *\n * ⚠️ IT LIVES HERE BECAUSE BOTH HALVES NEED THE SAME STRING. `shape` sends it and `attributes`\n * falls back to it; two copies of that literal in two files is exactly the drift that makes a\n * plan report an update over a value nobody set.\n * ⚠️ AND IT IS NEVER SPELLED OUT IN A COMMENT, because the string PVE chose ENDS A BLOCK COMMENT:\n * the two characters before the `15` are the comment terminator, and tsc says so loudly. It is\n * referred to by name everywhere else in these two files for that reason, not for style.\n */\nexport const DEFAULT_SCHEDULE = '*/15';\n\n/**\n * `{guest, jobnum}` -> `100-0`, the id in the only spelling PVE ever answers with.\n *\n * ⚠️ NUMBERS IN, SO CANONICAL OUT. PVE runs both halves of a job id through `int()` on parse — see\n * the ⛔ in replication-job.ts — and a JavaScript number has no leading-zero spelling to lose.\n * That is the whole reason this resource is keyed on two numbers instead of one string.\n */\nexport const jobId = (props: ReplicationJobProps) =>\n `${String(props.guest)}-${String(props.jobnum)}`;\n\n/**\n * The mutable half, shared by create and update.\n *\n * ⚠️ `schedule`, `disable` AND `comment` ARE ALWAYS SENT, EVEN AT THEIR DEFAULTS, because they are\n * always compared — and a field compared against a default but not SENT as that default is an\n * update reported on every plan that the PUT never performs (backup-job.ts records the same\n * trade). The empty string is how PVE is told to clear a comment. `rate` is the opposite case:\n * not declared, not sent, not compared, so a rate limit set by hand survives adoption untouched.\n * ⛔ `source` IS NEVER SENT, AND SENDING IT WOULD BE WORSE THAN REDUNDANT. MEASURED in\n * API2/ReplicationConfig.pm: create does `$param->{source} //= $guest_info->{node}` — PVE fills\n * it from wherever the guest actually is — and DIES with \"Source '<x>' does not match current\n * node of guest\" when a declaration disagrees. There is no correct value to hold here.\n */\nconst shape = (props: ReplicationJobProps) => ({\n comment: props.comment ?? '',\n disable: props.disable === true ? '1' : '0',\n schedule: props.schedule ?? DEFAULT_SCHEDULE,\n ...(props.rate === undefined ? {} : { rate: String(props.rate) }),\n});\n\n/**\n * ⚠️ `type` IS A CONSTANT RATHER THAN A PROP: `local` is the only section type PVE registers, and\n * an enum of one value is a prop that can only ever be wrong. `id` and `target` are both required\n * by the create schema and neither belongs in `shape` — `target` because PUT will not take it.\n * ⛔ THIS LINE IS THE ONLY PLACE PVE'S KEY `target` IS SPELLED, and the value beside it comes from\n * `targetNode`. The two words are different objects — a node name here, the whole cluster in\n * `WithTarget.target` — and the ⛔ in replication-job.ts explains why the rename was forced.\n */\nexport const createBody = (props: ReplicationJobProps) => ({\n ...shape(props),\n id: jobId(props),\n target: props.targetNode,\n type: 'local',\n});\n\n/**\n * ⛔ `delete=remove_job` ON EVERY UPDATE IS THE DELIBERATE PART. PVE's PUT merges the form into the\n * section and cannot unset anything, so without this the removal marker a DELETE wrote would\n * survive every reconcile and `matches` would report an update that never lands. MEASURED as\n * legal: the update handler refuses `delete` only for required or `fixed` options, and\n * `remove_job => { optional => 1 }` is neither; deleting a key that is not set is a no-op, so\n * this is safe to send unconditionally.\n * ⛔ AND THE DELETE LIST IS THIS ONE CONSTANT KEY, NEVER A COMPUTED \"everything you did not\n * declare\". backup-job.ts spells out why the computed form is dangerous — it strips settings the\n * resource does not even model off a job adopted from the UI. `remove_job` cannot be declared\n * here at all, so clearing it can only ever undo a removal this stack did not ask for.\n * ⚠️ IT CANCELS A REMOVAL SOMEBODY STARTED, WHICH IS THE POINT AND IS STILL WORTH KNOWING. If the\n * removal pass already ran its local-snapshot half, the revived job re-sends in full.\n */\nexport const updateBody = (props: ReplicationJobProps) => ({\n ...shape(props),\n delete: 'remove_job',\n});\n",
55
+ "/**\n * `Proxmox.Role` — a PVE role: one name, one set of privileges. The object every other resource\n * in this package stands on, because a role is what the provision credential actually holds.\n *\n * ★ THIS IS WHERE pool.ts's ⚠️ STOPS BEING A MEMORY. That file records, in prose, that the\n * provision role lacked `Pool.Allocate`, that reconcile answered \"Permission check failed\", and\n * that a human widened the role over SSH with `pveum role modify`. Prose cannot be planned\n * against: it goes stale the first time somebody edits the role in the UI and tells nobody.\n * Declared here, the same fact is a diff — the privileges the role is SUPPOSED to hold are read\n * off the cluster on every plan, and a hand edit shows up as `1 to update` rather than as a 403\n * six weeks later in the middle of something else.\n *\n * ⛔ THE INDEX AND THE ITEM DISAGREE ABOUT WHAT `privs` IS, AND MISSING THAT COSTS A DIFF THAT\n * NEVER CONVERGES. `GET /access/roles` (the index) reports each role's privileges as a COMMA\n * STRING. `GET /access/roles/{roleid}` — the path this resource reads — returns a privilege MAP\n * instead, `{\"VM.Allocate\":1,\"Sys.Audit\":1,…}`, and its key order is a Perl hash's order, so it\n * is not stable between two calls to the same endpoint. Compare the raw string, or the raw\n * object, or the keys in the order they arrived, and every plan reports an update forever.\n * `canonical` below is the whole answer: both sides become a sorted, de-duplicated set before\n * anything is compared, and `attributes` STORES the sorted form so Alchemy's state does not\n * churn either.\n *\n * ⚠️ A DECLARATION REPLACES THE PRIVILEGE SET; IT DOES NOT ADD TO IT. `PUT /access/roles/{roleid}`\n * accepts an `append` flag and this resource deliberately never sends it — with append a role\n * could only ever grow, so `matches` would report an update forever whenever props were a subset\n * of live, which is the same perpetual diff by a different road. The consequence is the one that\n * bites: anything a human added by hand is REVOKED on the next deploy unless it is in `privs`.\n * Copy the live set out of `pveum role list` before declaring a role that already exists; do not\n * type it from memory.\n *\n * ⛔ A ROLE CAN LOCK ITS OWN PROVIDER OUT, AND NOTHING IN THIS PACKAGE CAN UNDO IT. Reconcile runs\n * as the provision credential, and that credential holds a role. Declare THAT role without the\n * privileges the provider needs — `Sys.Modify` on `/access` above all — and the write succeeds,\n * after which every later plan reads 403 and the repair has to happen out of band as `root@pam`\n * over SSH. It is a one-way door, which is why the privileges a reconcile needs are written\n * down at the bottom of this comment rather than left to be rediscovered from an error message.\n *\n * ⚠️ PVE REFUSES TO EDIT ITS OWN BUILT-IN ROLES (`Administrator`, `NoAccess`, the `PVE*` set), and\n * the item endpoint gives no sign of which those are — only the index carries the `special`\n * flag. A declaration aimed at a built-in role therefore READS BACK CLEANLY and fails at write\n * time, which reads like a broken provider rather than like a refusal. Declare roles you own.\n *\n * ★ PRIVILEGES A RECONCILE NEEDS: `Sys.Audit` on `/access` to read and diff, `Sys.Modify` on\n * `/access` to create, update or delete. Not `Permissions.Modify` — binding a role to a user is\n * `/access/acl`, a different object, and nothing here writes it. An auditor-shaped credential\n * can already PLAN this resource and cannot DEPLOY it, which is the honest failure: the plan is\n * true and the deploy says exactly which privilege is missing.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\n\nexport interface RoleProps extends WithTarget {\n /**\n * PVE's primary key for a role.\n *\n * ⚠️ THERE IS NO RENAME. `path` is built from this, so changing it makes the factory read\n * nothing live, create a role under the new name, and leave the old one on the cluster with\n * nobody managing it. Delete the resource and declare a new one rather than editing this.\n */\n roleid: string;\n /**\n * The COMPLETE privilege set, e.g. `['VM.Allocate', 'VM.Audit', 'Sys.Audit']`. Order and\n * duplicates do not matter — see the ⛔ in the header — but completeness does: this list is the\n * role, not an addition to it.\n *\n * ⚠️ DECLARE AT LEAST ONE. A role with no privileges grants nothing and reads back as an empty\n * document, which is the one shape the factory cannot tell apart from an object that is not\n * there — reconcile would then refuse with its \"the write returned no error but the object is\n * still absent\" message, which is true of the read and misleading about the cause.\n */\n privs: string[];\n}\n\nexport interface RoleAttributes {\n roleid: string;\n /** Sorted and de-duplicated on the way in, so persisted state is identical across plans. */\n privs: string[];\n}\n\nexport interface ProxmoxRole extends Resource<\n 'Proxmox.Role',\n RoleProps,\n RoleAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxRole = Resource<ProxmoxRole>('Proxmox.Role');\n\n/**\n * The only shape two privilege sets may be compared in: sorted, de-duplicated, blanks dropped.\n *\n * ⚠️ THE TRIM AND THE EMPTY FILTER ARE NOT DECORATION. `'A,B,'.split(',')` yields a trailing `''`,\n * and a hand-written list is quite likely to carry a stray space after a comma. Either one turns\n * into a phantom member that no live answer can contain, so `matches` would be false on every\n * plan and the deploy would rewrite the role to exactly what it already was.\n */\nconst canonical = (privs: readonly string[]): string[] =>\n [...new Set(privs.map((priv) => priv.trim()).filter((priv) => priv.length > 0))].sort();\n\n/**\n * The privileges in a live answer, from EITHER shape PVE uses for them.\n *\n * ⚠️ THE MAP BRANCH IS THE ONE THAT RUNS HERE — the item endpoint answers `{\"VM.Allocate\":1,…}`,\n * so the privilege names are the KEYS and the `1`s carry no information. The string branch\n * exists because the index answers `{\"privs\":\"VM.Allocate,Sys.Audit\",…}` for that same role, and\n * a reader that assumed the map shape for an index entry would compare the words `privs`,\n * `roleid` and `special` against real privileges and report drift forever.\n *\n * ⚠️ A KEY WITH NO DOT IS NOT A PRIVILEGE. Every PVE privilege is `Category.Name` — VM.Allocate,\n * Sys.Modify, Datastore.AllocateSpace, Pool.Audit — while the metadata PVE mixes into role\n * answers (`special`, marking a built-in) is a bare word. Filtering on the dot keeps a flag from\n * being diffed as though somebody had granted it.\n */\nconst livePrivs = (live: Record<string, unknown>): string[] => {\n const listed = live['privs'];\n if (typeof listed === 'string') return canonical(listed.split(','));\n return canonical(Object.keys(live).filter((key) => key.includes('.')));\n};\n\nconst handlers = pveHandlers<RoleProps, RoleAttributes>({\n attributes: (live, props) => ({ privs: livePrivs(live), roleid: props.roleid }),\n collection: () => 'access/roles',\n /** ⚠️ PVE wants ONE comma string here, not a repeated field — `privs=A,B,C`. */\n createForm: (props) => ({ privs: canonical(props.privs).join(','), roleid: props.roleid }),\n /**\n * ⛔ NORMALISED ON BOTH SIDES, even though `attributes` already arrives sorted. This is a\n * predicate, not a fast path: the cost of trusting one side's order is not a slow plan, it is\n * a plan that reports an update every single time and a deploy that writes the same role back\n * forever. Cheap insurance against the exact trap named in the header.\n */\n matches: (attributes, props) =>\n canonical(attributes.privs).join(',') === canonical(props.privs).join(','),\n path: (props) => `access/roles/${props.roleid}`,\n /**\n * ⚠️ NO `append` FIELD, DELIBERATELY. Sending `append=1` would make every update additive, so a\n * privilege could be granted from here but never taken away — and a role that cannot narrow\n * is not a declaration. See the ⚠️ in the header for what that means for hand edits.\n */\n updateForm: (props) => ({ privs: canonical(props.privs).join(',') }),\n});\n\n/**\n* ⛔ AN EMPTY LIST, AND NOWHERE DOES IT MATTER MORE. `GET /access/roles` returns every\n* role on the cluster, PVE's own built-ins included. Returning them would invite Alchemy\n* to adopt `Administrator` — and therefore one day to narrow or delete it. Adoption is\n* an explicit act, here as everywhere else in this package.\n \n *\n* ⛔ DO NOT CARRY THE FACTORY'S REASSURANCE OVER TO THIS ONE. `destroy` there notes that\n* PVE refuses to delete things still in use — a pool holding guests, a storage with\n* volumes — and a role is NOT protected that way. Whoever is bound to the role loses\n* those privileges the moment it goes, and the credential this provider runs with is\n* bound through exactly such a binding. Checking who holds a role before removing it is\n* an operator's job, and it is not done here on their behalf while they read a diff.\n \n */\nexport const ProxmoxRoleProvider = () =>\n Provider.effect(ProxmoxRole, Effect.succeed(ProxmoxRole.Provider.of(handlers)));\n",
56
+ "/**\n * `Proxmox.SdnApply` — the call that makes a declared network real.\n *\n * ⛔ WITHOUT THIS RESOURCE, EVERY SDN DEPLOY IS A GREEN PLAN THAT CHANGES NO NETWORK. Writes under\n * `cluster/sdn/*` edit files in `/etc/pve/sdn/` and touch nothing on any node. `PUT /cluster/sdn`\n * is the apply, and it is CLUSTER-WIDE — it publishes every staged object at once, not the one\n * that happened to reconcile.\n *\n * ★ MEASURED ON TB4 ON 2026-09-13, NOT INFERRED. A probe zone was created, inspected and removed:\n *\n * pvesh create /cluster/sdn/zones --zone zzprobe --type simple\n * GET /cluster/sdn/zones/zzprobe -> {\"digest\":\"c438…\",\"type\":\"simple\",\"zone\":\"zzprobe\"}\n * GET /cluster/sdn/zones/zzprobe?pending=1 -> {\"digest\":null,\"pending\":{},\"state\":\"new\",…}\n * GET /cluster/sdn/zones?running=1 -> [] ⬅ THE APPLIED CONFIG WAS EMPTY\n *\n * So the plain read — the one `pveOperations` performs — answers from the STAGED file and cannot\n * tell staged from applied. `state` appears only under `?pending=1`, and `?running=1` is the\n * applied view. That is the whole basis for this resource.\n *\n * ★ IT IS A RESOURCE RATHER THAN A HOOK SO THAT THE GRAPH ORDERS IT. Pass the zones and vnets it\n * should follow in `after`; Alchemy orders by data flow, so reading their attributes is what\n * puts the apply last. A stack-level hook would fire on every run, including runs where no SDN\n * object changed, and would be invisible in `plan`.\n *\n * ⚠️ ONE APPLY PER STACK. Two of these would each publish the other's staged half, so whichever\n * ran first would apply a zone its own declaration had not finished writing. Declare one.\n *\n * ⚠️ THE COLLECTION READ IS DELIBERATE, AND IT IS WHAT LETS THE READ LEASE SEE ANYTHING AT ALL.\n * `GET /cluster/sdn/zones/{zone}` is checked against SDN.Allocate — read the ⛔ in sdn-zone.ts —\n * but `GET /cluster/sdn/zones` is \"list entries where you have SDN.Audit or SDN.Allocate\", so\n * the collection answers an auditor-shaped credential. This resource only ever reads collections.\n */\nimport { Resource } from 'alchemy';\nimport { isResolved } from 'alchemy/Diff';\nimport type { Input } from 'alchemy/Input';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { pve } from './client.ts';\nimport type { PveRequirements } from './resource.ts';\nimport type { WithTarget } from './resource.ts';\nimport { sdnPendingCount } from './sdn-apply-read.ts';\n\nexport interface SdnApplyProps extends WithTarget {\n /**\n * The staged objects this apply publishes.\n *\n * ⚠️ IT IS NEVER READ, AND IT IS NOT DECORATION. Alchemy orders resources by DATA FLOW, so the\n * only way to say \"after the zones\" is to consume something the zones produced. Pass their\n * attributes here — `after: [zone.zone, vnet.vnet]` — and the apply lands last. Leave it out\n * and the apply may run BEFORE the zone it was meant to publish, which plans green and\n * changes nothing.\n */\n after?: readonly unknown[];\n}\n\nexport interface SdnApplyAttributes {\n /**\n * How many SDN objects are still staged.\n *\n * ⚠️ ZERO IS THE ONLY SETTLED VALUE. Anything above it means the running config and the staged\n * config disagree — which is drift whether this stack caused it or somebody staged a zone in\n * the UI and walked away.\n */\n pending: number;\n}\n\nexport interface ProxmoxSdnApply extends Resource<\n 'Proxmox.SdnApply',\n SdnApplyProps,\n SdnApplyAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxSdnApply = Resource<ProxmoxSdnApply>('Proxmox.SdnApply');\n\nconst read = (props: SdnApplyProps) =>\n sdnPendingCount(props.target).pipe(Effect.map((pending) => ({ pending })));\n\nexport const ProxmoxSdnApplyProvider = () =>\n Provider.effect(\n ProxmoxSdnApply,\n Effect.succeed(\n ProxmoxSdnApply.Provider.of({\n /** ⛔ Empty for the same reason as every other resource here: adoption must be explicit. */\n list: () => Effect.succeed([]),\n\n read: Effect.fn(function* ({ olds }) {\n return yield* read(olds);\n }),\n\n /**\n * ⚠️ THE DIFF IS ABOUT THE CLUSTER, NOT ABOUT THE PROPS. This resource has no settable\n * field — `after` exists only to create an ordering edge — so comparing props to props\n * would report `noop` forever and the apply would run exactly once, ever. What decides\n * it is whether anything is staged right now.\n */\n diff: Effect.fn(function* ({ news }: { news: Input<SdnApplyProps> }) {\n if (!isResolved(news)) return undefined;\n const { pending } = yield* read(news);\n return pending === 0 ? ({ action: 'noop' } as const) : ({ action: 'update' } as const);\n }),\n\n reconcile: Effect.fn(function* ({ news }) {\n /**\n * ⛔ NOTHING STAGED MEANS NOTHING TO PUBLISH, AND THIS BRANCH IS A SAFETY PROPERTY RATHER\n * THAN AN OPTIMISATION — the same one network-apply.ts has carried all along, and the\n * absence of which is why this resource could not be declared at all.\n *\n * 🔴 WHAT IT PREVENTS. `reconcile` runs on CREATE, the first time this resource appears\n * in a stack, before `diff` has ever been consulted. `PUT /cluster/sdn` regenerates\n * `/etc/network/interfaces.d/sdn` on EVERY node at once — and on TB4 that file carries\n * the OSPF fabric holding Ceph's `cluster_network` on en05/en06. Without this branch,\n * adding one line to a stack file reloads networking on all three nodes simultaneously,\n * which is precisely what the serialised NetworkApply chain exists to prevent.\n *\n * ⚠️ IT DEPENDS ON sdn-apply-read.ts BEING HONEST ABOUT THE WHOLE SURFACE. A count that\n * only looks at zones and vnets answers zero on a cluster with a staged fabric, and\n * this branch would then wave through the exact publish it is here to stop.\n */\n const staged = yield* read(news);\n if (staged.pending === 0) return staged;\n\n yield* pve(news.target, 'provision', 'PUT', 'cluster/sdn');\n /**\n * ⛔ READ BACK, FOR THE SAME REASON THE FACTORY DOES. PVE answers 200 on writes that did\n * nothing, and here \"nothing\" is indistinguishable from success by status code alone.\n * If objects are still staged after an apply, the network does NOT match the\n * declaration and saying otherwise is the exact lie this resource was added to stop.\n */\n const after = yield* read(news);\n if (after.pending !== 0) {\n return yield* Effect.die(\n new Error(\n `PUT /cluster/sdn returned no error but ${String(after.pending)} SDN object(s) ` +\n 'are still staged. The running config does not match the declared one -- check ' +\n '`pvesh get /cluster/sdn/zones --pending 1` for the objects PVE refused.',\n ),\n );\n }\n return after;\n }),\n\n /**\n * ⛔ DELETING THIS RESOURCE APPLIES NOTHING AND UNDOES NOTHING, AND THAT IS CORRECT. There\n * is no un-apply in PVE: the running config is already published on every node, and the\n * way to remove a network is to delete the zone or vnet and apply AGAIN. Making this\n * destroy call `PUT /cluster/sdn` would publish whatever happened to be staged at the\n * moment somebody removed a line from a stack file, which is the worst possible time.\n */\n delete: () => Effect.void,\n }),\n ),\n );\n",
57
+ "/**\n * What is staged on the SDN, across the WHOLE surface the apply publishes — not just the two\n * collections this package declares resources for.\n *\n * 🔴 THE GAP THIS FILE CLOSES, AND IT WAS FOUND BY ALMOST DECLARING THE APPLY. `pendingCount` in\n * sdn-apply.ts counted `cluster/sdn/zones` and `cluster/sdn/vnets`. TB4 has zero of each — and a\n * staged OSPF FABRIC that nothing counted. MEASURED 2026-09-13 on n2:\n *\n * /etc/pve/sdn/fabrics.cfg ospf_fabric: tb4, area 1, ip_prefix 10.100.0.0/24\n * ospf_node: tb4_n2/n3/n4, interfaces en05 + en06,\n * ip 10.100.0.102 / .103 / .104\n * /etc/network/interfaces.d/sdn the file PVE GENERATES from it, carrying those /32s\n *\n * Those addresses are Ceph's `cluster_network`. So `diff` would have answered `noop` for ever\n * while `PUT /cluster/sdn` republished the fabric and reloaded networking on all three nodes at\n * once — the simultaneity the NetworkApply chain exists to prevent, arriving through the door\n * nobody was watching.\n *\n * ⛔ THE SURFACE IS NOT UNIFORM, AND ASSUMING IT WAS IS WHAT MADE THE GAP INVISIBLE. Measured, one\n * request per collection, per query:\n *\n * zones, vnets, controllers, prefix-lists, route-maps accept ?pending=1 and ?running=1,\n * and mark a staged row with `state`\n * fabrics accepts both, and its rows carry NO\n * `state` marker at all\n * ipams, dns REJECT both with HTTP 400,\n * \"property is not defined in schema\"\n *\n * ⛔ SO A `state`-ONLY TEST IS WRONG FOR FABRICS, AND `orElseSucceed(() => 0)` IS WORSE THAN WRONG\n * FOR ipams AND dns. The old code folded an unreadable collection to zero — right for a cluster\n * with no SDN at all, and indistinguishable from \"this collection rejects the question\". Adding\n * ipams and dns to the old list would have counted them as 0 for ever and read as coverage.\n */\nimport * as Effect from 'effect/Effect';\nimport { PveError, pve } from './client.ts';\nimport type { PveTarget } from './credentials.ts';\n\n/** A staged row. `state` is present only under `?pending=1`, and only when it differs from running. */\ntype PendingRow = { state?: string };\n\n/**\n * Collections that answer `?pending=1` AND mark a staged row with `state`.\n *\n * ⚠️ THIS LIST IS WIDER THAN THE RESOURCES THIS PACKAGE SHIPS, ON PURPOSE, AND THAT REVERSES THE\n * OLD COMMENT. It used to say counting a collection nothing declares would turn somebody else's\n * hand-staged object into a permanent `update`. True — and the alternative is publishing that\n * object without ever showing it in a plan. An apply that is cluster-wide must be honest about\n * the whole cluster: a controller staged by hand in the UI is a thing this resource WILL push,\n * so it has to be a thing this resource ADMITS to. A permanent `update` on somebody's abandoned\n * half-edit is a loud, safe failure; publishing it silently is not.\n */\nconst MARKED = [\n 'cluster/sdn/zones',\n 'cluster/sdn/vnets',\n 'cluster/sdn/controllers',\n 'cluster/sdn/prefix-lists',\n 'cluster/sdn/route-maps',\n] as const;\n\n/**\n * Collections with NO pending view at all.\n *\n * ⚠️ NAMED RATHER THAN SILENTLY SKIPPED. `ipams` and `dns` answer HTTP 400 to both `?pending=1` and\n * `?running=1`, so there is no way to ask them what is staged. They are a REAL blind spot: an\n * ipam edited by hand is published by the apply and cannot be seen from here. TB4 has one ipam\n * (`pve`, the built-in) and zero dns entries, so the blind spot is currently empty — which is a\n * fact about today, not a property of the design.\n */\nexport const UNDIFFABLE = ['cluster/sdn/ipams', 'cluster/sdn/dns'] as const;\n\n/**\n * Whether a failed read means \"this SDN subsystem does not exist here\" — the ONE failure that may\n * read as nothing staged.\n *\n * 🔴 IT USED TO BE EVERY FAILURE. `orElseSucceed` caught 401, 403, 5xx and a dropped connection\n * along with the 501 it was written for, so an expired read lease or a missing grant answered\n * \"nothing staged\": `diff` said noop, and the read-back after a real apply said settled while\n * objects were still staged. The fabric views were worse because they are COMPARED — one view\n * failing while the other succeeded read as a DIFFERENCE, which is `PUT /cluster/sdn` and a\n * network reload carrying Ceph's cluster network on all three nodes, over a timeout. Found in\n * review on 2026-09-14 and confirmed by reading.\n * ⛔ SO ANYTHING ELSE FAILS THE READ. A plan that stops on an unreadable SDN is loud and safe; a\n * plan that guesses is neither.\n */\nexport const subsystemAbsent = (error: unknown): boolean =>\n error instanceof PveError && error.status === 501;\n\n/** Staged rows in the collections that mark them. */\nconst markedPending = (target: PveTarget) =>\n Effect.all(\n MARKED.map((collection) =>\n pve<PendingRow[]>(target, 'read', 'GET', `${collection}?pending=1`).pipe(\n Effect.map((rows) => (rows ?? []).filter((row) => row.state !== undefined).length),\n /**\n * ⚠️ AN ABSENT COLLECTION COUNTS AS ZERO, AND THAT IS STILL RIGHT HERE — but ONLY an absent\n * one. Some versions answer 501 for an SDN subsystem that has never been configured, and\n * failing the whole plan over it would make this resource undeclarable on a cluster with\n * no SDN. The collections that REJECT the question are handled by not asking them — see\n * UNDIFFABLE — and every other failure is a failure; see `subsystemAbsent`.\n */\n Effect.catchIf(subsystemAbsent, () => Effect.succeed(0)),\n ),\n ),\n { concurrency: 'unbounded' },\n ).pipe(Effect.map((counts) => counts.reduce((total, count) => total + count, 0)));\n\n/**\n * Staged fabric changes from the two canonical views, where `undefined` is a view whose subsystem\n * answered 501.\n *\n * ⛔ ONE VIEW ABSENT AND ONE PRESENT IS NOT A DIFFERENCE. It is one endpoint answering two\n * questions inconsistently, and a difference is exactly what triggers the publish — so it is\n * refused rather than counted.\n */\nexport const fabricStaged = (\n staged: string | undefined,\n running: string | undefined,\n): number | 'inconsistent' => {\n if (staged === undefined && running === undefined) return 0;\n if (staged === undefined || running === undefined) return 'inconsistent';\n return staged === running ? 0 : 1;\n};\n\n/**\n * Whether the fabric config differs between staged and applied.\n *\n * ★ COMPARING THE TWO VIEWS IS THE TEST, BECAUSE THERE IS NO `state` TO READ. `?pending=1` is the\n * staged config and `?running=1` is what the nodes are actually running; equal means nothing to\n * publish. `cluster/sdn/fabrics/all` returns both fabrics and nodes in ONE call, which is why it\n * is asked rather than the two subdirectories.\n *\n * ⚠️ `digest` IS STRIPPED BEFORE COMPARING. The pending view carries one and the running view does\n * not — MEASURED — so comparing raw bodies reports a difference on a cluster where nothing has\n * changed, which is exactly the forever-diff this package has fixed three times elsewhere.\n * ⚠️ AND THE ORDER OF THE NODE LIST IS NOT STABLE between the two reads, so both sides are\n * canonically sorted. Order is not meaning in a set of fabric nodes.\n */\nconst fabricPending = (target: PveTarget) =>\n Effect.all(\n ['pending', 'running'].map((view) =>\n pve<unknown>(target, 'read', 'GET', `cluster/sdn/fabrics/all?${view}=1`).pipe(\n Effect.map(canonical),\n Effect.catchIf(subsystemAbsent, () => Effect.succeed(undefined)),\n ),\n ),\n { concurrency: 'unbounded' },\n ).pipe(\n Effect.flatMap(([staged, running]) => {\n const verdict = fabricStaged(staged, running);\n return verdict === 'inconsistent'\n ? Effect.die(\n new Error(\n 'cluster/sdn/fabrics/all answered 501 for one of ?pending=1 and ?running=1 and not ' +\n 'the other. Refusing to read that as a staged fabric change.',\n ),\n )\n : Effect.succeed(verdict);\n }),\n );\n\n/** Stable JSON with `digest` removed and every array sorted, so only real differences show. */\nexport const canonical = (value: unknown): string => JSON.stringify(sortDeep(value));\n\nconst sortDeep = (value: unknown): unknown => {\n if (Array.isArray(value)) {\n return value\n .map(sortDeep)\n .sort((left, right) => JSON.stringify(left).localeCompare(JSON.stringify(right)));\n }\n if (value !== null && typeof value === 'object') {\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([key]) => key !== 'digest')\n .sort(([left], [right]) => left.localeCompare(right));\n return Object.fromEntries(entries.map(([key, inner]) => [key, sortDeep(inner)]));\n }\n return value;\n};\n\n/**\n * How many staged changes the apply would publish, across everything it is capable of publishing.\n *\n * ⛔ ZERO HERE IS THE ONLY THING THAT MAKES DECLARING THE APPLY SAFE. `reconcile` runs on CREATE —\n * Alchemy always calls it the first time a resource appears — and `PUT /cluster/sdn` regenerates\n * `/etc/network/interfaces.d/sdn` on every node. On TB4 that file carries Ceph's cluster network.\n */\nexport const sdnPendingCount = (target: PveTarget) =>\n Effect.all([markedPending(target), fabricPending(target)], { concurrency: 'unbounded' }).pipe(\n Effect.map(([marked, fabric]) => marked + fabric),\n );\n",
58
+ "/**\n * `Proxmox.SdnSubnet` — the addresses on a declared bridge: the CIDR, its gateway, its DHCP pool.\n *\n * ★ THE THIRD LINK OF ONE CHAIN, AND THE ORDER IS DATA FLOW RATHER THAN CONVENTION. A subnet\n * belongs to a vnet and a vnet belongs to a zone. MEASURED and recorded in sdn-vnet.ts: creating\n * a vnet is permission-checked at `/sdn/zones/-`, so a missing zone surfaces as a PERMISSION\n * error rather than as \"no such zone\". One level deeper the same shape holds — PVE's\n * `check_vnet_access` looks the vnet's ZONE up and checks `/sdn/zones/<zone>/<vnet>` — so a\n * subnet declared against a vnet that does not exist yet dies inside that lookup, with the vnet\n * named and the zone not. Pass the zone and vnet resources' OWN attributes into `zone` and\n * `vnet`; a literal buys no ordering, and here it also buys a wrong path.\n *\n * ⛔ THE ID PVE FILES A SUBNET UNDER IS NOT THE ONE YOU WRITE, AND IT IS THIS FAMILY'S SHARPEST\n * EDGE. `POST` takes `subnet=10.0.0.0/24` while GET, PUT and DELETE address `house-10.0.0.0-24`.\n * One PVE parameter name, `subnet`, carrying two different values — so they are named APART here,\n * `cidr` for the declared one and `subnetId` for the derived one, for the reason values.ts gives\n * about `flag`: a name that means two things is a bug waiting for whoever reads one meaning. The\n * derivation, and its measurement, live in `subnetId` in sdn-subnet-form.ts.\n *\n * ⛔ WHICH IS WHY `zone` IS A PROP THOUGH PVE NEVER ACCEPTS IT ON A SUBNET WRITE. The path cannot\n * be built without it and it is knowable only from the VNET. Declare the wrong zone and the id is\n * wrong: the POST still succeeds, because PVE computes the real id itself from the vnet, and the\n * read-back then looks for a subnet that is not there. The factory's guard in resource.ts DIES on\n * that first deploy — \"the write returned no error but the object is still absent\" — which is\n * loud and immediate, and much better than the alternative it replaces: a plan that says create,\n * forever, against a subnet PVE insists is already defined.\n *\n * ⛔ SDN WRITES ARE STAGED, NOT APPLIED — the same trap as sdn-zone.ts and sdn-vnet.ts, and it\n * walks straight through the factory's read-back, which proves the staging file and nothing more.\n * Nothing here applies. `Proxmox.SdnApply` (sdn-apply.ts) publishes the whole staged config with\n * `PUT /cluster/sdn`; declare one and pass this resource's `subnetId` in its `after`.\n *\n * ⛔ AND `Proxmox.SdnApply` CANNOT YET SEE A STAGED SUBNET, SO ITS PLAN WILL LIE ABOUT THIS FAMILY.\n * MEASURED: its `COLLECTIONS` list is `cluster/sdn/zones` and `cluster/sdn/vnets`, while\n * `PVE::Network::SDN::pending_config` keys the pending view on a SEPARATE `subnets` section of\n * the running config. A run that stages only a subnet therefore leaves both counted collections\n * at zero, the apply diffs as `noop`, and the subnet never reaches a node. It is NOT fixable by\n * adding a string to that list: the subnet index is PER VNET\n * (`cluster/sdn/vnets/{vnet}/subnets?pending=1`), so SdnApply needs the vnet names before it can\n * count them. Until that lands, a subnet-only change needs `pvesh set /cluster/sdn` by hand.\n *\n * ★ THE READ LANE IS ENOUGH HERE, AND THAT IS A REAL DIFFERENCE FROM BOTH SIBLINGS. The zone and\n * vnet ITEM reads are gated on SDN.Allocate, which is why each sets `readRole: 'provision'`. This\n * one is not. MEASURED from the cluster's own schema on 2026-09-13:\n *\n * GET /cluster/sdn/vnets/{vnet}/subnets/{subnet}\n * -> \"Require 'SDN.Audit' or 'SDN.Allocate' permissions on '/sdn/zones/<zone>/<vnet>'\"\n *\n * and `GET /access/acl` the same day shows `hf-read@pve` holding the built-in PVEAuditor — whose\n * seven privileges include SDN.Audit — at `/` with propagate=1. So the default 3600s auditor\n * lease reads this family, and a `readRole: 'provision'` here would be privilege nobody needed.\n * Writes are a different answer: POST, PUT and DELETE all require SDN.Allocate on\n * `/sdn/zones/<zone>/<vnet>`, which `LXCProvisioner` gained on 2026-09-13.\n *\n * ⚠️ NO LIVE SUBNET EXISTS ON TB4 TO ROUND-TRIP AGAINST — there are no SDN zones and no vnets, so\n * there can be no subnets. Every claim above is read off PVE 9.2.11's own schema and Perl sources\n * on n2, and the noop argument below rests on those rather than on a plan this file has watched.\n *\n * ⚠️ TWO REFUSALS TO EXPECT, both from `SubnetPlugin::on_update_hook`: PVE will not put a subnet on\n * a vnet with `vlanaware` set (\"you can't add a subnet on a vlanaware vnet\"), and it rejects a\n * gateway outside the CIDR unless the mask is /32. Both are create-time 400s, not drift.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport {\n type DhcpRange,\n createForm,\n declaredRanges,\n dhcpRanges,\n subnetId,\n updateForm,\n} from './sdn-subnet-form.ts';\nimport { bool, int, text } from './values.ts';\n\nexport interface SdnSubnetProps extends WithTarget {\n /**\n * The vnet whose bridge carries these addresses. Identity AND a written field.\n *\n * ⛔ MOVING A SUBNET BETWEEN VNETS IS NOT SOMETHING THIS RESOURCE CAN DO, and the symptom is\n * worth knowing before you meet it. The id is built from the zone and the CIDR, so it does not\n * change; but the read goes to `.../vnets/<declared>/subnets/<id>`, and PVE answers a subnet\n * filed under another vnet with `raise_param_exc({ vnet => \"wrong vnet\" })`. `read` folds that\n * into \"absent\", reconcile POSTs, and PVE refuses with \"sdn subnet object ID ... already\n * defined\". Loud and accurate, but it does not converge: change the vnet by removing the\n * declaration and writing a new one.\n */\n vnet: string;\n /**\n * The zone that vnet lives in. ⚠️ PATH INPUT ONLY — PVE accepts no `zone` on a subnet write, and\n * nothing here sends one. It is a prop because the path cannot be spelled without it.\n */\n zone: string;\n /** `10.0.0.0/24`. Identity: PVE builds the id from it, so a new CIDR is a new subnet. */\n cidr: string;\n /** Handed to guests as their default route, and registered in the zone's IPAM as `<vnet>-gw`. */\n gateway?: string;\n /**\n * Masquerade this subnet. ⚠️ INERT UNTIL THE CLUSTER FIREWALL IS ON — PVE's own description is\n * \"enable masquerade for this subnet if pve-firewall\", and TB4's cluster firewall was empty and\n * disabled when this was written. It still round-trips, so declaring it does not diff.\n */\n snat?: boolean;\n /** `adm` -> `<hostname>.adm.example.internal` for records the zone's DNS plugin registers. */\n dnszoneprefix?: string;\n /** ⚠️ WIRE NAME `dhcp-dns-server`; see the ⚠️ on `isolatePorts` in sdn-vnet.ts about mappings. */\n dhcpDnsServer?: string;\n /**\n * ⛔ ONE POOL, NOT A LIST, AND THE LIMIT IS THE CLIENT'S RATHER THAN PVE'S. `dhcp-range` is a PVE\n * `type => 'array'` parameter, and an array reaches a form-encoded body only as a REPEATED KEY\n * — which `client.ts` cannot express, because `pve()` takes `Record<string, string>` and one\n * key holds one value. A single occurrence works today because `PVE::RESTHandler`'s\n * `$normalize_legacy_param_formats` wraps a scalar into `[$value]` for an array parameter, so\n * the type is declared as one range and a second one is unspellable rather than silently lost.\n * ⛔ THAT COERCION IS MARKED FOR REMOVAL. Its own comment in RESTHandler.pm reads \"mark the\n * behaviour deprecated with 9.x, and remove it with 10.x\", and this cluster runs 9.2.11 — so on\n * PVE 10 every write carrying a range becomes a hard 400. The fix is not here: it is a form\n * type in client.ts that admits repeated keys.\n * ⚠️ A LIVE SUBNET CARRYING TWO POOLS IS THEREFORE NARROWED TO ONE by the first deploy that\n * declares one. `matches` compares the WHOLE live list, so the narrowing is visible in the plan\n * as an update rather than happening quietly, and it converges.\n */\n dhcpRange?: DhcpRange;\n}\n\n/**\n * ⛔ NO `digest` HERE, for the reason sdn-zone.ts gives: PVE returns the digest of the WHOLE\n * subnets.cfg, so declaring a SECOND subnet would rewrite this one's stored attributes and\n * comparing it would report an update on a subnet nobody touched.\n */\nexport interface SdnSubnetAttributes {\n /** `<zone>-<network>-<mask>` — the path segment, and the name to use in `pvesh`. */\n subnetId: string;\n vnet: string;\n zone: string;\n /** `10.0.0.0/24`, as PVE reassembles it from the id. */\n cidr: string;\n /** Prefix length, so a guest's `ip=10.0.0.5/24` can be built from a reference. */\n mask: number;\n gateway: string;\n snat: boolean;\n dnszoneprefix: string;\n dhcpDnsServer: string;\n /** Normalised and sorted — never compare a raw PVE value to it. See `dhcpRanges`. */\n dhcpRange: string;\n /** ⚠️ THE REMINDER IN THE STATE ITSELF: staged config. No value here says a node has the subnet. */\n readonly staged: true;\n}\n\nexport interface ProxmoxSdnSubnet extends Resource<\n 'Proxmox.SdnSubnet',\n SdnSubnetProps,\n SdnSubnetAttributes,\n never,\n PveRequirements\n> {}\n\n/**\n * ⚠️ NO `defaultRemovalPolicy: 'retain'`, UNLIKE THE SEVEN FAMILIES THAT CARRY IT, AND THE ★ IN\n * resource.ts IS THE TEST IT FAILS: a subnet's whole content is a CIDR, a gateway and a pool,\n * which a line of TypeScript rebuilds exactly. The part that is NOT rebuildable is the guest\n * addresses the zone's IPAM handed out, and PVE guards that itself — MEASURED in the built-in\n * `pve` IPAM plugin, which answers a delete with \"cannot delete subnet '<cidr>', not empty\"\n * whenever anything beyond the gateway still holds an address. That refusal is surfaced as-is.\n */\nexport const ProxmoxSdnSubnet = Resource<ProxmoxSdnSubnet>('Proxmox.SdnSubnet');\n\nconst handlers = pveHandlers<SdnSubnetProps, SdnSubnetAttributes>({\n attributes: (live, props) => {\n /**\n * ⚠️ UNREACHABLE ON A HEALTHY CLUSTER, AND KEPT BECAUSE \"UNREACHABLE\" IS A FACT ABOUT TODAY'S\n * PVE. The read handler already refuses a subnet filed under another vnet, so this row should\n * never arrive — see the ⛔ on `vnet` above for what that refusal costs. If a future PVE\n * answers instead of raising, reporting the foreign subnet as absent makes reconcile POST and\n * PVE say \"already defined\": still loud, rather than a silent noop over somebody else's\n * addresses.\n */\n const liveVnet = text(live['vnet']);\n if (liveVnet !== '' && liveVnet !== props.vnet) return undefined;\n return {\n cidr: text(live['cidr']),\n dhcpDnsServer: text(live['dhcp-dns-server']),\n dhcpRange: dhcpRanges(live['dhcp-range']),\n dnszoneprefix: text(live['dnszoneprefix']),\n gateway: text(live['gateway']),\n mask: int(live['mask'], 0),\n snat: bool(live['snat']),\n staged: true,\n subnetId: subnetId(props),\n vnet: props.vnet,\n zone: text(live['zone']),\n };\n },\n collection: (props) => `cluster/sdn/vnets/${props.vnet}/subnets`,\n createForm,\n /**\n * ⛔ FIVE REPORTED FIELDS ARE DELIBERATELY ABSENT FROM THIS COMPARISON, and each is a\n * forever-diff if it goes back in.\n * `subnetId`, `cidr`, `zone` and `mask` are all DERIVED BY PVE FROM THE ID — measured in\n * `Subnets::sdn_subnets_config`, which splits the id and synthesises cidr/zone/network/mask on\n * every read. None of the four is a POST or PUT parameter, so a difference could never be\n * written; and since the id IS the path this read used, a difference cannot arise either — the\n * GET would have failed and the factory would report \"absent\" instead.\n * `vnet` is the FILTER that produced this row rather than a reading of it: PVE refuses to\n * answer with a subnet on another vnet, so comparing it can only ever be true.\n * `staged` is a fact about the cluster, not about the declaration: diffing it would report an\n * update on every plan until somebody applied, then another the moment anyone staged anything.\n * `digest` is not even reported — see the ⛔ above the attributes.\n */\n matches: (attributes, props) =>\n attributes.gateway === (props.gateway ?? '') &&\n attributes.snat === (props.snat === true) &&\n attributes.dnszoneprefix === (props.dnszoneprefix ?? '') &&\n attributes.dhcpDnsServer === (props.dhcpDnsServer ?? '') &&\n attributes.dhcpRange === declaredRanges(props.dhcpRange),\n /**\n * ⚠️ NO `?pending=1` AND NO `?running=1`, HOWEVER TEMPTING — the same refusal sdn-vnet.ts makes.\n * The factory uses this one path for GET, PUT and DELETE alike, every one of those schemas\n * declares `additionalProperties => 0`, and PVE answers an unexpected parameter on a write with\n * \"parameter verification failed\". Staged-ness is documented at the top of this file instead.\n */\n path: (props) => `cluster/sdn/vnets/${props.vnet}/subnets/${subnetId(props)}`,\n updateForm,\n});\n\n/**\n * ⛔ `list` IS EMPTY LIKE EVERY OTHER RESOURCE HERE. `GET /cluster/sdn/vnets/{vnet}/subnets` answers\n * with every subnet on that bridge, guest addresses and all; adopting one would invite Alchemy to\n * narrow or delete a network nobody declared. Adoption stays an explicit act.\n *\n * ⛔ AND A DELETE IS STAGED TOO, WHICH IS THE HALF PEOPLE FORGET. The section leaves subnets.cfg and\n * Alchemy drops the resource, but the gateway stays on the bridge and DHCP keeps answering until\n * something applies `PUT /cluster/sdn`: a destroy nobody applies reads as complete in the plan and\n * has not happened on the cluster.\n */\nexport const ProxmoxSdnSubnetProvider = () =>\n Provider.effect(ProxmoxSdnSubnet, Effect.succeed(ProxmoxSdnSubnet.Provider.of(handlers)));\n",
59
+ "/**\n * How a subnet crosses the wire in both directions, and what PVE actually calls its path.\n *\n * ★ SPLIT OUT OF sdn-subnet.ts TO KEEP BOTH FILES UNDER THE 250-LINE CAP, on the seam\n * node-network-form.ts cuts rather than at a convenient line number: this file owns the\n * COERCIONS in BOTH directions plus the derived id, because a read that normalises differently\n * from the write that produced it is exactly how a forever-diff is born. sdn-subnet.ts answers\n * \"what is a subnet, and when has it changed\". Nothing here calls the cluster.\n *\n * ⚠️ THE `import type` BACK TO sdn-subnet.ts IS A CYCLE ON PAPER ONLY — type-only, so it is erased\n * before anything runs and `SdnSubnetProps` stays in the file that declares the resource.\n */\nimport type { SdnSubnetProps } from './sdn-subnet.ts';\nimport { propertyString, withClears } from './values.ts';\n\n/** One DHCP pool. PVE's property-string keys are `start-address`/`end-address`; see `rangeString`. */\nexport type DhcpRange = { start: string; end: string };\n\n/**\n * The id PVE files a subnet under — and therefore the path segment GET, PUT and DELETE address it\n * by, which is NOT the value POST is handed.\n *\n * ⛔ MEASURED from `/usr/share/perl5/PVE/API2/Network/SDN/Subnets.pm` on pve-manager 9.2.11, in\n * the create handler: `my $id = $cidr =~ s/\\//-/r; $id = \"$zoneid-$id\";`. So `subnet=10.0.0.0/24`\n * goes out and `house-10.0.0.0-24` is what exists afterwards. A CIDR cannot be a path segment\n * anyway — it carries a slash — so there is no spelling of this endpoint that takes the CIDR.\n *\n * ⚠️ `.replace`, NOT `.replaceAll`, AND THE PARITY IS DELIBERATE. Perl's `s/\\//-/r` has no `/g`, so\n * it rewrites the FIRST slash only. A CIDR has exactly one, so the two agree on every legal\n * input; they would stop agreeing on an illegal one, and agreeing with PVE is the point.\n */\nexport const subnetId = (props: Pick<SdnSubnetProps, 'cidr' | 'zone'>) =>\n `${props.zone}-${props.cidr.replace('/', '-')}`;\n\n/** A range on its way OUT. PVE stores the string verbatim; nothing rewrites it. */\nconst rangeString = (range: DhcpRange) => `start-address=${range.start},end-address=${range.end}`;\n\n/**\n * DHCP ranges, from either shape, as one comparable string.\n *\n * ⛔ THIS FAMILY'S WRITE SHAPE AND READ SHAPE ARE DIFFERENT, WHICH IS THE CLASSIC FOREVER-DIFF.\n * MEASURED from the API module: `$scfg->{'dhcp-range'} = get_dhcp_ranges($scfg)` runs\n * `parse_property_string` over every stored element, so a range WRITTEN as the string\n * `start-address=10.0.0.10,end-address=10.0.0.20` is READ BACK as the object\n * `{\"start-address\":\"10.0.0.10\",\"end-address\":\"10.0.0.20\"}`. `propertyString` in values.ts\n * flattens both shapes to one sorted form and exists for exactly this — see its own ⚠️.\n *\n * ⚠️ AND IT IS A LIST, SO ORDER MUST NOT BE MEANING. PVE validates only that ranges do not overlap\n * and stores them in the order given; two declarations naming the same pools the other way round\n * are the same subnet. Sorting is what stops that being an update, exactly as `csv` does for a\n * zone's `nodes`.\n *\n * ⚠️ `;` IS THE JOINER BECAUSE `,` AND `=` ARE BOTH INSIDE THE VALUES. It never appears in an IPv4\n * or IPv6 address or in a property-string key, so the joined form cannot be ambiguous.\n */\nexport const dhcpRanges = (value: unknown): string =>\n (Array.isArray(value) ? value : [])\n .map((entry: unknown) => propertyString(entry))\n .filter((entry) => entry !== '')\n .sort()\n .join(';');\n\n/** The declared side of that same comparison, through the same funnel so it cannot drift. */\nexport const declaredRanges = (range: DhcpRange | undefined) =>\n range === undefined ? '' : dhcpRanges([rangeString(range)]);\n\n/**\n * ⚠️ AN EMPTY STRING IS HOW A CALLER SPELLS \"UNSET\", AND IT MUST NOT REACH PVE. `gateway` and\n * `dhcp-dns-server` are `format => 'ip'` and `dnszoneprefix` is `format => 'dns-name'`, so `''`\n * is a parameter-verification 400 rather than a clear. Clearing is a separate verb — `delete=`.\n */\nconst unset = (value: string | undefined) =>\n value === undefined || value === '' ? undefined : value;\n\n/**\n * Every optional this resource MANAGES: the value to send, or `undefined` meaning \"clear it\".\n *\n * ⛔ ONE TABLE FEEDS BOTH HALVES OF AN UPDATE, the way metric-server-form.ts does it, and for the\n * same measured reason: A PUT THAT OMITS A FIELD DOES NOT CLEAR IT. PVE merges the form into the\n * existing section (`$data->{$_} = $opts->{$_} for keys $opts->%*`), so dropping `gateway` from a\n * declaration leaves the old gateway in place and `matches` asks for the same update forever.\n * Deriving the form and the `delete=` list from one map makes \"managed but not clearable\"\n * impossible to write here.\n *\n * ⛔ AND THE TWO HALVES MUST NOT OVERLAP. MEASURED in `PVE::SectionConfig::delete_from_config`\n * (SectionConfig.pm:1853): naming a key in BOTH the form and `delete=` dies with \"cannot set and\n * delete property '<k>' at the same time!\". Because both halves are read off this one map, an\n * entry is in exactly one of them by construction.\n *\n * ⛔ NOTHING SET OUT OF BAND MAY BE LISTED HERE. A field in this map is CLEARED the moment it is\n * undeclared, so a live subnet whose DHCP pool an operator widened in the UI is narrowed back on\n * the next deploy. That is full ownership, the same bargain sdn-vnet.ts strikes over `alias`, and\n * it is a bargain rather than an accident only while this list stays deliberate.\n *\n * ⚠️ `snat` IS ABSENT ON PURPOSE AND LIVES IN `body` INSTEAD. It is a boolean, and `0` and \"never\n * declared\" are the same subnet to PVE and to `matches`, so sending an explicit `0` converges\n * without a `delete=` — the same choice sdn-vnet.ts makes for `vlanaware` and `isolate-ports`.\n */\nexport const optional = (props: SdnSubnetProps): Record<string, string | undefined> => ({\n 'dhcp-dns-server': unset(props.dhcpDnsServer),\n 'dhcp-range': props.dhcpRange === undefined ? undefined : rangeString(props.dhcpRange),\n dnszoneprefix: unset(props.dnszoneprefix),\n gateway: unset(props.gateway),\n});\n\n/**\n * The fields sent on EVERY write, create and update alike.\n *\n * ⚠️ `vnet` IS SENT THOUGH THE URL ALREADY CARRIES IT. PVE's handler reads `$param->{vnet}` to\n * resolve the zone for its permission check, and it is a declared parameter of both the create\n * and the update schema, so sending the same value the path carries is accepted and removes this\n * file's dependence on the router injecting a path placeholder into the parameter hash.\n */\nexport const body = (props: SdnSubnetProps): Record<string, string> => ({\n snat: props.snat === true ? '1' : '0',\n vnet: props.vnet,\n ...Object.fromEntries(\n Object.entries(optional(props)).filter(\n (entry): entry is [string, string] => entry[1] !== undefined,\n ),\n ),\n});\n\n/**\n * ⚠️ `type` IS HARDCODED, NOT A PROP. PVE's create schema declares it as an enum with exactly one\n * member, `subnet`, so a prop for it could only ever hold one value — and the POST refuses to\n * proceed without it, which is the parameter-verification error sdn-vnet.ts records.\n */\nexport const createForm = (props: SdnSubnetProps): Record<string, string> => ({\n ...body(props),\n subnet: props.cidr,\n type: 'subnet',\n});\n\n/**\n * ★ CLEARING AN OPTION THAT WAS NEVER SET IS A SILENT NO-OP, AND THIS IS MEASURED RATHER THAN\n * HOPED FOR. sdn-vnet.ts flags the same `delete=` habit as REASONED-not-measured and warns that a\n * first update on a bare object would carry `delete=alias,tag`. Read off the code both endpoints\n * share — `PVE::SectionConfig::delete_from_config`, SectionConfig.pm:1853-1866 — the loop dies\n * only for an option that is unknown to the plugin, not optional, fixed, or also being set; for\n * an option simply absent from the section it runs `delete $config->{$k}` on a missing key and\n * moves on. All four keys above are `optional => 1` in `SubnetPlugin::options`, so a bare\n * subnet's first update carries `delete=dhcp-dns-server,dhcp-range,dnszoneprefix,gateway` and\n * PVE accepts it. `vnet` is `optional => 0` there and is never in this list.\n *\n * ⚠️ TWO OF THOSE FOUR NAMES ARE HYPHENATED, WHICH NO OTHER FAMILY HERE HAS PUT IN A `delete=`.\n * The parameter's format is `pve-configid-list`, and a name that failed it would 400 the whole\n * update rather than skip one field. MEASURED: `$CONFIGID_RE` is `qr/[a-z][a-z0-9_-]+/i`\n * (JSONSchema.pm:30), so a hyphen after the first character is legal and all four pass.\n */\nexport const updateForm = (props: SdnSubnetProps): Record<string, string> => {\n const clear = Object.entries(optional(props))\n .filter(([, value]) => value === undefined)\n .map(([key]) => key);\n return withClears(body(props), clear);\n};\n",
60
+ "/**\n * `Proxmox.SdnVnet` — the bridge a guest actually attaches to.\n *\n * ★ THIS IS THE OBJECT THAT CLOSES THE GAP BETWEEN A DECLARED CONTAINER AND A DECLARED NETWORK.\n * `Proxmox.Lxc` takes `net0: name=eth0,bridge=vmbr0,ip=dhcp`, in which the bridge is a string\n * nothing checks. A vnet's id IS the bridge PVE builds on every node of its zone, so declaring\n * the vnet and passing its `bridge` attribute into `net0` turns that string into a reference\n * Alchemy can order and a plan can show.\n *\n * ⚠️ MEASURED: CREATING A VNET CHECKS PERMISSION AT `/sdn/zones/-`, NOT AT THE VNET. The ACL path\n * is the ZONE's, so a vnet whose zone does not exist yet fails as a PERMISSION error rather than\n * as \"no such zone\" — and you go off widening a role that was never the problem. `zone` is\n * therefore a hard dependency edge, not a convention: pass the zone resource's own attribute so\n * Alchemy creates the zone first. A zone name typed in as a literal buys no ordering at all.\n *\n * ⛔ THE READ-BACK AFTER A WRITE PROVES THE STAGING FILE AND NOTHING MORE — the same trap as\n * `sdn-zone`, and it walks straight through the factory's guard. PVE's SDN endpoints write\n * `/etc/pve/sdn/vnets.cfg`; nothing reaches a node's `/etc/network/interfaces` until\n * `PUT /cluster/sdn` applies the staged config. `pveOperations.reconcile` reads back and refuses\n * when an object is absent, and a vnet that exists only on paper SATISFIES that read: reconcile\n * reports success, the next plan says noop, and no bridge exists anywhere on the cluster.\n * This resource does NOT issue the apply, deliberately. One vnet's reconcile cannot decide to\n * commit every other pending SDN change in the cluster, including ones a human staged in the UI\n * and has not finished. Apply stays an operator's act — `pvesh set /cluster/sdn`.\n *\n * ★ SUBNETS ARE A SIBLING RESOURCE, NOT A FIELD HERE. The gateway and the DHCP ranges guests take\n * addresses from hang off `cluster/sdn/vnets/{vnet}/subnets`, which MEASURED refuses a POST that\n * omits `type` or `subnet` (\"parameter verification failed\"). Same factory, one path deeper, and\n * it depends on this resource the way this one depends on the zone.\n *\n * ⛔ read/diff NEED SDN.Allocate TOO, NOT SDN.Audit — corrected 2026-09-13 against the cluster's\n * schema. `GET /cluster/sdn/vnets/{vnet}` is checked against SDN.Allocate exactly as the zone\n * item endpoint is, while only the COLLECTION read accepts SDN.Audit. An auditor-shaped `read`\n * lease is therefore refused, and `pveOperations.read` turns that refusal into \"absent\" rather\n * than an error — see the ⛔ in sdn-zone.ts and docs/privileges.md.\n *\n * ⚠️ PRIVILEGES, AND THE ESTATE'S CREDENTIAL HELD NONE OF THEM UNTIL 2026-09-13. reconcile and\n * delete mint `provision` and need SDN.Allocate on `/sdn/zones`, or on the one zone if scoped. `LXCProvisioner` grants\n * SDN.Use, which is what a GUEST needs in order to attach to a vnet and NOT what creating one\n * needs, so a container declared on this vnet works today while the vnet itself 403s. Widen\n * deliberately, the way Pool.Allocate was:\n * `pveum role modify LXCProvisioner --privs \"<existing>,SDN.Allocate,SDN.Audit\"` over SSH,\n * preserving every existing privilege.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { bool, withClears } from './values.ts';\n\nexport interface SdnVnetProps extends WithTarget {\n /**\n * ⛔ THE PRIMARY KEY AND THE BRIDGE NAME AT ONCE. PVE caps it at eight alphanumeric characters\n * because it becomes a real interface on every node in the zone. There is no rename: a new id\n * is a new bridge, and every guest whose `net0` still names the old one stays on the old one.\n */\n vnet: string;\n /**\n * The SDN zone that owns it. Mutable — a vnet can be moved between zones — but see the ⚠️ at the\n * top of this file: the zone has to exist first, and passing a zone resource's attribute instead\n * of a literal is the only thing that makes Alchemy order them.\n */\n zone: string;\n /** Free text shown in the UI. Mutable; clear it by dropping the prop, never by passing `''`. */\n alias?: string;\n /** VLAN id or VXLAN VNI, depending on the zone's type. Mutable. Absent means untagged. */\n tag?: number;\n /** Let guests on this bridge carry their own VLAN tags. Mutable. */\n vlanaware?: boolean;\n /**\n * Stop guests on this bridge from reaching each other directly. Mutable.\n * ⚠️ The wire name is `isolate-ports`, with a hyphen — see the ⚠️ on `shape` for why that costs\n * attention in two places rather than one.\n */\n isolatePorts?: boolean;\n}\n\nexport interface SdnVnetAttributes {\n vnet: string;\n /**\n * The same string as `vnet`, duplicated on purpose: it is the name a guest's `net0` must carry.\n * Referencing it from a `Proxmox.Lxc`'s props is what makes Alchemy build the network before the\n * container. A hardcoded `vmbr1` in `net0` is a string nothing checks and nothing orders.\n */\n bridge: string;\n zone: string;\n alias: string;\n /**\n * Absent when the vnet is untagged — see `tagOf` for why this is optional and not `0`.\n * ⚠️ `| undefined` IS LOAD-BEARING under exactOptionalPropertyTypes: the attributes\n * builder always sets this key, writing `undefined` for an untagged vnet, so the type\n * must permit a present-but-undefined value as well as an absent one. Without it the\n * read path does not typecheck, and 0 is a real VLAN id so it cannot be the sentinel.\n */\n tag?: number | undefined;\n vlanaware: boolean;\n isolatePorts: boolean;\n}\n\nexport interface ProxmoxSdnVnet extends Resource<\n 'Proxmox.SdnVnet',\n SdnVnetProps,\n SdnVnetAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxSdnVnet = Resource<ProxmoxSdnVnet>('Proxmox.SdnVnet');\n\n/**\n * ⚠️ AN ABSENT TAG IS `undefined`, NOT 0, which is why `SdnVnetAttributes.tag` is optional rather\n * than falling back the way `memory` does in lxc.ts. VLAN id 0 and VXLAN VNI 0 are real values,\n * so a 0 fallback would report an untagged vnet as tagged 0 and then diff forever against a\n * declaration that asks for no tag at all.\n */\nconst tagOf = (value: unknown) => (typeof value === 'number' ? value : undefined);\n\n/**\n * The fields PVE accepts on create and on update alike.\n *\n * ⚠️ THE WIRE NAME IS `isolate-ports`, WITH A HYPHEN; the prop is `isolatePorts` so no call site\n * has to quote it. Both halves of that mapping have to be right: the form key here AND the read\n * in `attributes`. `live['isolatePorts']` would be `undefined` forever, which reads as \"the\n * cluster does not have it set\" and makes every plan ask for the same update, for good.\n */\nconst shape = (props: SdnVnetProps): Record<string, string> => {\n const alias = props.alias ?? '';\n return {\n // ⚠️ THE TWO BOOLEANS ARE ALWAYS SENT, `0` INCLUDED, AND THAT IS NOT AN OVERSIGHT. `0` and\n // \"never declared\" mean the same thing to PVE and to `matches` below, so an explicit `0`\n // makes the two converge — which is why neither ever appears in the `delete` list.\n 'isolate-ports': props.isolatePorts === true ? '1' : '0',\n vlanaware: props.vlanaware === true ? '1' : '0',\n zone: props.zone,\n // ⚠️ AN EMPTY ALIAS IS OMITTED, NOT SENT AS `''`. `''` is how this file spells \"unset\", and\n // unset goes through the `delete` parameter below; sending it as a value would ask PVE to\n // store an empty description, which is a different request from having none.\n ...(alias === '' ? {} : { alias }),\n ...(props.tag === undefined ? {} : { tag: String(props.tag) }),\n };\n};\n\n/**\n * ⛔ OMITTING A FIELD DOES NOT CLEAR IT. PVE keeps whatever the config already holds, so a\n * declaration that DROPS its alias would diff as `update` forever: `matches` compares `''`\n * against the live text, the PUT says nothing about alias, and the next plan asks for the very\n * same update. PVE's own answer is the `delete` parameter — a comma-separated list of properties\n * to unset — which exists on the update endpoint only. That is why create does not come through\n * here and calls `shape` directly.\n *\n * ⚠️ REASONED FROM PVE'S UPDATE SCHEMA, NOT MEASURED ON A CLUSTER — unlike the two MEASURED facts\n * at the top of this file, and the difference is worth a reader's attention. `delete` is what\n * `SectionConfig::updateSchema` adds to every PVE update endpoint, and unsetting a property that\n * was never set is a no-op there. If THIS endpoint turns out to disagree, the blast radius is\n * wider than the feature: a plain `{ vnet, zone }` vnet has neither alias nor tag, so its very\n * first update carries `delete=alias,tag` and every update fails, not just an unset. The symptom\n * is a 400 \"parameter verification failed\" naming `delete`; the fix is to drop this list and\n * accept the forever-update on unset instead. Verify it once against a live vnet.\n */\nconst updateForm = (props: SdnVnetProps): Record<string, string> => {\n const unset = [\n ...((props.alias ?? '') === '' ? ['alias'] : []),\n ...(props.tag === undefined ? ['tag'] : []),\n ];\n return withClears(shape(props), unset);\n};\n\nconst handlers = pveHandlers<SdnVnetProps, SdnVnetAttributes>({\n // ⛔ PVE gates this family's ITEM read on the allocate privilege, not the audit one — see\n // `readRole` in resource.ts. The auditor-shaped lease reads 403, which `read` turns into\n // \"absent\", and the plan then says create for an object that is plainly there.\n readRole: 'provision',\n attributes: (live, props) => ({\n alias: typeof live['alias'] === 'string' ? live['alias'] : '',\n bridge: props.vnet,\n isolatePorts: bool(live['isolate-ports']),\n tag: tagOf(live['tag']),\n vlanaware: bool(live['vlanaware']),\n vnet: props.vnet,\n /**\n * ⚠️ `''` RATHER THAN `props.zone` WHEN PVE DOES NOT SAY. Echoing the declared zone back would\n * make an unreadable zone look like agreement; `''` matches no declared zone, so the plan\n * reports drift instead. A vnet in the wrong zone is attached to the wrong network, and this\n * is the one field here where a spurious update costs less than a missed one.\n */\n zone: typeof live['zone'] === 'string' ? live['zone'] : '',\n }),\n collection: () => 'cluster/sdn/vnets',\n createForm: (props) => ({ ...shape(props), vnet: props.vnet }),\n /**\n * ⚠️ `vnet`, `bridge` AND WHETHER THE CONFIG IS APPLIED ARE ABSENT FROM THIS COMPARISON ON\n * PURPOSE. The first two are the path — a changed id is a different object, not an edit — and\n * staged-vs-running is a fact about the cluster rather than about the declaration. Diffing it\n * would report an update on every plan until somebody ran the apply, and then report another\n * one the moment anybody else staged anything at all.\n */\n matches: (attributes, props) =>\n attributes.zone === props.zone &&\n attributes.alias === (props.alias ?? '') &&\n attributes.tag === props.tag &&\n attributes.vlanaware === (props.vlanaware === true) &&\n attributes.isolatePorts === (props.isolatePorts === true),\n /**\n * ⚠️ NO QUERY STRING HERE, HOWEVER TEMPTING. `?pending=1` would surface whether the staged\n * config has been applied, but the factory uses this one path for GET, PUT and DELETE alike,\n * and PVE answers an unexpected parameter on a write with \"parameter verification failed\".\n * That is why staged-ness is documented at the top of this file rather than made an attribute.\n */\n path: (props) => `cluster/sdn/vnets/${props.vnet}`,\n updateForm,\n});\n\n/**\n* ⛔ EMPTY, LIKE EVERY OTHER RESOURCE IN THIS PACKAGE. `GET /cluster/sdn/vnets` answers\n* with every vnet on the cluster, and on an estate already running SDN those are\n* load-bearing bridges with guests on them. Returning them would invite Alchemy to\n* adopt — and therefore one day delete — a network nobody declared here. Adoption is an\n* explicit act.\n \n *\n* ⛔ A DELETE IS STAGED LIKE EVERY OTHER SDN WRITE. The vnet leaves `vnets.cfg` at once and\n* the bridge stays up on every node until `PUT /cluster/sdn` applies the removal, so a\n* plan reporting \"1 deleted\" has taken nothing off the network yet. Nothing here applies\n* on the operator's behalf: see the ⛔ at the top of this file.\n \n */\nexport const ProxmoxSdnVnetProvider = () =>\n Provider.effect(ProxmoxSdnVnet, Effect.succeed(ProxmoxSdnVnet.Provider.of(handlers)));\n",
61
+ "/**\n * `Proxmox.SdnZone` — the network a declared guest sits on, finally declared too.\n *\n * ★ WHY THIS ONE MATTERS MORE THAN IT LOOKS. Every guest NIC here names a bridge —\n * `net0=name=eth0,bridge=vmbr0` — that nothing in this package declares: a hand-built interface,\n * repeated per node, that a container silently depends on. A zone is the first piece of that\n * dependency PVE will let a plan own.\n *\n * ⛔ SDN WRITES ARE STAGED, NOT APPLIED, AND THAT DEFEATS THE FACTORY'S READ-BACK GUARANTEE.\n * POST and PUT under `cluster/sdn/zones` edit `/etc/pve/sdn/zones.cfg` and change NOTHING on any\n * node. The plain GET reads that same staged file back, so `pveOperations` sees its own write,\n * finds the object present, and reports a success in which no node gained an interface. The\n * applied state is a different document — `.running-config` beside it — and `?pending=1` is the\n * read that tells them apart: it returns a merged view with a `state` of new/changed/deleted.\n *\n * ⛔ THE APPLY CANNOT LIVE IN THIS RECONCILE, so it is absent rather than forgotten.\n * `PUT /cluster/sdn` is the atomic pending-to-apply and it applies the WHOLE staged config —\n * every zone, vnet and subnet, on every node. Called from a per-resource reconcile it would push\n * some OTHER resource's half-written zone out to the cluster at whatever point the plan ordering\n * reached this one, and PVE has no pre-apply hook to veto that. The apply belongs to ONE object\n * that depends on all of them — a sibling `Proxmox.SdnApply` over `cluster/sdn`, or a stack-level\n * hook that runs last — so that \"declared\" and \"live on the nodes\" stay two visible steps.\n *\n * ⚠️ SO THESE ATTRIBUTES DESCRIBE THE STAGED ZONE, and there is deliberately no `applied` flag:\n * the factory uses ONE path for GET, PUT and DELETE, and PVE's parameter schemas are closed, so\n * an unexpected `pending` on the PUT is a 400 rather than an ignored hint. Reading `?pending=1`\n * means re-implementing the operations this file exists to share, and an `applied: true` that\n * was never measured is worse than an absent one. Deploying this resource does not change the\n * network; it changes what the next apply will do.\n *\n * ⛔ THE READ THIS RESOURCE PERFORMS NEEDS SDN.Allocate, NOT SDN.Audit, AND AN EARLIER DRAFT OF\n * THIS COMMENT SAID OTHERWISE. Read off the cluster's own schema on 2026-09-13:\n *\n * GET /cluster/sdn/zones -> \"list entries where you have SDN.Audit or SDN.Allocate\"\n * GET /cluster/sdn/zones/{zone} -> {\"check\": [\"perm\", \"/sdn/zones/{zone}\", [\"SDN.Allocate\"]]}\n *\n * `pveOperations.read` calls the ITEM endpoint, so an auditor-shaped `read` lease is REFUSED —\n * and the refusal does not surface as a 403. `read` folds every failure into `undefined`, which\n * the factory reads as \"absent\", so the plan says create, the POST goes out, and PVE answers\n * that the zone already exists. This is the same class as Proxmox.Storage; see\n * docs/privileges.md, \"The failure that does not look like a permission problem\".\n *\n * ⚠️ THE REST OF THE PRIVILEGES. Writes need SDN.Allocate (`/sdn/zones` to create,\n * `/sdn/zones/{zone}` to update or delete); the apply — `Proxmox.SdnApply`, which is what\n * actually publishes any of this — needs SDN.Allocate on `/sdn` itself. SDN.Use is NOT among\n * them: it permits attaching a guest to an existing vnet and nothing else.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { csv, int, text, withClears } from './values.ts';\n\n/** PVE's zone plugins. Which one a zone is decides which fields below it will even accept. */\nexport type SdnZoneType = 'evpn' | 'qinq' | 'simple' | 'vlan' | 'vxlan';\n\nexport interface SdnZoneProps extends WithTarget {\n /**\n * PVE's primary key. ⚠️ AT MOST EIGHT LOWERCASE ALPHANUMERICS, first one a letter: the id lands\n * in generated interface names, so PVE enforces it with a regex whose rejection reads as\n * \"value does not match the regex pattern\" rather than as \"your name is too long\".\n */\n zone: string;\n /**\n * ⛔ CREATE-TIME ONLY. `PUT /cluster/sdn/zones/{zone}` has no `type` parameter at all — a\n * section's type is fixed when it is written. Changing it here is not an update PVE can\n * perform; the ⛔ in `attributes` turns that edit into a refusal instead of a silent no-op.\n */\n type: SdnZoneType;\n /** Accepted by every zone type. Unset means the zone inherits the underlying bridge's MTU. */\n mtu?: number;\n /** ⚠️ WHICH NODES THE ZONE IS DEPLOYED TO. Unset means EVERY node, not none. */\n nodes?: string[];\n /** IPAM plugin id. Unset is the built-in `pve` one — the two are one zone, see `sameIpam`. */\n ipam?: string;\n /** DNS plugin id used to register guest records. */\n dns?: string;\n /** The domain those records are registered under, e.g. `example.internal`. */\n dnszone?: string;\n /** vxlan only, and REQUIRED there: the peer addresses the tunnel mesh is built from. */\n peers?: string[];\n /** evpn only, and required there. PVE's own hyphenated name, so no mapping to get wrong. */\n 'vrf-vxlan'?: number;\n /** qinq only, and required there: the service VLAN tag the zone's vnets are stacked inside. */\n tag?: number;\n /** vlan and qinq only, and required in both: the existing bridge the zone is carved out of. */\n bridge?: string;\n}\n\n/**\n * ⛔ NO `digest` HERE, ON PURPOSE. PVE returns one, but it is the digest of the WHOLE zones.cfg\n * file rather than of this section — declaring a SECOND zone would rewrite this one's stored\n * attributes, and comparing it would report an update on a zone nobody touched.\n */\nexport interface SdnZoneAttributes {\n zone: string;\n type: SdnZoneType;\n /** 0 when unset, which is PVE's \"inherit from the bridge\" rather than an MTU of zero. */\n mtu: number;\n /** Normalised: split, sorted, rejoined. Never compare a raw PVE string to it — see `csv`. */\n nodes: string;\n /** The EFFECTIVE ipam: an absent one is reported as `pve`, because that is what will be used. */\n ipam: string;\n dns: string;\n dnszone: string;\n peers: string;\n 'vrf-vxlan': number;\n tag: number;\n bridge: string;\n /** ⚠️ THE REMINDER IN THE STATE ITSELF: staged config. No value here says a node has the zone. */\n readonly staged: true;\n}\n\nexport interface ProxmoxSdnZone extends Resource<\n 'Proxmox.SdnZone',\n SdnZoneProps,\n SdnZoneAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxSdnZone = Resource<ProxmoxSdnZone>('Proxmox.SdnZone');\n\n/**\n * ⚠️ AN ABSENT `ipam` AND `ipam pve` ARE THE SAME ZONE. `pve` is the built-in default, and whether\n * PVE materialises that word into zones.cfg on create is version-dependent — so comparing the\n * raw values reports an update on the plan immediately AFTER the create, on a zone this provider\n * just wrote itself. Normalising both sides is loop-proof under either behaviour.\n */\nconst sameIpam = (live: string, declared: string | undefined) =>\n (live === '' ? 'pve' : live) === (declared === undefined || declared === '' ? 'pve' : declared);\n\n/**\n * The mutable fields, spread in only when defined.\n *\n * ⚠️ AN EMPTY STRING IS NOT \"UNSET\" FOR AN INTEGER FIELD. `mtu=` fails PVE's parameter check\n * outright instead of clearing the value, so the pool.ts habit of sending `''` for an absent\n * optional does not carry over here. Clearing is a separate verb — see `clearable`.\n */\nconst body = (props: SdnZoneProps): Record<string, string> => ({\n ...(props.bridge === undefined ? {} : { bridge: props.bridge }),\n ...(props.dns === undefined ? {} : { dns: props.dns }),\n ...(props.dnszone === undefined ? {} : { dnszone: props.dnszone }),\n ...(props.ipam === undefined ? {} : { ipam: props.ipam }),\n ...(props.mtu === undefined ? {} : { mtu: String(props.mtu) }),\n ...(props.nodes === undefined ? {} : { nodes: csv(props.nodes) }),\n ...(props.peers === undefined ? {} : { peers: csv(props.peers) }),\n ...(props.tag === undefined ? {} : { tag: String(props.tag) }),\n ...(props['vrf-vxlan'] === undefined ? {} : { 'vrf-vxlan': String(props['vrf-vxlan']) }),\n});\n\n/**\n * Which managed fields PVE will let `delete=` clear, per zone type.\n *\n * ⛔ A PUT THAT SIMPLY OMITS A FIELD DOES NOT CLEAR IT. PVE merges the form into the existing\n * section, so dropping `mtu` from a declaration leaves the old MTU in place and `matches`\n * reports an update on every plan forever — the exact bug this table exists to prevent.\n * ⛔ AND THE LIST CANNOT BE THE SAME FOR EVERY TYPE. `delete=<opt>` dies with \"no such option\"\n * when the option is not in that plugin's schema (`peers` on a simple zone) and with \"unable to\n * delete required option\" when it is required there. `bridge`, `tag`, `peers` and `vrf-vxlan`\n * are required by the only types that accept them, so none of the four is ever clearable: a\n * zone that lost one is a replace, not an update.\n * ⚠️ `ipam` IS OMITTED FOR evpn DELIBERATELY. It is optional on the other four; on evpn its\n * optionality has moved between releases, and a wrong entry here is a hard 400 on EVERY update\n * rather than a cosmetic diff. Dropping `ipam` from an evpn declaration therefore reports an\n * update that does not converge — visible, unlike a wrong delete that breaks the zone.\n */\nconst clearable: Record<SdnZoneType, readonly string[]> = {\n evpn: ['dns', 'dnszone', 'mtu', 'nodes'],\n qinq: ['dns', 'dnszone', 'ipam', 'mtu', 'nodes'],\n simple: ['dns', 'dnszone', 'ipam', 'mtu', 'nodes'],\n vlan: ['dns', 'dnszone', 'ipam', 'mtu', 'nodes'],\n vxlan: ['dns', 'dnszone', 'ipam', 'mtu', 'nodes'],\n};\n\nconst handlers = pveHandlers<SdnZoneProps, SdnZoneAttributes>({\n // ⛔ PVE gates this family's ITEM read on the allocate privilege, not the audit one — see\n // `readRole` in resource.ts. The auditor-shaped lease reads 403, which `read` turns into\n // \"absent\", and the plan then says create for an object that is plainly there.\n readRole: 'provision',\n attributes: (live, props) => {\n /**\n * ⛔ A ZONE OF ANOTHER TYPE IS ANOTHER OBJECT, AND \"ABSENT\" IS THE HONEST ANSWER. A PUT cannot\n * change `type`, and the factory only calls a change `replace` for a resource with no update\n * path — which this is not. Reporting the foreign zone as missing makes reconcile POST, and\n * PVE refuses with \"sdn zone ID 'x' already defined\": a loud, accurate error instead of a\n * silent noop over somebody else's zone. An older PVE that omits `type` falls through.\n */\n const liveType = text(live['type']);\n if (liveType !== '' && liveType !== props.type) return undefined;\n return {\n bridge: text(live['bridge']),\n dns: text(live['dns']),\n dnszone: text(live['dnszone']),\n ipam: text(live['ipam']) === '' ? 'pve' : text(live['ipam']),\n mtu: int(live['mtu'], 0),\n nodes: csv(text(live['nodes'])),\n peers: csv(text(live['peers'])),\n staged: true,\n tag: int(live['tag'], 0),\n type: props.type,\n 'vrf-vxlan': int(live['vrf-vxlan'], 0),\n zone: props.zone,\n };\n },\n collection: () => 'cluster/sdn/zones',\n createForm: (props) => ({ ...body(props), type: props.type, zone: props.zone }),\n /**\n * ⚠️ `type` AND `zone` ARE NOT COMPARED. `zone` is the key the object was read by, and `type` is\n * handled above by refusing to recognise a zone of the wrong one. Comparing either here would\n * produce a diff whose update can never satisfy it.\n */\n matches: (attributes, props) =>\n attributes.mtu === (props.mtu ?? 0) &&\n attributes.nodes === csv(props.nodes) &&\n sameIpam(attributes.ipam, props.ipam) &&\n attributes.dns === (props.dns ?? '') &&\n attributes.dnszone === (props.dnszone ?? '') &&\n attributes.peers === csv(props.peers) &&\n attributes['vrf-vxlan'] === (props['vrf-vxlan'] ?? 0) &&\n attributes.tag === (props.tag ?? 0) &&\n attributes.bridge === (props.bridge ?? ''),\n path: (props) => `cluster/sdn/zones/${props.zone}`,\n updateForm: (props) => {\n const fields = body(props);\n const clear = clearable[props.type].filter((option) => fields[option] === undefined);\n return withClears(fields, clear);\n },\n});\n\n/**\n* ⛔ Empty for the same reason as every other resource here, and with extra force for SDN:\n* `GET /cluster/sdn/zones` answers with the zones the cluster's whole network already\n* runs on. Adopting those would make a later `alchemy destroy` a cluster-wide outage.\n \n *\n* ⛔ A DELETE IS STAGED TOO, AND THAT IS THE HALF PEOPLE FORGET. The section leaves\n* zones.cfg and Alchemy drops the resource, but the zone KEEPS RUNNING on every node\n* until something applies `PUT /cluster/sdn`: a destroy nobody applies reads as complete\n* in the plan and has not happened on the cluster.\n* ⚠️ PVE also refuses to remove a zone that still holds vnets. That refusal is kept — it is\n* the cluster declining to orphan a network because a line left a file.\n \n */\nexport const ProxmoxSdnZoneProvider = () =>\n Provider.effect(ProxmoxSdnZone, Effect.succeed(ProxmoxSdnZone.Provider.of(handlers)));\n",
62
+ "/**\n * `Proxmox.Storage` — one entry in `/etc/pve/storage.cfg`, declared. Cluster-scoped like a pool,\n * which is why `path` and `collection` carry no node segment though a storage is used per node.\n *\n * ★ THIS IS THE OBJECT EVERY CONTAINER ALREADY DEPENDS ON AND NOTHING DECLARES. `LxcProps.storage`\n * and the prefix of `LxcProps.ostemplate` (`local:vztmpl/...`) are bare strings, so a container's\n * rootfs points at something outside the graph: rebuild a node and the plan still reads `noop`\n * right up to the create that fails because the storage is not there. Passing this resource's\n * `storage` attribute into `LxcProps.storage` makes the dependency real — Alchemy orders by data\n * flow, so the storage reconciles first because the container reads a value out of it.\n *\n * ⛔ ONE PRIVILEGE COVERS THIS WHOLE FAMILY AND IT IS `Datastore.Allocate` ON `/storage`. Create,\n * update, delete AND the single-object read all check it — `Datastore.Audit` is not enough for\n * any of them. MEASURED: `GET /storage/local` under the auditor-scoped `read` lease answers 403\n * \"Permission check failed (/storage/local, Datastore.Allocate)\". `pveOperations.read` folds\n * every failure into `undefined`, i.e. \"absent\", because a 404 is a legitimate answer there and\n * it cannot tell the two apart — so under that lease this resource NEVER CONVERGES, in two\n * directions: reconcile reads \"absent\" and POSTs a create over a storage that is already defined,\n * and where a create does land the read-back is 403 too, so reconcile dies with \"the write\n * returned no error but the object is still absent\" about an object it has just built. Both\n * messages point away from the cause.\n * ★ SO WIDEN OR RE-POINT BEFORE THE FIRST PLAN, outside this file: give the credential mount's\n * `read` role `Datastore.Allocate` on `/storage`, or read this family with `provision`. The\n * provision role in the estate this was written for holds `Datastore.AllocateSpace` and\n * `Datastore.Audit`, and NEITHER IS IT — AllocateSpace writes volumes INTO a storage, Allocate\n * DEFINES one — so it 403s here until widened the way `Pool.Allocate` was for `Proxmox.Pool`.\n *\n * ⛔ THERE IS NO `password` PROP AND THERE MUST NEVER BE ONE. PBS and CIFS storages take one at\n * create time, and Alchemy persists attributes UNENCRYPTED — a secret in props is one careless\n * line away from being an attribute, and from there it is in the state store's nightly dump. So\n * `StorageLocator` types `password`, `keyring` and `encryption-key` as `never`: declaring one is\n * a COMPILE ERROR rather than a leak somebody finds in a backup months later. Set it once out of\n * band (`pvesm set <id> --password`); PVE never returns it on read, so nothing here could diff it\n * anyway.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { bool, flag } from './values.ts';\n\n/**\n * The create-time, plugin-specific half of a storage: `dir` wants `path`, `nfs` `server`+`export`,\n * `cifs` `server`+`share`, `pbs` `server`+`datastore`, `rbd` `pool`+`monhost`, `lvmthin`\n * `vgname`+`thinpool`, `zfspool` `pool`. A bag rather than two dozen named fields, because PVE\n * ships about that many plugins and each brings its own locator. ⚠️ Never diffed — see `matches`.\n *\n * ⛔ `password`, `keyring` AND `encryption-key` ARE `never` ON PURPOSE — see the ⛔ in the header.\n * POSITIVE-CONTROLLED rather than assumed: all three are a compile error, `TS2322: Type 'string'\n * is not assignable to type 'undefined'`.\n */\nexport type StorageLocator = Record<string, string> & {\n password?: never;\n keyring?: never;\n 'encryption-key'?: never;\n};\n\nexport interface StorageProps extends WithTarget {\n /** PVE's primary key, cluster-wide — the string an LXC's `storage` and `ostemplate` name. */\n storage: string;\n /**\n * `dir` | `nfs` | `cifs` | `pbs` | `zfspool` | `lvmthin` | `rbd` | … ⚠️ CREATE-ONLY, so a changed\n * `type` plans as `noop` (see `matches`). PVE cannot retype a storage: remove and redeclare.\n */\n type: string;\n /** ⚠️ Create-only, one shape per plugin. See `StorageLocator`. */\n locator?: StorageLocator;\n /** `images,rootdir,vztmpl,iso,backup,snippets`. PVE reports `none` for an empty set. */\n content?: string;\n /**\n * Node restriction, e.g. `n1,n2`. ⚠️ A STORAGE WITH A `nodes` LIST DOES NOT EXIST ANYWHERE ELSE:\n * an LXC declared on a node outside it fails at create with \"storage not available on node\".\n */\n nodes?: string;\n /** Keeps the definition but stops PVE using it. */\n disable?: boolean;\n /** Tells PVE the same volumes are visible from every node — a claim, not a mechanism. */\n shared?: boolean;\n /** `off` | `metadata` | `falloc` | `full`. File-based plugins only. */\n preallocation?: string;\n /**\n * `keep-last=3,keep-daily=7,…`. ⚠️ THE WIRE NAME IS KEPT, HYPHEN AND ALL: a `pruneBackups` that\n * quietly becomes `prune-backups` in the form body is a second name for one thing.\n */\n 'prune-backups'?: string;\n comment?: string;\n /**\n * ⚠️ THE DEPRECATED PREDECESSOR OF `prune-backups`, and the two do not mix — declare one or the\n * other. `0` means UNLIMITED to PVE rather than \"unset\", hence the `-1` in the attribute.\n */\n maxfiles?: number;\n}\n\nexport interface StorageAttributes {\n storage: string;\n /** Reported so a plan can show what it points at; never diffed — see `type` above. */\n type: string;\n content: string;\n nodes: string;\n disable: boolean;\n shared: boolean;\n preallocation: string;\n 'prune-backups': string;\n comment: string;\n /** ⚠️ `-1` means \"no maxfiles in storage.cfg\". `0` is a real setting meaning unlimited. */\n maxfiles: number;\n}\n\nexport interface ProxmoxStorage extends Resource<\n 'Proxmox.Storage',\n StorageProps,\n StorageAttributes,\n never,\n PveRequirements\n> {}\n\n/** ★ `retain` by default — a storage holding volumes cannot be rebuilt. See the ★ in resource.ts. */\nexport const ProxmoxStorage = Resource<ProxmoxStorage>('Proxmox.Storage', {\n defaultRemovalPolicy: 'retain',\n});\n\nconst str = (value: unknown, fallback = '') => (typeof value === 'string' ? value : fallback);\n\nconst field = (name: string, value: string | undefined): Record<string, string> =>\n value === undefined ? {} : { [name]: value };\n\n/**\n * ⚠️ THE CAST DROPS THE THREE `never` GUARDS AND NOTHING ELSE, and it is load-bearing rather than\n * lazy: an intersection carrying OPTIONAL properties is not assignable to `Record<string,string>`\n * at all, so the guards and the form body cannot both exist without one conversion. At runtime a\n * locator is a plain string map; the guards only ever existed to fail a declaration.\n */\nconst locatorForm = (locator: StorageLocator | undefined) =>\n ({ ...locator }) as Record<string, string>;\n\n/**\n * ⚠️ PVE RE-SERIALISES ITS LIST FIELDS IN ITS OWN ORDER — `content` and `nodes` are parsed into a\n * set and written back sorted, `prune-backups` is a property string that comes back in schema\n * order. Comparing raw strings would report an update for `iso,backup` against `backup,iso` on\n * every plan, and the PUT would \"fix\" it into the identical string. Trimming matters too: a\n * declared `iso, backup` would otherwise never equal what PVE stores.\n */\nconst tokens = (value: string) =>\n value\n .split(',')\n .map((part) => part.trim())\n .filter((part) => part !== '')\n .sort()\n .join(',');\n\nconst sameList = (declared: string | undefined, live: string) =>\n declared === undefined || tokens(declared) === tokens(live);\n\nconst same = <T>(declared: T | undefined, live: T) => declared === undefined || declared === live;\n\n/**\n * The mutable half, for create and update alike.\n *\n * ⚠️ AN UNDECLARED FIELD IS NEITHER SENT NOR COMPARED: undeclared means UNMANAGED here, unlike\n * `Proxmox.Pool` where an absent comment means `''`. A storage has no single default to fall back\n * on — `content` defaults per plugin, and clearing a field needs an explicit `delete=` parameter\n * rather than an empty value — so a guessed default would rewrite a storage somebody tuned by\n * hand, and comparing one would report drift nobody declared.\n *\n * ⚠️ RECONCILE PUTs UNCONDITIONALLY whenever the object exists (resource.ts), so this form must be\n * safe to re-apply to a storage that already matches. It is: the declared set and nothing else,\n * and PVE leaves absent parameters alone.\n */\nconst mutable = (props: StorageProps): Record<string, string> => ({\n ...field('comment', props.comment),\n ...field('content', props.content),\n ...field('disable', flag(props.disable)),\n ...field('maxfiles', props.maxfiles === undefined ? undefined : String(props.maxfiles)),\n ...field('nodes', props.nodes),\n ...field('preallocation', props.preallocation),\n ...field('prune-backups', props['prune-backups']),\n ...field('shared', flag(props.shared)),\n});\n\nconst handlers = pveHandlers<StorageProps, StorageAttributes>({\n // ⛔ PVE gates this family's ITEM read on the allocate privilege, not the audit one — see\n // `readRole` in resource.ts. The auditor-shaped lease reads 403, which `read` turns into\n // \"absent\", and the plan then says create for an object that is plainly there.\n readRole: 'provision',\n /**\n * ⚠️ `digest` IS DELIBERATELY NOT AN ATTRIBUTE. PVE returns one on every storage read and it\n * covers storage.cfg as a FILE, not this section of it, so keeping it would rewrite this\n * resource's state whenever an unrelated storage was edited — churn that reads like drift.\n */\n attributes: (live, props) => ({\n comment: str(live['comment']),\n content: str(live['content']),\n disable: bool(live['disable']),\n maxfiles: typeof live['maxfiles'] === 'number' ? live['maxfiles'] : -1,\n nodes: str(live['nodes']),\n preallocation: str(live['preallocation']),\n 'prune-backups': str(live['prune-backups']),\n shared: bool(live['shared']),\n storage: props.storage,\n type: str(live['type'], props.type),\n }),\n collection: () => 'storage',\n /**\n * ⚠️ THE BAG IS SPREAD FIRST SO NOTHING IN IT CAN SHADOW A FIELD THIS RESOURCE MANAGES. A stray\n * `storage` or `type` in a locator would otherwise rename the object being created, and PVE\n * would build the wrong thing under a name Alchemy then records as the declared one.\n */\n createForm: (props) => ({\n ...locatorForm(props.locator),\n ...mutable(props),\n storage: props.storage,\n type: props.type,\n }),\n /**\n * ⚠️ `type` AND THE LOCATOR ARE NEVER COMPARED, AND AN UNDECLARED FIELD IS NOT COMPARED EITHER.\n * PVE returns the create-only fields on read but refuses them on PUT, so diffing one could only\n * plan an update that no write can apply: a plan that reports work on every run, forever.\n */\n matches: (attributes, props) =>\n sameList(props.content, attributes.content) &&\n sameList(props.nodes, attributes.nodes) &&\n sameList(props['prune-backups'], attributes['prune-backups']) &&\n same(props.disable, attributes.disable) &&\n same(props.shared, attributes.shared) &&\n same(props.preallocation, attributes.preallocation) &&\n same(props.comment, attributes.comment) &&\n same(props.maxfiles, attributes.maxfiles),\n path: (props) => `storage/${props.storage}`,\n updateForm: mutable,\n});\n\n/**\n* ⛔ EMPTY, AND HERE IT MATTERS MORE THAN ANYWHERE ELSE IN THIS PACKAGE. `GET /storage`\n* returns every definition on the cluster, `local` and `local-lvm`/`local-zfs` included:\n* the installer's own, that every guest's rootfs sits on. Adopting those would put\n* Alchemy one `delete` away from the cluster's disks. Adoption is explicit, always.\n \n *\n* ⚠️ THIS REMOVES THE DEFINITION, NOT THE DATA. PVE drops the section from storage.cfg and\n* leaves the volumes on disk untouched — so the loss is not the bytes, it is that guests\n* whose config still names this storage can no longer resolve their own disks.\n \n */\nexport const ProxmoxStorageProvider = () =>\n Provider.effect(ProxmoxStorage, Effect.succeed(ProxmoxStorage.Provider.of(handlers)));\n",
63
+ "/**\n * `Proxmox.User` — a PVE account. The identity every other resource in this package borrows.\n *\n * ★ THIS IS THE ONE OBJECT THAT CAN CUT THE BRANCH IT SITS ON. The user the credential mount vends\n * tokens for, and the group whose members are allowed to mint, are what `src/credentials.ts`\n * ultimately asks OpenBao for. A cluster rebuilt without them cannot plan ANY resource here —\n * including the plan that would recreate them, which needs a credential to run. So this resource\n * is drift repair for an account that already exists (comment, email, enable, expire, groups),\n * not a bootstrap: the first mint user is made on a node with `pveum user add`, by a human, once.\n *\n * ⛔ THERE IS NO `password` PROP, AND ADDING ONE WOULD BE A LEAK RATHER THAN A FEATURE. Alchemy\n * writes resource state WITHOUT encryption — see the ⛔ in `credentials.ts` — so a password prop\n * would sit in clear in whatever database the stack points `state` at, and in every backup of it.\n * It is also unnecessary: `password` is accepted only by the CREATE call, changing one afterwards\n * is `PUT /access/password` (a different endpoint, a different privilege), and an account in a\n * realm such as `@pam`, `@ldap` or `@openid` has no PVE-side password at all — the realm holds\n * it. Out of scope by design. `keys` (TFA) is omitted for the same reason.\n *\n * ⚠️ `groups` COMES BACK AS AN ARRAY AND GOES OUT AS A COMMA STRING, and the asymmetry is the whole\n * trap. GET answers `[\"a\",\"b\"]`, POST/PUT want `a,b`, and PVE returns the list in ITS order, not\n * the declared one. Compared naively, `matches` reads ['b','a'] against 'a,b' and every plan for\n * the rest of time says \"1 to update\". Both sides are normalised to a sorted, deduplicated set\n * below. Joining is a safe comparison precisely because a group id cannot contain a comma — the\n * wire format is comma-separated, so PVE refuses one.\n *\n * ⚠️ `tokens` IS NESTED AND IS NOT SETTABLE THROUGH THIS ENDPOINT. The read hands back a map of the\n * account's API tokens; `PUT /access/users/{userid}` has no parameter for them, because they are\n * their own objects under `.../token/{tokenid}`. So they are reported as an attribute — a plan\n * can then say what a delete would take with it — and kept OUT of `matches`, exactly like\n * `pool.members`. Reported, never declared.\n *\n * ⚠️ RECONCILE NEEDS PRIVILEGES `LXCProvisioner` DOES NOT HOLD, so state them rather than meet a\n * 403 in the middle of a deploy (pool.ts records how that went the last time):\n * · `Realm.AllocateUser` on `/access/realm/<realm>` — create and delete.\n * · `User.Modify` on `/access/groups`, and on `/access/groups/<group>` for EVERY group named in\n * `groups` — create, update and delete. PVE checks the groups you are granting, not just the\n * user, so a role wide enough to edit the account can still be refused for one group in the\n * list.\n * · `Sys.Audit` (or `User.Modify`) for the read, which the `read` role's auditor already has.\n * `Permissions.Modify` is NOT on this list: that governs ACL entries, which are a different PVE\n * object and would be a different resource here.\n *\n * ⚠️ A MISSING USER IS A 500, NOT A 404 — \"no such user ('x@pve')\" — and the factory turns any\n * failed read into \"absent\". A 403 therefore also reads as absent, and the honest error arrives\n * one step later, from the create: \"Permission check failed (/access/groups, User.Modify)\". That\n * string is the one to grep for when a plan insists on creating an account that plainly exists.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport { type PveRequirements, type WithTarget, pveHandlers } from './resource.ts';\nimport { bool } from './values.ts';\n\nexport interface UserProps extends WithTarget {\n /**\n * ⛔ REALM-QUALIFIED, ALWAYS: `someone@pve`, `someone@pam`. The realm is part of PVE's primary\n * key, and a bare name is refused with \"value does not look like a valid user id\".\n *\n * ⚠️ PVE HAS NO RENAME. Editing this prop makes the path point at a DIFFERENT account, which\n * reads as absent and is then created — while the old one stays on the cluster with its tokens\n * and its ACL entries. Renaming is a delete and a create, and should be declared as one.\n */\n userid: string;\n /** Free text shown in the UI. */\n comment?: string;\n /** PVE accepts the empty string here; that is how an address is cleared. */\n email?: string;\n /** Default true, matching PVE's own `enable=1`. False disables login without deleting anything. */\n enable?: boolean;\n /** Seconds since the epoch. 0 — the default — means the account never expires. */\n expire?: number;\n /** Group memberships. Order and duplicates carry no meaning — see the ⚠️ in the header. */\n groups?: string[];\n firstname?: string;\n lastname?: string;\n}\n\nexport interface UserAttributes {\n userid: string;\n comment: string;\n email: string;\n enable: boolean;\n expire: number;\n /** Normalised: sorted, deduplicated, whatever shape the cluster used on the wire. */\n groups: string[];\n firstname: string;\n lastname: string;\n /**\n * API token names this account owns. Reported so a plan can show what a delete would revoke;\n * never compared, because this endpoint cannot set them.\n */\n tokens: string[];\n}\n\nexport interface ProxmoxUser extends Resource<\n 'Proxmox.User',\n UserProps,\n UserAttributes,\n never,\n PveRequirements\n> {}\n\nexport const ProxmoxUser = Resource<ProxmoxUser>('Proxmox.User');\n\nconst str = (value: unknown) => (typeof value === 'string' ? value : '');\n\n/**\n * ⚠️ MORE FORGIVING THAN `lxc.ts`'s `num`, ON PURPOSE. PVE's JSON is generated from a Perl schema\n * and an integer field can arrive as `0` or as `\"0\"` depending on the release and the endpoint. A\n * strict `typeof === 'number'` would silently fall back to 0 for the string form, so a declared\n * `expire` would never equal the live one and the plan would report an update it cannot settle.\n */\nconst int = (value: unknown) => {\n const parsed = typeof value === 'number' ? value : Number(value ?? 0);\n return Number.isFinite(parsed) ? parsed : 0;\n};\n\n/**\n * An array (what the read returns), a comma string (what older releases and the write side use), or\n * nothing — in; a sorted, deduplicated list out. Both sides of `matches` go through this, which is\n * the only reason the diff ever settles.\n */\nconst groupSet = (value: unknown): string[] => {\n const raw: unknown[] = Array.isArray(value)\n ? value\n : typeof value === 'string'\n ? value.split(',')\n : [];\n const names = raw.map((group) => str(group).trim()).filter((group) => group !== '');\n return [...new Set(names)].sort();\n};\n\n/**\n * ⚠️ THE SHAPE DEPENDS ON WHICH ENDPOINT YOU ASKED. Reading ONE user gives an object keyed by token\n * name; the collection read gives an array of records. This provider only ever reads the single\n * user path, so the map is what arrives — anything else is reported as \"no tokens\" rather than\n * guessed at, because a wrong guess here would show up as a phantom revocation in a plan.\n */\nconst tokenNames = (value: unknown): string[] =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n ? Object.keys(value).sort()\n : [];\n\n/** Everything mutable, in the form PVE wants. Create adds `userid`; update sends exactly this. */\nconst shape = (props: UserProps) => ({\n comment: props.comment ?? '',\n email: props.email ?? '',\n enable: props.enable === false ? '0' : '1',\n expire: String(props.expire ?? 0),\n firstname: props.firstname ?? '',\n /**\n * ⚠️ ALWAYS SENT, EVEN EMPTY. Omitting `groups` on a PUT leaves the existing memberships in\n * place, so a group removed from the declaration would never actually be removed — and\n * `matches` would keep reporting an update that the update cannot fix. Same for `email` and\n * `comment`: the empty string is how PVE is told to clear a field.\n * ⚠️ AND `append` IS DELIBERATELY NOT SET. Its default (0) REPLACES the list; setting it to 1\n * would turn every reconcile into an add-only merge, which is the same non-settling diff.\n */\n groups: groupSet(props.groups).join(','),\n lastname: props.lastname ?? '',\n});\n\nconst handlers = pveHandlers<UserProps, UserAttributes>({\n attributes: (live, props) => ({\n comment: str(live['comment']),\n email: str(live['email']),\n /**\n * ⚠️ ABSENT MEANS ENABLED. PVE's schema defaults `enable` to 1 and does not always write the\n * key back for an enabled account. Reading absence as `false` would report an update on every\n * plan and then DISABLE the account on the deploy that \"fixed\" it.\n */\n enable: bool(live['enable'], true),\n expire: int(live['expire']),\n firstname: str(live['firstname']),\n groups: groupSet(live['groups']),\n lastname: str(live['lastname']),\n tokens: tokenNames(live['tokens']),\n /** ⚠️ FROM PROPS: `GET /access/users/{userid}` does not echo the userid back in its data. */\n userid: props.userid,\n }),\n collection: () => 'access/users',\n createForm: (props) => ({ ...shape(props), userid: props.userid }),\n /**\n * ⚠️ `tokens` IS NOT COMPARED, and neither is anything create-only. What is compared is exactly\n * what a PUT can put back; a field that PVE reports but will not accept is drift nobody can\n * fix, and diffing it would report an update on every plan forever.\n */\n matches: (attributes, props) =>\n attributes.comment === (props.comment ?? '') &&\n attributes.email === (props.email ?? '') &&\n attributes.enable === (props.enable !== false) &&\n attributes.expire === (props.expire ?? 0) &&\n attributes.firstname === (props.firstname ?? '') &&\n attributes.lastname === (props.lastname ?? '') &&\n attributes.groups.join(',') === groupSet(props.groups).join(','),\n path: (props) => `access/users/${props.userid}`,\n updateForm: shape,\n});\n\n/**\n* ⛔ EMPTY, AND MORE POINTEDLY SO HERE THAN ANYWHERE ELSE. `GET /access/users` answers with\n* every account on the cluster: `root@pam`, every human who logs in, every service\n* identity someone made years ago. Handing that list to Alchemy would invite it to adopt\n* — and therefore one day DELETE — people. Adoption is an explicit act.\n \n *\n* ⛔ DELETING A USER TAKES ITS API TOKENS AND ITS ACL ENTRIES WITH IT, in one call and\n* without a confirmation. For the identity a credential mount vends from, that revokes\n* every outstanding lease at once and every plan in this package stops working — this one\n* included. PVE refuses only for `root@pam`; for everyone else it simply obeys.\n \n */\nexport const ProxmoxUserProvider = () =>\n Provider.effect(ProxmoxUser, Effect.succeed(ProxmoxUser.Provider.of(handlers)));\n",
64
+ "/**\n * `Proxmox.ZfsPool` — a zpool built on one node's physical disks, declared.\n *\n * ⛔ A CREATE HERE WIPES THE DISKS IT IS GIVEN AND THERE IS NO UNDO. `POST /nodes/{node}/disks/zfs`\n * runs `zpool create` on the block devices named in `devices`; whatever was on them is gone the\n * moment the worker runs. Every other decision in this file follows from that one sentence, and\n * each of them is written out below rather than left to be inferred.\n *\n * ⛔ DESTROY IS REFUSED. `delete` MAKES NO API CALL — removing this resource from a stack leaves\n * the zpool and its data exactly where they are, and Alchemy simply forgets about them. The\n * asymmetry is the whole argument: an ORPHANED pool is recoverable (declare it again, or destroy\n * it by hand once a human has looked at which disks are in it), a DESTROYED pool is not. Alchemy\n * deletes for reasons that have nothing to do with anybody intending it — a line removed from a\n * stack file, a resource renamed so the old id is dropped, a whole stack torn down by the wrong\n * command, a replace triggered by a prop nobody meant to touch. Handing `zpool destroy` to any\n * of those is not a feature. MEASURED in the node's own source: the DELETE handler forks\n * `zfsremove`, which runs `zpool destroy <name>` unconditionally, and with `cleanup-disks` then\n * calls `wipe_blockdev` on every member. Neither flag is offered as a prop, because there is no\n * call here for them to reach.\n * ★ THE OPERATOR'S PATH IS `pvesh delete /nodes/<node>/disks/zfs/<name>`, typed by a person who\n * has just looked at the pool. Do not \"complete the CRUD\" by wiring `delete` to `ops.destroy`:\n * that one line turns a text edit into an unrecoverable one.\n *\n * ⛔ THERE IS NO PUT ON THIS FAMILY AT ALL. MEASURED from the cluster's own published schema\n * (`/usr/share/pve-docs/api-viewer/apidoc.js`, read on n2 2026-09-13): `/nodes/{node}/disks/zfs`\n * has GET and POST, `/nodes/{node}/disks/zfs/{name}` has GET and DELETE, and that is the whole\n * surface. So `updateForm` is omitted — which, per `resource.ts`, makes any `matches` = false a\n * REPLACE. A replace is a delete followed by a create, and on this family the delete is the\n * thing above. Read the ⛔ on `matches` before adding anything to it.\n *\n * ⛔ NOT ONE CREATE PARAMETER COMES BACK ON READ, SO `matches` COMPARES NOTHING. MEASURED against\n * the live cluster: `GET /nodes/n2/disks/zfs/rpool` answers exactly\n * `{action, children, errors, leaf, name, scan, state, status}` — no `ashift`, no `compression`,\n * no `raidlevel`, no `devices`, no `add_storage`. Every create parameter is write-only. There is\n * therefore no field a declaration and a live pool can both be asked about, and a `matches` that\n * invented one would plan a replace — i.e. a `zpool destroy` — over a difference it could never\n * verify in the first place.\n *\n * ⚠️ AND WHAT THE INDEX RETURNS IS LIVE TELEMETRY, NOT CONFIGURATION. `GET /nodes/n2/disks/zfs`\n * gives `alloc`, `free`, `frag`, `dedup`, `size`, `health`. MEASURED: two reads of n2 seconds\n * apart returned `alloc` 14474944512 then 14472740864 — it moves on its own, with no declaration\n * anywhere near it. `scan` in the detail read moves the same way (it carries the last scrub), and\n * `status`/`action` appear and vanish as ZFS feature flags and faults come and go. None of them\n * is compared, and the three churning strings are kept out of the state store entirely rather\n * than rewriting this resource's row every time somebody writes a file.\n *\n * ⚠️ TWO HANDLERS ARE OVERRIDDEN AND THE OTHER THREE COME FROM THE FACTORY — see the ★ above\n * `handlers`. `delete` is the ⛔ above. `reconcile` is because the create is a FORKED WORKER, so\n * the factory's immediate read-back would report a successful create as a failure; the measured\n * detail is in the ⛔ on `createPool` in zfs-pool-create.ts.\n *\n * ⚠️ PRIVILEGES, FROM THE SCHEMA. Read and diff need `Sys.Audit` on `/` — both GETs check it.\n * Reconcile needs `Sys.Modify` on `/` for the POST. `Datastore.Allocate` on `/storage` is NOT\n * needed, because `add_storage` is not offered — see the ⛔ on `ZfsPoolProps`. `delete` needs\n * nothing at all, since it calls nothing.\n */\nimport { Resource } from 'alchemy';\nimport * as Provider from 'alchemy/Provider';\nimport * as Effect from 'effect/Effect';\nimport {\n type PveRequirements,\n type PveSpec,\n type WithTarget,\n pveHandlers,\n pveOperations,\n} from './resource.ts';\nimport { text } from './values.ts';\nimport { createForm, createPool, destroyPool } from './zfs-pool-write.ts';\n\n/** PVE's layouts. ⚠️ Each has a minimum disk count PVE enforces, and `raid10` needs an even one. */\nexport type ZfsRaidLevel =\n | 'single'\n | 'mirror'\n | 'raid10'\n | 'raidz'\n | 'raidz2'\n | 'raidz3'\n | 'draid'\n | 'draid2'\n | 'draid3';\n\nexport type ZfsCompression = 'on' | 'off' | 'gzip' | 'lz4' | 'lzjb' | 'zle' | 'zstd';\n\n/**\n * ⛔ THERE IS NO `add_storage`, `cleanup-config` OR `cleanup-disks` PROP, AND THAT IS NOT AN\n * OVERSIGHT. The last two belong to the DELETE this resource refuses to make. `add_storage=1`\n * would have the POST build a `Proxmox.Storage`-shaped object this resource does not own, cannot\n * see on any later read, and cannot remove — invisible to every diff forever, and a collision\n * waiting for the day somebody also declares the storage properly. Declare a `Proxmox.Storage`\n * with `type: 'zfspool'` and `locator: { pool: <this pool's name> }` instead, reading the `name`\n * attribute below so Alchemy orders the storage after the pool.\n */\nexport interface ZfsPoolProps extends WithTarget {\n /**\n * ⛔ A ZPOOL IS NODE-LOCAL AND THIS IS HALF ITS IDENTITY. Changing it moves nothing: `path` then\n * points at a different node, the read answers absent, and reconcile tries to CREATE the pool\n * over there — on whatever `/dev/...` happens to answer to those names on that machine.\n * Declare a separate resource per node instead.\n */\n node: string;\n /** The zpool name, and PVE's key for it on this node. ⚠️ Changing it creates a SECOND pool. */\n name: string;\n /**\n * The block devices to build it on.\n *\n * ⛔ NAME THEM BY `/dev/disk/by-id/...`, NOT `/dev/sdb`. Kernel names are not stable across\n * reboots; a by-id link is. MEASURED in the node's source: PVE resolves what it is handed to a\n * by-id link only AFTER it has decided the device is free, so a stale `/dev/sdb` in a stack\n * file is checked against, and then wiped, whichever disk currently answers to that name.\n * ⚠️ ORDER IS MEANING FOR `raid10` AND IS PRESERVED — PVE walks the list two at a time and makes\n * each pair a mirror. This is why the form uses a plain join and NOT `csv()` from values.ts:\n * `csv` sorts, and sorting this list silently re-pairs the mirrors into a different pool.\n * ⚠️ PVE's only guard is `assert_disk_unused`, i.e. its own `disk_is_used` over the same `used`\n * column the Disks view shows. A blank disk it considers free is wiped with no confirmation.\n */\n devices: readonly string[];\n raidlevel: ZfsRaidLevel;\n /**\n * Sector size exponent, 9–16, PVE default 12.\n *\n * ⛔ WRITE-ONLY AND IMMUTABLE FOR THE LIFE OF THE POOL. It is consumed by `zpool create -o\n * ashift=` and never returned by any read on this family, so changing it later plans as `noop`\n * and changes nothing. A different ashift means destroying and rebuilding the pool, by hand,\n * with the data moved off first.\n */\n ashift?: number;\n /**\n * ⚠️ Write-only in the same way as `ashift`: applied by `zfs set compression=` at create time and\n * never read back, so a later change plans `noop`. Change it with `zfs set` on the node.\n */\n compression?: ZfsCompression;\n /**\n * `data=<integer>,spares=<integer>`. ⚠️ THE WIRE NAME IS KEPT, HYPHEN AND ALL, for the reason\n * `storage.ts` keeps `prune-backups`: a second spelling is a second name for one thing.\n * ⚠️ PVE refuses it outright unless `raidlevel` is one of the `draid*` levels.\n */\n 'draid-config'?: string;\n}\n\n/**\n * ⚠️ EVERYTHING HERE IS REPORTED, NOTHING HERE IS COMPARED — see the ⛔ on `matches`. These exist\n * so a plan and the state store can say what the pool actually is, on a family where the\n * declaration and the live object share no comparable field at all.\n */\nexport interface ZfsPoolAttributes {\n /** ★ The value a `Proxmox.Storage` should read to order itself after this pool. */\n name: string;\n node: string;\n /** `ONLINE` | `DEGRADED` | `FAULTED` | … Health, not configuration. */\n state: string;\n /** ZFS's own error summary, e.g. `No known data errors`. */\n errors: string;\n /**\n * The leaf devices ZFS reports, in vdev order, comma-joined.\n *\n * ⚠️ THIS IS WHAT ZFS RESOLVED, NOT WHAT WAS DECLARED, and the two normally differ: PVE rewrites\n * a `/dev/sdb` into a by-id link before creating, and ZFS reports partition paths (`…-part3`)\n * for a pool built on partitions — MEASURED, that is exactly what n2's `rpool` reports. Never\n * compare it with `props.devices`.\n */\n devices: string;\n}\n\nexport interface ProxmoxZfsPool extends Resource<\n 'Proxmox.ZfsPool',\n ZfsPoolProps,\n ZfsPoolAttributes,\n never,\n PveRequirements\n> {}\n\n/** ★ `retain` by default — a pool holding datasets cannot be rebuilt. See the ★ in resource.ts. */\nexport const ProxmoxZfsPool = Resource<ProxmoxZfsPool>('Proxmox.ZfsPool', {\n defaultRemovalPolicy: 'retain',\n});\n\n/**\n * The device paths at the bottom of PVE's vdev tree, in the order ZFS reports them.\n *\n * ⚠️ \"NO CHILDREN\" IS THE LEAF TEST, AND IT IS NOT A GUESS — MEASURED in the node's `preparetree`,\n * which sets `leaf` to 0 when there are children and 1 otherwise. Reading the flag would work\n * equally well; recursing on `children` needs no second field to be present and is what makes\n * nested sections (mirrors inside a raid10, `spares`, `cache`) flatten correctly.\n */\nconst leafDevices = (children: unknown): string[] =>\n Array.isArray(children)\n ? children.flatMap((entry: unknown) => {\n const vdev = entry as { children?: unknown; name?: unknown };\n const nested = leafDevices(vdev.children);\n return nested.length > 0 ? nested : [text(vdev.name)].filter((name) => name !== '');\n })\n : [];\n\nconst spec: PveSpec<ZfsPoolProps, ZfsPoolAttributes> = {\n /**\n * ⚠️ `scan`, `status` AND `action` ARE DELIBERATELY NOT ATTRIBUTES. All three are advisory\n * strings ZFS rewrites on its own — `scan` on every scrub, the other two as feature flags and\n * faults come and go — so keeping them would rewrite this resource's state row for reasons no\n * declaration caused. Same reasoning as `digest` in storage.ts.\n */\n attributes: (live, props) => {\n // ⚠️ A detail answer with no `name` is not a pool. `name` is non-optional in PVE's schema, so\n // this is a shape check rather than a default — and \"absent\" is the honest reading of a\n // reply that does not describe the object that was asked for.\n if (text(live['name']) === '') return undefined;\n return {\n devices: leafDevices(live['children']).join(','),\n errors: text(live['errors'], 'unknown'),\n name: props.name,\n node: props.node,\n state: text(live['state'], 'unknown'),\n };\n },\n collection: (props) => `nodes/${props.node}/disks/zfs`,\n createForm,\n /**\n * ⛔ IT ALWAYS ANSWERS TRUE, AND THAT IS THE POINT OF THIS FILE. A pool that is there under the\n * declared name on the declared node IS the declaration, because there is nothing else the two\n * can be compared on: every create parameter is write-only (see the ⛔ in the header) and\n * everything the read does return is telemetry that moves by itself. So declaring what is live\n * plans as `noop` — the only honest answer available, and the one the live cluster needs:\n * `rpool` exists on n2, n3 and n4 with nothing about its construction readable.\n * ⛔ ANYTHING ADDED HERE IS A REPLACE, NOT AN UPDATE. `updateForm` is omitted because PVE has\n * no PUT, so `resource.ts` turns a false into `{action:'replace'}` — delete then create — on\n * a family whose delete is `zpool destroy`. A comparison added here would be one plan away\n * from destroying a pool over a field it cannot even read back. If a future PVE grows a PUT,\n * add `updateForm` FIRST and only then consider comparing what that PUT accepts.\n */\n matches: () => true,\n path: (props) => `nodes/${props.node}/disks/zfs/${props.name}`,\n};\n\nconst ops = pveOperations(spec);\n\n/**\n * ★ THREE HANDLERS COME FROM THE FACTORY AND TWO DO NOT, SO THE TWO ARE THE ONLY ONES WRITTEN OUT.\n * `list`, `read` and `diff` are the factory's, unchanged — the spread is what proves it, rather\n * than three re-typed delegations nobody rereads. `reconcile` and `delete` are the two the header\n * explains, and they are the only places this family departs from every other resource here.\n * This is the acl.ts precedent, for a different reason: there the factory's delete hits an\n * endpoint PVE does not implement, here it hits one that works and destroys the data.\n */\nconst handlers = {\n ...pveHandlers(spec),\n delete: Effect.fn(function* ({ olds }: { olds: ZfsPoolProps }) {\n yield* destroyPool(olds, spec.path(olds));\n }),\n reconcile: ({ news }: { news: ZfsPoolProps }) =>\n createPool(news, spec.collection(news), spec.path(news), ops.read),\n};\n\nexport const ProxmoxZfsPoolProvider = () =>\n Provider.effect(ProxmoxZfsPool, Effect.succeed(ProxmoxZfsPool.Provider.of(handlers)));\n",
65
+ "/**\n * The create lane for `Proxmox.ZfsPool`: the form PVE wants, and the wait for the worker it forks.\n *\n * ★ SPLIT OUT OF zfs-pool.ts TO KEEP BOTH FILES UNDER THE 250-LINE CAP, and the seam is a real one\n * rather than a convenient line number. This file answers \"how does a declaration become a pool\n * on disks, and how do we know it landed\". zfs-pool.ts answers \"what is a zpool, what can be\n * said about a live one, and when has it changed\" — and on this family the answer to the last of\n * those is \"never\", which is why the two halves have so little to say to each other.\n *\n * ⚠️ THE `import type` BACK TO zfs-pool.ts IS A CYCLE ON PAPER ONLY — it is type-only, so it is\n * erased before anything runs, and the resource's public shape stays in the file that declares\n * the resource rather than being moved somewhere odd to dodge the arrow. Same as\n * metric-server-form.ts.\n *\n * ⚠️ `createPool` TAKES THE READ AS A PARAMETER, GENERIC IN ITS ERROR AND REQUIREMENT CHANNELS,\n * rather than importing `pveOperations` and rebuilding the spec here. Two `pveOperations` over\n * one spec would be two closures nobody can prove are the same; passing the one the resource\n * already built means this file cannot accidentally read the cluster differently from `diff`.\n */\nimport * as Effect from 'effect/Effect';\nimport { pve } from './client.ts';\nimport { text } from './values.ts';\nimport type { ZfsPoolAttributes, ZfsPoolProps } from './zfs-pool.ts';\n\n/**\n * The POST body. Every field in it is write-only — nothing here is ever read back.\n *\n * ⚠️ `node` IS NOT IN THE BODY: it is already the `nodes/{node}` segment of the URL being POSTed\n * to, and a second copy can only disagree with it. Same reasoning as `id` in metric-server.ts.\n * ⚠️ `devices` IS JOINED IN DECLARED ORDER AND NOT PUT THROUGH `csv()` FROM values.ts. `csv` sorts,\n * and PVE walks this list two at a time to pair `raid10` mirrors — MEASURED in the node's own\n * `PVE::API2::Disks::ZFS` — so sorting it builds a different pool from the one declared. The\n * list is never compared against anything, so it needs no normalisation, only faithful order.\n * ⚠️ AN OMITTED OPTIONAL IS NOT SENT. PVE's own defaults (ashift 12, compression on) are then\n * applied by the node. Sending a guessed default would be indistinguishable here — the values\n * are unreadable afterwards either way — but it would put a number in the request that no\n * declaration asked for, and this is the one call that writes to physical disks.\n */\nexport const createForm = (props: ZfsPoolProps): Record<string, string> => ({\n devices: props.devices.join(','),\n name: props.name,\n raidlevel: props.raidlevel,\n ...(props.ashift === undefined ? {} : { ashift: String(props.ashift) }),\n ...(props.compression === undefined ? {} : { compression: props.compression }),\n ...(props['draid-config'] === undefined ? {} : { 'draid-config': props['draid-config'] }),\n});\n\n/** 30 reads, 2s apart. A create that has not landed in a minute has gone wrong, not gone slow. */\nconst SETTLE_ATTEMPTS = 30;\n\n/**\n * Create the pool if it is absent, and otherwise leave it completely alone.\n *\n * ⛔ THE POST ONLY FORKS A WORKER. MEASURED in `/usr/share/perl5/PVE/API2/Disks/ZFS.pm` on n2: the\n * create handler ends in `$rpcenv->fork_worker('zfscreate', ...)` and its HTTP answer is a UPID\n * returned the instant the worker is forked — before `zpool create` has run, let alone finished.\n * A read-back taken immediately, as `pveOperations.reconcile` takes it, finds nothing and would\n * report a successful create as the failure \"the write returned no error but the object is still\n * absent\". THAT is why this function exists instead of the factory's reconcile.\n *\n * ⚠️ THERE IS NO UPDATE BRANCH BECAUSE PVE HAS NO PUT HERE. An existing pool is returned exactly as\n * read, unwritten: the only write this resource ever makes is the create of a pool that is not\n * there. Do not add a \"repair\" write; there is no field it could set.\n *\n * ⛔ AND IF THE READ IS WRONG, THE POST IS STILL SAFE — measured, not hoped for. `read` folds a 403\n * or an unreachable node into \"absent\", so a too-narrow lease would send this down the create\n * path over a live pool. PVE's handler calls `get_pool_data()` before it forks anything and dies\n * with \"pool '<name>' already exists on node '<node>'\", and `assert_disk_unused` refuses every\n * device that pool is holding. A create aimed at a pool that is really there fails loudly rather\n * than wiping it.\n *\n * ⚠️ SHORT POLLS WITH A HARD CAP, NOT ONE LONG WAIT. `read` cannot tell \"not yet\" from \"forbidden\"\n * — both are `undefined` — so the loop gives up with the UPID rather than retrying forever, and\n * the UPID is the only thing that leads to the worker's real error.\n */\nexport const createPool = <E, R>(\n props: ZfsPoolProps,\n collection: string,\n path: string,\n read: (props: ZfsPoolProps) => Effect.Effect<ZfsPoolAttributes | undefined, E, R>,\n) =>\n Effect.gen(function* () {\n const existing = yield* read(props);\n if (existing !== undefined) return existing;\n\n const upid = yield* pve<string>(\n props.target,\n 'provision',\n 'POST',\n collection,\n createForm(props),\n );\n\n const settle = (attempts: number): Effect.Effect<ZfsPoolAttributes | undefined, E, R> =>\n Effect.gen(function* () {\n const live = yield* read(props);\n if (live !== undefined || attempts <= 0) return live;\n yield* Effect.sleep('2 seconds');\n return yield* settle(attempts - 1);\n });\n\n const after = yield* settle(SETTLE_ATTEMPTS);\n if (after === undefined) {\n return yield* Effect.die(\n new Error(\n `${path}: POST returned ${text(upid, '(no UPID)')} but the pool has not appeared. That ` +\n 'POST only forks a `zfscreate` worker, so the task holds the real error -- read it ' +\n `with \\`pvesh get /nodes/${props.node}/tasks/<upid>/log\\`. NOTHING WAS RETRIED AND ` +\n 'NOTHING WAS CLEANED UP: if the worker reached `zpool create`, the declared devices ' +\n 'have already been written to.',\n ),\n );\n }\n return after;\n });\n\n/**\n * ⛔ `DELETE /nodes/{node}/disks/zfs/{name}` RUNS `zpool destroy` AND THE DATASETS GO WITH IT.\n * It is implemented rather than stubbed, because a `delete` that silently does nothing lies to\n * whoever reads the plan. What keeps a deleted line from destroying a pool is the resource's\n * `defaultRemovalPolicy: 'retain'` above — an orphaned pool is forgotten, not destroyed, and a\n * caller who means it says `.pipe(RemovalPolicy.destroy())`.\n *\n * ⚠️ `cleanup-config` IS NOT SENT. It would additionally remove the PVE storage entry pointing\n * at this pool, which is a different object with its own resource (`Proxmox.Storage`); one\n * resource reaching over to delete another's is how a stack ends up with state describing\n * something that is gone.\n */\nexport const destroyPool = (olds: ZfsPoolProps, path: string) =>\n pve(olds.target, 'provision', 'DELETE', path);\n"
66
+ ],
67
+ "mappings": ";AA+BA;AACA,uBAAS;AACT;AACA;;;ACpBA;AACA;AACA;;;ACcA;AACA;AACA;AACA;AACA;AACA;AA6FA,IAAM,cAAc,CAAC,KAAqB,SACxC,IAAI,OAAO,WAAW,IAAI,SAAS,WAAW;AA0BzC,IAAM,OAAO,CAAC,QAAmB,MAAe,MAAsB,QAAQ,QAC5E,WAAI,UAAU,GAAG;AAAA,EACtB,MAAM,OAAO,GAAG,OAAO,eAAe;AAAA,EAGtC,MAAM,SAAS,CAAC,S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