@jam-overture/loom 0.1.0 → 0.2.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 (290) 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/cli/templates.js +19 -0
  11. package/dist/data/plan.js +0 -0
  12. package/dist/data/resolution.d.ts +23 -1
  13. package/dist/data/resolve.d.ts +30 -3
  14. package/dist/data/resolve.js +11 -3
  15. package/dist/ids.d.ts +10 -0
  16. package/dist/ids.js +11 -1
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.js +1 -0
  19. package/dist/patch.d.ts +54 -0
  20. package/dist/patch.js +44 -0
  21. package/dist/project/closing.d.ts +51 -0
  22. package/dist/project/closing.js +53 -0
  23. package/dist/project/memory.d.ts +20 -0
  24. package/dist/project/memory.js +97 -0
  25. package/dist/project/project.d.ts +90 -0
  26. package/dist/project/project.js +91 -0
  27. package/dist/project/store.d.ts +135 -0
  28. package/dist/project/store.js +41 -0
  29. package/dist/registered.d.ts +64 -0
  30. package/dist/registered.js +118 -0
  31. package/dist/render/behaviour-adjust.d.ts +11 -19
  32. package/dist/render/behaviour-adjust.js +75 -21
  33. package/dist/render/behaviour-present.d.ts +8 -0
  34. package/dist/render/behaviour-present.js +57 -6
  35. package/dist/render/behaviour.d.ts +98 -17
  36. package/dist/render/behaviour.js +91 -26
  37. package/dist/render/control-name.d.ts +68 -0
  38. package/dist/render/control-name.js +37 -0
  39. package/dist/render/diagnostics.d.ts +72 -0
  40. package/dist/render/diagnostics.js +7 -0
  41. package/dist/render/index.d.ts +2 -0
  42. package/dist/render/index.js +2 -0
  43. package/dist/render/reads.d.ts +11 -0
  44. package/dist/render/reads.js +12 -1
  45. package/dist/render/render.js +102 -7
  46. package/dist/render/slots.d.ts +52 -0
  47. package/dist/render/slots.js +24 -0
  48. package/dist/render/theme.d.ts +54 -1
  49. package/dist/render/theme.js +23 -1
  50. package/dist/render/unshown.d.ts +152 -0
  51. package/dist/render/unshown.js +80 -0
  52. package/dist/runtime/analysis.d.ts +94 -9
  53. package/dist/runtime/analysis.js +54 -9
  54. package/dist/runtime/assessment.d.ts +36 -2
  55. package/dist/runtime/assessment.js +27 -2
  56. package/dist/runtime/checks.d.ts +148 -0
  57. package/dist/runtime/checks.js +112 -0
  58. package/dist/runtime/disposition.d.ts +96 -0
  59. package/dist/runtime/disposition.js +46 -0
  60. package/dist/runtime/gate.js +22 -0
  61. package/dist/runtime/index.d.ts +3 -0
  62. package/dist/runtime/index.js +3 -0
  63. package/dist/runtime/irreversibility.d.ts +64 -0
  64. package/dist/runtime/irreversibility.js +45 -0
  65. package/dist/runtime/pipeline.d.ts +43 -0
  66. package/dist/runtime/pipeline.js +10 -2
  67. package/dist/runtime/policy-change.d.ts +93 -0
  68. package/dist/runtime/policy-change.js +299 -0
  69. package/dist/runtime/policy-log.d.ts +406 -0
  70. package/dist/runtime/policy-log.js +285 -0
  71. package/dist/runtime/reversibility.d.ts +11 -9
  72. package/dist/runtime/stakes.d.ts +129 -1
  73. package/dist/runtime/stakes.js +240 -26
  74. package/dist/runtime/vocabulary.d.ts +164 -7
  75. package/dist/runtime/vocabulary.js +181 -8
  76. package/dist/sdk/audit.d.ts +174 -3
  77. package/dist/sdk/audit.js +176 -17
  78. package/dist/sdk/catalogue.d.ts +9 -1
  79. package/dist/sdk/conformance.d.ts +37 -3
  80. package/dist/sdk/conformance.js +25 -4
  81. package/dist/sdk/definition.d.ts +65 -0
  82. package/dist/sdk/definition.js +22 -0
  83. package/dist/sdk/registry.d.ts +29 -2
  84. package/dist/sdk/registry.js +63 -1
  85. package/dist/signals/action-change.d.ts +507 -0
  86. package/dist/signals/action-change.js +265 -0
  87. package/dist/signals/action.d.ts +331 -0
  88. package/dist/signals/action.js +182 -0
  89. package/dist/signals/applied-window.contract.d.ts +23 -0
  90. package/dist/signals/applied-window.contract.js +160 -0
  91. package/dist/signals/arriving.d.ts +210 -0
  92. package/dist/signals/arriving.js +133 -0
  93. package/dist/signals/audiences.d.ts +528 -0
  94. package/dist/signals/audiences.js +255 -0
  95. package/dist/signals/broadcast.d.ts +8 -2
  96. package/dist/signals/broadcast.js +58 -8
  97. package/dist/signals/change.d.ts +378 -0
  98. package/dist/signals/change.js +327 -0
  99. package/dist/signals/collect.d.ts +41 -0
  100. package/dist/signals/collect.js +88 -7
  101. package/dist/signals/copy-change.d.ts +553 -0
  102. package/dist/signals/copy-change.js +377 -0
  103. package/dist/signals/copy.d.ts +337 -0
  104. package/dist/signals/copy.js +211 -0
  105. package/dist/signals/counters.d.ts +46 -0
  106. package/dist/signals/counters.js +102 -0
  107. package/dist/signals/deliver.d.ts +23 -4
  108. package/dist/signals/deliver.js +34 -6
  109. package/dist/signals/deployment-change.d.ts +371 -0
  110. package/dist/signals/deployment-change.js +268 -0
  111. package/dist/signals/deployment.d.ts +265 -0
  112. package/dist/signals/deployment.js +152 -0
  113. package/dist/signals/door.d.ts +92 -0
  114. package/dist/signals/door.js +53 -0
  115. package/dist/signals/fold.d.ts +10 -0
  116. package/dist/signals/fold.js +5 -1
  117. package/dist/signals/form-action.d.ts +302 -0
  118. package/dist/signals/form-action.js +169 -0
  119. package/dist/signals/form-copy.d.ts +523 -0
  120. package/dist/signals/form-copy.js +346 -0
  121. package/dist/signals/forms.d.ts +247 -0
  122. package/dist/signals/forms.js +147 -0
  123. package/dist/signals/funnel-change.d.ts +548 -0
  124. package/dist/signals/funnel-change.js +361 -0
  125. package/dist/signals/funnel.d.ts +532 -0
  126. package/dist/signals/funnel.js +216 -0
  127. package/dist/signals/health.d.ts +497 -0
  128. package/dist/signals/health.js +361 -0
  129. package/dist/signals/index.d.ts +41 -0
  130. package/dist/signals/index.js +41 -0
  131. package/dist/signals/ingest.d.ts +56 -1
  132. package/dist/signals/ingest.js +91 -1
  133. package/dist/signals/journal.d.ts +11 -0
  134. package/dist/signals/kinds.d.ts +8 -6
  135. package/dist/signals/kinds.js +14 -6
  136. package/dist/signals/library-action.d.ts +430 -0
  137. package/dist/signals/library-action.js +336 -0
  138. package/dist/signals/library-change.d.ts +477 -0
  139. package/dist/signals/library-change.js +335 -0
  140. package/dist/signals/library-copy-change.d.ts +498 -0
  141. package/dist/signals/library-copy-change.js +476 -0
  142. package/dist/signals/library-pace.d.ts +319 -0
  143. package/dist/signals/library-pace.js +305 -0
  144. package/dist/signals/library-reach-change.d.ts +636 -0
  145. package/dist/signals/library-reach-change.js +534 -0
  146. package/dist/signals/library-reach.d.ts +377 -0
  147. package/dist/signals/library-reach.js +227 -0
  148. package/dist/signals/library-word-reach-change.d.ts +567 -0
  149. package/dist/signals/library-word-reach-change.js +568 -0
  150. package/dist/signals/library.d.ts +306 -0
  151. package/dist/signals/library.js +178 -0
  152. package/dist/signals/memory.d.ts +9 -0
  153. package/dist/signals/memory.js +105 -14
  154. package/dist/signals/migrate.d.ts +17 -2
  155. package/dist/signals/migrate.js +122 -5
  156. package/dist/signals/notice.d.ts +334 -0
  157. package/dist/signals/notice.js +228 -0
  158. package/dist/signals/pace-change.d.ts +501 -0
  159. package/dist/signals/pace-change.js +310 -0
  160. package/dist/signals/pace.d.ts +296 -0
  161. package/dist/signals/pace.js +291 -0
  162. package/dist/signals/page-views.d.ts +365 -0
  163. package/dist/signals/page-views.js +218 -0
  164. package/dist/signals/parts.d.ts +344 -0
  165. package/dist/signals/parts.js +273 -0
  166. package/dist/signals/postgres.d.ts +16 -2
  167. package/dist/signals/postgres.js +390 -87
  168. package/dist/signals/progress.d.ts +212 -0
  169. package/dist/signals/progress.js +150 -0
  170. package/dist/signals/ratios.d.ts +108 -0
  171. package/dist/signals/ratios.js +40 -0
  172. package/dist/signals/reach.d.ts +309 -0
  173. package/dist/signals/reach.js +93 -0
  174. package/dist/signals/readable.d.ts +34 -0
  175. package/dist/signals/readable.js +34 -0
  176. package/dist/signals/readership.d.ts +381 -0
  177. package/dist/signals/readership.js +308 -0
  178. package/dist/signals/region-pages.d.ts +173 -0
  179. package/dist/signals/region-pages.js +62 -0
  180. package/dist/signals/region.d.ts +287 -0
  181. package/dist/signals/region.js +198 -0
  182. package/dist/signals/retention.d.ts +141 -0
  183. package/dist/signals/retention.js +58 -0
  184. package/dist/signals/rollup.d.ts +67 -3
  185. package/dist/signals/rollup.js +0 -0
  186. package/dist/signals/schema.d.ts +432 -1
  187. package/dist/signals/schema.js +157 -3
  188. package/dist/signals/signal.d.ts +237 -11
  189. package/dist/signals/signal.js +70 -10
  190. package/dist/signals/silence-census.d.ts +205 -0
  191. package/dist/signals/silence-census.js +87 -0
  192. package/dist/signals/silences.d.ts +848 -0
  193. package/dist/signals/silences.js +753 -0
  194. package/dist/signals/tally.d.ts +140 -11
  195. package/dist/signals/window-figures.d.ts +148 -0
  196. package/dist/signals/window-figures.js +42 -0
  197. package/dist/signals/window.d.ts +866 -0
  198. package/dist/signals/window.js +693 -0
  199. package/dist/signals/words.d.ts +24 -0
  200. package/dist/signals/words.js +24 -0
  201. package/dist/store/index.d.ts +19 -0
  202. package/dist/store/index.js +19 -0
  203. package/dist/store/memory.d.ts +2 -1
  204. package/dist/store/memory.js +48 -12
  205. package/dist/store/migrate.d.ts +80 -0
  206. package/dist/store/migrate.js +259 -7
  207. package/dist/store/postgres-applications.d.ts +4 -0
  208. package/dist/store/postgres-applications.js +197 -0
  209. package/dist/store/postgres-holds.d.ts +10 -1
  210. package/dist/store/postgres-holds.js +116 -101
  211. package/dist/store/postgres-policy-log.d.ts +14 -0
  212. package/dist/store/postgres-policy-log.js +240 -0
  213. package/dist/store/postgres-projects.d.ts +4 -0
  214. package/dist/store/postgres-projects.js +217 -0
  215. package/dist/store/postgres.d.ts +16 -1
  216. package/dist/store/postgres.js +59 -9
  217. package/dist/store/replay.d.ts +102 -1
  218. package/dist/store/replay.js +190 -19
  219. package/dist/store/reseed.d.ts +238 -0
  220. package/dist/store/reseed.js +308 -0
  221. package/dist/store/schema.d.ts +450 -2
  222. package/dist/store/schema.js +141 -5
  223. package/dist/store/store.d.ts +29 -6
  224. package/dist/submit/resolve.js +2 -1
  225. package/dist/telemetry/calibration.d.ts +25 -0
  226. package/dist/telemetry/calibration.js +27 -1
  227. package/dist/telemetry/event.d.ts +391 -33
  228. package/dist/telemetry/event.js +84 -20
  229. package/dist/telemetry/index.d.ts +1 -0
  230. package/dist/telemetry/index.js +1 -0
  231. package/dist/telemetry/journal.d.ts +72 -3
  232. package/dist/telemetry/journal.js +9 -0
  233. package/dist/telemetry/lookup.d.ts +27 -0
  234. package/dist/telemetry/lookup.js +18 -0
  235. package/dist/telemetry/memory.js +23 -0
  236. package/dist/telemetry/migrate.js +22 -1
  237. package/dist/telemetry/postgres.d.ts +10 -1
  238. package/dist/telemetry/postgres.js +172 -90
  239. package/dist/telemetry/remeasure.d.ts +78 -0
  240. package/dist/telemetry/remeasure.js +83 -0
  241. package/dist/telemetry/retention.d.ts +2 -2
  242. package/dist/telemetry/schema.d.ts +17 -0
  243. package/dist/telemetry/schema.js +27 -1
  244. package/dist/telemetry/sink.d.ts +2 -2
  245. package/dist/testing/application-contract.d.ts +14 -0
  246. package/dist/testing/application-contract.js +270 -0
  247. package/dist/testing/contracts.d.ts +12 -7
  248. package/dist/testing/contracts.js +12 -7
  249. package/dist/testing/definitions.d.ts +78 -0
  250. package/dist/testing/definitions.js +134 -9
  251. package/dist/testing/doubles.d.ts +103 -0
  252. package/dist/testing/doubles.js +143 -0
  253. package/dist/testing/index.d.ts +2 -2
  254. package/dist/testing/index.js +2 -2
  255. package/dist/testing/journal-contract.js +140 -2
  256. package/dist/testing/model-contract.d.ts +110 -0
  257. package/dist/testing/model-contract.js +150 -0
  258. package/dist/testing/policy-log-contract.d.ts +26 -0
  259. package/dist/testing/policy-log-contract.js +344 -0
  260. package/dist/testing/project-contract.d.ts +14 -0
  261. package/dist/testing/project-contract.js +266 -0
  262. package/dist/testing/reader-signal-contract.d.ts +27 -2
  263. package/dist/testing/reader-signal-contract.js +475 -5
  264. package/dist/testing/store-contract.d.ts +7 -1
  265. package/dist/testing/store-contract.js +84 -3
  266. package/dist/theme/apply.d.ts +20 -1
  267. package/dist/theme/apply.js +5 -3
  268. package/dist/theme/derive.d.ts +22 -0
  269. package/dist/theme/derive.js +54 -1
  270. package/dist/theme/library.js +1 -1
  271. package/dist/theme/measure.d.ts +34 -0
  272. package/dist/theme/measure.js +30 -1
  273. package/dist/theme/palettes.js +7 -7
  274. package/dist/theme/ramp.d.ts +64 -0
  275. package/dist/theme/ramp.js +114 -0
  276. package/dist/theme/registry.d.ts +9 -0
  277. package/dist/theme/registry.js +11 -1
  278. package/dist/theme/separation.d.ts +97 -3
  279. package/dist/theme/separation.js +75 -0
  280. package/dist/tree/compare.d.ts +9 -0
  281. package/dist/tree/compare.js +18 -0
  282. package/dist/write/computed.d.ts +60 -0
  283. package/dist/write/computed.js +61 -0
  284. package/dist/write/held.d.ts +59 -0
  285. package/dist/write/index.d.ts +5 -2
  286. package/dist/write/index.js +5 -2
  287. package/dist/write/reseed.d.ts +151 -0
  288. package/dist/write/reseed.js +184 -0
  289. package/dist/write/revert.js +2 -16
  290. package/package.json +98 -19
