@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.
- package/agency-kit/tools/lib/catalog-model/files.mjs +11 -4
- package/agency-kit/tools/lib/catalog-model/model.mjs +5 -1
- package/agency-kit/tools/lib/redirect-shadows.mjs +261 -0
- package/apps/storefront/astro.config.mjs +8 -2
- package/apps/storefront/package.json +1 -2
- package/apps/storefront/src/components/catalog/storefront/ProductCard.astro +20 -6
- package/apps/storefront/src/components/catalog/storefront/islands/ImageGallery.tsx +17 -6
- package/apps/storefront/src/components/compliance/storefront/islands/CheckoutComplianceGate.tsx +1 -32
- package/apps/storefront/src/config/compliance/rulesets.ts +1 -1
- package/apps/storefront/src/layouts/Layout.astro +17 -0
- package/apps/storefront/src/lib/access/auth/agentRoles.ts +20 -0
- package/apps/storefront/src/lib/access/auth/agentSessionGate.ts +32 -8
- package/apps/storefront/src/lib/access/auth/brokerAssertion.ts +16 -2
- package/apps/storefront/src/lib/access/auth/contactReaderAuthority.ts +39 -0
- package/apps/storefront/src/lib/access/auth/loginGate.ts +15 -17
- package/apps/storefront/src/lib/access/dashboard/staffAdmission.ts +5 -0
- package/apps/storefront/src/lib/access/dashboard/tenantSelection.ts +2 -0
- package/apps/storefront/src/lib/access/shared/capability.ts +14 -6
- package/apps/storefront/src/lib/access/shared/generated/capabilityCatalog.generated.ts +161 -0
- package/apps/storefront/src/lib/activity/activityScope.ts +36 -0
- package/apps/storefront/src/lib/activity/recordActivity.ts +23 -1
- package/apps/storefront/src/lib/activity/serverFanOut.ts +31 -0
- package/apps/storefront/src/lib/activity/store.ts +9 -3
- package/apps/storefront/src/lib/checkout/agent/checkoutProtocol.ts +196 -0
- package/apps/storefront/src/lib/checkout/agent/checkoutSession.ts +296 -0
- package/apps/storefront/src/lib/checkout/agent/webBotAuth.ts +347 -0
- package/apps/storefront/src/lib/checkout/commerce/cardCartForm.ts +2 -0
- package/apps/storefront/src/lib/checkout/commerce/cartSession.ts +109 -12
- package/apps/storefront/src/lib/checkout/commerce/checkoutHandoffRoute.ts +53 -25
- package/apps/storefront/src/lib/checkout/commerce/finalCartAuthorization.ts +48 -6
- package/apps/storefront/src/lib/checkout/proposal/cartProposal.ts +388 -0
- package/apps/storefront/src/lib/checkout/proposal/listMatcher.ts +149 -0
- package/apps/storefront/src/lib/checkout/proposal/proposalRoutes.ts +522 -0
- package/apps/storefront/src/lib/checkout/proposal/reviewHtml.ts +100 -0
- package/apps/storefront/src/lib/compliance/browser/checkoutVerificationFlow.ts +26 -2
- package/apps/storefront/src/lib/content/shared/redirects.ts +21 -4
- package/apps/storefront/src/lib/publication/shared/edgeCache.ts +5 -2
- package/apps/storefront/src/lib/publication/shared/previewAnnotations/renderDecorator.ts +15 -8
- package/apps/storefront/src/lib/publication/shared/runtimeEnv.ts +1 -1
- package/apps/storefront/src/middleware/controlPlane.ts +15 -1
- package/apps/storefront/src/middleware/index.ts +7 -3
- package/apps/storefront/src/middleware/renderChain.ts +46 -33
- package/apps/storefront/src/pages/api/cart-proposal/confirm.ts +12 -0
- package/apps/storefront/src/pages/api/cart-proposal/review.ts +26 -0
- package/apps/storefront/src/pages/api/commerce/checkout-sessions/[id].ts +9 -0
- package/apps/storefront/src/pages/api/commerce/checkout-sessions.ts +8 -0
- package/apps/storefront/src/pages/api/commerce/final-cart-authorization.ts +29 -6
- package/apps/storefront/src/pages/api/compliance/preflight.ts +25 -1
- package/apps/storefront/src/pages/products/[handle].astro +2 -15
- package/apps/storefront/tsconfig.astro.json +11 -0
- package/package.json +1 -1
- package/packages/public-runtime/src/activity/README.md +12 -0
- package/packages/public-runtime/src/activity/catalog.ts +7 -0
- package/packages/public-runtime/src/activity/event.ts +19 -0
- package/packages/public-runtime/src/activity/redaction.ts +31 -2
- package/packages/public-runtime/src/catalog-files.ts +3 -2
- package/packages/public-runtime/src/checkout-orders.ts +18 -19
- package/packages/public-runtime/src/checkout.ts +70 -0
- package/packages/public-runtime/src/compliance/evaluate.ts +60 -1
- package/packages/public-runtime/src/compliance/index.ts +1 -1
- package/packages/public-runtime/src/compliance/pact-report.ts +184 -3
- package/packages/public-runtime/src/compliance/profile.ts +268 -20
- package/packages/public-runtime/src/compliance/ruleset.ts +42 -0
- package/packages/public-runtime/src/customization-runtime.ts +1 -1
- package/packages/public-runtime/src/product.ts +9 -1
- package/packages/public-runtime/src/publication-content-redirects.ts +16 -3
- package/packages/public-runtime/tests/fixtures/compliance-decisions.golden.json +252 -52
- package/pnpm-lock.runner.yaml +0 -15
- package/scripts/tenant/materialize-tenant-content.mjs +3 -0
- package/scripts/tenant/validate.mjs +128 -0
- package/apps/storefront/dev-plugins/dev-publish.mjs +0 -55
- package/apps/storefront/drizzle.config.apps.ts +0 -13
- package/apps/storefront/integrations/preview-annotations-client-bundle.mjs +0 -80
- package/apps/storefront/migrations-apps/0000_fast_millenium_guard.sql +0 -129
- package/apps/storefront/migrations-apps/0001_woozy_lyja.sql +0 -22
- package/apps/storefront/migrations-apps/0002_good_switch.sql +0 -26
- package/apps/storefront/migrations-apps/0003_mute_marauders.sql +0 -12
- package/apps/storefront/migrations-apps/0004_deep_morph.sql +0 -36
- package/apps/storefront/migrations-apps/0005_common_mystique.sql +0 -23
- package/apps/storefront/migrations-apps/0006_broad_microchip.sql +0 -16
- package/apps/storefront/migrations-apps/0007_brave_outlaw_kid.sql +0 -15
- package/apps/storefront/migrations-apps/0008_blue_dazzler.sql +0 -11
- package/apps/storefront/migrations-apps/0009_bored_shinobi_shaw.sql +0 -15
- package/apps/storefront/migrations-apps/0010_ws4_verified_provider_measurement.sql +0 -35
- package/apps/storefront/migrations-apps/0011_dt_tracking_tenant_databases.sql +0 -23
- package/apps/storefront/migrations-apps/0012_test_destinations.sql +0 -29
- package/apps/storefront/migrations-apps/0013_publication_space_editorial.sql +0 -64
- package/apps/storefront/migrations-apps/0014_retire_candidate_ledger.sql +0 -12
- package/apps/storefront/migrations-apps/0015_merchant_calculation_settings.sql +0 -31
- package/apps/storefront/migrations-apps/0016_scrappy_commerce_contract.sql +0 -166
- package/apps/storefront/migrations-apps/0017_commerce_durable_projection.sql +0 -28
- package/apps/storefront/migrations-apps/0018_commerce_provider_cart_identity.sql +0 -13
- package/apps/storefront/migrations-apps/0019_commerce_source_authority.sql +0 -23
- package/apps/storefront/migrations-apps/0020_contact_messages.sql +0 -18
- package/apps/storefront/migrations-apps/0021_contact_vault.sql +0 -166
- package/apps/storefront/migrations-apps/0022_contact_vault_fields.sql +0 -342
- package/apps/storefront/migrations-apps/0023_principal_grant_contacts.sql +0 -15
- package/apps/storefront/migrations-apps/0024_order_contact_erasure_state.sql +0 -22
- package/apps/storefront/migrations-apps/0025_shipment_audit_order_lookup.sql +0 -2
- package/apps/storefront/migrations-apps/0026_fulfillment_assignment.sql +0 -44
- package/apps/storefront/migrations-apps/0027_app_contact_authority.sql +0 -70
- package/apps/storefront/migrations-apps/0028_app_jwk_and_candidates.sql +0 -133
- package/apps/storefront/migrations-apps/0029_inventory_locations_wms.sql +0 -38
- package/apps/storefront/migrations-apps/0030_assignment_split_shipments.sql +0 -149
- package/apps/storefront/migrations-apps/meta/0000_snapshot.json +0 -843
- package/apps/storefront/migrations-apps/meta/0001_snapshot.json +0 -990
- package/apps/storefront/migrations-apps/meta/0002_snapshot.json +0 -1160
- package/apps/storefront/migrations-apps/meta/0003_snapshot.json +0 -1235
- package/apps/storefront/migrations-apps/meta/0004_snapshot.json +0 -1474
- package/apps/storefront/migrations-apps/meta/0005_snapshot.json +0 -1617
- package/apps/storefront/migrations-apps/meta/0006_snapshot.json +0 -1716
- package/apps/storefront/migrations-apps/meta/0007_snapshot.json +0 -1812
- package/apps/storefront/migrations-apps/meta/0008_snapshot.json +0 -1881
- package/apps/storefront/migrations-apps/meta/0009_snapshot.json +0 -1979
- package/apps/storefront/migrations-apps/meta/_journal.json +0 -76
- package/apps/storefront/perf/README.md +0 -64
- package/apps/storefront/perf/assert-budgets.ts +0 -159
- package/apps/storefront/platform-reconcile-tenants.json +0 -3
- package/apps/storefront/playwright.config.ts +0 -23
- package/apps/storefront/public/js/dashboard-access-banner.js +0 -53
- package/apps/storefront/public/js/dashboard-apps.js +0 -183
- package/apps/storefront/public/js/dashboard-contact-capture.js +0 -52
- package/apps/storefront/public/js/dashboard-delegate.js +0 -167
- package/apps/storefront/public/js/dashboard-team.js +0 -356
- package/apps/storefront/public/js/dashboard-vendor-search.js +0 -115
- package/apps/storefront/src/components/content/storefront/AsyncStylesheet.astro +0 -26
- package/apps/storefront/src/components/integrations/storefront/WidgetFrame.astro +0 -34
- package/apps/storefront/src/config/adminTenantLookup.ts +0 -35
- package/apps/storefront/src/config/evidenceTenantRoster.ts +0 -25
- package/apps/storefront/src/config/staffProvisionProjection.ts +0 -24
- package/apps/storefront/src/config/storeName.ts +0 -34
- package/apps/storefront/src/lib/access/admin/README.md +0 -122
- package/apps/storefront/src/lib/access/admin/adminShell.ts +0 -281
- package/apps/storefront/src/lib/access/admin/envelope.ts +0 -9
- package/apps/storefront/src/lib/access/admin/viewmodels/settings.ts +0 -64
- package/apps/storefront/src/lib/access/auth/adminApiGuard.ts +0 -66
- package/apps/storefront/src/lib/access/auth/adminEntry.ts +0 -126
- package/apps/storefront/src/lib/access/auth/mcpClientAssertion.ts +0 -217
- package/apps/storefront/src/lib/access/auth/operatorSession.ts +0 -120
- package/apps/storefront/src/lib/access/dashboard/agentStoreEntry.ts +0 -253
- package/apps/storefront/src/lib/access/dashboard/delegateGate.ts +0 -130
- package/apps/storefront/src/lib/access/dashboard/staffStoreEntry.ts +0 -153
- package/apps/storefront/src/lib/access/dashboard/staffVendorAccess.ts +0 -474
- package/apps/storefront/src/lib/access/dashboard/vendorQuery.ts +0 -61
- package/apps/storefront/src/lib/access/fixtures/settings.ts +0 -67
- package/apps/storefront/src/lib/access/fixtures/tenants.ts +0 -29
- package/apps/storefront/src/lib/access/notifications/magicLinkInviteEmail.ts +0 -62
- package/apps/storefront/src/lib/access/shared/grantContactLookup.ts +0 -97
- package/apps/storefront/src/lib/access/shared/principalGrants.ts +0 -775
- package/apps/storefront/src/lib/activity/alerts.ts +0 -426
- package/apps/storefront/src/lib/activity/candidateSubmitLease.ts +0 -87
- package/apps/storefront/src/lib/activity/changeActorAttribution.ts +0 -181
- package/apps/storefront/src/lib/activity/evidence/evidenceReference.ts +0 -32
- package/apps/storefront/src/lib/activity/fixtures/evidence.ts +0 -99
- package/apps/storefront/src/lib/activity/query.ts +0 -403
- package/apps/storefront/src/lib/activity/uiActor.ts +0 -152
- package/apps/storefront/src/lib/admin/services/mock/index.ts +0 -12
- package/apps/storefront/src/lib/assets/addons/catalog.ts +0 -60
- package/apps/storefront/src/lib/assets/addons/storeEntitlements.ts +0 -260
- package/apps/storefront/src/lib/assets/durableAssetsRoute.ts +0 -65
- package/apps/storefront/src/lib/assets/durableR2.ts +0 -473
- package/apps/storefront/src/lib/assets/durableR2Bindings.ts +0 -33
- package/apps/storefront/src/lib/automation/admin/viewmodels/aiWorkflows.ts +0 -65
- package/apps/storefront/src/lib/automation/ai/approvalMode.ts +0 -20
- package/apps/storefront/src/lib/automation/ai/askEnvelope.ts +0 -47
- package/apps/storefront/src/lib/automation/ai/audit.ts +0 -12
- package/apps/storefront/src/lib/automation/ai/operationalRuns.ts +0 -155
- package/apps/storefront/src/lib/automation/ai/recommendation.ts +0 -20
- package/apps/storefront/src/lib/automation/fixtures/aiWorkflows.ts +0 -59
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsClient.ts +0 -250
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsFields.ts +0 -134
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsPreview.ts +0 -37
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsPricingView.ts +0 -39
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsRuleView.ts +0 -44
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsSkuView.ts +0 -21
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsState.ts +0 -132
- package/apps/storefront/src/lib/catalog/admin/productSetupPhoto.ts +0 -23
- package/apps/storefront/src/lib/catalog/admin/productsTabClient.ts +0 -193
- package/apps/storefront/src/lib/catalog/admin/services/catalogProducts.ts +0 -32
- package/apps/storefront/src/lib/catalog/admin/viewmodels/catalogProducts.ts +0 -164
- package/apps/storefront/src/lib/catalog/admin/viewmodels/products.ts +0 -267
- package/apps/storefront/src/lib/catalog/fixtures/products.ts +0 -105
- package/apps/storefront/src/lib/catalog/tot/syncState.ts +0 -111
- package/apps/storefront/src/lib/checkout/admin/checkoutStyleInput.ts +0 -172
- package/apps/storefront/src/lib/checkout/admin/checkoutStyleTarget.ts +0 -65
- package/apps/storefront/src/lib/checkout/browser/checkoutExciseForm.ts +0 -152
- package/apps/storefront/src/lib/checkout/browser/checkoutRequirementsForm.ts +0 -72
- package/apps/storefront/src/lib/checkout/browser/checkoutStyleForm.ts +0 -110
- package/apps/storefront/src/lib/checkout/browser/settingDraftActions.ts +0 -367
- package/apps/storefront/src/lib/checkout/commerce/checkoutSettings.ts +0 -246
- package/apps/storefront/src/lib/checkout/fixtures/checkoutSettings.ts +0 -77
- package/apps/storefront/src/lib/content/blog/markdown.ts +0 -174
- package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome-assignments.example.json +0 -6
- package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome.example.json +0 -79
- package/apps/storefront/src/lib/content/index.ts +0 -27
- package/apps/storefront/src/lib/content/the-build/readingTime.ts +0 -35
- package/apps/storefront/src/lib/content/the-build/toc.ts +0 -95
- package/apps/storefront/src/lib/customers/admin/viewmodels/customers.ts +0 -56
- package/apps/storefront/src/lib/customers/contactVault/blindIndex.ts +0 -28
- package/apps/storefront/src/lib/customers/contactVault/contactAudit.ts +0 -149
- package/apps/storefront/src/lib/customers/contactVault/dataKeys.ts +0 -283
- package/apps/storefront/src/lib/customers/contactVault/fieldEnvelope.ts +0 -88
- package/apps/storefront/src/lib/customers/contactVault/isolateMetrics.ts +0 -37
- package/apps/storefront/src/lib/customers/contactVault/kms.ts +0 -292
- package/apps/storefront/src/lib/customers/contactVault/retention.ts +0 -302
- package/apps/storefront/src/lib/customers/contactVault/retentionPolicy.ts +0 -290
- package/apps/storefront/src/lib/customers/contactVault/zip3.ts +0 -24
- package/apps/storefront/src/lib/customers/fixtures/customers.ts +0 -86
- package/apps/storefront/src/lib/developer-experience/admin/memoizeByEnvelope.ts +0 -27
- package/apps/storefront/src/lib/developer-experience/admin/seed.ts +0 -54
- package/apps/storefront/src/lib/developer-experience/dev/activityIngestToken.ts +0 -85
- package/apps/storefront/src/lib/developer-experience/dev/activityStore.ts +0 -82
- package/apps/storefront/src/lib/developer-experience/dev/agentGrantAttestation.ts +0 -74
- package/apps/storefront/src/lib/developer-experience/dev/ai-widget-client.js +0 -308
- package/apps/storefront/src/lib/developer-experience/dev/apiBase.ts +0 -17
- package/apps/storefront/src/lib/developer-experience/dev/cliSignInCode.ts +0 -124
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/ask.ts +0 -49
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/clickToSource.ts +0 -71
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/copyCommand.ts +0 -227
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/files.ts +0 -249
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/hostedActivity.ts +0 -500
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/infoPopover.ts +0 -12
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/mcpCopy.ts +0 -34
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/monitor.ts +0 -107
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/stepper.ts +0 -116
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/themeToggle.ts +0 -23
- package/apps/storefront/src/lib/developer-experience/dev/livePreview.ts +0 -77
- package/apps/storefront/src/lib/developer-experience/dev/obstacleStore.ts +0 -214
- package/apps/storefront/src/lib/developer-experience/dev/previewStatus.ts +0 -87
- package/apps/storefront/src/lib/developer-experience/dev/rendezvousBroker.ts +0 -226
- package/apps/storefront/src/lib/developer-experience/dev/runtimeStore.ts +0 -291
- package/apps/storefront/src/lib/developer-experience/dev/storeStatus.ts +0 -142
- package/apps/storefront/src/lib/developer-experience/dev/subjectReissue.ts +0 -67
- package/apps/storefront/src/lib/developer-experience/fixtures/regulated-commerce-truth/index.ts +0 -540
- package/apps/storefront/src/lib/developer-experience/fixtures/ws3-readonly-clone-preflight/index.ts +0 -495
- package/apps/storefront/src/lib/engagement/contact/contactMessages.ts +0 -671
- package/apps/storefront/src/lib/engagement/contact/messagesTabClient.ts +0 -175
- package/apps/storefront/src/lib/engagement/contact/submission.ts +0 -112
- package/apps/storefront/src/lib/engagement/messaging/messagesClient.ts +0 -149
- package/apps/storefront/src/lib/engagement/newsletter/digest.ts +0 -117
- package/apps/storefront/src/lib/engagement/newsletter/resendClient.ts +0 -79
- package/apps/storefront/src/lib/engagement/newsletter/send.ts +0 -265
- package/apps/storefront/src/lib/engagement/social/golive.ts +0 -212
- package/apps/storefront/src/lib/engagement/social/notify.ts +0 -32
- package/apps/storefront/src/lib/engagement/social/tokenStore.ts +0 -171
- package/apps/storefront/src/lib/fulfillment/admin/commerceDesk.ts +0 -180
- package/apps/storefront/src/lib/fulfillment/admin/commerceDeskRouting.ts +0 -45
- package/apps/storefront/src/lib/fulfillment/admin/viewmodels/fulfillment.ts +0 -1071
- package/apps/storefront/src/lib/fulfillment/appShipmentEvidence.ts +0 -271
- package/apps/storefront/src/lib/fulfillment/carrierEvidence.ts +0 -105
- package/apps/storefront/src/lib/fulfillment/commerceProjection.ts +0 -157
- package/apps/storefront/src/lib/fulfillment/commerceReadback.ts +0 -60
- package/apps/storefront/src/lib/fulfillment/commerceRecovery.ts +0 -84
- package/apps/storefront/src/lib/fulfillment/commerceRuntime.ts +0 -41
- package/apps/storefront/src/lib/fulfillment/fulfillmentService.ts +0 -2842
- package/apps/storefront/src/lib/fulfillment/readiness.ts +0 -217
- package/apps/storefront/src/lib/fulfillment/splitShipments.ts +0 -388
- package/apps/storefront/src/lib/fulfillment/syntheticPreviewOrders.ts +0 -292
- package/apps/storefront/src/lib/integrations/apps/appContactAuthority.ts +0 -27
- package/apps/storefront/src/lib/integrations/apps/appContactConsents.ts +0 -118
- package/apps/storefront/src/lib/integrations/apps/appInstallEnv.ts +0 -28
- package/apps/storefront/src/lib/integrations/apps/gtmMigrationDraft.ts +0 -103
- package/apps/storefront/src/lib/integrations/apps/inventoryWrite.ts +0 -906
- package/apps/storefront/src/lib/integrations/apps/orders/customerHash.ts +0 -28
- package/apps/storefront/src/lib/integrations/apps/orders/idempotency.ts +0 -100
- package/apps/storefront/src/lib/integrations/apps/reports/salesVelocityReport.ts +0 -96
- package/apps/storefront/src/lib/integrations/apps/routeParams.ts +0 -45
- package/apps/storefront/src/lib/integrations/webhooks/cloudflareQueueDispatcher.ts +0 -82
- package/apps/storefront/src/lib/integrations/webhooks/commercePayloads.ts +0 -159
- package/apps/storefront/src/lib/integrations/webhooks/deliveryEngine.ts +0 -379
- package/apps/storefront/src/lib/integrations/webhooks/deliveryMapper.ts +0 -34
- package/apps/storefront/src/lib/integrations/webhooks/deliveryStore.ts +0 -903
- package/apps/storefront/src/lib/integrations/webhooks/dispatcher.ts +0 -168
- package/apps/storefront/src/lib/integrations/webhooks/emit.ts +0 -245
- package/apps/storefront/src/lib/integrations/webhooks/events.ts +0 -105
- package/apps/storefront/src/lib/integrations/webhooks/getDispatcher.ts +0 -77
- package/apps/storefront/src/lib/integrations/webhooks/orderFulfilledClaim.ts +0 -75
- package/apps/storefront/src/lib/measurement/admin/analyticsRegionPolicy.ts +0 -151
- package/apps/storefront/src/lib/measurement/admin/analyticsRegionsClient.ts +0 -84
- package/apps/storefront/src/lib/measurement/admin/consentSettingsClient.ts +0 -113
- package/apps/storefront/src/lib/measurement/analytics/index.ts +0 -44
- package/apps/storefront/src/lib/measurement/attribution/attributionService.ts +0 -206
- package/apps/storefront/src/lib/measurement/attribution/orderConversionD1.ts +0 -150
- package/apps/storefront/src/lib/measurement/attribution/verifiedProviderMeasurement.ts +0 -118
- package/apps/storefront/src/lib/measurement/tracking/interactionCollector.ts +0 -205
- package/apps/storefront/src/lib/measurement/tracking/pruneRollup.ts +0 -260
- package/apps/storefront/src/lib/measurement/tracking/tenantReadAccess.ts +0 -138
- package/apps/storefront/src/lib/measurement/tracking-writeback/rewriteTrackingIds.ts +0 -175
- package/apps/storefront/src/lib/measurement/tracking-writeback/writebackCandidate.ts +0 -110
- package/apps/storefront/src/lib/observability/diag/capture.ts +0 -162
- package/apps/storefront/src/lib/observability/diag/consoleLine.ts +0 -76
- package/apps/storefront/src/lib/observability/diag/debugConsole.ts +0 -118
- package/apps/storefront/src/lib/observability/diag/debugMode.ts +0 -163
- package/apps/storefront/src/lib/observability/diag/debugWindow.ts +0 -111
- package/apps/storefront/src/lib/observability/diag/redact.ts +0 -17
- package/apps/storefront/src/lib/observability/diag/reference.ts +0 -148
- package/apps/storefront/src/lib/observability/diag/referenceStore.ts +0 -113
- package/apps/storefront/src/lib/observability/diag/report.ts +0 -110
- package/apps/storefront/src/lib/observability/diag/serverResponseTime.ts +0 -91
- package/apps/storefront/src/lib/observability/diag/session.ts +0 -93
- package/apps/storefront/src/lib/observability/monitoring/manifest.ts +0 -301
- package/apps/storefront/src/lib/observability/performance/lighthouseReport.ts +0 -109
- package/apps/storefront/src/lib/observability/performance/rumAlert.ts +0 -179
- package/apps/storefront/src/lib/orders/admin/orderActions.ts +0 -556
- package/apps/storefront/src/lib/orders/admin/orderClient.ts +0 -248
- package/apps/storefront/src/lib/orders/admin/orderSource.ts +0 -410
- package/apps/storefront/src/lib/orders/admin/services/orders.ts +0 -922
- package/apps/storefront/src/lib/orders/admin/viewmodels/orders.ts +0 -135
- package/apps/storefront/src/lib/orders/data/commerceCallerConfig.ts +0 -37
- package/apps/storefront/src/lib/orders/data/ledgerContractOrders.ts +0 -148
- package/apps/storefront/src/lib/orders/data/orderForwardReceiver.ts +0 -532
- package/apps/storefront/src/lib/orders/data/orderMapper.ts +0 -454
- package/apps/storefront/src/lib/orders/data/ordersStore.ts +0 -623
- package/apps/storefront/src/lib/orders/data/sourceAuthorityContract.ts +0 -380
- package/apps/storefront/src/lib/orders/data/sourceAuthorityStore.ts +0 -830
- package/apps/storefront/src/lib/orders/fixtures/orders.ts +0 -186
- package/apps/storefront/src/lib/orders/providers/foxyOrderClient.ts +0 -207
- package/apps/storefront/src/lib/orders/vault/appRecipientRead.ts +0 -222
- package/apps/storefront/src/lib/orders/vault/contactIntake.ts +0 -63
- package/apps/storefront/src/lib/orders/vault/contactRoutes.ts +0 -110
- package/apps/storefront/src/lib/orders/vault/kmsEnv.ts +0 -11
- package/apps/storefront/src/lib/orders/vault/orderContact.ts +0 -96
- package/apps/storefront/src/lib/orders/vault/orderContactVault.ts +0 -1427
- package/apps/storefront/src/lib/orders/vault/vault-test-support.ts +0 -258
- package/apps/storefront/src/lib/publication/d1/schema-apps.ts +0 -808
- package/apps/storefront/src/lib/publication/notifications/candidateConflictEmail.ts +0 -80
- package/apps/storefront/src/lib/publication/servingMode.ts +0 -52
- package/apps/storefront/src/lib/publication/shared/previewAnnotations/moduleAsset.ts +0 -65
- package/apps/storefront/src/lib/publication/shared/routedApiParam.ts +0 -38
- package/apps/storefront/src/lib/reporting/admin/viewmodels/reporting.ts +0 -34
- package/apps/storefront/src/lib/reporting/fixtures/reporting.ts +0 -51
- package/apps/storefront/src/lib/subscriptions/admin/viewmodels/subscriptions.ts +0 -106
- package/apps/storefront/src/lib/subscriptions/fixtures/subscriptions.ts +0 -398
- package/apps/storefront/src/pages/api/admin/activity-alerts.ts +0 -58
- package/apps/storefront/src/pages/api/admin/commerce-readiness.ts +0 -172
- package/apps/storefront/src/pages/api/admin/fulfillment/batches.ts +0 -59
- package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id]/address.ts +0 -66
- package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id].ts +0 -118
- package/apps/storefront/src/pages/api/admin/fulfillment/orders/contact-search.ts +0 -26
- package/apps/storefront/src/pages/api/admin/fulfillment/orders/contacts.ts +0 -22
- package/apps/storefront/src/pages/api/admin/interaction-insights.ts +0 -101
- package/apps/storefront/src/pages/api/admin/orders/[id].ts +0 -63
- package/apps/storefront/src/pages/api/admin/orders.ts +0 -65
- package/apps/storefront/src/pages/api/contact.ts +0 -144
- package/apps/storefront/src/scheduled/contactVaultSweep.ts +0 -113
- package/apps/storefront/src/styles/admin.css +0 -1161
- package/apps/storefront/test/pipeline/fake-preview-services.ts +0 -288
- package/apps/storefront/test/pipeline/harness.ts +0 -209
- package/apps/storefront/test/pipeline/intake-worker.mjs +0 -14
- package/apps/storefront/test/pipeline/matrix-faults.ts +0 -366
- package/apps/storefront/test/pipeline/pipeline-host.ts +0 -418
- package/apps/storefront/test/pipeline/pool-config.cjs +0 -85
- package/apps/storefront/test/pipeline/publish-kinds.ts +0 -279
- package/apps/storefront/test/pipeline/synthetic-job.ts +0 -303
- package/apps/storefront/test/pipeline-faults/matrix-lib.ts +0 -696
- package/apps/storefront/vitest.config.cts +0 -44
- package/apps/storefront/vitest.faults.config.cts +0 -13
- package/apps/storefront/vitest.workers.config.cts +0 -7
- package/packages/feedback/fixtures/v1/expected-findings.json +0 -16
- package/packages/feedback/fixtures/v1/feedback-action/invalid/carries-transport-credential.json +0 -14
- package/packages/feedback/fixtures/v1/feedback-action/invalid/control-char-in-description.json +0 -13
- package/packages/feedback/fixtures/v1/feedback-action/invalid/legacy-schema-version.json +0 -13
- package/packages/feedback/fixtures/v1/feedback-action/invalid/page-path-with-query.json +0 -14
- package/packages/feedback/fixtures/v1/feedback-action/invalid/title-too-short.json +0 -13
- package/packages/feedback/fixtures/v1/feedback-action/valid/element-problem.json +0 -33
- package/packages/feedback/fixtures/v1/feedback-action/valid/page-comment.json +0 -20
- package/packages/feedback/fixtures/v1/feedback-action/valid/region-improvement.json +0 -24
- package/packages/feedback/fixtures/v1/feedback-action/valid/text-selection-feature.json +0 -30
- package/packages/feedback/fixtures/v1/submission-receipt/invalid/accepted-at-not-utc.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/invalid/bad-feedback-id.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/invalid/legacy-contract-version.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/invalid/missing-replayed.json +0 -8
- package/packages/feedback/fixtures/v1/submission-receipt/valid/accepted.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/valid/fractional-seconds.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/valid/replayed.json +0 -9
- package/packages/feedback/fixtures/v1/target-evidence/invalid/page-kind-claims-structure.json +0 -6
- package/packages/feedback/fixtures/v1/target-evidence/invalid/path-too-deep.json +0 -17
- package/packages/feedback/fixtures/v1/target-evidence/invalid/relative-region-out-of-range.json +0 -11
- package/packages/feedback/fixtures/v1/target-evidence/invalid/selector-uses-class.json +0 -7
- package/packages/feedback/fixtures/v1/target-evidence/invalid/source-precision-without-anchor.json +0 -6
- package/packages/feedback/fixtures/v1/target-evidence/valid/element-structure.json +0 -21
- package/packages/feedback/fixtures/v1/target-evidence/valid/host-iframe.json +0 -14
- package/packages/feedback/fixtures/v1/target-evidence/valid/source-anchor.json +0 -12
- package/packages/feedback/fixtures/v1/target-evidence/valid/text-selection.json +0 -26
- package/packages/feedback/package.json +0 -35
- package/packages/feedback/scripts/build-player.mjs +0 -28
- package/packages/feedback/src/index.ts +0 -1
- package/packages/feedback/src/primitives/composer.ts +0 -639
- package/packages/feedback/src/primitives/dialog.ts +0 -263
- package/packages/feedback/src/primitives/hostAdapter.ts +0 -116
- package/packages/feedback/src/primitives/index.ts +0 -10
- package/packages/feedback/src/primitives/launcher.ts +0 -200
- package/packages/feedback/src/primitives/picker.ts +0 -663
- package/packages/feedback/src/primitives/redaction.ts +0 -204
- package/packages/feedback/src/primitives/selection.ts +0 -49
- package/packages/feedback/src/primitives/shiftAccelerator.ts +0 -160
- package/packages/feedback/src/primitives/styles.ts +0 -77
- package/packages/feedback/src/primitives/surface.ts +0 -124
- package/packages/feedback/src/primitives/target.ts +0 -293
- package/packages/feedback/src/tour/canonical.ts +0 -27
- package/packages/feedback/src/tour/index.ts +0 -3
- package/packages/feedback/src/tour/player/browser.ts +0 -5
- package/packages/feedback/src/tour/player/host.ts +0 -12
- package/packages/feedback/src/tour/player/index.ts +0 -205
- package/packages/feedback/src/tour/player/manifest.ts +0 -76
- package/packages/feedback/src/tour/player/player.css +0 -130
- package/packages/feedback/src/tour/player/resolver.ts +0 -12
- package/packages/feedback/src/tour/player/surface.ts +0 -295
- package/packages/feedback/src/tour/player/types.ts +0 -8
- package/packages/feedback/src/tour/resolve/core.ts +0 -267
- package/packages/feedback/src/tour/resolve/dom.ts +0 -115
- package/packages/feedback/src/tour/resolve/index.ts +0 -29
- package/packages/feedback/src/tour/sanitize.ts +0 -76
- package/packages/feedback/src/tour/schema.ts +0 -362
- package/packages/feedback/src/v1/guards.ts +0 -335
- package/packages/feedback/src/v1/index.ts +0 -3
- package/packages/feedback/src/v1/protectedSurfaces.ts +0 -32
- package/packages/feedback/src/v1/types.ts +0 -177
- package/packages/feedback/tsconfig.json +0 -9
- package/packages/feedback/vitest.config.cts +0 -21
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Monitoring contract (monitors, alerts, operator runbooks).
|
|
3
|
-
*
|
|
4
|
-
* This is the CHECKED-IN source of truth for "what do we watch, at what
|
|
5
|
-
* threshold, at what severity, and which runbook fires when it trips." It is
|
|
6
|
-
* deliberately data, not wiring: this file ships the *contract* so operators can
|
|
7
|
-
* see coverage and reviewers can diff it; the actual alert providers (Cloudflare
|
|
8
|
-
* Health Checks / Workers metrics / Logpush alerts / a RUM sink) are provisioned
|
|
9
|
-
* out-of-band and each monitor records whether it is `in-code` or still
|
|
10
|
-
* `needs-external` / `needs-secret`.
|
|
11
|
-
*
|
|
12
|
-
* Signal sources are named against real code where it exists in this repo
|
|
13
|
-
* (`/health` → lib/observability/shared/health.ts, CSP → pages/api/csp-report.ts + CSP_REPORT_PATH,
|
|
14
|
-
* commerce events → lib/analytics). Signals owned by sibling units are referenced
|
|
15
|
-
* by CONTRACT NAME, not imported — Core Web Vitals come from the RUM beacon,
|
|
16
|
-
* and age-verification / restricted-state denials come from the compliance
|
|
17
|
-
* evidence signals. This file does not edit or depend on those units; point the
|
|
18
|
-
* corresponding monitor's `observe` at the real sink where one exists.
|
|
19
|
-
*
|
|
20
|
-
* The companion operator doc renders this for humans and lists the external
|
|
21
|
-
* wiring/secrets checklist: docs/epics/sample-store-migration/monitoring-and-runbooks.md.
|
|
22
|
-
* RUNBOOK.md §6–§8 hold the incident runbooks these monitors dispatch to.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Alert severity, in escalation order.
|
|
27
|
-
* - `page` — wake someone now; launch-critical, customer-blocking.
|
|
28
|
-
* - `critical` — same-business-hours; degraded but not fully down, or a
|
|
29
|
-
* compliance/legal risk that must be resolved before more sales.
|
|
30
|
-
* - `warning` — investigate; a spike or trend that predicts a `critical`.
|
|
31
|
-
* - `info` — record only; useful for post-incident context, no alert.
|
|
32
|
-
*/
|
|
33
|
-
export type Severity = "page" | "critical" | "warning" | "info";
|
|
34
|
-
|
|
35
|
-
/** What each monitor watches, grouped so a dashboard can lane them. */
|
|
36
|
-
export type MonitorCategory =
|
|
37
|
-
| "availability"
|
|
38
|
-
| "commerce"
|
|
39
|
-
| "compliance"
|
|
40
|
-
| "catalog"
|
|
41
|
-
| "performance"
|
|
42
|
-
| "security";
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Provisioning status of a monitor — the honest "is this actually alerting?"
|
|
46
|
-
* flag so a green manifest never implies coverage we don't have.
|
|
47
|
-
* - `in-code` — the signal is emitted by code in THIS repo; only a log
|
|
48
|
-
* or metric alert rule needs attaching.
|
|
49
|
-
* - `needs-external` — depends on an external provider/probe/sink that must be
|
|
50
|
-
* configured (Cloudflare Health Check, Logpush alert, RUM).
|
|
51
|
-
* - `needs-secret` — additionally blocked on a credential/token being set.
|
|
52
|
-
*/
|
|
53
|
-
export type WiringStatus = "in-code" | "needs-external" | "needs-secret";
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Stable ids for the six incident runbooks (RUNBOOK.md §7). Every monitor names
|
|
57
|
-
* the runbook an operator opens when it fires, so detection → response is a
|
|
58
|
-
* lookup, not archaeology.
|
|
59
|
-
*/
|
|
60
|
-
export type RunbookId =
|
|
61
|
-
| "checkout-down"
|
|
62
|
-
| "catalog-stale"
|
|
63
|
-
| "bad-price"
|
|
64
|
-
| "compliance-provider-down"
|
|
65
|
-
| "tax-shipping-outage"
|
|
66
|
-
| "bad-content-policy";
|
|
67
|
-
|
|
68
|
-
export interface Monitor {
|
|
69
|
-
/** Stable kebab-case id; also the alert name. Never renamed once shipped. */
|
|
70
|
-
id: string;
|
|
71
|
-
/** One-line human title for dashboards/alerts. */
|
|
72
|
-
title: string;
|
|
73
|
-
category: MonitorCategory;
|
|
74
|
-
/** Where the signal comes from and how a monitor reads it. */
|
|
75
|
-
signal: {
|
|
76
|
-
/** The emitter — code symbol/path in this repo, or a named sibling contract. */
|
|
77
|
-
source: string;
|
|
78
|
-
/** How the alert observes it: probe, Worker metric, log filter, RUM, webhook. */
|
|
79
|
-
observe: string;
|
|
80
|
-
};
|
|
81
|
-
/** The alarm condition in plain, checkable terms (thresholds are launch defaults). */
|
|
82
|
-
threshold: string;
|
|
83
|
-
severity: Severity;
|
|
84
|
-
/** Which incident runbook to run when this fires. */
|
|
85
|
-
runbook: RunbookId;
|
|
86
|
-
wiring: WiringStatus;
|
|
87
|
-
/** External dependency, secret name, or sibling-unit signal reference. */
|
|
88
|
-
notes?: string;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* The ten launch-critical monitors. Order is presentation order.
|
|
93
|
-
* Thresholds are defaults; tune against the 24h post-cutover soak
|
|
94
|
-
* and record any change here — this file is the audit trail.
|
|
95
|
-
*/
|
|
96
|
-
export const MONITORS: readonly Monitor[] = [
|
|
97
|
-
{
|
|
98
|
-
id: "uptime",
|
|
99
|
-
title: "Storefront uptime / liveness",
|
|
100
|
-
category: "availability",
|
|
101
|
-
signal: {
|
|
102
|
-
source: "GET /health (lib/observability/shared/health.ts — answered before tenant/gate/cache)",
|
|
103
|
-
observe: "external synthetic probe hits /health across regions; expects 200 {status:'ok'}",
|
|
104
|
-
},
|
|
105
|
-
threshold: "2 consecutive probe failures (or >1% of probes failing over 5m)",
|
|
106
|
-
severity: "page",
|
|
107
|
-
runbook: "checkout-down",
|
|
108
|
-
wiring: "needs-external",
|
|
109
|
-
notes:
|
|
110
|
-
"Wire a Cloudflare Health Check (or external uptime monitor) per production host. " +
|
|
111
|
-
"/health also returns the live commit .sha — use it to confirm which build is up during an incident.",
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
id: "page-errors",
|
|
115
|
-
title: "Page / Worker errors (5xx + unhandled exceptions)",
|
|
116
|
-
category: "availability",
|
|
117
|
-
signal: {
|
|
118
|
-
source: "Cloudflare Worker exceptions + non-2xx responses from the middleware render path",
|
|
119
|
-
observe: "Workers 'Errors' metric + Logpush; alert on error-rate over the request baseline",
|
|
120
|
-
},
|
|
121
|
-
threshold: "5xx rate > 1% over 5m, or any sustained unhandled-exception stream",
|
|
122
|
-
severity: "critical",
|
|
123
|
-
runbook: "bad-content-policy",
|
|
124
|
-
wiring: "needs-external",
|
|
125
|
-
notes:
|
|
126
|
-
"A spike isolated to one route usually points at a bad publish/content artifact (see bad-content-policy); " +
|
|
127
|
-
"a broad spike is an availability event (checkout-down).",
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
id: "checkout-failures",
|
|
131
|
-
title: "Checkout failures (add-to-cart / checkout handoff)",
|
|
132
|
-
category: "commerce",
|
|
133
|
-
signal: {
|
|
134
|
-
source:
|
|
135
|
-
"Signed add-to-cart + cross-origin checkout POST (F11; lib/checkout/shared/checkoutCommerce.ts, checkoutCspAdditions)",
|
|
136
|
-
observe:
|
|
137
|
-
"Worker logs on the signed add-to-cart path + checkout-host success beacon; alert on failure ratio",
|
|
138
|
-
},
|
|
139
|
-
threshold: "checkout-start error ratio > 2% over 10m, or add-to-cart 5xx > 1% over 5m",
|
|
140
|
-
severity: "page",
|
|
141
|
-
runbook: "checkout-down",
|
|
142
|
-
wiring: "needs-external",
|
|
143
|
-
notes:
|
|
144
|
-
"Checkout completes on the store's cross-origin cart/checkout host, so full funnel coverage needs a beacon " +
|
|
145
|
-
"from that host too. Storefront-side we can only see the signed handoff; a CSP formAction/frameSrc block " +
|
|
146
|
-
"also surfaces here as csp-violations.",
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
id: "age-verification-failures",
|
|
150
|
-
title: "Age-verification failures",
|
|
151
|
-
category: "compliance",
|
|
152
|
-
signal: {
|
|
153
|
-
source:
|
|
154
|
-
"F12 compliance 'age-verification' evidence signal (AgeGate / IsolatedAgeGate → ToT verification)",
|
|
155
|
-
observe: "F12 evidence signal + ToT verification provider errors; alert on error/timeout rate, not on user-declines",
|
|
156
|
-
},
|
|
157
|
-
threshold: "verification provider error/timeout rate > 5% over 10m (distinct from legitimate fail-age outcomes)",
|
|
158
|
-
severity: "critical",
|
|
159
|
-
runbook: "compliance-provider-down",
|
|
160
|
-
wiring: "needs-external",
|
|
161
|
-
notes:
|
|
162
|
-
"Reference F12's signal by name; do NOT read the compliance internals here. Distinguish PROVIDER failure " +
|
|
163
|
-
"(page/critical — we can't legally sell) from a shopper genuinely failing age (expected, not an alert). " +
|
|
164
|
-
"Pre-launch config-coherence gate is in-repo: GET /api/evidence.json (assembleEvidenceReport → age_gate).",
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
id: "restricted-state-denials",
|
|
168
|
-
title: "Restricted-state / shipping denials (anomaly)",
|
|
169
|
-
category: "compliance",
|
|
170
|
-
signal: {
|
|
171
|
-
source:
|
|
172
|
-
"F12 compliance 'restricted-state denial' signal (StateEligibilityNotice / ShippingRestrictionNotice / complianceFloor)",
|
|
173
|
-
observe: "F12 evidence signal counted per state; alert on ANOMALOUS spike vs baseline, not on absolute count",
|
|
174
|
-
},
|
|
175
|
-
threshold: "denial rate for a state jumps >3x its 7-day baseline over 1h (mis-configured rule, not normal traffic)",
|
|
176
|
-
severity: "warning",
|
|
177
|
-
runbook: "bad-content-policy",
|
|
178
|
-
wiring: "needs-external",
|
|
179
|
-
notes:
|
|
180
|
-
"Denials are EXPECTED (that's the control working). This monitor catches a mis-configured restriction " +
|
|
181
|
-
"rule that suddenly blocks a legal state — a spike, not a level. Reference F12's signal by name. " +
|
|
182
|
-
"Pre-launch config-coherence gate is in-repo: GET /api/evidence.json (jurisdiction/excise signals).",
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
id: "catalog-sync-failures",
|
|
186
|
-
title: "Catalog sync failures",
|
|
187
|
-
category: "catalog",
|
|
188
|
-
signal: {
|
|
189
|
-
source: "Migration incremental sync (packages/migration) + F17 catalog graduation job",
|
|
190
|
-
observe: "sync-job exit status + migration report (errors/skipped); alert on failed or missed run",
|
|
191
|
-
},
|
|
192
|
-
threshold: "any sync job fails, OR no successful sync within the expected cadence window (default 1h)",
|
|
193
|
-
severity: "warning",
|
|
194
|
-
runbook: "catalog-stale",
|
|
195
|
-
wiring: "needs-external",
|
|
196
|
-
notes:
|
|
197
|
-
"Escalate to critical once a store is on a live source (F17): a failed sync means the catalog is drifting " +
|
|
198
|
-
"from the merchant source. Depends on F17 defining the launch cadence.",
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
id: "inventory-mismatch",
|
|
202
|
-
title: "Inventory mismatch (oversell risk)",
|
|
203
|
-
category: "catalog",
|
|
204
|
-
signal: {
|
|
205
|
-
source: "F17 inventory-freshness mismatch alarm (storefront-shown vs source-of-truth stock)",
|
|
206
|
-
observe: "reconciliation check comparing served inventory to the merchant/hosted source",
|
|
207
|
-
},
|
|
208
|
-
threshold: "any product served in-stock while source says out-of-stock, or staleness > sync cadence + grace",
|
|
209
|
-
severity: "critical",
|
|
210
|
-
runbook: "catalog-stale",
|
|
211
|
-
wiring: "needs-external",
|
|
212
|
-
notes:
|
|
213
|
-
"Overselling regulated goods is a launch-blocker. This alarm is the one F16 defines but F17 FEEDS with real " +
|
|
214
|
-
"data — until F17 lands it is a contract only.",
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
id: "payment-failures",
|
|
218
|
-
title: "Payment failures",
|
|
219
|
-
category: "commerce",
|
|
220
|
-
signal: {
|
|
221
|
-
source: "Payment provider on the checkout host (external to the storefront Worker)",
|
|
222
|
-
observe: "payment provider dashboard/webhooks; alert on declined/error rate vs baseline",
|
|
223
|
-
},
|
|
224
|
-
threshold: "payment error rate (non-decline gateway errors) > 3% over 15m",
|
|
225
|
-
severity: "page",
|
|
226
|
-
runbook: "checkout-down",
|
|
227
|
-
wiring: "needs-external",
|
|
228
|
-
notes:
|
|
229
|
-
"Owned by the checkout/payment provider, not this Worker. Separate genuine card declines (expected) from " +
|
|
230
|
-
"gateway/integration errors (alert). Coordinate the provider webhook wiring with F11/F17 owners.",
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
id: "csp-violations",
|
|
234
|
-
title: "CSP violations",
|
|
235
|
-
category: "security",
|
|
236
|
-
signal: {
|
|
237
|
-
source: "POST /api/csp-report (CSP_REPORT_PATH / CSP_REPORT_GROUP) — logs '[csp-report]'",
|
|
238
|
-
observe: "log-based alert on '[csp-report]' volume; CSP is ENFORCED in prod (middleware sets Content-Security-Policy)",
|
|
239
|
-
},
|
|
240
|
-
threshold: "sustained new-violation stream (> baseline) — esp. on checkout/widget origins after a publish",
|
|
241
|
-
severity: "warning",
|
|
242
|
-
runbook: "bad-content-policy",
|
|
243
|
-
wiring: "in-code",
|
|
244
|
-
notes:
|
|
245
|
-
"Emitter already ships (pages/api/csp-report.ts). Only a log-volume alert rule needs attaching. A spike after " +
|
|
246
|
-
"a tenant publish means a script/style/frame origin needs adding to the allowlist — or a blocked injection.",
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
id: "core-web-vitals",
|
|
250
|
-
title: "Core Web Vitals (LCP / INP / CLS)",
|
|
251
|
-
category: "performance",
|
|
252
|
-
signal: {
|
|
253
|
-
source: "F14 RUM beacon (web-vitals: LCP, INP, CLS) — Real User Monitoring",
|
|
254
|
-
observe: "RUM sink p75 per metric per key template (home, PLP, PDP, checkout entry)",
|
|
255
|
-
},
|
|
256
|
-
threshold: "p75 regresses past 'good': LCP > 2.5s, INP > 200ms, CLS > 0.1 (sustained over 1h)",
|
|
257
|
-
severity: "warning",
|
|
258
|
-
runbook: "bad-content-policy",
|
|
259
|
-
wiring: "needs-external",
|
|
260
|
-
notes:
|
|
261
|
-
"Reference F14's consent-gated RUM signal by name; do not duplicate its analytics implementation.",
|
|
262
|
-
},
|
|
263
|
-
] as const;
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* The monitors this contract requires by name. The test asserts MONITORS covers exactly
|
|
267
|
-
* these — so dropping or misnaming one fails CI, and adding a new monitor is a
|
|
268
|
-
* deliberate edit here.
|
|
269
|
-
*/
|
|
270
|
-
export const REQUIRED_MONITOR_IDS = [
|
|
271
|
-
"uptime",
|
|
272
|
-
"page-errors",
|
|
273
|
-
"checkout-failures",
|
|
274
|
-
"age-verification-failures",
|
|
275
|
-
"restricted-state-denials",
|
|
276
|
-
"catalog-sync-failures",
|
|
277
|
-
"inventory-mismatch",
|
|
278
|
-
"payment-failures",
|
|
279
|
-
"csp-violations",
|
|
280
|
-
"core-web-vitals",
|
|
281
|
-
] as const;
|
|
282
|
-
|
|
283
|
-
/** The six incident runbooks in RUNBOOK.md §7 that monitors dispatch to. */
|
|
284
|
-
export const RUNBOOK_IDS: readonly RunbookId[] = [
|
|
285
|
-
"checkout-down",
|
|
286
|
-
"catalog-stale",
|
|
287
|
-
"bad-price",
|
|
288
|
-
"compliance-provider-down",
|
|
289
|
-
"tax-shipping-outage",
|
|
290
|
-
"bad-content-policy",
|
|
291
|
-
] as const;
|
|
292
|
-
|
|
293
|
-
/** Lookup a monitor by id (undefined if absent). */
|
|
294
|
-
export function getMonitor(id: string): Monitor | undefined {
|
|
295
|
-
return MONITORS.find((m) => m.id === id);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/** Monitors still needing external wiring or a secret before they alert. */
|
|
299
|
-
export function monitorsNeedingWiring(): readonly Monitor[] {
|
|
300
|
-
return MONITORS.filter((m) => m.wiring !== "in-code");
|
|
301
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* F14 — Lighthouse result → budget measurement (the lab hook, pure half).
|
|
3
|
-
*
|
|
4
|
-
* The budget gate (`perfBudgets.ts`) evaluates a tool-neutral `RouteMeasurement`.
|
|
5
|
-
* This module is the one adapter that turns a Lighthouse result object (LHR JSON,
|
|
6
|
-
* as `lighthouse --output=json` / LHCI emit) into that shape, so a live
|
|
7
|
-
* Lighthouse run in preview validation feeds the SAME gate the unit tests do.
|
|
8
|
-
*
|
|
9
|
-
* Kept pure (LHR in → measurement out, no fs/network) so `lighthouseReport.test.ts`
|
|
10
|
-
* can prove the extraction against a fixture LHR without running Lighthouse; the
|
|
11
|
-
* thin CLI (`perf/assert-budgets.ts`) does the fs + Lighthouse invocation.
|
|
12
|
-
*
|
|
13
|
-
* We read only the stable, documented LHR fields:
|
|
14
|
-
* - `audits['largest-contentful-paint'].numericValue` (ms) → webVitals.lcpMs
|
|
15
|
-
* - `audits['cumulative-layout-shift'].numericValue` (unitless)→ webVitals.cls
|
|
16
|
-
* - `audits['resource-summary'].details.items[]` (bytes) → resource KiB
|
|
17
|
-
* - `audits['network-requests'].details.items[]` (url) → third-party origins
|
|
18
|
-
* INP is intentionally absent — it has no lab value; it is enforced from field
|
|
19
|
-
* RUM (`rumAlert.ts`), matching `toLighthouseBudgets`' note.
|
|
20
|
-
*
|
|
21
|
-
* Third-party origins are taken from `network-requests` (real request URLs →
|
|
22
|
-
* hostnames), NOT `third-party-summary` — the latter reports entity DISPLAY
|
|
23
|
-
* names ("Google Fonts"), which would never match the manifest's hostname
|
|
24
|
-
* allowlist. We keep hostnames that loaded a Script and are cross-origin to the
|
|
25
|
-
* page, so the gate's allowlist check compares like-for-like.
|
|
26
|
-
*/
|
|
27
|
-
import type { RouteId, RouteMeasurement } from "./perfBudgets.js";
|
|
28
|
-
|
|
29
|
-
/** The (loose) slice of a Lighthouse result we read. */
|
|
30
|
-
export interface LighthouseResult {
|
|
31
|
-
audits?: Record<
|
|
32
|
-
string,
|
|
33
|
-
{
|
|
34
|
-
numericValue?: number;
|
|
35
|
-
details?: {
|
|
36
|
-
items?: Array<Record<string, unknown>>;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
>;
|
|
40
|
-
finalUrl?: string;
|
|
41
|
-
requestedUrl?: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const hostnameOf = (url: string | undefined): string | undefined => {
|
|
45
|
-
if (!url) return undefined;
|
|
46
|
-
try {
|
|
47
|
-
return new URL(url).hostname.toLowerCase();
|
|
48
|
-
} catch {
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const BYTES_PER_KIB = 1024;
|
|
54
|
-
const toKib = (bytes: unknown): number | undefined =>
|
|
55
|
-
typeof bytes === "number" && Number.isFinite(bytes)
|
|
56
|
-
? Math.round((bytes / BYTES_PER_KIB) * 10) / 10
|
|
57
|
-
: undefined;
|
|
58
|
-
|
|
59
|
-
/** Map a Lighthouse `resource-summary` resourceType onto our budget keys. */
|
|
60
|
-
const RESOURCE_TYPE_KEY: Record<string, "jsKib" | "cssKib" | "imageKib" | "totalKib"> = {
|
|
61
|
-
script: "jsKib",
|
|
62
|
-
stylesheet: "cssKib",
|
|
63
|
-
image: "imageKib",
|
|
64
|
-
total: "totalKib",
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Extract a `RouteMeasurement` for `routeId` from a Lighthouse result. Missing
|
|
69
|
-
* audits simply yield missing dimensions — the gate only checks what was
|
|
70
|
-
* measured — so a partial/failed audit under-reports rather than crashing.
|
|
71
|
-
*/
|
|
72
|
-
export function lhrToMeasurement(lhr: LighthouseResult, routeId: RouteId): RouteMeasurement {
|
|
73
|
-
const audits = lhr.audits ?? {};
|
|
74
|
-
|
|
75
|
-
const resources: NonNullable<RouteMeasurement["resources"]> = {};
|
|
76
|
-
const summaryItems = audits["resource-summary"]?.details?.items ?? [];
|
|
77
|
-
for (const item of summaryItems) {
|
|
78
|
-
const type = typeof item["resourceType"] === "string" ? (item["resourceType"] as string) : "";
|
|
79
|
-
const key = RESOURCE_TYPE_KEY[type];
|
|
80
|
-
const kib = toKib(item["transferSize"]);
|
|
81
|
-
if (key && kib !== undefined) resources[key] = kib;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const webVitals: NonNullable<RouteMeasurement["webVitals"]> = {};
|
|
85
|
-
const lcp = audits["largest-contentful-paint"]?.numericValue;
|
|
86
|
-
if (typeof lcp === "number") webVitals.lcpMs = Math.round(lcp);
|
|
87
|
-
const cls = audits["cumulative-layout-shift"]?.numericValue;
|
|
88
|
-
if (typeof cls === "number") webVitals.cls = Math.round(cls * 1e4) / 1e4;
|
|
89
|
-
|
|
90
|
-
// Third-party SCRIPT hostnames, cross-origin to the page, from real requests.
|
|
91
|
-
const pageHost = hostnameOf(lhr.finalUrl ?? lhr.requestedUrl);
|
|
92
|
-
const netItems = audits["network-requests"]?.details?.items ?? [];
|
|
93
|
-
const thirdPartyOrigins: string[] = [];
|
|
94
|
-
for (const item of netItems) {
|
|
95
|
-
const type = typeof item["resourceType"] === "string" ? (item["resourceType"] as string) : "";
|
|
96
|
-
if (type.toLowerCase() !== "script") continue;
|
|
97
|
-
const host = hostnameOf(typeof item["url"] === "string" ? (item["url"] as string) : undefined);
|
|
98
|
-
if (!host || host === pageHost) continue;
|
|
99
|
-
if (!thirdPartyOrigins.includes(host)) thirdPartyOrigins.push(host);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
routeId,
|
|
104
|
-
...(lhr.finalUrl || lhr.requestedUrl ? { url: lhr.finalUrl ?? lhr.requestedUrl } : {}),
|
|
105
|
-
...(Object.keys(resources).length ? { resources } : {}),
|
|
106
|
-
...(Object.keys(webVitals).length ? { webVitals } : {}),
|
|
107
|
-
...(thirdPartyOrigins.length ? { thirdPartyOrigins } : {}),
|
|
108
|
-
};
|
|
109
|
-
}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* F14 — RUM regression-alert contract.
|
|
3
|
-
*
|
|
4
|
-
* The field beacon (`webVitals.ts`) emits per-route CWV samples; this module is
|
|
5
|
-
* the PURE sink-side logic that turns a window of those samples into regression
|
|
6
|
-
* alerts. It is the code half of F16's `core-web-vitals` monitor: F16's manifest
|
|
7
|
-
* declares WHAT is watched (p75 per metric per key template, threshold "past
|
|
8
|
-
* 'good'", runbook), and names F14's beacon as the source; this decides, from
|
|
9
|
-
* the samples, WHETHER the threshold tripped.
|
|
10
|
-
*
|
|
11
|
-
* Deliberately pure + transport-agnostic: it takes an array of `WebVitalsSample`
|
|
12
|
-
* and returns `RegressionAlert[]`. WHERE the samples come from (a Workers
|
|
13
|
-
* Analytics Engine query, a KV rollup, a Logpush aggregation) and WHERE the
|
|
14
|
-
* alerts go (PagerDuty, Slack, a Logpush alert rule) are the sink's job — this
|
|
15
|
-
* is the contract both sides agree on, and the only part worth unit-testing.
|
|
16
|
-
*
|
|
17
|
-
* The p75 percentile + the 1-hour sustain window match F16's threshold text and
|
|
18
|
-
* Google/CrUX convention. The window itself (which hour of samples) is chosen by
|
|
19
|
-
* the caller; a low-traffic bucket is suppressed by `minSamples` so a single
|
|
20
|
-
* bad sample never pages anyone.
|
|
21
|
-
*/
|
|
22
|
-
import {
|
|
23
|
-
PERF_BUDGETS,
|
|
24
|
-
type PerfBudgetManifest,
|
|
25
|
-
type RouteId,
|
|
26
|
-
} from "./perfBudgets.js";
|
|
27
|
-
import {
|
|
28
|
-
rateMetric,
|
|
29
|
-
type WebVitalName,
|
|
30
|
-
type WebVitalRating,
|
|
31
|
-
type WebVitalsSample,
|
|
32
|
-
} from "./webVitals.js";
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* The F16 monitor this contract feeds. Referenced by id, NOT imported from
|
|
36
|
-
* `monitoring/manifest.ts` — F14 owns the signal, F16 owns the monitor; keeping
|
|
37
|
-
* the coupling to a string means neither unit imports the other's files.
|
|
38
|
-
*/
|
|
39
|
-
export const CWV_MONITOR_ID = "core-web-vitals";
|
|
40
|
-
|
|
41
|
-
/** Alert severity, mirroring F16's `Severity` (kept local to avoid the import). */
|
|
42
|
-
export type AlertSeverity = "page" | "critical" | "warning" | "info";
|
|
43
|
-
|
|
44
|
-
/** The p75 rollup for one route bucket over the caller's window. */
|
|
45
|
-
export interface RouteVitalsP75 {
|
|
46
|
-
route: RouteId;
|
|
47
|
-
/** Number of samples that fed this bucket (across all three metrics). */
|
|
48
|
-
sampleCount: number;
|
|
49
|
-
/** p75 per metric, or undefined when the window had no sample for it. */
|
|
50
|
-
p75: Partial<Record<WebVitalName, number>>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** One regression: a route's p75 for a metric crossed out of `good`. */
|
|
54
|
-
export interface RegressionAlert {
|
|
55
|
-
/** Always `core-web-vitals` — the F16 monitor an operator opens. */
|
|
56
|
-
monitorId: typeof CWV_MONITOR_ID;
|
|
57
|
-
route: RouteId;
|
|
58
|
-
metric: WebVitalName;
|
|
59
|
-
/** The observed p75 that tripped the alert. */
|
|
60
|
-
p75: number;
|
|
61
|
-
/** The `good` budget line it crossed. */
|
|
62
|
-
budget: number;
|
|
63
|
-
/** `needs-improvement` (warning) or `poor` (critical). */
|
|
64
|
-
rating: Exclude<WebVitalRating, "good">;
|
|
65
|
-
severity: AlertSeverity;
|
|
66
|
-
sampleCount: number;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface DetectOptions {
|
|
70
|
-
/**
|
|
71
|
-
* Minimum samples in a route bucket before it can alert — guards low-traffic
|
|
72
|
-
* routes from paging on noise. Default 50 (a stable-ish p75).
|
|
73
|
-
*/
|
|
74
|
-
minSamples?: number;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Exact-rank percentile (nearest-rank, p in [0,1]) over a numeric series.
|
|
79
|
-
* Small windows are fine — this is O(n log n) and the series is one route-hour.
|
|
80
|
-
*/
|
|
81
|
-
export function percentile(values: readonly number[], p: number): number | undefined {
|
|
82
|
-
if (values.length === 0) return undefined;
|
|
83
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
84
|
-
const rank = Math.ceil(p * sorted.length);
|
|
85
|
-
const idx = Math.min(Math.max(rank, 1), sorted.length) - 1;
|
|
86
|
-
return sorted[idx];
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const METRICS: readonly WebVitalName[] = ["lcp", "inp", "cls"];
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Roll a flat sample list up into per-route p75s. Samples whose route is
|
|
93
|
-
* `"other"` (unbudgeted) are dropped — we only alert on budgeted templates.
|
|
94
|
-
*/
|
|
95
|
-
export function aggregateP75(samples: readonly WebVitalsSample[]): RouteVitalsP75[] {
|
|
96
|
-
const byRoute = new Map<RouteId, Map<WebVitalName, number[]>>();
|
|
97
|
-
for (const s of samples) {
|
|
98
|
-
if (s.route === "other") continue;
|
|
99
|
-
let metrics = byRoute.get(s.route);
|
|
100
|
-
if (!metrics) {
|
|
101
|
-
metrics = new Map();
|
|
102
|
-
byRoute.set(s.route, metrics);
|
|
103
|
-
}
|
|
104
|
-
const series = metrics.get(s.metric) ?? [];
|
|
105
|
-
series.push(s.value);
|
|
106
|
-
metrics.set(s.metric, series);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const out: RouteVitalsP75[] = [];
|
|
110
|
-
for (const [route, metrics] of byRoute) {
|
|
111
|
-
const p75: Partial<Record<WebVitalName, number>> = {};
|
|
112
|
-
let sampleCount = 0;
|
|
113
|
-
for (const metric of METRICS) {
|
|
114
|
-
const series = metrics.get(metric);
|
|
115
|
-
if (!series?.length) continue;
|
|
116
|
-
sampleCount += series.length;
|
|
117
|
-
const v = percentile(series, 0.75);
|
|
118
|
-
if (v !== undefined) p75[metric] = v;
|
|
119
|
-
}
|
|
120
|
-
out.push({ route, sampleCount, p75 });
|
|
121
|
-
}
|
|
122
|
-
return out;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function severityFor(rating: Exclude<WebVitalRating, "good">): AlertSeverity {
|
|
126
|
-
// A `poor` p75 is customer-visible degradation → same-hours critical; a
|
|
127
|
-
// `needs-improvement` p75 is the leading-indicator warning F16 describes.
|
|
128
|
-
return rating === "poor" ? "critical" : "warning";
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* The contract: given a window of field samples, return the regressions. A
|
|
133
|
-
* regression is a budgeted route whose p75 for some metric rates worse than
|
|
134
|
-
* `good`, in a bucket with enough samples to trust. Zero regressions ⇒ the
|
|
135
|
-
* `core-web-vitals` monitor stays green.
|
|
136
|
-
*/
|
|
137
|
-
export function detectRegressions(
|
|
138
|
-
samples: readonly WebVitalsSample[],
|
|
139
|
-
manifest: PerfBudgetManifest = PERF_BUDGETS,
|
|
140
|
-
opts: DetectOptions = {},
|
|
141
|
-
): RegressionAlert[] {
|
|
142
|
-
const minSamples = opts.minSamples ?? 50;
|
|
143
|
-
const budgets: Record<WebVitalName, number> = {
|
|
144
|
-
lcp: manifest.webVitals.lcpMs,
|
|
145
|
-
inp: manifest.webVitals.inpMs,
|
|
146
|
-
cls: manifest.webVitals.cls,
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const alerts: RegressionAlert[] = [];
|
|
150
|
-
for (const bucket of aggregateP75(samples)) {
|
|
151
|
-
if (bucket.sampleCount < minSamples) continue;
|
|
152
|
-
for (const metric of METRICS) {
|
|
153
|
-
const p75 = bucket.p75[metric];
|
|
154
|
-
if (p75 === undefined) continue;
|
|
155
|
-
const rating = rateMetric(metric, p75, manifest);
|
|
156
|
-
if (rating === "good") continue;
|
|
157
|
-
alerts.push({
|
|
158
|
-
monitorId: CWV_MONITOR_ID,
|
|
159
|
-
route: bucket.route,
|
|
160
|
-
metric,
|
|
161
|
-
p75,
|
|
162
|
-
budget: budgets[metric],
|
|
163
|
-
rating,
|
|
164
|
-
severity: severityFor(rating),
|
|
165
|
-
sampleCount: bucket.sampleCount,
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return alerts;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/** One-line alert summary for a log line / notification body. */
|
|
173
|
-
export function formatRegressionAlert(a: RegressionAlert): string {
|
|
174
|
-
const unit = a.metric === "cls" ? "" : "ms";
|
|
175
|
-
return (
|
|
176
|
-
`[${a.severity}] ${a.monitorId}: ${a.route} ${a.metric.toUpperCase()} ` +
|
|
177
|
-
`p75 ${a.p75}${unit} > budget ${a.budget}${unit} (${a.rating}, n=${a.sampleCount})`
|
|
178
|
-
);
|
|
179
|
-
}
|