xytara 3.1.16 → 3.2.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 (390) hide show
  1. package/README.md +120 -92
  2. package/RELEASE_NOTES.md +7 -3
  3. package/START_HERE.md +56 -224
  4. package/bin/xytara.js +21 -8
  5. package/client.js +79 -1
  6. package/lib/{delivery_receipt.js → delivery_receipt_verify.js} +14 -100
  7. package/package.json +25 -35
  8. package/scripts/verify_client.js +418 -0
  9. package/scripts/verify_release_candidate.js +146 -45
  10. package/.env.example +0 -173
  11. package/ADAPTER_START_HERE.md +0 -56
  12. package/BSV_TERANODE_PLATFORM_DISCONTINUITY_RUNBOOK.md +0 -126
  13. package/CARRIED_HANDOFF_DEMO.md +0 -60
  14. package/EXAMPLE_PATHS.md +0 -53
  15. package/FINAL_CONTRACT.md +0 -498
  16. package/PARTNER_READY_PATH.md +0 -71
  17. package/PUBLIC_DEMO_SCRIPT.md +0 -78
  18. package/REAL_PAYMENT_SETUP.md +0 -320
  19. package/SERVICE_CONTRACT.md +0 -419
  20. package/SUPABASE_RUNTIME_STATE_SETUP.md +0 -61
  21. package/TERMINOLOGY.md +0 -50
  22. package/WHY_XYTARA_XOONYA.md +0 -63
  23. package/XT1_EXECUTION_TRUTH_STANDARD.md +0 -78
  24. package/XYTARA_ADAPTER_PROTOCOL_TRUTH_MODEL.md +0 -75
  25. package/XYTARA_AUTONOMOUS_ENTRY_MODEL.md +0 -124
  26. package/XYTARA_DEFAULT_PATH_MODEL.md +0 -84
  27. package/XYTARA_EXECUTION_TRUTH_MODEL.md +0 -171
  28. package/XYTARA_PAYMENT_RAIL_TRUTH_MODEL.md +0 -68
  29. package/adapters/AUTHORING_GUIDE.md +0 -244
  30. package/adapters/ONBOARDING_POSTURE.md +0 -61
  31. package/adapters/THIRD_PARTY_SUBMISSION_PROCESS.md +0 -84
  32. package/adapters/adapter-manifest.schema.json +0 -283
  33. package/adapters/examples/example-execution-adapter.js +0 -61
  34. package/adapters/examples/example-execution-adapter.manifest.json +0 -81
  35. package/adapters/examples/example-settlement-adapter.js +0 -55
  36. package/adapters/examples/example-settlement-adapter.manifest.json +0 -78
  37. package/adapters/examples/example-third-party-acp-registration.submission-bundle.json +0 -124
  38. package/adapters/examples/example-third-party-erc8004-registration.submission-bundle.json +0 -121
  39. package/adapters/examples/example-third-party-identity-registration.certification-pack.json +0 -22
  40. package/adapters/examples/example-third-party-identity-registration.record.json +0 -26
  41. package/adapters/examples/example-third-party-identity-registration.submission-bundle.json +0 -126
  42. package/adapters/examples/example-third-party-langchain-registration.submission-bundle.json +0 -124
  43. package/adapters/examples/example-third-party-mpp-registration.submission-bundle.json +0 -120
  44. package/adapters/examples/example-third-party-registration.certification-pack.json +0 -22
  45. package/adapters/examples/example-third-party-registration.record.json +0 -28
  46. package/adapters/examples/example-third-party-registration.submission-bundle.json +0 -126
  47. package/adapters/examples/example-third-party-settlement-registration.certification-pack.json +0 -22
  48. package/adapters/examples/example-third-party-settlement-registration.record.json +0 -26
  49. package/adapters/examples/example-third-party-settlement-registration.submission-bundle.json +0 -127
  50. package/adapters/examples/langchain-reference-execution-adapter.js +0 -81
  51. package/adapters/examples/langchain-reference-execution-adapter.manifest.json +0 -79
  52. package/adapters/examples/langgraph-reference-execution-adapter.js +0 -81
  53. package/adapters/examples/langgraph-reference-execution-adapter.manifest.json +0 -79
  54. package/adapters/examples/minimal-third-party-execution-adapter.js +0 -61
  55. package/adapters/examples/minimal-third-party-execution-adapter.manifest.json +0 -79
  56. package/adapters/examples/minimal-third-party-execution-registration.record.json +0 -26
  57. package/adapters/examples/minimal-third-party-execution.certification-pack.json +0 -22
  58. package/adapters/examples/minimal-third-party-execution.submission-bundle.json +0 -126
  59. package/adapters/integration-certification-pack.schema.json +0 -82
  60. package/adapters/integration-registration-record.schema.json +0 -114
  61. package/adapters/integration-submission-bundle-set.schema.json +0 -39
  62. package/adapters/integration-submission-bundle.schema.json +0 -34
  63. package/adapters/interfaces.js +0 -56
  64. package/bin/xytara-release.js +0 -1429
  65. package/examples/_demo_env.js +0 -40
  66. package/examples/adapter_review_walkthrough.js +0 -54
  67. package/examples/export_carried_handoff.js +0 -81
  68. package/examples/funded_runtime_walkthrough.js +0 -71
  69. package/examples/partner_launch_walkthrough.js +0 -44
  70. package/examples/quickstart.js +0 -3256
  71. package/fixtures/catalog.js +0 -1156
  72. package/index.js +0 -395
  73. package/integrations/dispatch.js +0 -276
  74. package/integrations/registry-snapshot.schema.json +0 -36
  75. package/integrations/registry.js +0 -2261
  76. package/integrations/views.js +0 -28
  77. package/lib/a2a_lane_contract.js +0 -104
  78. package/lib/a2a_rpc.js +0 -287
  79. package/lib/a2c_lane_contract.js +0 -111
  80. package/lib/account_auth.js +0 -585
  81. package/lib/acp_lane_contract.js +0 -54
  82. package/lib/activity_audit_contract.js +0 -322
  83. package/lib/adapter_certification_contract.js +0 -130
  84. package/lib/adapter_depth_contract.js +0 -218
  85. package/lib/adapter_pack.js +0 -118
  86. package/lib/adapter_partner_pack.js +0 -89
  87. package/lib/adapter_promotion_pack.js +0 -89
  88. package/lib/adapter_protocol_truth_contract.js +0 -229
  89. package/lib/agent_identity.js +0 -162
  90. package/lib/announcement_pack.js +0 -61
  91. package/lib/artifact_distribution_lane_contract.js +0 -54
  92. package/lib/asyncapi_contract.js +0 -150
  93. package/lib/auth_interop_contract.js +0 -80
  94. package/lib/authority_binding_lifecycle_contract.js +0 -182
  95. package/lib/autonomous_entry_contract.js +0 -409
  96. package/lib/bolt_adapter.js +0 -187
  97. package/lib/bolt_lane_contract.js +0 -55
  98. package/lib/bolt_payment_front.js +0 -224
  99. package/lib/business_cockpit.js +0 -378
  100. package/lib/buyer_event_log.js +0 -230
  101. package/lib/buyer_safety_policy.js +0 -132
  102. package/lib/capability_execution_truth.js +0 -276
  103. package/lib/capability_registry.js +0 -633
  104. package/lib/catalog_contract.js +0 -966
  105. package/lib/catalog_family_model.js +0 -193
  106. package/lib/catalog_views.js +0 -55
  107. package/lib/cdp_jwt.js +0 -57
  108. package/lib/checkout_event_security.js +0 -142
  109. package/lib/checkout_processor_adapter.js +0 -217
  110. package/lib/cloudevents_contract.js +0 -80
  111. package/lib/command_flow.js +0 -911
  112. package/lib/commerce_artifacts.js +0 -591
  113. package/lib/commerce_authority.js +0 -449
  114. package/lib/commerce_bridge.js +0 -274
  115. package/lib/commerce_cases.js +0 -399
  116. package/lib/commerce_checkout.js +0 -509
  117. package/lib/commerce_coordination.js +0 -346
  118. package/lib/commerce_economics.js +0 -4017
  119. package/lib/commerce_identity.js +0 -578
  120. package/lib/commerce_quotes.js +0 -266
  121. package/lib/commerce_reports.js +0 -14461
  122. package/lib/commerce_runtime.js +0 -322
  123. package/lib/commerce_shell.js +0 -257
  124. package/lib/crypto_agility_matrix.js +0 -125
  125. package/lib/default_path_contract.js +0 -412
  126. package/lib/delivery_summary_contract.js +0 -95
  127. package/lib/ecosystem_entry.js +0 -64
  128. package/lib/erc8004_lane_contract.js +0 -65
  129. package/lib/event_system_lane_contract.js +0 -75
  130. package/lib/execution_dedupe.js +0 -86
  131. package/lib/execution_truth_contract.js +0 -234
  132. package/lib/external_credit_bridge.js +0 -142
  133. package/lib/external_execution_policy.js +0 -143
  134. package/lib/external_execution_runtime.js +0 -238
  135. package/lib/feature_control_lane_contract.js +0 -54
  136. package/lib/first_run_conversion_contract.js +0 -290
  137. package/lib/framework_lane_contract.js +0 -89
  138. package/lib/framework_provider_promotion.js +0 -235
  139. package/lib/full_catalog_contract.js +0 -525
  140. package/lib/go_live_operator_pack.js +0 -391
  141. package/lib/http_transport.js +0 -99
  142. package/lib/identity_auth.js +0 -175
  143. package/lib/identity_interop_contract.js +0 -82
  144. package/lib/integration_matrix_contract.js +0 -102
  145. package/lib/l402_adapter.js +0 -241
  146. package/lib/l402_lane_contract.js +0 -55
  147. package/lib/l402_payment_front.js +0 -265
  148. package/lib/launch_narrative.js +0 -53
  149. package/lib/lifecycle_continuity_contract.js +0 -115
  150. package/lib/machine_identity_registry_contract.js +0 -199
  151. package/lib/major_rails_lane_contract.js +0 -150
  152. package/lib/market_lane_contract.js +0 -467
  153. package/lib/market_lane_depth_contract.js +0 -182
  154. package/lib/market_lane_promotion_contract.js +0 -210
  155. package/lib/market_lane_trace_contract.js +0 -278
  156. package/lib/mcp_lane_contract.js +0 -137
  157. package/lib/mpp_adapter.js +0 -237
  158. package/lib/network_transport.js +0 -110
  159. package/lib/offline_verifiability_recovery_contract.js +0 -155
  160. package/lib/openapi_contract.js +0 -300
  161. package/lib/operational_receipt_contract.js +0 -165
  162. package/lib/operator_intelligence.js +0 -407
  163. package/lib/outreach_copy_pack.js +0 -51
  164. package/lib/outreach_message_pack.js +0 -71
  165. package/lib/outreach_proof.js +0 -71
  166. package/lib/outreach_target_pack.js +0 -60
  167. package/lib/partner_intelligence.js +0 -105
  168. package/lib/payment_config.js +0 -257
  169. package/lib/payment_front_registry.js +0 -53
  170. package/lib/payment_protocol_contract.js +0 -165
  171. package/lib/payment_rail_truth_contract.js +0 -324
  172. package/lib/payment_verification.js +0 -357
  173. package/lib/phase_10_closeout_pack.js +0 -45
  174. package/lib/phase_10_completion_pack.js +0 -76
  175. package/lib/phase_10_decision_record_pack.js +0 -54
  176. package/lib/phase_10_decision_resolution_pack.js +0 -53
  177. package/lib/phase_10_demand_signal_adapters_runtime_pack.js +0 -74
  178. package/lib/phase_10_ecosystem_backlog_triage_runtime_pack.js +0 -74
  179. package/lib/phase_10_freeze_baseline_pack.js +0 -67
  180. package/lib/phase_10_freeze_review_pack.js +0 -64
  181. package/lib/phase_10_gate_pack.js +0 -57
  182. package/lib/phase_10_long_tail_continuity_pack.js +0 -80
  183. package/lib/phase_10_long_tail_ecosystem_pack.js +0 -66
  184. package/lib/phase_10_niche_extension_registry_runtime_pack.js +0 -74
  185. package/lib/phase_1_claude_mcp_pack.js +0 -60
  186. package/lib/phase_1_claude_mcp_runtime_pack.js +0 -52
  187. package/lib/phase_1_ecosystem_pack.js +0 -67
  188. package/lib/phase_1_openai_codex_pack.js +0 -60
  189. package/lib/phase_1_openai_codex_runtime_pack.js +0 -52
  190. package/lib/phase_2_base_runtime_pack.js +0 -71
  191. package/lib/phase_2_base_usdc_runtime_pack.js +0 -72
  192. package/lib/phase_2_closeout_pack.js +0 -65
  193. package/lib/phase_2_completion_pack.js +0 -113
  194. package/lib/phase_2_decision_record_pack.js +0 -66
  195. package/lib/phase_2_decision_resolution_pack.js +0 -69
  196. package/lib/phase_2_eth_runtime_pack.js +0 -70
  197. package/lib/phase_2_evm_base_runtime_pack.js +0 -73
  198. package/lib/phase_2_evm_runtime_pack.js +0 -71
  199. package/lib/phase_2_flip_preview_pack.js +0 -60
  200. package/lib/phase_2_freeze_review_pack.js +0 -99
  201. package/lib/phase_2_gate_pack.js +0 -77
  202. package/lib/phase_2_payment_rails_pack.js +0 -71
  203. package/lib/phase_2_usdc_runtime_pack.js +0 -71
  204. package/lib/phase_3_brc_runtime_pack.js +0 -81
  205. package/lib/phase_3_bsv_teranode_runtime_pack.js +0 -83
  206. package/lib/phase_3_closeout_pack.js +0 -62
  207. package/lib/phase_3_completion_pack.js +0 -94
  208. package/lib/phase_3_decision_record_pack.js +0 -64
  209. package/lib/phase_3_decision_resolution_pack.js +0 -69
  210. package/lib/phase_3_freeze_baseline_pack.js +0 -67
  211. package/lib/phase_3_freeze_review_pack.js +0 -80
  212. package/lib/phase_3_gate_pack.js +0 -76
  213. package/lib/phase_3_metanet_runtime_pack.js +0 -81
  214. package/lib/phase_3_native_bsv_pack.js +0 -91
  215. package/lib/phase_3_native_continuity_pack.js +0 -82
  216. package/lib/phase_4_attestation_runtime_pack.js +0 -75
  217. package/lib/phase_4_closeout_pack.js +0 -45
  218. package/lib/phase_4_completion_pack.js +0 -94
  219. package/lib/phase_4_decision_record_pack.js +0 -54
  220. package/lib/phase_4_decision_resolution_pack.js +0 -45
  221. package/lib/phase_4_erc8004_runtime_pack.js +0 -76
  222. package/lib/phase_4_freeze_baseline_pack.js +0 -67
  223. package/lib/phase_4_freeze_review_pack.js +0 -68
  224. package/lib/phase_4_gate_pack.js +0 -58
  225. package/lib/phase_4_identity_registry_runtime_pack.js +0 -75
  226. package/lib/phase_4_identity_trust_pack.js +0 -73
  227. package/lib/phase_4_trust_continuity_pack.js +0 -86
  228. package/lib/phase_5_antelope_runtime_pack.js +0 -76
  229. package/lib/phase_5_closeout_pack.js +0 -44
  230. package/lib/phase_5_completion_pack.js +0 -82
  231. package/lib/phase_5_constellation_dag_runtime_pack.js +0 -76
  232. package/lib/phase_5_decision_record_pack.js +0 -54
  233. package/lib/phase_5_decision_resolution_pack.js +0 -45
  234. package/lib/phase_5_digibyte_dgb_runtime_pack.js +0 -76
  235. package/lib/phase_5_freeze_baseline_pack.js +0 -67
  236. package/lib/phase_5_freeze_review_pack.js +0 -68
  237. package/lib/phase_5_gate_pack.js +0 -58
  238. package/lib/phase_5_hedera_hbar_runtime_pack.js +0 -76
  239. package/lib/phase_5_kaspa_kas_runtime_pack.js +0 -76
  240. package/lib/phase_5_major_rails_continuity_pack.js +0 -86
  241. package/lib/phase_5_major_rails_pack.js +0 -110
  242. package/lib/phase_5_metal_runtime_pack.js +0 -76
  243. package/lib/phase_5_polkadot_dot_runtime_pack.js +0 -76
  244. package/lib/phase_5_proton_xpr_runtime_pack.js +0 -76
  245. package/lib/phase_5_solana_runtime_pack.js +0 -76
  246. package/lib/phase_6_autogen_runtime_pack.js +0 -72
  247. package/lib/phase_6_closeout_pack.js +0 -46
  248. package/lib/phase_6_completion_pack.js +0 -77
  249. package/lib/phase_6_decision_record_pack.js +0 -54
  250. package/lib/phase_6_decision_resolution_pack.js +0 -53
  251. package/lib/phase_6_framework_continuity_pack.js +0 -81
  252. package/lib/phase_6_framework_runtime_pack.js +0 -68
  253. package/lib/phase_6_freeze_baseline_pack.js +0 -68
  254. package/lib/phase_6_freeze_review_pack.js +0 -65
  255. package/lib/phase_6_gate_pack.js +0 -59
  256. package/lib/phase_6_langchain_runtime_pack.js +0 -72
  257. package/lib/phase_6_langgraph_runtime_pack.js +0 -72
  258. package/lib/phase_6_semantic_kernel_runtime_pack.js +0 -72
  259. package/lib/phase_7_closeout_pack.js +0 -45
  260. package/lib/phase_7_completion_pack.js +0 -85
  261. package/lib/phase_7_decision_record_pack.js +0 -53
  262. package/lib/phase_7_decision_resolution_pack.js +0 -53
  263. package/lib/phase_7_event_system_continuity_pack.js +0 -89
  264. package/lib/phase_7_event_system_pack.js +0 -76
  265. package/lib/phase_7_freeze_baseline_pack.js +0 -74
  266. package/lib/phase_7_freeze_review_pack.js +0 -65
  267. package/lib/phase_7_gate_pack.js +0 -58
  268. package/lib/phase_7_kafka_runtime_pack.js +0 -74
  269. package/lib/phase_7_mqtt_runtime_pack.js +0 -74
  270. package/lib/phase_7_nats_runtime_pack.js +0 -74
  271. package/lib/phase_7_webhook_event_bus_runtime_pack.js +0 -74
  272. package/lib/phase_8_closeout_pack.js +0 -46
  273. package/lib/phase_8_completion_pack.js +0 -82
  274. package/lib/phase_8_decision_record_pack.js +0 -54
  275. package/lib/phase_8_decision_resolution_pack.js +0 -53
  276. package/lib/phase_8_external_receipt_import_runtime_pack.js +0 -74
  277. package/lib/phase_8_external_result_import_runtime_pack.js +0 -74
  278. package/lib/phase_8_freeze_baseline_pack.js +0 -71
  279. package/lib/phase_8_freeze_review_pack.js +0 -64
  280. package/lib/phase_8_gate_pack.js +0 -58
  281. package/lib/phase_8_proof_bridge_continuity_pack.js +0 -86
  282. package/lib/phase_8_proof_bridges_pack.js +0 -72
  283. package/lib/phase_8_proof_bundle_normalization_runtime_pack.js +0 -74
  284. package/lib/phase_9_closeout_pack.js +0 -46
  285. package/lib/phase_9_completion_pack.js +0 -82
  286. package/lib/phase_9_custody_refs_runtime_pack.js +0 -74
  287. package/lib/phase_9_decision_record_pack.js +0 -54
  288. package/lib/phase_9_decision_resolution_pack.js +0 -53
  289. package/lib/phase_9_freeze_baseline_pack.js +0 -71
  290. package/lib/phase_9_freeze_review_pack.js +0 -64
  291. package/lib/phase_9_gate_pack.js +0 -58
  292. package/lib/phase_9_operator_accounting_bridges_runtime_pack.js +0 -74
  293. package/lib/phase_9_treasury_connectivity_pack.js +0 -72
  294. package/lib/phase_9_treasury_continuity_pack.js +0 -86
  295. package/lib/phase_9_treasury_destinations_runtime_pack.js +0 -74
  296. package/lib/phase_program_pack.js +0 -120
  297. package/lib/pricing_optimization_contract.js +0 -775
  298. package/lib/protocol_lane_contract.js +0 -117
  299. package/lib/provenance_lane_contract.js +0 -54
  300. package/lib/provider_lane_contract.js +0 -240
  301. package/lib/provider_network_contract.js +0 -149
  302. package/lib/provider_payout_execution.js +0 -155
  303. package/lib/provider_registry.js +0 -852
  304. package/lib/provider_runtime_journey_contract.js +0 -183
  305. package/lib/public_surface_policy_contract.js +0 -111
  306. package/lib/publish_plan.js +0 -51
  307. package/lib/rate_limiter.js +0 -81
  308. package/lib/record_queries.js +0 -48
  309. package/lib/release_candidate.js +0 -50
  310. package/lib/release_center.js +0 -1093
  311. package/lib/release_history.js +0 -205
  312. package/lib/release_manifest.js +0 -113
  313. package/lib/release_pack.js +0 -453
  314. package/lib/request_rate_limit.js +0 -144
  315. package/lib/resource_views.js +0 -31
  316. package/lib/revenue_launch_path_contract.js +0 -326
  317. package/lib/route_matchers.js +0 -34
  318. package/lib/route_params.js +0 -19
  319. package/lib/runtime_bridge.js +0 -124
  320. package/lib/runtime_operations_worker.js +0 -282
  321. package/lib/runtime_state_store.js +0 -495
  322. package/lib/settlement_bsv_live.js +0 -600
  323. package/lib/settlement_bsv_teranode.js +0 -117
  324. package/lib/settlement_lane_contract.js +0 -111
  325. package/lib/shared_signals_lane_contract.js +0 -54
  326. package/lib/signed_audit_provenance_contract.js +0 -83
  327. package/lib/soft_launch_pack.js +0 -78
  328. package/lib/stablecoin_lane_contract.js +0 -76
  329. package/lib/stripe_mpp_lane_contract.js +0 -96
  330. package/lib/stripe_mpp_payment_front.js +0 -258
  331. package/lib/telemetry_lane_contract.js +0 -54
  332. package/lib/treasury_destinations_contract.js +0 -764
  333. package/lib/treasury_egress_policy_contract.js +0 -91
  334. package/lib/treasury_lane_contract.js +0 -84
  335. package/lib/trust_portability_boundary_contract.js +0 -72
  336. package/lib/x402_facilitator.js +0 -198
  337. package/lib/x402_lane_contract.js +0 -136
  338. package/lib/x402_settlement_recovery.js +0 -175
  339. package/scripts/buyer_events_daily_report.js +0 -79
  340. package/scripts/registry_cli.js +0 -275
  341. package/scripts/state_backup_offsite.js +0 -196
  342. package/scripts/verify_a2a_rpc.js +0 -131
  343. package/scripts/verify_adapters.js +0 -554
  344. package/scripts/verify_agent_identity.js +0 -153
  345. package/scripts/verify_all.js +0 -4963
  346. package/scripts/verify_bolt_adapter.js +0 -128
  347. package/scripts/verify_buyer_event_log.js +0 -128
  348. package/scripts/verify_buyer_safety.js +0 -141
  349. package/scripts/verify_cdp_facilitator.js +0 -110
  350. package/scripts/verify_checkout_processor.js +0 -109
  351. package/scripts/verify_commerce_bridge.js +0 -177
  352. package/scripts/verify_control_plane_contracts.js +0 -34
  353. package/scripts/verify_control_plane_routes.js +0 -70
  354. package/scripts/verify_delivery_summary.js +0 -112
  355. package/scripts/verify_examples.js +0 -19
  356. package/scripts/verify_execution_dedupe.js +0 -189
  357. package/scripts/verify_execution_surfacing.js +0 -76
  358. package/scripts/verify_external_execution_retry.js +0 -140
  359. package/scripts/verify_final_activation.js +0 -191
  360. package/scripts/verify_first_run_conversions.js +0 -81
  361. package/scripts/verify_framework_provider_promotion.js +0 -152
  362. package/scripts/verify_full_catalog.js +0 -174
  363. package/scripts/verify_integrations.js +0 -620
  364. package/scripts/verify_l402_adapter.js +0 -86
  365. package/scripts/verify_lifecycle_continuity.js +0 -96
  366. package/scripts/verify_lifecycle_spend_binding.js +0 -88
  367. package/scripts/verify_market_lane_depth.js +0 -94
  368. package/scripts/verify_market_lane_promotion.js +0 -103
  369. package/scripts/verify_market_lane_traces.js +0 -98
  370. package/scripts/verify_market_lanes.js +0 -102
  371. package/scripts/verify_mpp_adapter.js +0 -128
  372. package/scripts/verify_operator_observability_boundary.js +0 -83
  373. package/scripts/verify_pricing_experiment_plan.js +0 -124
  374. package/scripts/verify_production_readiness.js +0 -268
  375. package/scripts/verify_provider_network.js +0 -819
  376. package/scripts/verify_provider_runtime_breadth.js +0 -109
  377. package/scripts/verify_provider_runtime_journeys.js +0 -111
  378. package/scripts/verify_rate_limiter.js +0 -52
  379. package/scripts/verify_refund_credit.js +0 -106
  380. package/scripts/verify_revenue_launch_paths.js +0 -105
  381. package/scripts/verify_runtime_durability.js +0 -52
  382. package/scripts/verify_runtime_state_guard.js +0 -117
  383. package/scripts/verify_service.js +0 -15421
  384. package/scripts/verify_settlement.js +0 -116
  385. package/scripts/verify_tooling.js +0 -1412
  386. package/scripts/verify_treasury_public_boundary.js +0 -97
  387. package/scripts/verify_verify_execute_settle.js +0 -209
  388. package/scripts/verify_x402_facilitator.js +0 -307
  389. package/scripts/verify_x402_settlement_recovery.js +0 -153
  390. package/server.js +0 -12245
