@jam-overture/loom 0.1.0 → 0.3.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 (414) hide show
  1. package/README.md +3 -1
  2. package/dist/application/application.d.ts +109 -0
  3. package/dist/application/application.js +97 -0
  4. package/dist/application/memory.d.ts +20 -0
  5. package/dist/application/memory.js +79 -0
  6. package/dist/application/store.d.ts +101 -0
  7. package/dist/application/store.js +25 -0
  8. package/dist/audience/audience.d.ts +36 -0
  9. package/dist/audience/audience.js +41 -0
  10. package/dist/audience/compose.d.ts +112 -0
  11. package/dist/audience/compose.js +134 -0
  12. package/dist/audience/memory.d.ts +14 -0
  13. package/dist/audience/memory.js +71 -0
  14. package/dist/audience/overlay-store.d.ts +343 -0
  15. package/dist/audience/overlay-store.js +217 -0
  16. package/dist/audience/rule.d.ts +121 -0
  17. package/dist/audience/rule.js +78 -0
  18. package/dist/cli/index.d.ts +3 -4
  19. package/dist/cli/index.js +3 -4
  20. package/dist/cli/templates.js +19 -0
  21. package/dist/data/adapter.d.ts +9 -1
  22. package/dist/data/adapter.js +2 -0
  23. package/dist/data/plan.js +0 -0
  24. package/dist/data/resolution.d.ts +23 -1
  25. package/dist/data/resolve.d.ts +31 -4
  26. package/dist/data/resolve.js +11 -3
  27. package/dist/ids.d.ts +10 -0
  28. package/dist/ids.js +11 -1
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.js +1 -0
  31. package/dist/interpretation/anthropic.d.ts +1 -1
  32. package/dist/interpretation/anthropic.js +2 -22
  33. package/dist/interpretation/client.d.ts +1 -1
  34. package/dist/interpretation/materialize.js +67 -22
  35. package/dist/interpretation/openai-compatible.d.ts +36 -0
  36. package/dist/interpretation/openai-compatible.js +79 -0
  37. package/dist/interpretation/status.d.ts +19 -0
  38. package/dist/interpretation/status.js +26 -0
  39. package/dist/live/index.d.ts +73 -0
  40. package/dist/live/index.js +73 -0
  41. package/dist/live/pages.d.ts +187 -0
  42. package/dist/live/pages.js +161 -0
  43. package/dist/live/pull.d.ts +147 -0
  44. package/dist/live/pull.js +398 -0
  45. package/dist/live/pulling.d.ts +79 -0
  46. package/dist/live/pulling.js +117 -0
  47. package/dist/live/window.d.ts +129 -0
  48. package/dist/live/window.js +132 -0
  49. package/dist/patch.d.ts +54 -0
  50. package/dist/patch.js +44 -0
  51. package/dist/project/closing.d.ts +51 -0
  52. package/dist/project/closing.js +53 -0
  53. package/dist/project/memory.d.ts +20 -0
  54. package/dist/project/memory.js +97 -0
  55. package/dist/project/project.d.ts +90 -0
  56. package/dist/project/project.js +91 -0
  57. package/dist/project/store.d.ts +135 -0
  58. package/dist/project/store.js +41 -0
  59. package/dist/registered.d.ts +64 -0
  60. package/dist/registered.js +118 -0
  61. package/dist/render/addressed.d.ts +35 -0
  62. package/dist/render/addressed.js +79 -0
  63. package/dist/render/behaviour-adjust.d.ts +11 -19
  64. package/dist/render/behaviour-adjust.js +75 -21
  65. package/dist/render/behaviour-present.d.ts +8 -0
  66. package/dist/render/behaviour-present.js +57 -6
  67. package/dist/render/behaviour.d.ts +98 -17
  68. package/dist/render/behaviour.js +91 -26
  69. package/dist/render/control-name.d.ts +68 -0
  70. package/dist/render/control-name.js +37 -0
  71. package/dist/render/diagnostics.d.ts +72 -0
  72. package/dist/render/diagnostics.js +7 -0
  73. package/dist/render/document-theme.d.ts +70 -0
  74. package/dist/render/document-theme.js +139 -0
  75. package/dist/render/editable.d.ts +15 -1
  76. package/dist/render/editable.js +13 -1
  77. package/dist/render/expected.d.ts +98 -0
  78. package/dist/render/expected.js +88 -0
  79. package/dist/render/index.d.ts +4 -0
  80. package/dist/render/index.js +4 -0
  81. package/dist/render/reads.d.ts +11 -0
  82. package/dist/render/reads.js +12 -1
  83. package/dist/render/render.d.ts +11 -0
  84. package/dist/render/render.js +294 -53
  85. package/dist/render/request.d.ts +8 -1
  86. package/dist/render/request.js +1 -0
  87. package/dist/render/slots.d.ts +52 -0
  88. package/dist/render/slots.js +24 -0
  89. package/dist/render/theme.d.ts +54 -1
  90. package/dist/render/theme.js +23 -1
  91. package/dist/render/unshown.d.ts +152 -0
  92. package/dist/render/unshown.js +80 -0
  93. package/dist/runtime/analysis.d.ts +94 -9
  94. package/dist/runtime/analysis.js +54 -9
  95. package/dist/runtime/assessment.d.ts +36 -2
  96. package/dist/runtime/assessment.js +27 -2
  97. package/dist/runtime/auto-apply-ceiling.d.ts +54 -0
  98. package/dist/runtime/auto-apply-ceiling.js +66 -0
  99. package/dist/runtime/checks.d.ts +148 -0
  100. package/dist/runtime/checks.js +112 -0
  101. package/dist/runtime/disposition.d.ts +96 -0
  102. package/dist/runtime/disposition.js +46 -0
  103. package/dist/runtime/gate.js +91 -10
  104. package/dist/runtime/index.d.ts +4 -0
  105. package/dist/runtime/index.js +4 -0
  106. package/dist/runtime/irreversibility.d.ts +64 -0
  107. package/dist/runtime/irreversibility.js +45 -0
  108. package/dist/runtime/nesting.d.ts +13 -1
  109. package/dist/runtime/nesting.js +41 -24
  110. package/dist/runtime/pipeline.d.ts +43 -0
  111. package/dist/runtime/pipeline.js +10 -2
  112. package/dist/runtime/policy-change.d.ts +93 -0
  113. package/dist/runtime/policy-change.js +305 -0
  114. package/dist/runtime/policy-log.d.ts +406 -0
  115. package/dist/runtime/policy-log.js +285 -0
  116. package/dist/runtime/policy.d.ts +8 -6
  117. package/dist/runtime/policy.js +5 -2
  118. package/dist/runtime/repointing.js +0 -0
  119. package/dist/runtime/reversibility.d.ts +11 -9
  120. package/dist/runtime/stakes.d.ts +129 -1
  121. package/dist/runtime/stakes.js +240 -26
  122. package/dist/runtime/vocabulary.d.ts +164 -7
  123. package/dist/runtime/vocabulary.js +181 -8
  124. package/dist/sdk/audit.d.ts +174 -3
  125. package/dist/sdk/audit.js +176 -17
  126. package/dist/sdk/catalogue.d.ts +9 -1
  127. package/dist/sdk/conformance.d.ts +37 -3
  128. package/dist/sdk/conformance.js +25 -4
  129. package/dist/sdk/definition.d.ts +129 -5
  130. package/dist/sdk/definition.js +66 -0
  131. package/dist/sdk/registry.d.ts +45 -2
  132. package/dist/sdk/registry.js +102 -1
  133. package/dist/signals/acted.contract.d.ts +21 -0
  134. package/dist/signals/acted.contract.js +236 -0
  135. package/dist/signals/acted.d.ts +359 -0
  136. package/dist/signals/acted.js +135 -0
  137. package/dist/signals/action-change.d.ts +507 -0
  138. package/dist/signals/action-change.js +265 -0
  139. package/dist/signals/action.d.ts +331 -0
  140. package/dist/signals/action.js +182 -0
  141. package/dist/signals/agenda.d.ts +585 -0
  142. package/dist/signals/agenda.js +295 -0
  143. package/dist/signals/applied-window.contract.d.ts +23 -0
  144. package/dist/signals/applied-window.contract.js +160 -0
  145. package/dist/signals/arrivals.contract.d.ts +21 -0
  146. package/dist/signals/arrivals.contract.js +180 -0
  147. package/dist/signals/arrivals.d.ts +375 -0
  148. package/dist/signals/arrivals.js +254 -0
  149. package/dist/signals/arriving.d.ts +210 -0
  150. package/dist/signals/arriving.js +133 -0
  151. package/dist/signals/audiences.d.ts +528 -0
  152. package/dist/signals/audiences.js +255 -0
  153. package/dist/signals/broadcast.d.ts +33 -17
  154. package/dist/signals/broadcast.js +255 -32
  155. package/dist/signals/change.d.ts +378 -0
  156. package/dist/signals/change.js +327 -0
  157. package/dist/signals/collect.d.ts +169 -34
  158. package/dist/signals/collect.js +186 -38
  159. package/dist/signals/conversion.d.ts +348 -0
  160. package/dist/signals/conversion.js +235 -0
  161. package/dist/signals/copy-change.d.ts +553 -0
  162. package/dist/signals/copy-change.js +377 -0
  163. package/dist/signals/copy.d.ts +337 -0
  164. package/dist/signals/copy.js +211 -0
  165. package/dist/signals/correlated.contract.d.ts +24 -0
  166. package/dist/signals/correlated.contract.js +94 -0
  167. package/dist/signals/counters.d.ts +97 -0
  168. package/dist/signals/counters.js +160 -0
  169. package/dist/signals/deliver.d.ts +23 -4
  170. package/dist/signals/deliver.js +34 -6
  171. package/dist/signals/deployment-change.d.ts +395 -0
  172. package/dist/signals/deployment-change.js +309 -0
  173. package/dist/signals/deployment.d.ts +278 -0
  174. package/dist/signals/deployment.js +178 -0
  175. package/dist/signals/door.d.ts +114 -0
  176. package/dist/signals/door.js +77 -0
  177. package/dist/signals/expire.d.ts +192 -0
  178. package/dist/signals/expire.js +213 -0
  179. package/dist/signals/fold.d.ts +10 -0
  180. package/dist/signals/fold.js +5 -1
  181. package/dist/signals/form-action.d.ts +302 -0
  182. package/dist/signals/form-action.js +169 -0
  183. package/dist/signals/form-copy.d.ts +523 -0
  184. package/dist/signals/form-copy.js +346 -0
  185. package/dist/signals/forms.d.ts +247 -0
  186. package/dist/signals/forms.js +147 -0
  187. package/dist/signals/frontier.d.ts +268 -0
  188. package/dist/signals/frontier.js +145 -0
  189. package/dist/signals/funnel-change.d.ts +548 -0
  190. package/dist/signals/funnel-change.js +361 -0
  191. package/dist/signals/funnel-hours.contract.d.ts +21 -0
  192. package/dist/signals/funnel-hours.contract.js +221 -0
  193. package/dist/signals/funnel-hours.d.ts +293 -0
  194. package/dist/signals/funnel-hours.js +99 -0
  195. package/dist/signals/funnel.d.ts +592 -0
  196. package/dist/signals/funnel.js +231 -0
  197. package/dist/signals/health.d.ts +694 -0
  198. package/dist/signals/health.js +573 -0
  199. package/dist/signals/index.d.ts +60 -0
  200. package/dist/signals/index.js +60 -0
  201. package/dist/signals/ingest.d.ts +56 -1
  202. package/dist/signals/ingest.js +91 -1
  203. package/dist/signals/inside.d.ts +190 -0
  204. package/dist/signals/inside.js +263 -0
  205. package/dist/signals/join.d.ts +56 -0
  206. package/dist/signals/join.js +60 -0
  207. package/dist/signals/journal.d.ts +123 -9
  208. package/dist/signals/kept.contract.d.ts +22 -0
  209. package/dist/signals/kept.contract.js +111 -0
  210. package/dist/signals/kinds.d.ts +8 -6
  211. package/dist/signals/kinds.js +14 -6
  212. package/dist/signals/library-action.d.ts +430 -0
  213. package/dist/signals/library-action.js +336 -0
  214. package/dist/signals/library-agenda-change.d.ts +324 -0
  215. package/dist/signals/library-agenda-change.js +199 -0
  216. package/dist/signals/library-agenda.d.ts +258 -0
  217. package/dist/signals/library-agenda.js +167 -0
  218. package/dist/signals/library-change.d.ts +477 -0
  219. package/dist/signals/library-change.js +335 -0
  220. package/dist/signals/library-copy-change.d.ts +498 -0
  221. package/dist/signals/library-copy-change.js +476 -0
  222. package/dist/signals/library-pace.d.ts +319 -0
  223. package/dist/signals/library-pace.js +305 -0
  224. package/dist/signals/library-reach-change.d.ts +646 -0
  225. package/dist/signals/library-reach-change.js +542 -0
  226. package/dist/signals/library-reach.d.ts +377 -0
  227. package/dist/signals/library-reach.js +227 -0
  228. package/dist/signals/library-senders-change.d.ts +457 -0
  229. package/dist/signals/library-senders-change.js +367 -0
  230. package/dist/signals/library-senders-reach-change.d.ts +486 -0
  231. package/dist/signals/library-senders-reach-change.js +538 -0
  232. package/dist/signals/library-senders-reach.d.ts +340 -0
  233. package/dist/signals/library-senders-reach.js +252 -0
  234. package/dist/signals/library-senders.d.ts +271 -0
  235. package/dist/signals/library-senders.js +180 -0
  236. package/dist/signals/library-word-reach-change.d.ts +567 -0
  237. package/dist/signals/library-word-reach-change.js +564 -0
  238. package/dist/signals/library.d.ts +306 -0
  239. package/dist/signals/library.js +178 -0
  240. package/dist/signals/memory.d.ts +9 -0
  241. package/dist/signals/memory.js +246 -14
  242. package/dist/signals/migrate.d.ts +20 -4
  243. package/dist/signals/migrate.js +269 -8
  244. package/dist/signals/notice.d.ts +389 -0
  245. package/dist/signals/notice.js +250 -0
  246. package/dist/signals/pace-change.d.ts +501 -0
  247. package/dist/signals/pace-change.js +310 -0
  248. package/dist/signals/pace.d.ts +296 -0
  249. package/dist/signals/pace.js +291 -0
  250. package/dist/signals/page-views.d.ts +365 -0
  251. package/dist/signals/page-views.js +218 -0
  252. package/dist/signals/part-pace.d.ts +378 -0
  253. package/dist/signals/part-pace.js +333 -0
  254. package/dist/signals/parts.d.ts +354 -0
  255. package/dist/signals/parts.js +232 -0
  256. package/dist/signals/postgres.d.ts +16 -2
  257. package/dist/signals/postgres.js +753 -76
  258. package/dist/signals/progress.d.ts +212 -0
  259. package/dist/signals/progress.js +150 -0
  260. package/dist/signals/ratios.d.ts +108 -0
  261. package/dist/signals/ratios.js +40 -0
  262. package/dist/signals/reach.d.ts +309 -0
  263. package/dist/signals/reach.js +93 -0
  264. package/dist/signals/readable.d.ts +34 -0
  265. package/dist/signals/readable.js +34 -0
  266. package/dist/signals/readership.d.ts +381 -0
  267. package/dist/signals/readership.js +308 -0
  268. package/dist/signals/region-pages.d.ts +173 -0
  269. package/dist/signals/region-pages.js +62 -0
  270. package/dist/signals/region.d.ts +287 -0
  271. package/dist/signals/region.js +198 -0
  272. package/dist/signals/retention.d.ts +163 -0
  273. package/dist/signals/retention.js +75 -0
  274. package/dist/signals/rhythm.d.ts +302 -0
  275. package/dist/signals/rhythm.js +262 -0
  276. package/dist/signals/rollup.d.ts +194 -4
  277. package/dist/signals/rollup.js +0 -0
  278. package/dist/signals/schema.d.ts +1069 -1
  279. package/dist/signals/schema.js +393 -3
  280. package/dist/signals/signal.d.ts +237 -11
  281. package/dist/signals/signal.js +70 -10
  282. package/dist/signals/silence-census.d.ts +205 -0
  283. package/dist/signals/silence-census.js +87 -0
  284. package/dist/signals/silences.d.ts +1147 -0
  285. package/dist/signals/silences.js +996 -0
  286. package/dist/signals/subtrees.d.ts +123 -0
  287. package/dist/signals/subtrees.js +102 -0
  288. package/dist/signals/tally.d.ts +262 -12
  289. package/dist/signals/unread.d.ts +292 -0
  290. package/dist/signals/unread.js +137 -0
  291. package/dist/signals/window-agenda.d.ts +276 -0
  292. package/dist/signals/window-agenda.js +83 -0
  293. package/dist/signals/window-figures.d.ts +148 -0
  294. package/dist/signals/window-figures.js +42 -0
  295. package/dist/signals/window-funnels.d.ts +88 -0
  296. package/dist/signals/window-funnels.js +47 -0
  297. package/dist/signals/window.d.ts +866 -0
  298. package/dist/signals/window.js +693 -0
  299. package/dist/signals/words.d.ts +24 -0
  300. package/dist/signals/words.js +24 -0
  301. package/dist/store/cache.d.ts +101 -0
  302. package/dist/store/cache.js +149 -0
  303. package/dist/store/history.d.ts +82 -0
  304. package/dist/store/history.js +36 -0
  305. package/dist/store/index.d.ts +30 -0
  306. package/dist/store/index.js +30 -0
  307. package/dist/store/memory.d.ts +2 -1
  308. package/dist/store/memory.js +48 -12
  309. package/dist/store/migrate.d.ts +106 -0
  310. package/dist/store/migrate.js +323 -7
  311. package/dist/store/postgres-applications.d.ts +4 -0
  312. package/dist/store/postgres-applications.js +197 -0
  313. package/dist/store/postgres-audience.d.ts +14 -0
  314. package/dist/store/postgres-audience.js +272 -0
  315. package/dist/store/postgres-holds.d.ts +10 -1
  316. package/dist/store/postgres-holds.js +116 -101
  317. package/dist/store/postgres-policy-log.d.ts +14 -0
  318. package/dist/store/postgres-policy-log.js +240 -0
  319. package/dist/store/postgres-projects.d.ts +4 -0
  320. package/dist/store/postgres-projects.js +217 -0
  321. package/dist/store/postgres.d.ts +17 -1
  322. package/dist/store/postgres.js +60 -9
  323. package/dist/store/replay.d.ts +102 -1
  324. package/dist/store/replay.js +190 -19
  325. package/dist/store/reseed.d.ts +238 -0
  326. package/dist/store/reseed.js +308 -0
  327. package/dist/store/schema.d.ts +762 -2
  328. package/dist/store/schema.js +218 -5
  329. package/dist/store/source.d.ts +57 -1
  330. package/dist/store/source.js +65 -1
  331. package/dist/store/store.d.ts +29 -6
  332. package/dist/submit/resolve.d.ts +1 -1
  333. package/dist/submit/resolve.js +2 -1
  334. package/dist/telemetry/calibration.d.ts +25 -0
  335. package/dist/telemetry/calibration.js +27 -1
  336. package/dist/telemetry/event.d.ts +391 -33
  337. package/dist/telemetry/event.js +84 -20
  338. package/dist/telemetry/index.d.ts +2 -0
  339. package/dist/telemetry/index.js +2 -0
  340. package/dist/telemetry/journal.d.ts +104 -3
  341. package/dist/telemetry/journal.js +9 -0
  342. package/dist/telemetry/lookup.d.ts +27 -0
  343. package/dist/telemetry/lookup.js +18 -0
  344. package/dist/telemetry/memory.js +33 -1
  345. package/dist/telemetry/migrate.js +22 -1
  346. package/dist/telemetry/postgres.d.ts +10 -1
  347. package/dist/telemetry/postgres.js +188 -90
  348. package/dist/telemetry/remeasure.d.ts +78 -0
  349. package/dist/telemetry/remeasure.js +83 -0
  350. package/dist/telemetry/retention.d.ts +2 -2
  351. package/dist/telemetry/schema.d.ts +17 -0
  352. package/dist/telemetry/schema.js +27 -1
  353. package/dist/telemetry/sink.d.ts +2 -2
  354. package/dist/telemetry/window.d.ts +135 -0
  355. package/dist/telemetry/window.js +101 -0
  356. package/dist/testing/application-contract.d.ts +14 -0
  357. package/dist/testing/application-contract.js +270 -0
  358. package/dist/testing/audience-overlay-contract.d.ts +31 -0
  359. package/dist/testing/audience-overlay-contract.js +354 -0
  360. package/dist/testing/contracts.d.ts +13 -7
  361. package/dist/testing/contracts.js +13 -7
  362. package/dist/testing/definitions.d.ts +78 -0
  363. package/dist/testing/definitions.js +134 -9
  364. package/dist/testing/doubles.d.ts +103 -0
  365. package/dist/testing/doubles.js +143 -0
  366. package/dist/testing/index.d.ts +2 -2
  367. package/dist/testing/index.js +2 -2
  368. package/dist/testing/journal-contract.js +297 -6
  369. package/dist/testing/model-contract.d.ts +110 -0
  370. package/dist/testing/model-contract.js +150 -0
  371. package/dist/testing/policy-log-contract.d.ts +26 -0
  372. package/dist/testing/policy-log-contract.js +344 -0
  373. package/dist/testing/project-contract.d.ts +14 -0
  374. package/dist/testing/project-contract.js +266 -0
  375. package/dist/testing/reader-signal-contract.d.ts +27 -2
  376. package/dist/testing/reader-signal-contract.js +475 -5
  377. package/dist/testing/store-contract.d.ts +7 -1
  378. package/dist/testing/store-contract.js +84 -3
  379. package/dist/theme/apply.d.ts +20 -1
  380. package/dist/theme/apply.js +5 -3
  381. package/dist/theme/contrast.d.ts +19 -14
  382. package/dist/theme/contrast.js +181 -17
  383. package/dist/theme/derive.d.ts +22 -0
  384. package/dist/theme/derive.js +54 -1
  385. package/dist/theme/library.js +1 -1
  386. package/dist/theme/measure.d.ts +34 -0
  387. package/dist/theme/measure.js +30 -1
  388. package/dist/theme/palettes.js +7 -7
  389. package/dist/theme/ramp.d.ts +64 -0
  390. package/dist/theme/ramp.js +114 -0
  391. package/dist/theme/registry.d.ts +9 -0
  392. package/dist/theme/registry.js +11 -1
  393. package/dist/theme/separation.d.ts +97 -3
  394. package/dist/theme/separation.js +75 -0
  395. package/dist/tree/apply.js +13 -0
  396. package/dist/tree/compare.d.ts +9 -0
  397. package/dist/tree/compare.js +18 -0
  398. package/dist/tree/mutation.d.ts +18 -0
  399. package/dist/tree/mutation.js +24 -12
  400. package/dist/tree/navigation.d.ts +5 -0
  401. package/dist/tree/navigation.js +32 -10
  402. package/dist/tree/outline.d.ts +7 -0
  403. package/dist/tree/outline.js +9 -5
  404. package/dist/write/computed.d.ts +60 -0
  405. package/dist/write/computed.js +61 -0
  406. package/dist/write/held.d.ts +59 -0
  407. package/dist/write/index.d.ts +5 -2
  408. package/dist/write/index.js +5 -2
  409. package/dist/write/reseed.d.ts +151 -0
  410. package/dist/write/reseed.js +184 -0
  411. package/dist/write/revert.js +2 -16
  412. package/package.json +25 -3
  413. package/dist/runtime/inverse-interpreter.d.ts +0 -90
  414. package/dist/runtime/inverse-interpreter.js +0 -56
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
+ import { type AutoApplyCeiling } from "./auto-apply-ceiling.js";
2
3
  import { type IntentOrigin } from "./intent.js";