@@ -0,0 +1,151 @@
1
+ import type { IdFactory, TreeId } from "../ids.js";
2
+ import type { Clock } from "../runtime/events.js";
3
+ import type { IntentOrigin } from "../runtime/intent.js";
4
+ import type { ChangeInterpreter } from "../runtime/interpreter.js";
5
+ import type { DiscardedWork } from "../runtime/proposal.js";
6
+ import { type ReseedPlan, type UnreseedablePlan } from "../store/reseed.js";
7
+ import type { LoomTree } from "../tree/tree.js";
8
+ import { type WriteOutcome, type WritePath } from "./commit.js";
9
+ /**
10
+ * Putting a page back, as a change like any other — and the half that makes the
11
+ * operation pressable.
12
+ *
13
+ * `planReseed` has been able to say *here are the operations that carry this
14
+ * stored page to the tree its builder produces now* since 0268. Nothing
15
+ * proposed them. The gap that left is the one `Loom marketing` filed on 12
16
+ * October, and it filed it as a cost rather than as a gap, which is the version
17
+ * that says who is blocked:
18
+ *
19
+ * > **Merging a marketing pull request no longer changes the marketing site.**
20
+ *
21
+ * Every page of that surface is already a row on any deployment that has been
22
+ * visited once. Seeding is create-if-absent and must stay that way — a deploy
23
+ * that wrote over a stored page would throw away every change somebody accepted
24
+ * in the portal, which is the trade 0259 took deliberately. So an edited builder
25
+ * finds the same tree id it found yesterday, leaves it alone, and the authored
26
+ * page stops being the served one.
27
+ *
28
+ * This is `revertRevision`'s sibling and takes the same seven steps: interpreted
29
+ * (deterministically), proposed, assessed, gated, applied, and appended to the
30
+ * log as a new revision. A reseed is therefore attributable to whoever asked for
31
+ * it, refusable by the Gate, holdable for confirmation, visible to telemetry,
32
+ * and itself revertable. The log says *this page was put back on this date, by
33
+ * this person, over these revisions* rather than the history simply ending.
34
+ *
35
+ * ## The question this does not answer, and does not need to
36
+ *
37
+ * The entry asked for one decision beyond the operation: **who presses it.** It
38
+ * set out three answers — only a person, on every deploy, or a button on the
39
+ * page's own screen beside its history — and preferred the third.
40
+ *
41
+ * The Gate already answers it, and the answer is better than any of the three
42
+ * because it is not a fourth switch. 0035 made discarded work a *rule* rather
43
+ * than a level: a change that writes over work already in the log is never
44
+ * applied without a person, whatever latitude its origin has. `reseedDiscards`
45
+ * reads the log and declares what this reseed costs, so:
46
+ *
47
+ * - a page nobody has edited since it was seeded declares nothing, and the
48
+ * reseed applies. A deploy step may call this, and the authored page wins,
49
+ * which is the right default for a page no one has touched.
50
+ * - a page somebody has edited through the portal declares those revisions, and
51
+ * the reseed is **held** — the same hold a reviewer answers on
52
+ * `/portal/trust`, carrying the sentence that names what it would overwrite.
53
+ * A deploy step may call this too, and it cannot quietly discard the edit.
54
+ *
55
+ * So the caller does not choose the safety; the cost of the particular reseed
56
+ * does. The surfaces are then free to offer the button wherever it belongs
57
+ * (`Loom portal`'s to place), because every route to it is the same route.
58
+ *
59
+ * ## What this does not become
60
+ *
61
+ * `TreeStore` still gains nothing — no delete, no reseed method, nothing that
62
+ * writes a tree without being proposed (0268). Seeding is still create-only.
63
+ * What is new is one function a surface can call, and it goes through the one
64
+ * write path (0017) like everything else that becomes history.
65
+ */
66
+ /** What produced the delta, for `Provenance.interpreter`. Not a model. */
67
+ export declare const RESEED_INTERPRETER = "loom/reseed";
68
+ export type ReseedablePlan = Extract<ReseedPlan, {
69
+ readonly outcome: "reseedable";
70
+ }>;
71
+ /** Everything that stops a reseed being proposed. `already-authored` is not one — see `ReseedOutcome`. */
72
+ export type UnproposableReseed = Exclude<UnreseedablePlan, {
73
+ readonly outcome: "already-authored";
74
+ }>;
75
+ /**
76
+ * The same interpreter every reseed uses, with the plan's half filled in.
77
+ *
78
+ * Everything specific to a reseed is here — the stamp that says the runtime
79
+ * planned this against a builder, the rationale a reviewer reads, and the
80
+ * discards the log read found. What is left is `inverseInterpreter`: the head
81
+ * check, the provenance of a computed change, and the shape of the proposal are
82
+ * one implementation rather than two that drift.
83
+ *
84
+ * `undoes` is **absent**, and that is not an omission. It names the one revision
85
+ * a change puts back, and a reseed puts back no revision — it carries the page
86
+ * to a tree that was never in the log, over however many entries stand in the
87
+ * way. Stamping any number there would be a claim the log cannot support; the
88
+ * revisions it writes over are in `discards`, where they are true.
89
+ */
90
+ export declare const reseedInterpreter: (plan: ReseedablePlan, discards: readonly DiscardedWork[], idFactory: IdFactory, clock: Clock) => ChangeInterpreter;
91
+ export type ReseedRequest = {
92
+ readonly treeId: TreeId;
93
+ /**
94
+ * A fresh build of the page — what the builder in the repository produces now.
95
+ *
96
+ * The caller's rather than something this module could obtain, because a
97
+ * builder is the host's: §3 has no registry of pages and no way to run one.
98
+ * The surfaces hold theirs already, and both sides of the comparison being
99
+ * passed in is what keeps this testable without a build step.
100
+ */
101
+ readonly authored: LoomTree;
102
+ readonly origin: IntentOrigin;
103
+ readonly actor?: string;
104
+ };
105
+ export type ReseedOutcome = WriteOutcome
106
+ /**
107
+ * The stored page is already the tree the builder produces, so nothing was
108
+ * proposed and nothing needed to be.
109
+ *
110
+ * Its own ending rather than one of the obstacles below, which is the
111
+ * difference between this and `revertRevision`. A reseed is the kind of
112
+ * operation that gets pressed twice — by a person who cannot see whether the
113
+ * first took, and by a deploy that runs on every release — so *the page is
114
+ * already right* is the healthy answer, and a caller that could not tell it
115
+ * from *the page cannot be put back* would report a success as a failure on
116
+ * every release after the first.
117
+ */
118
+ | {
119
+ readonly kind: "already-authored";
120
+ readonly headRevision: number;
121
+ }
122
+ /**
123
+ * Nothing was proposed, because no reseed could be planned: the two trees are
124
+ * different pages, or they differ by something no operation can express.
125
+ * Writing over accepted work is not one of these — that is a proposal the Gate
126
+ * holds, not a plan that failed (0035).
127
+ */
128
+ | {
129
+ readonly kind: "not-reseedable";
130
+ readonly plan: UnproposableReseed;
131
+ };
132
+ export declare const describeReseedOutcome: (outcome: ReseedOutcome) => string;
133
+ /**
134
+ * Puts a page back to its authored shape, if it can be expressed and the Gate
135
+ * agrees.
136
+ *
137
+ * Reads head itself rather than taking the stored tree, because the head the
138
+ * plan is made against and the head the intent names have to be the same
139
+ * revision — and a caller passing one it read earlier is a caller that can pass
140
+ * a stale one. The write path checks the intent against head again before
141
+ * interpreting, and the interpreter refuses a tree at a revision the plan was
142
+ * not made against, so a page that moves between the read and the commit ends as
143
+ * a `revision-conflict` rather than as a reseed to the wrong arrangement.
144
+ *
145
+ * The intent is synthesised here, for the reason the revert path gives: the
146
+ * utterance behind a reseed is not a sentence anybody typed. `origin` and
147
+ * `actor` are the caller's, and they are what the Gate weighs and what the
148
+ * provenance records — putting a page back is still someone asking for a change.
149
+ */
150
+ export declare const reseedPage: (path: WritePath, request: ReseedRequest) => Promise<ReseedOutcome>;
151
+ //# sourceMappingURL=reseed.d.ts.map
@@ -0,0 +1,184 @@
1
+ import { inverseInterpreter } from "../runtime/inverse.js";
2
+ import { describeReseedPlan, planReseed, reseedDiscards, } from "../store/reseed.js";
3
+ import { commitIntent, describeWriteOutcome } from "./commit.js";
4
+ import { computedChangeRuntime } from "./computed.js";
5
+ /**
6
+ * Putting a page back, as a change like any other — and the half that makes the
7
+ * operation pressable.
8
+ *
9
+ * `planReseed` has been able to say *here are the operations that carry this
10
+ * stored page to the tree its builder produces now* since 0268. Nothing
11
+ * proposed them. The gap that left is the one `Loom marketing` filed on 12
12
+ * October, and it filed it as a cost rather than as a gap, which is the version
13
+ * that says who is blocked:
14
+ *
15
+ * > **Merging a marketing pull request no longer changes the marketing site.**
16
+ *
17
+ * Every page of that surface is already a row on any deployment that has been
18
+ * visited once. Seeding is create-if-absent and must stay that way — a deploy
19
+ * that wrote over a stored page would throw away every change somebody accepted
20
+ * in the portal, which is the trade 0259 took deliberately. So an edited builder
21
+ * finds the same tree id it found yesterday, leaves it alone, and the authored
22
+ * page stops being the served one.
23
+ *
24
+ * This is `revertRevision`'s sibling and takes the same seven steps: interpreted
25
+ * (deterministically), proposed, assessed, gated, applied, and appended to the
26
+ * log as a new revision. A reseed is therefore attributable to whoever asked for
27
+ * it, refusable by the Gate, holdable for confirmation, visible to telemetry,
28
+ * and itself revertable. The log says *this page was put back on this date, by
29
+ * this person, over these revisions* rather than the history simply ending.
30
+ *
31
+ * ## The question this does not answer, and does not need to
32
+ *
33
+ * The entry asked for one decision beyond the operation: **who presses it.** It
34
+ * set out three answers — only a person, on every deploy, or a button on the
35
+ * page's own screen beside its history — and preferred the third.
36
+ *
37
+ * The Gate already answers it, and the answer is better than any of the three
38
+ * because it is not a fourth switch. 0035 made discarded work a *rule* rather
39
+ * than a level: a change that writes over work already in the log is never
40
+ * applied without a person, whatever latitude its origin has. `reseedDiscards`
41
+ * reads the log and declares what this reseed costs, so:
42
+ *
43
+ * - a page nobody has edited since it was seeded declares nothing, and the
44
+ * reseed applies. A deploy step may call this, and the authored page wins,
45
+ * which is the right default for a page no one has touched.
46
+ * - a page somebody has edited through the portal declares those revisions, and
47
+ * the reseed is **held** — the same hold a reviewer answers on
48
+ * `/portal/trust`, carrying the sentence that names what it would overwrite.
49
+ * A deploy step may call this too, and it cannot quietly discard the edit.
50
+ *
51
+ * So the caller does not choose the safety; the cost of the particular reseed
52
+ * does. The surfaces are then free to offer the button wherever it belongs
53
+ * (`Loom portal`'s to place), because every route to it is the same route.
54
+ *
55
+ * ## What this does not become
56
+ *
57
+ * `TreeStore` still gains nothing — no delete, no reseed method, nothing that
58
+ * writes a tree without being proposed (0268). Seeding is still create-only.
59
+ * What is new is one function a surface can call, and it goes through the one
60
+ * write path (0017) like everything else that becomes history.
61
+ */
62
+ /** What produced the delta, for `Provenance.interpreter`. Not a model. */
63
+ export const RESEED_INTERPRETER = "loom/reseed";
64
+ const countOf = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
65
+ /**
66
+ * What the reseed is for, and — when there is one — what it costs.
67
+ *
68
+ * Stated in the rationale as well as declared in `discards`, for the reason
69
+ * `revertRevision` gives: the Gate reads the declaration and the person
70
+ * answering the hold reads this (0019 — a reviewer is shown the reason, not a
71
+ * verdict).
72
+ *
73
+ * The shape of the page is named before the cost, because the two answer
74
+ * different halves of a reviewer's question. *What does this do to the page* is
75
+ * the operations, the nodes it removes and the ids it brings back. *What does it
76
+ * take away from me* is the revisions. A reviewer who is told only the second
77
+ * cannot tell a headline being restored from the page being emptied.
78
+ */
79
+ const rationaleFor = (plan, discards) => {
80
+ const puts = `Puts the page back to the tree its builder produces, at head ${plan.headRevision}: ${countOf(plan.operations.length, "operation")}${plan.retires.length === 0 ? "" : `, removing ${countOf(plan.retires.length, "node")}`}${plan.revives.length === 0 ? "" : `, reviving ${countOf(plan.revives.length, "id")}`}.`;
81
+ if (discards.length === 0)
82
+ return `${puts} Nothing in the log has touched the nodes it changes.`;
83
+ const revisions = discards.map((discarded) => discarded.revision).join(", ");
84
+ return `${puts} Revision${discards.length === 1 ? "" : "s"} ${revisions} changed nodes this reseed touches, and applying it writes over what they did.`;
85
+ };
86
+ /**
87
+ * The same interpreter every reseed uses, with the plan's half filled in.
88
+ *
89
+ * Everything specific to a reseed is here — the stamp that says the runtime
90
+ * planned this against a builder, the rationale a reviewer reads, and the
91
+ * discards the log read found. What is left is `inverseInterpreter`: the head
92
+ * check, the provenance of a computed change, and the shape of the proposal are
93
+ * one implementation rather than two that drift.
94
+ *
95
+ * `undoes` is **absent**, and that is not an omission. It names the one revision
96
+ * a change puts back, and a reseed puts back no revision — it carries the page
97
+ * to a tree that was never in the log, over however many entries stand in the
98
+ * way. Stamping any number there would be a claim the log cannot support; the
99
+ * revisions it writes over are in `discards`, where they are true.
100
+ */
101
+ export const reseedInterpreter = (plan, discards, idFactory, clock) => inverseInterpreter({
102
+ operations: plan.operations,
103
+ /**
104
+ * The plan and its cost were both measured at one head. Judging them at a
105
+ * different one would be judging a different question, so the interpreter
106
+ * declines rather than proposing something whose reasoning has expired.
107
+ */
108
+ headRevision: plan.headRevision,
109
+ interpreter: RESEED_INTERPRETER,
110
+ rationale: rationaleFor(plan, discards),
111
+ /**
112
+ * Declared only when there is something to declare, so absence keeps
113
+ * meaning "nobody looked at a log" rather than "a log was checked and was
114
+ * clean" (0035). Here a log was always read — the empty case is said in
115
+ * the rationale in words instead, which is the only place it can be said
116
+ * without lying in a field.
117
+ */
118
+ ...(discards.length === 0 ? {} : { discards }),
119
+ }, idFactory, clock);
120
+ export const describeReseedOutcome = (outcome) => {
121
+ switch (outcome.kind) {
122
+ case "already-authored":
123
+ return `already authored: revision ${outcome.headRevision} is the page the builder produces`;
124
+ case "not-reseedable":
125
+ return `not reseedable: ${describeReseedPlan(outcome.plan)}`;
126
+ default:
127
+ return describeWriteOutcome(outcome);
128
+ }
129
+ };
130
+ /**
131
+ * Puts a page back to its authored shape, if it can be expressed and the Gate
132
+ * agrees.
133
+ *
134
+ * Reads head itself rather than taking the stored tree, because the head the
135
+ * plan is made against and the head the intent names have to be the same
136
+ * revision — and a caller passing one it read earlier is a caller that can pass
137
+ * a stale one. The write path checks the intent against head again before
138
+ * interpreting, and the interpreter refuses a tree at a revision the plan was
139
+ * not made against, so a page that moves between the read and the commit ends as
140
+ * a `revision-conflict` rather than as a reseed to the wrong arrangement.
141
+ *
142
+ * The intent is synthesised here, for the reason the revert path gives: the
143
+ * utterance behind a reseed is not a sentence anybody typed. `origin` and
144
+ * `actor` are the caller's, and they are what the Gate weighs and what the
145
+ * provenance records — putting a page back is still someone asking for a change.
146
+ */
147
+ export const reseedPage = async (path, request) => {
148
+ const head = await path.store.head(request.treeId);
149
+ if (!head.ok)
150
+ return { kind: "not-written", error: head.error };
151
+ const plan = planReseed(head.value, request.authored);
152
+ if (plan.outcome === "already-authored") {
153
+ return { kind: "already-authored", headRevision: plan.headRevision };
154
+ }
155
+ if (plan.outcome !== "reseedable")
156
+ return { kind: "not-reseedable", plan };
157
+ /**
158
+ * The cost is read before anything is proposed, and a log that cannot be read
159
+ * stops the reseed. Proposing it with an empty declaration would tell the Gate
160
+ * the log was clean, and the Gate would apply it over somebody's accepted edit.
161
+ */
162
+ const discards = await reseedDiscards(path.store, {
163
+ treeId: request.treeId,
164
+ operations: plan.operations,
165
+ });
166
+ if (!discards.ok)
167
+ return { kind: "not-written", error: discards.error };
168
+ const { idFactory, clock } = path.runtime;
169
+ const intent = {
170
+ intentId: idFactory.intentId(),
171
+ treeId: request.treeId,
172
+ baseRevision: plan.headRevision,
173
+ origin: request.origin,
174
+ ...(request.actor === undefined ? {} : { actor: request.actor }),
175
+ utterance: "Put this page back to the version in the repository.",
176
+ observedAt: clock.now(),
177
+ };
178
+ return commitIntent({
179
+ store: path.store,
180
+ holds: path.holds,
181
+ runtime: computedChangeRuntime(path.runtime, reseedInterpreter(plan, discards.value, idFactory, clock)),
182
+ }, intent);
183
+ };
184
+ //# sourceMappingURL=reseed.js.map
@@ -1,6 +1,7 @@
1
1
  import { inverseInterpreter } from "../runtime/inverse.js";
