@tokenoftrust/storefront-runner 1.4.1 → 2.0.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 (474) hide show
  1. package/apps/storefront/astro.config.mjs +17 -1
  2. package/apps/storefront/env.d.ts +54 -5
  3. package/apps/storefront/integrations/materialize-guard.mjs +54 -0
  4. package/apps/storefront/migrations-apps/0002_good_switch.sql +26 -0
  5. package/apps/storefront/migrations-apps/0003_mute_marauders.sql +12 -0
  6. package/apps/storefront/migrations-apps/0004_deep_morph.sql +36 -0
  7. package/apps/storefront/migrations-apps/0005_common_mystique.sql +23 -0
  8. package/apps/storefront/migrations-apps/0006_broad_microchip.sql +16 -0
  9. package/apps/storefront/migrations-apps/0007_brave_outlaw_kid.sql +15 -0
  10. package/apps/storefront/migrations-apps/0008_blue_dazzler.sql +11 -0
  11. package/apps/storefront/migrations-apps/0009_bored_shinobi_shaw.sql +15 -0
  12. package/apps/storefront/migrations-apps/0010_ws4_verified_provider_measurement.sql +35 -0
  13. package/apps/storefront/migrations-apps/meta/0002_snapshot.json +1160 -0
  14. package/apps/storefront/migrations-apps/meta/0003_snapshot.json +1235 -0
  15. package/apps/storefront/migrations-apps/meta/0004_snapshot.json +1474 -0
  16. package/apps/storefront/migrations-apps/meta/0005_snapshot.json +1617 -0
  17. package/apps/storefront/migrations-apps/meta/0006_snapshot.json +1716 -0
  18. package/apps/storefront/migrations-apps/meta/0007_snapshot.json +1812 -0
  19. package/apps/storefront/migrations-apps/meta/0008_snapshot.json +1881 -0
  20. package/apps/storefront/migrations-apps/meta/0009_snapshot.json +1979 -0
  21. package/apps/storefront/migrations-apps/meta/_journal.json +56 -0
  22. package/apps/storefront/public/apps/tot.demo.analytics/0.1.0/entry.js +42 -0
  23. package/apps/storefront/public/js/dashboard-team.js +38 -2
  24. package/apps/storefront/public/platform/amplitude-http/v1/entry.mjs +19 -0
  25. package/apps/storefront/public/platform/google-measurement/v1/entry.mjs +19 -0
  26. package/apps/storefront/public/shared/commerce-chrome.css +20 -2
  27. package/apps/storefront/scripts/build-v84-clean-clone-standalone.mjs +68 -0
  28. package/apps/storefront/scripts/deny-v84-clean-clone-standalone-capabilities.mjs +111 -0
  29. package/apps/storefront/scripts/deny-v84-dogfood-capabilities.mjs +2 -0
  30. package/apps/storefront/scripts/deny-v84-lifecycle-capabilities.mjs +247 -0
  31. package/apps/storefront/scripts/dogfood-v84-nonportable-routes.ts +73 -0
  32. package/apps/storefront/scripts/fixed-v84-native-install-producer.ts +79 -0
  33. package/apps/storefront/scripts/generated/v84-clean-clone-replay.bundle.mjs +10982 -0
  34. package/apps/storefront/scripts/import-v84-through-ws2.ts +38 -0
  35. package/apps/storefront/scripts/initialize-v84-lifecycle-tooling-dependency.ts +2 -0
  36. package/apps/storefront/scripts/initialize-v84-lifecycle-tooling.ts +4 -0
  37. package/apps/storefront/scripts/install-v84-native-through-ws1.ts +185 -0
  38. package/apps/storefront/scripts/prove-clone-isolation.ts +506 -0
  39. package/apps/storefront/scripts/replay-v84-clean-clone-pass.ts +148 -0
  40. package/apps/storefront/scripts/replay-v84-clean-clone-standalone.ts +35 -0
  41. package/apps/storefront/scripts/replay-v84-clean-clone.ts +214 -0
  42. package/apps/storefront/scripts/run-fixed-v84-native-install-producer.mjs +18 -0
  43. package/apps/storefront/scripts/run-v84-clone-isolation-proof.mjs +18 -0
  44. package/apps/storefront/scripts/run-v84-clone-lifecycle-proof.mjs +18 -0
  45. package/apps/storefront/scripts/run-v84-import-through-ws2-proof.mjs +17 -0
  46. package/apps/storefront/scripts/run-v84-nonportable-route-dogfood.mjs +15 -0
  47. package/apps/storefront/scripts/sanitize-v84-proof-environment.mjs +21 -0
  48. package/apps/storefront/scripts/v84CleanCloneGraphPin.ts +42 -0
  49. package/apps/storefront/scripts/v84CleanCloneSourceGraph.ts +145 -0
  50. package/apps/storefront/scripts/validate-v84-clone-lifecycle.ts +18 -0
  51. package/apps/storefront/src/components/Img.astro +1 -1
  52. package/apps/storefront/src/components/Seo.astro +65 -1
  53. package/apps/storefront/src/components/admin/AdminBlogDetailRail.astro +878 -0
  54. package/apps/storefront/src/components/admin/AdminBlogTab.astro +1435 -0
  55. package/apps/storefront/src/components/admin/AdminCustomersTab.astro +3 -7
  56. package/apps/storefront/src/components/admin/AdminIntegrationsTab.astro +105 -0
  57. package/apps/storefront/src/components/admin/AdminPublishTab.astro +1980 -2564
  58. package/apps/storefront/src/components/admin/AdminSettingsTab.astro +2 -2
  59. package/apps/storefront/src/components/admin/AdminSubscriptionsTab.astro +1 -3
  60. package/apps/storefront/src/components/admin/orders/OrdersWorkspace.astro +5 -5
  61. package/apps/storefront/src/components/blog/BlogPaywall.astro +87 -0
  62. package/apps/storefront/src/components/blog/PostAccessBadge.astro +43 -0
  63. package/apps/storefront/src/components/blog/PostGrid.astro +57 -0
  64. package/apps/storefront/src/components/blog/ReactionBar.astro +214 -0
  65. package/apps/storefront/src/components/chrome/NavDropdown.astro +12 -0
  66. package/apps/storefront/src/components/chrome/SiteFooter.astro +7 -2
  67. package/apps/storefront/src/components/chrome/SiteHeader.astro +46 -10
  68. package/apps/storefront/src/components/compliance/AdultSignatureNotice.astro +1 -1
  69. package/apps/storefront/src/components/compliance/ComplianceNotice.astro +1 -2
  70. package/apps/storefront/src/components/compliance/ExciseTaxNotice.astro +1 -2
  71. package/apps/storefront/src/components/compliance/PactActNotice.astro +1 -1
  72. package/apps/storefront/src/components/compliance/Prop65Warning.astro +1 -2
  73. package/apps/storefront/src/components/compliance/PurchaseLimitNotice.astro +2 -3
  74. package/apps/storefront/src/components/compliance/ShippingRestrictionNotice.astro +2 -2
  75. package/apps/storefront/src/components/compliance/StateEligibilityNotice.astro +2 -3
  76. package/apps/storefront/src/components/content/TrustStrip.astro +4 -4
  77. package/apps/storefront/src/components/islands/MobileNav.tsx +26 -1
  78. package/apps/storefront/src/components/islands/VariantSelector.tsx +27 -2
  79. package/apps/storefront/src/components/islands/useCheckoutHandoffCorrelation.ts +75 -0
  80. package/apps/storefront/src/components/membership/IllustrativeLabel.astro +1 -2
  81. package/apps/storefront/src/components/membership/TierCards.astro +2 -2
  82. package/apps/storefront/src/components/membership/TierComparisonTable.astro +2 -2
  83. package/apps/storefront/src/components/subscription/SavingsExplainer.astro +2 -2
  84. package/apps/storefront/src/config/adminTenantLookup.ts +35 -0
  85. package/apps/storefront/src/config/devTenantSeed.ts +9 -9
  86. package/apps/storefront/src/config/resolver.ts +4 -4
  87. package/apps/storefront/src/layouts/Layout.astro +146 -21
  88. package/apps/storefront/src/lib/activity/alerts.ts +17 -19
  89. package/apps/storefront/src/lib/activity/candidateSubmitLease.ts +87 -0
  90. package/apps/storefront/src/lib/activity/changeActorAttribution.ts +89 -9
  91. package/apps/storefront/src/lib/activity/deployVersion.ts +20 -27
  92. package/apps/storefront/src/lib/activity/ingest.ts +8 -8
  93. package/apps/storefront/src/lib/activity/ingestAuth.ts +1 -1
  94. package/apps/storefront/src/lib/activity/killSwitch.ts +6 -6
  95. package/apps/storefront/src/lib/activity/query.ts +9 -9
  96. package/apps/storefront/src/lib/activity/recordActivity.ts +11 -15
  97. package/apps/storefront/src/lib/activity/store.ts +4 -6
  98. package/apps/storefront/src/lib/activity/uiActor.ts +12 -12
  99. package/apps/storefront/src/lib/activity/workerCommit.ts +6 -6
  100. package/apps/storefront/src/lib/admin/adminShell.ts +292 -0
  101. package/apps/storefront/src/lib/admin/ai/approvalMode.ts +2 -3
  102. package/apps/storefront/src/lib/admin/ai/audit.ts +3 -5
  103. package/apps/storefront/src/lib/admin/checkoutStyleInput.ts +7 -7
  104. package/apps/storefront/src/lib/admin/checkoutStyleTarget.ts +3 -3
  105. package/apps/storefront/src/lib/admin/envelope.ts +1 -2
  106. package/apps/storefront/src/lib/admin/orderClient.ts +3 -5
  107. package/apps/storefront/src/lib/admin/services/orders.ts +17 -19
  108. package/apps/storefront/src/lib/admin/viewmodels/aiWorkflows.ts +4 -6
  109. package/apps/storefront/src/lib/admin/viewmodels/settings.ts +1 -1
  110. package/apps/storefront/src/lib/apps/adminService.ts +14 -4
  111. package/apps/storefront/src/lib/apps/adminSession.ts +54 -45
  112. package/apps/storefront/src/lib/apps/apiAuth.ts +2 -2
  113. package/apps/storefront/src/lib/apps/apiRoute.ts +2 -2
  114. package/apps/storefront/src/lib/apps/appVersionStore.ts +281 -0
  115. package/apps/storefront/src/lib/apps/catalogMapper.ts +1 -1
  116. package/apps/storefront/src/lib/apps/consentConfigStore.ts +228 -0
  117. package/apps/storefront/src/lib/apps/credentials.ts +2 -2
  118. package/apps/storefront/src/lib/apps/gatewayKeys.ts +4 -4
  119. package/apps/storefront/src/lib/apps/gtmMigrationInstall.ts +447 -0
  120. package/apps/storefront/src/lib/apps/gtmMigrationReport.ts +367 -0
  121. package/apps/storefront/src/lib/apps/gtmMigrationTab.ts +315 -0
  122. package/apps/storefront/src/lib/apps/healthAggregate.ts +5 -5
  123. package/apps/storefront/src/lib/apps/integrationLifecycle.ts +614 -0
  124. package/apps/storefront/src/lib/apps/integrationLifecycleController.ts +125 -0
  125. package/apps/storefront/src/lib/apps/integrationReadModel.ts +563 -0
  126. package/apps/storefront/src/lib/apps/integrationsTab.ts +547 -0
  127. package/apps/storefront/src/lib/apps/integrationsView.ts +106 -0
  128. package/apps/storefront/src/lib/apps/managedAnalyticsService.ts +599 -0
  129. package/apps/storefront/src/lib/apps/orders/attributionService.ts +2 -2
  130. package/apps/storefront/src/lib/apps/orders/customerHash.ts +1 -1
  131. package/apps/storefront/src/lib/apps/orders/foxyOrderClient.ts +12 -12
  132. package/apps/storefront/src/lib/apps/orders/idempotency.ts +7 -7
  133. package/apps/storefront/src/lib/apps/orders/orderConversionD1.ts +150 -0
  134. package/apps/storefront/src/lib/apps/orders/orderForwardReceiver.ts +9 -1
  135. package/apps/storefront/src/lib/apps/orders/orderMapper.ts +2 -2
  136. package/apps/storefront/src/lib/apps/orders/ordersStore.ts +7 -7
  137. package/apps/storefront/src/lib/apps/orders/verifiedProviderMeasurement.ts +117 -0
  138. package/apps/storefront/src/lib/apps/registryService.ts +270 -16
  139. package/apps/storefront/src/lib/apps/scopes.ts +2 -2
  140. package/apps/storefront/src/lib/apps/tenantIntegrationMaterialization.ts +170 -0
  141. package/apps/storefront/src/lib/apps/tokenIssuer.ts +4 -4
  142. package/apps/storefront/src/lib/apps/tokenVerifier.ts +6 -6
  143. package/apps/storefront/src/lib/apps/v84CleanCloneReplayContext.ts +16 -0
  144. package/apps/storefront/src/lib/apps/v84CloneLifecycleCacheEvidence.ts +105 -0
  145. package/apps/storefront/src/lib/apps/v84CloneLifecycleEvidence.ts +177 -0
  146. package/apps/storefront/src/lib/apps/v84CloneLifecycleMaterialization.ts +251 -0
  147. package/apps/storefront/src/lib/apps/v84CloneLifecycleSemantics.ts +241 -0
  148. package/apps/storefront/src/lib/apps/v84CloneMigrationEvidence.ts +211 -0
  149. package/apps/storefront/src/lib/apps/v84CloneNativeInstallEvidence.ts +409 -0
  150. package/apps/storefront/src/lib/apps/v84NonportableCodeCoaching.ts +368 -0
  151. package/apps/storefront/src/lib/apps/v84NonportableRouteContract.ts +188 -0
  152. package/apps/storefront/src/lib/apps/v84NonportableRouteDogfood.ts +291 -0
  153. package/apps/storefront/src/lib/apps/widgets/eligibility.ts +2 -2
  154. package/apps/storefront/src/lib/apps/widgets/frameProps.ts +3 -3
  155. package/apps/storefront/src/lib/apps/widgets/launchToken.ts +4 -4
  156. package/apps/storefront/src/lib/apps/widgets/placements.ts +2 -2
  157. package/apps/storefront/src/lib/apps/widgets/renderSlot.ts +1 -1
  158. package/apps/storefront/src/lib/apps/ws1ManagedAnalyticsClient.ts +95 -0
  159. package/apps/storefront/src/lib/auth/adminApiGuard.ts +66 -0
  160. package/apps/storefront/src/lib/auth/adminEntry.ts +11 -11
  161. package/apps/storefront/src/lib/auth/adminLanding.ts +88 -0
  162. package/apps/storefront/src/lib/auth/identityToken.ts +6 -14
  163. package/apps/storefront/src/lib/auth/loginGate.ts +75 -13
  164. package/apps/storefront/src/lib/auth/mcpClientAssertion.ts +2 -4
  165. package/apps/storefront/src/lib/auth/operatorSession.ts +113 -0
  166. package/apps/storefront/src/lib/auth/session.ts +7 -8
  167. package/apps/storefront/src/lib/auth/totAccessClient.ts +8 -18
  168. package/apps/storefront/src/lib/basePath.ts +9 -2
  169. package/apps/storefront/src/lib/blog/access.ts +29 -0
  170. package/apps/storefront/src/lib/blog/collection.ts +400 -0
  171. package/apps/storefront/src/lib/blog/markdown.ts +174 -0
  172. package/apps/storefront/src/lib/blog/provider.ts +62 -3
  173. package/apps/storefront/src/lib/blog/reactions.ts +87 -0
  174. package/apps/storefront/src/lib/blog/rss.ts +92 -0
  175. package/apps/storefront/src/lib/blog/teaser.ts +83 -0
  176. package/apps/storefront/src/lib/blog/types.ts +34 -0
  177. package/apps/storefront/src/lib/blog/viewCounts.ts +243 -0
  178. package/apps/storefront/src/lib/chrome/examples/tokenoftrust.chrome-assignments.example.json +6 -0
  179. package/apps/storefront/src/lib/chrome/examples/tokenoftrust.chrome.example.json +79 -0
  180. package/apps/storefront/src/lib/chrome/model.ts +48 -253
  181. package/apps/storefront/src/lib/chrome/navCurrent.ts +29 -0
  182. package/apps/storefront/src/lib/chrome/parseConfig.ts +18 -32
  183. package/apps/storefront/src/lib/chrome/variant.ts +39 -0
  184. package/apps/storefront/src/lib/commerce/checkoutHandoffCorrelation.ts +105 -0
  185. package/apps/storefront/src/lib/compliance/tamper-sentinel-boot.ts +152 -0
  186. package/apps/storefront/src/lib/compliance/tamper-sentinel.ts +327 -0
  187. package/apps/storefront/src/lib/content/index.ts +5 -5
  188. package/apps/storefront/src/lib/content-edit/applyDiff.ts +1 -1
  189. package/apps/storefront/src/lib/content-edit/route.ts +1 -1
  190. package/apps/storefront/src/lib/d1/catalog.ts +14 -2
  191. package/apps/storefront/src/lib/d1/schema-apps.ts +372 -17
  192. package/apps/storefront/src/lib/dev/activityIngestToken.ts +2 -4
  193. package/apps/storefront/src/lib/dev/activityStore.ts +3 -5
  194. package/apps/storefront/src/lib/dev/apiBase.ts +1 -4
  195. package/apps/storefront/src/lib/dev/cockpit/ask.ts +49 -0
  196. package/apps/storefront/src/lib/dev/cockpit/clickToSource.ts +71 -0
  197. package/apps/storefront/src/lib/dev/cockpit/copyCommand.ts +227 -0
  198. package/apps/storefront/src/lib/dev/cockpit/files.ts +249 -0
  199. package/apps/storefront/src/lib/dev/cockpit/hostedActivity.ts +500 -0
  200. package/apps/storefront/src/lib/dev/cockpit/infoPopover.ts +12 -0
  201. package/apps/storefront/src/lib/dev/cockpit/mcpCopy.ts +34 -0
  202. package/apps/storefront/src/lib/dev/cockpit/monitor.ts +107 -0
  203. package/apps/storefront/src/lib/dev/cockpit/stepper.ts +116 -0
  204. package/apps/storefront/src/lib/dev/cockpit/themeToggle.ts +23 -0
  205. package/apps/storefront/src/lib/dev/cockpitStore.ts +1 -9
  206. package/apps/storefront/src/lib/dev/devDraft.ts +1 -1
  207. package/apps/storefront/src/lib/dev/previewStatus.ts +9 -21
  208. package/apps/storefront/src/lib/dev/rendezvousBroker.ts +9 -24
  209. package/apps/storefront/src/lib/dev/runtimeStore.ts +1 -1
  210. package/apps/storefront/src/lib/edgeCache.ts +34 -5
  211. package/apps/storefront/src/lib/email/candidateConflictEmail.ts +80 -0
  212. package/apps/storefront/src/lib/http/fetchTransport.ts +63 -0
  213. package/apps/storefront/src/lib/i18n.ts +25 -0
  214. package/apps/storefront/src/lib/integration/browserEnvironment.ts +137 -0
  215. package/apps/storefront/src/lib/integration/managedInstallDeclarations.ts +72 -0
  216. package/apps/storefront/src/lib/integration/nonceStamp.ts +49 -0
  217. package/apps/storefront/src/lib/integration/tenantDeclarations.ts +116 -0
  218. package/apps/storefront/src/lib/jsonld.ts +118 -0
  219. package/apps/storefront/src/lib/membership/eligibility.ts +1 -1
  220. package/apps/storefront/src/lib/membership/model.ts +1 -2
  221. package/apps/storefront/src/lib/monitoring/manifest.ts +11 -11
  222. package/apps/storefront/src/lib/newsletter/confirmationEmail.ts +30 -0
  223. package/apps/storefront/src/lib/newsletter/consent.ts +23 -0
  224. package/apps/storefront/src/lib/newsletter/digest.ts +117 -0
  225. package/apps/storefront/src/lib/newsletter/resendClient.ts +79 -0
  226. package/apps/storefront/src/lib/newsletter/send.ts +265 -0
  227. package/apps/storefront/src/lib/newsletter/subscribers.ts +156 -0
  228. package/apps/storefront/src/lib/previewReload.ts +57 -1
  229. package/apps/storefront/src/lib/publish/adminPublishTab.ts +4625 -0
  230. package/apps/storefront/src/lib/publish/apex-readiness.ts +41 -18
  231. package/apps/storefront/src/lib/publish/buildStream.ts +269 -0
  232. package/apps/storefront/src/lib/publish/collapsePersistence.ts +72 -0
  233. package/apps/storefront/src/lib/publish/dispatchHealth.ts +5 -7
  234. package/apps/storefront/src/lib/publish/domainState.ts +22 -13
  235. package/apps/storefront/src/lib/publish/lifecycleState.ts +369 -0
  236. package/apps/storefront/src/lib/publish/liveReleaseSummary.ts +29 -0
  237. package/apps/storefront/src/lib/publish/mergeDoctorOnFailure.ts +78 -0
  238. package/apps/storefront/src/lib/publish/mergeHealthBanner.ts +62 -0
  239. package/apps/storefront/src/lib/publish/mergeRowFindings.ts +124 -0
  240. package/apps/storefront/src/lib/publish/mergeSupportEscalation.ts +75 -0
  241. package/apps/storefront/src/lib/publish/panelPolling.ts +78 -0
  242. package/apps/storefront/src/lib/publish/publish-guard.ts +88 -0
  243. package/apps/storefront/src/lib/publish/publishFormat.ts +165 -0
  244. package/apps/storefront/src/lib/publish/publishHero.ts +177 -0
  245. package/apps/storefront/src/lib/publish/reviewRelease/changeState.ts +66 -0
  246. package/apps/storefront/src/lib/publish/reviewRelease/copy.ts +141 -0
  247. package/apps/storefront/src/lib/publish/reviewRelease/index.ts +41 -0
  248. package/apps/storefront/src/lib/publish/reviewRelease/permissions.ts +47 -0
  249. package/apps/storefront/src/lib/publish/reviewRelease/releaseState.ts +42 -0
  250. package/apps/storefront/src/lib/publish/reviewRelease/types.ts +59 -0
  251. package/apps/storefront/src/lib/publish/reviewRelease/viewModel.ts +440 -0
  252. package/apps/storefront/src/lib/publish/reviewReleaseWorkspace/actions.ts +161 -0
  253. package/apps/storefront/src/lib/publish/reviewReleaseWorkspace/controller.ts +325 -0
  254. package/apps/storefront/src/lib/publish/reviewReleaseWorkspace/render.ts +241 -0
  255. package/apps/storefront/src/lib/publish/shipWorkspace.ts +121 -51
  256. package/apps/storefront/src/lib/publish/sseRoute.ts +119 -0
  257. package/apps/storefront/src/lib/publish/stageBundleUpload.ts +215 -0
  258. package/apps/storefront/src/lib/publish/streamLogConsole.ts +142 -0
  259. package/apps/storefront/src/lib/publish/versionNumber.ts +52 -0
  260. package/apps/storefront/src/lib/rate/kvWindow.ts +53 -0
  261. package/apps/storefront/src/lib/rawChrome.ts +125 -47
  262. package/apps/storefront/src/lib/rawMarketingHtml.ts +74 -3
  263. package/apps/storefront/src/lib/search/index.ts +2 -2
  264. package/apps/storefront/src/lib/seo/alternates.ts +42 -0
  265. package/apps/storefront/src/lib/seo/meta.ts +65 -0
  266. package/apps/storefront/src/lib/social/golive.ts +212 -0
  267. package/apps/storefront/src/lib/social/notify.ts +32 -0
  268. package/apps/storefront/src/lib/social/tokenStore.ts +171 -0
  269. package/apps/storefront/src/lib/storyblok/content-model.ts +7 -33
  270. package/apps/storefront/src/lib/storyblok/provider.ts +168 -60
  271. package/apps/storefront/src/lib/subscription/model.ts +4 -4
  272. package/apps/storefront/src/lib/the-build/provider.ts +32 -0
  273. package/apps/storefront/src/lib/the-build/readingTime.ts +35 -0
  274. package/apps/storefront/src/lib/the-build/toc.ts +95 -0
  275. package/apps/storefront/src/lib/tot/ToTClient.ts +1 -1
  276. package/apps/storefront/src/lib/tot/d1Client.ts +2 -2
  277. package/apps/storefront/src/lib/tot/totClientInterface.ts +3 -4
  278. package/apps/storefront/src/lib/webhooks/deliveryStore.ts +16 -17
  279. package/apps/storefront/src/middleware/index.ts +385 -52
  280. package/apps/storefront/src/pages/[...slug].astro +9 -4
  281. package/apps/storefront/src/pages/admin/review-release.astro +265 -0
  282. package/apps/storefront/src/pages/admin/select.astro +96 -0
  283. package/apps/storefront/src/pages/admin.astro +25 -1313
  284. package/apps/storefront/src/pages/api/activity.ts +8 -8
  285. package/apps/storefront/src/pages/api/admin/activity-alerts.ts +5 -20
  286. package/apps/storefront/src/pages/api/admin/orders/[id].ts +7 -2
  287. package/apps/storefront/src/pages/api/admin/orders.ts +8 -2
  288. package/apps/storefront/src/pages/api/apps/admin/gtm-migration-install.ts +174 -0
  289. package/apps/storefront/src/pages/api/apps/admin/gtm-migration.ts +96 -0
  290. package/apps/storefront/src/pages/api/apps/admin/integration-lifecycle.ts +118 -0
  291. package/apps/storefront/src/pages/api/apps/admin/integrations.ts +89 -0
  292. package/apps/storefront/src/pages/api/apps/admin/platform-adapters.ts +85 -0
  293. package/apps/storefront/src/pages/api/apps/internal/order-forward.ts +74 -2
  294. package/apps/storefront/src/pages/api/blog/[collection]/[slug]/react.ts +104 -0
  295. package/apps/storefront/src/pages/api/commerce/checkout-handoff.ts +77 -0
  296. package/apps/storefront/src/pages/api/compliance/tamper.ts +88 -0
  297. package/apps/storefront/src/pages/api/integrations/v1/[operation].ts +108 -0
  298. package/apps/storefront/src/pages/api/newsletter/[collection]/subscribe.ts +146 -0
  299. package/apps/storefront/src/pages/api/newsletter/confirm.ts +75 -0
  300. package/apps/storefront/src/pages/api/newsletter/unsubscribe.ts +90 -0
  301. package/apps/storefront/src/pages/api/publish/stage-bundle.ts +70 -0
  302. package/apps/storefront/src/pages/api/rum/vitals.ts +20 -2
  303. package/apps/storefront/src/pages/blog/[slug].astro +99 -19
  304. package/apps/storefront/src/pages/blog/author/[author].astro +140 -0
  305. package/apps/storefront/src/pages/blog/category/[category].astro +67 -0
  306. package/apps/storefront/src/pages/blog/index.astro +4 -2
  307. package/apps/storefront/src/pages/blog/tag/[tag].astro +65 -0
  308. package/apps/storefront/src/pages/cockpit.astro +77 -1353
  309. package/apps/storefront/src/pages/dashboard/[appDomain]/team.astro +15 -11
  310. package/apps/storefront/src/pages/index.astro +10 -5
  311. package/apps/storefront/src/pages/llms.txt.ts +1 -1
  312. package/apps/storefront/src/pages/products/[handle].astro +7 -6
  313. package/apps/storefront/src/pages/search.astro +1 -1
  314. package/apps/storefront/src/pages/sitemap.xml.ts +21 -1
  315. package/apps/storefront/src/pages/style-guide/[tenant]/[theme].astro +31 -27
  316. package/apps/storefront/src/pages/style-guide/[tenant]/chrome/[theme].astro +1 -1
  317. package/apps/storefront/src/pages/tenants/[id]/[...path].ts +38 -2
  318. package/apps/storefront/src/pages/the-build/[slug].astro +129 -0
  319. package/apps/storefront/src/pages/the-build/index.astro +146 -0
  320. package/apps/storefront/src/pages/the-build/rss.xml.ts +33 -0
  321. package/apps/storefront/src/styles/admin.css +1106 -0
  322. package/apps/storefront/tsconfig.json +6 -1
  323. package/package.json +1 -1
  324. package/packages/public-runtime/package.json +3 -1
  325. package/packages/public-runtime/schemas/managed-analytics/v1/adapter-definition.schema.json +427 -0
  326. package/packages/public-runtime/schemas/managed-analytics/v1/create-integration-install-request.schema.json +161 -0
  327. package/packages/public-runtime/schemas/managed-analytics/v1/create-migration-draft-request.schema.json +157 -0
  328. package/packages/public-runtime/schemas/managed-analytics/v1/delete-integration-install-request.schema.json +84 -0
  329. package/packages/public-runtime/schemas/managed-analytics/v1/delete-migration-draft-request.schema.json +84 -0
  330. package/packages/public-runtime/schemas/managed-analytics/v1/error-envelope.schema.json +180 -0
  331. package/packages/public-runtime/schemas/managed-analytics/v1/get-adapter-definition-request.schema.json +52 -0
  332. package/packages/public-runtime/schemas/managed-analytics/v1/get-integration-install-request.schema.json +52 -0
  333. package/packages/public-runtime/schemas/managed-analytics/v1/get-integration-revision-request.schema.json +79 -0
  334. package/packages/public-runtime/schemas/managed-analytics/v1/get-migration-draft-request.schema.json +52 -0
  335. package/packages/public-runtime/schemas/managed-analytics/v1/integration-install.schema.json +167 -0
  336. package/packages/public-runtime/schemas/managed-analytics/v1/integration-revision.schema.json +208 -0
  337. package/packages/public-runtime/schemas/managed-analytics/v1/list-adapter-definitions-request.schema.json +53 -0
  338. package/packages/public-runtime/schemas/managed-analytics/v1/list-integration-installs-request.schema.json +53 -0
  339. package/packages/public-runtime/schemas/managed-analytics/v1/list-integration-revisions-request.schema.json +82 -0
  340. package/packages/public-runtime/schemas/managed-analytics/v1/migration-draft.schema.json +218 -0
  341. package/packages/public-runtime/schemas/managed-analytics/v1/mutation-request.schema.json +52 -0
  342. package/packages/public-runtime/schemas/managed-analytics/v1/mutation-success-envelope.schema.json +49 -0
  343. package/packages/public-runtime/schemas/managed-analytics/v1/read-request.schema.json +20 -0
  344. package/packages/public-runtime/schemas/managed-analytics/v1/read-success-envelope.schema.json +45 -0
  345. package/packages/public-runtime/schemas/managed-analytics/v1/revise-integration-install-request.schema.json +156 -0
  346. package/packages/public-runtime/schemas/managed-analytics/v1/set-integration-install-status-request.schema.json +92 -0
  347. package/packages/public-runtime/schemas/managed-analytics/v1/update-migration-draft-request.schema.json +184 -0
  348. package/packages/public-runtime/scripts/generate-managed-analytics-api-v1-schemas.mjs +13 -0
  349. package/packages/public-runtime/src/activity/catalog.ts +89 -33
  350. package/packages/public-runtime/src/activity/event.ts +6 -6
  351. package/packages/public-runtime/src/activity/index.ts +2 -2
  352. package/packages/public-runtime/src/activity/redaction.ts +4 -4
  353. package/packages/public-runtime/src/candidate-index.ts +42 -8
  354. package/packages/public-runtime/src/catalog-d1.ts +1 -1
  355. package/packages/public-runtime/src/checkout-orders.ts +2 -2
  356. package/packages/public-runtime/src/checkout-style-publish.ts +2 -2
  357. package/packages/public-runtime/src/checkout-style.ts +7 -7
  358. package/packages/public-runtime/src/checkout.ts +3 -3
  359. package/packages/public-runtime/src/chrome.ts +777 -0
  360. package/packages/public-runtime/src/compliance-obligations.ts +310 -0
  361. package/packages/public-runtime/src/csp.ts +99 -0
  362. package/packages/public-runtime/src/customization-preview.ts +25 -2
  363. package/packages/public-runtime/src/customization-runtime.ts +156 -3
  364. package/packages/public-runtime/src/customization-versioning.ts +10 -0
  365. package/packages/public-runtime/src/destination-webhook/contract.ts +353 -0
  366. package/packages/public-runtime/src/embed-catalog.d.mts +9 -0
  367. package/packages/public-runtime/src/embed-catalog.mjs +40 -0
  368. package/packages/public-runtime/src/evidence.ts +288 -0
  369. package/packages/public-runtime/src/gtm-migration/bounds.ts +138 -0
  370. package/packages/public-runtime/src/gtm-migration/disposition-rules.ts +361 -0
  371. package/packages/public-runtime/src/gtm-migration/dispositions.ts +181 -0
  372. package/packages/public-runtime/src/gtm-migration/draft-generator.ts +400 -0
  373. package/packages/public-runtime/src/gtm-migration/graph.ts +468 -0
  374. package/packages/public-runtime/src/gtm-migration/index.ts +95 -0
  375. package/packages/public-runtime/src/gtm-migration/parse.ts +410 -0
  376. package/packages/public-runtime/src/gtm-migration/references.ts +266 -0
  377. package/packages/public-runtime/src/gtm-migration/types.ts +86 -0
  378. package/packages/public-runtime/src/index.ts +17 -1
  379. package/packages/public-runtime/src/integration/assurance-decision.ts +259 -0
  380. package/packages/public-runtime/src/integration/assurance.ts +228 -0
  381. package/packages/public-runtime/src/integration/candidate-evidence.ts +377 -0
  382. package/packages/public-runtime/src/integration/commerce-broker.ts +497 -0
  383. package/packages/public-runtime/src/integration/consent-broker.ts +337 -0
  384. package/packages/public-runtime/src/integration/consent-cmp-demand.ts +115 -0
  385. package/packages/public-runtime/src/integration/consent-config.ts +260 -0
  386. package/packages/public-runtime/src/integration/consent-preview.ts +125 -0
  387. package/packages/public-runtime/src/integration/correlation-token.ts +444 -0
  388. package/packages/public-runtime/src/integration/csp-compiler.ts +267 -0
  389. package/packages/public-runtime/src/integration/csp.ts +105 -0
  390. package/packages/public-runtime/src/integration/digest.ts +43 -0
  391. package/packages/public-runtime/src/integration/environment.ts +228 -0
  392. package/packages/public-runtime/src/integration/events-catalog.ts +186 -0
  393. package/packages/public-runtime/src/integration/events.ts +701 -0
  394. package/packages/public-runtime/src/integration/g2-action-boundary.ts +106 -0
  395. package/packages/public-runtime/src/integration/index.ts +90 -0
  396. package/packages/public-runtime/src/integration/interim-bridge.ts +138 -0
  397. package/packages/public-runtime/src/integration/lifecycle-boot.ts +317 -0
  398. package/packages/public-runtime/src/integration/lifecycle-runtime.ts +393 -0
  399. package/packages/public-runtime/src/integration/lifecycle.ts +94 -0
  400. package/packages/public-runtime/src/integration/managed-analytics-api-v1-safety.d.mts +2 -0
  401. package/packages/public-runtime/src/integration/managed-analytics-api-v1-safety.mjs +10 -0
  402. package/packages/public-runtime/src/integration/managed-analytics-api-v1.schemas.ts +382 -0
  403. package/packages/public-runtime/src/integration/managed-analytics-api-v1.ts +684 -0
  404. package/packages/public-runtime/src/integration/managed-analytics-bridge.ts +383 -0
  405. package/packages/public-runtime/src/integration/managed-analytics-value-safety.ts +14 -0
  406. package/packages/public-runtime/src/integration/managed-analytics.ts +277 -0
  407. package/packages/public-runtime/src/integration/manifest.ts +470 -0
  408. package/packages/public-runtime/src/integration/native-amplitude.ts +362 -0
  409. package/packages/public-runtime/src/integration/native-ga4.ts +352 -0
  410. package/packages/public-runtime/src/integration/observability.ts +451 -0
  411. package/packages/public-runtime/src/integration/order-conversion.ts +0 -0
  412. package/packages/public-runtime/src/integration/phases.ts +182 -0
  413. package/packages/public-runtime/src/integration/plan.ts +112 -0
  414. package/packages/public-runtime/src/integration/platform-adapter-runtime.ts +146 -0
  415. package/packages/public-runtime/src/integration/platform-adapters.ts +671 -0
  416. package/packages/public-runtime/src/integration/promotion-gate.ts +451 -0
  417. package/packages/public-runtime/src/integration/provider-checkout-extension.ts +425 -0
  418. package/packages/public-runtime/src/integration/receipt-measurement.ts +370 -0
  419. package/packages/public-runtime/src/integration/regulated-parent-cert.ts +311 -0
  420. package/packages/public-runtime/src/integration/render-phases.ts +267 -0
  421. package/packages/public-runtime/src/integration/resolve.ts +465 -0
  422. package/packages/public-runtime/src/integration/result.ts +239 -0
  423. package/packages/public-runtime/src/integration/secrets.ts +92 -0
  424. package/packages/public-runtime/src/integration/tamper-evidence.ts +205 -0
  425. package/packages/public-runtime/src/integration/tamper-recovery.ts +127 -0
  426. package/packages/public-runtime/src/integration/version.ts +92 -0
  427. package/packages/public-runtime/src/integration-capabilities.ts +520 -0
  428. package/packages/public-runtime/src/membership.ts +2 -2
  429. package/packages/public-runtime/src/raw-html-policy.ts +2 -4
  430. package/packages/public-runtime/src/regulated-commerce/broker/consent-dedupe.ts +144 -0
  431. package/packages/public-runtime/src/regulated-commerce/correlation/contract.ts +177 -0
  432. package/packages/public-runtime/src/regulated-commerce/diagnostics/local-dispatch.ts +24 -0
  433. package/packages/public-runtime/src/regulated-commerce/diagnostics/read-model.ts +69 -0
  434. package/packages/public-runtime/src/regulated-commerce/dispatch/core.ts +134 -0
  435. package/packages/public-runtime/src/regulated-commerce/events/contract.ts +113 -0
  436. package/packages/public-runtime/src/regulated-commerce/ledger/core.ts +81 -0
  437. package/packages/public-runtime/src/regulated-commerce/mappings/ga4-ads.ts +87 -0
  438. package/packages/public-runtime/src/regulated-commerce/provider-order/bridge.ts +52 -0
  439. package/packages/public-runtime/src/regulated-commerce/purchase-truth/contract.ts +252 -0
  440. package/packages/public-runtime/src/regulated-commerce/sources/accepted-browser-operation.ts +67 -0
  441. package/packages/public-runtime/src/regulated-commerce/testing/fake-destination.ts +93 -0
  442. package/packages/public-runtime/src/static-bundle.ts +357 -0
  443. package/packages/public-runtime/src/tenant-assets.ts +143 -4
  444. package/packages/public-runtime/src/tenant.ts +81 -17
  445. package/packages/public-runtime/tests/fixtures/integration/browser-environment.example.json +8 -0
  446. package/packages/public-runtime/tests/fixtures/integration/commerce-event.example.json +44 -0
  447. package/packages/public-runtime/tests/fixtures/integration/commerce-order-event.example.json +44 -0
  448. package/packages/public-runtime/tests/fixtures/integration/compliance-assurance-record.example.json +50 -0
  449. package/packages/public-runtime/tests/fixtures/integration/integration-manifest-v2.example.json +120 -0
  450. package/packages/public-runtime/tests/fixtures/integration/managed-analytics-v1/fake-adapter-catalog.json +35 -0
  451. package/packages/public-runtime/tests/fixtures/integration/tenant-action-registry.example.json +11 -0
  452. package/packages/public-runtime/tests/fixtures/integration/tenant-local-example/README.md +22 -0
  453. package/packages/public-runtime/tests/fixtures/integration/tenant-local-example/entry.js +30 -0
  454. package/packages/public-runtime/tests/fixtures/integration/tenant-local-example/manifest.json +75 -0
  455. package/packages/public-runtime/tests/fixtures/integration/tenant-local-example/public-config.json +3 -0
  456. package/packages/public-runtime/tests/fixtures/regulated-commerce/fake-destinations.ts +38 -0
  457. package/packages/public-runtime/tests/gtm-migration/fixtures/gtm-sample-container-v84.provenance.json +29 -0
  458. package/packages/public-runtime/tests/gtm-migration/fixtures/gtm-sample-container-v84.redacted.json +3397 -0
  459. package/scripts/build/copy-tenant-assets.mjs +14 -4
  460. package/scripts/dev/ai-edit.mjs +1 -1
  461. package/scripts/dev/checkout-watch.mjs +2 -2
  462. package/scripts/dev/file-browser.mjs +4 -6
  463. package/scripts/dev/file-writer.mjs +3 -3
  464. package/scripts/dev/git-status.mjs +2 -2
  465. package/scripts/dev/integration-guardrails.mjs +498 -0
  466. package/scripts/dev/locate-handler.mjs +3 -3
  467. package/scripts/dev/port-check.mjs +3 -3
  468. package/scripts/dev/publish.mjs +5 -9
  469. package/scripts/dev/safe-path.mjs +2 -2
  470. package/scripts/dev/shot.mjs +1 -1
  471. package/scripts/dev/tenant-source-root.mjs +1 -1
  472. package/scripts/dev/unified-diff.mjs +8 -3
  473. package/scripts/tot-dev.mjs +8 -11
  474. package/apps/storefront/src/lib/dev/vcBinding.ts +0 -80
