@cosmicdrift/kumiko-samples 0.413.0 → 0.414.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 (459) hide show
  1. package/package.json +1 -1
  2. package/packages/bundled-features/package.json +16 -1
  3. package/packages/bundled-features/src/admin-shell/changes.json +6 -0
  4. package/packages/bundled-features/src/admin-shell/feature.ts +8 -7
  5. package/packages/bundled-features/src/agent-tools/agent-doc-lint.ts +5 -1
  6. package/packages/bundled-features/src/agent-tools/agent-manifest.ts +36 -27
  7. package/packages/bundled-features/src/agent-tools/api-docs/collect-events.ts +8 -1
  8. package/packages/bundled-features/src/agent-tools/api-docs/collect.ts +3 -2
  9. package/packages/bundled-features/src/agent-tools/api-docs/generate.ts +6 -0
  10. package/packages/bundled-features/src/agent-tools/api-docs/index.ts +1 -0
  11. package/packages/bundled-features/src/agent-tools/api-docs/problems.ts +38 -1
  12. package/packages/bundled-features/src/agent-tools/api-docs/render-openapi.ts +1 -0
  13. package/packages/bundled-features/src/agent-tools/api-docs/resolve-config.ts +17 -0
  14. package/packages/bundled-features/src/agent-tools/api-docs/scope-slug-collisions.ts +17 -0
  15. package/packages/bundled-features/src/agent-tools/api-docs/translation-gaps.ts +42 -0
  16. package/packages/bundled-features/src/agent-tools/api-docs/webhook-example-problems.ts +30 -0
  17. package/packages/bundled-features/src/agent-tools/changes.json +12 -0
  18. package/packages/bundled-features/src/agent-tools/index.ts +1 -0
  19. package/packages/bundled-features/src/agent-tools/labels.ts +19 -6
  20. package/packages/bundled-features/src/agent-tools/tool-catalog.ts +18 -7
  21. package/packages/bundled-features/src/agent-tools/tool-dispatch.ts +14 -1
  22. package/packages/bundled-features/src/agent-tools/types.ts +4 -0
  23. package/packages/bundled-features/src/audit/event-classification.ts +6 -0
  24. package/packages/bundled-features/src/audit/web/i18n.ts +1 -0
  25. package/packages/bundled-features/src/auth-email-password/changes.json +18 -0
  26. package/packages/bundled-features/src/auth-email-password/errors.ts +0 -13
  27. package/packages/bundled-features/src/auth-email-password/handlers/invite-signup-complete.write.ts +147 -121
  28. package/packages/bundled-features/src/auth-email-password/handlers/login-options.query.ts +1 -1
  29. package/packages/bundled-features/src/auth-email-password/handlers/request-account-unlock.write.ts +1 -1
  30. package/packages/bundled-features/src/auth-email-password/handlers/request-email-verification.write.ts +0 -1
  31. package/packages/bundled-features/src/auth-email-password/handlers/request-password-reset.write.ts +0 -1
  32. package/packages/bundled-features/src/auth-email-password/handlers/self-registration-status.query.ts +1 -1
  33. package/packages/bundled-features/src/auth-email-password/reset-token.ts +0 -2
  34. package/packages/bundled-features/src/auth-email-password/seeding.ts +39 -7
  35. package/packages/bundled-features/src/auth-email-password/unlock-token.ts +0 -2
  36. package/packages/bundled-features/src/auth-email-password/verification-token.ts +0 -2
  37. package/packages/bundled-features/src/auth-email-password/web/auth-form-primitives.tsx +2 -2
  38. package/packages/bundled-features/src/auth-email-password/web/auth-gate.tsx +2 -2
  39. package/packages/bundled-features/src/auth-email-password/web/auth-redirect.ts +5 -0
  40. package/packages/bundled-features/src/auth-email-password/web/forgot-password-screen.tsx +1 -6
  41. package/packages/bundled-features/src/auth-email-password/web/invite-accept-screen.tsx +1 -1
  42. package/packages/bundled-features/src/auth-email-password/web/return-path.ts +2 -1
  43. package/packages/bundled-features/src/auth-email-password/web/session.tsx +10 -12
  44. package/packages/bundled-features/src/auth-email-password/web/signup-screen.tsx +1 -6
  45. package/packages/bundled-features/src/auth-email-password/web/static-account.ts +6 -1
  46. package/packages/bundled-features/src/auth-email-password/web/tenant-switcher.tsx +1 -1
  47. package/packages/bundled-features/src/auth-email-password/web/token-confirm-screen.tsx +4 -5
  48. package/packages/bundled-features/src/auth-email-password/web/user-menu.tsx +1 -1
  49. package/packages/bundled-features/src/auth-mfa/web/mfa-code-or-recovery-field.tsx +17 -1
  50. package/packages/bundled-features/src/auth-mfa/web/mfa-disable-dialog.tsx +1 -1
  51. package/packages/bundled-features/src/auth-mfa/web/mfa-regenerate-recovery-dialog.tsx +1 -1
  52. package/packages/bundled-features/src/auth-mfa/web/mfa-setup-preauth-screen.tsx +1 -1
  53. package/packages/bundled-features/src/auth-mfa/web/mfa-verify-screen.tsx +16 -47
  54. package/packages/bundled-features/src/auth-mfa-user-data/index.ts +5 -6
  55. package/packages/bundled-features/src/billing-foundation/aggregate-id.ts +0 -4
  56. package/packages/bundled-features/src/billing-foundation/changes.json +37 -0
  57. package/packages/bundled-features/src/billing-foundation/checkout-core.ts +8 -1
  58. package/packages/bundled-features/src/billing-foundation/checkout-ledger.ts +59 -0
  59. package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-gate.ts +2 -1
  60. package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-text.ts +49 -2
  61. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-open-cancels.ts +5 -0
  62. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-provider-timeout.ts +23 -0
  63. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-record.ts +12 -7
  64. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-revoke.ts +1 -1
  65. package/packages/bundled-features/src/billing-foundation/events.ts +49 -10
  66. package/packages/bundled-features/src/billing-foundation/feature.ts +15 -1
  67. package/packages/bundled-features/src/billing-foundation/handlers/billing-plans.query.ts +47 -14
  68. package/packages/bundled-features/src/billing-foundation/handlers/create-checkout-session.write.ts +7 -1
  69. package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +124 -10
  70. package/packages/bundled-features/src/billing-foundation/handlers/process-payment-event.write.ts +33 -9
  71. package/packages/bundled-features/src/billing-foundation/handlers/record-checkout-opened.write.ts +25 -0
  72. package/packages/bundled-features/src/billing-foundation/handlers/start-plan-checkout.write.ts +7 -1
  73. package/packages/bundled-features/src/billing-foundation/handlers/switch-plan.write.ts +16 -4
  74. package/packages/bundled-features/src/billing-foundation/i18n.ts +3 -0
  75. package/packages/bundled-features/src/billing-foundation/pending-plan-switch.ts +80 -0
  76. package/packages/bundled-features/src/billing-foundation/scrub-raw-payload-headers.ts +50 -0
  77. package/packages/bundled-features/src/billing-foundation/types.ts +47 -30
  78. package/packages/bundled-features/src/billing-foundation/validate-options.ts +18 -0
  79. package/packages/bundled-features/src/billing-foundation/web/billing-plans-panel.tsx +10 -5
  80. package/packages/bundled-features/src/billing-foundation/web/cancel-contract-dialog.tsx +1 -1
  81. package/packages/bundled-features/src/billing-foundation/web/checkout-consent-dialog.tsx +1 -1
  82. package/packages/bundled-features/src/billing-foundation/web/constants.ts +5 -2
  83. package/packages/bundled-features/src/billing-foundation/web/plan-switch-confirm-dialog.tsx +1 -1
  84. package/packages/bundled-features/src/billing-foundation/webhook-handler.ts +65 -17
  85. package/packages/bundled-features/src/cap-counter/aggregate-id.ts +0 -2
  86. package/packages/bundled-features/src/cap-counter/changes.json +6 -0
  87. package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +19 -4
  88. package/packages/bundled-features/src/cap-overview/changes.json +6 -0
  89. package/packages/bundled-features/src/cap-overview/handlers/tenant-caps-list.query.ts +22 -6
  90. package/packages/bundled-features/src/cap-overview/i18n.ts +1 -0
  91. package/packages/bundled-features/src/cap-overview/index.ts +1 -0
  92. package/packages/bundled-features/src/cap-overview/types.ts +11 -1
  93. package/packages/bundled-features/src/cap-overview/web/cap-cards-panel.tsx +6 -2
  94. package/packages/bundled-features/src/cap-overview/web/cap-usage-bar.tsx +10 -1
  95. package/packages/bundled-features/src/cap-overview/web/usage-math.ts +5 -0
  96. package/packages/bundled-features/src/channel-in-app/changes.json +6 -0
  97. package/packages/bundled-features/src/channel-in-app/handlers/read-state-by-keys.query.ts +2 -2
  98. package/packages/bundled-features/src/channel-whatsapp/aggregate-id.ts +29 -0
  99. package/packages/bundled-features/src/channel-whatsapp/changes.json +8 -0
  100. package/packages/bundled-features/src/channel-whatsapp/constants.ts +46 -0
  101. package/packages/bundled-features/src/channel-whatsapp/events.ts +93 -0
  102. package/packages/bundled-features/src/channel-whatsapp/feature.ts +72 -0
  103. package/packages/bundled-features/src/channel-whatsapp/graph-client.ts +398 -0
  104. package/packages/bundled-features/src/channel-whatsapp/in-memory-meta.ts +300 -0
  105. package/packages/bundled-features/src/channel-whatsapp/inbound-handlers.ts +189 -0
  106. package/packages/bundled-features/src/channel-whatsapp/index.ts +66 -0
  107. package/packages/bundled-features/src/channel-whatsapp/meta-signature.ts +26 -0
  108. package/packages/bundled-features/src/channel-whatsapp/options.ts +149 -0
  109. package/packages/bundled-features/src/channel-whatsapp/pii.ts +109 -0
  110. package/packages/bundled-features/src/channel-whatsapp/webhook-normalize.ts +226 -0
  111. package/packages/bundled-features/src/channel-whatsapp/webhook-routes.ts +185 -0
  112. package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +1 -1
  113. package/packages/bundled-features/src/config/changes.json +12 -0
  114. package/packages/bundled-features/src/config/handlers/set.write.ts +7 -0
  115. package/packages/bundled-features/src/config/handlers/values.query.ts +8 -1
  116. package/packages/bundled-features/src/config/index.ts +1 -0
  117. package/packages/bundled-features/src/config/read-redaction.ts +6 -3
  118. package/packages/bundled-features/src/config/table.ts +1 -0
  119. package/packages/bundled-features/src/config/write-helpers.ts +3 -2
  120. package/packages/bundled-features/src/crypto-shredding/changes.json +18 -0
  121. package/packages/bundled-features/src/crypto-shredding/constants.ts +2 -0
  122. package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +38 -18
  123. package/packages/bundled-features/src/crypto-shredding/index.ts +4 -0
  124. package/packages/bundled-features/src/crypto-shredding/subject-forget-after-delete-hook.ts +49 -0
  125. package/packages/bundled-features/src/custom-fields/aggregate-id.ts +0 -1
  126. package/packages/bundled-features/src/custom-fields/entity.ts +1 -0
  127. package/packages/bundled-features/src/custom-fields/wire-for-entity.ts +0 -1
  128. package/packages/bundled-features/src/data-retention/changes.json +18 -0
  129. package/packages/bundled-features/src/data-retention/erase-notes-of-deleted-row.ts +23 -0
  130. package/packages/bundled-features/src/data-retention/feature.ts +4 -7
  131. package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +38 -18
  132. package/packages/bundled-features/src/data-retention/tenant-destruction-hold.ts +9 -0
  133. package/packages/bundled-features/src/delivery/attempt-log-factory.ts +11 -0
  134. package/packages/bundled-features/src/delivery/attempt-log.ts +3 -3
  135. package/packages/bundled-features/src/delivery/changes.json +6 -0
  136. package/packages/bundled-features/src/delivery/channel-context.ts +6 -3
  137. package/packages/bundled-features/src/delivery/db/queries/preferences.ts +0 -1
  138. package/packages/bundled-features/src/delivery/delivery-service.ts +3 -0
  139. package/packages/bundled-features/src/delivery/feature.ts +4 -13
  140. package/packages/bundled-features/src/delivery/handlers/opted-in-user-ids.query.ts +45 -0
  141. package/packages/bundled-features/src/delivery/handlers/preferences.query.ts +2 -20
  142. package/packages/bundled-features/src/delivery/handlers/resubscribe-user.write.ts +2 -25
  143. package/packages/bundled-features/src/delivery/handlers/unsubscribe-page-chrome.query.ts +2 -0
  144. package/packages/bundled-features/src/delivery/handlers/unsubscribe-user.write.ts +2 -27
  145. package/packages/bundled-features/src/delivery/index.ts +3 -1
  146. package/packages/bundled-features/src/delivery/options.ts +11 -0
  147. package/packages/bundled-features/src/delivery/preference-rows.ts +33 -0
  148. package/packages/bundled-features/src/delivery/set-preference-enabled.ts +40 -0
  149. package/packages/bundled-features/src/delivery/testing.ts +3 -1
  150. package/packages/bundled-features/src/delivery/types.ts +1 -0
  151. package/packages/bundled-features/src/delivery/unsubscribe-page.ts +7 -1
  152. package/packages/bundled-features/src/delivery/upsert-preference.ts +0 -1
  153. package/packages/bundled-features/src/delivery/web/public-names.ts +1 -0
  154. package/packages/bundled-features/src/derivatives-sharp/render.ts +9 -9
  155. package/packages/bundled-features/src/document-ingest-foundation/aggregate-id.ts +0 -1
  156. package/packages/bundled-features/src/document-ingest-foundation/append-missing-extract-event.ts +37 -25
  157. package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +32 -14
  158. package/packages/bundled-features/src/documents/aggregate-id.ts +0 -2
  159. package/packages/bundled-features/src/documents/changes.json +18 -0
  160. package/packages/bundled-features/src/documents/constants.ts +10 -2
  161. package/packages/bundled-features/src/documents/ensure-link.ts +3 -4
  162. package/packages/bundled-features/src/documents/feature.ts +28 -6
  163. package/packages/bundled-features/src/documents/handlers/import.write.ts +2 -2
  164. package/packages/bundled-features/src/documents/queries/expiry-overview.query.ts +2 -1
  165. package/packages/bundled-features/src/documents/queries/for-record.query.ts +3 -4
  166. package/packages/bundled-features/src/documents/queries/list-page.ts +11 -3
  167. package/packages/bundled-features/src/documents/queries/overview.query.ts +2 -2
  168. package/packages/bundled-features/src/documents/screens.ts +8 -3
  169. package/packages/bundled-features/src/documents/tab.ts +1 -1
  170. package/packages/bundled-features/src/feature-toggles/toggle-sync-signal.ts +6 -3
  171. package/packages/bundled-features/src/file-derivatives/handlers/public-variant-by-file-ref.query.ts +1 -1
  172. package/packages/bundled-features/src/file-derivatives/handlers/public-variant.query.ts +1 -1
  173. package/packages/bundled-features/src/file-foundation/probe.ts +9 -3
  174. package/packages/bundled-features/src/file-foundation/read-file-ref-content.ts +24 -11
  175. package/packages/bundled-features/src/file-provider-inmemory/feature.ts +1 -1
  176. package/packages/bundled-features/src/file-provider-s3/changes.json +14 -0
  177. package/packages/bundled-features/src/file-provider-s3/env-feature.ts +1 -1
  178. package/packages/bundled-features/src/file-provider-s3/env-named-feature.ts +1 -1
  179. package/packages/bundled-features/src/file-provider-s3/env-schema.ts +24 -7
  180. package/packages/bundled-features/src/file-provider-s3/feature.ts +1 -1
  181. package/packages/bundled-features/src/file-provider-s3/index.ts +7 -1
  182. package/packages/bundled-features/src/file-provider-s3/lib/env-helper.ts +21 -13
  183. package/packages/bundled-features/src/file-provider-s3/lib/s3-provider.ts +8 -1
  184. package/packages/bundled-features/src/files/changes.json +7 -0
  185. package/packages/bundled-features/src/folders/aggregate-id.ts +0 -1
  186. package/packages/bundled-features/src/folders/web/folder-manager.tsx +6 -6
  187. package/packages/bundled-features/src/folders-user-data/index.ts +12 -14
  188. package/packages/bundled-features/src/helpdesk/changes.json +62 -0
  189. package/packages/bundled-features/src/helpdesk/entity.ts +4 -1
  190. package/packages/bundled-features/src/helpdesk/feature.ts +41 -0
  191. package/packages/bundled-features/src/helpdesk/handlers/access.ts +0 -10
  192. package/packages/bundled-features/src/helpdesk/handlers/attempts.ts +7 -14
  193. package/packages/bundled-features/src/helpdesk/handlers/challenge.query.ts +1 -2
  194. package/packages/bundled-features/src/helpdesk/handlers/reply.write.ts +2 -9
  195. package/packages/bundled-features/src/helpdesk/handlers/report.write.ts +2 -9
  196. package/packages/bundled-features/src/helpdesk/handlers/submit.write.ts +3 -11
  197. package/packages/bundled-features/src/helpdesk/index.ts +1 -0
  198. package/packages/bundled-features/src/helpdesk/legacy-contact-config.ts +61 -0
  199. package/packages/bundled-features/src/helpdesk/legacy-contact-erasure.ts +45 -0
  200. package/packages/bundled-features/src/helpdesk/legacy-contact-retention.ts +65 -0
  201. package/packages/bundled-features/src/helpdesk/legacy-contact-streams.ts +185 -0
  202. package/packages/bundled-features/src/helpdesk/legacy-contact-user-data.ts +84 -0
  203. package/packages/bundled-features/src/helpdesk/lib.ts +47 -34
  204. package/packages/bundled-features/src/helpdesk/user-data-hooks.ts +89 -48
  205. package/packages/bundled-features/src/helpdesk/web/constants.ts +0 -1
  206. package/packages/bundled-features/src/inbound-mail-foundation/account-health.ts +1 -1
  207. package/packages/bundled-features/src/inbound-mail-foundation/account-poll.ts +5 -1
  208. package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +0 -2
  209. package/packages/bundled-features/src/inbound-mail-foundation/changes.json +48 -0
  210. package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +6 -0
  211. package/packages/bundled-features/src/inbound-mail-foundation/content-refetch.ts +15 -1
  212. package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +64 -15
  213. package/packages/bundled-features/src/inbound-mail-foundation/events.ts +15 -16
  214. package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +3 -1
  215. package/packages/bundled-features/src/inbound-mail-foundation/handlers/account-address.ts +16 -2
  216. package/packages/bundled-features/src/inbound-mail-foundation/handlers/attach-message-content.write.ts +10 -3
  217. package/packages/bundled-features/src/inbound-mail-foundation/handlers/connect-account.write.ts +21 -8
  218. package/packages/bundled-features/src/inbound-mail-foundation/handlers/forget-message.write.ts +73 -0
  219. package/packages/bundled-features/src/inbound-mail-foundation/i18n.ts +3 -0
  220. package/packages/bundled-features/src/inbound-mail-foundation/index.ts +1 -0
  221. package/packages/bundled-features/src/inbound-mail-foundation/oauth-access-token.ts +1 -1
  222. package/packages/bundled-features/src/inbound-mail-foundation/outbound-mail.ts +2 -0
  223. package/packages/bundled-features/src/inbound-mail-foundation/personal-address.ts +20 -0
  224. package/packages/bundled-features/src/inbound-mail-foundation/purge-messages.ts +54 -0
  225. package/packages/bundled-features/src/inbound-mail-foundation/quarantine.ts +15 -5
  226. package/packages/bundled-features/src/inbound-mail-foundation/retention-job.ts +1 -5
  227. package/packages/bundled-features/src/inbound-mail-foundation/retention-sweep.ts +21 -34
  228. package/packages/bundled-features/src/inbound-mail-foundation/send-from-account.ts +9 -1
  229. package/packages/bundled-features/src/inbound-mail-foundation/supervisor-ingest.ts +7 -1
  230. package/packages/bundled-features/src/inbound-mail-foundation/sync-account-now.ts +1 -1
  231. package/packages/bundled-features/src/inbound-mail-foundation/tenant-destroy-hook.ts +14 -17
  232. package/packages/bundled-features/src/inbound-mail-foundation/watch-supervisor.ts +1 -1
  233. package/packages/bundled-features/src/inbound-provider-imap/byte-budget.ts +80 -0
  234. package/packages/bundled-features/src/inbound-provider-imap/changes.json +13 -0
  235. package/packages/bundled-features/src/inbound-provider-imap/connect-mailbox.ts +8 -4
  236. package/packages/bundled-features/src/inbound-provider-imap/connect-my-mailbox.ts +23 -6
  237. package/packages/bundled-features/src/inbound-provider-imap/connect-target-rate-limit.ts +46 -0
  238. package/packages/bundled-features/src/inbound-provider-imap/download-batch.ts +47 -10
  239. package/packages/bundled-features/src/inbound-provider-imap/feature.ts +7 -4
  240. package/packages/bundled-features/src/inbound-provider-imap/fetch-content.ts +43 -29
  241. package/packages/bundled-features/src/inbound-provider-imap/i18n.ts +2 -2
  242. package/packages/bundled-features/src/inbound-provider-imap/parse-message.ts +14 -0
  243. package/packages/bundled-features/src/inbound-provider-imap/reconnect-mailbox.ts +5 -4
  244. package/packages/bundled-features/src/inbound-provider-imap/send-mail.ts +39 -7
  245. package/packages/bundled-features/src/inbound-provider-imap/smtp-client.ts +19 -4
  246. package/packages/bundled-features/src/inbound-provider-imap/watch-mailbox.ts +8 -23
  247. package/packages/bundled-features/src/inbound-provider-inmemory/feature.ts +1 -1
  248. package/packages/bundled-features/src/jobs/events.ts +10 -0
  249. package/packages/bundled-features/src/jobs/feature.ts +2 -0
  250. package/packages/bundled-features/src/jobs/handlers/consumer.write.ts +41 -16
  251. package/packages/bundled-features/src/jobs/web/constants.ts +4 -0
  252. package/packages/bundled-features/src/mail-foundation/changes.json +6 -0
  253. package/packages/bundled-features/src/mail-transport-inmemory/feature.ts +1 -1
  254. package/packages/bundled-features/src/mail-transport-smtp/feature.ts +3 -2
  255. package/packages/bundled-features/src/managed-pages/changes.json +12 -0
  256. package/packages/bundled-features/src/managed-pages/handlers/branding.query.ts +1 -1
  257. package/packages/bundled-features/src/managed-pages/handlers/by-slug.query.ts +1 -1
  258. package/packages/bundled-features/src/managed-pages/handlers/by-tenant-published.query.ts +1 -1
  259. package/packages/bundled-features/src/managed-pages/render-page-body.ts +18 -10
  260. package/packages/bundled-features/src/managed-pages/screens/page-screens.ts +18 -38
  261. package/packages/bundled-features/src/managed-pages/table.ts +1 -0
  262. package/packages/bundled-features/src/managed-pages/web/client-plugin.tsx +8 -6
  263. package/packages/bundled-features/src/managed-pages/web/constants.ts +8 -1
  264. package/packages/bundled-features/src/managed-pages/web/i18n.ts +11 -3
  265. package/packages/bundled-features/src/managed-pages/web/markdown-to-document.ts +1 -1
  266. package/packages/bundled-features/src/managed-pages/web/page-edit-draft.ts +108 -0
  267. package/packages/bundled-features/src/managed-pages/web/page-edit-screen.tsx +198 -0
  268. package/packages/bundled-features/src/managed-pages/web/page-settings-rail.tsx +117 -0
  269. package/packages/bundled-features/src/notes-history-user-data/index.ts +8 -14
  270. package/packages/bundled-features/src/personal-access-tokens/boot-rules.ts +5 -0
  271. package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +0 -1
  272. package/packages/bundled-features/src/personal-access-tokens/scope-events-check.ts +31 -5
  273. package/packages/bundled-features/src/presence/changes.json +6 -0
  274. package/packages/bundled-features/src/presence/handlers/list.query.ts +28 -11
  275. package/packages/bundled-features/src/presence/room.ts +21 -7
  276. package/packages/bundled-features/src/presence/store.ts +79 -21
  277. package/packages/bundled-features/src/readiness/changes.json +25 -0
  278. package/packages/bundled-features/src/readiness/handlers/latest-summary.query.ts +11 -6
  279. package/packages/bundled-features/src/readiness/handlers/run-probes.write.ts +35 -5
  280. package/packages/bundled-features/src/readiness/handlers/run-tone.ts +3 -2
  281. package/packages/bundled-features/src/readiness/handlers/status.query.ts +15 -1
  282. package/packages/bundled-features/src/readiness/probe-context.ts +11 -10
  283. package/packages/bundled-features/src/readiness/screens.ts +4 -4
  284. package/packages/bundled-features/src/readiness/visible-results.ts +5 -3
  285. package/packages/bundled-features/src/renderer-foundation/api.ts +6 -13
  286. package/packages/bundled-features/src/renderer-foundation/types.ts +2 -2
  287. package/packages/bundled-features/src/secrets/changes.json +7 -0
  288. package/packages/bundled-features/src/secrets/db/queries/read.ts +18 -4
  289. package/packages/bundled-features/src/secrets/handlers/list.query.ts +8 -2
  290. package/packages/bundled-features/src/secrets/secret-scope.ts +2 -3
  291. package/packages/bundled-features/src/secrets/secrets-context.ts +6 -4
  292. package/packages/bundled-features/src/secrets/write-gate.ts +4 -2
  293. package/packages/bundled-features/src/seo/handlers/seo-config.query.ts +1 -1
  294. package/packages/bundled-features/src/shared/acknowledged-system-db.ts +20 -0
  295. package/packages/bundled-features/src/shared/assert-billing-live.ts +9 -2
  296. package/packages/bundled-features/src/shared/changes.json +6 -0
  297. package/packages/bundled-features/src/shared/index.ts +6 -1
  298. package/packages/bundled-features/src/shared/parent-visibility.ts +25 -1
  299. package/packages/bundled-features/src/shared/password-hashing.ts +0 -1
  300. package/packages/bundled-features/src/shared/price-env-shape.ts +1 -4
  301. package/packages/bundled-features/src/shared/register-user-data-hooks.ts +29 -0
  302. package/packages/bundled-features/src/shared/require-bootstrap-extension.ts +26 -0
  303. package/packages/bundled-features/src/shared/send-best-effort.ts +19 -0
  304. package/packages/bundled-features/src/shared/stream-tenant-backfill.ts +22 -1
  305. package/packages/bundled-features/src/shared/stream-tenant-derived-state.ts +31 -1
  306. package/packages/bundled-features/src/step-dispatcher/changes.json +12 -0
  307. package/packages/bundled-features/src/step-dispatcher/constants.ts +13 -0
  308. package/packages/bundled-features/src/step-dispatcher/deliver-dispatch-request.ts +47 -2
  309. package/packages/bundled-features/src/step-dispatcher/feature.ts +28 -1
  310. package/packages/bundled-features/src/step-dispatcher/mail-runner.ts +0 -1
  311. package/packages/bundled-features/src/step-dispatcher/sweep-abandoned.ts +57 -0
  312. package/packages/bundled-features/src/subscription-mollie/changes.json +7 -0
  313. package/packages/bundled-features/src/subscription-mollie/plugin-methods.ts +5 -3
  314. package/packages/bundled-features/src/subscription-mollie/verify-webhook.ts +5 -5
  315. package/packages/bundled-features/src/subscription-paddle/backfill-checkout-ledger.ts +159 -0
  316. package/packages/bundled-features/src/subscription-paddle/changes.json +13 -0
  317. package/packages/bundled-features/src/subscription-paddle/checkout-config.query.ts +1 -1
  318. package/packages/bundled-features/src/subscription-paddle/checkout-methods.ts +2 -8
  319. package/packages/bundled-features/src/subscription-paddle/constants.ts +1 -2
  320. package/packages/bundled-features/src/subscription-paddle/feature.ts +26 -24
  321. package/packages/bundled-features/src/subscription-paddle/ledger-backfill-marker.ts +70 -0
  322. package/packages/bundled-features/src/subscription-paddle/plan-switch-methods.ts +2 -8
  323. package/packages/bundled-features/src/subscription-paddle/redeliver-legacy-checkout.ts +36 -0
  324. package/packages/bundled-features/src/subscription-paddle/runtime.ts +13 -24
  325. package/packages/bundled-features/src/subscription-paddle/subscription-state.ts +1 -0
  326. package/packages/bundled-features/src/subscription-paddle/webhook-events.ts +68 -21
  327. package/packages/bundled-features/src/subscription-stripe/changes.json +7 -0
  328. package/packages/bundled-features/src/subscription-stripe/feature.ts +5 -0
  329. package/packages/bundled-features/src/subscription-stripe/plugin-methods.ts +6 -6
  330. package/packages/bundled-features/src/subscription-stripe/runtime.ts +8 -7
  331. package/packages/bundled-features/src/subscription-stripe/verify-webhook.ts +24 -6
  332. package/packages/bundled-features/src/tags/aggregate-id.ts +0 -1
  333. package/packages/bundled-features/src/tags/web/tag-chip.tsx +4 -5
  334. package/packages/bundled-features/src/tags/web/tag-manager.tsx +2 -1
  335. package/packages/bundled-features/src/template-resolver/api.ts +6 -13
  336. package/packages/bundled-features/src/template-resolver/changes.json +36 -0
  337. package/packages/bundled-features/src/template-resolver/document-sanitizer.ts +25 -0
  338. package/packages/bundled-features/src/template-resolver/feature.ts +2 -0
  339. package/packages/bundled-features/src/template-resolver/handlers/body-preview.query.ts +41 -0
  340. package/packages/bundled-features/src/template-resolver/handlers/by-slug.query.ts +1 -1
  341. package/packages/bundled-features/src/template-resolver/handlers/by-tenant.query.ts +1 -1
  342. package/packages/bundled-features/src/template-resolver/handlers/collection-shared.ts +5 -11
  343. package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +3 -2
  344. package/packages/bundled-features/src/template-resolver/handlers/send-test.write.ts +37 -8
  345. package/packages/bundled-features/src/template-resolver/linked-resources.ts +2 -5
  346. package/packages/bundled-features/src/template-resolver/seeding.ts +77 -0
  347. package/packages/bundled-features/src/template-resolver/table.ts +1 -0
  348. package/packages/bundled-features/src/template-resolver/template-draft.ts +2 -1
  349. package/packages/bundled-features/src/template-resolver/template-preview.ts +14 -3
  350. package/packages/bundled-features/src/template-resolver/testing.ts +0 -2
  351. package/packages/bundled-features/src/template-resolver/web/client-plugin.tsx +3 -0
  352. package/packages/bundled-features/src/template-resolver/web/collection-entry-create-form.tsx +33 -33
  353. package/packages/bundled-features/src/template-resolver/web/constants.ts +7 -0
  354. package/packages/bundled-features/src/template-resolver/web/content-tree-provider.ts +0 -1
  355. package/packages/bundled-features/src/template-resolver/web/content-workbench.tsx +142 -0
  356. package/packages/bundled-features/src/template-resolver/web/document-insert-model.ts +3 -8
  357. package/packages/bundled-features/src/template-resolver/web/document-link-policy.ts +58 -0
  358. package/packages/bundled-features/src/template-resolver/web/document-schema.ts +11 -57
  359. package/packages/bundled-features/src/template-resolver/web/document-tiptap-bubble.tsx +2 -4
  360. package/packages/bundled-features/src/template-resolver/web/document-tiptap-context.ts +4 -5
  361. package/packages/bundled-features/src/template-resolver/web/document-tiptap-editor.tsx +2 -2
  362. package/packages/bundled-features/src/template-resolver/web/document-tiptap-helpers.ts +6 -3
  363. package/packages/bundled-features/src/template-resolver/web/document-tiptap-toolbar-groups.tsx +2 -3
  364. package/packages/bundled-features/src/template-resolver/web/editor-handle.ts +1 -0
  365. package/packages/bundled-features/src/template-resolver/web/fill-document-variables.ts +24 -0
  366. package/packages/bundled-features/src/template-resolver/web/i18n.ts +14 -0
  367. package/packages/bundled-features/src/template-resolver/web/index.ts +3 -0
  368. package/packages/bundled-features/src/template-resolver/web/preview-targets.ts +25 -0
  369. package/packages/bundled-features/src/template-resolver/web/qualified-names.ts +1 -0
  370. package/packages/bundled-features/src/template-resolver/web/snippet-preview-renderer.tsx +24 -0
  371. package/packages/bundled-features/src/template-resolver/web/string-values.ts +7 -0
  372. package/packages/bundled-features/src/template-resolver/web/text-block-editor.tsx +38 -50
  373. package/packages/bundled-features/src/template-resolver/web/use-collection-entry-create.ts +7 -0
  374. package/packages/bundled-features/src/template-resolver/web/use-content-write.ts +1 -3
  375. package/packages/bundled-features/src/template-resolver/web/use-document-tiptap-model.ts +1 -2
  376. package/packages/bundled-features/src/template-resolver/web/use-text-block-editor.ts +28 -7
  377. package/packages/bundled-features/src/template-resolver/web/web-preview-renderer.tsx +126 -0
  378. package/packages/bundled-features/src/template-resolver-user-data/index.ts +11 -10
  379. package/packages/bundled-features/src/tenant/changes.json +6 -0
  380. package/packages/bundled-features/src/tenant/handlers/create.write.ts +7 -8
  381. package/packages/bundled-features/src/tenant/handlers/list.query.ts +7 -9
  382. package/packages/bundled-features/src/tenant/handlers/member-directory.query.ts +10 -4
  383. package/packages/bundled-features/src/tenant/handlers/toggle-enabled.write.ts +1 -1
  384. package/packages/bundled-features/src/tenant/invited-membership.ts +10 -1
  385. package/packages/bundled-features/src/tenant/seeding.ts +4 -2
  386. package/packages/bundled-features/src/tenant/stream-tenant-backfill.ts +5 -1
  387. package/packages/bundled-features/src/tenant/testing.ts +1 -1
  388. package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +4 -3
  389. package/packages/bundled-features/src/tenant-inactivity/constants.ts +1 -2
  390. package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +1 -2
  391. package/packages/bundled-features/src/tenant-inactivity/state-store.ts +10 -1
  392. package/packages/bundled-features/src/tenant-lifecycle/changes.json +18 -0
  393. package/packages/bundled-features/src/tenant-lifecycle/constants.ts +4 -0
  394. package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +43 -6
  395. package/packages/bundled-features/src/tenant-lifecycle/stages.ts +15 -2
  396. package/packages/bundled-features/src/tier-engine/aggregate-id.ts +0 -1
  397. package/packages/bundled-features/src/tier-engine/changes.json +6 -0
  398. package/packages/bundled-features/src/tier-engine/feature.ts +8 -2
  399. package/packages/bundled-features/src/user/changes.json +6 -0
  400. package/packages/bundled-features/src/user/db/queries/stream-tenant-backfill.ts +2 -1
  401. package/packages/bundled-features/src/user/handlers/me.query.ts +3 -1
  402. package/packages/bundled-features/src/user/index.ts +1 -0
  403. package/packages/bundled-features/src/user/resolve-verified-user-email.ts +17 -0
  404. package/packages/bundled-features/src/user-data-rights/db/queries/export-jobs.ts +0 -1
  405. package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +1 -1
  406. package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +1 -1
  407. package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +1 -1
  408. package/packages/bundled-features/src/user-data-rights/run-export-jobs.ts +0 -2
  409. package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +3 -3
  410. package/packages/bundled-features/src/user-data-rights/schema/download-attempt.ts +3 -2
  411. package/packages/bundled-features/src/user-data-rights/web/confirm-deletion-screen.tsx +1 -1
  412. package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +1 -1
  413. package/packages/bundled-features/src/user-data-rights/web/request-deletion-screen.tsx +1 -1
  414. package/packages/bundled-features/src/user-data-rights-defaults/hooks/api-token.userdata-hook.ts +5 -5
  415. package/packages/bundled-features/src/user-data-rights-defaults/hooks/hard-delete-own-rows-hook.ts +17 -0
  416. package/packages/bundled-features/src/user-data-rights-defaults/hooks/in-app-message.userdata-hook.ts +5 -5
  417. package/packages/bundled-features/src/user-data-rights-defaults/hooks/job-run.userdata-hook.ts +2 -1
  418. package/packages/bundled-features/src/user-data-rights-defaults/hooks/user-session.userdata-hook.ts +5 -5
  419. package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +0 -1
  420. package/packages/bundled-features/src/waitlist/changes.json +6 -0
  421. package/packages/bundled-features/src/waitlist/handlers/submit.write.ts +4 -28
  422. package/packages/bundled-features/src/waitlist/lib.ts +2 -7
  423. package/packages/bundled-features/src/waitlist/user-data-hooks.ts +6 -19
  424. package/packages/bundled-features/src/workflow-runner/aggregate-id.ts +0 -1
  425. package/packages/bundled-features/src/workflow-runner/event-trigger.ts +6 -2
  426. package/packages/bundled-features/src/workflow-runner/feature.ts +1 -5
  427. package/packages/bundled-features/src/workflow-runner/handlers/resume-run.write.ts +5 -4
  428. package/packages/bundled-features/src/workflow-runner/runner.ts +2 -0
  429. package/samples/apps/showcase/src/features/demos/web/pages/dialog.tsx +0 -1
  430. package/samples/apps/showcase/src/features/demos/web/pages/layout.tsx +1 -1
  431. package/samples/apps/showcase/src/features/demos/web/pages/sidebar-panel.tsx +0 -1
  432. package/samples/apps/styleguide/src/features/gallery/web/Gallery.tsx +1 -4
  433. package/samples/apps/ui-walkthrough/src/features/subscription-plans/feature.ts +6 -2
  434. package/samples/apps/use-all-bundled/e2e-billing-gallery/gallery-features.ts +12 -14
  435. package/samples/apps/use-all-bundled/feature-manifest.json +60 -29
  436. package/samples/apps/use-all-bundled/playwright.billing-docs.config.ts +1 -1
  437. package/samples/apps/use-all-bundled/playwright.config.ts +1 -0
  438. package/samples/apps/use-all-bundled/src/app/seed.ts +1 -1
  439. package/samples/apps/use-all-bundled/src/run-config.ts +2 -1
  440. package/samples/recipes/auth-mfa/src/web/confirmation-code-step.tsx +32 -10
  441. package/samples/recipes/chat-channels/README.md +2 -0
  442. package/samples/recipes/currencies-global/src/entities/currency.ts +1 -0
  443. package/samples/recipes/helpdesk/README.md +9 -5
  444. package/samples/recipes/helpdesk/src/feature.ts +6 -3
  445. package/samples/recipes/managed-pages/README.md +5 -1
  446. package/samples/recipes/managed-pages/package.json +3 -2
  447. package/samples/recipes/managed-pages/src/web/branded-preview.tsx +21 -0
  448. package/samples/recipes/managed-pages/tsconfig.json +8 -0
  449. package/samples/recipes/pwa-shell/README.md +52 -0
  450. package/samples/recipes/pwa-shell/bin/server.ts +12 -0
  451. package/samples/recipes/pwa-shell/package.json +13 -0
  452. package/samples/recipes/pwa-shell/src/app.ts +34 -0
  453. package/samples/recipes/rate-limiting/README.md +3 -3
  454. package/samples/recipes/record-detail-layout/README.md +33 -0
  455. package/samples/recipes/record-detail-layout/src/feature.ts +525 -44
  456. package/samples/recipes/record-detail-layout/src/order-board.ts +521 -0
  457. package/packages/bundled-features/src/managed-pages/web/page-body-section.tsx +0 -72
  458. package/packages/bundled-features/src/subscription-paddle/tenant-binding.ts +0 -34
  459. package/packages/bundled-features/src/template-resolver/web/content-field.tsx +0 -61
