@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
@@ -0,0 +1,199 @@
1
+ import { everyMemberOf } from "../closed-set.js";
2
+ import { kindKeyOf } from "./library.js";
3
+ export const LIBRARY_AGENDA_SIDES = everyMemberOf()(["earlier", "later", "both"]);
4
+ /** One line per side, for a surface saying which window is missing. */
5
+ export const describeLibraryAgendaSide = (side) => {
6
+ switch (side) {
7
+ case "earlier":
8
+ return "the earlier window could not speak about this component";
9
+ case "later":
10
+ return "the later window cannot speak about this component";
11
+ case "both":
12
+ return "neither window could speak about this component";
13
+ }
14
+ };
15
+ export const LIBRARY_AGENDA_SHIFTS = everyMemberOf()([
16
+ "done",
17
+ "arrived",
18
+ "turned",
19
+ "standing",
20
+ "clear",
21
+ "unknown",
22
+ ]);
23
+ /** One line per member, for a surface saying what became of a component's errand. */
24
+ export const describeLibraryAgendaShift = (shift) => {
25
+ switch (shift) {
26
+ case "done":
27
+ return "it asked for work and asks for none now, and both windows could speak about it";
28
+ case "arrived":
29
+ return "it asked for nothing and asks for work now";
30
+ case "turned":
31
+ return "it asks for work in both windows and the errand has changed hands";
32
+ case "standing":
33
+ return "it asks for the same work it asked for before";
34
+ case "clear":
35
+ return "neither window asked for anything about this component";
36
+ case "unknown":
37
+ return "one of the two windows could not speak about it, so nothing is said about progress";
38
+ }
39
+ };
40
+ const EMPTY_SHIFTS = Object.freeze(Object.fromEntries(LIBRARY_AGENDA_SHIFTS.map((shift) => [shift, 0])));
41
+ /**
42
+ * Rows filed under `kindKeyOf`, with the first appearance of a key kept.
43
+ *
44
+ * The first and not the last for the reason the agenda itself keeps the first: a
45
+ * caller's two reads of one library are the same library, and which copy is
46
+ * answered must not depend on the order they were concatenated in.
47
+ */
48
+ const byKind = (rows) => {
49
+ const first = new Map();
50
+ let duplicated = 0;
51
+ for (const row of rows) {
52
+ const key = kindKeyOf(row.kind);
53
+ if (first.has(key))
54
+ duplicated += 1;
55
+ else
56
+ first.set(key, row);
57
+ }
58
+ return { first, duplicated };
59
+ };
60
+ /**
61
+ * The reason there is no before and after, which is the reach reading's own.
62
+ *
63
+ * The later window first, because its reason is the one a deployment still has
64
+ * a remedy for — an earlier window that could not be scaled cannot be scaled
65
+ * now — and both reasons stand whole on the two rows either way.
66
+ *
67
+ * `unpaired` is not decided here: it is a property of the pairing rather than
68
+ * of either row, and the rows this function is asked about are the paired ones.
69
+ */
70
+ const silenceOf = (earlier, later) => {
71
+ const was = earlier.reach.silence;
72
+ const now = later.reach.silence;
73
+ if (was === null && now === null)
74
+ return { reason: null, side: null };
75
+ return {
76
+ reason: now ?? was,
77
+ side: was !== null && now !== null ? "both" : now !== null ? "later" : "earlier",
78
+ };
79
+ };
80
+ /**
81
+ * What became of the errand, off the two words and never off the two ranks.
82
+ *
83
+ * A rank is a position in an order over one window's population and two of them
84
+ * are not a pair; the errand is the same four-member question asked of both
85
+ * windows, which is the only thing here that compares.
86
+ */
87
+ const shiftOf = (was, now, silenced) => {
88
+ if (silenced !== null)
89
+ return "unknown";
90
+ if (was === "none")
91
+ return now === "none" ? "clear" : "arrived";
92
+ if (now === "none")
93
+ return "done";
94
+ return was === now ? "standing" : "turned";
95
+ };
96
+ const asksForWork = (work) => work !== "none";
97
+ /** The name a row is listed under, which is the key's own. */
98
+ const nameOf = (kind) => (kind.by === "type" ? kind.type : (kind.role ?? ""));
99
+ /**
100
+ * Hold a deployment's component fix-list against an earlier reading of it, and
101
+ * publish what became of each errand.
102
+ *
103
+ * ```ts
104
+ * const moved = libraryAgendaChangeOf(
105
+ * libraryAgendaOf(lastWeek.reach, lastWeek.senders),
106
+ * libraryAgendaOf(thisWeek.reach, thisWeek.senders)
107
+ * )
108
+ * ```
109
+ *
110
+ * The two agendas are handed in rather than derived here, on the terms every
111
+ * derived reading in this subsystem takes readings: each is separately useful
112
+ * and separately drawn, and deriving either a second time is how two screens
113
+ * come to disagree about one deployment (0330).
114
+ *
115
+ * @param earlier The agenda of the earlier window, as `libraryAgendaOf`
116
+ * answered it.
117
+ * @param later The agenda of the later window. **Both are required**, on the
118
+ * terms every input of a fix-list is required (0322, 0343): an argument a caller
119
+ * may omit is a comparison that type-checks, runs, and calls a deployment's
120
+ * whole library finished.
121
+ */
122
+ export const libraryAgendaChangeOf = (earlier, later) => {
123
+ const before = byKind(earlier.rows);
124
+ const after = byKind(later.rows);
125
+ /**
126
+ * One row per key, built once and looked up by every list — so the lists and
127
+ * the slices are views of one set of rows rather than separate constructions
128
+ * of it, and a shift cannot differ between them.
129
+ */
130
+ const joined = new Map();
131
+ for (const [key, now] of after.first) {
132
+ const was = before.first.get(key);
133
+ if (was === undefined)
134
+ continue;
135
+ const silence = silenceOf(was, now);
136
+ joined.set(key, {
137
+ kind: now.kind,
138
+ role: now.role,
139
+ shift: shiftOf(was.work, now.work, silence.side),
140
+ was: was.work,
141
+ now: now.work,
142
+ contested: was.spoiled || now.spoiled,
143
+ spoiledWas: was.spoiled,
144
+ spoiledNow: now.spoiled,
145
+ silence: silence.reason,
146
+ silenced: silence.side,
147
+ earlier: was,
148
+ later: now,
149
+ });
150
+ }
151
+ const rows = [...joined.values()].sort((one, other) => nameOf(one.kind).localeCompare(nameOf(other.kind)));
152
+ /**
153
+ * The rows of one agenda's own orders, readers missed first and then readings
154
+ * lost, each component at most once.
155
+ *
156
+ * The dedup is here as well as on the join, and it is the one thing a reader
157
+ * of this file should not simplify away: these lists walk an agenda's own
158
+ * lists rather than the joined map, and an agenda publishes a component in
159
+ * both of them whenever its errand is `both` — so without it every such
160
+ * component is in a published list twice while the counts above it stay right,
161
+ * which is how a list lies about how much there is to do (0158).
162
+ */
163
+ const taken = (of, wanted) => {
164
+ const already = new Set();
165
+ return [...of.library, ...of.collection].flatMap((each) => {
166
+ const key = kindKeyOf(each.kind);
167
+ const row = joined.get(key);
168
+ if (row === undefined || already.has(key) || !wanted(row))
169
+ return [];
170
+ already.add(key);
171
+ return [row];
172
+ });
173
+ };
174
+ const shifts = rows.reduce((counted, row) => ({ ...counted, [row.shift]: counted[row.shift] + 1 }), { ...EMPTY_SHIFTS });
175
+ const headWas = earlier.first?.kind ?? null;
176
+ const headNow = later.first?.kind ?? null;
177
+ return {
178
+ rows,
179
+ done: taken(earlier, (row) => row.shift === "done"),
180
+ arrived: taken(later, (row) => row.shift === "arrived"),
181
+ outstanding: taken(later, (row) => row.shift !== "unknown" && asksForWork(row.was) && asksForWork(row.now)),
182
+ withheld: rows.filter((row) => row.shift === "unknown"),
183
+ contested: rows.filter((row) => row.contested),
184
+ shifts,
185
+ head: {
186
+ earlier: headWas,
187
+ later: headNow,
188
+ same: headWas === null || headNow === null
189
+ ? headWas === headNow
190
+ : kindKeyOf(headWas) === kindKeyOf(headNow),
191
+ },
192
+ unpaired: {
193
+ earlier: before.first.size - joined.size,
194
+ later: after.first.size - joined.size,
195
+ },
196
+ duplicated: before.duplicated + after.duplicated,
197
+ };
198
+ };
199
+ //# sourceMappingURL=library-agenda-change.js.map
@@ -0,0 +1,258 @@
1
+ import type { PrimitiveRole } from "../role.js";
2
+ import { type KindKey } from "./library.js";
3
+ import type { KindReach, LibraryReach } from "./library-reach.js";
4
+ import type { KindSenderReach, LibrarySendersReach } from "./library-senders-reach.js";
5
+ /**
6
+ * **Which component to fix first, and whether the figure that says so is the
7
+ * component's own.**
8
+ *
9
+ * [`agenda.ts`](agenda.ts) answers *what should this deployment do next* about
10
+ * its **pages**. Everything under `library-*.ts` answers the same question one
11
+ * key along, about the **components** a deployment builds those pages out of —
12
+ * and two of those readings are orders an operator would act on directly:
13
+ *
14
+ * - [`library-reach.ts`](library-reach.ts) ranks every kind by the page views
15
+ * that met a page bearing it and never reached it. The head of that order is
16
+ * *the component readers skip*, and the errand is **rewrite the component**.
17
+ * - [`library-senders-reach.ts`](library-senders-reach.ts) ranks every kind by
18
+ * the readings that got inside a copy of it which never reported itself
19
+ * ([0382](../../decisions/0382-a-part-that-reported-nothing-with-a-reader-below-it-is-an-eighth-collection-fault-and-it-reaches-both-ranking-keys.md),
20
+ * [0404](../../decisions/0404-whether-a-silent-component-is-worth-fixing-is-a-share-of-the-readings-that-got-inside-it-and-the-weight-is-the-reach-below.md)).
21
+ * The head of that one is *the component whose silence costs the most*, and
22
+ * the errand is **repair its sender**.
23
+ *
24
+ * They are over the same kinds, off the same readings, and **nothing joins
25
+ * them** — so an operator holds two lists of components and finds the overlap
26
+ * by eye. That is the same gap 0330 found between a deployment's orders of
27
+ * pages, at the key the library is read by.
28
+ *
29
+ * ## The overlap, and the one direction it is dangerous in
30
+ *
31
+ * A silent placement is a part whose standing is `skipped` while something
32
+ * inside it reported reach (0382). `libraryReachOf` gives a `skipped` placement
33
+ * a **verdict**: its page's readers go into the kind's denominator and its own
34
+ * nought goes into the numerator. So **every silent copy of a component pushes
35
+ * that component up the order of readers missed**, by the whole of its page's
36
+ * counted page views.
37
+ *
38
+ * The sentence an operator reads at the head of that order is *readers are
39
+ * skipping your accordion*. The accordion is fine. Its sender is broken, and
40
+ * the figure that sent them to rewrite it was made of the defect. A fix-list
41
+ * whose first row is an artefact is worse than no fix-list, which is the whole
42
+ * of 0330 and is why this file exists.
43
+ *
44
+ * ## One of the two sender states reaches that key and the other does not
45
+ *
46
+ * {@link spoilsTheReach}, published beside the reading it is about. A kind's
47
+ * silent placements are `skipped`, which is a verdict, so they are **in** the
48
+ * order of readers missed. A kind's `indeterminate` placements — something
49
+ * below them reported reach and they reported something that was not a view —
50
+ * have the standing `unknown`, which `libraryReachOf` counts in `unknown` and
51
+ * puts in **no term** of the share (0212, 0282). They are already divided out.
52
+ *
53
+ * So the two states a census brackets a share between are **not
54
+ * interchangeable here**, and asking only *is this kind faulted* would take
55
+ * every kind with one unclaimed placement out of an order its figures are sound
56
+ * in. That is the over-caution 0336 names: it sends an operator to repair a
57
+ * sender while readers walk past a band. A kind whose only defect is unclaimed
58
+ * keeps its place in the order of readers missed, with the defect named beside
59
+ * it, and that is {@link LibraryWork} `both`.
60
+ *
61
+ * ## It publishes no reader figure of its own
62
+ *
63
+ * Every number on a row is the source reading's own, on the source reading's
64
+ * own row (0265). The two orders are in **two units** — readers who missed a
65
+ * component, and readings that got inside a silent copy of one — so there is
66
+ * nothing here to add, and a corrected loss (*the readers missed, less the
67
+ * readings demonstrably inside silent copies*) would be a third figure in
68
+ * neither reading, needing a population argument of its own. It was considered
69
+ * and is not published; the two rows are carried whole and a surface that wants
70
+ * the bracket has both ends of it (0327).
71
+ *
72
+ * **Nor does it say how many kinds were read, or whether anything was
73
+ * collected.** `LibraryReach` and `LibrarySendersReach` each publish their own
74
+ * `pages`, `arrivals` and `scaled`, and the one word about whether this
75
+ * deployment collected anything at all is the page fix-list's
76
+ * `DeploymentAgenda.subject` (0326): a second copy of it here, computed from a
77
+ * different count, is how two screens come to disagree about one deployment.
78
+ *
79
+ * ## A kind is counted once, however many lists name it
80
+ *
81
+ * The permanent mistake available to a join of two orders is a row counted
82
+ * twice (0158). Both inputs publish one row per kind, so a duplicate arrives
83
+ * only from a hand-built reading — it is deduplicated on `kindKeyOf`, the first
84
+ * appearance kept, and counted in {@link LibraryAgenda.duplicated} rather than
85
+ * preferred quietly. The published orders walk their own source lists and take
86
+ * each key at most once, so a kind twice in an input is not a kind twice in an
87
+ * order.
88
+ *
89
+ * ## Types, and deliberately not roles
90
+ *
91
+ * Both inputs publish `byType` and `byRole`. **A role is not a thing anybody
92
+ * can fix.** `loom.accordion` is a component an author can rewrite and a
93
+ * developer can repair; *heading* is what a reader met, and an errand naming it
94
+ * has no hand to fall to. It is the rule `LibrarySendersReach.costliestSender`
95
+ * already keeps, and the role rows stay where they are, unjoined and
96
+ * separately drawn.
97
+ *
98
+ * Pure, linear in the two readings, and reaches no store, clock or DOM.
99
+ */
100
+ /**
101
+ * What the next thing to do about one component is.
102
+ *
103
+ * Four members over *whose hand the work falls to*, which is
104
+ * {@link AgendaWork}'s axis read at the library's key — an author who rewrites
105
+ * a component, or a developer who repairs the sender inside it. The members are
106
+ * not that vocabulary's: a page's `page` is *rewrite the page*, and the thing
107
+ * to rewrite here is one component on every page it stands on. One word at two
108
+ * subjects is two words (0240).
109
+ */
110
+ export type LibraryWork =
111
+ /**
112
+ * Rewrite the component: the order of readers missed ranked it, and nothing
113
+ * about its senders reaches the figure that put it there.
114
+ */
115
+ "library"
116
+ /**
117
+ * Repair its sender: copies of it are silent, and either the order of readers
118
+ * missed did not rank it or its own silence made the figure it was ranked by.
119
+ */
120
+ | "collection"
121
+ /**
122
+ * Both, and in that order.
123
+ *
124
+ * The order of readers missed ranked it, that rank is evidence —
125
+ * {@link spoilsTheReach} is false of its senders — and there is still
126
+ * something wrong with them. The only way in is an unclaimed placement, which
127
+ * is a defect that cannot reach the ranking key because `unknown` is in no
128
+ * term of it. A surface may draw it in either list; it is one component and
129
+ * is counted once.
130
+ */
131
+ | "both"
132
+ /**
133
+ * Neither reading asks for anything: readers reach it wherever it stands and
134
+ * every copy of it that could be checked reported itself.
135
+ *
136
+ * **Or nothing could be said about it**, which is the same row here and a
137
+ * different sentence on it — the silences on {@link LibraryAgendaRow.reach}
138
+ * and {@link LibraryAgendaRow.senders} say which.
139
+ */
140
+ | "none";
141
+ export declare const LIBRARY_WORK: readonly LibraryWork[];
142
+ /** One line per member, for a surface saying what a row is asking for. */
143
+ export declare const describeLibraryWork: (work: LibraryWork) => string;
144
+ /**
145
+ * Whether a kind's senders reach the key the order of readers missed ranked it
146
+ * by.
147
+ *
148
+ * **Silent and not merely faulted**, and the two are one word apart in a
149
+ * condition and a world apart in what an operator is sent to do. A silent
150
+ * placement is `skipped`, which is a verdict `libraryReachOf` puts in both
151
+ * terms of the share; an unclaimed one is `unknown`, which it puts in neither
152
+ * (0212, 0282). So a component with unclaimed copies keeps its rank and a
153
+ * component with silent ones loses it.
154
+ *
155
+ * Asked of the row rather than of a placement's state, because the state is
156
+ * internal to this directory and the count of placements in it is what the
157
+ * reading publishes.
158
+ */
159
+ export declare const spoilsTheReach: (senders: KindSenderReach) => boolean;
160
+ /** One kind of part, as both readings have it, with the errand it adds up to. */
161
+ export type LibraryAgendaRow = {
162
+ readonly kind: KindKey;
163
+ /** What part the type plays (0114), or `null`. Always a type key here, never a role. */
164
+ readonly role: PrimitiveRole | null;
165
+ readonly work: LibraryWork;
166
+ /**
167
+ * The order of readers missed ranked it, and its own silence is what made the
168
+ * figure.
169
+ *
170
+ * True only where there was a rank to spoil: a component nobody misses and
171
+ * whose copies are silent is collection work and is not contested, because no
172
+ * order said anything about it to withdraw.
173
+ */
174
+ readonly spoiled: boolean;
175
+ /** What the readers who met it did, as `libraryReachOf` answered it. */
176
+ readonly reach: KindReach;
177
+ /** What its silence cost those readers, as `librarySendersReachOf` answered it. */
178
+ readonly senders: KindSenderReach;
179
+ };
180
+ /** What a deployment should do about its components, out of the two orders over them. */
181
+ export type LibraryAgenda = {
182
+ /** Every type both readings named, by type, so a surface can key a table on it. */
183
+ readonly rows: readonly LibraryAgendaRow[];
184
+ /**
185
+ * Components to rewrite, most readers missed first, in the order of readers
186
+ * missed's **own** order.
187
+ *
188
+ * A component whose rank its own silence made is not in it — it is in
189
+ * {@link collection} and named in {@link contested}.
190
+ */
191
+ readonly library: readonly LibraryAgendaRow[];
192
+ /**
193
+ * Components whose senders to repair, most readings lost first, in the order
194
+ * of silence's **own** order.
195
+ */
196
+ readonly collection: readonly LibraryAgendaRow[];
197
+ /**
198
+ * The components taken out of the order of readers missed, carrying the whole
199
+ * row that order gave them.
200
+ *
201
+ * A **slice** of {@link collection} and never a list beside it, so the counts
202
+ * in {@link work} add to the rows there are (0158). Never dropped quietly: a
203
+ * component taken out of an order is findable in the place it was taken to,
204
+ * with the figure it was taken for (0301, 0326).
205
+ */
206
+ readonly contested: readonly LibraryAgendaRow[];
207
+ /**
208
+ * The one thing to do first, or `null` where neither reading asks for
209
+ * anything.
210
+ *
211
+ * A contested component first, because while one exists an order of
212
+ * components is not evidence — the same rule, and the same reason, as the
213
+ * page fix-list's.
214
+ */
215
+ readonly first: LibraryAgendaRow | null;
216
+ /** How many components each errand falls to, over {@link rows}. */
217
+ readonly work: Readonly<Record<LibraryWork, number>>;
218
+ /**
219
+ * Types one reading named and the other did not, which is nought for a caller
220
+ * that read one window and the alarm for one that did not.
221
+ *
222
+ * Both readings are over *the pages their caller read*, so a caller holding a
223
+ * reach reading of one window and a silence reading of another gets a join
224
+ * that is silently of the intersection.
225
+ */
226
+ readonly unpaired: {
227
+ readonly reach: number;
228
+ readonly senders: number;
229
+ };
230
+ /** Rows for a type beyond the first, on either side, which were dropped (0158). */
231
+ readonly duplicated: number;
232
+ };
233
+ /**
234
+ * Join the order of readers a library's components miss to the order of what
235
+ * their silence costs, and publish the errands that come out.
236
+ *
237
+ * ```ts
238
+ * const agenda = libraryAgendaOf(
239
+ * libraryReachOf(assembly.readings.pages, window.pageViews),
240
+ * librarySendersReachOf(assembly.readings.pages, window.pageViews)
241
+ * )
242
+ * ```
243
+ *
244
+ * The two readings are handed in rather than derived here, for the reason every
245
+ * derived reading in this subsystem takes readings: each is separately useful
246
+ * and separately drawn, and deriving either a second time is how two screens
247
+ * come to disagree about one deployment (0330).
248
+ *
249
+ * @param reach What the readers who met each kind did, as `libraryReachOf`
250
+ * answered it.
251
+ * @param senders What each kind's silent copies cost those readers, as
252
+ * `librarySendersReachOf` answered it. **Required rather than optional**, on
253
+ * the terms every input of the page fix-list is required (0322, 0343): an
254
+ * argument a caller may omit is a list of components that type-checks, runs,
255
+ * and puts a component at the top of it because its sender is broken.
256
+ */
257
+ export declare const libraryAgendaOf: (reach: LibraryReach, senders: LibrarySendersReach) => LibraryAgenda;
258
+ //# sourceMappingURL=library-agenda.d.ts.map
@@ -0,0 +1,167 @@
1
+ import { everyMemberOf } from "../closed-set.js";
2
+ import { kindKeyOf } from "./library.js";
3
+ export const LIBRARY_WORK = everyMemberOf()([
4
+ "library",
5
+ "collection",
6
+ "both",
7
+ "none",
8
+ ]);
9
+ /** One line per member, for a surface saying what a row is asking for. */
10
+ export const describeLibraryWork = (work) => {
11
+ switch (work) {
12
+ case "library":
13
+ return "rewrite the component: readers meet it and do not reach it, and the figure can be trusted";
14
+ case "collection":
15
+ return "repair its sender: copies of it report nothing, so what it costs readers cannot be read";
16
+ case "both":
17
+ return "rewrite the component, and look at a copy of it that reported something which was not a view";
18
+ case "none":
19
+ return "neither reading asks for anything about this component";
20
+ }
21
+ };
22
+ /**
23
+ * Whether a kind's senders reach the key the order of readers missed ranked it
24
+ * by.
25
+ *
26
+ * **Silent and not merely faulted**, and the two are one word apart in a
27
+ * condition and a world apart in what an operator is sent to do. A silent
28
+ * placement is `skipped`, which is a verdict `libraryReachOf` puts in both
29
+ * terms of the share; an unclaimed one is `unknown`, which it puts in neither
30
+ * (0212, 0282). So a component with unclaimed copies keeps its rank and a
31
+ * component with silent ones loses it.
32
+ *
33
+ * Asked of the row rather than of a placement's state, because the state is
34
+ * internal to this directory and the count of placements in it is what the
35
+ * reading publishes.
36
+ */
37
+ export const spoilsTheReach = (senders) => senders.silent > 0;
38
+ const EMPTY_WORK = Object.freeze(Object.fromEntries(LIBRARY_WORK.map((work) => [work, 0])));
39
+ /**
40
+ * Rows filed under `kindKeyOf`, with the first appearance of a key kept.
41
+ *
42
+ * The first and not the last for the reason the page fix-list keeps the first:
43
+ * a caller's two reads of one library are the same library, and which copy is
44
+ * answered must not depend on the order they were concatenated in.
45
+ */
46
+ const byKind = (rows) => {
47
+ const first = new Map();
48
+ let duplicated = 0;
49
+ for (const row of rows) {
50
+ const key = kindKeyOf(row.kind);
51
+ if (first.has(key))
52
+ duplicated += 1;
53
+ else
54
+ first.set(key, row);
55
+ }
56
+ return { first, duplicated };
57
+ };
58
+ /**
59
+ * What one row asks for, out of what the order ranked and what its senders
60
+ * reach.
61
+ *
62
+ * The same three questions the page fix-list asks, and `evidence` is the one
63
+ * that differs: there it is *at least one of two ranks a deployment may act
64
+ * on*, and here there is one order, so it is that order's rank surviving
65
+ * {@link spoilsTheReach}. **A second order added to this file would have to go
66
+ * back to asking per order** — reading `work` to fill two lists is how a rank a
67
+ * defect manufactured gets into one order on the strength of the other (0336).
68
+ */
69
+ const workOf = (ranked, faulted, evidence) => {
70
+ if (!faulted)
71
+ return ranked ? "library" : "none";
72
+ return evidence ? "both" : "collection";
73
+ };
74
+ const asksToRewrite = (row) => row.work === "library" || row.work === "both";
75
+ const asksForCollection = (row) => row.work === "collection" || row.work === "both";
76
+ /** The name a row is listed under, which is the key's own. */
77
+ const nameOf = (kind) => (kind.by === "type" ? kind.type : (kind.role ?? ""));
78
+ /**
79
+ * Join the order of readers a library's components miss to the order of what
80
+ * their silence costs, and publish the errands that come out.
81
+ *
82
+ * ```ts
83
+ * const agenda = libraryAgendaOf(
84
+ * libraryReachOf(assembly.readings.pages, window.pageViews),
85
+ * librarySendersReachOf(assembly.readings.pages, window.pageViews)
86
+ * )
87
+ * ```
88
+ *
89
+ * The two readings are handed in rather than derived here, for the reason every
90
+ * derived reading in this subsystem takes readings: each is separately useful
91
+ * and separately drawn, and deriving either a second time is how two screens
92
+ * come to disagree about one deployment (0330).
93
+ *
94
+ * @param reach What the readers who met each kind did, as `libraryReachOf`
95
+ * answered it.
96
+ * @param senders What each kind's silent copies cost those readers, as
97
+ * `librarySendersReachOf` answered it. **Required rather than optional**, on
98
+ * the terms every input of the page fix-list is required (0322, 0343): an
99
+ * argument a caller may omit is a list of components that type-checks, runs,
100
+ * and puts a component at the top of it because its sender is broken.
101
+ */
102
+ export const libraryAgendaOf = (reach, senders) => {
103
+ const reaches = byKind(reach.byType);
104
+ const silences = byKind(senders.byType);
105
+ /**
106
+ * One row per key, built once and looked up by both orders — so the two
107
+ * orders and the slice are three views of one set of rows rather than three
108
+ * constructions of it, and `work` cannot differ between them.
109
+ */
110
+ const joined = new Map();
111
+ for (const [key, own] of reaches.first) {
112
+ const sender = silences.first.get(key);
113
+ if (sender === undefined)
114
+ continue;
115
+ const ranked = (own.missed ?? 0) > 0;
116
+ const spoiled = ranked && spoilsTheReach(sender);
117
+ const faulted = sender.silent > 0 || sender.indeterminate > 0;
118
+ joined.set(key, {
119
+ kind: own.kind,
120
+ role: own.role,
121
+ work: workOf(ranked, faulted, ranked && !spoiled),
122
+ spoiled,
123
+ reach: own,
124
+ senders: sender,
125
+ });
126
+ }
127
+ const rows = [...joined.values()].sort((one, other) => nameOf(one.kind).localeCompare(nameOf(other.kind)));
128
+ /**
129
+ * The rows of one source list, in that list's own order, each at most once.
130
+ *
131
+ * The dedup is here as well as on the join, and it is the one thing a reader
132
+ * of this file should not simplify away: the published orders walk the
133
+ * caller's lists rather than the joined map, so a caller's two reads of one
134
+ * library put a component in an order twice while the counts above it stay
135
+ * right — and a component twice in an order is how an order lies about how
136
+ * much there is to fix (0158).
137
+ */
138
+ const taken = (kinds, wanted) => {
139
+ const already = new Set();
140
+ return kinds.flatMap((kind) => {
141
+ const key = kindKeyOf(kind.kind);
142
+ const row = joined.get(key);
143
+ if (row === undefined || already.has(key) || !wanted(row))
144
+ return [];
145
+ already.add(key);
146
+ return [row];
147
+ });
148
+ };
149
+ const library = taken(reach.byType, asksToRewrite);
150
+ const collection = taken(senders.byType, asksForCollection);
151
+ const contested = collection.filter((row) => row.spoiled);
152
+ const work = rows.reduce((counted, row) => ({ ...counted, [row.work]: counted[row.work] + 1 }), { ...EMPTY_WORK });
153
+ return {
154
+ rows,
155
+ library,
156
+ collection,
157
+ contested,
158
+ first: contested[0] ?? library[0] ?? collection[0] ?? null,
159
+ work,
160
+ unpaired: {
161
+ reach: reaches.first.size - joined.size,
162
+ senders: silences.first.size - joined.size,
163
+ },
164
+ duplicated: reaches.duplicated + silences.duplicated,
165
+ };
166
+ };
167
+ //# sourceMappingURL=library-agenda.js.map