3
- import { type StakeLevel } from "./stake-level.js";
4
4
  /**
5
5
  * Everything the Gate needs that is a choice rather than a fact.
6
6
  *
@@ -85,9 +85,11 @@ export declare const gatePolicySchema: z.ZodObject<{
85
85
  confidenceFloor: z.ZodDefault<z.ZodNumber>;
86
86
  /**
87
87
  * The highest stakes each origin may apply without asking. An explicit human
88
- * instruction earns more latitude than an adaptation nobody requested.
88
+ * instruction earns more latitude than an adaptation nobody requested, and
89
+ * `nothing` is the deployment that lets none of them through unattended
90
+ * (0405).
89
91
  */
90
- autoApplyCeiling: z.ZodDefault<z.ZodRecord<z.ZodEnum<["user-instruction", "system-signal", "scheduled-adaptation", "developer"]>, z.ZodEnum<["low", "medium", "high", "critical"]>>>;
92
+ autoApplyCeiling: z.ZodDefault<z.ZodRecord<z.ZodEnum<["user-instruction", "system-signal", "scheduled-adaptation", "developer"]>, z.ZodUnion<[z.ZodLiteral<"nothing">, z.ZodEnum<["low", "medium", "high", "critical"]>]>>>;
91
93
  /** At or above this, the change is refused outright rather than offered. */