@@ -1,775 +0,0 @@
1
- "use strict";
2
-
3
- const { findTask } = require("../fixtures/catalog");
4
- const { getCatalog, getCreditPackList } = require("./catalog_contract");
5
-
6
- const PRICING_BAND_UNITS = {
7
- utility: 1,
8
- transactional: 2,
9
- decision_support: 3,
10
- governed_high_consequence: 5,
11
- trust_critical: 8
12
- };
13
-
14
- const PRICING_EXPERIMENT_REJECTION_CODES = [
15
- "pricing_sample_too_sparse",
16
- "experiment_not_registered",
17
- "experiment_not_allowed_now",
18
- "operator_approval_missing",
19
- "baseline_metrics_missing",
20
- "rollback_trigger_thresholds_missing",
21
- "public_checkout_copy_review_missing",
22
- "post_experiment_review_window_missing",
23
- "target_surface_mismatch"
24
- ];
25
-
26
- const PRICING_EXPERIMENT_LAUNCH_REQUIREMENTS = [
27
- "operator_approval_recorded",
28
- "sample_maturity_is_mature_live_signals",
29
- "baseline_metrics_recorded_before_change",
30
- "rollback_trigger_thresholds_recorded",
31
- "public_checkout_copy_reviewed_for_accuracy",
32
- "post_experiment_review_window_defined"
33
- ];
34
-
35
- function normalizeAmount(value) {
36
- const amount = Number(value || 0);
37
- return Number.isFinite(amount) ? amount : 0;
38
- }
39
-
40
- function collectQuotes(state) {
41
- return state && state.quotes instanceof Map ? Array.from(state.quotes.values()) : [];
42
- }
43
-
44
- function valuesFromCollection(collection) {
45
- if (!collection) return [];
46
- if (collection instanceof Map) return Array.from(collection.values());
47
- return Array.isArray(collection) ? collection : [];
48
- }
49
-
50
- function collectCheckoutPurchaseIntents(state) {
51
- return valuesFromCollection(state && state.checkoutPurchaseIntents);
52
- }
53
-
54
- function collectCheckoutSessions(state) {
55
- return valuesFromCollection(state && state.checkoutSessions);
56
- }
57
-
58
- function collectCheckoutEvents(state) {
59
- return valuesFromCollection(state && state.checkoutEvents);
60
- }
61
-
62
- function collectExternalCreditGrants(state) {
63
- return valuesFromCollection(state && state.externalCreditGrants);
64
- }
65
-
66
- function collectPaymentLedger(state) {
67
- return Array.isArray(state && state.paymentLedger) ? state.paymentLedger : [];
68
- }
69
-
70
- function collectRefunds(state) {
71
- return valuesFromCollection(state && state.refunds);
72
- }
73
-
74
- function collectTransactions(state) {
75
- return valuesFromCollection(state && state.transactions)
76
- .map((entry) => entry && entry.transaction ? entry.transaction : entry)
77
- .filter(Boolean);
78
- }
79
-
80
- function resolveQuotePricingBand(quote) {
81
- const taskRefs = Array.isArray(quote && quote.task_refs) ? quote.task_refs : [];
82
- const observed = new Set();
83
- for (const taskRef of taskRefs) {
84
- const task = findTask(taskRef);
85
- if (task && task.pricing_band) observed.add(task.pricing_band);
86
- }
87
- if (observed.has("trust_critical")) return "trust_critical";
88
- if (observed.has("governed_high_consequence")) return "governed_high_consequence";
89
- if (observed.has("decision_support")) return "decision_support";
90
- if (observed.has("transactional")) return "transactional";
91
- return observed.has("utility") ? "utility" : "utility";
92
- }
93
-
94
- function listTaskPricesByBand() {
95
- const catalog = getCatalog();
96
- const tasks = Array.isArray(catalog && catalog.tasks) ? catalog.tasks : [];
97
- const byBand = new Map();
98
- for (const task of tasks) {
99
- if (!task || !task.pricing_band || !task.public_launch_price) continue;
100
- const amount = normalizeAmount(task.public_launch_price.amount_minor);
101
- if (amount <= 0) continue;
102
- const band = String(task.pricing_band);
103
- const current = byBand.get(band) || [];
104
- current.push(amount);
105
- byBand.set(band, current);
106
- }
107
- return byBand;
108
- }
109
-
110
- function buildMinimumChargeFloors() {
111
- const byBand = listTaskPricesByBand();
112
- return Object.entries(PRICING_BAND_UNITS).map(([pricingBand, usageUnits]) => {
113
- const amounts = (byBand.get(pricingBand) || []).slice().sort((left, right) => left - right);
114
- const observedMin = amounts.length > 0 ? amounts[0] : usageUnits * 10;
115
- return {
116
- pricing_band: pricingBand,
117
- usage_units: usageUnits,
118
- minimum_charge_floor_minor: observedMin,
119
- currency: "USD_CENTS",
120
- reasoning: "prevent_undercharging_of_runtime_consequence_even_when_quotes_are_small"
121
- };
122
- });
123
- }
124
-
125
- function buildStarterPricing() {
126
- const packs = getCreditPackList();
127
- const starter = packs.find((pack) => pack && pack.pack_id === "credits.starter") || null;
128
- return {
129
- starter_pack_id: starter ? starter.pack_id : "credits.starter",
130
- starter_pack_amount_minor: starter ? starter.nominal_amount_minor : 1000,
131
- starter_pack_units: starter ? starter.issued_units : 100,
132
- recommended_free_boundary: [
133
- "auth",
134
- "docs",
135
- "catalog",
136
- "light_preview"
137
- ],
138
- recommended_paid_entry: [
139
- "credit_pack_topup",
140
- "quote_then_execute",
141
- "low_friction_starter_pack_conversion"
142
- ],
143
- why_it_matters: "reduce_first-purchase_friction_without_giving_away_execution_and_consequence"
144
- };
145
- }
146
-
147
- function buildCreditPackBreakpoints() {
148
- return getCreditPackList().map((pack) => ({
149
- pack_id: pack.pack_id,
150
- category: pack.category,
151
- issued_units: pack.issued_units,
152
- nominal_amount_minor: pack.nominal_amount_minor,
153
- intended_usage_posture: pack.intended_usage_posture,
154
- recommended_for: pack.recommended_for
155
- }));
156
- }
157
-
158
- function buildConsequencePremiumMultipliers() {
159
- return [
160
- { posture_id: "standard_runtime", multiplier: 1, recommended_for: "normal_direct_runtime_execution" },
161
- { posture_id: "priority_runtime", multiplier: 1.15, recommended_for: "time-sensitive_runtime_execution" },
162
- { posture_id: "transactional_consequence", multiplier: 1.2, recommended_for: "settlement_or_commit_bearing_work" },
163
- { posture_id: "governed_high_consequence", multiplier: 1.35, recommended_for: "governed_or_multi-step_high_consequence_execution" },
164
- { posture_id: "trust_critical", multiplier: 1.5, recommended_for: "trust-critical_authority_identity_or_proof-bearing_execution" }
165
- ];
166
- }
167
-
168
- function buildQuoteAbandonmentSummary(state) {
169
- const quotes = collectQuotes(state);
170
- const statusCounts = quotes.reduce((acc, quote) => {
171
- const key = quote && quote.status ? quote.status : "unknown";
172
- acc[key] = (acc[key] || 0) + 1;
173
- return acc;
174
- }, {});
175
- const total = quotes.length;
176
- const executed = Number(statusCounts.executed || 0);
177
- const accepted = Number(statusCounts.accepted || 0);
178
- const expired = Number(statusCounts.expired || 0);
179
- const quoted = Number(statusCounts.quoted || 0);
180
- const converted = executed + accepted;
181
- const quotedAmountMinor = quotes.reduce((sum, quote) => sum + normalizeAmount(quote && quote.amount_minor), 0);
182
- const convertedAmountMinor = quotes
183
- .filter((quote) => quote && (quote.status === "accepted" || quote.status === "executed"))
184
- .reduce((sum, quote) => sum + normalizeAmount(quote.amount_minor), 0);
185
- const expiredAmountMinor = quotes
186
- .filter((quote) => quote && quote.status === "expired")
187
- .reduce((sum, quote) => sum + normalizeAmount(quote.amount_minor), 0);
188
- return {
189
- summary_version: "xytara-quote-abandonment-summary-v2",
190
- quote_count: total,
191
- status_counts: statusCounts,
192
- accepted_or_executed_count: converted,
193
- open_quote_count: quoted,
194
- expired_quote_count: expired,
195
- quoted_amount_minor: quotedAmountMinor,
196
- converted_amount_minor: convertedAmountMinor,
197
- expired_amount_minor: expiredAmountMinor,
198
- conversion_rate: total > 0 ? Number((converted / total).toFixed(4)) : null,
199
- abandonment_rate: total > 0 ? Number((expired / total).toFixed(4)) : null,
200
- revenue_capture_rate: quotedAmountMinor > 0 ? Number((convertedAmountMinor / quotedAmountMinor).toFixed(4)) : null,
201
- note: "true_revenue_optimization_requires_live_quote_acceptance_and_abandonment_data_not_just_static_policy"
202
- };
203
- }
204
-
205
- function buildQuoteCohortSummary(state, groupingKey) {
206
- const quotes = collectQuotes(state);
207
- const groups = new Map();
208
- for (const quote of quotes) {
209
- const key = groupingKey(quote);
210
- const current = groups.get(key) || {
211
- cohort_id: key,
212
- quote_count: 0,
213
- quoted_amount_minor: 0,
214
- converted_count: 0,
215
- converted_amount_minor: 0,
216
- expired_count: 0,
217
- expired_amount_minor: 0,
218
- open_count: 0
219
- };
220
- const amount = normalizeAmount(quote && quote.amount_minor);
221
- current.quote_count += 1;
222
- current.quoted_amount_minor += amount;
223
- if (quote && (quote.status === "accepted" || quote.status === "executed")) {
224
- current.converted_count += 1;
225
- current.converted_amount_minor += amount;
226
- } else if (quote && quote.status === "expired") {
227
- current.expired_count += 1;
228
- current.expired_amount_minor += amount;
229
- } else if (quote && quote.status === "quoted") {
230
- current.open_count += 1;
231
- }
232
- groups.set(key, current);
233
- }
234
- return Array.from(groups.values())
235
- .map((entry) => ({
236
- ...entry,
237
- conversion_rate: entry.quote_count > 0 ? Number((entry.converted_count / entry.quote_count).toFixed(4)) : null,
238
- abandonment_rate: entry.quote_count > 0 ? Number((entry.expired_count / entry.quote_count).toFixed(4)) : null,
239
- revenue_capture_rate: entry.quoted_amount_minor > 0
240
- ? Number((entry.converted_amount_minor / entry.quoted_amount_minor).toFixed(4))
241
- : null
242
- }))
243
- .sort((left, right) => right.quoted_amount_minor - left.quoted_amount_minor || right.quote_count - left.quote_count);
244
- }
245
-
246
- function buildQuoteCohorts(state) {
247
- return {
248
- by_pricing_band: buildQuoteCohortSummary(state, (quote) => resolveQuotePricingBand(quote)),
249
- by_payment_protocol: buildQuoteCohortSummary(state, (quote) => quote && quote.payment_protocol ? quote.payment_protocol : "unknown"),
250
- by_settlement_mode: buildQuoteCohortSummary(state, (quote) => quote && quote.settlement_mode ? quote.settlement_mode : "default")
251
- };
252
- }
253
-
254
- function determineSampleMaturity(signalCounts) {
255
- const counts = signalCounts || {};
256
- const quoteCount = Number(counts.quote_count || 0);
257
- const checkoutEventCount = Number(counts.checkout_event_count || 0);
258
- const paymentLedgerCount = Number(counts.payment_ledger_count || 0);
259
- const externalCreditGrantCount = Number(counts.external_credit_grant_count || 0);
260
- const executionTransactionCount = Number(counts.execution_transaction_count || 0);
261
-
262
- if (quoteCount >= 100 && paymentLedgerCount >= 20 && executionTransactionCount >= 20) {
263
- return "mature_live_signals";
264
- }
265
- if (
266
- quoteCount >= 25
267
- && (checkoutEventCount >= 5 || paymentLedgerCount >= 5 || externalCreditGrantCount >= 5)
268
- && executionTransactionCount >= 5
269
- ) {
270
- return "emerging_live_signals";
271
- }
272
- return "sparse_live_signals";
273
- }
274
-
275
- function postureForSampleMaturity(sampleMaturity) {
276
- if (sampleMaturity === "mature_live_signals") return "ready_for_cautious_price_tests";
277
- if (sampleMaturity === "emerging_live_signals") return "observe_and_prepare_small_price_tests";
278
- return "observe_do_not_optimize_aggressively";
279
- }
280
-
281
- function buildRevenueSignalSummary(state) {
282
- const quotes = collectQuotes(state);
283
- const checkoutPurchaseIntents = collectCheckoutPurchaseIntents(state);
284
- const checkoutSessions = collectCheckoutSessions(state);
285
- const checkoutEvents = collectCheckoutEvents(state);
286
- const externalCreditGrants = collectExternalCreditGrants(state);
287
- const paymentLedger = collectPaymentLedger(state);
288
- const refunds = collectRefunds(state);
289
- const transactions = collectTransactions(state);
290
- const quoteSummary = buildQuoteAbandonmentSummary(state);
291
- const paidCheckoutEvents = checkoutEvents.filter((event) => event && event.payment_status === "paid");
292
- const refundedCheckoutEvents = checkoutEvents.filter((event) =>
293
- event && (event.payment_status === "refunded" || event.payment_status === "chargeback")
294
- );
295
- const checkoutPaidIntents = checkoutPurchaseIntents.filter((intent) =>
296
- intent && (
297
- intent.checkout_status === "paid"
298
- || intent.customer_status === "credits_issued"
299
- || intent.customer_status === "execution_dispatched"
300
- || (intent.fulfillment && (intent.fulfillment.credits_issued || intent.fulfillment.execution_authorized))
301
- )
302
- );
303
- const counts = {
304
- quote_count: quotes.length,
305
- checkout_purchase_intent_count: checkoutPurchaseIntents.length,
306
- checkout_session_count: checkoutSessions.length,
307
- checkout_event_count: checkoutEvents.length,
308
- paid_checkout_event_count: paidCheckoutEvents.length,
309
- refunded_checkout_event_count: refundedCheckoutEvents.length,
310
- paid_checkout_intent_count: checkoutPaidIntents.length,
311
- external_credit_grant_count: externalCreditGrants.length,
312
- payment_ledger_count: paymentLedger.length,
313
- refund_count: refunds.length,
314
- execution_transaction_count: transactions.length
315
- };
316
- const sampleMaturity = determineSampleMaturity(counts);
317
- return {
318
- summary_version: "xytara-revenue-signal-summary-v1",
319
- sample_maturity: sampleMaturity,
320
- pricing_change_posture: postureForSampleMaturity(sampleMaturity),
321
- counts,
322
- amounts: {
323
- quoted_amount_minor: quoteSummary.quoted_amount_minor,
324
- converted_quote_amount_minor: quoteSummary.converted_amount_minor,
325
- paid_checkout_amount_minor: paidCheckoutEvents.reduce((sum, event) => sum + normalizeAmount(event && event.amount_received_minor), 0),
326
- payment_ledger_amount_minor: paymentLedger.reduce((sum, payment) => sum + normalizeAmount(payment && payment.amount_minor), 0),
327
- external_credit_grant_amount_minor: externalCreditGrants.reduce((sum, grant) => sum + normalizeAmount(grant && grant.amount_minor), 0),
328
- refund_amount_minor: refunds.reduce((sum, refund) => sum + normalizeAmount(refund && refund.amount_minor), 0)
329
- },
330
- rates: {
331
- quote_conversion_rate: quoteSummary.conversion_rate,
332
- quote_abandonment_rate: quoteSummary.abandonment_rate,
333
- revenue_capture_rate: quoteSummary.revenue_capture_rate,
334
- checkout_paid_rate: checkoutPurchaseIntents.length > 0
335
- ? Number((checkoutPaidIntents.length / checkoutPurchaseIntents.length).toFixed(4))
336
- : null,
337
- refund_request_rate: checkoutPurchaseIntents.length > 0
338
- ? Number((refunds.length / checkoutPurchaseIntents.length).toFixed(4))
339
- : null
340
- },
341
- required_next_metrics: [
342
- "quote_created_and_expired_counts",
343
- "hosted_checkout_start_and_paid_counts",
344
- "hosted_checkout_api_pack_purchase_counts",
345
- "external_credit_grant_success_and_retry_counts",
346
- "execution_transaction_completion_counts",
347
- "refund_and_chargeback_counts"
348
- ],
349
- operator_note: sampleMaturity === "sparse_live_signals"
350
- ? "live_revenue_signals_are_sparse_so_hold_pricing_thresholds_and_collect_more_evidence"
351
- : "live_revenue_signals_are_available_for_careful_operator_review"
352
- };
353
- }
354
-
355
- function buildPricingDecisionGuardrail(state) {
356
- const revenueSignals = buildRevenueSignalSummary(state);
357
- const allowPriceChange = revenueSignals.sample_maturity === "mature_live_signals";
358
- return {
359
- guardrail_version: "xytara-pricing-decision-guardrail-v1",
360
- sample_maturity: revenueSignals.sample_maturity,
361
- allow_price_change: allowPriceChange,
362
- pricing_change_posture: revenueSignals.pricing_change_posture,
363
- required_before_price_change: [
364
- "enough_real_quotes_to_measure_conversion_and_abandonment",
365
- "enough_hosted_checkout_events_to_measure_pack_purchase_conversion",
366
- "enough_external_credit_grants_to_measure_fulfillment_reliability",
367
- "enough_execution_transactions_to_measure_paid_usage_quality",
368
- "refund_or_chargeback_monitoring_present"
369
- ],
370
- allowed_actions: allowPriceChange
371
- ? [
372
- "run_small_operator_reviewed_price_tests",
373
- "adjust_auto_topup_thresholds_with_documented_rationale",
374
- "review_package_breakpoints_against_live_conversion"
375
- ]
376
- : [
377
- "collect_live_quote_checkout_grant_execution_and_refund_metrics",
378
- "keep_current_package_prices_and_thresholds",
379
- "improve_instrumentation_and_operator_reporting"
380
- ],
381
- blocked_actions: allowPriceChange
382
- ? []
383
- : [
384
- "raise_or_lower_public_package_prices_from_sparse_signals",
385
- "change_auto_topup_thresholds_without_live_conversion_rationale",
386
- "remove_starter_api_pack_or_change_hosted_checkout_gateway_language"
387
- ],
388
- evidence: {
389
- counts: revenueSignals.counts,
390
- rates: revenueSignals.rates
391
- }
392
- };
393
- }
394
-
395
- function buildPackageThresholdRationale(state) {
396
- const revenueSignals = buildRevenueSignalSummary(state);
397
- return {
398
- rationale_version: "xytara-package-threshold-rationale-v1",
399
- current_posture: revenueSignals.sample_maturity === "mature_live_signals"
400
- ? "eligible_for_operator_reviewed_threshold_tests"
401
- : "hold_current_thresholds_until_live_metrics_mature",
402
- hosted_checkout_gateway_product_boundary: "public_checkout_sells_api_packs_while_internal_runtime_accounts_consume_credits_and_entitlements",
403
- starter_api_pack: {
404
- public_package_id: "starter-api",
405
- internal_credit_pack_id: "credits.starter",
406
- rationale: "keep_the_first_paid_entry_simple_and_compliant_as_an_api_pack_while_mapping_to_internal_machine_runtime_credits",
407
- tuning_rule: "do_not_change_until_checkout_conversion_grant_success_execution_completion_and_refund_rates_are_visible"
408
- },
409
- auto_topup: {
410
- current_action: "observe",
411
- rationale: "auto_topup_thresholds_should_follow_repeat_usage_and_low_balance_behavior_not_static_launch_assumptions",
412
- tuning_rule: "require_live_repeat_purchase_or_low_balance_data_before_threshold_changes"
413
- },
414
- evidence: {
415
- sample_maturity: revenueSignals.sample_maturity,
416
- counts: revenueSignals.counts
417
- }
418
- };
419
- }
420
-
421
- function buildOptimizationRecommendations(state) {
422
- const quoteSummary = buildQuoteAbandonmentSummary(state);
423
- const cohorts = buildQuoteCohorts(state);
424
- const decisionGuardrail = buildPricingDecisionGuardrail(state);
425
- const recommendations = [];
426
- const utilityBand = cohorts.by_pricing_band.find((entry) => entry.cohort_id === "utility");
427
- const trustBand = cohorts.by_pricing_band.find((entry) => entry.cohort_id === "trust_critical");
428
- const x402Cohort = cohorts.by_payment_protocol.find((entry) => entry.cohort_id === "x402");
429
- const creditCohort = cohorts.by_payment_protocol.find((entry) => entry.cohort_id === "account_credits");
430
- const highOpenQuotes = quoteSummary.open_quote_count >= 5;
431
-
432
- if (decisionGuardrail.allow_price_change && utilityBand && utilityBand.abandonment_rate !== null && utilityBand.abandonment_rate > 0.35) {
433
- recommendations.push({
434
- action_id: "soften_utility_entry_pricing",
435
- why: "utility_band_is_showing_meaningful_quote_abandonment",
436
- target_surface: "starter_pricing_and_minimum_charge_floors",
437
- evidence: utilityBand
438
- });
439
- }
440
- if (decisionGuardrail.allow_price_change && trustBand && trustBand.conversion_rate !== null && trustBand.conversion_rate > 0.7) {
441
- recommendations.push({
442
- action_id: "review_trust_critical_premium_upward",
443
- why: "high-consequence_quotes_are_closing_well_enough_to_support_margin_capture",
444
- target_surface: "high_consequence_premium_multipliers",
445
- evidence: trustBand
446
- });
447
- }
448
- if (decisionGuardrail.allow_price_change && x402Cohort && creditCohort && x402Cohort.conversion_rate !== null && creditCohort.conversion_rate !== null
449
- && x402Cohort.conversion_rate + 0.15 < creditCohort.conversion_rate) {
450
- recommendations.push({
451
- action_id: "push_repeat_use_toward_credits_after_first_x402_conversion",
452
- why: "credits_are_converting_better_than_direct_machine_payment_for_repeat_use",
453
- target_surface: "credit_pack_breakpoints_and_runtime_prompts",
454
- evidence: {
455
- x402: x402Cohort,
456
- account_credits: creditCohort
457
- }
458
- });
459
- }
460
- if (highOpenQuotes) {
461
- recommendations.push({
462
- action_id: "review_quote_ttl_and_follow-up",
463
- why: "too_many_quotes_are_stalling_without_resolving_to_payment_or_expiry",
464
- target_surface: "quote_lifecycle_and_payment_prompts",
465
- evidence: {
466
- open_quote_count: quoteSummary.open_quote_count,
467
- quote_count: quoteSummary.quote_count
468
- }
469
- });
470
- }
471
- if (recommendations.length === 0) {
472
- recommendations.push({
473
- action_id: "continue_live_quote_observation",
474
- why: decisionGuardrail.allow_price_change
475
- ? "no_price_change_signal_has_cleared_operator_review_thresholds_yet"
476
- : "not_enough_live_variance_yet_to_justify_aggressive_pricing_changes",
477
- target_surface: "quote_acceptance_and_abandonment_monitoring",
478
- evidence: {
479
- quote_summary: quoteSummary,
480
- decision_guardrail: decisionGuardrail
481
- }
482
- });
483
- }
484
- return {
485
- recommendation_version: "xytara-pricing-optimization-recommendations-v1",
486
- recommendations
487
- };
488
- }
489
-
490
- function buildPricingExperimentPlan(state) {
491
- const revenueSignals = buildRevenueSignalSummary(state);
492
- const decisionGuardrail = buildPricingDecisionGuardrail(state);
493
- const quoteCohorts = buildQuoteCohorts(state);
494
- const sampleMaturity = revenueSignals.sample_maturity;
495
- const experimentReady = decisionGuardrail.allow_price_change;
496
- const candidateExperiments = [
497
- {
498
- experiment_id: "starter_api_pack_entry_price_test",
499
- target_surface: "hosted_checkout_starter_api_pack",
500
- hypothesis: "starter_entry_conversion_can_improve_without_degrading_refund_or_grant_success_rates",
501
- required_segments: [
502
- "first_purchase",
503
- "hosted_checkout",
504
- "starter_api_pack"
505
- ],
506
- primary_metrics: [
507
- "checkout_paid_rate",
508
- "external_credit_grant_success_rate",
509
- "execution_completion_rate"
510
- ],
511
- rollback_triggers: [
512
- "refund_or_chargeback_rate_increases",
513
- "grant_failure_rate_increases",
514
- "execution_completion_rate_decreases"
515
- ],
516
- allowed_now: experimentReady
517
- },
518
- {
519
- experiment_id: "utility_minimum_floor_test",
520
- target_surface: "utility_pricing_band_minimum_charge_floor",
521
- hypothesis: "utility_quote_abandonment_can_be_reduced_without_training_users_to_expect_free_execution",
522
- required_segments: [
523
- "pricing_band.utility",
524
- "quote_created",
525
- "quote_accepted_or_expired"
526
- ],
527
- primary_metrics: [
528
- "quote_conversion_rate",
529
- "quote_abandonment_rate",
530
- "revenue_capture_rate"
531
- ],
532
- rollback_triggers: [
533
- "revenue_capture_rate_decreases",
534
- "support_or_refund_signal_increases",
535
- "paid_execution_quality_decreases"
536
- ],
537
- allowed_now: experimentReady
538
- },
539
- {
540
- experiment_id: "trust_critical_premium_review",
541
- target_surface: "trust_critical_premium_multiplier",
542
- hypothesis: "high_consequence_work_may_support_higher_margin_when_conversion_is_already_strong",
543
- required_segments: [
544
- "pricing_band.trust_critical",
545
- "converted_quotes",
546
- "completed_transactions"
547
- ],
548
- primary_metrics: [
549
- "trust_critical_conversion_rate",
550
- "completed_paid_execution_count",
551
- "refund_or_dispute_rate"
552
- ],
553
- rollback_triggers: [
554
- "trust_critical_conversion_rate_decreases",
555
- "refund_or_dispute_rate_increases",
556
- "operator_quality_review_fails"
557
- ],
558
- allowed_now: experimentReady
559
- }
560
- ];
561
- return {
562
- experiment_plan_version: "xytara-pricing-experiment-plan-v1",
563
- sample_maturity: sampleMaturity,
564
- experiment_state: experimentReady ? "operator_reviewed_experiments_allowed" : "blocked_collect_more_live_data",
565
- allow_experiment_launch: experimentReady,
566
- required_minimum_live_sample: {
567
- quote_count: 100,
568
- payment_ledger_count: 20,
569
- execution_transaction_count: 20,
570
- refund_monitoring_required: true
571
- },
572
- current_evidence: {
573
- counts: revenueSignals.counts,
574
- rates: revenueSignals.rates,
575
- pricing_band_cohorts: quoteCohorts.by_pricing_band
576
- },
577
- candidate_experiments: candidateExperiments,
578
- launch_requirements: PRICING_EXPERIMENT_LAUNCH_REQUIREMENTS.slice(),
579
- deterministic_rejection_codes: PRICING_EXPERIMENT_REJECTION_CODES.slice(),
580
- launch_request_template: {
581
- experiment_id: "starter_api_pack_entry_price_test",
582
- target_surface: "hosted_checkout_starter_api_pack",
583
- operator_approval_ref: "ops.pricing.approval.<date>",
584
- baseline_metrics_ref: "ops.pricing.baseline.<date>",
585
- rollback_trigger_thresholds: {
586
- refund_or_chargeback_rate_increases: "operator_defined_threshold",
587
- grant_failure_rate_increases: "operator_defined_threshold",
588
- execution_completion_rate_decreases: "operator_defined_threshold"
589
- },
590
- public_checkout_copy_review_ref: "ops.pricing.copy_review.<date>",
591
- post_experiment_review_window_days: 14
592
- },
593
- blocked_actions: experimentReady
594
- ? []
595
- : [
596
- "start_price_ab_test_from_sparse_signals",
597
- "change_public_package_prices_without_operator_approval",
598
- "change_minimum_floors_without_baseline_metrics",
599
- "change_auto_topup_thresholds_without_repeat_usage_data"
600
- ],
601
- allowed_actions: experimentReady
602
- ? [
603
- "prepare_small_operator_reviewed_price_experiment",
604
- "record_baseline_and_rollback_thresholds",
605
- "run_one_surface_at_a_time"
606
- ]
607
- : [
608
- "collect_more_live_quote_payment_execution_and_refund_data",
609
- "review_cohort_instrumentation",
610
- "keep_current_public_prices_and_thresholds"
611
- ],
612
- boundary: "pricing_experiments_are_operator_reviewed_and_data_gated_not_automatic_price_changes"
613
- };
614
- }
615
-
616
- function validatePricingExperimentLaunchRequest(plan, request) {
617
- const pricingPlan = plan || {};
618
- const launchRequest = request || {};
619
- const candidates = Array.isArray(pricingPlan.candidate_experiments)
620
- ? pricingPlan.candidate_experiments
621
- : [];
622
- const experimentId = launchRequest.experiment_id ? String(launchRequest.experiment_id) : "";
623
- const candidate = candidates.find((entry) => entry && entry.experiment_id === experimentId) || null;
624
- const rollbackThresholds = launchRequest.rollback_trigger_thresholds || {};
625
- const missingRollbackThreshold = candidate
626
- ? (Array.isArray(candidate.rollback_triggers) ? candidate.rollback_triggers : [])
627
- .some((trigger) => !rollbackThresholds || !rollbackThresholds[trigger])
628
- : true;
629
- const reviewWindowDays = Number(launchRequest.post_experiment_review_window_days || 0);
630
- const rejectionCodes = [];
631
-
632
- if (pricingPlan.allow_experiment_launch !== true || pricingPlan.sample_maturity !== "mature_live_signals") {
633
- rejectionCodes.push("pricing_sample_too_sparse");
634
- }
635
- if (!candidate) {
636
- rejectionCodes.push("experiment_not_registered");
637
- } else {
638
- if (candidate.allowed_now !== true) rejectionCodes.push("experiment_not_allowed_now");
639
- if (launchRequest.target_surface && launchRequest.target_surface !== candidate.target_surface) {
640
- rejectionCodes.push("target_surface_mismatch");
641
- }
642
- }
643
- if (!launchRequest.operator_approval_ref) rejectionCodes.push("operator_approval_missing");
644
- if (!launchRequest.baseline_metrics_ref) rejectionCodes.push("baseline_metrics_missing");
645
- if (missingRollbackThreshold) rejectionCodes.push("rollback_trigger_thresholds_missing");
646
- if (!launchRequest.public_checkout_copy_review_ref) rejectionCodes.push("public_checkout_copy_review_missing");
647
- if (!Number.isFinite(reviewWindowDays) || reviewWindowDays < 1) {
648
- rejectionCodes.push("post_experiment_review_window_missing");
649
- }
650
-
651
- return {
652
- validation_version: "xytara-pricing-experiment-launch-validation-v1",
653
- launch_allowed: rejectionCodes.length === 0,
654
- experiment_id: experimentId || null,
655
- sample_maturity: pricingPlan.sample_maturity || null,
656
- rejection_codes: Array.from(new Set(rejectionCodes)),
657
- required_requirements: PRICING_EXPERIMENT_LAUNCH_REQUIREMENTS.slice(),
658
- boundary: "pricing_launch_validation_requires_mature_samples_operator_approval_baseline_metrics_and_rollback_thresholds"
659
- };
660
- }
661
-
662
- function summarizePricingExperimentPlan(state) {
663
- const plan = buildPricingExperimentPlan(state);
664
- return {
665
- product: "xytara",
666
- category: "machine-commerce-pricing-experiment-plan-summary",
667
- summary_version: "xytara-pricing-experiment-plan-summary-v1",
668
- sample_maturity: plan.sample_maturity,
669
- experiment_state: plan.experiment_state,
670
- allow_experiment_launch: plan.allow_experiment_launch,
671
- candidate_experiment_count: plan.candidate_experiments.length,
672
- blocked_action_count: plan.blocked_actions.length,
673
- launch_requirement_count: plan.launch_requirements.length,
674
- deterministic_rejection_code_count: plan.deterministic_rejection_codes.length,
675
- boundary: plan.boundary
676
- };
677
- }
678
-
679
- function buildPricingOptimizationPack(state) {
680
- const minimumChargeFloors = buildMinimumChargeFloors();
681
- const starterPricing = buildStarterPricing();
682
- const creditPackBreakpoints = buildCreditPackBreakpoints();
683
- const quoteAbandonmentSummary = buildQuoteAbandonmentSummary(state);
684
- const quoteCohorts = buildQuoteCohorts(state);
685
- const recommendations = buildOptimizationRecommendations(state);
686
- const revenueSignalSummary = buildRevenueSignalSummary(state);
687
- const pricingDecisionGuardrail = buildPricingDecisionGuardrail(state);
688
- const packageThresholdRationale = buildPackageThresholdRationale(state);
689
- const pricingExperimentPlan = buildPricingExperimentPlan(state);
690
- return {
691
- product: "xytara",
692
- category: "machine-commerce-pricing-optimization-pack",
693
- pack_version: "xytara-pricing-optimization-pack-v3",
694
- optimization_posture: "quote_based_pricing_with_credit_conversion_and_consequence_weighting",
695
- pricing_change_posture: revenueSignalSummary.pricing_change_posture,
696
- live_data_note: revenueSignalSummary.operator_note,
697
- why_not_flat_pricing: [
698
- "flat_pricing_undercharges_high_consequence_runtime_work",
699
- "flat_pricing_overprices_simple_utility_and_entry_paths",
700
- "quote_based_pricing_preserves_margin_capture_across_different_runtime_shapes"
701
- ],
702
- minimum_charge_floors: minimumChargeFloors,
703
- pricing_band_review: {
704
- pricing_band_units: PRICING_BAND_UNITS,
705
- policy_goal: "keep_simple_work_easy_to_try_while_protecting_margin_on_consequence-bearing_runtime"
706
- },
707
- credit_pack_breakpoints: creditPackBreakpoints,
708
- starter_pricing: starterPricing,
709
- high_consequence_premium_multipliers: buildConsequencePremiumMultipliers(),
710
- quote_abandonment_summary: quoteAbandonmentSummary,
711
- quote_conversion_cohorts: quoteCohorts,
712
- revenue_signal_summary: revenueSignalSummary,
713
- pricing_decision_guardrail: pricingDecisionGuardrail,
714
- package_threshold_rationale: packageThresholdRationale,
715
- pricing_experiment_plan: pricingExperimentPlan,
716
- optimization_recommendations: recommendations,
717
- data_dependent_tuning: [
718
- "conversion_test_starter_pack_pricing",
719
- "review_quote_acceptance_and_expiry",
720
- "lift_or_lower_minimum_charge_floors_based_on_real_demand",
721
- "tighten_or_relax_premium_multipliers_based_on_close_rate_and_margin"
722
- ],
723
- supported_surfaces: {
724
- credit_pack_ref: "/v1/credit-packs",
725
- pricing_policy_ref_template: "/v1/economics/accounts/:account_id/pricing-policy-package",
726
- quote_policy_ref_template: "/v1/economics/accounts/:account_id/quote-policy-package",
727
- payment_quotes_ref: "/v1/payment-quotes",
728
- quote_cohorts_ref: "/v1/pricing-optimization/quote-cohorts",
729
- recommendations_ref: "/v1/pricing-optimization/recommendations",
730
- revenue_signal_summary_ref: "/v1/pricing-optimization/revenue-signal-summary",
731
- decision_guardrail_ref: "/v1/pricing-optimization/decision-guardrail",
732
- experiment_plan_ref: "/v1/pricing-optimization/experiment-plan",
733
- experiment_plan_summary_ref: "/v1/pricing-optimization/experiment-plan/summary"
734
- }
735
- };
736
- }
737
-
738
- function summarizePricingOptimizationPack(state) {
739
- const pack = buildPricingOptimizationPack(state);
740
- return {
741
- product: "xytara",
742
- category: "machine-commerce-pricing-optimization-pack-summary",
743
- summary_version: "xytara-pricing-optimization-pack-summary-v3",
744
- optimization_posture: pack.optimization_posture,
745
- pricing_change_posture: pack.pricing_change_posture,
746
- sample_maturity: pack.revenue_signal_summary.sample_maturity,
747
- allow_price_change: pack.pricing_decision_guardrail.allow_price_change,
748
- floor_count: pack.minimum_charge_floors.length,
749
- credit_pack_breakpoint_count: pack.credit_pack_breakpoints.length,
750
- premium_multiplier_count: pack.high_consequence_premium_multipliers.length,
751
- quote_count: pack.quote_abandonment_summary.quote_count,
752
- checkout_event_count: pack.revenue_signal_summary.counts.checkout_event_count,
753
- external_credit_grant_count: pack.revenue_signal_summary.counts.external_credit_grant_count,
754
- payment_ledger_count: pack.revenue_signal_summary.counts.payment_ledger_count,
755
- refund_count: pack.revenue_signal_summary.counts.refund_count,
756
- execution_transaction_count: pack.revenue_signal_summary.counts.execution_transaction_count,
757
- recommendation_count: pack.optimization_recommendations.recommendations.length,
758
- candidate_experiment_count: pack.pricing_experiment_plan.candidate_experiments.length,
759
- allow_experiment_launch: pack.pricing_experiment_plan.allow_experiment_launch,
760
- linked_surfaces: pack.supported_surfaces
761
- };
762
- }
763
-
764
- module.exports = {
765
- buildPricingOptimizationPack,
766
- summarizePricingOptimizationPack,
767
- buildQuoteAbandonmentSummary,
768
- buildQuoteCohorts,
769
- buildRevenueSignalSummary,
770
- buildPricingDecisionGuardrail,
771
- buildOptimizationRecommendations,
772
- buildPricingExperimentPlan,
773
- summarizePricingExperimentPlan,
774
- validatePricingExperimentLaunchRequest
775
- };