2
2
  import { describeRevertPlan, planRevert } from "../store/revert.js";
3
3
  import { commitIntent, describeWriteOutcome } from "./commit.js";
4
+ import { computedChangeRuntime } from "./computed.js";
4
5
  /**
5
6
  * Undo, as a change like any other.
6
7
  *
@@ -80,21 +81,6 @@ export const revertInterpreter = (plan, idFactory, clock) => inverseInterpreter(
80
81
  export const describeRevertOutcome = (outcome) => outcome.kind === "not-revertable"
81
82
  ? `not revertable: ${describeRevertPlan(outcome.plan)}`
82
83
  : describeWriteOutcome(outcome);
83
- /**
84
- * The same runtime, interpreting reverts.
85
- *
86
- * Built field by field rather than spread, so that dropping the repairer is a
87
- * statement instead of an omission: repair (0006) exists to let a model try a
88
- * smaller version of what the Gate refused, and there is no smaller version of
89
- * an undo. A revert the Gate refuses is refused.
90
- */
91
- const revertingRuntime = (runtime, interpreter) => ({
92
- interpreter,
93
- policySource: runtime.policySource,
94
- events: runtime.events,
95
- clock: runtime.clock,
96
- idFactory: runtime.idFactory,
97
- });
98
84
  /**
99
85
  * Undoes a revision, if the log allows it and the Gate agrees.
100
86
  *
@@ -128,7 +114,7 @@ export const revertRevision = async (path, request) => {
128
114
  return commitIntent({
129
115
  store: path.store,
130
116
  holds: path.holds,
131
- runtime: revertingRuntime(path.runtime, revertInterpreter(plan, idFactory, clock)),
117
+ runtime: computedChangeRuntime(path.runtime, revertInterpreter(plan, idFactory, clock)),
132
118
  }, intent);
133
119
  };
134
120
  //# sourceMappingURL=revert.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jam-overture/loom",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Loom — an AI-powered adaptive UI runtime",
5
5
  "license": "MIT",
6
6
  "author": "jam-overture",
@@ -40,6 +40,14 @@
40
40
  "types": "./dist/render/index.d.ts",
41
41
  "default": "./dist/render/index.js"
42
42
  },
43
+ "./primitives": {
44
+ "types": "./dist/primitives/index.d.ts",
45
+ "default": "./dist/primitives/index.js"
46
+ },
47
+ "./primitives/compositions": {
48
+ "types": "./dist/primitives/compositions/index.d.ts",
49
+ "default": "./dist/primitives/compositions/index.js"
50
+ },
43
51
  "./sdk": {
44
52
  "types": "./dist/sdk/index.d.ts",
45
53
  "default": "./dist/sdk/index.js"
@@ -92,6 +100,29 @@
92
100
  "bin": {
93
101
  "loom": "./dist/cli/main.js"
94
102
  },
103
+ "scripts": {
104
+ "loom": "tsx src/cli/main.ts",
105
+ "typecheck": "tsc --noEmit",
106
+ "test": "vitest run",
107
+ "test:watch": "vitest",
108
+ "test:coverage": "vitest run --coverage",
109
+ "prepare": "git config merge.ours.driver true || true",
110
+ "verify": "pnpm build && pnpm typecheck && pnpm test && pnpm findings:check && pnpm reports:check && pnpm --filter @loom/app verify && pnpm prerender:check",
111
+ "findings:check": "tsx tools/findings/main.ts",
112
+ "build": "tsc -p tsconfig.build.json",
113
+ "clean": "rm -rf dist apps/loom/.next",
114
+ "decisions:index": "tsx tools/decisions/build-index.ts",
115
+ "prerender:check": "tsx tools/prerender/main.ts",
116
+ "queue": "tsx tools/queue/main.ts",
117
+ "package:primitives": "tsx tools/package/main.ts",
118
+ "shoot": "tsx tools/screenshot/shoot.ts",
119
+ "specimen": "tsx tools/specimen/main.ts",
120
+ "prepack": "pnpm build",
121
+ "reports:check": "tsx tools/reports/main.ts",
122
+ "reports:shrink": "tsx tools/reports/shrink.ts",
123
+ "portal:account": "pnpm --filter @loom/app portal:account",
124
+ "signals:key": "pnpm --filter @loom/app signals:key"
125
+ },
95
126
  "dependencies": {
96
127
  "zod": "^3.24.1"
97
128
  },
@@ -118,6 +149,7 @@
118
149
  "devDependencies": {
119
150
  "@anthropic-ai/sdk": "^0.115.0",
120
151
  "@electric-sql/pglite": "^0.5.4",
152
+ "@types/jsdom": "^30.0.0",
121
153
  "@types/node": "^26.1.2",
122
154
  "@types/react": "^19.2.17",
123
155
  "@types/react-dom": "^19.2.3",
@@ -132,6 +164,7 @@
132
164
  "typescript": "^5.7.3",
133
165
  "vitest": "^3.0.5"
134
166
  },
167
+ "packageManager": "pnpm@10.31.0",
135
168
  "types": "./dist/index.d.ts",
136
169
  "files": [
137
170
  "dist",
@@ -139,22 +172,68 @@
139
172
  "!dist/**/*.map"