@@ -0,0 +1,16 @@
1
+ /** Shared fake/local state contract for one composed v84 clean-clone pass. */
2
+ export const V84_REPLAY_SESSION_ID = "offline-v84-shared-clone-session" as const;
3
+ export const V84_REPLAY_CLONE_TENANT = "tokenoftrust.com~clone~gtm-migration-v84" as const;
4
+
5
+ export interface V84CleanCloneReplayContext {
6
+ readonly sessionId: typeof V84_REPLAY_SESSION_ID;
7
+ readonly cloneTenant: typeof V84_REPLAY_CLONE_TENANT;
8
+ read<T>(key: string): T | undefined;
9
+ write(key: string, value: unknown): void;
10
+ delete(key: string): void;
11
+ keys(prefix?: string): readonly string[];
12
+ }
13
+
14
+ export function sameV84ReplayValue(left: unknown, right: unknown): boolean {
15
+ return JSON.stringify(left) === JSON.stringify(right);
16
+ }
@@ -0,0 +1,105 @@
1
+ /** Clone-only cold/warm cache evidence over local managed-install state. */
2
+ import { getCachedPage, pageCacheKey, putCachedPage } from "../edgeCache.js";
3
+ import type { V84DisabledInstallMaterializationResult } from "./v84CloneLifecycleMaterialization.js";
4
+ import {
5
+ V84_NATIVE_CLONE_TENANT,
6
+ V84_NATIVE_SOURCE_TENANT,
7
+ } from "./v84CloneNativeInstallEvidence.js";
8
+ import type { V84CleanCloneReplayContext } from "./v84CleanCloneReplayContext.js";
9
+
10
+ const CACHE_BODY = "<!-- offline v84 lifecycle cache artifact; no integration markup -->";
11
+ const INTEGRATION_MARKUP = /<script|dataLayer|googletagmanager|GTM-|\beval\s*\(/i;
12
+
13
+ function fakeCache(replayContext?: V84CleanCloneReplayContext) {
14
+ const store = new Map<string, Response>();
15
+ const reads: string[] = [];
16
+ const writes: string[] = [];
17
+ const cache = {
18
+ async match(request: Request) {
19
+ reads.push(request.url);
20
+ if (replayContext) {
21
+ const found = replayContext.read<{
22
+ body: string;
23
+ headers: Record<string, string>;
24
+ status: number;
25
+ }>(`stage/lifecycle/cache/${encodeURIComponent(request.url)}`);
26
+ return found ? new Response(found.body, { headers: found.headers, status: found.status }) : undefined;
27
+ }
28
+ return store.get(request.url)?.clone();
29
+ },
30
+ async put(request: Request, response: Response) {
31
+ writes.push(request.url);
32
+ if (replayContext) {
33
+ replayContext.write(`stage/lifecycle/cache/${encodeURIComponent(request.url)}`, {
34
+ body: await response.clone().text(),
35
+ headers: Object.fromEntries(response.headers.entries()),
36
+ status: response.status,
37
+ });
38
+ return;
39
+ }
40
+ store.set(request.url, response.clone());
41
+ },
42
+ } as unknown as Cache;
43
+ return { cache, reads, writes };
44
+ }
45
+
46
+ /** Exercise a true cold miss and warm clone-only hit without touching source keys. */
47
+ export async function buildV84CloneCacheEvidence(
48
+ materialization: V84DisabledInstallMaterializationResult,
49
+ replayContext?: V84CleanCloneReplayContext,
50
+ ) {
51
+ const memory = fakeCache(replayContext);
52
+ const disabledCacheKeyBefore = pageCacheKey(
53
+ V84_NATIVE_CLONE_TENANT,
54
+ "/v84-lifecycle",
55
+ "",
56
+ 1,
57
+ materialization.candidatePlanBefore.planRevision,
58
+ );
59
+ const cloneCacheKey = pageCacheKey(
60
+ V84_NATIVE_CLONE_TENANT,
61
+ "/v84-lifecycle",
62
+ "",
63
+ 1,
64
+ materialization.candidatePlanAfter.planRevision,
65
+ );
66
+ const sourceCacheKey = pageCacheKey(V84_NATIVE_SOURCE_TENANT, "/v84-lifecycle", "", 1);
67
+ const cold = await getCachedPage(memory.cache, cloneCacheKey);
68
+ await putCachedPage(memory.cache, cloneCacheKey, new Response(CACHE_BODY, {
69
+ status: 200,
70
+ headers: { "content-type": "text/html; charset=utf-8" },
71
+ }));
72
+ const warm = await getCachedPage(memory.cache, cloneCacheKey);
73
+ const warmBody = warm ? await warm.text() : "";
74
+ if (
75
+ cold !== null ||
76
+ !warm ||
77
+ warmBody !== CACHE_BODY ||
78
+ warm.headers.get("x-tot-cache") !== "hit" ||
79
+ disabledCacheKeyBefore.url !== cloneCacheKey.url ||
80
+ INTEGRATION_MARKUP.test(warmBody)
81
+ ) {
82
+ throw new Error("The clone-local warm-cache proof failed.");
83
+ }
84
+ if (memory.reads.includes(sourceCacheKey.url) || memory.writes.includes(sourceCacheKey.url)) {
85
+ throw new Error("The warm-cache proof touched the source namespace.");
86
+ }
87
+
88
+ return {
89
+ warmCache: {
90
+ tenant: V84_NATIVE_CLONE_TENANT,
91
+ coldMiss: true,
92
+ warmHit: true,
93
+ cloneWriteCount: memory.writes.length,
94
+ sourceReadCount: memory.reads.filter((url) => url === sourceCacheKey.url).length,
95
+ sourceWriteCount: memory.writes.filter((url) => url === sourceCacheKey.url).length,
96
+ managedInstallStateChanged: materialization.managedInstallStateChanged,
97
+ effectivePlanChanged:
98
+ materialization.candidatePlanBefore.planRevision !== materialization.candidatePlanAfter.planRevision,
99
+ disabledDraftsChangedCacheKey: disabledCacheKeyBefore.url !== cloneCacheKey.url,
100
+ artifactContainsIntegrationMarkup: INTEGRATION_MARKUP.test(warmBody),
101
+ },
102
+ cloneCacheReads: memory.reads.length,
103
+ cloneCacheWrites: memory.writes.length,
104
+ };
105
+ }
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Exact-clone, offline lifecycle validation composed from public product seams.
3
+ *
4
+ * It consumes the already-reviewed native-install evidence, then exercises only
5
+ * public-value environment, consent, semantic-event, lifecycle-bridge, and cache
6
+ * contracts. It has no renderer, integration loader, destination runtime, network,
7
+ * persistence, GTM, eval, or publish authority.
8
+ */
9
+ import {
10
+ APPROVED_MARKETING_ACTION_NAMES,
11
+ planCacheIdentity,
12
+ sha256Hex,
13
+ snapshotManagedAnalyticsDeclarativeInput,
14
+ stableIntegrationStringify,
15
+ } from "@tot/public-runtime";
16
+ import { buildV84CloneCacheEvidence } from "./v84CloneLifecycleCacheEvidence.js";
17
+ import {
18
+ validateV84DisabledInstallMaterialization,
19
+ type V84LifecycleMaterializationDependencies,
20
+ } from "./v84CloneLifecycleMaterialization.js";
21
+ import { buildV84CloneLifecycleSemantics } from "./v84CloneLifecycleSemantics.js";
22
+ import {
23
+ V84_NATIVE_CLONE_TENANT,
24
+ V84_NATIVE_SOURCE_TENANT,
25
+ V84_WS1_API_CONTRACT,
26
+ V84_WS1_FINAL,
27
+ V84_WS2_EVIDENCE_SHA256,
28
+ V84_WS2_FINAL,
29
+ type V84NativeInstallEvidence,
30
+ } from "./v84CloneNativeInstallEvidence.js";
31
+ import {
32
+ sameV84ReplayValue,
33
+ type V84CleanCloneReplayContext,
34
+ } from "./v84CleanCloneReplayContext.js";
35
+
36
+ /** SHA-256 of the full canonical native-install evidence accepted by this unit. */
37
+ export const V84_NATIVE_INSTALL_EVIDENCE_SHA256 = "d479a8b07cdde0808c75abea7410c7f1c685ed8d79f5e62f21a6261d1087eda8" as const;
38
+
39
+ function assertNativeEvidence(evidence: V84NativeInstallEvidence): void {
40
+ if (
41
+ evidence.scope.sourceTenant !== V84_NATIVE_SOURCE_TENANT ||
42
+ evidence.scope.sourceMode !== "read-only" ||
43
+ evidence.scope.cloneTenant !== V84_NATIVE_CLONE_TENANT ||
44
+ evidence.scope.destinationMode !== "offline-in-memory-fake-only" ||
45
+ evidence.contractPins.ws1Final !== V84_WS1_FINAL ||
46
+ evidence.contractPins.ws1ApiContract !== V84_WS1_API_CONTRACT ||
47
+ evidence.contractPins.ws2Final !== V84_WS2_FINAL ||
48
+ evidence.contractPins.ws2EvidenceSha256 !== V84_WS2_EVIDENCE_SHA256 ||
49
+ evidence.installations.length !== 2 ||
50
+ evidence.installations.some((item) =>
51
+ item.desired.installStatus !== "disabled" ||
52
+ item.desired.revisionStatus !== "draft" ||
53
+ item.effective.activeRevisionId !== null ||
54
+ item.effective.materialized !== false
55
+ ) ||
56
+ stableIntegrationStringify(evidence.semanticActions) !==
57
+ stableIntegrationStringify(APPROVED_MARKETING_ACTION_NAMES) ||
58
+ evidence.operationCounts.reviseIntegrationInstall !== 0 ||
59
+ evidence.operationCounts.setIntegrationInstallStatus !== 0 ||
60
+ evidence.operationCounts.publish !== 0 ||
61
+ evidence.safety.sourceMutationCount !== 0 ||
62
+ evidence.safety.liveDestinationCount !== 0 ||
63
+ evidence.safety.externalNetworkRequestCount !== 0 ||
64
+ evidence.safety.importedCodeExecuted ||
65
+ evidence.safety.runtimeLoaded ||
66
+ evidence.safety.lifecycle !== "reviewed-disabled-draft-only"
67
+ ) {
68
+ throw new Error("The supplied native-install evidence is outside the exact disabled v84 proof.");
69
+ }
70
+ }
71
+
72
+ /** Build deterministic, sanitized evidence. Every delivery remains an in-memory callback. */
73
+ export async function buildV84CloneLifecycleEvidence(
74
+ unsafeNativeEvidence: unknown,
75
+ materializationDependencies?: V84LifecycleMaterializationDependencies,
76
+ replayContext?: V84CleanCloneReplayContext,
77
+ ) {
78
+ const snapshot = snapshotManagedAnalyticsDeclarativeInput<V84NativeInstallEvidence>(unsafeNativeEvidence);
79
+ if (!snapshot.ok) throw new Error("The native-install evidence could not be snapshotted safely.");
80
+ const nativeEvidence = snapshot.value;
81
+ assertNativeEvidence(nativeEvidence);
82
+ if (replayContext && !sameV84ReplayValue(
83
+ replayContext.read<V84NativeInstallEvidence>("stage/native/handoff"),
84
+ nativeEvidence,
85
+ )) {
86
+ throw new Error("The lifecycle proof did not receive the shared native handoff.");
87
+ }
88
+ const nativeEvidenceSha256 = await sha256Hex(stableIntegrationStringify(nativeEvidence));
89
+ if (nativeEvidenceSha256 !== V84_NATIVE_INSTALL_EVIDENCE_SHA256) {
90
+ throw new Error("The supplied native-install evidence does not match the pinned exact proof.");
91
+ }
92
+
93
+ const semantics = buildV84CloneLifecycleSemantics();
94
+ const materialization = await validateV84DisabledInstallMaterialization(
95
+ nativeEvidence.installations,
96
+ semantics.candidateEnvironment,
97
+ semantics.stagedEnvironment,
98
+ materializationDependencies,
99
+ replayContext,
100
+ );
101
+ const candidatePlan = materialization.candidatePlanAfter;
102
+ const stagedPlan = materialization.stagedPlanAfter;
103
+ const cache = await buildV84CloneCacheEvidence(materialization, replayContext);
104
+
105
+ const evidence = {
106
+ schemaVersion: 1 as const,
107
+ scope: {
108
+ sourceTenant: V84_NATIVE_SOURCE_TENANT,
109
+ sourceMode: "read-only" as const,
110
+ cloneTenant: V84_NATIVE_CLONE_TENANT,
111
+ destinationMode: "offline-in-memory-callback-only" as const,
112
+ environments: ["candidate", "staged"] as const,
113
+ },
114
+ contractPins: {
115
+ ws1Final: V84_WS1_FINAL,
116
+ ws1ApiContract: V84_WS1_API_CONTRACT,
117
+ ws2Final: V84_WS2_FINAL,
118
+ ws2EvidenceSha256: V84_WS2_EVIDENCE_SHA256,
119
+ nativeInstallEvidenceSha256: nativeEvidenceSha256,
120
+ },
121
+ disabledDrafts: {
122
+ count: nativeEvidence.installations.length,
123
+ statuses: nativeEvidence.installations.map(({ desired }) => ({
124
+ install: desired.installStatus,
125
+ revision: desired.revisionStatus,
126
+ })),
127
+ activeRevisionCount: nativeEvidence.installations.filter(({ effective }) => effective.activeRevisionId !== null).length,
128
+ materializedCount: candidatePlan.integrations.length + stagedPlan.integrations.length,
129
+ materializedDeclarationCount: materialization.materializedDeclarationCount,
130
+ materializedAssetCount: materialization.materializedAssetCount,
131
+ readModelUnmaterializedCount: materialization.readModelUnmaterializedCount,
132
+ lifecycleRefusalCount: materialization.lifecycleRefusalCount,
133
+ lifecycleMutationCount: materialization.lifecycleMutationCount,
134
+ },
135
+ environment: {
136
+ candidate: semantics.candidateEnvironment,
137
+ staged: semantics.stagedEnvironment,
138
+ candidatePlanIdentity: planCacheIdentity(candidatePlan),
139
+ stagedPlanIdentity: planCacheIdentity(stagedPlan),
140
+ distinctPlanIdentities: planCacheIdentity(candidatePlan) !== planCacheIdentity(stagedPlan),
141
+ liveEnvironmentCount: 0,
142
+ },
143
+ consent: semantics.consent,
144
+ lifecycle: semantics.lifecycle,
145
+ routes: semantics.routes,
146
+ actions: semantics.actions,
147
+ warmCache: cache.warmCache,
148
+ operationCounts: {
149
+ sourceReads: 0,
150
+ sourceWrites: 0,
151
+ managedMaterializationReads: materialization.materializationReadCount,
152
+ managedReadModelAssemblies: materialization.readModelAssemblyCount,
153
+ managedLifecycleLoads: materialization.lifecycleLoadCount,
154
+ cloneCacheReads: cache.cloneCacheReads,
155
+ cloneCacheWrites: cache.cloneCacheWrites,
156
+ inMemoryEventDeliveries: semantics.inMemoryEventDeliveries,
157
+ externalNetworkRequests: 0,
158
+ lifecycleMutations: 0,
159
+ publishes: 0,
160
+ },
161
+ safety: {
162
+ importedCodeExecuted: false,
163
+ rendererCalled: false,
164
+ integrationLifecycleRuntimeInitialized: false,
165
+ nativeDestinationRuntimeInvoked: false,
166
+ gtmLoaded: false,
167
+ markupEvaluated: false,
168
+ externalNetworkUsed: false,
169
+ liveSecretUsed: false,
170
+ productionUsed: false,
171
+ sourceMutated: false,
172
+ diagnosticsCarryDestinationValues: false,
173
+ },
174
+ };
175
+ replayContext?.write("stage/lifecycle/handoff", evidence);
176
+ return evidence;
177
+ }
@@ -0,0 +1,251 @@
1
+ /**
2
+ * Fake/local adapter that proves disabled managed-install rows remain absent from
3
+ * the real declaration, admin read-model, and lifecycle seams.
4
+ */
5
+ import {
6
+ resolveEffectivePlan,
7
+ stableIntegrationStringify,
8
+ type BrowserEnvironment,
9
+ type EffectivePlan,
10
+ type IntegrationDeclarationInput,
11
+ } from "@tot/public-runtime";
12
+ import type { Queryable } from "../d1/catalog.js";
13
+ import { loadActiveManagedInstallDeclarations } from "../integration/managedInstallDeclarations.js";
14
+ import { assembleIntegrationReadModel } from "./integrationReadModel.js";
15
+ import { handleLifecycleRequest } from "./integrationLifecycleController.js";
16
+ import {
17
+ V84_NATIVE_CLONE_TENANT,
18
+ type V84NativeInstallEvidence,
19
+ } from "./v84CloneNativeInstallEvidence.js";
20
+ import type { V84CleanCloneReplayContext } from "./v84CleanCloneReplayContext.js";
21
+
22
+ type NativeInstall = V84NativeInstallEvidence["installations"][number];
23
+
24
+ interface LocalManagedRow {
25
+ readonly install_id: string;
26
+ readonly tenant_id: string;
27
+ readonly managed_kind: "managed-analytics-v1";
28
+ readonly status: "suspended";
29
+ readonly app_id: string;
30
+ readonly app_version: string;
31
+ readonly manifest: "{}";
32
+ readonly revision_status: "draft";
33
+ }
34
+
35
+ export interface V84LifecycleMaterializationDependencies {
36
+ readonly loadDeclarations: typeof loadActiveManagedInstallDeclarations;
37
+ }
38
+
39
+ const dependencies: V84LifecycleMaterializationDependencies = {
40
+ loadDeclarations: loadActiveManagedInstallDeclarations,
41
+ };
42
+
43
+ function resolvePlan(
44
+ environment: BrowserEnvironment,
45
+ declarations: readonly IntegrationDeclarationInput[],
46
+ ): EffectivePlan {
47
+ const result = resolveEffectivePlan({
48
+ tenantPublicId: V84_NATIVE_CLONE_TENANT,
49
+ environment,
50
+ declarations,
51
+ });
52
+ if (!result.ok) throw new Error("The local managed-install plan failed safely.");
53
+ return result.value;
54
+ }
55
+
56
+ function localRows(installations: readonly NativeInstall[]): LocalManagedRow[] {
57
+ return installations.map((install, index) => ({
58
+ install_id: `v84-local-managed-${index + 1}`,
59
+ tenant_id: V84_NATIVE_CLONE_TENANT,
60
+ managed_kind: "managed-analytics-v1",
61
+ status: "suspended",
62
+ app_id: install.adapterId,
63
+ app_version: install.adapterVersion,
64
+ manifest: "{}",
65
+ revision_status: install.desired.revisionStatus,
66
+ }));
67
+ }
68
+
69
+ /** Minimal local Queryable that executes the materializer's active-row predicate. */
70
+ function localManagedInstallDb(rows: readonly LocalManagedRow[]): Queryable {
71
+ const unexpected = async (): Promise<never> => {
72
+ throw new Error("The disabled managed-install proof reached an unexpected persistence operation.");
73
+ };
74
+ return {
75
+ all: async <T>(sql: string, ...params: unknown[]) => {
76
+ const normalized = sql.replace(/\s+/g, " ").trim();
77
+ if (
78
+ !normalized.includes("FROM app_installs") ||
79
+ !normalized.includes("tenant_id = ?") ||
80
+ !normalized.includes("managed_kind = ?") ||
81
+ !normalized.includes("status = 'active'") ||
82
+ params.length !== 2
83
+ ) {
84
+ throw new Error("The managed-install materializer widened its active-row boundary.");
85
+ }
86
+ const [tenantId, managedKind] = params;
87
+ return rows
88
+ .filter((row) =>
89
+ row.tenant_id === tenantId &&
90
+ row.managed_kind === managedKind &&
91
+ row.status === ("active" as string)
92
+ )
93
+ .map(({ install_id, app_id, app_version, manifest }) => ({
94
+ install_id,
95
+ app_id,
96
+ app_version,
97
+ manifest,
98
+ })) as T[];
99
+ },
100
+ first: unexpected,
101
+ run: unexpected,
102
+ exec: unexpected,
103
+ };
104
+ }
105
+
106
+ export interface V84DisabledInstallMaterializationResult {
107
+ readonly candidatePlanBefore: EffectivePlan;
108
+ readonly candidatePlanAfter: EffectivePlan;
109
+ readonly stagedPlanAfter: EffectivePlan;
110
+ readonly managedInstallStateChanged: true;
111
+ readonly readModelUnmaterializedCount: 2;
112
+ readonly lifecycleRefusalCount: 2;
113
+ readonly materializedDeclarationCount: 0;
114
+ readonly materializedAssetCount: 0;
115
+ readonly materializationReadCount: 2;
116
+ readonly readModelAssemblyCount: 1;
117
+ readonly lifecycleLoadCount: 2;
118
+ readonly lifecycleMutationCount: 0;
119
+ }
120
+
121
+ /**
122
+ * Exercise the actual managed-install declaration loader, admin read model, and
123
+ * lifecycle controller over local rows derived from the canonical install output.
124
+ */
125
+ export async function validateV84DisabledInstallMaterialization(
126
+ installations: readonly NativeInstall[],
127
+ candidateEnvironment: BrowserEnvironment,
128
+ stagedEnvironment: BrowserEnvironment,
129
+ deps: V84LifecycleMaterializationDependencies = dependencies,
130
+ replayContext?: V84CleanCloneReplayContext,
131
+ ): Promise<V84DisabledInstallMaterializationResult> {
132
+ const localBeforeRows: readonly LocalManagedRow[] = [];
133
+ const localAfterRows = localRows(installations);
134
+ if (replayContext) {
135
+ replayContext.write("stage/lifecycle/materialization/before", localBeforeRows);
136
+ replayContext.write("stage/lifecycle/materialization/after", localAfterRows);
137
+ }
138
+ const beforeRows = replayContext
139
+ ? replayContext.read<readonly LocalManagedRow[]>("stage/lifecycle/materialization/before") ?? []
140
+ : localBeforeRows;
141
+ const afterRows = replayContext
142
+ ? replayContext.read<readonly LocalManagedRow[]>("stage/lifecycle/materialization/after") ?? []
143
+ : localAfterRows;
144
+ if (
145
+ afterRows.length !== 2 ||
146
+ afterRows.some((row) => row.status !== "suspended" || row.revision_status !== "draft") ||
147
+ stableIntegrationStringify(beforeRows) === stableIntegrationStringify(afterRows)
148
+ ) {
149
+ throw new Error("The local disabled managed-install state was not exact.");
150
+ }
151
+
152
+ let materializationReadCount = 0;
153
+ const loadDeclarations = async (db: Queryable) => {
154
+ materializationReadCount += 1;
155
+ return deps.loadDeclarations(db, V84_NATIVE_CLONE_TENANT);
156
+ };
157
+ const beforeDeclarations = await loadDeclarations(
158
+ localManagedInstallDb(beforeRows),
159
+ );
160
+ const afterDeclarations = await loadDeclarations(
161
+ localManagedInstallDb(afterRows),
162
+ );
163
+ if (beforeDeclarations.length !== 0 || afterDeclarations.length !== 0) {
164
+ throw new Error("A disabled draft was treated as a materializable managed install.");
165
+ }
166
+
167
+ const candidatePlanBefore = resolvePlan(candidateEnvironment, beforeDeclarations);
168
+ const candidatePlanAfter = resolvePlan(candidateEnvironment, afterDeclarations);
169
+ const stagedPlanAfter = resolvePlan(stagedEnvironment, afterDeclarations);
170
+ let readModelAssemblyCount = 0;
171
+ readModelAssemblyCount += 1;
172
+ const readModel = assembleIntegrationReadModel({
173
+ tenantPublicId: V84_NATIVE_CLONE_TENANT,
174
+ stage: "candidate",
175
+ items: afterRows.map((row) => ({
176
+ install: {
177
+ installId: row.install_id,
178
+ appId: row.app_id,
179
+ appVersion: row.app_version,
180
+ tenantId: row.tenant_id,
181
+ status: row.status,
182
+ },
183
+ purpose: "Reviewed managed analytics destination.",
184
+ desiredConfig: { destinationConfigured: true },
185
+ declaredTier: "platform-adapter",
186
+ effectivePlan: null,
187
+ effectiveCsp: null,
188
+ consentSnapshot: null,
189
+ candidate: null,
190
+ knownGood: null,
191
+ })),
192
+ });
193
+ if (
194
+ !readModel.ok ||
195
+ readModel.value.items.length !== 2 ||
196
+ readModel.value.items.some((item) => item.effective !== null || !item.drift.unmaterialized)
197
+ ) {
198
+ throw new Error("The disabled managed-install read model materialized an effective state.");
199
+ }
200
+
201
+ let lifecycleMutationCount = 0;
202
+ let lifecycleRefusalCount = 0;
203
+ let lifecycleLoadCount = 0;
204
+ for (const row of afterRows) {
205
+ const response = await handleLifecycleRequest({
206
+ load: async () => { lifecycleLoadCount += 1; return null; },
207
+ save: async () => { lifecycleMutationCount += 1; },
208
+ resolveCandidateEvidence: async () => {
209
+ throw new Error("An unmaterialized disabled install must not resolve candidate evidence.");
210
+ },
211
+ resolveGate: async () => {
212
+ throw new Error("An unmaterialized disabled install must not resolve a publish gate.");
213
+ },
214
+ }, {
215
+ action: "preview",
216
+ installId: row.install_id,
217
+ actor: "v84-local-reviewer",
218
+ });
219
+ if (response.status !== 409 || JSON.stringify(response.body) !== JSON.stringify({
220
+ error: "integration is not materialized",
221
+ code: "not_materialized",
222
+ })) {
223
+ throw new Error("The disabled managed-install lifecycle did not fail closed.");
224
+ }
225
+ lifecycleRefusalCount += 1;
226
+ }
227
+ if (
228
+ materializationReadCount !== 2 ||
229
+ readModelAssemblyCount !== 1 ||
230
+ lifecycleLoadCount !== 2 ||
231
+ lifecycleMutationCount !== 0 ||
232
+ lifecycleRefusalCount !== 2
233
+ ) {
234
+ throw new Error("The disabled managed-install lifecycle changed local state.");
235
+ }
236
+
237
+ return {
238
+ candidatePlanBefore,
239
+ candidatePlanAfter,
240
+ stagedPlanAfter,
241
+ managedInstallStateChanged: true,
242
+ readModelUnmaterializedCount: 2,
243
+ lifecycleRefusalCount: 2,
244
+ materializedDeclarationCount: afterDeclarations.length as 0,
245
+ materializedAssetCount: afterDeclarations.flatMap((item) => item.materializedAssets).length as 0,
246
+ materializationReadCount: materializationReadCount as 2,
247
+ readModelAssemblyCount: readModelAssemblyCount as 1,
248
+ lifecycleLoadCount: lifecycleLoadCount as 2,
249
+ lifecycleMutationCount,
250
+ };
251
+ }