@tokenoftrust/storefront-runner 7.3.2 → 7.5.1

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 (420) hide show
  1. package/agency-kit/tools/lib/catalog-model/files.mjs +11 -4
  2. package/agency-kit/tools/lib/catalog-model/model.mjs +5 -1
  3. package/agency-kit/tools/lib/redirect-shadows.mjs +261 -0
  4. package/apps/storefront/astro.config.mjs +8 -2
  5. package/apps/storefront/package.json +1 -2
  6. package/apps/storefront/src/components/catalog/storefront/ProductCard.astro +20 -6
  7. package/apps/storefront/src/components/catalog/storefront/islands/ImageGallery.tsx +17 -6
  8. package/apps/storefront/src/components/compliance/storefront/islands/CheckoutComplianceGate.tsx +1 -32
  9. package/apps/storefront/src/config/compliance/rulesets.ts +1 -1
  10. package/apps/storefront/src/layouts/Layout.astro +17 -0
  11. package/apps/storefront/src/lib/access/auth/agentRoles.ts +20 -0
  12. package/apps/storefront/src/lib/access/auth/agentSessionGate.ts +32 -8
  13. package/apps/storefront/src/lib/access/auth/brokerAssertion.ts +16 -2
  14. package/apps/storefront/src/lib/access/auth/contactReaderAuthority.ts +39 -0
  15. package/apps/storefront/src/lib/access/auth/loginGate.ts +15 -17
  16. package/apps/storefront/src/lib/access/dashboard/staffAdmission.ts +5 -0
  17. package/apps/storefront/src/lib/access/dashboard/tenantSelection.ts +2 -0
  18. package/apps/storefront/src/lib/access/shared/capability.ts +14 -6
  19. package/apps/storefront/src/lib/access/shared/generated/capabilityCatalog.generated.ts +161 -0
  20. package/apps/storefront/src/lib/activity/activityScope.ts +36 -0
  21. package/apps/storefront/src/lib/activity/recordActivity.ts +23 -1
  22. package/apps/storefront/src/lib/activity/serverFanOut.ts +31 -0
  23. package/apps/storefront/src/lib/activity/store.ts +9 -3
  24. package/apps/storefront/src/lib/checkout/agent/checkoutProtocol.ts +196 -0
  25. package/apps/storefront/src/lib/checkout/agent/checkoutSession.ts +296 -0
  26. package/apps/storefront/src/lib/checkout/agent/webBotAuth.ts +347 -0
  27. package/apps/storefront/src/lib/checkout/commerce/cardCartForm.ts +2 -0
  28. package/apps/storefront/src/lib/checkout/commerce/cartSession.ts +109 -12
  29. package/apps/storefront/src/lib/checkout/commerce/checkoutHandoffRoute.ts +53 -25
  30. package/apps/storefront/src/lib/checkout/commerce/finalCartAuthorization.ts +48 -6
  31. package/apps/storefront/src/lib/checkout/proposal/cartProposal.ts +388 -0
  32. package/apps/storefront/src/lib/checkout/proposal/listMatcher.ts +149 -0
  33. package/apps/storefront/src/lib/checkout/proposal/proposalRoutes.ts +522 -0
  34. package/apps/storefront/src/lib/checkout/proposal/reviewHtml.ts +100 -0
  35. package/apps/storefront/src/lib/compliance/browser/checkoutVerificationFlow.ts +26 -2
  36. package/apps/storefront/src/lib/content/shared/redirects.ts +21 -4
  37. package/apps/storefront/src/lib/publication/shared/edgeCache.ts +5 -2
  38. package/apps/storefront/src/lib/publication/shared/previewAnnotations/renderDecorator.ts +15 -8
  39. package/apps/storefront/src/lib/publication/shared/runtimeEnv.ts +1 -1
  40. package/apps/storefront/src/middleware/controlPlane.ts +15 -1
  41. package/apps/storefront/src/middleware/index.ts +7 -3
  42. package/apps/storefront/src/middleware/renderChain.ts +46 -33
  43. package/apps/storefront/src/pages/api/cart-proposal/confirm.ts +12 -0
  44. package/apps/storefront/src/pages/api/cart-proposal/review.ts +26 -0
  45. package/apps/storefront/src/pages/api/commerce/checkout-sessions/[id].ts +9 -0
  46. package/apps/storefront/src/pages/api/commerce/checkout-sessions.ts +8 -0
  47. package/apps/storefront/src/pages/api/commerce/final-cart-authorization.ts +29 -6
  48. package/apps/storefront/src/pages/api/compliance/preflight.ts +25 -1
  49. package/apps/storefront/src/pages/products/[handle].astro +2 -15
  50. package/apps/storefront/tsconfig.astro.json +11 -0
  51. package/package.json +1 -1
  52. package/packages/public-runtime/src/activity/README.md +12 -0
  53. package/packages/public-runtime/src/activity/catalog.ts +7 -0
  54. package/packages/public-runtime/src/activity/event.ts +19 -0
  55. package/packages/public-runtime/src/activity/redaction.ts +31 -2
  56. package/packages/public-runtime/src/catalog-files.ts +3 -2
  57. package/packages/public-runtime/src/checkout-orders.ts +18 -19
  58. package/packages/public-runtime/src/checkout.ts +70 -0
  59. package/packages/public-runtime/src/compliance/evaluate.ts +60 -1
  60. package/packages/public-runtime/src/compliance/index.ts +1 -1
  61. package/packages/public-runtime/src/compliance/pact-report.ts +184 -3
  62. package/packages/public-runtime/src/compliance/profile.ts +268 -20
  63. package/packages/public-runtime/src/compliance/ruleset.ts +42 -0
  64. package/packages/public-runtime/src/customization-runtime.ts +1 -1
  65. package/packages/public-runtime/src/product.ts +9 -1
  66. package/packages/public-runtime/src/publication-content-redirects.ts +16 -3
  67. package/packages/public-runtime/tests/fixtures/compliance-decisions.golden.json +252 -52
  68. package/pnpm-lock.runner.yaml +0 -15
  69. package/scripts/tenant/materialize-tenant-content.mjs +3 -0
  70. package/scripts/tenant/validate.mjs +128 -0
  71. package/apps/storefront/dev-plugins/dev-publish.mjs +0 -55
  72. package/apps/storefront/drizzle.config.apps.ts +0 -13
  73. package/apps/storefront/integrations/preview-annotations-client-bundle.mjs +0 -80
  74. package/apps/storefront/migrations-apps/0000_fast_millenium_guard.sql +0 -129
  75. package/apps/storefront/migrations-apps/0001_woozy_lyja.sql +0 -22
  76. package/apps/storefront/migrations-apps/0002_good_switch.sql +0 -26
  77. package/apps/storefront/migrations-apps/0003_mute_marauders.sql +0 -12
  78. package/apps/storefront/migrations-apps/0004_deep_morph.sql +0 -36
  79. package/apps/storefront/migrations-apps/0005_common_mystique.sql +0 -23
  80. package/apps/storefront/migrations-apps/0006_broad_microchip.sql +0 -16
  81. package/apps/storefront/migrations-apps/0007_brave_outlaw_kid.sql +0 -15
  82. package/apps/storefront/migrations-apps/0008_blue_dazzler.sql +0 -11
  83. package/apps/storefront/migrations-apps/0009_bored_shinobi_shaw.sql +0 -15
  84. package/apps/storefront/migrations-apps/0010_ws4_verified_provider_measurement.sql +0 -35
  85. package/apps/storefront/migrations-apps/0011_dt_tracking_tenant_databases.sql +0 -23
  86. package/apps/storefront/migrations-apps/0012_test_destinations.sql +0 -29
  87. package/apps/storefront/migrations-apps/0013_publication_space_editorial.sql +0 -64
  88. package/apps/storefront/migrations-apps/0014_retire_candidate_ledger.sql +0 -12
  89. package/apps/storefront/migrations-apps/0015_merchant_calculation_settings.sql +0 -31
  90. package/apps/storefront/migrations-apps/0016_scrappy_commerce_contract.sql +0 -166
  91. package/apps/storefront/migrations-apps/0017_commerce_durable_projection.sql +0 -28
  92. package/apps/storefront/migrations-apps/0018_commerce_provider_cart_identity.sql +0 -13
  93. package/apps/storefront/migrations-apps/0019_commerce_source_authority.sql +0 -23
  94. package/apps/storefront/migrations-apps/0020_contact_messages.sql +0 -18
  95. package/apps/storefront/migrations-apps/0021_contact_vault.sql +0 -166
  96. package/apps/storefront/migrations-apps/0022_contact_vault_fields.sql +0 -342
  97. package/apps/storefront/migrations-apps/0023_principal_grant_contacts.sql +0 -15
  98. package/apps/storefront/migrations-apps/0024_order_contact_erasure_state.sql +0 -22
  99. package/apps/storefront/migrations-apps/0025_shipment_audit_order_lookup.sql +0 -2
  100. package/apps/storefront/migrations-apps/0026_fulfillment_assignment.sql +0 -44
  101. package/apps/storefront/migrations-apps/0027_app_contact_authority.sql +0 -70
  102. package/apps/storefront/migrations-apps/0028_app_jwk_and_candidates.sql +0 -133
  103. package/apps/storefront/migrations-apps/0029_inventory_locations_wms.sql +0 -38
  104. package/apps/storefront/migrations-apps/0030_assignment_split_shipments.sql +0 -149
  105. package/apps/storefront/migrations-apps/meta/0000_snapshot.json +0 -843
  106. package/apps/storefront/migrations-apps/meta/0001_snapshot.json +0 -990
  107. package/apps/storefront/migrations-apps/meta/0002_snapshot.json +0 -1160
  108. package/apps/storefront/migrations-apps/meta/0003_snapshot.json +0 -1235
  109. package/apps/storefront/migrations-apps/meta/0004_snapshot.json +0 -1474
  110. package/apps/storefront/migrations-apps/meta/0005_snapshot.json +0 -1617
  111. package/apps/storefront/migrations-apps/meta/0006_snapshot.json +0 -1716
  112. package/apps/storefront/migrations-apps/meta/0007_snapshot.json +0 -1812
  113. package/apps/storefront/migrations-apps/meta/0008_snapshot.json +0 -1881
  114. package/apps/storefront/migrations-apps/meta/0009_snapshot.json +0 -1979
  115. package/apps/storefront/migrations-apps/meta/_journal.json +0 -76
  116. package/apps/storefront/perf/README.md +0 -64
  117. package/apps/storefront/perf/assert-budgets.ts +0 -159
  118. package/apps/storefront/platform-reconcile-tenants.json +0 -3
  119. package/apps/storefront/playwright.config.ts +0 -23
  120. package/apps/storefront/public/js/dashboard-access-banner.js +0 -53
  121. package/apps/storefront/public/js/dashboard-apps.js +0 -183
  122. package/apps/storefront/public/js/dashboard-contact-capture.js +0 -52
  123. package/apps/storefront/public/js/dashboard-delegate.js +0 -167
  124. package/apps/storefront/public/js/dashboard-team.js +0 -356
  125. package/apps/storefront/public/js/dashboard-vendor-search.js +0 -115
  126. package/apps/storefront/src/components/content/storefront/AsyncStylesheet.astro +0 -26
  127. package/apps/storefront/src/components/integrations/storefront/WidgetFrame.astro +0 -34
  128. package/apps/storefront/src/config/adminTenantLookup.ts +0 -35
  129. package/apps/storefront/src/config/evidenceTenantRoster.ts +0 -25
  130. package/apps/storefront/src/config/staffProvisionProjection.ts +0 -24
  131. package/apps/storefront/src/config/storeName.ts +0 -34
  132. package/apps/storefront/src/lib/access/admin/README.md +0 -122
  133. package/apps/storefront/src/lib/access/admin/adminShell.ts +0 -281
  134. package/apps/storefront/src/lib/access/admin/envelope.ts +0 -9
  135. package/apps/storefront/src/lib/access/admin/viewmodels/settings.ts +0 -64
  136. package/apps/storefront/src/lib/access/auth/adminApiGuard.ts +0 -66
  137. package/apps/storefront/src/lib/access/auth/adminEntry.ts +0 -126
  138. package/apps/storefront/src/lib/access/auth/mcpClientAssertion.ts +0 -217
  139. package/apps/storefront/src/lib/access/auth/operatorSession.ts +0 -120
  140. package/apps/storefront/src/lib/access/dashboard/agentStoreEntry.ts +0 -253
  141. package/apps/storefront/src/lib/access/dashboard/delegateGate.ts +0 -130
  142. package/apps/storefront/src/lib/access/dashboard/staffStoreEntry.ts +0 -153
  143. package/apps/storefront/src/lib/access/dashboard/staffVendorAccess.ts +0 -474
  144. package/apps/storefront/src/lib/access/dashboard/vendorQuery.ts +0 -61
  145. package/apps/storefront/src/lib/access/fixtures/settings.ts +0 -67
  146. package/apps/storefront/src/lib/access/fixtures/tenants.ts +0 -29
  147. package/apps/storefront/src/lib/access/notifications/magicLinkInviteEmail.ts +0 -62
  148. package/apps/storefront/src/lib/access/shared/grantContactLookup.ts +0 -97
  149. package/apps/storefront/src/lib/access/shared/principalGrants.ts +0 -775
  150. package/apps/storefront/src/lib/activity/alerts.ts +0 -426
  151. package/apps/storefront/src/lib/activity/candidateSubmitLease.ts +0 -87
  152. package/apps/storefront/src/lib/activity/changeActorAttribution.ts +0 -181
  153. package/apps/storefront/src/lib/activity/evidence/evidenceReference.ts +0 -32
  154. package/apps/storefront/src/lib/activity/fixtures/evidence.ts +0 -99
  155. package/apps/storefront/src/lib/activity/query.ts +0 -403
  156. package/apps/storefront/src/lib/activity/uiActor.ts +0 -152
  157. package/apps/storefront/src/lib/admin/services/mock/index.ts +0 -12
  158. package/apps/storefront/src/lib/assets/addons/catalog.ts +0 -60
  159. package/apps/storefront/src/lib/assets/addons/storeEntitlements.ts +0 -260
  160. package/apps/storefront/src/lib/assets/durableAssetsRoute.ts +0 -65
  161. package/apps/storefront/src/lib/assets/durableR2.ts +0 -473
  162. package/apps/storefront/src/lib/assets/durableR2Bindings.ts +0 -33
  163. package/apps/storefront/src/lib/automation/admin/viewmodels/aiWorkflows.ts +0 -65
  164. package/apps/storefront/src/lib/automation/ai/approvalMode.ts +0 -20
  165. package/apps/storefront/src/lib/automation/ai/askEnvelope.ts +0 -47
  166. package/apps/storefront/src/lib/automation/ai/audit.ts +0 -12
  167. package/apps/storefront/src/lib/automation/ai/operationalRuns.ts +0 -155
  168. package/apps/storefront/src/lib/automation/ai/recommendation.ts +0 -20
  169. package/apps/storefront/src/lib/automation/fixtures/aiWorkflows.ts +0 -59
  170. package/apps/storefront/src/lib/catalog/admin/catalogSettingsClient.ts +0 -250
  171. package/apps/storefront/src/lib/catalog/admin/catalogSettingsFields.ts +0 -134
  172. package/apps/storefront/src/lib/catalog/admin/catalogSettingsPreview.ts +0 -37
  173. package/apps/storefront/src/lib/catalog/admin/catalogSettingsPricingView.ts +0 -39
  174. package/apps/storefront/src/lib/catalog/admin/catalogSettingsRuleView.ts +0 -44
  175. package/apps/storefront/src/lib/catalog/admin/catalogSettingsSkuView.ts +0 -21
  176. package/apps/storefront/src/lib/catalog/admin/catalogSettingsState.ts +0 -132
  177. package/apps/storefront/src/lib/catalog/admin/productSetupPhoto.ts +0 -23
  178. package/apps/storefront/src/lib/catalog/admin/productsTabClient.ts +0 -193
  179. package/apps/storefront/src/lib/catalog/admin/services/catalogProducts.ts +0 -32
  180. package/apps/storefront/src/lib/catalog/admin/viewmodels/catalogProducts.ts +0 -164
  181. package/apps/storefront/src/lib/catalog/admin/viewmodels/products.ts +0 -267
  182. package/apps/storefront/src/lib/catalog/fixtures/products.ts +0 -105
  183. package/apps/storefront/src/lib/catalog/tot/syncState.ts +0 -111
  184. package/apps/storefront/src/lib/checkout/admin/checkoutStyleInput.ts +0 -172
  185. package/apps/storefront/src/lib/checkout/admin/checkoutStyleTarget.ts +0 -65
  186. package/apps/storefront/src/lib/checkout/browser/checkoutExciseForm.ts +0 -152
  187. package/apps/storefront/src/lib/checkout/browser/checkoutRequirementsForm.ts +0 -72
  188. package/apps/storefront/src/lib/checkout/browser/checkoutStyleForm.ts +0 -110
  189. package/apps/storefront/src/lib/checkout/browser/settingDraftActions.ts +0 -367
  190. package/apps/storefront/src/lib/checkout/commerce/checkoutSettings.ts +0 -246
  191. package/apps/storefront/src/lib/checkout/fixtures/checkoutSettings.ts +0 -77
  192. package/apps/storefront/src/lib/content/blog/markdown.ts +0 -174
  193. package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome-assignments.example.json +0 -6
  194. package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome.example.json +0 -79
  195. package/apps/storefront/src/lib/content/index.ts +0 -27
  196. package/apps/storefront/src/lib/content/the-build/readingTime.ts +0 -35
  197. package/apps/storefront/src/lib/content/the-build/toc.ts +0 -95
  198. package/apps/storefront/src/lib/customers/admin/viewmodels/customers.ts +0 -56
  199. package/apps/storefront/src/lib/customers/contactVault/blindIndex.ts +0 -28
  200. package/apps/storefront/src/lib/customers/contactVault/contactAudit.ts +0 -149
  201. package/apps/storefront/src/lib/customers/contactVault/dataKeys.ts +0 -283
  202. package/apps/storefront/src/lib/customers/contactVault/fieldEnvelope.ts +0 -88
  203. package/apps/storefront/src/lib/customers/contactVault/isolateMetrics.ts +0 -37
  204. package/apps/storefront/src/lib/customers/contactVault/kms.ts +0 -292
  205. package/apps/storefront/src/lib/customers/contactVault/retention.ts +0 -302
  206. package/apps/storefront/src/lib/customers/contactVault/retentionPolicy.ts +0 -290
  207. package/apps/storefront/src/lib/customers/contactVault/zip3.ts +0 -24
  208. package/apps/storefront/src/lib/customers/fixtures/customers.ts +0 -86
  209. package/apps/storefront/src/lib/developer-experience/admin/memoizeByEnvelope.ts +0 -27
  210. package/apps/storefront/src/lib/developer-experience/admin/seed.ts +0 -54
  211. package/apps/storefront/src/lib/developer-experience/dev/activityIngestToken.ts +0 -85
  212. package/apps/storefront/src/lib/developer-experience/dev/activityStore.ts +0 -82
  213. package/apps/storefront/src/lib/developer-experience/dev/agentGrantAttestation.ts +0 -74
  214. package/apps/storefront/src/lib/developer-experience/dev/ai-widget-client.js +0 -308
  215. package/apps/storefront/src/lib/developer-experience/dev/apiBase.ts +0 -17
  216. package/apps/storefront/src/lib/developer-experience/dev/cliSignInCode.ts +0 -124
  217. package/apps/storefront/src/lib/developer-experience/dev/cockpit/ask.ts +0 -49
  218. package/apps/storefront/src/lib/developer-experience/dev/cockpit/clickToSource.ts +0 -71
  219. package/apps/storefront/src/lib/developer-experience/dev/cockpit/copyCommand.ts +0 -227
  220. package/apps/storefront/src/lib/developer-experience/dev/cockpit/files.ts +0 -249
  221. package/apps/storefront/src/lib/developer-experience/dev/cockpit/hostedActivity.ts +0 -500
  222. package/apps/storefront/src/lib/developer-experience/dev/cockpit/infoPopover.ts +0 -12
  223. package/apps/storefront/src/lib/developer-experience/dev/cockpit/mcpCopy.ts +0 -34
  224. package/apps/storefront/src/lib/developer-experience/dev/cockpit/monitor.ts +0 -107
  225. package/apps/storefront/src/lib/developer-experience/dev/cockpit/stepper.ts +0 -116
  226. package/apps/storefront/src/lib/developer-experience/dev/cockpit/themeToggle.ts +0 -23
  227. package/apps/storefront/src/lib/developer-experience/dev/livePreview.ts +0 -77
  228. package/apps/storefront/src/lib/developer-experience/dev/obstacleStore.ts +0 -214
  229. package/apps/storefront/src/lib/developer-experience/dev/previewStatus.ts +0 -87
  230. package/apps/storefront/src/lib/developer-experience/dev/rendezvousBroker.ts +0 -226
  231. package/apps/storefront/src/lib/developer-experience/dev/runtimeStore.ts +0 -291
  232. package/apps/storefront/src/lib/developer-experience/dev/storeStatus.ts +0 -142
  233. package/apps/storefront/src/lib/developer-experience/dev/subjectReissue.ts +0 -67
  234. package/apps/storefront/src/lib/developer-experience/fixtures/regulated-commerce-truth/index.ts +0 -540
  235. package/apps/storefront/src/lib/developer-experience/fixtures/ws3-readonly-clone-preflight/index.ts +0 -495
  236. package/apps/storefront/src/lib/engagement/contact/contactMessages.ts +0 -671
  237. package/apps/storefront/src/lib/engagement/contact/messagesTabClient.ts +0 -175
  238. package/apps/storefront/src/lib/engagement/contact/submission.ts +0 -112
  239. package/apps/storefront/src/lib/engagement/messaging/messagesClient.ts +0 -149
  240. package/apps/storefront/src/lib/engagement/newsletter/digest.ts +0 -117
  241. package/apps/storefront/src/lib/engagement/newsletter/resendClient.ts +0 -79
  242. package/apps/storefront/src/lib/engagement/newsletter/send.ts +0 -265
  243. package/apps/storefront/src/lib/engagement/social/golive.ts +0 -212
  244. package/apps/storefront/src/lib/engagement/social/notify.ts +0 -32
  245. package/apps/storefront/src/lib/engagement/social/tokenStore.ts +0 -171
  246. package/apps/storefront/src/lib/fulfillment/admin/commerceDesk.ts +0 -180
  247. package/apps/storefront/src/lib/fulfillment/admin/commerceDeskRouting.ts +0 -45
  248. package/apps/storefront/src/lib/fulfillment/admin/viewmodels/fulfillment.ts +0 -1071
  249. package/apps/storefront/src/lib/fulfillment/appShipmentEvidence.ts +0 -271
  250. package/apps/storefront/src/lib/fulfillment/carrierEvidence.ts +0 -105
  251. package/apps/storefront/src/lib/fulfillment/commerceProjection.ts +0 -157
  252. package/apps/storefront/src/lib/fulfillment/commerceReadback.ts +0 -60
  253. package/apps/storefront/src/lib/fulfillment/commerceRecovery.ts +0 -84
  254. package/apps/storefront/src/lib/fulfillment/commerceRuntime.ts +0 -41
  255. package/apps/storefront/src/lib/fulfillment/fulfillmentService.ts +0 -2842
  256. package/apps/storefront/src/lib/fulfillment/readiness.ts +0 -217
  257. package/apps/storefront/src/lib/fulfillment/splitShipments.ts +0 -388
  258. package/apps/storefront/src/lib/fulfillment/syntheticPreviewOrders.ts +0 -292
  259. package/apps/storefront/src/lib/integrations/apps/appContactAuthority.ts +0 -27
  260. package/apps/storefront/src/lib/integrations/apps/appContactConsents.ts +0 -118
  261. package/apps/storefront/src/lib/integrations/apps/appInstallEnv.ts +0 -28
  262. package/apps/storefront/src/lib/integrations/apps/gtmMigrationDraft.ts +0 -103
  263. package/apps/storefront/src/lib/integrations/apps/inventoryWrite.ts +0 -906
  264. package/apps/storefront/src/lib/integrations/apps/orders/customerHash.ts +0 -28
  265. package/apps/storefront/src/lib/integrations/apps/orders/idempotency.ts +0 -100
  266. package/apps/storefront/src/lib/integrations/apps/reports/salesVelocityReport.ts +0 -96
  267. package/apps/storefront/src/lib/integrations/apps/routeParams.ts +0 -45
  268. package/apps/storefront/src/lib/integrations/webhooks/cloudflareQueueDispatcher.ts +0 -82
  269. package/apps/storefront/src/lib/integrations/webhooks/commercePayloads.ts +0 -159
  270. package/apps/storefront/src/lib/integrations/webhooks/deliveryEngine.ts +0 -379
  271. package/apps/storefront/src/lib/integrations/webhooks/deliveryMapper.ts +0 -34
  272. package/apps/storefront/src/lib/integrations/webhooks/deliveryStore.ts +0 -903
  273. package/apps/storefront/src/lib/integrations/webhooks/dispatcher.ts +0 -168
  274. package/apps/storefront/src/lib/integrations/webhooks/emit.ts +0 -245
  275. package/apps/storefront/src/lib/integrations/webhooks/events.ts +0 -105
  276. package/apps/storefront/src/lib/integrations/webhooks/getDispatcher.ts +0 -77
  277. package/apps/storefront/src/lib/integrations/webhooks/orderFulfilledClaim.ts +0 -75
  278. package/apps/storefront/src/lib/measurement/admin/analyticsRegionPolicy.ts +0 -151
  279. package/apps/storefront/src/lib/measurement/admin/analyticsRegionsClient.ts +0 -84
  280. package/apps/storefront/src/lib/measurement/admin/consentSettingsClient.ts +0 -113
  281. package/apps/storefront/src/lib/measurement/analytics/index.ts +0 -44
  282. package/apps/storefront/src/lib/measurement/attribution/attributionService.ts +0 -206
  283. package/apps/storefront/src/lib/measurement/attribution/orderConversionD1.ts +0 -150
  284. package/apps/storefront/src/lib/measurement/attribution/verifiedProviderMeasurement.ts +0 -118
  285. package/apps/storefront/src/lib/measurement/tracking/interactionCollector.ts +0 -205
  286. package/apps/storefront/src/lib/measurement/tracking/pruneRollup.ts +0 -260
  287. package/apps/storefront/src/lib/measurement/tracking/tenantReadAccess.ts +0 -138
  288. package/apps/storefront/src/lib/measurement/tracking-writeback/rewriteTrackingIds.ts +0 -175
  289. package/apps/storefront/src/lib/measurement/tracking-writeback/writebackCandidate.ts +0 -110
  290. package/apps/storefront/src/lib/observability/diag/capture.ts +0 -162
  291. package/apps/storefront/src/lib/observability/diag/consoleLine.ts +0 -76
  292. package/apps/storefront/src/lib/observability/diag/debugConsole.ts +0 -118
  293. package/apps/storefront/src/lib/observability/diag/debugMode.ts +0 -163
  294. package/apps/storefront/src/lib/observability/diag/debugWindow.ts +0 -111
  295. package/apps/storefront/src/lib/observability/diag/redact.ts +0 -17
  296. package/apps/storefront/src/lib/observability/diag/reference.ts +0 -148
  297. package/apps/storefront/src/lib/observability/diag/referenceStore.ts +0 -113
  298. package/apps/storefront/src/lib/observability/diag/report.ts +0 -110
  299. package/apps/storefront/src/lib/observability/diag/serverResponseTime.ts +0 -91
  300. package/apps/storefront/src/lib/observability/diag/session.ts +0 -93
  301. package/apps/storefront/src/lib/observability/monitoring/manifest.ts +0 -301
  302. package/apps/storefront/src/lib/observability/performance/lighthouseReport.ts +0 -109
  303. package/apps/storefront/src/lib/observability/performance/rumAlert.ts +0 -179
  304. package/apps/storefront/src/lib/orders/admin/orderActions.ts +0 -556
  305. package/apps/storefront/src/lib/orders/admin/orderClient.ts +0 -248
  306. package/apps/storefront/src/lib/orders/admin/orderSource.ts +0 -410
  307. package/apps/storefront/src/lib/orders/admin/services/orders.ts +0 -922
  308. package/apps/storefront/src/lib/orders/admin/viewmodels/orders.ts +0 -135
  309. package/apps/storefront/src/lib/orders/data/commerceCallerConfig.ts +0 -37
  310. package/apps/storefront/src/lib/orders/data/ledgerContractOrders.ts +0 -148
  311. package/apps/storefront/src/lib/orders/data/orderForwardReceiver.ts +0 -532
  312. package/apps/storefront/src/lib/orders/data/orderMapper.ts +0 -454
  313. package/apps/storefront/src/lib/orders/data/ordersStore.ts +0 -623
  314. package/apps/storefront/src/lib/orders/data/sourceAuthorityContract.ts +0 -380
  315. package/apps/storefront/src/lib/orders/data/sourceAuthorityStore.ts +0 -830
  316. package/apps/storefront/src/lib/orders/fixtures/orders.ts +0 -186
  317. package/apps/storefront/src/lib/orders/providers/foxyOrderClient.ts +0 -207
  318. package/apps/storefront/src/lib/orders/vault/appRecipientRead.ts +0 -222
  319. package/apps/storefront/src/lib/orders/vault/contactIntake.ts +0 -63
  320. package/apps/storefront/src/lib/orders/vault/contactRoutes.ts +0 -110
  321. package/apps/storefront/src/lib/orders/vault/kmsEnv.ts +0 -11
  322. package/apps/storefront/src/lib/orders/vault/orderContact.ts +0 -96
  323. package/apps/storefront/src/lib/orders/vault/orderContactVault.ts +0 -1427
  324. package/apps/storefront/src/lib/orders/vault/vault-test-support.ts +0 -258
  325. package/apps/storefront/src/lib/publication/d1/schema-apps.ts +0 -808
  326. package/apps/storefront/src/lib/publication/notifications/candidateConflictEmail.ts +0 -80
  327. package/apps/storefront/src/lib/publication/servingMode.ts +0 -52
  328. package/apps/storefront/src/lib/publication/shared/previewAnnotations/moduleAsset.ts +0 -65
  329. package/apps/storefront/src/lib/publication/shared/routedApiParam.ts +0 -38
  330. package/apps/storefront/src/lib/reporting/admin/viewmodels/reporting.ts +0 -34
  331. package/apps/storefront/src/lib/reporting/fixtures/reporting.ts +0 -51
  332. package/apps/storefront/src/lib/subscriptions/admin/viewmodels/subscriptions.ts +0 -106
  333. package/apps/storefront/src/lib/subscriptions/fixtures/subscriptions.ts +0 -398
  334. package/apps/storefront/src/pages/api/admin/activity-alerts.ts +0 -58
  335. package/apps/storefront/src/pages/api/admin/commerce-readiness.ts +0 -172
  336. package/apps/storefront/src/pages/api/admin/fulfillment/batches.ts +0 -59
  337. package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id]/address.ts +0 -66
  338. package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id].ts +0 -118
  339. package/apps/storefront/src/pages/api/admin/fulfillment/orders/contact-search.ts +0 -26
  340. package/apps/storefront/src/pages/api/admin/fulfillment/orders/contacts.ts +0 -22
  341. package/apps/storefront/src/pages/api/admin/interaction-insights.ts +0 -101
  342. package/apps/storefront/src/pages/api/admin/orders/[id].ts +0 -63
  343. package/apps/storefront/src/pages/api/admin/orders.ts +0 -65
  344. package/apps/storefront/src/pages/api/contact.ts +0 -144
  345. package/apps/storefront/src/scheduled/contactVaultSweep.ts +0 -113
  346. package/apps/storefront/src/styles/admin.css +0 -1161
  347. package/apps/storefront/test/pipeline/fake-preview-services.ts +0 -288
  348. package/apps/storefront/test/pipeline/harness.ts +0 -209
  349. package/apps/storefront/test/pipeline/intake-worker.mjs +0 -14
  350. package/apps/storefront/test/pipeline/matrix-faults.ts +0 -366
  351. package/apps/storefront/test/pipeline/pipeline-host.ts +0 -418
  352. package/apps/storefront/test/pipeline/pool-config.cjs +0 -85
  353. package/apps/storefront/test/pipeline/publish-kinds.ts +0 -279
  354. package/apps/storefront/test/pipeline/synthetic-job.ts +0 -303
  355. package/apps/storefront/test/pipeline-faults/matrix-lib.ts +0 -696
  356. package/apps/storefront/vitest.config.cts +0 -44
  357. package/apps/storefront/vitest.faults.config.cts +0 -13
  358. package/apps/storefront/vitest.workers.config.cts +0 -7
  359. package/packages/feedback/fixtures/v1/expected-findings.json +0 -16
  360. package/packages/feedback/fixtures/v1/feedback-action/invalid/carries-transport-credential.json +0 -14
  361. package/packages/feedback/fixtures/v1/feedback-action/invalid/control-char-in-description.json +0 -13
  362. package/packages/feedback/fixtures/v1/feedback-action/invalid/legacy-schema-version.json +0 -13
  363. package/packages/feedback/fixtures/v1/feedback-action/invalid/page-path-with-query.json +0 -14
  364. package/packages/feedback/fixtures/v1/feedback-action/invalid/title-too-short.json +0 -13
  365. package/packages/feedback/fixtures/v1/feedback-action/valid/element-problem.json +0 -33
  366. package/packages/feedback/fixtures/v1/feedback-action/valid/page-comment.json +0 -20
  367. package/packages/feedback/fixtures/v1/feedback-action/valid/region-improvement.json +0 -24
  368. package/packages/feedback/fixtures/v1/feedback-action/valid/text-selection-feature.json +0 -30
  369. package/packages/feedback/fixtures/v1/submission-receipt/invalid/accepted-at-not-utc.json +0 -9
  370. package/packages/feedback/fixtures/v1/submission-receipt/invalid/bad-feedback-id.json +0 -9
  371. package/packages/feedback/fixtures/v1/submission-receipt/invalid/legacy-contract-version.json +0 -9
  372. package/packages/feedback/fixtures/v1/submission-receipt/invalid/missing-replayed.json +0 -8
  373. package/packages/feedback/fixtures/v1/submission-receipt/valid/accepted.json +0 -9
  374. package/packages/feedback/fixtures/v1/submission-receipt/valid/fractional-seconds.json +0 -9
  375. package/packages/feedback/fixtures/v1/submission-receipt/valid/replayed.json +0 -9
  376. package/packages/feedback/fixtures/v1/target-evidence/invalid/page-kind-claims-structure.json +0 -6
  377. package/packages/feedback/fixtures/v1/target-evidence/invalid/path-too-deep.json +0 -17
  378. package/packages/feedback/fixtures/v1/target-evidence/invalid/relative-region-out-of-range.json +0 -11
  379. package/packages/feedback/fixtures/v1/target-evidence/invalid/selector-uses-class.json +0 -7
  380. package/packages/feedback/fixtures/v1/target-evidence/invalid/source-precision-without-anchor.json +0 -6
  381. package/packages/feedback/fixtures/v1/target-evidence/valid/element-structure.json +0 -21
  382. package/packages/feedback/fixtures/v1/target-evidence/valid/host-iframe.json +0 -14
  383. package/packages/feedback/fixtures/v1/target-evidence/valid/source-anchor.json +0 -12
  384. package/packages/feedback/fixtures/v1/target-evidence/valid/text-selection.json +0 -26
  385. package/packages/feedback/package.json +0 -35
  386. package/packages/feedback/scripts/build-player.mjs +0 -28
  387. package/packages/feedback/src/index.ts +0 -1
  388. package/packages/feedback/src/primitives/composer.ts +0 -639
  389. package/packages/feedback/src/primitives/dialog.ts +0 -263
  390. package/packages/feedback/src/primitives/hostAdapter.ts +0 -116
  391. package/packages/feedback/src/primitives/index.ts +0 -10
  392. package/packages/feedback/src/primitives/launcher.ts +0 -200
  393. package/packages/feedback/src/primitives/picker.ts +0 -663
  394. package/packages/feedback/src/primitives/redaction.ts +0 -204
  395. package/packages/feedback/src/primitives/selection.ts +0 -49
  396. package/packages/feedback/src/primitives/shiftAccelerator.ts +0 -160
  397. package/packages/feedback/src/primitives/styles.ts +0 -77
  398. package/packages/feedback/src/primitives/surface.ts +0 -124
  399. package/packages/feedback/src/primitives/target.ts +0 -293
  400. package/packages/feedback/src/tour/canonical.ts +0 -27
  401. package/packages/feedback/src/tour/index.ts +0 -3
  402. package/packages/feedback/src/tour/player/browser.ts +0 -5
  403. package/packages/feedback/src/tour/player/host.ts +0 -12
  404. package/packages/feedback/src/tour/player/index.ts +0 -205
  405. package/packages/feedback/src/tour/player/manifest.ts +0 -76
  406. package/packages/feedback/src/tour/player/player.css +0 -130
  407. package/packages/feedback/src/tour/player/resolver.ts +0 -12
  408. package/packages/feedback/src/tour/player/surface.ts +0 -295
  409. package/packages/feedback/src/tour/player/types.ts +0 -8
  410. package/packages/feedback/src/tour/resolve/core.ts +0 -267
  411. package/packages/feedback/src/tour/resolve/dom.ts +0 -115
  412. package/packages/feedback/src/tour/resolve/index.ts +0 -29
  413. package/packages/feedback/src/tour/sanitize.ts +0 -76
  414. package/packages/feedback/src/tour/schema.ts +0 -362
  415. package/packages/feedback/src/v1/guards.ts +0 -335
  416. package/packages/feedback/src/v1/index.ts +0 -3
  417. package/packages/feedback/src/v1/protectedSurfaces.ts +0 -32
  418. package/packages/feedback/src/v1/types.ts +0 -177
  419. package/packages/feedback/tsconfig.json +0 -9
  420. package/packages/feedback/vitest.config.cts +0 -21