@@ -5,7 +5,8 @@
5
5
  // requires nothing) so notes-history stays usable without the
6
6
  // user-data-rights stack. Mirrors folders-user-data.
7
7
 
8
- import { defineFeature, EXT_USER_DATA } from "@cosmicdrift/kumiko-framework/engine";
8
+ import { defineFeature } from "@cosmicdrift/kumiko-framework/engine";
9
+ import { registerUserDataHooks } from "../shared/index.ts";
9
10
  import {
10
11
  noteEntryDeleteHook,
11
12
  noteEntryExportHook,
@@ -22,19 +23,12 @@ export function createNotesHistoryUserDataFeature() {
22
23
  r.describe(
23
24
  "GDPR (Art. 20 export / Art. 17 erasure) coverage for the `notes-history` feature's `note-entry` and `note-mention` entities. Mounts the export hook so a user's authored notes are included in the user-data export bundle; the note-entry delete hook crypto-shreds the row-subject key of each note that structurally @-mentions the forgotten user (`note-mention`) or hangs on the user as host entity (regardless of the host entity's retention strategy: the note text is free PII, the host's anonymize/blockDelete protects the row, not the content), keeping the append-only history intact for all other notes. The manual `crypto-shredding` forget-subject command reaches the same notes for user and record subjects through the exported `eraseNoteBodiesReachingSubject`, and the export lists them under `note-mention`. `note-mention`'s own hooks are a no-op — it is a plain FK pointer, not separately exportable content. Kept separate from `notes-history` so notes consumers without the user-data-rights pipeline don't pull a hard dependency — requires `user-data-rights`, optionalRequires `notes-history`.",
24
25
  );
25
- // user-data-rights is the hard dependency (EXT_USER_DATA host). notes-history
26
- // is OPTIONAL: if it's mounted toggleable(default=false), a hard r.requires
27
- // would throw an "effectively disabled" boot warning even though the
28
- // note-entry entity exists and the hooks work fine.
29
- r.requires({ features: ["user-data-rights"] });
30
- r.optionalRequires("notes-history");
31
- r.useExtension(EXT_USER_DATA, "note-entry", {
32
- export: noteEntryExportHook,
33
- delete: noteEntryDeleteHook,
34
- });
35
- r.useExtension(EXT_USER_DATA, "note-mention", {
36
- export: noteMentionExportHook,
37
- delete: noteMentionDeleteHook,
26
+ registerUserDataHooks(r, {
27
+ sourceFeature: "notes-history",
28
+ entities: [
29
+ { entity: "note-entry", export: noteEntryExportHook, delete: noteEntryDeleteHook },
30
+ { entity: "note-mention", export: noteMentionExportHook, delete: noteMentionDeleteHook },
31
+ ],
38
32
  });
39
33
  },
40
34
  { dedupeOptions: {} },
@@ -6,4 +6,9 @@ export const PERSONAL_ACCESS_TOKENS_BOOT_RULES = {
6
6
  summary: "Events listed in PAT scopes have a public webhook contract.",
7
7
  fix: "Declare the event with r.defineWebhookEvent or opt the entity into webhookEvents.",
8
8
  },
9
+ releasedWireNameCollision: {
10
+ id: "personal-access-tokens/released-wire-name-collision",
11
+ summary: "Webhook events released through PAT scopes have unique wire names.",
12
+ fix: "Give one of the colliding events another wireName in r.defineWebhookEvent.",
13
+ },
9
14
  } as const satisfies BootRuleTable;
@@ -34,7 +34,6 @@ export type CreatePatOptions = {
34
34
  ) => Promise<PatMfaVerifyResult>;
35
35
  };
36
36
 
37
- // @wrapper-known error-helper
38
37
  function reauthFailed() {
39
38
  return unprocessable(PatErrors.reauthRequired, "errors.reauthRequired");
40
39
  }
@@ -2,14 +2,28 @@ import {
2
2
  bootRuleError,
3
3
  createWebhookContractResolver,
4
4
  type FeatureDefinition,
5
+ findEntity,
6
+ WEBHOOK_ENTITY_VERBS,
5
7
  } from "@cosmicdrift/kumiko-framework/engine";
6
8
  import { PERSONAL_ACCESS_TOKENS_BOOT_RULES } from "./boot-rules.ts";
7
9
  import { PAT_FEATURE } from "./web/constants.ts";
8
10
  import type { PatScopeConfig } from "./web/scopes.ts";
9
11
 
10
- function entityNameOf(qualifiedName: string): string {
12
+ // Why an event without a contract is not released: only an `<entity>.<verb>` name can be fixed by
13
+ // an entity opt-in, so every other shape gets no entity hint.
14
+ function missingContractHint(
15
+ qualifiedName: string,
16
+ featureMap: ReadonlyMap<string, FeatureDefinition>,
17
+ ): string {
11
18
  const dot = qualifiedName.lastIndexOf(".");
12
- return dot > 0 ? qualifiedName.slice(0, dot) : qualifiedName;
19
+ const verb = qualifiedName.slice(dot + 1);
20
+ if (dot <= 0 || !WEBHOOK_ENTITY_VERBS.some((candidate) => candidate === verb)) {
21
+ return "internal r.defineEvent events are never released.";
22
+ }
23
+ const entityName = qualifiedName.slice(0, dot);
24
+ return findEntity(featureMap, entityName) === undefined
25
+ ? `there is no entity "${entityName}".`
26
+ : `entity "${entityName}" has no such opt-in.`;
13
27
  }
14
28
 
15
29
  export function validateScopeEventContracts(
@@ -17,14 +31,26 @@ export function validateScopeEventContracts(
17
31
  features: readonly FeatureDefinition[],
18
32
  ): void {
19
33
  const resolver = createWebhookContractResolver(features);
34
+ const featureMap = new Map(features.map((feature) => [feature.name, feature]));
35
+ const qnByWireName = new Map<string, string>();
20
36
  for (const [domain, def] of Object.entries(scopes)) {
21
37
  for (const qn of def.events ?? []) {
22
- if (resolver.get(qn)) continue;
38
+ const contract = resolver.get(qn);
39
+ if (contract) {
40
+ const existing = qnByWireName.get(contract.wireName);
41
+ if (existing !== undefined && existing !== contract.qn) {
42
+ throw bootRuleError(PERSONAL_ACCESS_TOKENS_BOOT_RULES.releasedWireNameCollision, {
43
+ message: `[${PAT_FEATURE}] released webhook wire name "${contract.wireName}" is used by both "${existing}" and "${contract.qn}"; receivers tell events apart by wire name, give one of them another wireName.`,
44
+ });
45
+ }
46
+ qnByWireName.set(contract.wireName, contract.qn);
47
+ continue;
48
+ }
23
49
  throw bootRuleError(PERSONAL_ACCESS_TOKENS_BOOT_RULES.scopeEventWithoutContract, {
24
50
  message:
25
51
  `[${PAT_FEATURE}] scope "${domain}" lists event "${qn}" without a public contract. ` +
26
- "Declare it with r.defineWebhookEvent(...), or set webhookEvents: true on the entity to release its <entity>.created/.updated/.deleted events " +
27
- `(entity "${entityNameOf(qn)}" has no such opt-in); internal r.defineEvent events are never released.`,
52
+ "Declare it with r.defineWebhookEvent(...), or set webhookEvents: true on the entity to release its <entity>.created/.updated/.deleted events; " +
53
+ missingContractHint(qn, featureMap),
28
54
  });
29
55
  }
30
56
  }
@@ -1,4 +1,10 @@
1
1
  [
2
+ {
3
+ "version": "0.414.0",
4
+ "type": "fix",
5
+ "title": "Batched presence lookups, safe expiry",
6
+ "detail": "presence list resolves display names and parent visibility in batches (PresenceStore gains listMany) and drops expired fields only if unchanged since read (Lua compare-and-delete)."
7
+ },
2
8
  {
3
9
  "version": "0.411.0",
4
10
  "type": "improvement",
@@ -1,14 +1,16 @@
1
1
  import { type AccessRule, defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import type { PresenceEntry, PresenceListResult } from "@cosmicdrift/kumiko-types/presence-types";
3
+ import { visibleParentRowIds } from "../../shared/index.ts";
3
4
  import { ListSchema } from "../payloads.ts";
4
5
  import {
5
- canUseRoom,
6
+ displayNamesOf,
7
+ entriesWithNames,
6
8
  othersOf,
7
9
  type PresenceRuntime,
8
10
  roomKey,
9
11
  storeFor,
10
- toEntries,
11
12
  } from "../room.ts";
13
+ import type { PresenceRecord } from "../store.ts";
12
14
 
13
15
  export function createListQuery(runtime: PresenceRuntime, access: AccessRule) {
14
16
  return defineQueryHandler({
@@ -23,16 +25,31 @@ export function createListQuery(runtime: PresenceRuntime, access: AccessRule) {
23
25
  if (!runtime.settings.entities.has(entity)) return { byId: {} };
24
26
  const store = storeFor(runtime, ctx);
25
27
  const nowMs = ctx.tz.now().epochMilliseconds;
28
+ const uniqueIds = [...new Set(ids)];
29
+ const rooms = await store.listMany(
30
+ uniqueIds.map((id) => roomKey(ctx, entity, id)),
31
+ nowMs,
32
+ runtime.settings.ttlMs,
33
+ );
34
+ const othersById = new Map<string, readonly PresenceRecord[]>();
35
+ uniqueIds.forEach((id, index) => {
36
+ const others = othersOf(rooms[index] ?? [], event.user.id);
37
+ if (others.length > 0) othersById.set(id, others);
38
+ });
39
+ // Visibility is checked only where someone is present, so an empty row costs no lookup.
40
+ const visibleIds = await visibleParentRowIds(
41
+ ctx.registry,
42
+ entity,
43
+ [...othersById.keys()],
44
+ event.user,
45
+ ctx.db,
46
+ );
47
+ const visibleOthers = [...othersById].filter(([id]) => visibleIds.has(id));
48
+ const names = await displayNamesOf(ctx, [
49
+ ...new Set(visibleOthers.flatMap(([, others]) => others.map((other) => other.userId))),
50
+ ]);
26
51
  const byId: Record<string, readonly PresenceEntry[]> = {};
27
- for (const id of new Set(ids)) {
28
- const others = othersOf(
29
- await store.list(roomKey(ctx, entity, id), nowMs, runtime.settings.ttlMs),
30
- event.user.id,
31
- );
32
- // Visibility is checked only where someone is present, so an empty row costs no lookup.
33
- if (others.length === 0 || !(await canUseRoom(runtime, ctx, entity, id))) continue;
34
- byId[id] = await toEntries(ctx, others);
35
- }
52
+ for (const [id, others] of visibleOthers) byId[id] = entriesWithNames(others, names);
36
53
  return { byId };
37
54
  },
38
55
  });
@@ -44,17 +44,31 @@ export function othersOf(
44
44
  }
45
45
 
46
46
  // Names are looked up per response and never stored, so an erased user leaves no name behind.
47
+ export async function displayNamesOf(
48
+ ctx: HandlerContext,
49
+ userIds: readonly string[],
50
+ ): Promise<ReadonlyMap<string, string>> {
51
+ if (userIds.length === 0 || !ctx.registry.getFeature(USER_FEATURE)) return new Map();
52
+ return resolveUserDisplayNames(ctx.db, userIds);
53
+ }
54
+
47
55
  export async function toEntries(
48
56
  ctx: HandlerContext,
49
57
  records: readonly PresenceRecord[],
50
58
  ): Promise<readonly PresenceEntry[]> {
51
- if (records.length === 0) return [];
52
- const names = ctx.registry.getFeature(USER_FEATURE)
53
- ? await resolveUserDisplayNames(
54
- ctx.db,
55
- records.map((record) => record.userId),
56
- )
57
- : new Map<string, string>();
59
+ return entriesWithNames(
60
+ records,
61
+ await displayNamesOf(
62
+ ctx,
63
+ records.map((record) => record.userId),
64
+ ),
65
+ );
66
+ }
67
+
68
+ export function entriesWithNames(
69
+ records: readonly PresenceRecord[],
70
+ names: ReadonlyMap<string, string>,
71
+ ): readonly PresenceEntry[] {
58
72
  return records.map((record) => ({
59
73
  userId: record.userId,
60
74
  displayName: names.get(record.userId) ?? record.userId,
@@ -1,5 +1,6 @@
1
1
  import type { Logger } from "@cosmicdrift/kumiko-framework/logging";
2
2
  import type { PresenceActivity } from "@cosmicdrift/kumiko-types/presence-types";
3
+ import { isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
3
4
  import type { Redis } from "ioredis";
4
5
  import * as z from "zod";
5
6
 
@@ -30,6 +31,12 @@ export type PresenceStore = {
30
31
  remove(key: string, userId: string): Promise<{ readonly existed: boolean }>;
31
32
  /** Live entries only; expired ones are dropped on read. */
32
33
  list(key: string, nowMs: number, ttlMs: number): Promise<readonly PresenceRecord[]>;
34
+ /** `list` for many rooms in one round trip; result order follows `keys`. */
35
+ listMany(
36
+ keys: readonly string[],
37
+ nowMs: number,
38
+ ttlMs: number,
39
+ ): Promise<readonly (readonly PresenceRecord[])[]>;
33
40
  };
34
41
 
35
42
  export function presenceKey(tenantId: string, entity: string, id: string): string {
@@ -83,8 +90,24 @@ export function createMemoryPresenceStore(): MemoryPresenceStore {
83
90
  }
84
91
  }
85
92
 
93
+ async function list(
94
+ key: string,
95
+ nowMs: number,
96
+ ttlMs: number,
97
+ ): Promise<readonly PresenceRecord[]> {
98
+ const room = rooms.get(key);
99
+ if (!room) return [];
100
+ for (const [userId, record] of room) {
101
+ if (isExpired(record, nowMs, ttlMs)) room.delete(userId);
102
+ }
103
+ if (room.size === 0) rooms.delete(key);
104
+ return [...room.values()];
105
+ }
106
+
86
107
  return {
87
108
  roomCount: () => rooms.size,
109
+ list,
110
+ listMany: (keys, nowMs, ttlMs) => Promise.all(keys.map((key) => list(key, nowMs, ttlMs))),
88
111
  async touch(key, userId, state, nowMs, ttlMs) {
89
112
  sweepExpired(nowMs, ttlMs);
90
113
  const room = rooms.get(key) ?? new Map<string, PresenceRecord>();
@@ -100,15 +123,6 @@ export function createMemoryPresenceStore(): MemoryPresenceStore {
100
123
  if (room?.size === 0) rooms.delete(key);
101
124
  return { existed };
102
125
  },
103
- async list(key, nowMs, ttlMs) {
104
- const room = rooms.get(key);
105
- if (!room) return [];
106
- for (const [userId, record] of room) {
107
- if (isExpired(record, nowMs, ttlMs)) room.delete(userId);
108
- }
109
- if (room.size === 0) rooms.delete(key);
110
- return [...room.values()];
111
- },
112
126
  };
113
127
  }
114
128
 
@@ -169,17 +183,61 @@ export function createRedisPresenceStore(redis: Redis, log: Logger): PresenceSto
169
183
  remove: (key, userId) =>
170
184
  guarded({ existed: false }, async () => ({ existed: (await redis.hdel(key, userId)) > 0 })),
171
185
  list: (key, nowMs, ttlMs) =>
172
- guarded<readonly PresenceRecord[]>([], async () => {
173
- const all = await redis.hgetall(key);
174
- const live: PresenceRecord[] = [];
175
- const expired: string[] = [];
176
- for (const [userId, raw] of Object.entries(all)) {
177
- const record = parseRecord(userId, raw);
178
- if (record && !isExpired(record, nowMs, ttlMs)) live.push(record);
179
- else expired.push(userId);
180
- }
181
- if (expired.length > 0) await redis.hdel(key, ...expired);
182
- return live;
183
- }),
186
+ guarded<readonly PresenceRecord[]>([], async () =>
187
+ liveRecordsOf(key, await redis.hgetall(key), nowMs, ttlMs),
188
+ ),
189
+ listMany: (keys, nowMs, ttlMs) =>
190
+ guarded<readonly (readonly PresenceRecord[])[]>(
191
+ keys.map(() => []),
192
+ async () => {
193
+ if (keys.length === 0) return [];
194
+ const pipeline = redis.pipeline();
195
+ for (const key of keys) pipeline.hgetall(key);
196
+ const replies = (await pipeline.exec()) ?? [];
197
+ return Promise.all(
198
+ keys.map(async (key, index) => {
199
+ const [error, all] = replies[index] ?? [new Error("missing pipeline reply"), null];
200
+ if (error) throw error;
201
+ return liveRecordsOf(key, hashOf(all), nowMs, ttlMs);
202
+ }),
203
+ );
204
+ },
205
+ ),
184
206
  };
207
+
208
+ // Expired fields are removed only while they still hold the value that was read: a touch landing
209
+ // between the read and the removal must survive.
210
+ async function liveRecordsOf(
211
+ key: string,
212
+ all: Readonly<Record<string, string>>,
213
+ nowMs: number,
214
+ ttlMs: number,
215
+ ): Promise<readonly PresenceRecord[]> {
216
+ const live: PresenceRecord[] = [];
217
+ const staleArgs: string[] = [];
218
+ for (const [userId, raw] of Object.entries(all)) {
219
+ const record = parseRecord(userId, raw);
220
+ if (record && !isExpired(record, nowMs, ttlMs)) live.push(record);
221
+ else staleArgs.push(userId, raw);
222
+ }
223
+ if (staleArgs.length > 0) await redis.eval(DROP_FIELDS_IF_UNCHANGED, 1, key, ...staleArgs);
224
+ return live;
225
+ }
226
+ }
227
+
228
+ const DROP_FIELDS_IF_UNCHANGED = `
229
+ for i = 1, #ARGV, 2 do
230
+ if redis.call('HGET', KEYS[1], ARGV[i]) == ARGV[i + 1] then
231
+ redis.call('HDEL', KEYS[1], ARGV[i])
232
+ end
233
+ end
234
+ return 0`;
235
+
236
+ function hashOf(value: unknown): Readonly<Record<string, string>> {
237
+ const hash: Record<string, string> = {};
238
+ if (!isPlainObject(value)) return hash;
239
+ for (const [field, raw] of Object.entries(value)) {
240
+ if (typeof raw === "string") hash[field] = raw;
241
+ }
242
+ return hash;
185
243
  }
@@ -1,4 +1,29 @@
1
1
  [
2
+ {
3
+ "version": "0.414.0",
4
+ "type": "breaking",
5
+ "title": "includePaid from a non-SystemAdmin is rejected",
6
+ "detail": "`readiness:write:run-probes` ignored the role of the caller for `includePaid`, so any TenantAdmin could trigger paid probes. A TenantAdmin that sends `includePaid: true` now gets `access_denied` and no run is started. `readiness:query:latest-summary` reports `hasPaidProbes` as false for everyone but a SystemAdmin, so the paid action on the system check screen is only offered to a SystemAdmin.",
7
+ "migration": "Send `includePaid: true` only from a SystemAdmin session. Apps with their own button for the paid run must show it to a SystemAdmin only; a TenantAdmin request with `includePaid` now fails instead of running the free probes."
8
+ },
9
+ {
10
+ "version": "0.414.0",
11
+ "type": "fix",
12
+ "title": "Readiness probes judge running runs by startedAt",
13
+ "detail": "readiness run-probes judges a running run by startedAt (pending by requestedAt) before abandoning it; an undecryptable starter address skips the mail probe instead of crashing the run; the storage probe no longer deletes after a failed write and a cleanup error cannot replace the original failure; RUN_OUTCOME replaces the literals and the abandoned empty-state variant comes first."
14
+ },
15
+ {
16
+ "version": "0.414.0",
17
+ "type": "fix",
18
+ "title": "Conditional secret readiness",
19
+ "detail": "A secret can declare requiredWhenConfigSet (qualified config key name) and readiness:query:status then counts it as missing only while that key is non-empty; the SMTP password uses it with authUser. Test coverage added for a recently started run that was requested long ago staying active in run-probes."
20
+ },
21
+ {
22
+ "version": "0.414.0",
23
+ "type": "fix",
24
+ "title": "system check runs are rate limited per user",
25
+ "detail": "`readiness:write:run-probes` sends a real test mail and logs in to every mailbox per run; the single-active-run lock only bounded concurrency. It now allows 10 runs per user and hour."
26
+ },
2
27
  {
3
28
  "version": "0.402.0",
4
29
  "type": "fix",
@@ -1,6 +1,7 @@
1
1
  import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import * as z from "zod";
3
3
  import { hasPaidProbes } from "../collect-probes.ts";
4
+ import { RUN_OUTCOME } from "../constants.ts";
4
5
  import { fetchLatestRun, viewRun } from "../run-view.ts";
5
6
  import { countResults } from "../visible-results.ts";
6
7
  import { toneOf } from "./run-tone.ts";
@@ -14,12 +15,16 @@ export const latestSummaryQuery = defineQueryHandler({
14
15
  schema: z.object({}),
15
16
  access: { roles: ["TenantAdmin", "SystemAdmin"] },
16
17
  description:
17
- "Returns the one-line summary of the tenant's latest system-check run (when it started, how many of the checks the caller may see passed, a tone and a ready-made translatable text) and whether the caller's check has paid probes. Zero counts and runId null when no run exists yet.",
18
+ "Returns the one-line summary of the tenant's latest system-check run (when it started, how many of the checks the caller may see passed, a tone and a ready-made translatable text) and whether the caller may start a run with paid probes (SystemAdmins only). Zero counts and runId null when no run exists yet.",
18
19
  handler: async (query, ctx) => {
19
- const paid = hasPaidProbes(ctx.registry, {
20
- includeSystemProbes: query.user.roles.includes("SystemAdmin"),
21
- enabledFeatures: ctx.services.effectiveFeatures?.(query.user.tenantId),
22
- });
20
+ const isSystemAdmin = query.user.roles.includes("SystemAdmin");
21
+ // Only a SystemAdmin may start a paid run, so only they are offered the button.
22
+ const paid =
23
+ isSystemAdmin &&
24
+ hasPaidProbes(ctx.registry, {
25
+ includeSystemProbes: true,
26
+ enabledFeatures: ctx.services.effectiveFeatures?.(query.user.tenantId),
27
+ });
23
28
  const latest = await fetchLatestRun(ctx.db);
24
29
  if (!latest) {
25
30
  return {
@@ -42,7 +47,7 @@ export const latestSummaryQuery = defineQueryHandler({
42
47
  outcome,
43
48
  tone: toneOf(outcome),
44
49
  text:
45
- outcome === "running"
50
+ outcome === RUN_OUTCOME.running
46
51
  ? { i18nKey: SUMMARY_RUNNING_TEXT_KEY }
47
52
  : {
48
53
  i18nKey: SUMMARY_TEXT_KEY,
@@ -5,11 +5,16 @@
5
5
 
6
6
  import { createEventStoreExecutor } from "@cosmicdrift/kumiko-framework/db";
7
7
  import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
8
- import type { WriteFailure } from "@cosmicdrift/kumiko-framework/errors";
9
- import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
8
+ import {
9
+ AccessDeniedError,
10
+ FrameworkReasons,
11
+ InternalError,
12
+ type WriteFailure,
13
+ } from "@cosmicdrift/kumiko-framework/errors";
10
14
  import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
11
15
  import * as z from "zod";
12
16
  import { staleRunAfterMs } from "../collect-probes.ts";
17
+ import { ReadinessWrites } from "../constants.ts";
13
18
  import {
14
19
  ACTIVE_PROBE_RUN_CONSTRAINT,
15
20
  PROBE_RUN_STATUS,
@@ -21,14 +26,26 @@ const crud = createEventStoreExecutor(probeRunsTable, probeRunEntity, {
21
26
  entityName: "probe-run",
22
27
  });
23
28
 
29
+ // The single-active-run lock only bounds concurrency; each run sends a real mail and logs in to every mailbox.
30
+ const RUN_PROBES_RATE_LIMIT = { per: "user+handler", limit: 10, windowSeconds: 3600 } as const;
31
+
24
32
  const ACTIVE_STATUSES = [PROBE_RUN_STATUS.Pending, PROBE_RUN_STATUS.Running];
25
33
 
26
34
  type ActiveRunRow = {
27
35
  readonly id: string;
28
36
  readonly version: number;
37
+ readonly status: string;
29
38
  readonly requestedAt: { readonly epochMilliseconds: number };
39
+ readonly startedAt?: { readonly epochMilliseconds: number } | null;
30
40
  };
31
41
 
42
+ // A queued run may wait on the worker lane for long; only a running one is judged by when it started.
43
+ function lastLifeSignMs(run: ActiveRunRow): number {
44
+ const anchor =
45
+ run.status === PROBE_RUN_STATUS.Running ? (run.startedAt ?? run.requestedAt) : run.requestedAt;
46
+ return anchor.epochMilliseconds;
47
+ }
48
+
32
49
  function isActiveRunConflict(failure: WriteFailure): boolean {
33
50
  return (
34
51
  failure.error.code === "unique_violation" &&
@@ -40,8 +57,9 @@ export const runProbesWrite = defineWriteHandler({
40
57
  name: "run-probes",
41
58
  schema: z.object({ includePaid: z.boolean().default(false) }),
42
59
  access: { roles: ["TenantAdmin", "SystemAdmin"] },
60
+ rateLimit: RUN_PROBES_RATE_LIMIT,
43
61
  description:
44
- "Starts the system check: real calls against mail, storage, search, inbound mailboxes and PDF that show what works in this environment. Returns the run id (isExisting true while a run is still active); the worker fills the run, read the outcome via readiness:query:probe-run:latest-results. Paid probes only run with includePaid true.",
62
+ "Starts the system check: real calls against mail, storage, search, inbound mailboxes and PDF that show what works in this environment. Returns the run id (isExisting true while a run is still active); the worker fills the run, read the outcome via readiness:query:probe-run:latest-results. Paid probes only run with includePaid true, which only a SystemAdmin can set; includePaid true from a TenantAdmin is rejected with access_denied.",
45
63
  handler: async (event, ctx) => {
46
64
  if (!ctx.services.jobRunner) {
47
65
  throw new InternalError({
@@ -49,13 +67,25 @@ export const runProbesWrite = defineWriteHandler({
49
67
  });
50
68
  }
51
69
 
70
+ const isSystemAdmin = event.user.roles.includes("SystemAdmin");
71
+ if (event.payload.includePaid && !isSystemAdmin) {
72
+ throw new AccessDeniedError({
73
+ message: "readiness:run-probes: includePaid is reserved for SystemAdmins",
74
+ details: {
75
+ reason: FrameworkReasons.fieldAccessDenied,
76
+ handler: ReadinessWrites.runProbes,
77
+ field: "includePaid",
78
+ },
79
+ });
80
+ }
81
+
52
82
  const findActive = () =>
53
83
  ctx.db.fetchOne<ActiveRunRow>(probeRunsTable, { status: ACTIVE_STATUSES });
54
84
 
55
85
  const nowMs = ctx.tz.now().epochMilliseconds;
56
86
  const active = await findActive();
57
87
  if (active) {
58
- if (nowMs - active.requestedAt.epochMilliseconds <= staleRunAfterMs(ctx.registry)) {
88
+ if (nowMs - lastLifeSignMs(active) <= staleRunAfterMs(ctx.registry)) {
59
89
  return { isSuccess: true as const, data: { runId: active.id, isExisting: true } };
60
90
  }
61
91
  const abandoned = await crud.update(
@@ -74,7 +104,7 @@ export const runProbesWrite = defineWriteHandler({
74
104
  {
75
105
  status: PROBE_RUN_STATUS.Pending,
76
106
  includePaid: event.payload.includePaid,
77
- includeSystemProbes: event.user.roles.includes("SystemAdmin"),
107
+ includeSystemProbes: isSystemAdmin,
78
108
  triggeredByUserId: event.user.id,
79
109
  requestedAt: ctx.tz.now(),
80
110
  results: { rows: [] },
@@ -1,6 +1,7 @@
1
+ import { RUN_OUTCOME } from "../constants.ts";
1
2
  import type { RunOutcome } from "../visible-results.ts";
2
3
 
3
4
  export function toneOf(outcome: RunOutcome): "default" | "positive" | "negative" {
4
- if (outcome === "running") return "default";
5
- return outcome === "ok" ? "positive" : "negative";
5
+ if (outcome === RUN_OUTCOME.running) return "default";
6
+ return outcome === RUN_OUTCOME.ok ? "positive" : "negative";
6
7
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  buildProviderSelectionGate,
3
3
  collectMissingRequiredConfig,
4
+ requireConfigResolver,
4
5
  } from "@cosmicdrift/kumiko-bundled-features/config";
5
6
  import { requireSecretsContext } from "@cosmicdrift/kumiko-bundled-features/secrets";
6
7
  import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
@@ -41,9 +42,22 @@ export const statusQuery = defineQueryHandler({
41
42
  ReadinessQueries.status,
42
43
  );
43
44
  const missingSecrets: ReadinessMissingSecret[] = [];
45
+ const resolver = requireConfigResolver(ctx, ReadinessQueries.status);
44
46
  for (const [qualifiedName, keyDef] of ctx.registry.getAllSecretKeys()) {
45
- if (keyDef.required !== true) continue;
46
47
  if (!gate(qualifiedName)) continue;
48
+ if (keyDef.required !== true) {
49
+ const conditionKey = keyDef.requiredWhenConfigSet;
50
+ const conditionDef = conditionKey && ctx.registry.getConfigKey(conditionKey);
51
+ if (!conditionKey || !conditionDef) continue;
52
+ const conditionValue = await resolver.get(
53
+ conditionKey,
54
+ conditionDef,
55
+ query.user.tenantId,
56
+ query.user.id,
57
+ ctx.db,
58
+ );
59
+ if (typeof conditionValue !== "string" || conditionValue.trim() === "") continue;
60
+ }
47
61
  if (!(await secrets.has(query.user.tenantId, qualifiedName))) {
48
62
  missingSecrets.push({ key: qualifiedName });
49
63
  }
@@ -19,23 +19,24 @@ async function resolveTriggeredByEmail(
19
19
  userId: string,
20
20
  ): Promise<string | undefined> {
21
21
  if (!ctx.registry.features.has("user")) return undefined;
22
- let found: unknown;
22
+ // Probes that need the address skip themselves; neither lookup nor decrypt may take the whole run down.
23
23
  try {
24
- found = await ctx.dispatch.queryAs(createSystemUser(tenantId), UserQueries.findForAuth, {
25
- id: userId,
26
- });
24
+ const found: unknown = await ctx.dispatch.queryAs(
25
+ createSystemUser(tenantId),
26
+ UserQueries.findForAuth,
27
+ { id: userId },
28
+ );
29
+ const row = triggeringUserRowSchema.safeParse(found);
30
+ if (!row.success || row.data.email === undefined || row.data.isDeleted === true) {
31
+ return undefined;
32
+ }
33
+ return (await decryptStoredUserEmail(row.data.email, "readiness:run-probes")) ?? undefined;
27
34
  } catch (error) {
28
- // Probes that need the address skip themselves; the lookup must not take the whole run down.
29
35
  ctx.obs.log.warn("readiness could not look up the run starter", {
30
36
  error: error instanceof Error ? error.name : "unknown",
31
37
  });
32
38
  return undefined;
33
39
  }
34
- const row = triggeringUserRowSchema.safeParse(found);
35
- if (!row.success || row.data.email === undefined || row.data.isDeleted === true) {
36
- return undefined;
37
- }
38
- return (await decryptStoredUserEmail(row.data.email, "readiness:run-probes")) ?? undefined;
39
40
  }
40
41
 
41
42
  export async function buildProbeContext(
@@ -84,6 +84,10 @@ function resultsSection(
84
84
  title: ScreenTextKeys.latestEmpty,
85
85
  // A finished run without rows had nothing the caller may see, not "no run yet".
86
86
  variants: [
87
+ {
88
+ when: { field: "status", eq: PROBE_RUN_STATUS.Abandoned },
89
+ title: ScreenTextKeys.latestAbandoned,
90
+ },
87
91
  {
88
92
  when: { field: "outcome", eq: RUN_OUTCOME.running },
89
93
  title: ScreenTextKeys.latestRunning,
@@ -92,10 +96,6 @@ function resultsSection(
92
96
  when: { field: "outcome", eq: RUN_OUTCOME.ok },
93
97
  title: ScreenTextKeys.latestNothingToCheck,
94
98
  },
95
- {
96
- when: { field: "status", eq: PROBE_RUN_STATUS.Abandoned },
97
- title: ScreenTextKeys.latestAbandoned,
98
- },
99
99
  ],
100
100
  },
101
101
  ...extra,
@@ -1,6 +1,6 @@
1
1
  import type { SessionUser } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import * as z from "zod";
3
- import type { RUN_OUTCOME } from "./constants.ts";
3
+ import { RUN_OUTCOME } from "./constants.ts";
4
4
  import { PROBE_RUN_STATUS } from "./schema/probe-run.ts";
5
5
 
6
6
  const probeTextSchema = z.object({
@@ -102,6 +102,8 @@ export function isRunActive(status: string): boolean {
102
102
  }
103
103
 
104
104
  export function outcomeOf(status: string, counts: ResultCounts): RunOutcome {
105
- if (isRunActive(status)) return "running";
106
- return status === PROBE_RUN_STATUS.Done && counts.failedCount === 0 ? "ok" : "failed";
105
+ if (isRunActive(status)) return RUN_OUTCOME.running;
106
+ return status === PROBE_RUN_STATUS.Done && counts.failedCount === 0
107
+ ? RUN_OUTCOME.ok
108
+ : RUN_OUTCOME.failed;
107
109
  }