140
173
  ],
141
174
  "publishConfig": {
142
- "access": "public"
143
- },
144
- "scripts": {
145
- "loom": "tsx src/cli/main.ts",
146
- "typecheck": "tsc --noEmit",
147
- "test": "vitest run",
148
- "test:watch": "vitest",
149
- "test:coverage": "vitest run --coverage",
150
- "verify": "pnpm build && pnpm typecheck && pnpm test && pnpm findings:check && pnpm --filter @loom/app verify && pnpm prerender:check",
151
- "findings:check": "tsx tools/findings/main.ts",
152
- "build": "tsc -p tsconfig.build.json",
153
- "clean": "rm -rf dist apps/loom/.next",
154
- "decisions:index": "tsx tools/decisions/build-index.ts",
155
- "prerender:check": "tsx tools/prerender/main.ts",
156
- "queue": "tsx tools/queue/main.ts",
157
- "shoot": "tsx tools/screenshot/shoot.ts",
158
- "specimen": "tsx tools/specimen/main.ts"
175
+ "access": "public",
176
+ "exports": {
177
+ ".": {
178
+ "types": "./dist/index.d.ts",
179
+ "default": "./dist/index.js"
180
+ },
181
+ "./anthropic": {
182
+ "types": "./dist/interpretation/anthropic.d.ts",
183
+ "default": "./dist/interpretation/anthropic.js"
184
+ },
185
+ "./react": {
186
+ "types": "./dist/render/index.d.ts",
187
+ "default": "./dist/render/index.js"
188
+ },
189
+ "./sdk": {
190
+ "types": "./dist/sdk/index.d.ts",
191
+ "default": "./dist/sdk/index.js"
192
+ },
193
+ "./cli": {
194
+ "types": "./dist/cli/index.d.ts",
195
+ "default": "./dist/cli/index.js"
196
+ },
197
+ "./store": {
198
+ "types": "./dist/store/index.d.ts",
199
+ "default": "./dist/store/index.js"
200
+ },
201
+ "./write": {
202
+ "types": "./dist/write/index.d.ts",
203
+ "default": "./dist/write/index.js"
204
+ },
205
+ "./postgres": {
206
+ "types": "./dist/store/postgres.d.ts",
207
+ "default": "./dist/store/postgres.js"
208
+ },
209
+ "./signals": {
210
+ "types": "./dist/signals/index.d.ts",
211
+ "default": "./dist/signals/index.js"
212
+ },
213
+ "./signals/broadcast": {
214
+ "types": "./dist/signals/broadcast.d.ts",
215
+ "default": "./dist/signals/broadcast.js"
216
+ },
217
+ "./signals/postgres": {
218
+ "types": "./dist/signals/postgres.d.ts",
219
+ "default": "./dist/signals/postgres.js"
220
+ },
221
+ "./telemetry": {
222
+ "types": "./dist/telemetry/index.d.ts",
223
+ "default": "./dist/telemetry/index.js"
224
+ },
225
+ "./telemetry/postgres": {
226
+ "types": "./dist/telemetry/postgres.d.ts",
227
+ "default": "./dist/telemetry/postgres.js"
228
+ },
229
+ "./testing": {
230
+ "types": "./dist/testing/index.d.ts",
231
+ "default": "./dist/testing/index.js"
232
+ },
233
+ "./testing/contracts": {
234
+ "types": "./dist/testing/contracts.d.ts",
235
+ "default": "./dist/testing/contracts.js"
236
+ }
237
+ }
159
238
  }
160
- }
239
+ }