92
94
  refusalFloor: z.ZodDefault<z.ZodEnum<["low", "medium", "high", "critical"]>>;
93
95
  }, "strip", z.ZodTypeAny, {
@@ -106,7 +108,7 @@ export declare const gatePolicySchema: z.ZodObject<{
106
108
  inverseRetentionBudget: number;
107
109
  minimumConfidence: number;
108
110
  confidenceFloor: number;
109
- autoApplyCeiling: Partial<Record<"user-instruction" | "system-signal" | "scheduled-adaptation" | "developer", "low" | "medium" | "high" | "critical">>;
111
+ autoApplyCeiling: Partial<Record<"user-instruction" | "system-signal" | "scheduled-adaptation" | "developer", "low" | "medium" | "high" | "critical" | "nothing">>;
110
112
  refusalFloor: "low" | "medium" | "high" | "critical";
111
113
  }, {
112
114
  policyId?: string | undefined;
@@ -124,7 +126,7 @@ export declare const gatePolicySchema: z.ZodObject<{
124
126
  inverseRetentionBudget?: number | undefined;
125
127
  minimumConfidence?: number | undefined;
126
128
  confidenceFloor?: number | undefined;
127
- autoApplyCeiling?: Partial<Record<"user-instruction" | "system-signal" | "scheduled-adaptation" | "developer", "low" | "medium" | "high" | "critical">> | undefined;
129
+ autoApplyCeiling?: Partial<Record<"user-instruction" | "system-signal" | "scheduled-adaptation" | "developer", "low" | "medium" | "high" | "critical" | "nothing">> | undefined;
128
130
  refusalFloor?: "low" | "medium" | "high" | "critical" | undefined;
129
131
  }>;
130
132
  /**
@@ -152,5 +154,5 @@ export type GatePolicy = Readonly<z.infer<typeof gatePolicySchema>>;
152
154
  * removed, how broadly, how close to the root.
153
155
  */
154
156
  export declare const defaultGatePolicy: GatePolicy;
155
- export declare const ceilingFor: (policy: GatePolicy, origin: IntentOrigin) => StakeLevel;
157
+ export declare const ceilingFor: (policy: GatePolicy, origin: IntentOrigin) => AutoApplyCeiling;
156
158
  //# sourceMappingURL=policy.d.ts.map
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { interactiveTypesSchema } from "../interactivity.js";
3
3
  import { primitiveTypeSchema } from "../primitive-type.js";
4
+ import { autoApplyCeilingSchema } from "./auto-apply-ceiling.js";
4
5
  import { intentOriginSchema } from "./intent.js";
5
6
  import { stakeLevelSchema } from "./stake-level.js";
6
7
  /**
@@ -83,10 +84,12 @@ export const gatePolicySchema = z.object({
83
84
  confidenceFloor: z.number().min(0).max(1).default(0.3),
84
85
  /**
85
86
  * The highest stakes each origin may apply without asking. An explicit human
86
- * instruction earns more latitude than an adaptation nobody requested.
87
+ * instruction earns more latitude than an adaptation nobody requested, and
88
+ * `nothing` is the deployment that lets none of them through unattended
89
+ * (0405).
87
90
  */
88
91
  autoApplyCeiling: z
89
- .record(intentOriginSchema, stakeLevelSchema)
92
+ .record(intentOriginSchema, autoApplyCeilingSchema)
90
93
  .default({
91
94
  "user-instruction": "medium",
92
95
  "system-signal": "low",
Binary file
@@ -1,10 +1,10 @@
1
1
  import type { DeltaId } from "../ids.js";
2
- import type { PrimitiveType } from "../primitive-type.js";
3
2
  import { type Result } from "../result.js";
4
3
  import type { TreeDelta } from "../tree/delta.js";
5
4
  import type { TreeError } from "../tree/errors.js";
6
5
  import type { LoomTree } from "../tree/tree.js";
7
6
  import type { ChangeAnalysis } from "./analysis.js";
7
+ import type { IrreversibilityReason } from "./irreversibility.js";
8
8
  import type { GatePolicy } from "./policy.js";
9
9
  /**
10
10
  * Reversibility is computed, not guessed: the inverse delta is produced up
@@ -16,14 +16,16 @@ import type { GatePolicy } from "./policy.js";
16
16
  * configuration reaches a payment flow or a sent message — or that the inverse
17
17
  * would have to retain more content than the runtime is willing to hold.
18
18
  */
19
- export type IrreversibilityReason = {
20
- readonly code: "out-of-tree-effect";
21
- readonly primitiveTypes: readonly PrimitiveType[];
22
- } | {
23
- readonly code: "retention-budget-exceeded";
24
- readonly retainedNodeCount: number;
25
- readonly budget: number;
26
- };
19
+ /**
20
+ * The reason's shape is published from here, where it always was. Its schema and
21
+ * the narrowing helper beside it are not: both exist so that `disposition.ts`
22
+ * can validate a stored judgment and `telemetry/event.ts` can journal the types
23
+ * one reason blames, and neither is something a host composing a runtime has to
24
+ * reach for. A published door has to be documented on a page a reader can find,
25
+ * which is the right bar for a name a host needs and the wrong one for an
26
+ * internal seam between two modules of this package.
27
+ */
28
+ export type { IrreversibilityReason } from "./irreversibility.js";
27
29
  export type Reversibility = {
28
30
  readonly reversible: boolean;
29
31
  /** The tree-level undo. Present even when `reversible` is false. */
@@ -1,3 +1,5 @@
1
+ import { z } from "zod";
2
+ import type { PrimitiveType } from "../primitive-type.js";
1
3
  import type { ChangeAnalysis } from "./analysis.js";
2
4
  import type { GatePolicy } from "./policy.js";
3
5
  import type { DiscardedWork } from "./proposal.js";
@@ -18,7 +20,34 @@ import { type StakeLevel } from "./stake-level.js";
18
20
  * exception, `discards-later-work`, is a fact about the log the delta was
19
21
  * computed from, which no amount of looking at the delta can recover (0035).
20
22
  */
21
- export type StakeFactorCode = "protected-type-removed" | "protected-type-touched" | "protected-type-relocated" | "protected-prop-configured" | "large-removal" | "broad-change" | "shallow-structural-change" | "discards-later-work" | "nested-target" | "unknown-primitive" | "invalid-props" | "redirected-submission" | "repointed-binding";
23
+ /**
24
+ * Which rule a factor is, as a closed vocabulary rather than a bare union.
25
+ *
26
+ * A schema because the codes leave the process. A telemetry record carries them
27
+ * so that a corpus can group refusals by the rule that caused one, and anything
28
+ * crossing that boundary has to be parsed on the way back in. This is the same
29
+ * bargain `stakeLevelSchema` and `dispositionReasonSchema` already make, and it
30
+ * is deliberately *not* the bargain `telemetryFailureSchema.code` makes: an
31
+ * error taxonomy is open because adding a code elsewhere in the codebase must
32
+ * not invalidate yesterday's records, whereas this list is the Gate's own
33
+ * vocabulary and a record naming a rule this version has never heard of is a
34
+ * record it genuinely cannot interpret.
35
+ *
36
+ * The order is the order `FACTORS` evaluates in, which is severity-ish and not
37
+ * arithmetic: nothing reads an index here, unlike `STAKE_ORDER` (0166).
38
+ */
39
+ export declare const stakeFactorCodeSchema: z.ZodEnum<["protected-type-removed", "protected-type-touched", "protected-type-relocated", "protected-prop-configured", "large-removal", "broad-change", "shallow-structural-change", "discards-later-work", "nested-target", "unknown-primitive", "invalid-props", "unread-binding", "unplaced-slot", "redirected-submission", "repointed-binding"]>;
40
+ export type StakeFactorCode = z.infer<typeof stakeFactorCodeSchema>;
41
+ /**
42
+ * Every rule the Gate can raise, walkable.
43
+ *
44
+ * Derived rather than declared: the members come from a schema, so a second
45
+ * hand-written list would be the copy `closed-set.ts` exists to avoid. Two
46
+ * surfaces hold a plain-language table keyed by this union and both reached for
47
+ * `Object.keys(...) as StakeFactorCode[]` to walk it, which is a cast standing
48
+ * in for a list.
49
+ */
50
+ export declare const STAKE_FACTOR_CODES: readonly StakeFactorCode[];
22
51
  export type StakeFactor = {
23
52
  readonly code: StakeFactorCode;
24
53
  readonly level: StakeLevel;
@@ -41,7 +70,106 @@ export type StakeInput = {
41
70
  /** Empty when the proposal declared nothing, which is not the same as nothing. */
42
71
  readonly discards: readonly DiscardedWork[];
43
72
  };
73
+ /**
74
+ * The rules whose level is fixed at the code, and the level each one is fixed
75
+ * at.
76
+ *
77
+ * Every rule in this file is one of two kinds, and the difference is which
78
+ * question it answers. Seven of them ask *how much of this deployment's page
79
+ * does this touch* — how many nodes went, how broad it was, how shallow, which
80
+ * of the types this host declared it cares about — so moving a field of the
81
+ * policy moves the answer. The other eight ask *is this change coherent at all*:
82
+ * a target nobody can reach, a type nothing is registered for, props the
83
+ * declaring primitive refuses, a question nothing reads, content put in a region
84
+ * nothing places, a form or a region pointed somewhere else, work written over.
85
+ * None of those consults a policy field. A host turns them off by declaring no
86
+ * vocabulary (0002) and cannot tune them, so their level is a property of the
87
+ * rule itself.
88
+ *
89
+ * Declared here rather than written into each factor because the level now has
90
+ * two readers. The Gate computes it while it holds the delta, and
91
+ * `remeasureStakes` has to state it months later holding only a record — and the
92
+ * second reader exists *because* these seven cannot be re-measured from a
93
+ * record: a code says a rule fired and the list of nodes it fired about does not
94
+ * cross the boundary (0023). What crosses is the code, and this is what turns a
95
+ * code back into a level without a second copy of these numbers in whatever
96
+ * reads the journal.
97
+ */
98
+ declare const FIXED_LEVELS: {
99
+ readonly "discards-later-work": "high";
100
+ readonly "nested-target": "critical";
101
+ readonly "unknown-primitive": "critical";
102
+ readonly "invalid-props": "critical";
103
+ readonly "unread-binding": "critical";
104
+ readonly "unplaced-slot": "critical";
105
+ readonly "redirected-submission": "high";
106
+ readonly "repointed-binding": "high";
107
+ };
108
+ /** A rule no policy field can move, so its code alone gives its level. */
109
+ export type FixedStakeFactorCode = keyof typeof FIXED_LEVELS;
110
+ /**
111
+ * A rule a policy decides, so the same change under two policies is two
112
+ * answers. The complement of `FixedStakeFactorCode` by construction: a factor
113
+ * added to the vocabulary belongs to one set or the other and nothing has to
114
+ * remember to put it there.
115
+ */
116
+ export type MeasuredStakeFactorCode = Exclude<StakeFactorCode, FixedStakeFactorCode>;
117
+ /** The level this rule is always raised at, which is the whole of what its code means. */
118
+ export declare const fixedStakeLevel: (code: FixedStakeFactorCode) => StakeLevel;
119
+ export declare const isFixedStakeFactor: (code: StakeFactorCode) => code is FixedStakeFactorCode;
120
+ /**
121
+ * The two halves of the vocabulary, walkable, in the order the Gate raises them.
122
+ *
123
+ * Filtered from `STAKE_FACTOR_CODES` rather than written out, so neither list can
124
+ * be the stale copy of a partition that lives in one place. A factor added to the
125
+ * schema joins one of them according to whether `FIXED_LEVELS` names it, and a
126
+ * reader walking either gets the new member without being told.
127
+ */
128
+ export declare const FIXED_STAKE_FACTOR_CODES: readonly FixedStakeFactorCode[];
129
+ export declare const MEASURED_STAKE_FACTOR_CODES: readonly MeasuredStakeFactorCode[];
130
+ /**
131
+ * The facts the policy-dependent rules read, and nothing else.
132
+ *
133
+ * Narrower than `ChangeAnalysis` on purpose, and the narrowing is the contract.
134
+ * An analysis holds six lists of specifics — which targets are unreachable,
135
+ * which nodes carry refused props — that name parts of a particular page, so
136
+ * they belong to the moment the delta was weighed and go no further. What is
137
+ * here is nine numbers and four lists of type and prop names, which is exactly
138
+ * the part a telemetry record can carry and therefore the part a host can hold
139
+ * on to and measure again.
140
+ *
141
+ * So the seven rules below take this rather than the analysis, and the two
142
+ * producers — `stakeMeasurementOf` from a delta, `remeasureStakes` from a
143
+ * journalled record — put the same rules to the same numbers. A second
144
+ * implementation of *large removal* or *broad change* in whatever wants to
145
+ * re-run them would be a copy of the Gate that drifts from the Gate, which is
146
+ * the one failure a simulation of a policy must not have.
147
+ */
148
+ export type StakeMeasurement = {
149
+ readonly insertedNodeCount: number;
150
+ readonly removedNodeCount: number;
151
+ readonly movedNodeCount: number;
152
+ /** `affectedNodeIds.length`. Breadth reads the count and never the ids. */
153
+ readonly affectedNodeCount: number;
154
+ readonly shallowestAffectedDepth: number;
155
+ readonly touchedPrimitiveTypes: readonly PrimitiveType[];
156
+ readonly removedPrimitiveTypes: readonly PrimitiveType[];
157
+ readonly relocatedPrimitiveTypes: readonly PrimitiveType[];
158
+ readonly configuredPropKeys: readonly string[];
159
+ };
160
+ /** The measurable half of an analysis, which is what the Gate's own path takes. */
161
+ export declare const stakeMeasurementOf: (analysis: ChangeAnalysis) => StakeMeasurement;
162
+ /**
163
+ * The policy-dependent half, against a measurement rather than a delta.
164
+ *
165
+ * Published because it is the half that can be run twice: once by the Gate on
166
+ * the change in front of it, and again by anything holding a record of that
167
+ * change and a policy it is considering. The other half cannot, which is why it
168
+ * is not here — see `fixedStakeLevel`.
169
+ */
170
+ export declare const measureStakes: (measurement: StakeMeasurement, policy: GatePolicy) => readonly StakeFactor[];
44
171
  export declare const assessStakes: (input: StakeInput, policy: GatePolicy) => StakeAssessment;
45
172
  /** The factor with this code, for a caller that needs the reason and not the level. */
46
173
  export declare const stakeFactor: (stakes: StakeAssessment, code: StakeFactorCode) => StakeFactor | undefined;
174
+ export {};
47
175
  //# sourceMappingURL=stakes.d.ts.map
@@ -1,12 +1,132 @@
1
+ import { z } from "zod";
1
2
  import { describeNestedTarget } from "./nesting.js";
2
3
  import { describeRedirectedSubmission } from "./redirection.js";
3
4
  import { describeRepointedBinding } from "./repointing.js";
4
- import { describeInvalidProps, describeUnknownPrimitive } from "./vocabulary.js";
5
+ import { describeInvalidProps, describeUnknownPrimitive, describeUnplacedSlot, describeUnreadBinding, } from "./vocabulary.js";
5
6
  import { highestStake } from "./stake-level.js";
7
+ /**
8
+ * Stakes assessment: facts plus policy in, a level plus its reasons out.
9
+ *
10
+ * Every factor is recorded rather than collapsed, so a disposition can explain
11
+ * itself. "High stakes" is not useful feedback; "this removes 14 nodes and
12
+ * touches commerce.checkout" is.
13
+ *
14
+ * Stakes measure damage only. Whether a change can be taken back is a separate
15
+ * axis assessed separately — a change can be devastating and trivially
16
+ * reversible, or tiny and permanent, and the Gate needs to see those two
17
+ * properties independently rather than pre-blended into one number.
18
+ *
19
+ * Every factor but one is a fact about the delta against the tree. The
20
+ * exception, `discards-later-work`, is a fact about the log the delta was
21
+ * computed from, which no amount of looking at the delta can recover (0035).
22
+ */
23
+ /**
24
+ * Which rule a factor is, as a closed vocabulary rather than a bare union.
25
+ *
26
+ * A schema because the codes leave the process. A telemetry record carries them
27
+ * so that a corpus can group refusals by the rule that caused one, and anything
28
+ * crossing that boundary has to be parsed on the way back in. This is the same
29
+ * bargain `stakeLevelSchema` and `dispositionReasonSchema` already make, and it
30
+ * is deliberately *not* the bargain `telemetryFailureSchema.code` makes: an
31
+ * error taxonomy is open because adding a code elsewhere in the codebase must
32
+ * not invalidate yesterday's records, whereas this list is the Gate's own
33
+ * vocabulary and a record naming a rule this version has never heard of is a
34
+ * record it genuinely cannot interpret.
35
+ *
36
+ * The order is the order `FACTORS` evaluates in, which is severity-ish and not
37
+ * arithmetic: nothing reads an index here, unlike `STAKE_ORDER` (0166).
38
+ */
39
+ export const stakeFactorCodeSchema = z.enum([
40
+ "protected-type-removed",
41
+ "protected-type-touched",
42
+ "protected-type-relocated",
43
+ "protected-prop-configured",
44
+ "large-removal",
45
+ "broad-change",
46
+ "shallow-structural-change",
47
+ "discards-later-work",
48
+ "nested-target",
49
+ "unknown-primitive",
50
+ "invalid-props",
51
+ "unread-binding",
52
+ "unplaced-slot",
53
+ "redirected-submission",
54
+ "repointed-binding",
55
+ ]);
56
+ /**
57
+ * Every rule the Gate can raise, walkable.
58
+ *
59
+ * Derived rather than declared: the members come from a schema, so a second
60
+ * hand-written list would be the copy `closed-set.ts` exists to avoid. Two
61
+ * surfaces hold a plain-language table keyed by this union and both reached for
62
+ * `Object.keys(...) as StakeFactorCode[]` to walk it, which is a cast standing
63
+ * in for a list.
64
+ */
65
+ export const STAKE_FACTOR_CODES = stakeFactorCodeSchema.options;
66
+ /**
67
+ * The rules whose level is fixed at the code, and the level each one is fixed
68
+ * at.
69
+ *
70
+ * Every rule in this file is one of two kinds, and the difference is which
71
+ * question it answers. Seven of them ask *how much of this deployment's page
72
+ * does this touch* — how many nodes went, how broad it was, how shallow, which
73
+ * of the types this host declared it cares about — so moving a field of the
74
+ * policy moves the answer. The other eight ask *is this change coherent at all*:
75
+ * a target nobody can reach, a type nothing is registered for, props the
76
+ * declaring primitive refuses, a question nothing reads, content put in a region
77
+ * nothing places, a form or a region pointed somewhere else, work written over.
78
+ * None of those consults a policy field. A host turns them off by declaring no
79
+ * vocabulary (0002) and cannot tune them, so their level is a property of the
80
+ * rule itself.
81
+ *
82
+ * Declared here rather than written into each factor because the level now has
83
+ * two readers. The Gate computes it while it holds the delta, and
84
+ * `remeasureStakes` has to state it months later holding only a record — and the
85
+ * second reader exists *because* these seven cannot be re-measured from a
86
+ * record: a code says a rule fired and the list of nodes it fired about does not
87
+ * cross the boundary (0023). What crosses is the code, and this is what turns a
88
+ * code back into a level without a second copy of these numbers in whatever
89
+ * reads the journal.
90
+ */
91
+ const FIXED_LEVELS = {
92
+ "discards-later-work": "high",
93
+ "nested-target": "critical",
94
+ "unknown-primitive": "critical",
95
+ "invalid-props": "critical",
96
+ "unread-binding": "critical",
97
+ "unplaced-slot": "critical",
98
+ "redirected-submission": "high",
99
+ "repointed-binding": "high",
100
+ };
101
+ /** The level this rule is always raised at, which is the whole of what its code means. */
102
+ export const fixedStakeLevel = (code) => FIXED_LEVELS[code];
103
+ export const isFixedStakeFactor = (code) => code in FIXED_LEVELS;
104
+ /**
105
+ * The two halves of the vocabulary, walkable, in the order the Gate raises them.
106
+ *
107
+ * Filtered from `STAKE_FACTOR_CODES` rather than written out, so neither list can
108
+ * be the stale copy of a partition that lives in one place. A factor added to the
109
+ * schema joins one of them according to whether `FIXED_LEVELS` names it, and a
110
+ * reader walking either gets the new member without being told.
111
+ */
112
+ export const FIXED_STAKE_FACTOR_CODES = STAKE_FACTOR_CODES.filter(isFixedStakeFactor);
113
+ export const MEASURED_STAKE_FACTOR_CODES = STAKE_FACTOR_CODES.filter((code) => !isFixedStakeFactor(code));
114
+ /** The measurable half of an analysis, which is what the Gate's own path takes. */
115
+ export const stakeMeasurementOf = (analysis) => ({
116
+ insertedNodeCount: analysis.insertedNodeCount,
117
+ removedNodeCount: analysis.removedNodeCount,
118
+ movedNodeCount: analysis.movedNodeCount,
119
+ affectedNodeCount: analysis.affectedNodeIds.length,
120
+ shallowestAffectedDepth: analysis.shallowestAffectedDepth,
121
+ touchedPrimitiveTypes: analysis.touchedPrimitiveTypes,
122
+ removedPrimitiveTypes: analysis.removedPrimitiveTypes,
123
+ relocatedPrimitiveTypes: analysis.relocatedPrimitiveTypes,
124
+ configuredPropKeys: analysis.configuredPropKeys,
125
+ });
6
126
  const intersect = (candidates, declared) => candidates.filter((candidate) => declared.includes(candidate));
7
127
  /** Destroying a protected primitive outranks merely reconfiguring one. */
8
- const protectedTypeRemoved = ({ analysis }, policy) => {
9
- const matches = intersect(analysis.removedPrimitiveTypes, policy.protectedPrimitiveTypes);
128
+ const protectedTypeRemoved = (measurement, policy) => {
129
+ const matches = intersect(measurement.removedPrimitiveTypes, policy.protectedPrimitiveTypes);
10
130
  if (matches.length === 0)
11
131
  return null;
12
132
  return {
@@ -15,8 +135,8 @@ const protectedTypeRemoved = ({ analysis }, policy) => {
15
135
  detail: `destroys protected ${matches.join(", ")}`,
16
136
  };
17
137
  };
18
- const protectedTypeTouched = ({ analysis }, policy) => {
19
- const matches = intersect(analysis.touchedPrimitiveTypes, policy.protectedPrimitiveTypes);
138
+ const protectedTypeTouched = (measurement, policy) => {
139
+ const matches = intersect(measurement.touchedPrimitiveTypes, policy.protectedPrimitiveTypes);
20
140
  if (matches.length === 0)
21
141
  return null;
22
142
  return {
@@ -32,8 +152,8 @@ const protectedTypeTouched = ({ analysis }, policy) => {
32
152
  * because the two sentences a reviewer needs are different — one says the card
33
153
  * was rewritten, the other says it is somewhere else now (0044).
34
154
  */
35
- const protectedTypeRelocated = ({ analysis }, policy) => {
36
- const matches = intersect(analysis.relocatedPrimitiveTypes, policy.protectedPrimitiveTypes);
155
+ const protectedTypeRelocated = (measurement, policy) => {
156
+ const matches = intersect(measurement.relocatedPrimitiveTypes, policy.protectedPrimitiveTypes);
37
157
  if (matches.length === 0)
38
158
  return null;
39
159
  return {
@@ -42,8 +162,8 @@ const protectedTypeRelocated = ({ analysis }, policy) => {
42
162
  detail: `relocates protected ${matches.join(", ")}`,
43
163
  };
44
164
  };
45
- const protectedProp = ({ analysis }, policy) => {
46
- const matches = intersect(analysis.configuredPropKeys, policy.protectedPropKeys);
165
+ const protectedProp = (measurement, policy) => {
166
+ const matches = intersect(measurement.configuredPropKeys, policy.protectedPropKeys);
47
167
  if (matches.length === 0)
48
168
  return null;
49
169
  return {
@@ -52,8 +172,8 @@ const protectedProp = ({ analysis }, policy) => {
52
172
  detail: `configures protected ${matches.join(", ")}`,
53
173
  };
54
174
  };
55
- const largeRemoval = ({ analysis }, policy) => {
56
- const { removedNodeCount } = analysis;
175
+ const largeRemoval = (measurement, policy) => {
176
+ const { removedNodeCount } = measurement;
57
177
  const { removalThresholds } = policy;
58
178
  if (removedNodeCount >= removalThresholds.high) {
59
179
  return {
@@ -71,22 +191,22 @@ const largeRemoval = ({ analysis }, policy) => {
71
191
  }
72
192
  return null;
73
193
  };
74
- const broadChange = ({ analysis }, policy) => {
75
- const touched = analysis.affectedNodeIds.length;
194
+ const broadChange = (measurement, policy) => {
195
+ const touched = measurement.affectedNodeCount;
76
196
  if (touched < policy.breadthThreshold)
77
197
  return null;
78
198
  return { code: "broad-change", level: "medium", detail: `touches ${touched} nodes` };
79
199
  };
80
- const isStructural = (analysis) => analysis.insertedNodeCount + analysis.removedNodeCount + analysis.movedNodeCount > 0;
81
- const shallowStructuralChange = ({ analysis }, policy) => {
82
- if (!isStructural(analysis))
200
+ const isStructural = (measurement) => measurement.insertedNodeCount + measurement.removedNodeCount + measurement.movedNodeCount > 0;
201
+ const shallowStructuralChange = (measurement, policy) => {
202
+ if (!isStructural(measurement))
83
203
  return null;
84
- if (analysis.shallowestAffectedDepth > policy.shallowDepthThreshold)
204
+ if (measurement.shallowestAffectedDepth > policy.shallowDepthThreshold)
85
205
  return null;
86
206
  return {
87
207
  code: "shallow-structural-change",
88
208
  level: "medium",
89
- detail: `restructures at depth ${analysis.shallowestAffectedDepth}`,
209
+ detail: `restructures at depth ${measurement.shallowestAffectedDepth}`,
90
210
  };
91
211
  };
92
212
  /**
@@ -108,7 +228,7 @@ const discardsLaterWork = ({ discards }) => {
108
228
  const nodes = new Set(discards.flatMap((discarded) => discarded.nodeIds));
109
229
  return {
110
230
  code: "discards-later-work",
111
- level: "high",
231
+ level: FIXED_LEVELS["discards-later-work"],
112
232
  detail: `discards work from revision${revisions.length === 1 ? "" : "s"} ${revisions.join(", ")} at ${nodes.size} node${nodes.size === 1 ? "" : "s"}`,
113
233
  };
114
234
  };
@@ -148,7 +268,7 @@ const nestedTarget = ({ analysis }) => {
148
268
  const one = nestedTargets.length === 1;
149
269
  return {
150
270
  code: "nested-target",
151
- level: "critical",
271
+ level: FIXED_LEVELS["nested-target"],
152
272
  detail: `puts ${one ? "a target" : `${nestedTargets.length} targets`} where the reader cannot reach ${one ? "it" : "them"}: ${nestedTargets.map(describeNestedTarget).join("; ")}`,
153
273
  };
154
274
  };
@@ -188,7 +308,7 @@ const unknownPrimitive = ({ analysis }) => {
188
308
  const one = unknownPrimitives.length === 1;
189
309
  return {
190
310
  code: "unknown-primitive",
191
- level: "critical",
311
+ level: FIXED_LEVELS["unknown-primitive"],
192
312
  detail: `adds ${one ? "a node" : `${unknownPrimitives.length} nodes`} no primitive is registered for, so ${one ? "it draws" : "they draw"} nothing: ${unknownPrimitives.map(describeUnknownPrimitive).join("; ")}`,
193
313
  };
194
314
  };
@@ -218,10 +338,80 @@ const invalidProps = ({ analysis }) => {
218
338
  const one = invalid.length === 1;
219
339
  return {
220
340
  code: "invalid-props",
221
- level: "critical",
341
+ level: FIXED_LEVELS["invalid-props"],
222
342
  detail: `leaves ${one ? "a node" : `${invalid.length} nodes`} carrying props the declaring primitive refuses, so ${one ? "it draws" : "they draw"} nothing: ${invalid.map(describeInvalidProps).join("; ")}`,
223
343
  };
224
344
  };
345
+ /**
346
+ * A question nothing will read, as damage.
347
+ *
348
+ * `critical`, which ranks it with `unknown-primitive` and `invalid-props`, and
349
+ * the argument is **not** theirs. Those two are `critical` because the damage is
350
+ * identical — `renderElement` returns `null` and the page has a hole — and a
351
+ * level that separated them would be ranking the explanation rather than the
352
+ * harm. This harm is a different thing: the page draws, nothing is missing from
353
+ * the markup, and what is wrong is that the region shows its empty state while
354
+ * the host pays a round trip to its own source on every render to fill it.
355
+ *
356
+ * It is ranked with them because of the **available answer** rather than the
357
+ * damage, which is worth stating plainly rather than filed under a family
358
+ * resemblance. A refusal is the disposition a repairer is offered, and
359
+ * *`loom.feed` reads `entries`, and this node asked under `rows`* is close to
360
+ * the most actionable thing a model can be told: the declaration holds the
361
+ * correct name, so the repair is one string. Confirmation is the wrong rung for
362
+ * the same reason it is wrong for invalid props — it puts a change to a person
363
+ * whose only sensible answer is no, and the one thing it could not tell them is
364
+ * what to do instead.
365
+ *
366
+ * The one case it ranks too high is the node somebody meant to leave asking
367
+ * ahead of a primitive that will read it next week. That change is honestly
368
+ * refusable today: the round trip is real now and the reader nobody wrote is
369
+ * not, so a host that wants it declares no reader and this never fires — which
370
+ * is the default, and 0002's answer to every knob that was not built.
371
+ */
372
+ const unreadBinding = ({ analysis }) => {
373
+ const { unreadBindings: unread } = analysis;
374
+ if (unread.length === 0)
375
+ return null;
376
+ const one = unread.length === 1;
377
+ return {
378
+ code: "unread-binding",
379
+ level: FIXED_LEVELS["unread-binding"],
380
+ detail: `asks ${one ? "a question" : `${unread.length} questions`} no primitive reads, so the ${one ? "answer is" : "answers are"} fetched and dropped: ${unread.map(describeUnreadBinding).join("; ")}`,
381
+ };
382
+ };
383
+ /**
384
+ * Content put where nothing will draw it, as damage.
385
+ *
386
+ * `critical`, which is `unread-binding`'s level and the argument for it applies
387
+ * here with one word changed. The repair is one string and the registry holds
388
+ * it: *`loom.dialog` places `header` and `footer`, and this node filled `body`*
389
+ * is something a repairer can act on without being told anything else, so a
390
+ * refusal is worth more to it than a confirmation a person can only answer no
391
+ * to.
392
+ *
393
+ * Where it is a stronger case than the binding is in what is lost. A question
394
+ * nothing reads costs a round trip and draws an empty state; a region nothing
395
+ * places drops the content **and everything under it**, so an author's
396
+ * paragraph is simply not on the page. 0249 gave the renderer a diagnostic for
397
+ * that and this is the half that keeps it from being written in the first
398
+ * place.
399
+ *
400
+ * It fires only where a host has handed a placer, which is 0002's answer again:
401
+ * a deployment resolving primitives from a plain map has never been able to say
402
+ * what a primitive places, and nothing here invents the knowledge.
403
+ */
404
+ const unplacedSlot = ({ analysis }) => {
405
+ const { unplacedSlots: unplaced } = analysis;
406
+ if (unplaced.length === 0)
407
+ return null;
408
+ const one = unplaced.length === 1;
409
+ return {
410
+ code: "unplaced-slot",
411
+ level: FIXED_LEVELS["unplaced-slot"],
412
+ detail: `fills ${one ? "a region" : `${unplaced.length} regions`} no primitive places, so the ${one ? "content and everything under it is" : "contents and everything under them are"} dropped: ${unplaced.map(describeUnplacedSlot).join("; ")}`,
413
+ };
414
+ };
225
415
  /**
226
416
  * A form pointed somewhere else, as damage.
227
417
  *
@@ -248,7 +438,7 @@ const redirectedSubmission = ({ analysis }) => {
248
438
  return null;
249
439
  return {
250
440
  code: "redirected-submission",
251
- level: "high",
441
+ level: FIXED_LEVELS["redirected-submission"],
252
442
  detail: `redirects ${redirectedSubmissions.length === 1 ? "a submission" : `${redirectedSubmissions.length} submissions`}: ${redirectedSubmissions.map(describeRedirectedSubmission).join("; ")}`,
253
443
  };
254
444
  };
@@ -277,11 +467,18 @@ const repointedBinding = ({ analysis }) => {
277
467
  return null;
278
468
  return {
279
469
  code: "repointed-binding",
280
- level: "high",
470
+ level: FIXED_LEVELS["repointed-binding"],
281
471
  detail: `repoints ${repointedBindings.length === 1 ? "a binding" : `${repointedBindings.length} bindings`}: ${repointedBindings.map(describeRepointedBinding).join("; ")}`,
282
472
  };
283
473
  };
284
- const FACTORS = [
474
+ /**
475
+ * The seven a policy decides, in the order the Gate raises them.
476
+ *
477
+ * Order is part of the record: `stakeFactorCodes` is written in the order the
478
+ * factors came out, so the two lists here are the one list this used to be, cut
479
+ * where the kinds change and not reordered.
480
+ */
481
+ const MEASURED_FACTORS = [
285
482
  protectedTypeRemoved,
286
483
  protectedTypeTouched,
287
484
  protectedTypeRelocated,
@@ -289,15 +486,32 @@ const FACTORS = [
289
486
  largeRemoval,
290
487
  broadChange,
291
488
  shallowStructuralChange,
489
+ ];
490
+ /** The eight fixed at their code, which read the specifics a record does not carry. */
491
+ const FIXED_FACTORS = [
292
492
  discardsLaterWork,
293
493
  nestedTarget,
294
494
  unknownPrimitive,
295
495
  invalidProps,
496
+ unreadBinding,
497
+ unplacedSlot,
296
498
  redirectedSubmission,
297
499
  repointedBinding,
298
500
  ];
501
+ /**
502
+ * The policy-dependent half, against a measurement rather than a delta.
503
+ *
504
+ * Published because it is the half that can be run twice: once by the Gate on
505
+ * the change in front of it, and again by anything holding a record of that
506
+ * change and a policy it is considering. The other half cannot, which is why it
507
+ * is not here — see `fixedStakeLevel`.
508
+ */
509
+ export const measureStakes = (measurement, policy) => MEASURED_FACTORS.flatMap((factor) => factor(measurement, policy) ?? []);
299
510
  export const assessStakes = (input, policy) => {
300
- const factors = FACTORS.flatMap((factor) => factor(input, policy) ?? []);
511
+ const factors = [
512
+ ...measureStakes(stakeMeasurementOf(input.analysis), policy),
513
+ ...FIXED_FACTORS.flatMap((factor) => factor(input, policy) ?? []),
514
+ ];
301
515
  return { level: highestStake(factors.map((factor) => factor.level)), factors };
302
516
  };
303
517
  /** The factor with this code, for a caller that needs the reason and not the level. */