@@ -1,279 +0,0 @@
1
- /**
2
- * The REAL publish / rollback / hotfix job kinds for the TenantPipeline fault harness, over the
3
- * stand-in world (`src/lib/publication/pipeline/publish/publish-test-support.ts`: GitHub Actions, CloudFront,
4
- * the Cloudflare edge, the MCP promotion ledger). Test-only.
5
- *
6
- * Every byte of state — the job's KV (release ledger, version store, `live` pointer) and the
7
- * stand-ins' — lives in the Durable Object's own SQLite, so it survives the evictions the harness
8
- * causes. Timing is shortened so the CloudFront callback window, GitHub run lookups and proof
9
- * retries play out in seconds.
10
- *
11
- * Faults are armed per object (each test uses its own tenant) at a named step — or `on-terminal`, the
12
- * kind's compensation after a terminal transition — `before` its work or `after` it (once the work
13
- * is done, before the engine records the step): `evict` aborts the
14
- * object, `throw` fails the attempt, `preview-write` moves the shared preview channel to `versionId`
15
- * through the object's pointer authority (what a preview job does) and lets the step go on. A fault's
16
- * remaining count is persisted (and flushed) before it acts, so it survives the eviction it causes.
17
- *
18
- * The job's version store writes the pointer through the object's own pointer authority (its
19
- * SQLite record, projected to the harness KV) — the production writer.
20
- */
21
- import type { DurableObjectState } from "cloudflare:workers";
22
- import { JobKindRegistry, type JobKindDefinition, type StepDefinition } from "../../src/lib/publication/pipeline/job-runner";
23
- import { registerPublishJobKinds, type PublishKindTuning, type PublishTiming } from "../../src/lib/publication/pipeline/publish/publish-job";
24
- import {
25
- PublishWorld,
26
- movePreview,
27
- standInPublishEnvironment,
28
- testVersionStore,
29
- type CiDispatch,
30
- type TestKv,
31
- type WorldDesignation,
32
- } from "../../src/lib/publication/pipeline/publish/publish-test-support";
33
- import type { Landed } from "./matrix-faults";
34
-
35
- type SiteVersionStore = ReturnType<typeof testVersionStore>;
36
- type PointerWriter = NonNullable<Parameters<typeof testVersionStore>[1]>;
37
- type PointerRecord = Awaited<ReturnType<PointerWriter["read"]>>;
38
-
39
- /**
40
- * Production's ratios, in seconds: a CI window (45 min) outlasts the lease an evicted object waits
41
- * out before it resumes (10 min, here `leaseMs`), so a job resumed after an eviction is still inside
42
- * its window — as in production.
43
- *
44
- * A hotfix's stage window ends the job `stuck` when it expires, and the fault matrix answers the
45
- * prebuild from a poll loop that a loaded host starves for several seconds at a time (a 30 ms sleep
46
- * measured at 4–8 s on an oversubscribed machine). The window is sized well past that stall.
47
- */
48
- export const PUBLISH_HARNESS_TIMING: PublishTiming = {
49
- awaitWindowMs: 4_000,
50
- runGraceMs: 500,
51
- proofDelayMs: 30,
52
- proofProbes: { synchronous: 3, asynchronous: 5 },
53
- stageWindowMs: 15_000,
54
- stageChecks: 3,
55
- };
56
-
57
- export const PUBLISH_HARNESS_TUNING: PublishKindTuning = {
58
- leaseMs: 3_000,
59
- retryBaseMs: 20,
60
- deadlineMs: { synchronous: 60_000, asynchronous: 60_000 },
61
- hotfixExtraMs: 0,
62
- compensationRetryBaseMs: 300,
63
- };
64
-
65
- export interface PublishFault {
66
- step: string;
67
- at: "before" | "after";
68
- mode: "evict" | "throw" | "preview-write";
69
- /** `preview-write`: the version the preview channel moves to. */
70
- versionId?: string;
71
- /** How many times it fires (default 1). */
72
- times?: number;
73
- }
74
-
75
- function tables(state: DurableObjectState): void {
76
- const { sql } = state.storage;
77
- sql.exec(`CREATE TABLE IF NOT EXISTS harness_kv (key TEXT PRIMARY KEY, value TEXT NOT NULL)`);
78
- sql.exec(`CREATE TABLE IF NOT EXISTS harness_publish_faults (id INTEGER PRIMARY KEY AUTOINCREMENT, step TEXT, at TEXT, mode TEXT, remaining INTEGER, version_id TEXT)`);
79
- sql.exec(`CREATE TABLE IF NOT EXISTS harness_publish_fired (seq INTEGER PRIMARY KEY AUTOINCREMENT, step TEXT, at TEXT, mode TEXT)`);
80
- }
81
-
82
- /** A KV over the object's SQLite: durable across evictions, visible to every later execution. */
83
- export function sqlKv(state: DurableObjectState): TestKv {
84
- const { sql } = state.storage;
85
- return {
86
- get: async (key) => sql.exec<{ value: string }>(`SELECT value FROM harness_kv WHERE key = ?`, key).toArray()[0]?.value ?? null,
87
- put: async (key, value) => {
88
- sql.exec(`INSERT INTO harness_kv (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value`, key, value);
89
- },
90
- delete: async (key) => {
91
- sql.exec(`DELETE FROM harness_kv WHERE key = ?`, key);
92
- },
93
- };
94
- }
95
-
96
- export function armPublishFault(state: DurableObjectState, fault: PublishFault): void {
97
- tables(state);
98
- state.storage.sql.exec(
99
- `INSERT INTO harness_publish_faults (step, at, mode, remaining, version_id) VALUES (?, ?, ?, ?, ?)`,
100
- fault.step,
101
- fault.at,
102
- fault.mode,
103
- fault.times ?? 1,
104
- fault.versionId ?? null,
105
- );
106
- }
107
-
108
- export function firedPublishFaults(state: DurableObjectState): { step: string; at: string; mode: string }[] {
109
- tables(state);
110
- return state.storage.sql.exec<{ step: string; at: string; mode: string }>(`SELECT step, at, mode FROM harness_publish_fired ORDER BY seq`).toArray();
111
- }
112
-
113
- interface FaultScope {
114
- tenantId: string;
115
- store: SiteVersionStore;
116
- }
117
-
118
- async function maybeFault(state: DurableObjectState, step: string, at: "before" | "after", scope: FaultScope | null): Promise<void> {
119
- const { sql } = state.storage;
120
- const fault = sql
121
- .exec<{ id: number; mode: string; version_id: string | null }>(
122
- `SELECT id, mode, version_id FROM harness_publish_faults WHERE step = ? AND at = ? AND remaining > 0 ORDER BY id LIMIT 1`,
123
- step,
124
- at,
125
- )
126
- .toArray()[0];
127
- if (!fault) return;
128
- sql.exec(`UPDATE harness_publish_faults SET remaining = remaining - 1 WHERE id = ?`, fault.id);
129
- sql.exec(`INSERT INTO harness_publish_fired (step, at, mode) VALUES (?, ?, ?)`, step, at, fault.mode);
130
- // Everything written so far — including a step's own effect, for an `after` fault — is made
131
- // durable first, exactly as a real crash after the write would leave it.
132
- await state.storage.sync();
133
- if (fault.mode === "preview-write") {
134
- if (!scope || !fault.version_id) throw new Error(`a preview-write fault needs a job step and a version (${at} ${step})`);
135
- await movePreview(scope.store, scope.tenantId, fault.version_id);
136
- return;
137
- }
138
- if (fault.mode === "evict") {
139
- state.abort(`synthetic eviction ${at} ${step}`);
140
- throw new Error("abort() returned");
141
- }
142
- throw new Error(`synthetic fault ${at} ${step}`);
143
- }
144
-
145
- function withFaults(state: DurableObjectState, definition: JobKindDefinition<unknown>, store: SiteVersionStore): JobKindDefinition<unknown> {
146
- const onTerminal = definition.onTerminal;
147
- return {
148
- ...definition,
149
- // The compensation after a terminal transition can be faulted too (as the step "on-terminal").
150
- ...(onTerminal
151
- ? {
152
- onTerminal: async (info: Parameters<NonNullable<JobKindDefinition<unknown>["onTerminal"]>>[0]) => {
153
- await maybeFault(state, "on-terminal", "before", null);
154
- await onTerminal(info);
155
- },
156
- }
157
- : {}),
158
- steps: definition.steps.map(
159
- (step): StepDefinition<unknown> => ({
160
- ...step,
161
- async run(ctx) {
162
- await maybeFault(state, step.name, "before", { tenantId: ctx.tenantId, store });
163
- const outcome = await step.run(ctx);
164
- await maybeFault(state, step.name, "after", { tenantId: ctx.tenantId, store });
165
- return outcome;
166
- },
167
- }),
168
- ),
169
- };
170
- }
171
-
172
- export function publishWorldOf(state: DurableObjectState): { kv: TestKv; world: PublishWorld } {
173
- tables(state);
174
- const kv = sqlKv(state);
175
- return { kv, world: new PublishWorld(kv) };
176
- }
177
-
178
- /** The world's logs that record an external effect, by the effect name the fault matrix uses. */
179
- const NOTED_EFFECTS: Record<string, string> = {
180
- "hotfix-merges": "forge:merge-to-main",
181
- "forward-integrations": "forge:forward-integrate",
182
- "staged-originals": "r2:stage-originals",
183
- "went-live": "notice:went-live",
184
- };
185
-
186
- /** The publish world, reporting every external effect a job makes to the fault matrix. */
187
- class EffectWorld extends PublishWorld {
188
- constructor(
189
- kv: TestKv,
190
- private readonly landed: Landed,
191
- ) {
192
- super(kv);
193
- }
194
-
195
- override async dispatch(dispatch: CiDispatch, at = 0): Promise<void> {
196
- const before = (await this.dispatches()).length;
197
- let lost: unknown = null;
198
- try {
199
- await super.dispatch(dispatch, at);
200
- } catch (thrown) {
201
- // A refused dispatch recorded nothing (no run exists); a lost response came after the run did.
202
- if ((await this.dispatches()).length === before) throw thrown;
203
- lost = thrown;
204
- }
205
- await this.landed(`ci:${dispatch.workflow}`);
206
- if (lost) throw lost;
207
- }
208
-
209
- override async recordDesignation(entry: WorldDesignation): Promise<void> {
210
- await super.recordDesignation(entry);
211
- await this.landed("mcp:designate");
212
- }
213
-
214
- override async note(key: string, value: unknown): Promise<void> {
215
- await super.note(key, value);
216
- const effect = NOTED_EFFECTS[key];
217
- if (effect) await this.landed(effect);
218
- }
219
- }
220
-
221
- /** The object's pointer writer, reporting each write that moved a channel (`pointer:<channel>`). */
222
- function effectPointers(inner: PointerWriter, landed: Landed): PointerWriter {
223
- return {
224
- read: (tenantId) => inner.read(tenantId),
225
- ...(inner.peek ? { peek: (tenantId: string) => inner.peek!(tenantId) } : {}),
226
- async update(tenantId, apply) {
227
- let before: PointerRecord | null = null;
228
- const after = await inner.update(tenantId, (current) => {
229
- before = current;
230
- return apply(current);
231
- });
232
- const prior = before as PointerRecord | null;
233
- for (const channel of ["live", "preview"] as const) {
234
- if (prior?.channels?.[channel] !== after.channels?.[channel] || prior?.channelRevs?.[channel] !== after.channelRevs?.[channel]) {
235
- await landed(`pointer:${channel}`);
236
- }
237
- }
238
- return after;
239
- },
240
- };
241
- }
242
-
243
- /** The job's KV, reporting each write of the assets pointer (`assets:live`). */
244
- function effectKv(kv: TestKv, landed: Landed): TestKv {
245
- return {
246
- get: (key) => kv.get(key),
247
- put: async (key, value) => {
248
- await kv.put(key, value);
249
- if (key.startsWith("cust:assets-pointer:")) await landed("assets:live");
250
- },
251
- ...(kv.delete ? { delete: (key: string) => kv.delete!(key) } : {}),
252
- };
253
- }
254
-
255
- const noEffects: Landed = async () => {};
256
-
257
- /**
258
- * Register the publish kinds (fault-wrapped, over the stand-in world) into `registry`; `pointers` is
259
- * the object's authority. `landed` hears every external effect the jobs make (the fault matrix).
260
- */
261
- export function registerHarnessPublishKinds(
262
- state: DurableObjectState,
263
- registry: JobKindRegistry,
264
- pointers: PointerWriter,
265
- landed: Landed = noEffects,
266
- ): JobKindRegistry {
267
- const { kv } = publishWorldOf(state);
268
- const store = testVersionStore(kv, effectPointers(pointers, landed));
269
- const environment = standInPublishEnvironment({
270
- kv: effectKv(kv, landed),
271
- world: new EffectWorld(kv, landed),
272
- store,
273
- now: () => Date.now(),
274
- timing: PUBLISH_HARNESS_TIMING,
275
- });
276
- const kinds = registerPublishJobKinds(new JobKindRegistry(), async () => environment, PUBLISH_HARNESS_TUNING);
277
- for (const name of kinds.list()) registry.register(withFaults(state, kinds.get(name)!, store));
278
- return registry;
279
- }
@@ -1,303 +0,0 @@
1
- /**
2
- * A synthetic 5-step job kind for the TenantPipeline fault harness. Test-only: the deployed
3
- * registry (`src/lib/publication/pipeline/job-kinds.ts`) never contains it.
4
- *
5
- * Steps s1..s5. s3 works in three chunks and checkpoints after each one. s2 records a commit
6
- * fact, s4 evidence, s5 the live state, so retried fact writes are exercised too. Every step
7
- * execution is logged to `synthetic_runs` (to prove resume-not-restart) and every effect to
8
- * `synthetic_effects` with INSERT OR IGNORE (the step is idempotent, as the engine requires).
9
- *
10
- * The intent carries a fault plan: throw a transient fault / hang past the lease / evict the
11
- * object / refuse (a developer-class refusal) / crash (a platform-class error), at a step
12
- * boundary (`before` the step's work, `after` it but before the engine records it) or `mid` s3
13
- * (after its first chunk's checkpoint). A fault fires once unless `persistent`; its firing is
14
- * persisted before it acts so it survives the eviction it causes.
15
- */
16
- import type { DurableObjectState } from "cloudflare:workers";
17
- import { PipelineRefusal } from "../../src/lib/publication/pipeline/classify";
18
- import {
19
- InvalidJobInput,
20
- JobKindRegistry,
21
- StaleExecutionError,
22
- type JobKindDefinition,
23
- type StepContext,
24
- type StepDefinition,
25
- type StepOutcome,
26
- } from "../../src/lib/publication/pipeline/job-runner";
27
-
28
- export type FaultMode = "throw" | "hang" | "evict" | "refuse" | "crash";
29
-
30
- /**
31
- * The transient fault a `throw` raises: a typed connection reset, which `classify()` names
32
- * `transient` — so the engine retries it, exactly as it retries a real network blip.
33
- */
34
- export class SyntheticTransientFault extends Error {
35
- override name = "SyntheticTransientFault";
36
- readonly code = "ECONNRESET";
37
- }
38
- export interface Fault {
39
- at: "before" | "after" | "mid";
40
- step: number;
41
- mode: FaultMode;
42
- persistent?: boolean;
43
- }
44
- export interface SyntheticInput {
45
- faults: Fault[];
46
- }
47
-
48
- export const SYNTHETIC_KIND = "synthetic-5-step";
49
- export const SYNTHETIC_SHORT_DEADLINE_KIND = "synthetic-5-step-short-deadline";
50
- export const SYNTHETIC_LEASE_MS = 250;
51
- export const SYNTHETIC_DEADLINE_MS = 30_000;
52
- export const SHORT_DEADLINE_MS = 1_500;
53
- export const S3_CHUNKS = 3;
54
-
55
- /** Executions abandoned by a lease expiry, kept so a test can try writing through them. */
56
- export const abandonedContexts: StepContext<SyntheticInput>[] = [];
57
-
58
- function parseInput(raw: unknown): SyntheticInput {
59
- const faults = (raw as { faults?: unknown } | null)?.faults ?? [];
60
- if (!Array.isArray(faults)) throw new InvalidJobInput("faults must be an array");
61
- for (const f of faults as Fault[]) {
62
- if (!["before", "after", "mid"].includes(f.at)) throw new InvalidJobInput("fault.at is invalid");
63
- if (!["throw", "hang", "evict", "refuse", "crash"].includes(f.mode)) throw new InvalidJobInput("fault.mode is invalid");
64
- if (!Number.isInteger(f.step) || f.step < 1 || f.step > 5) throw new InvalidJobInput("fault.step is invalid");
65
- }
66
- return { faults: faults as Fault[] };
67
- }
68
-
69
- function harnessTables(state: DurableObjectState): void {
70
- const { sql } = state.storage;
71
- sql.exec(`CREATE TABLE IF NOT EXISTS synthetic_runs (seq INTEGER PRIMARY KEY AUTOINCREMENT, job_id TEXT, step INTEGER, chunk INTEGER, attempt INTEGER)`);
72
- sql.exec(`CREATE TABLE IF NOT EXISTS synthetic_effects (job_id TEXT, step INTEGER, chunk INTEGER, PRIMARY KEY (job_id, step, chunk))`);
73
- sql.exec(`CREATE TABLE IF NOT EXISTS synthetic_faults_fired (job_id TEXT, fault INTEGER, n INTEGER, PRIMARY KEY (job_id, fault))`);
74
- sql.exec(`CREATE TABLE IF NOT EXISTS synthetic_zombie_writes (job_id TEXT, outcome TEXT)`);
75
- }
76
-
77
- function syntheticKind(state: DurableObjectState, kind: string, deadlineMs: number): JobKindDefinition<SyntheticInput> {
78
- const { sql } = state.storage;
79
-
80
- async function maybeFault(ctx: StepContext<SyntheticInput>, at: Fault["at"], step: number): Promise<void> {
81
- const index = ctx.input.faults.findIndex((f) => f.at === at && f.step === step);
82
- if (index < 0) return;
83
- const fault = ctx.input.faults[index]!;
84
- const fired = sql
85
- .exec<{ n: number }>(`SELECT n FROM synthetic_faults_fired WHERE job_id = ? AND fault = ?`, ctx.jobId, index)
86
- .toArray()[0];
87
- if (fired && !fault.persistent) return;
88
- sql.exec(
89
- `INSERT INTO synthetic_faults_fired (job_id, fault, n) VALUES (?, ?, 1)
90
- ON CONFLICT(job_id, fault) DO UPDATE SET n = n + 1`,
91
- ctx.jobId,
92
- index,
93
- );
94
- await state.storage.sync();
95
- if (fault.mode === "throw") throw new SyntheticTransientFault(`synthetic fault ${at} s${step}`);
96
- if (fault.mode === "refuse") throw new PipelineRefusal("build_refused", [`synthetic refusal ${at} s${step}`]);
97
- if (fault.mode === "crash") throw new Error(`synthetic crash ${at} s${step}`);
98
- if (fault.mode === "evict") {
99
- state.abort(`synthetic eviction ${at} s${step}`);
100
- throw new Error("abort() returned");
101
- }
102
- abandonedContexts.push(ctx);
103
- await new Promise((resolve) => setTimeout(resolve, SYNTHETIC_LEASE_MS * 8));
104
- try {
105
- ctx.saveCheckpoint({ zombie: true });
106
- sql.exec(`INSERT INTO synthetic_zombie_writes (job_id, outcome) VALUES (?, 'accepted')`, ctx.jobId);
107
- } catch (err) {
108
- sql.exec(
109
- `INSERT INTO synthetic_zombie_writes (job_id, outcome) VALUES (?, ?)`,
110
- ctx.jobId,
111
- err instanceof StaleExecutionError ? "refused" : "error",
112
- );
113
- }
114
- throw new Error("hung execution woke up");
115
- }
116
-
117
- function logRun(ctx: StepContext<SyntheticInput>, step: number, chunk: number): void {
118
- sql.exec(`INSERT INTO synthetic_runs (job_id, step, chunk, attempt) VALUES (?, ?, ?, ?)`, ctx.jobId, step, chunk, ctx.attempt);
119
- sql.exec(`INSERT OR IGNORE INTO synthetic_effects (job_id, step, chunk) VALUES (?, ?, ?)`, ctx.jobId, step, chunk);
120
- }
121
-
122
- const plainStep = (step: number, fact?: (ctx: StepContext<SyntheticInput>) => void): StepDefinition<SyntheticInput> => ({
123
- name: `s${step}`,
124
- async run(ctx): Promise<StepOutcome> {
125
- await maybeFault(ctx, "before", step);
126
- logRun(ctx, step, 0);
127
- fact?.(ctx);
128
- await maybeFault(ctx, "after", step);
129
- return { kind: "done" };
130
- },
131
- });
132
-
133
- const chunkedStep: StepDefinition<SyntheticInput> = {
134
- name: "s3",
135
- async run(ctx): Promise<StepOutcome> {
136
- const next = (ctx.checkpoint as { next?: number } | null)?.next ?? 0;
137
- if (next === 0) await maybeFault(ctx, "before", 3);
138
- if (next === 1) await maybeFault(ctx, "mid", 3);
139
- logRun(ctx, 3, next);
140
- if (next < S3_CHUNKS - 1) return { kind: "continue", checkpoint: { next: next + 1 } };
141
- await maybeFault(ctx, "after", 3);
142
- return { kind: "done" };
143
- },
144
- };
145
-
146
- return {
147
- kind,
148
- parseInput,
149
- steps: [
150
- plainStep(1),
151
- plainStep(2, (ctx) => ctx.recordCommit(`sha-${ctx.jobId}`, [{ pr: 2, changeId: "c2", headSha: "h2" }])),
152
- chunkedStep,
153
- plainStep(4, (ctx) => ctx.recordEvidence(`sha-${ctx.jobId}`, `digest-${ctx.jobId}`, true)),
154
- plainStep(5, (ctx) => ctx.recordLive("worker-r2-pointer", `sha-${ctx.jobId}`, `rcpt-${ctx.jobId}`, null)),
155
- ],
156
- leaseMs: SYNTHETIC_LEASE_MS,
157
- deadlineMs,
158
- maxAttemptsPerStep: kind === SYNTHETIC_SHORT_DEADLINE_KIND ? 1_000 : 5,
159
- retryBaseMs: 10,
160
- defaultExpectedMs: 2_000,
161
- };
162
- }
163
-
164
- // ── Engine-behaviour kinds ──────────────────────────────────────────────────
165
-
166
- /** s1 then an optional s2 that fails as the intent says (`crash` | `refuse` | `hang`). */
167
- export const SYNTHETIC_OPTIONAL_TAIL_KIND = "synthetic-optional-tail";
168
- /** One long step that works in chunks, checkpointing each, for longer than one execution may run. */
169
- export const SYNTHETIC_LONG_STEP_KIND = "synthetic-long-step";
170
- /** A step that hangs past its lease but honours its abort signal, then retries clean. */
171
- export const SYNTHETIC_COOPERATIVE_HANG_KIND = "synthetic-cooperative-hang";
172
- export const LONG_STEP_CHUNKS = 12;
173
- export const LONG_STEP_CHUNK_MS = 100;
174
- export const LONG_STEP_MAX_EXECUTION_MS = 450;
175
- export const SYNTHETIC_STEP_CLOCK_KIND = "synthetic-step-clock";
176
- export const STEP_CLOCK_BASE_MS = 1_000;
177
- export const STEP_CLOCK_CAPTURE_MS = 1_500;
178
- export const STEP_CLOCK_LIMIT_MS = 4_000;
179
-
180
- function engineKinds(state: DurableObjectState): JobKindDefinition<{ mode?: string }>[] {
181
- const { sql } = state.storage;
182
- sql.exec(`CREATE TABLE IF NOT EXISTS synthetic_spans (seq INTEGER PRIMARY KEY AUTOINCREMENT, job_id TEXT, started INTEGER, ended INTEGER)`);
183
- const base = { leaseMs: SYNTHETIC_LEASE_MS, deadlineMs: SYNTHETIC_DEADLINE_MS, retryBaseMs: 10, defaultExpectedMs: 1_000 };
184
- const parse = (raw: unknown) => (raw && typeof raw === "object" ? (raw as { mode?: string }) : {});
185
- const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
186
- return [
187
- {
188
- ...base,
189
- kind: SYNTHETIC_STEP_CLOCK_KIND,
190
- parseInput: parse,
191
- deadlineMs: STEP_CLOCK_BASE_MS,
192
- leaseMs: 10_000,
193
- maxAttemptsPerStep: 3,
194
- steps: [
195
- { name: "capture", deadlineMs: STEP_CLOCK_LIMIT_MS, run: async (ctx) => {
196
- const deadline = sql.exec<{ deadline: number }>(`SELECT deadline FROM jobs WHERE job_id = ?`, ctx.jobId).one().deadline;
197
- ctx.setProduces({ captureStartedAt: ctx.now(), captureDeadline: deadline });
198
- if (ctx.input.mode === "evict" && !ctx.checkpoint) {
199
- ctx.saveCheckpoint({ evicted: true });
200
- await ctx.flush();
201
- state.abort("synthetic eviction during bounded step clock");
202
- }
203
- if (ctx.input.mode === "hang") await new Promise<void>((resolve) => ctx.signal.addEventListener("abort", () => resolve(), { once: true }));
204
- else await sleep(STEP_CLOCK_CAPTURE_MS);
205
- return { kind: "done" as const };
206
- } },
207
- { name: "after", run: async (ctx) => {
208
- const deadline = sql.exec<{ deadline: number }>(`SELECT deadline FROM jobs WHERE job_id = ?`, ctx.jobId).one().deadline;
209
- ctx.setProduces({ afterStartedAt: ctx.now(), afterDeadline: deadline });
210
- await new Promise<void>((resolve) => ctx.signal.addEventListener("abort", () => resolve(), { once: true }));
211
- return { kind: "done" as const };
212
- } },
213
- ],
214
- },
215
- {
216
- kind: SYNTHETIC_OPTIONAL_TAIL_KIND,
217
- parseInput: parse,
218
- steps: [
219
- { name: "s1", run: async () => ({ kind: "done" }) },
220
- {
221
- name: "s2",
222
- optional: true,
223
- run: async (ctx) => {
224
- if (ctx.input.mode === "refuse") throw new PipelineRefusal("build_refused");
225
- if (ctx.input.mode === "hang") await sleep(SYNTHETIC_LEASE_MS * 4);
226
- throw new Error("optional tail crashed");
227
- },
228
- },
229
- ],
230
- ...base,
231
- maxAttemptsPerStep: 2,
232
- },
233
- {
234
- kind: SYNTHETIC_LONG_STEP_KIND,
235
- parseInput: parse,
236
- steps: [
237
- {
238
- name: "long",
239
- run: async (ctx) => {
240
- let next = (ctx.checkpoint as { next?: number } | null)?.next ?? 0;
241
- while (next < LONG_STEP_CHUNKS) {
242
- if (ctx.signal.aborted) throw new Error("aborted");
243
- await sleep(LONG_STEP_CHUNK_MS);
244
- next += 1;
245
- ctx.saveCheckpoint({ next });
246
- await ctx.renewLease();
247
- }
248
- return { kind: "done" };
249
- },
250
- },
251
- ],
252
- ...base,
253
- // One attempt only: reaching the execution cap after checkpointing must not spend it.
254
- maxAttemptsPerStep: 1,
255
- maxExecutionMs: LONG_STEP_MAX_EXECUTION_MS,
256
- },
257
- {
258
- kind: SYNTHETIC_COOPERATIVE_HANG_KIND,
259
- parseInput: parse,
260
- steps: [
261
- {
262
- name: "hang",
263
- run: async (ctx) => {
264
- const started = Date.now();
265
- const seq = sql
266
- .exec<{ seq: number }>(`INSERT INTO synthetic_spans (job_id, started) VALUES (?, ?) RETURNING seq`, ctx.jobId, started)
267
- .one().seq;
268
- const first = sql.exec<{ n: number }>(`SELECT COUNT(*) AS n FROM synthetic_spans WHERE job_id = ?`, ctx.jobId).one().n === 1;
269
- try {
270
- if (first) {
271
- // Wait for the abort, then take a while to wind down (within one further lease).
272
- await new Promise<void>((resolve) => ctx.signal.addEventListener("abort", () => resolve(), { once: true }));
273
- await sleep(SYNTHETIC_LEASE_MS / 2);
274
- throw new Error("stopped after abort");
275
- }
276
- return { kind: "done" };
277
- } finally {
278
- sql.exec(`UPDATE synthetic_spans SET ended = ? WHERE seq = ?`, Date.now(), seq);
279
- }
280
- },
281
- },
282
- ],
283
- ...base,
284
- maxAttemptsPerStep: 5,
285
- },
286
- ];
287
- }
288
-
289
- export function syntheticJobKinds(state: DurableObjectState): JobKindRegistry {
290
- harnessTables(state);
291
- const registry = new JobKindRegistry()
292
- .register(syntheticKind(state, SYNTHETIC_KIND, SYNTHETIC_DEADLINE_MS))
293
- .register(syntheticKind(state, SYNTHETIC_SHORT_DEADLINE_KIND, SHORT_DEADLINE_MS));
294
- for (const kind of engineKinds(state)) registry.register(kind as JobKindDefinition<unknown> as never);
295
- return registry;
296
- }
297
-
298
- /** Execution spans of the cooperative-hang kind, for overlap checks. */
299
- export function syntheticSpans(state: DurableObjectState, jobId: string): { started: number; ended: number | null }[] {
300
- return state.storage.sql
301
- .exec<{ started: number; ended: number | null }>(`SELECT started, ended FROM synthetic_spans WHERE job_id = ? ORDER BY seq`, jobId)
302
- .toArray();
303
- }