xytara 2.0.0 → 2.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 (176) hide show
  1. package/.env.example +6 -0
  2. package/ADAPTER_START_HERE.md +56 -0
  3. package/BSV_TERANODE_SETUP.md +30 -1
  4. package/CARRIED_HANDOFF_DEMO.md +60 -0
  5. package/EXAMPLE_PATHS.md +53 -0
  6. package/FINAL_CONTRACT.md +6 -6
  7. package/OPERATIONS_RUNBOOK.md +65 -0
  8. package/OPERATOR_START_HERE.md +63 -0
  9. package/PARTNER_READY_PATH.md +71 -0
  10. package/PROGRAM_COMPLETE_RELEASE.md +63 -0
  11. package/PROGRAM_STATUS.md +57 -0
  12. package/PUBLIC_DEMO_SCRIPT.md +78 -0
  13. package/PUBLISH_PLAN.md +14 -0
  14. package/README.md +142 -6
  15. package/RELEASE_CHECKLIST.md +16 -0
  16. package/RELEASE_NOTES.md +28 -0
  17. package/SERVICE_CONTRACT.md +4 -4
  18. package/START_HERE.md +32 -0
  19. package/SUPABASE_RUNTIME_STATE_SETUP.md +61 -0
  20. package/WHY_XYTARA_XOONYA.md +63 -0
  21. package/adapters/examples/minimal-third-party-execution-adapter.js +61 -0
  22. package/adapters/examples/minimal-third-party-execution-adapter.manifest.json +79 -0
  23. package/adapters/examples/minimal-third-party-execution-registration.record.json +26 -0
  24. package/adapters/examples/minimal-third-party-execution.certification-pack.json +22 -0
  25. package/adapters/examples/minimal-third-party-execution.submission-bundle.json +126 -0
  26. package/bin/xytara-release.js +1419 -0
  27. package/bin/xytara-run.js +186 -0
  28. package/examples/adapter_review_walkthrough.js +53 -0
  29. package/examples/export_carried_handoff.js +80 -0
  30. package/examples/funded_runtime_walkthrough.js +70 -0
  31. package/examples/partner_launch_walkthrough.js +43 -0
  32. package/examples/quickstart.js +3255 -0
  33. package/index.js +87 -1
  34. package/lib/adapter_pack.js +118 -0
  35. package/lib/adapter_partner_pack.js +89 -0
  36. package/lib/adapter_promotion_pack.js +89 -0
  37. package/lib/announcement_pack.js +61 -0
  38. package/lib/commerce_artifacts.js +3 -0
  39. package/lib/commerce_economics.js +14 -0
  40. package/lib/commerce_reports.js +26 -1
  41. package/lib/commerce_shell.js +18 -2
  42. package/lib/ecosystem_entry.js +64 -0
  43. package/lib/launch_narrative.js +53 -0
  44. package/lib/outreach_copy_pack.js +51 -0
  45. package/lib/outreach_message_pack.js +71 -0
  46. package/lib/outreach_proof.js +71 -0
  47. package/lib/outreach_target_pack.js +60 -0
  48. package/lib/phase_10_closeout_pack.js +45 -0
  49. package/lib/phase_10_completion_pack.js +76 -0
  50. package/lib/phase_10_decision_record_pack.js +54 -0
  51. package/lib/phase_10_decision_resolution_pack.js +53 -0
  52. package/lib/phase_10_demand_signal_adapters_runtime_pack.js +74 -0
  53. package/lib/phase_10_ecosystem_backlog_triage_runtime_pack.js +74 -0
  54. package/lib/phase_10_freeze_baseline_pack.js +67 -0
  55. package/lib/phase_10_freeze_review_pack.js +64 -0
  56. package/lib/phase_10_gate_pack.js +57 -0
  57. package/lib/phase_10_long_tail_continuity_pack.js +80 -0
  58. package/lib/phase_10_long_tail_ecosystem_pack.js +66 -0
  59. package/lib/phase_10_niche_extension_registry_runtime_pack.js +74 -0
  60. package/lib/phase_1_claude_mcp_pack.js +60 -0
  61. package/lib/phase_1_claude_mcp_runtime_pack.js +52 -0
  62. package/lib/phase_1_ecosystem_pack.js +67 -0
  63. package/lib/phase_1_openai_codex_pack.js +60 -0
  64. package/lib/phase_1_openai_codex_runtime_pack.js +52 -0
  65. package/lib/phase_2_base_runtime_pack.js +71 -0
  66. package/lib/phase_2_base_usdc_runtime_pack.js +72 -0
  67. package/lib/phase_2_closeout_pack.js +65 -0
  68. package/lib/phase_2_completion_pack.js +113 -0
  69. package/lib/phase_2_decision_record_pack.js +66 -0
  70. package/lib/phase_2_decision_resolution_pack.js +69 -0
  71. package/lib/phase_2_eth_runtime_pack.js +70 -0
  72. package/lib/phase_2_evm_base_runtime_pack.js +73 -0
  73. package/lib/phase_2_evm_runtime_pack.js +71 -0
  74. package/lib/phase_2_flip_preview_pack.js +60 -0
  75. package/lib/phase_2_freeze_review_pack.js +99 -0
  76. package/lib/phase_2_gate_pack.js +77 -0
  77. package/lib/phase_2_payment_rails_pack.js +71 -0
  78. package/lib/phase_2_usdc_runtime_pack.js +71 -0
  79. package/lib/phase_3_brc_runtime_pack.js +81 -0
  80. package/lib/phase_3_bsv_teranode_runtime_pack.js +83 -0
  81. package/lib/phase_3_closeout_pack.js +62 -0
  82. package/lib/phase_3_completion_pack.js +94 -0
  83. package/lib/phase_3_decision_record_pack.js +64 -0
  84. package/lib/phase_3_decision_resolution_pack.js +69 -0
  85. package/lib/phase_3_freeze_baseline_pack.js +67 -0
  86. package/lib/phase_3_freeze_review_pack.js +80 -0
  87. package/lib/phase_3_gate_pack.js +76 -0
  88. package/lib/phase_3_metanet_runtime_pack.js +81 -0
  89. package/lib/phase_3_native_bsv_pack.js +91 -0
  90. package/lib/phase_3_native_continuity_pack.js +82 -0
  91. package/lib/phase_4_attestation_runtime_pack.js +75 -0
  92. package/lib/phase_4_closeout_pack.js +45 -0
  93. package/lib/phase_4_completion_pack.js +94 -0
  94. package/lib/phase_4_decision_record_pack.js +54 -0
  95. package/lib/phase_4_decision_resolution_pack.js +45 -0
  96. package/lib/phase_4_erc8004_runtime_pack.js +76 -0
  97. package/lib/phase_4_freeze_baseline_pack.js +67 -0
  98. package/lib/phase_4_freeze_review_pack.js +68 -0
  99. package/lib/phase_4_gate_pack.js +58 -0
  100. package/lib/phase_4_identity_registry_runtime_pack.js +75 -0
  101. package/lib/phase_4_identity_trust_pack.js +73 -0
  102. package/lib/phase_4_trust_continuity_pack.js +86 -0
  103. package/lib/phase_5_antelope_runtime_pack.js +76 -0
  104. package/lib/phase_5_closeout_pack.js +44 -0
  105. package/lib/phase_5_completion_pack.js +82 -0
  106. package/lib/phase_5_decision_record_pack.js +54 -0
  107. package/lib/phase_5_decision_resolution_pack.js +45 -0
  108. package/lib/phase_5_freeze_baseline_pack.js +67 -0
  109. package/lib/phase_5_freeze_review_pack.js +68 -0
  110. package/lib/phase_5_gate_pack.js +58 -0
  111. package/lib/phase_5_major_rails_continuity_pack.js +86 -0
  112. package/lib/phase_5_major_rails_pack.js +74 -0
  113. package/lib/phase_5_proton_xpr_runtime_pack.js +76 -0
  114. package/lib/phase_5_solana_runtime_pack.js +76 -0
  115. package/lib/phase_6_autogen_runtime_pack.js +72 -0
  116. package/lib/phase_6_closeout_pack.js +46 -0
  117. package/lib/phase_6_completion_pack.js +77 -0
  118. package/lib/phase_6_decision_record_pack.js +54 -0
  119. package/lib/phase_6_decision_resolution_pack.js +53 -0
  120. package/lib/phase_6_framework_continuity_pack.js +81 -0
  121. package/lib/phase_6_framework_runtime_pack.js +68 -0
  122. package/lib/phase_6_freeze_baseline_pack.js +68 -0
  123. package/lib/phase_6_freeze_review_pack.js +65 -0
  124. package/lib/phase_6_gate_pack.js +59 -0
  125. package/lib/phase_6_langchain_runtime_pack.js +72 -0
  126. package/lib/phase_6_langgraph_runtime_pack.js +72 -0
  127. package/lib/phase_6_semantic_kernel_runtime_pack.js +72 -0
  128. package/lib/phase_7_closeout_pack.js +45 -0
  129. package/lib/phase_7_completion_pack.js +85 -0
  130. package/lib/phase_7_decision_record_pack.js +53 -0
  131. package/lib/phase_7_decision_resolution_pack.js +53 -0
  132. package/lib/phase_7_event_system_continuity_pack.js +89 -0
  133. package/lib/phase_7_event_system_pack.js +76 -0
  134. package/lib/phase_7_freeze_baseline_pack.js +74 -0
  135. package/lib/phase_7_freeze_review_pack.js +65 -0
  136. package/lib/phase_7_gate_pack.js +58 -0
  137. package/lib/phase_7_kafka_runtime_pack.js +74 -0
  138. package/lib/phase_7_mqtt_runtime_pack.js +74 -0
  139. package/lib/phase_7_nats_runtime_pack.js +74 -0
  140. package/lib/phase_7_webhook_event_bus_runtime_pack.js +74 -0
  141. package/lib/phase_8_closeout_pack.js +46 -0
  142. package/lib/phase_8_completion_pack.js +82 -0
  143. package/lib/phase_8_decision_record_pack.js +54 -0
  144. package/lib/phase_8_decision_resolution_pack.js +53 -0
  145. package/lib/phase_8_external_receipt_import_runtime_pack.js +74 -0
  146. package/lib/phase_8_external_result_import_runtime_pack.js +74 -0
  147. package/lib/phase_8_freeze_baseline_pack.js +71 -0
  148. package/lib/phase_8_freeze_review_pack.js +64 -0
  149. package/lib/phase_8_gate_pack.js +58 -0
  150. package/lib/phase_8_proof_bridge_continuity_pack.js +86 -0
  151. package/lib/phase_8_proof_bridges_pack.js +72 -0
  152. package/lib/phase_8_proof_bundle_normalization_runtime_pack.js +74 -0
  153. package/lib/phase_9_closeout_pack.js +46 -0
  154. package/lib/phase_9_completion_pack.js +82 -0
  155. package/lib/phase_9_custody_refs_runtime_pack.js +74 -0
  156. package/lib/phase_9_decision_record_pack.js +54 -0
  157. package/lib/phase_9_decision_resolution_pack.js +53 -0
  158. package/lib/phase_9_freeze_baseline_pack.js +71 -0
  159. package/lib/phase_9_freeze_review_pack.js +64 -0
  160. package/lib/phase_9_gate_pack.js +58 -0
  161. package/lib/phase_9_operator_accounting_bridges_runtime_pack.js +74 -0
  162. package/lib/phase_9_treasury_connectivity_pack.js +72 -0
  163. package/lib/phase_9_treasury_continuity_pack.js +86 -0
  164. package/lib/phase_9_treasury_destinations_runtime_pack.js +74 -0
  165. package/lib/phase_program_pack.js +120 -0
  166. package/lib/publish_plan.js +51 -0
  167. package/lib/release_candidate.js +50 -0
  168. package/lib/release_center.js +1085 -0
  169. package/lib/release_history.js +72 -0
  170. package/lib/release_manifest.js +114 -0
  171. package/lib/release_pack.js +454 -0
  172. package/lib/runtime_state_store.js +354 -0
  173. package/lib/settlement_bsv_live.js +262 -13
  174. package/lib/soft_launch_pack.js +78 -0
  175. package/package.json +24 -2
  176. package/server.js +2562 -220
package/server.js CHANGED
@@ -122,10 +122,12 @@ const {
122
122
  const {
123
123
  getBsvSettlementRecord,
124
124
  listBsvSettlementRecords,
125
+ loadBsvSettlementRuntimeConfig,
125
126
  refreshBsvSettlementRecord,
126
127
  submitBsvSettlementRecord,
127
128
  summarizeBsvSettlementRecords
128
129
  } = require("./lib/settlement_bsv_live");
130
+ const { loadBsvTeranodeConfig } = require("./lib/settlement_bsv_teranode");
129
131
  const {
130
132
  buildCoordinationAdminView,
131
133
  buildAdmissionCaseBundle,
@@ -202,6 +204,556 @@ const {
202
204
  buildWorkflowDetailResponse,
203
205
  buildWorkflowListResponse
204
206
  } = require("./lib/catalog_views");
207
+ const {
208
+ buildReleasePack,
209
+ summarizeReleasePack,
210
+ buildComparisonPack,
211
+ summarizeComparisonPack,
212
+ buildAdoptionPack,
213
+ summarizeAdoptionPack,
214
+ buildScenarioPack,
215
+ summarizeScenarioPack,
216
+ buildLaunchPack,
217
+ summarizeLaunchPack
218
+ } = require("./lib/release_pack");
219
+ const {
220
+ buildReleaseManifest,
221
+ summarizeReleaseManifest,
222
+ buildLaunchNotes,
223
+ summarizeLaunchNotes
224
+ } = require("./lib/release_manifest");
225
+ const {
226
+ buildReleaseCenter,
227
+ summarizeReleaseCenter
228
+ } = require("./lib/release_center");
229
+ const {
230
+ buildReleaseHistory,
231
+ summarizeReleaseHistory
232
+ } = require("./lib/release_history");
233
+ const {
234
+ buildAdapterPack,
235
+ summarizeAdapterPack
236
+ } = require("./lib/adapter_pack");
237
+ const {
238
+ buildAdapterPromotionPack,
239
+ summarizeAdapterPromotionPack
240
+ } = require("./lib/adapter_promotion_pack");
241
+ const {
242
+ buildAdapterPartnerPack,
243
+ summarizeAdapterPartnerPack
244
+ } = require("./lib/adapter_partner_pack");
245
+ const {
246
+ buildSoftLaunchPack,
247
+ summarizeSoftLaunchPack
248
+ } = require("./lib/soft_launch_pack");
249
+ const {
250
+ buildOutreachCopyPack,
251
+ summarizeOutreachCopyPack
252
+ } = require("./lib/outreach_copy_pack");
253
+ const {
254
+ buildOutreachTargetPack,
255
+ summarizeOutreachTargetPack
256
+ } = require("./lib/outreach_target_pack");
257
+ const {
258
+ buildOutreachMessagePack,
259
+ summarizeOutreachMessagePack
260
+ } = require("./lib/outreach_message_pack");
261
+ const {
262
+ buildPublishPlan,
263
+ summarizePublishPlan
264
+ } = require("./lib/publish_plan");
265
+ const {
266
+ buildEcosystemEntryPack,
267
+ summarizeEcosystemEntryPack
268
+ } = require("./lib/ecosystem_entry");
269
+ const {
270
+ buildLaunchNarrativePack,
271
+ summarizeLaunchNarrativePack
272
+ } = require("./lib/launch_narrative");
273
+ const {
274
+ buildOutreachProofPack,
275
+ summarizeOutreachProofPack
276
+ } = require("./lib/outreach_proof");
277
+ const {
278
+ buildAnnouncementPack,
279
+ summarizeAnnouncementPack
280
+ } = require("./lib/announcement_pack");
281
+ const {
282
+ buildReleaseCandidatePack,
283
+ summarizeReleaseCandidatePack
284
+ } = require("./lib/release_candidate");
285
+ const {
286
+ buildPhaseProgramPack,
287
+ summarizePhaseProgramPack
288
+ } = require("./lib/phase_program_pack");
289
+ const {
290
+ buildPhase1EcosystemPack,
291
+ summarizePhase1EcosystemPack
292
+ } = require("./lib/phase_1_ecosystem_pack");
293
+ const {
294
+ buildPhase1OpenaiCodexPack,
295
+ summarizePhase1OpenaiCodexPack
296
+ } = require("./lib/phase_1_openai_codex_pack");
297
+ const {
298
+ buildPhase1ClaudeMcpPack,
299
+ summarizePhase1ClaudeMcpPack
300
+ } = require("./lib/phase_1_claude_mcp_pack");
301
+ const {
302
+ buildPhase1OpenaiCodexRuntimePack,
303
+ summarizePhase1OpenaiCodexRuntimePack
304
+ } = require("./lib/phase_1_openai_codex_runtime_pack");
305
+ const {
306
+ buildPhase1ClaudeMcpRuntimePack,
307
+ summarizePhase1ClaudeMcpRuntimePack
308
+ } = require("./lib/phase_1_claude_mcp_runtime_pack");
309
+ const {
310
+ buildPhase2PaymentRailsPack,
311
+ summarizePhase2PaymentRailsPack
312
+ } = require("./lib/phase_2_payment_rails_pack");
313
+ const {
314
+ buildPhase2EvmBaseRuntimePack,
315
+ summarizePhase2EvmBaseRuntimePack
316
+ } = require("./lib/phase_2_evm_base_runtime_pack");
317
+ const {
318
+ buildPhase2BaseUsdcRuntimePack,
319
+ summarizePhase2BaseUsdcRuntimePack
320
+ } = require("./lib/phase_2_base_usdc_runtime_pack");
321
+ const {
322
+ buildPhase2EthRuntimePack,
323
+ summarizePhase2EthRuntimePack
324
+ } = require("./lib/phase_2_eth_runtime_pack");
325
+ const {
326
+ buildPhase2EvmRuntimePack,
327
+ summarizePhase2EvmRuntimePack
328
+ } = require("./lib/phase_2_evm_runtime_pack");
329
+ const {
330
+ buildPhase2BaseRuntimePack,
331
+ summarizePhase2BaseRuntimePack
332
+ } = require("./lib/phase_2_base_runtime_pack");
333
+ const {
334
+ buildPhase2UsdcRuntimePack,
335
+ summarizePhase2UsdcRuntimePack
336
+ } = require("./lib/phase_2_usdc_runtime_pack");
337
+ const {
338
+ buildPhase2CompletionPack,
339
+ summarizePhase2CompletionPack
340
+ } = require("./lib/phase_2_completion_pack");
341
+ const {
342
+ buildPhase2FreezeReviewPack,
343
+ summarizePhase2FreezeReviewPack
344
+ } = require("./lib/phase_2_freeze_review_pack");
345
+ const {
346
+ buildPhase2GatePack,
347
+ summarizePhase2GatePack
348
+ } = require("./lib/phase_2_gate_pack");
349
+ const {
350
+ buildPhase2CloseoutPack,
351
+ summarizePhase2CloseoutPack
352
+ } = require("./lib/phase_2_closeout_pack");
353
+ const {
354
+ buildPhase2DecisionRecordPack,
355
+ summarizePhase2DecisionRecordPack
356
+ } = require("./lib/phase_2_decision_record_pack");
357
+ const {
358
+ buildPhase2DecisionResolutionPack,
359
+ summarizePhase2DecisionResolutionPack
360
+ } = require("./lib/phase_2_decision_resolution_pack");
361
+ const {
362
+ buildPhase2FlipPreviewPack,
363
+ summarizePhase2FlipPreviewPack
364
+ } = require("./lib/phase_2_flip_preview_pack");
365
+ const {
366
+ buildPhase3NativeBsvPack,
367
+ summarizePhase3NativeBsvPack
368
+ } = require("./lib/phase_3_native_bsv_pack");
369
+ const {
370
+ buildPhase3BsvTeranodeRuntimePack,
371
+ summarizePhase3BsvTeranodeRuntimePack
372
+ } = require("./lib/phase_3_bsv_teranode_runtime_pack");
373
+ const {
374
+ buildPhase3MetanetRuntimePack,
375
+ summarizePhase3MetanetRuntimePack
376
+ } = require("./lib/phase_3_metanet_runtime_pack");
377
+ const {
378
+ buildPhase3BrcRuntimePack,
379
+ summarizePhase3BrcRuntimePack
380
+ } = require("./lib/phase_3_brc_runtime_pack");
381
+ const {
382
+ buildPhase3NativeContinuityPack,
383
+ summarizePhase3NativeContinuityPack
384
+ } = require("./lib/phase_3_native_continuity_pack");
385
+ const {
386
+ buildPhase3FreezeBaselinePack,
387
+ summarizePhase3FreezeBaselinePack
388
+ } = require("./lib/phase_3_freeze_baseline_pack");
389
+ const {
390
+ buildPhase4IdentityTrustPack,
391
+ summarizePhase4IdentityTrustPack
392
+ } = require("./lib/phase_4_identity_trust_pack");
393
+ const {
394
+ buildPhase4Erc8004RuntimePack,
395
+ summarizePhase4Erc8004RuntimePack
396
+ } = require("./lib/phase_4_erc8004_runtime_pack");
397
+ const {
398
+ buildPhase4IdentityRegistryRuntimePack,
399
+ summarizePhase4IdentityRegistryRuntimePack
400
+ } = require("./lib/phase_4_identity_registry_runtime_pack");
401
+ const {
402
+ buildPhase4AttestationRuntimePack,
403
+ summarizePhase4AttestationRuntimePack
404
+ } = require("./lib/phase_4_attestation_runtime_pack");
405
+ const {
406
+ buildPhase4TrustContinuityPack,
407
+ summarizePhase4TrustContinuityPack
408
+ } = require("./lib/phase_4_trust_continuity_pack");
409
+ const {
410
+ buildPhase4CompletionPack,
411
+ summarizePhase4CompletionPack
412
+ } = require("./lib/phase_4_completion_pack");
413
+ const {
414
+ buildPhase4FreezeReviewPack,
415
+ summarizePhase4FreezeReviewPack
416
+ } = require("./lib/phase_4_freeze_review_pack");
417
+ const {
418
+ buildPhase4FreezeBaselinePack,
419
+ summarizePhase4FreezeBaselinePack
420
+ } = require("./lib/phase_4_freeze_baseline_pack");
421
+ const {
422
+ buildPhase4GatePack,
423
+ summarizePhase4GatePack
424
+ } = require("./lib/phase_4_gate_pack");
425
+ const {
426
+ buildPhase4CloseoutPack,
427
+ summarizePhase4CloseoutPack
428
+ } = require("./lib/phase_4_closeout_pack");
429
+ const {
430
+ buildPhase4DecisionRecordPack,
431
+ summarizePhase4DecisionRecordPack
432
+ } = require("./lib/phase_4_decision_record_pack");
433
+ const {
434
+ buildPhase4DecisionResolutionPack,
435
+ summarizePhase4DecisionResolutionPack
436
+ } = require("./lib/phase_4_decision_resolution_pack");
437
+ const {
438
+ buildPhase5MajorRailsPack,
439
+ summarizePhase5MajorRailsPack
440
+ } = require("./lib/phase_5_major_rails_pack");
441
+ const {
442
+ buildPhase5MajorRailsContinuityPack,
443
+ summarizePhase5MajorRailsContinuityPack
444
+ } = require("./lib/phase_5_major_rails_continuity_pack");
445
+ const {
446
+ buildPhase5CompletionPack,
447
+ summarizePhase5CompletionPack
448
+ } = require("./lib/phase_5_completion_pack");
449
+ const {
450
+ buildPhase5FreezeReviewPack,
451
+ summarizePhase5FreezeReviewPack
452
+ } = require("./lib/phase_5_freeze_review_pack");
453
+ const {
454
+ buildPhase5FreezeBaselinePack,
455
+ summarizePhase5FreezeBaselinePack
456
+ } = require("./lib/phase_5_freeze_baseline_pack");
457
+ const {
458
+ buildPhase5GatePack,
459
+ summarizePhase5GatePack
460
+ } = require("./lib/phase_5_gate_pack");
461
+ const {
462
+ buildPhase5CloseoutPack,
463
+ summarizePhase5CloseoutPack
464
+ } = require("./lib/phase_5_closeout_pack");
465
+ const {
466
+ buildPhase5DecisionRecordPack,
467
+ summarizePhase5DecisionRecordPack
468
+ } = require("./lib/phase_5_decision_record_pack");
469
+ const {
470
+ buildPhase5DecisionResolutionPack,
471
+ summarizePhase5DecisionResolutionPack
472
+ } = require("./lib/phase_5_decision_resolution_pack");
473
+ const {
474
+ buildPhase5SolanaRuntimePack,
475
+ summarizePhase5SolanaRuntimePack
476
+ } = require("./lib/phase_5_solana_runtime_pack");
477
+ const {
478
+ buildPhase5AntelopeRuntimePack,
479
+ summarizePhase5AntelopeRuntimePack
480
+ } = require("./lib/phase_5_antelope_runtime_pack");
481
+ const {
482
+ buildPhase5ProtonXprRuntimePack,
483
+ summarizePhase5ProtonXprRuntimePack
484
+ } = require("./lib/phase_5_proton_xpr_runtime_pack");
485
+ const {
486
+ buildPhase6FrameworkRuntimePack,
487
+ summarizePhase6FrameworkRuntimePack
488
+ } = require("./lib/phase_6_framework_runtime_pack");
489
+ const {
490
+ buildPhase6LanggraphRuntimePack,
491
+ summarizePhase6LanggraphRuntimePack
492
+ } = require("./lib/phase_6_langgraph_runtime_pack");
493
+ const {
494
+ buildPhase6LangchainRuntimePack,
495
+ summarizePhase6LangchainRuntimePack
496
+ } = require("./lib/phase_6_langchain_runtime_pack");
497
+ const {
498
+ buildPhase6AutogenRuntimePack,
499
+ summarizePhase6AutogenRuntimePack
500
+ } = require("./lib/phase_6_autogen_runtime_pack");
501
+ const {
502
+ buildPhase6SemanticKernelRuntimePack,
503
+ summarizePhase6SemanticKernelRuntimePack
504
+ } = require("./lib/phase_6_semantic_kernel_runtime_pack");
505
+ const {
506
+ buildPhase6FrameworkContinuityPack,
507
+ summarizePhase6FrameworkContinuityPack
508
+ } = require("./lib/phase_6_framework_continuity_pack");
509
+ const {
510
+ buildPhase6CompletionPack,
511
+ summarizePhase6CompletionPack
512
+ } = require("./lib/phase_6_completion_pack");
513
+ const {
514
+ buildPhase6FreezeReviewPack,
515
+ summarizePhase6FreezeReviewPack
516
+ } = require("./lib/phase_6_freeze_review_pack");
517
+ const {
518
+ buildPhase6FreezeBaselinePack,
519
+ summarizePhase6FreezeBaselinePack
520
+ } = require("./lib/phase_6_freeze_baseline_pack");
521
+ const {
522
+ buildPhase6GatePack,
523
+ summarizePhase6GatePack
524
+ } = require("./lib/phase_6_gate_pack");
525
+ const {
526
+ buildPhase6CloseoutPack,
527
+ summarizePhase6CloseoutPack
528
+ } = require("./lib/phase_6_closeout_pack");
529
+ const {
530
+ buildPhase6DecisionRecordPack,
531
+ summarizePhase6DecisionRecordPack
532
+ } = require("./lib/phase_6_decision_record_pack");
533
+ const {
534
+ buildPhase6DecisionResolutionPack,
535
+ summarizePhase6DecisionResolutionPack
536
+ } = require("./lib/phase_6_decision_resolution_pack");
537
+ const {
538
+ buildPhase7EventSystemPack,
539
+ summarizePhase7EventSystemPack
540
+ } = require("./lib/phase_7_event_system_pack");
541
+ const {
542
+ buildPhase7KafkaRuntimePack,
543
+ summarizePhase7KafkaRuntimePack
544
+ } = require("./lib/phase_7_kafka_runtime_pack");
545
+ const {
546
+ buildPhase7NatsRuntimePack,
547
+ summarizePhase7NatsRuntimePack
548
+ } = require("./lib/phase_7_nats_runtime_pack");
549
+ const {
550
+ buildPhase7MqttRuntimePack,
551
+ summarizePhase7MqttRuntimePack
552
+ } = require("./lib/phase_7_mqtt_runtime_pack");
553
+ const {
554
+ buildPhase7WebhookEventBusRuntimePack,
555
+ summarizePhase7WebhookEventBusRuntimePack
556
+ } = require("./lib/phase_7_webhook_event_bus_runtime_pack");
557
+ const {
558
+ buildPhase7EventSystemContinuityPack,
559
+ summarizePhase7EventSystemContinuityPack
560
+ } = require("./lib/phase_7_event_system_continuity_pack");
561
+ const {
562
+ buildPhase7CompletionPack,
563
+ summarizePhase7CompletionPack
564
+ } = require("./lib/phase_7_completion_pack");
565
+ const {
566
+ buildPhase7FreezeBaselinePack,
567
+ summarizePhase7FreezeBaselinePack
568
+ } = require("./lib/phase_7_freeze_baseline_pack");
569
+ const {
570
+ buildPhase7FreezeReviewPack,
571
+ summarizePhase7FreezeReviewPack
572
+ } = require("./lib/phase_7_freeze_review_pack");
573
+ const {
574
+ buildPhase7GatePack,
575
+ summarizePhase7GatePack
576
+ } = require("./lib/phase_7_gate_pack");
577
+ const {
578
+ buildPhase7CloseoutPack,
579
+ summarizePhase7CloseoutPack
580
+ } = require("./lib/phase_7_closeout_pack");
581
+ const {
582
+ buildPhase7DecisionRecordPack,
583
+ summarizePhase7DecisionRecordPack
584
+ } = require("./lib/phase_7_decision_record_pack");
585
+ const {
586
+ buildPhase7DecisionResolutionPack,
587
+ summarizePhase7DecisionResolutionPack
588
+ } = require("./lib/phase_7_decision_resolution_pack");
589
+ const {
590
+ buildPhase8ProofBridgesPack,
591
+ summarizePhase8ProofBridgesPack
592
+ } = require("./lib/phase_8_proof_bridges_pack");
593
+ const {
594
+ buildPhase8ProofBridgeContinuityPack,
595
+ summarizePhase8ProofBridgeContinuityPack
596
+ } = require("./lib/phase_8_proof_bridge_continuity_pack");
597
+ const {
598
+ buildPhase8CompletionPack,
599
+ summarizePhase8CompletionPack
600
+ } = require("./lib/phase_8_completion_pack");
601
+ const {
602
+ buildPhase8FreezeBaselinePack,
603
+ summarizePhase8FreezeBaselinePack
604
+ } = require("./lib/phase_8_freeze_baseline_pack");
605
+ const {
606
+ buildPhase8FreezeReviewPack,
607
+ summarizePhase8FreezeReviewPack
608
+ } = require("./lib/phase_8_freeze_review_pack");
609
+ const {
610
+ buildPhase8GatePack,
611
+ summarizePhase8GatePack
612
+ } = require("./lib/phase_8_gate_pack");
613
+ const {
614
+ buildPhase8CloseoutPack,
615
+ summarizePhase8CloseoutPack
616
+ } = require("./lib/phase_8_closeout_pack");
617
+ const {
618
+ buildPhase8DecisionRecordPack,
619
+ summarizePhase8DecisionRecordPack
620
+ } = require("./lib/phase_8_decision_record_pack");
621
+ const {
622
+ buildPhase8DecisionResolutionPack,
623
+ summarizePhase8DecisionResolutionPack
624
+ } = require("./lib/phase_8_decision_resolution_pack");
625
+ const {
626
+ buildPhase8ExternalResultImportRuntimePack,
627
+ summarizePhase8ExternalResultImportRuntimePack
628
+ } = require("./lib/phase_8_external_result_import_runtime_pack");
629
+ const {
630
+ buildPhase8ExternalReceiptImportRuntimePack,
631
+ summarizePhase8ExternalReceiptImportRuntimePack
632
+ } = require("./lib/phase_8_external_receipt_import_runtime_pack");
633
+ const {
634
+ buildPhase8ProofBundleNormalizationRuntimePack,
635
+ summarizePhase8ProofBundleNormalizationRuntimePack
636
+ } = require("./lib/phase_8_proof_bundle_normalization_runtime_pack");
637
+ const {
638
+ buildPhase9TreasuryConnectivityPack,
639
+ summarizePhase9TreasuryConnectivityPack
640
+ } = require("./lib/phase_9_treasury_connectivity_pack");
641
+ const {
642
+ buildPhase9TreasuryContinuityPack,
643
+ summarizePhase9TreasuryContinuityPack
644
+ } = require("./lib/phase_9_treasury_continuity_pack");
645
+ const {
646
+ buildPhase9CompletionPack,
647
+ summarizePhase9CompletionPack
648
+ } = require("./lib/phase_9_completion_pack");
649
+ const {
650
+ buildPhase9FreezeBaselinePack,
651
+ summarizePhase9FreezeBaselinePack
652
+ } = require("./lib/phase_9_freeze_baseline_pack");
653
+ const {
654
+ buildPhase9FreezeReviewPack,
655
+ summarizePhase9FreezeReviewPack
656
+ } = require("./lib/phase_9_freeze_review_pack");
657
+ const {
658
+ buildPhase9GatePack,
659
+ summarizePhase9GatePack
660
+ } = require("./lib/phase_9_gate_pack");
661
+ const {
662
+ buildPhase9CloseoutPack,
663
+ summarizePhase9CloseoutPack
664
+ } = require("./lib/phase_9_closeout_pack");
665
+ const {
666
+ buildPhase9DecisionRecordPack,
667
+ summarizePhase9DecisionRecordPack
668
+ } = require("./lib/phase_9_decision_record_pack");
669
+ const {
670
+ buildPhase9DecisionResolutionPack,
671
+ summarizePhase9DecisionResolutionPack
672
+ } = require("./lib/phase_9_decision_resolution_pack");
673
+ const {
674
+ buildPhase9TreasuryDestinationsRuntimePack,
675
+ summarizePhase9TreasuryDestinationsRuntimePack
676
+ } = require("./lib/phase_9_treasury_destinations_runtime_pack");
677
+ const {
678
+ buildPhase9CustodyRefsRuntimePack,
679
+ summarizePhase9CustodyRefsRuntimePack
680
+ } = require("./lib/phase_9_custody_refs_runtime_pack");
681
+ const {
682
+ buildPhase9OperatorAccountingBridgesRuntimePack,
683
+ summarizePhase9OperatorAccountingBridgesRuntimePack
684
+ } = require("./lib/phase_9_operator_accounting_bridges_runtime_pack");
685
+ const {
686
+ buildPhase10LongTailEcosystemPack,
687
+ summarizePhase10LongTailEcosystemPack
688
+ } = require("./lib/phase_10_long_tail_ecosystem_pack");
689
+ const {
690
+ buildPhase10LongTailContinuityPack,
691
+ summarizePhase10LongTailContinuityPack
692
+ } = require("./lib/phase_10_long_tail_continuity_pack");
693
+ const {
694
+ buildPhase10CompletionPack,
695
+ summarizePhase10CompletionPack
696
+ } = require("./lib/phase_10_completion_pack");
697
+ const {
698
+ buildPhase10FreezeReviewPack,
699
+ summarizePhase10FreezeReviewPack
700
+ } = require("./lib/phase_10_freeze_review_pack");
701
+ const {
702
+ buildPhase10FreezeBaselinePack,
703
+ summarizePhase10FreezeBaselinePack
704
+ } = require("./lib/phase_10_freeze_baseline_pack");
705
+ const {
706
+ buildPhase10GatePack,
707
+ summarizePhase10GatePack
708
+ } = require("./lib/phase_10_gate_pack");
709
+ const {
710
+ buildPhase10CloseoutPack,
711
+ summarizePhase10CloseoutPack
712
+ } = require("./lib/phase_10_closeout_pack");
713
+ const {
714
+ buildPhase10DecisionRecordPack,
715
+ summarizePhase10DecisionRecordPack
716
+ } = require("./lib/phase_10_decision_record_pack");
717
+ const {
718
+ buildPhase10DecisionResolutionPack,
719
+ summarizePhase10DecisionResolutionPack
720
+ } = require("./lib/phase_10_decision_resolution_pack");
721
+ const {
722
+ buildPhase10DemandSignalAdaptersRuntimePack,
723
+ summarizePhase10DemandSignalAdaptersRuntimePack
724
+ } = require("./lib/phase_10_demand_signal_adapters_runtime_pack");
725
+ const {
726
+ buildPhase10NicheExtensionRegistryRuntimePack,
727
+ summarizePhase10NicheExtensionRegistryRuntimePack
728
+ } = require("./lib/phase_10_niche_extension_registry_runtime_pack");
729
+ const {
730
+ buildPhase10EcosystemBacklogTriageRuntimePack,
731
+ summarizePhase10EcosystemBacklogTriageRuntimePack
732
+ } = require("./lib/phase_10_ecosystem_backlog_triage_runtime_pack");
733
+ const {
734
+ buildPhase3CompletionPack,
735
+ summarizePhase3CompletionPack
736
+ } = require("./lib/phase_3_completion_pack");
737
+ const {
738
+ buildPhase3FreezeReviewPack,
739
+ summarizePhase3FreezeReviewPack
740
+ } = require("./lib/phase_3_freeze_review_pack");
741
+ const {
742
+ buildPhase3GatePack,
743
+ summarizePhase3GatePack
744
+ } = require("./lib/phase_3_gate_pack");
745
+ const {
746
+ buildPhase3CloseoutPack,
747
+ summarizePhase3CloseoutPack
748
+ } = require("./lib/phase_3_closeout_pack");
749
+ const {
750
+ buildPhase3DecisionRecordPack,
751
+ summarizePhase3DecisionRecordPack
752
+ } = require("./lib/phase_3_decision_record_pack");
753
+ const {
754
+ buildPhase3DecisionResolutionPack,
755
+ summarizePhase3DecisionResolutionPack
756
+ } = require("./lib/phase_3_decision_resolution_pack");
205
757
  const {
206
758
  getIntegration,
207
759
  listIntegrations,
@@ -238,8 +790,56 @@ const {
238
790
  isRemediationTicketDetailPath
239
791
  } = require("./lib/route_matchers");
240
792
  const { executeCommandRequest } = require("./lib/command_flow");
793
+ const { createRuntimeStateStore } = require("./lib/runtime_state_store");
241
794
 
242
795
  const state = createRuntimeState();
796
+ const runtimeStateStore = createRuntimeStateStore({
797
+ filePath: process.env.XYTARA_STATE_FILE,
798
+ intervalMs: process.env.XYTARA_STATE_SNAPSHOT_INTERVAL_MS,
799
+ supabaseUrl: process.env.XYTARA_SUPABASE_URL,
800
+ supabaseServiceRoleKey: process.env.XYTARA_SUPABASE_SERVICE_ROLE_KEY,
801
+ supabaseTable: process.env.XYTARA_SUPABASE_STATE_TABLE,
802
+ stateKey: process.env.XYTARA_SUPABASE_STATE_KEY
803
+ });
804
+ const runtimeStateReady = Promise.resolve(runtimeStateStore.load(state))
805
+ .then((restored) => {
806
+ if (runtimeStateStore.enabled()) {
807
+ const durabilityInspect = runtimeStateStore.inspect();
808
+ const storageLabel = durabilityInspect.storage_mode === "supabase"
809
+ ? `Supabase table ${durabilityInspect.supabase_table} (${durabilityInspect.supabase_state_key})`
810
+ : runtimeStateStore.filePath;
811
+ console.log(
812
+ restored
813
+ ? `xytara restored runtime state from ${storageLabel}`
814
+ : `xytara runtime state snapshots enabled at ${storageLabel}`
815
+ );
816
+ if (durabilityInspect.storage_mode === "file" && durabilityInspect.directory_exists !== true) {
817
+ console.warn(
818
+ `xytara runtime state snapshot directory does not exist yet: ${durabilityInspect.directory_path}`
819
+ );
820
+ }
821
+ if (durabilityInspect.storage_mode === "file" && durabilityInspect.directory_writable !== true) {
822
+ console.warn(
823
+ `xytara runtime state snapshot directory is not writable: ${durabilityInspect.directory_path}`
824
+ );
825
+ }
826
+ if (durabilityInspect.storage_mode === "supabase" && durabilityInspect.remote_reachable !== true) {
827
+ console.warn("xytara runtime state Supabase endpoint is not reachable");
828
+ }
829
+ if (durabilityInspect.storage_mode === "supabase" && durabilityInspect.remote_table_ready !== true) {
830
+ console.warn(`xytara runtime state Supabase table is not ready: ${durabilityInspect.supabase_table}`);
831
+ }
832
+ } else {
833
+ console.warn(
834
+ "xytara runtime state snapshots are disabled; grants, entitlements, and usage meters will reset on restart unless XYTARA_STATE_FILE or XYTARA_SUPABASE_* persistence is configured"
835
+ );
836
+ }
837
+ return restored;
838
+ })
839
+ .catch((error) => {
840
+ console.error("xytara runtime state restore failed", error);
841
+ return false;
842
+ });
243
843
 
244
844
  function getCreditBridgeBearerToken() {
245
845
  const value = typeof process.env.XYTARA_CREDIT_BRIDGE_BEARER_TOKEN === "string"
@@ -313,6 +913,88 @@ function verifyCreditBridgeWriteAccess(headers) {
313
913
  };
314
914
  }
315
915
 
916
+ function buildRuntimeDurabilitySummary() {
917
+ const inspect = typeof runtimeStateStore.inspect === "function"
918
+ ? runtimeStateStore.inspect()
919
+ : {
920
+ enabled: runtimeStateStore.enabled(),
921
+ storage_mode: runtimeStateStore.storageMode || "memory",
922
+ file_path: runtimeStateStore.filePath || null,
923
+ interval_ms: runtimeStateStore.intervalMs || null
924
+ };
925
+ const blockers = [];
926
+ if (inspect.enabled !== true) blockers.push("runtime_state_snapshot_disabled");
927
+ if (inspect.storage_mode === "file" && inspect.enabled === true && inspect.directory_exists !== true) blockers.push("runtime_state_snapshot_directory_missing");
928
+ if (inspect.storage_mode === "file" && inspect.enabled === true && inspect.directory_writable !== true) blockers.push("runtime_state_snapshot_directory_not_writable");
929
+ if (inspect.storage_mode === "supabase" && inspect.enabled === true && inspect.remote_reachable !== true) blockers.push("runtime_state_supabase_unreachable");
930
+ if (inspect.storage_mode === "supabase" && inspect.enabled === true && inspect.remote_table_ready !== true) blockers.push("runtime_state_supabase_table_not_ready");
931
+ if (inspect.enabled === true && inspect.snapshot_exists !== true) blockers.push("runtime_state_snapshot_missing");
932
+ if (inspect.last_flush_succeeded === false) blockers.push("runtime_state_last_flush_failed");
933
+ return {
934
+ ok: true,
935
+ inspect_ref: "/v1/runtime/durability",
936
+ recovery_posture: inspect.enabled === true && inspect.last_flush_succeeded !== false
937
+ ? inspect.snapshot_exists === true
938
+ ? "recoverable_snapshot_ready"
939
+ : "snapshot_enabled_not_yet_persisted"
940
+ : "volatile_runtime_state",
941
+ blockers,
942
+ operator_guidance: inspect.storage_mode === "supabase"
943
+ ? "keep XYTARA_SUPABASE_URL, XYTARA_SUPABASE_SERVICE_ROLE_KEY, XYTARA_SUPABASE_STATE_TABLE, and XYTARA_SUPABASE_STATE_KEY configured so grants, entitlements, and usage meters survive restart"
944
+ : inspect.enabled === true
945
+ ? "store XYTARA_STATE_FILE on persistent disk so grants, entitlements, and usage meters survive restart"
946
+ : "configure XYTARA_STATE_FILE on persistent disk or XYTARA_SUPABASE_* remote persistence to preserve grants, entitlements, and usage meters across restart",
947
+ ...inspect
948
+ };
949
+ }
950
+
951
+ function buildNativeSettlementReadinessSummary() {
952
+ const railConfig = loadBsvTeranodeConfig();
953
+ const runtimeConfig = loadBsvSettlementRuntimeConfig();
954
+ const paymentVerificationMode = String(process.env.XYTARA_PAYMENT_VERIFICATION_MODE || "presence").trim() || "presence";
955
+ const receivingIdentityKind = railConfig.merchant_address
956
+ ? "address"
957
+ : railConfig.merchant_paymail
958
+ ? "paymail"
959
+ : null;
960
+ const treasuryConfigured = Boolean(railConfig.merchant_address || railConfig.merchant_paymail);
961
+ const transportConfigured = Boolean(railConfig.rpc_url || runtimeConfig.rpc_url);
962
+ const transportAuthConfigured = runtimeConfig.mode !== "arc" || Boolean(runtimeConfig.rpc_api_key);
963
+ const blockers = [];
964
+ if (!treasuryConfigured) blockers.push("merchant_receiving_identity_missing");
965
+ if (!transportConfigured) blockers.push("settlement_transport_missing");
966
+ if (!transportAuthConfigured) blockers.push("settlement_transport_auth_missing");
967
+ if (paymentVerificationMode === "presence") blockers.push("payment_verification_too_weak");
968
+ if (runtimeConfig.mode === "mock") blockers.push("settlement_runtime_still_mock");
969
+ return {
970
+ ok: true,
971
+ readiness_ref: "/v1/settlement/bsv-teranode/readiness",
972
+ settlement_mode: railConfig.settlement_mode,
973
+ rail: railConfig.rail,
974
+ network: railConfig.network,
975
+ settlement_profile_mode: railConfig.mode,
976
+ runtime_mode: runtimeConfig.mode,
977
+ payment_verification_mode: paymentVerificationMode,
978
+ receiving_identity_kind: receivingIdentityKind,
979
+ merchant_address_configured: Boolean(railConfig.merchant_address),
980
+ merchant_paymail_configured: Boolean(railConfig.merchant_paymail),
981
+ treasury_configured: treasuryConfigured,
982
+ settlement_transport_configured: transportConfigured,
983
+ settlement_transport_auth_configured: transportAuthConfigured,
984
+ required_confirmations: runtimeConfig.required_confirmations,
985
+ metanet_enabled: railConfig.use_metanet === true,
986
+ ready: blockers.length === 0,
987
+ blockers,
988
+ next_manual_inputs: [
989
+ treasuryConfigured ? null : "merchant_address_or_paymail",
990
+ transportConfigured ? null : "rpc_url_or_settlement_provider",
991
+ transportAuthConfigured ? null : "rpc_api_key",
992
+ paymentVerificationMode !== "presence" ? null : "stronger_payment_verification_mode",
993
+ runtimeConfig.mode !== "mock" ? null : "live_settlement_runtime_mode"
994
+ ].filter(Boolean)
995
+ };
996
+ }
997
+
316
998
  function buildNamedTaskPayload(taskRef, body, fallbackCommand) {
317
999
  const requestBody = body && typeof body === "object" && !Array.isArray(body) ? body : {};
318
1000
  return {
@@ -1073,6 +1755,183 @@ function buildLinkedRecordSetFromCommandResult(result) {
1073
1755
  };
1074
1756
  }
1075
1757
 
1758
+ function findPaymentLedgerEntry(paymentId) {
1759
+ const paymentLedger = Array.isArray(state.paymentLedger) ? state.paymentLedger : [];
1760
+ return paymentLedger.find((item) => item && item.payment_id === paymentId) || null;
1761
+ }
1762
+
1763
+ function buildSettlementOperatorSummary(settlement) {
1764
+ const item = settlement && typeof settlement === "object" ? settlement : {};
1765
+ return {
1766
+ settlement_id: item.settlement_id || null,
1767
+ payment_id: item.payment_id || null,
1768
+ transaction_id: item.transaction_id || null,
1769
+ receipt_id: item.receipt_id || null,
1770
+ account_id: item.account_id || null,
1771
+ rail: item.rail || null,
1772
+ network: item.network || null,
1773
+ runtime_mode: item.runtime_mode || null,
1774
+ status: item.status || null,
1775
+ finality_status: item.finality_status || null,
1776
+ confirmation_count: Number(item.confirmation_count || 0),
1777
+ required_confirmations: Number(item.required_confirmations || 0),
1778
+ txid: item.txid || null,
1779
+ raw_tx_present: Boolean(item.raw_tx),
1780
+ provider_ref: item.provider_ref || null,
1781
+ last_error: item.last_error || null,
1782
+ observed_at_iso: item.observed_at_iso || null,
1783
+ confirmed_at_iso: item.confirmed_at_iso || null,
1784
+ finalized_at_iso: item.finalized_at_iso || null
1785
+ };
1786
+ }
1787
+
1788
+ function buildEconomicConsequenceOperatorSummary(transaction, receipt, settlement) {
1789
+ const creditSpend = transaction && transaction.credit_spend && typeof transaction.credit_spend === "object"
1790
+ ? transaction.credit_spend
1791
+ : null;
1792
+ if (!creditSpend || !creditSpend.account_id || !creditSpend.usage_meter_id || !creditSpend.credit_spend_id) {
1793
+ return {
1794
+ consequence_ready: false,
1795
+ account_ref: creditSpend && creditSpend.account_id ? creditSpend.account_id : null,
1796
+ usage_meter_ref: creditSpend && creditSpend.usage_meter_id ? creditSpend.usage_meter_id : null,
1797
+ credit_spend_ref: creditSpend && creditSpend.credit_spend_id ? creditSpend.credit_spend_id : null,
1798
+ conformance_pack_ref: null,
1799
+ settlement_ref: settlement && settlement.settlement_id ? settlement.settlement_id : null,
1800
+ payment_ref: transaction && transaction.payment && transaction.payment.payment_id ? transaction.payment.payment_id : null,
1801
+ treasury_receipt_ref: transaction && transaction.treasury && transaction.treasury.treasury_receipt_id ? transaction.treasury.treasury_receipt_id : null,
1802
+ proof_ref: receipt && receipt.proof_ref ? receipt.proof_ref : null
1803
+ };
1804
+ }
1805
+ const handoff = buildEconomicConsequenceHandoffBundle(state, {
1806
+ account_id: creditSpend.account_id,
1807
+ usage_meter_id: creditSpend.usage_meter_id,
1808
+ credit_spend_id: creditSpend.credit_spend_id,
1809
+ payment_ref: transaction && transaction.payment && transaction.payment.payment_id ? transaction.payment.payment_id : null,
1810
+ settlement_ref: settlement && settlement.settlement_id ? settlement.settlement_id : null,
1811
+ settlement_txid: settlement && settlement.txid ? settlement.txid : null,
1812
+ settlement_status: settlement && settlement.status ? settlement.status : null,
1813
+ settlement_finality_status: settlement && settlement.live && settlement.live.finality_status
1814
+ ? settlement.live.finality_status
1815
+ : settlement && settlement.verified ? "verified" : null,
1816
+ treasury_receipt_ref: transaction && transaction.treasury && transaction.treasury.treasury_receipt_id
1817
+ ? transaction.treasury.treasury_receipt_id
1818
+ : null,
1819
+ proof_ref: receipt && receipt.proof_ref ? receipt.proof_ref : null
1820
+ });
1821
+ const bundle = handoff && handoff.ok === true ? handoff.handoff_bundle : null;
1822
+ return {
1823
+ consequence_ready: Boolean(bundle),
1824
+ account_ref: bundle ? bundle.account_ref : creditSpend.account_id,
1825
+ usage_meter_ref: bundle ? bundle.usage_meter_ref : creditSpend.usage_meter_id,
1826
+ credit_spend_ref: bundle ? bundle.credit_spend_ref : creditSpend.credit_spend_id,
1827
+ meter_profile_ref: bundle ? bundle.meter_profile_ref || null : null,
1828
+ payment_ref: bundle ? bundle.payment_ref || null : null,
1829
+ settlement_ref: bundle ? bundle.settlement_ref || null : null,
1830
+ settlement_txid: bundle ? bundle.settlement_txid || null : null,
1831
+ settlement_status: bundle ? bundle.settlement_status || null : null,
1832
+ settlement_finality_status: bundle ? bundle.settlement_finality_status || null : null,
1833
+ treasury_receipt_ref: bundle ? bundle.treasury_receipt_ref || null : null,
1834
+ proof_ref: bundle ? bundle.proof_ref || null : (receipt && receipt.proof_ref ? receipt.proof_ref : null),
1835
+ proof_bridge_surface: bundle && bundle.handoff_surfaces ? bundle.handoff_surfaces.proof_bridge_surface || null : null,
1836
+ proof_conformance_surface: bundle && bundle.handoff_surfaces ? bundle.handoff_surfaces.proof_conformance_surface || null : null
1837
+ };
1838
+ }
1839
+
1840
+ function buildPaymentLedgerOperatorPack(payment) {
1841
+ const entry = payment && typeof payment === "object" ? payment : null;
1842
+ if (!entry) return null;
1843
+ const transactionEntry = entry.transaction_id && state.transactions.has(entry.transaction_id)
1844
+ ? state.transactions.get(entry.transaction_id)
1845
+ : null;
1846
+ const transaction = transactionEntry && transactionEntry.transaction ? transactionEntry.transaction : null;
1847
+ const receipt = transactionEntry && transactionEntry.receipt
1848
+ ? transactionEntry.receipt
1849
+ : entry.receipt_id && state.receipts.has(entry.receipt_id)
1850
+ ? state.receipts.get(entry.receipt_id).receipt
1851
+ : null;
1852
+ const settlementId = entry.live_settlement && entry.live_settlement.settlement_id
1853
+ ? entry.live_settlement.settlement_id
1854
+ : transaction && transaction.settlement && transaction.settlement.live && transaction.settlement.live.settlement_id
1855
+ ? transaction.settlement.live.settlement_id
1856
+ : null;
1857
+ const settlement = settlementId ? getBsvSettlementRecord(state, settlementId) : null;
1858
+ const economics = buildEconomicConsequenceOperatorSummary(transaction, receipt, settlement);
1859
+ return {
1860
+ ok: true,
1861
+ operator_pack_ref: `operator.payment-ledger.${entry.payment_id}`,
1862
+ payment_id: entry.payment_id || null,
1863
+ transaction_id: entry.transaction_id || null,
1864
+ receipt_id: entry.receipt_id || null,
1865
+ account_id: entry.account_id || null,
1866
+ payment_summary: summarizePaymentLedgerPayload(entry),
1867
+ settlement_summary: buildSettlementOperatorSummary(settlement || entry.live_settlement || entry.settlement),
1868
+ treasury_summary: transaction && transaction.treasury ? transaction.treasury : entry.treasury || null,
1869
+ proof_summary: {
1870
+ proof_ref: receipt && receipt.proof_ref ? receipt.proof_ref : null,
1871
+ proof_ready: Boolean(receipt && receipt.receipt_id && receipt.proof_ref),
1872
+ receipt_status: receipt && receipt.status ? receipt.status : null
1873
+ },
1874
+ economic_consequence_summary: economics,
1875
+ linked_surfaces: {
1876
+ payment_ref: `/v1/payment-ledger/${encodeURIComponent(entry.payment_id)}`,
1877
+ settlement_ref: settlementId ? `/v1/settlement/bsv-teranode/${encodeURIComponent(settlementId)}` : null,
1878
+ receipt_ref: receipt && receipt.receipt_id ? `/v1/receipts/${encodeURIComponent(receipt.receipt_id)}` : null,
1879
+ transaction_ref: entry.transaction_id ? `/v1/transactions/${encodeURIComponent(entry.transaction_id)}` : null,
1880
+ proof_review_summary_surface: economics.proof_conformance_surface ? "/v1/proof-center/result-package-handoff/review/summary" : null
1881
+ },
1882
+ recommended_actions: [
1883
+ settlement && settlement.status === "ready_for_submission" ? "submit_settlement" : null,
1884
+ settlement && settlement.status !== "finalized" ? "refresh_settlement" : null,
1885
+ economics.consequence_ready ? "inspect_proof_bridge_carry" : "economic_consequence_not_linked"
1886
+ ].filter(Boolean)
1887
+ };
1888
+ }
1889
+
1890
+ function buildSettlementOperatorPack(settlement) {
1891
+ const item = settlement && typeof settlement === "object" ? settlement : null;
1892
+ if (!item) return null;
1893
+ const payment = item.payment_id ? findPaymentLedgerEntry(item.payment_id) : null;
1894
+ const transactionEntry = item.transaction_id && state.transactions.has(item.transaction_id)
1895
+ ? state.transactions.get(item.transaction_id)
1896
+ : null;
1897
+ const transaction = transactionEntry && transactionEntry.transaction ? transactionEntry.transaction : null;
1898
+ const receipt = transactionEntry && transactionEntry.receipt
1899
+ ? transactionEntry.receipt
1900
+ : item.receipt_id && state.receipts.has(item.receipt_id)
1901
+ ? state.receipts.get(item.receipt_id).receipt
1902
+ : null;
1903
+ const economics = buildEconomicConsequenceOperatorSummary(transaction, receipt, item);
1904
+ return {
1905
+ ok: true,
1906
+ operator_pack_ref: `operator.bsv-settlement.${item.settlement_id}`,
1907
+ settlement_id: item.settlement_id,
1908
+ transaction_id: item.transaction_id || null,
1909
+ receipt_id: item.receipt_id || null,
1910
+ payment_id: item.payment_id || null,
1911
+ account_id: item.account_id || null,
1912
+ settlement_summary: buildSettlementOperatorSummary(item),
1913
+ payment_summary: payment ? summarizePaymentLedgerPayload(payment) : null,
1914
+ treasury_summary: transaction && transaction.treasury ? transaction.treasury : null,
1915
+ proof_summary: {
1916
+ proof_ref: receipt && receipt.proof_ref ? receipt.proof_ref : null,
1917
+ proof_ready: Boolean(receipt && receipt.receipt_id && receipt.proof_ref),
1918
+ receipt_status: receipt && receipt.status ? receipt.status : null
1919
+ },
1920
+ economic_consequence_summary: economics,
1921
+ linked_surfaces: {
1922
+ settlement_ref: `/v1/settlement/bsv-teranode/${encodeURIComponent(item.settlement_id)}`,
1923
+ payment_ref: item.payment_id ? `/v1/payment-ledger/${encodeURIComponent(item.payment_id)}` : null,
1924
+ receipt_ref: item.receipt_id ? `/v1/receipts/${encodeURIComponent(item.receipt_id)}` : null,
1925
+ transaction_ref: item.transaction_id ? `/v1/transactions/${encodeURIComponent(item.transaction_id)}` : null
1926
+ },
1927
+ recommended_actions: [
1928
+ item.status === "ready_for_submission" ? "submit_settlement" : null,
1929
+ item.status !== "finalized" ? "refresh_settlement" : null,
1930
+ economics.consequence_ready ? "inspect_proof_bridge_carry" : "economic_consequence_not_linked"
1931
+ ].filter(Boolean)
1932
+ };
1933
+ }
1934
+
1076
1935
  function buildActivitySnapshotFromCommandResult(result) {
1077
1936
  const linked = buildLinkedRecordSetFromCommandResult(result);
1078
1937
  return {
@@ -1260,7 +2119,16 @@ function buildInteractionResultPackagePortableHandoff(result, resultPackage) {
1260
2119
  const economicConsequence = buildEconomicConsequenceHandoffBundle(state, {
1261
2120
  account_id: creditSpend.account_id,
1262
2121
  usage_meter_id: creditSpend.usage_meter_id,
1263
- credit_spend_id: creditSpend.credit_spend_id
2122
+ credit_spend_id: creditSpend.credit_spend_id,
2123
+ payment_ref: payment.payment_id || null,
2124
+ settlement_ref: settlement.settlement_id || (settlement.live && settlement.live.settlement_id) || null,
2125
+ settlement_txid: settlement.txid || null,
2126
+ settlement_status: settlement.status || null,
2127
+ settlement_finality_status: settlement.live && settlement.live.finality_status
2128
+ ? settlement.live.finality_status
2129
+ : null,
2130
+ treasury_receipt_ref: treasury.treasury_receipt_id || null,
2131
+ proof_ref: receipt.proof_ref || null
1264
2132
  });
1265
2133
  if (economicConsequence && economicConsequence.ok === true) {
1266
2134
  economicConsequenceHandoffBundle = economicConsequence.handoff_bundle;
@@ -2032,225 +2900,1647 @@ function buildPreparedContinuationAdapterIntegrableOperatingIntegrationBundle(po
2032
2900
  };
2033
2901
  }
2034
2902
 
2035
- function buildPreparedContinuationDefaultOperatingIntegrationSummary(portableHandoff, continuation) {
2036
- const operatingIntegration = buildPreparedContinuationAdapterIntegrableOperatingIntegrationSummary(portableHandoff, continuation);
2037
- return {
2038
- ok: operatingIntegration.ok === true,
2039
- operating_integration_ref: operatingIntegration.operating_integration_ref || null,
2040
- default_operating_integration_ref: operatingIntegration.operating_integration_ref
2041
- ? `default.${operatingIntegration.operating_integration_ref}`
2042
- : null,
2043
- stable_default_operating_integration_ids: Array.isArray(operatingIntegration.integrable_operating_ids)
2044
- ? operatingIntegration.integrable_operating_ids
2045
- : [],
2046
- default_operating_integration_carry: operatingIntegration.operating_integration_carry || {},
2047
- operating_integration_integrable_by_default: operatingIntegration.adapter_integrable === true,
2048
- next_surface: "/v1/proof-center/result-package-handoff/review/operating-integration-run"
2049
- };
2050
- }
2903
+ function buildPreparedContinuationDefaultOperatingIntegrationSummary(portableHandoff, continuation) {
2904
+ const operatingIntegration = buildPreparedContinuationAdapterIntegrableOperatingIntegrationSummary(portableHandoff, continuation);
2905
+ return {
2906
+ ok: operatingIntegration.ok === true,
2907
+ operating_integration_ref: operatingIntegration.operating_integration_ref || null,
2908
+ default_operating_integration_ref: operatingIntegration.operating_integration_ref
2909
+ ? `default.${operatingIntegration.operating_integration_ref}`
2910
+ : null,
2911
+ stable_default_operating_integration_ids: Array.isArray(operatingIntegration.integrable_operating_ids)
2912
+ ? operatingIntegration.integrable_operating_ids
2913
+ : [],
2914
+ default_operating_integration_carry: operatingIntegration.operating_integration_carry || {},
2915
+ operating_integration_integrable_by_default: operatingIntegration.adapter_integrable === true,
2916
+ next_surface: "/v1/proof-center/result-package-handoff/review/operating-integration-run"
2917
+ };
2918
+ }
2919
+
2920
+ function buildPreparedContinuationAdapterDefaultOperatingPathSummary(portableHandoff, continuation) {
2921
+ const operatingIntegration = buildPreparedContinuationDefaultOperatingIntegrationSummary(portableHandoff, continuation);
2922
+ return {
2923
+ ok: operatingIntegration.ok === true,
2924
+ default_operating_integration_ref: operatingIntegration.default_operating_integration_ref || null,
2925
+ operating_path_ref: operatingIntegration.default_operating_integration_ref
2926
+ ? `path.${operatingIntegration.default_operating_integration_ref}`
2927
+ : null,
2928
+ default_operating_path_ids: Array.isArray(operatingIntegration.stable_default_operating_integration_ids)
2929
+ ? operatingIntegration.stable_default_operating_integration_ids
2930
+ : [],
2931
+ operating_path_carry: operatingIntegration.default_operating_integration_carry || {},
2932
+ adapter_ready_by_default: operatingIntegration.operating_integration_integrable_by_default === true,
2933
+ next_surface: "/v1/proof-center/result-package-handoff/review/operating-path"
2934
+ };
2935
+ }
2936
+
2937
+ function buildPreparedContinuationAdapterDefaultOperatingPathBundle(portableHandoff, continuation) {
2938
+ const handoff = portableHandoff && typeof portableHandoff === "object" ? portableHandoff : {};
2939
+ const summary = buildPreparedContinuationAdapterDefaultOperatingPathSummary(portableHandoff, continuation);
2940
+ return {
2941
+ ok: true,
2942
+ operating_path_summary: summary,
2943
+ operating_path_template: {
2944
+ ok: true,
2945
+ operating_path_ref: summary.operating_path_ref || null,
2946
+ target_surface: "/v1/proof-center/result-package-handoff/review/operating-path",
2947
+ request_template: {
2948
+ handoff_bundle: handoff
2949
+ },
2950
+ stable_boundary_ids: Array.isArray(summary.default_operating_path_ids) ? summary.default_operating_path_ids : []
2951
+ }
2952
+ };
2953
+ }
2954
+
2955
+ function buildPreparedContinuationDefaultOperatingPathRunSummary(portableHandoff, continuation) {
2956
+ const operatingPath = buildPreparedContinuationAdapterDefaultOperatingPathSummary(portableHandoff, continuation);
2957
+ return {
2958
+ ok: operatingPath.ok === true,
2959
+ operating_path_ref: operatingPath.operating_path_ref || null,
2960
+ default_operating_path_ref: operatingPath.operating_path_ref
2961
+ ? `default.${operatingPath.operating_path_ref}`
2962
+ : null,
2963
+ stable_default_operating_path_ids: Array.isArray(operatingPath.default_operating_path_ids)
2964
+ ? operatingPath.default_operating_path_ids
2965
+ : [],
2966
+ default_operating_path_carry: operatingPath.operating_path_carry || {},
2967
+ operating_path_ready_by_default: operatingPath.adapter_ready_by_default === true,
2968
+ next_surface: "/v1/proof-center/result-package-handoff/review/operating-path-run"
2969
+ };
2970
+ }
2971
+
2972
+ function buildPreparedContinuationAdapterCompleteDefaultPathSummary(portableHandoff, continuation) {
2973
+ const operatingPath = buildPreparedContinuationDefaultOperatingPathRunSummary(portableHandoff, continuation);
2974
+ return {
2975
+ ok: operatingPath.ok === true,
2976
+ default_operating_path_ref: operatingPath.default_operating_path_ref || null,
2977
+ complete_default_path_ref: operatingPath.default_operating_path_ref
2978
+ ? `complete.${operatingPath.default_operating_path_ref}`
2979
+ : null,
2980
+ complete_default_path_ids: Array.isArray(operatingPath.stable_default_operating_path_ids)
2981
+ ? operatingPath.stable_default_operating_path_ids
2982
+ : [],
2983
+ complete_default_path_carry: operatingPath.default_operating_path_carry || {},
2984
+ adapter_complete_by_default: operatingPath.operating_path_ready_by_default === true,
2985
+ next_surface: "/v1/proof-center/result-package-handoff/review/complete-default-path"
2986
+ };
2987
+ }
2988
+
2989
+ function buildPreparedContinuationAdapterCompleteDefaultPathBundle(portableHandoff, continuation) {
2990
+ const handoff = portableHandoff && typeof portableHandoff === "object" ? portableHandoff : {};
2991
+ const summary = buildPreparedContinuationAdapterCompleteDefaultPathSummary(portableHandoff, continuation);
2992
+ return {
2993
+ ok: true,
2994
+ complete_default_path_summary: summary,
2995
+ complete_default_path_template: {
2996
+ ok: true,
2997
+ complete_default_path_ref: summary.complete_default_path_ref || null,
2998
+ target_surface: "/v1/proof-center/result-package-handoff/review/complete-default-path",
2999
+ request_template: {
3000
+ handoff_bundle: handoff
3001
+ },
3002
+ stable_boundary_ids: Array.isArray(summary.complete_default_path_ids) ? summary.complete_default_path_ids : []
3003
+ }
3004
+ };
3005
+ }
3006
+
3007
+ function buildPreparedContinuationDefaultCompletePathRunSummary(portableHandoff, continuation) {
3008
+ const completePath = buildPreparedContinuationAdapterCompleteDefaultPathSummary(portableHandoff, continuation);
3009
+ return {
3010
+ ok: completePath.ok === true,
3011
+ complete_default_path_ref: completePath.complete_default_path_ref || null,
3012
+ default_complete_default_path_ref: completePath.complete_default_path_ref
3013
+ ? `default.${completePath.complete_default_path_ref}`
3014
+ : null,
3015
+ stable_default_complete_default_path_ids: Array.isArray(completePath.complete_default_path_ids)
3016
+ ? completePath.complete_default_path_ids
3017
+ : [],
3018
+ default_complete_default_path_carry: completePath.complete_default_path_carry || {},
3019
+ complete_default_path_ready: completePath.adapter_complete_by_default === true,
3020
+ next_surface: "/v1/proof-center/result-package-handoff/review/complete-default-path-run"
3021
+ };
3022
+ }
3023
+
3024
+ function buildInteractionResultPackageContinuationRequestTemplate(portableHandoff, continuation) {
3025
+ const handoff = portableHandoff && typeof portableHandoff === "object" ? portableHandoff : {};
3026
+ return {
3027
+ ok: true,
3028
+ continuation_ref: continuation && continuation.continuation_ref ? continuation.continuation_ref : null,
3029
+ target_surface: "/v1/proof-center/result-package-handoff/run",
3030
+ review_surface: "/v1/proof-center/result-package-handoff/review",
3031
+ request_template: {
3032
+ handoff_bundle: handoff,
3033
+ evidence_refs: handoff.proof_ref ? [handoff.proof_ref] : [],
3034
+ options: {
3035
+ legacy_identity_material_hex: "<required_for_local_demo_signing>"
3036
+ }
3037
+ }
3038
+ };
3039
+ }
3040
+
3041
+ function buildOperationsDashboard(filters) {
3042
+ const disputes = listRecords(state.disputes, filters);
3043
+ const refunds = listRecords(state.refunds, filters);
3044
+ const remediationTickets = listRecords(state.remediationTickets, filters);
3045
+ const transactions = listTransactionRecords(filters);
3046
+ const receipts = listReceiptRecords(filters);
3047
+ const deliveries = listRecords(state.deliveries, filters);
3048
+ return summarizeOperationsDashboardPayload({
3049
+ open_issues: {
3050
+ disputes,
3051
+ refunds,
3052
+ remediation_tickets: remediationTickets
3053
+ },
3054
+ execution_exceptions: {
3055
+ transactions,
3056
+ receipts,
3057
+ deliveries,
3058
+ remediation_tickets: remediationTickets
3059
+ }
3060
+ });
3061
+ }
3062
+
3063
+ function buildAttentionRecords(filters) {
3064
+ const dashboard = buildOperationsDashboard(filters);
3065
+ const refs = dashboard && dashboard.attention_refs ? dashboard.attention_refs : {};
3066
+ const disputes = (Array.isArray(refs.dispute_ids) ? refs.dispute_ids : [])
3067
+ .map((id) => summarizeDisputePayload(state.disputes.get(id)))
3068
+ .filter((entry) => entry && entry.dispute_id);
3069
+ const refunds = (Array.isArray(refs.refund_ids) ? refs.refund_ids : [])
3070
+ .map((id) => summarizeRefundPayload(state.refunds.get(id)))
3071
+ .filter((entry) => entry && entry.refund_id);
3072
+ const remediationTickets = (Array.isArray(refs.ticket_ids) ? refs.ticket_ids : [])
3073
+ .map((id) => summarizeRemediationTicketPayload(state.remediationTickets.get(id)))
3074
+ .filter((entry) => entry && entry.ticket_id);
3075
+ const transactions = (Array.isArray(refs.transaction_ids) ? refs.transaction_ids : [])
3076
+ .map((id) => summarizeTransactionPayload(state.transactions.get(id)))
3077
+ .filter((entry) => entry && entry.transaction_id);
3078
+ const receipts = (Array.isArray(refs.receipt_ids) ? refs.receipt_ids : [])
3079
+ .map((id) => summarizeReceiptPayload(state.receipts.get(id)))
3080
+ .filter((entry) => entry && entry.receipt_id);
3081
+ const deliveries = (Array.isArray(refs.delivery_ids) ? refs.delivery_ids : [])
3082
+ .map((id) => summarizeDeliveryPayload(state.deliveries.get(id)))
3083
+ .filter((entry) => entry && entry.delivery_id);
3084
+ return {
3085
+ dashboard,
3086
+ disputes,
3087
+ refunds,
3088
+ remediation_tickets: remediationTickets,
3089
+ transactions,
3090
+ receipts,
3091
+ deliveries
3092
+ };
3093
+ }
3094
+
3095
+ function buildOperatorShellSummaryPayload(body) {
3096
+ const requestBody = body && typeof body === "object" && !Array.isArray(body) ? body : {};
3097
+ const accountId = requestBody.account_id || "acct_demo";
3098
+ const runtimeDurability = buildRuntimeDurabilitySummary();
3099
+ const nativeSettlementReadiness = buildNativeSettlementReadinessSummary();
3100
+ return buildOperatorShellSummary({
3101
+ account_id: accountId,
3102
+ operations_dashboard: buildOperationsDashboard({ account_id: accountId }),
3103
+ operator_export_pack: buildOperatorExportPack(state, { account_id: accountId }, listRecords, {
3104
+ runtime_durability: runtimeDurability,
3105
+ native_settlement_readiness: nativeSettlementReadiness
3106
+ }),
3107
+ economics_operator_view: buildOperatorView(state, accountId),
3108
+ economics_operator_dashboard: buildOperatorDashboard(state, accountId),
3109
+ entitlement_replenishment_summary: buildEntitlementReplenishmentSummary(state, accountId),
3110
+ hosted_checkout_operator_summary: buildHostedCheckoutOperatorSummary(state, accountId),
3111
+ coordination_operator_view: buildCoordinationOperatorView(requestBody),
3112
+ coordination_admin_view: buildCoordinationAdminView(requestBody),
3113
+ runtime_durability: runtimeDurability,
3114
+ native_settlement_readiness: nativeSettlementReadiness
3115
+ });
3116
+ }
3117
+
3118
+ async function routeRequest(req, res) {
3119
+ const url = new URL(req.url, "http://127.0.0.1");
3120
+ hydrateQuoteStates(state);
3121
+ hydratePendingExecutions(state);
3122
+
3123
+ if (req.method === "GET" && url.pathname === "/health") {
3124
+ sendJson(res, 200, {
3125
+ status: "ok",
3126
+ service: "xytara",
3127
+ readiness: "ready",
3128
+ runtime_durability: buildRuntimeDurabilitySummary(),
3129
+ native_settlement_readiness: buildNativeSettlementReadinessSummary()
3130
+ });
3131
+ return;
3132
+ }
3133
+
3134
+ if (req.method === "GET" && url.pathname === "/v1/release-pack") {
3135
+ sendJson(res, 200, buildReleasePack());
3136
+ return;
3137
+ }
3138
+
3139
+ if (req.method === "GET" && url.pathname === "/v1/release-pack/summary") {
3140
+ sendJson(res, 200, summarizeReleasePack());
3141
+ return;
3142
+ }
3143
+
3144
+ if (req.method === "GET" && url.pathname === "/v1/release-pack/comparison") {
3145
+ sendJson(res, 200, buildComparisonPack());
3146
+ return;
3147
+ }
3148
+
3149
+ if (req.method === "GET" && url.pathname === "/v1/release-pack/comparison/summary") {
3150
+ sendJson(res, 200, summarizeComparisonPack());
3151
+ return;
3152
+ }
3153
+
3154
+ if (req.method === "GET" && url.pathname === "/v1/release-pack/adoption") {
3155
+ sendJson(res, 200, buildAdoptionPack());
3156
+ return;
3157
+ }
3158
+
3159
+ if (req.method === "GET" && url.pathname === "/v1/release-pack/adoption/summary") {
3160
+ sendJson(res, 200, summarizeAdoptionPack());
3161
+ return;
3162
+ }
3163
+
3164
+ if (req.method === "GET" && url.pathname === "/v1/release-pack/scenarios") {
3165
+ sendJson(res, 200, buildScenarioPack());
3166
+ return;
3167
+ }
3168
+
3169
+ if (req.method === "GET" && url.pathname === "/v1/release-pack/scenarios/summary") {
3170
+ sendJson(res, 200, summarizeScenarioPack());
3171
+ return;
3172
+ }
3173
+
3174
+ if (req.method === "GET" && url.pathname === "/v1/release-pack/launch") {
3175
+ sendJson(res, 200, buildLaunchPack({
3176
+ liveReadiness: buildNativeSettlementReadinessSummary()
3177
+ }));
3178
+ return;
3179
+ }
3180
+
3181
+ if (req.method === "GET" && url.pathname === "/v1/release-pack/launch/summary") {
3182
+ sendJson(res, 200, summarizeLaunchPack({
3183
+ liveReadiness: buildNativeSettlementReadinessSummary()
3184
+ }));
3185
+ return;
3186
+ }
3187
+
3188
+ if (req.method === "GET" && url.pathname === "/v1/release-manifest") {
3189
+ sendJson(res, 200, buildReleaseManifest());
3190
+ return;
3191
+ }
3192
+
3193
+ if (req.method === "GET" && url.pathname === "/v1/release-manifest/summary") {
3194
+ sendJson(res, 200, summarizeReleaseManifest());
3195
+ return;
3196
+ }
3197
+
3198
+ if (req.method === "GET" && url.pathname === "/v1/release-notes") {
3199
+ sendJson(res, 200, buildLaunchNotes());
3200
+ return;
3201
+ }
3202
+
3203
+ if (req.method === "GET" && url.pathname === "/v1/release-notes/summary") {
3204
+ sendJson(res, 200, summarizeLaunchNotes());
3205
+ return;
3206
+ }
3207
+
3208
+ if (req.method === "GET" && url.pathname === "/v1/release-center") {
3209
+ sendJson(res, 200, buildReleaseCenter({
3210
+ liveReadiness: buildNativeSettlementReadinessSummary()
3211
+ }));
3212
+ return;
3213
+ }
3214
+
3215
+ if (req.method === "GET" && url.pathname === "/v1/release-center/summary") {
3216
+ sendJson(res, 200, summarizeReleaseCenter({
3217
+ liveReadiness: buildNativeSettlementReadinessSummary()
3218
+ }));
3219
+ return;
3220
+ }
3221
+
3222
+ if (req.method === "GET" && url.pathname === "/v1/release-history") {
3223
+ sendJson(res, 200, buildReleaseHistory());
3224
+ return;
3225
+ }
3226
+
3227
+ if (req.method === "GET" && url.pathname === "/v1/release-history/summary") {
3228
+ sendJson(res, 200, summarizeReleaseHistory());
3229
+ return;
3230
+ }
3231
+
3232
+ if (req.method === "GET" && url.pathname === "/v1/adapter-pack") {
3233
+ sendJson(res, 200, buildAdapterPack());
3234
+ return;
3235
+ }
3236
+
3237
+ if (req.method === "GET" && url.pathname === "/v1/adapter-pack/summary") {
3238
+ sendJson(res, 200, summarizeAdapterPack());
3239
+ return;
3240
+ }
3241
+
3242
+ if (req.method === "GET" && url.pathname === "/v1/adapter-promotion") {
3243
+ sendJson(res, 200, buildAdapterPromotionPack());
3244
+ return;
3245
+ }
3246
+
3247
+ if (req.method === "GET" && url.pathname === "/v1/adapter-promotion/summary") {
3248
+ sendJson(res, 200, summarizeAdapterPromotionPack());
3249
+ return;
3250
+ }
3251
+
3252
+ if (req.method === "GET" && url.pathname === "/v1/adapter-partners") {
3253
+ sendJson(res, 200, buildAdapterPartnerPack());
3254
+ return;
3255
+ }
3256
+
3257
+ if (req.method === "GET" && url.pathname === "/v1/adapter-partners/summary") {
3258
+ sendJson(res, 200, summarizeAdapterPartnerPack());
3259
+ return;
3260
+ }
3261
+
3262
+ if (req.method === "GET" && url.pathname === "/v1/soft-launch") {
3263
+ sendJson(res, 200, buildSoftLaunchPack());
3264
+ return;
3265
+ }
3266
+
3267
+ if (req.method === "GET" && url.pathname === "/v1/soft-launch/summary") {
3268
+ sendJson(res, 200, summarizeSoftLaunchPack());
3269
+ return;
3270
+ }
3271
+
3272
+ if (req.method === "GET" && url.pathname === "/v1/outreach-copy") {
3273
+ sendJson(res, 200, buildOutreachCopyPack());
3274
+ return;
3275
+ }
3276
+
3277
+ if (req.method === "GET" && url.pathname === "/v1/outreach-copy/summary") {
3278
+ sendJson(res, 200, summarizeOutreachCopyPack());
3279
+ return;
3280
+ }
3281
+
3282
+ if (req.method === "GET" && url.pathname === "/v1/outreach-targets") {
3283
+ sendJson(res, 200, buildOutreachTargetPack());
3284
+ return;
3285
+ }
3286
+
3287
+ if (req.method === "GET" && url.pathname === "/v1/outreach-targets/summary") {
3288
+ sendJson(res, 200, summarizeOutreachTargetPack());
3289
+ return;
3290
+ }
3291
+
3292
+ if (req.method === "GET" && url.pathname === "/v1/outreach-messages") {
3293
+ sendJson(res, 200, buildOutreachMessagePack());
3294
+ return;
3295
+ }
3296
+
3297
+ if (req.method === "GET" && url.pathname === "/v1/outreach-messages/summary") {
3298
+ sendJson(res, 200, summarizeOutreachMessagePack());
3299
+ return;
3300
+ }
3301
+
3302
+ if (req.method === "GET" && url.pathname === "/v1/phases") {
3303
+ sendJson(res, 200, buildPhaseProgramPack());
3304
+ return;
3305
+ }
3306
+
3307
+ if (req.method === "GET" && url.pathname === "/v1/phases/summary") {
3308
+ sendJson(res, 200, summarizePhaseProgramPack());
3309
+ return;
3310
+ }
3311
+
3312
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-1") {
3313
+ sendJson(res, 200, buildPhase1EcosystemPack());
3314
+ return;
3315
+ }
3316
+
3317
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-1/summary") {
3318
+ sendJson(res, 200, summarizePhase1EcosystemPack());
3319
+ return;
3320
+ }
3321
+
3322
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-1/openai-codex") {
3323
+ sendJson(res, 200, buildPhase1OpenaiCodexPack());
3324
+ return;
3325
+ }
3326
+
3327
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-1/openai-codex/summary") {
3328
+ sendJson(res, 200, summarizePhase1OpenaiCodexPack());
3329
+ return;
3330
+ }
3331
+
3332
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-1/openai-codex/runtime") {
3333
+ sendJson(res, 200, buildPhase1OpenaiCodexRuntimePack());
3334
+ return;
3335
+ }
3336
+
3337
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-1/openai-codex/runtime/summary") {
3338
+ sendJson(res, 200, summarizePhase1OpenaiCodexRuntimePack());
3339
+ return;
3340
+ }
3341
+
3342
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-1/claude-mcp") {
3343
+ sendJson(res, 200, buildPhase1ClaudeMcpPack());
3344
+ return;
3345
+ }
3346
+
3347
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-1/claude-mcp/summary") {
3348
+ sendJson(res, 200, summarizePhase1ClaudeMcpPack());
3349
+ return;
3350
+ }
3351
+
3352
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-1/claude-mcp/runtime") {
3353
+ sendJson(res, 200, buildPhase1ClaudeMcpRuntimePack());
3354
+ return;
3355
+ }
3356
+
3357
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-1/claude-mcp/runtime/summary") {
3358
+ sendJson(res, 200, summarizePhase1ClaudeMcpRuntimePack());
3359
+ return;
3360
+ }
3361
+
3362
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2") {
3363
+ sendJson(res, 200, buildPhase2PaymentRailsPack());
3364
+ return;
3365
+ }
3366
+
3367
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/summary") {
3368
+ sendJson(res, 200, summarizePhase2PaymentRailsPack());
3369
+ return;
3370
+ }
3371
+
3372
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/completion") {
3373
+ sendJson(res, 200, buildPhase2CompletionPack());
3374
+ return;
3375
+ }
3376
+
3377
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/completion/summary") {
3378
+ sendJson(res, 200, summarizePhase2CompletionPack());
3379
+ return;
3380
+ }
3381
+
3382
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/freeze-review") {
3383
+ sendJson(res, 200, buildPhase2FreezeReviewPack());
3384
+ return;
3385
+ }
3386
+
3387
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/freeze-review/summary") {
3388
+ sendJson(res, 200, summarizePhase2FreezeReviewPack());
3389
+ return;
3390
+ }
3391
+
3392
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/gate") {
3393
+ sendJson(res, 200, buildPhase2GatePack());
3394
+ return;
3395
+ }
3396
+
3397
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/gate/summary") {
3398
+ sendJson(res, 200, summarizePhase2GatePack());
3399
+ return;
3400
+ }
3401
+
3402
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/closeout") {
3403
+ sendJson(res, 200, buildPhase2CloseoutPack());
3404
+ return;
3405
+ }
3406
+
3407
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/closeout/summary") {
3408
+ sendJson(res, 200, summarizePhase2CloseoutPack());
3409
+ return;
3410
+ }
3411
+
3412
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/decision-record") {
3413
+ sendJson(res, 200, buildPhase2DecisionRecordPack());
3414
+ return;
3415
+ }
3416
+
3417
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/decision-record/summary") {
3418
+ sendJson(res, 200, summarizePhase2DecisionRecordPack());
3419
+ return;
3420
+ }
3421
+
3422
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/decision-resolution") {
3423
+ sendJson(res, 200, buildPhase2DecisionResolutionPack());
3424
+ return;
3425
+ }
3426
+
3427
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/decision-resolution/summary") {
3428
+ sendJson(res, 200, summarizePhase2DecisionResolutionPack());
3429
+ return;
3430
+ }
3431
+
3432
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/flip-preview") {
3433
+ sendJson(res, 200, buildPhase2FlipPreviewPack());
3434
+ return;
3435
+ }
3436
+
3437
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/flip-preview/summary") {
3438
+ sendJson(res, 200, summarizePhase2FlipPreviewPack());
3439
+ return;
3440
+ }
3441
+
3442
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/evm-base") {
3443
+ sendJson(res, 200, buildPhase2EvmBaseRuntimePack());
3444
+ return;
3445
+ }
3446
+
3447
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/evm-base/summary") {
3448
+ sendJson(res, 200, summarizePhase2EvmBaseRuntimePack());
3449
+ return;
3450
+ }
3451
+
3452
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/base-usdc") {
3453
+ sendJson(res, 200, buildPhase2BaseUsdcRuntimePack());
3454
+ return;
3455
+ }
3456
+
3457
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/base-usdc/summary") {
3458
+ sendJson(res, 200, summarizePhase2BaseUsdcRuntimePack());
3459
+ return;
3460
+ }
3461
+
3462
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/eth") {
3463
+ sendJson(res, 200, buildPhase2EthRuntimePack());
3464
+ return;
3465
+ }
3466
+
3467
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/eth/summary") {
3468
+ sendJson(res, 200, summarizePhase2EthRuntimePack());
3469
+ return;
3470
+ }
3471
+
3472
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3") {
3473
+ sendJson(res, 200, buildPhase3NativeBsvPack());
3474
+ return;
3475
+ }
3476
+
3477
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/summary") {
3478
+ sendJson(res, 200, summarizePhase3NativeBsvPack());
3479
+ return;
3480
+ }
3481
+
3482
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/native-continuity") {
3483
+ sendJson(res, 200, buildPhase3NativeContinuityPack());
3484
+ return;
3485
+ }
3486
+
3487
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/native-continuity/summary") {
3488
+ sendJson(res, 200, summarizePhase3NativeContinuityPack());
3489
+ return;
3490
+ }
3491
+
3492
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/freeze-baseline") {
3493
+ sendJson(res, 200, buildPhase3FreezeBaselinePack());
3494
+ return;
3495
+ }
3496
+
3497
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/freeze-baseline/summary") {
3498
+ sendJson(res, 200, summarizePhase3FreezeBaselinePack());
3499
+ return;
3500
+ }
3501
+
3502
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/completion") {
3503
+ sendJson(res, 200, buildPhase3CompletionPack());
3504
+ return;
3505
+ }
3506
+
3507
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/completion/summary") {
3508
+ sendJson(res, 200, summarizePhase3CompletionPack());
3509
+ return;
3510
+ }
3511
+
3512
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/freeze-review") {
3513
+ sendJson(res, 200, buildPhase3FreezeReviewPack());
3514
+ return;
3515
+ }
3516
+
3517
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/freeze-review/summary") {
3518
+ sendJson(res, 200, summarizePhase3FreezeReviewPack());
3519
+ return;
3520
+ }
3521
+
3522
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/gate") {
3523
+ sendJson(res, 200, buildPhase3GatePack());
3524
+ return;
3525
+ }
3526
+
3527
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/gate/summary") {
3528
+ sendJson(res, 200, summarizePhase3GatePack());
3529
+ return;
3530
+ }
3531
+
3532
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/closeout") {
3533
+ sendJson(res, 200, buildPhase3CloseoutPack());
3534
+ return;
3535
+ }
3536
+
3537
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/closeout/summary") {
3538
+ sendJson(res, 200, summarizePhase3CloseoutPack());
3539
+ return;
3540
+ }
3541
+
3542
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/decision-record") {
3543
+ sendJson(res, 200, buildPhase3DecisionRecordPack());
3544
+ return;
3545
+ }
3546
+
3547
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/decision-record/summary") {
3548
+ sendJson(res, 200, summarizePhase3DecisionRecordPack());
3549
+ return;
3550
+ }
3551
+
3552
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/decision-resolution") {
3553
+ sendJson(res, 200, buildPhase3DecisionResolutionPack());
3554
+ return;
3555
+ }
3556
+
3557
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/decision-resolution/summary") {
3558
+ sendJson(res, 200, summarizePhase3DecisionResolutionPack());
3559
+ return;
3560
+ }
3561
+
3562
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/bsv-teranode") {
3563
+ sendJson(res, 200, buildPhase3BsvTeranodeRuntimePack());
3564
+ return;
3565
+ }
3566
+
3567
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/bsv-teranode/summary") {
3568
+ sendJson(res, 200, summarizePhase3BsvTeranodeRuntimePack());
3569
+ return;
3570
+ }
3571
+
3572
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/metanet") {
3573
+ sendJson(res, 200, buildPhase3MetanetRuntimePack());
3574
+ return;
3575
+ }
3576
+
3577
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/metanet/summary") {
3578
+ sendJson(res, 200, summarizePhase3MetanetRuntimePack());
3579
+ return;
3580
+ }
3581
+
3582
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/brc") {
3583
+ sendJson(res, 200, buildPhase3BrcRuntimePack());
3584
+ return;
3585
+ }
3586
+
3587
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-3/brc/summary") {
3588
+ sendJson(res, 200, summarizePhase3BrcRuntimePack());
3589
+ return;
3590
+ }
3591
+
3592
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4") {
3593
+ sendJson(res, 200, buildPhase4IdentityTrustPack());
3594
+ return;
3595
+ }
3596
+
3597
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/summary") {
3598
+ sendJson(res, 200, summarizePhase4IdentityTrustPack());
3599
+ return;
3600
+ }
3601
+
3602
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/erc8004") {
3603
+ sendJson(res, 200, buildPhase4Erc8004RuntimePack());
3604
+ return;
3605
+ }
3606
+
3607
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/erc8004/summary") {
3608
+ sendJson(res, 200, summarizePhase4Erc8004RuntimePack());
3609
+ return;
3610
+ }
3611
+
3612
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/identity-registry") {
3613
+ sendJson(res, 200, buildPhase4IdentityRegistryRuntimePack());
3614
+ return;
3615
+ }
3616
+
3617
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/identity-registry/summary") {
3618
+ sendJson(res, 200, summarizePhase4IdentityRegistryRuntimePack());
3619
+ return;
3620
+ }
3621
+
3622
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/attestation") {
3623
+ sendJson(res, 200, buildPhase4AttestationRuntimePack());
3624
+ return;
3625
+ }
3626
+
3627
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/attestation/summary") {
3628
+ sendJson(res, 200, summarizePhase4AttestationRuntimePack());
3629
+ return;
3630
+ }
3631
+
3632
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/trust-continuity") {
3633
+ sendJson(res, 200, buildPhase4TrustContinuityPack());
3634
+ return;
3635
+ }
3636
+
3637
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/trust-continuity/summary") {
3638
+ sendJson(res, 200, summarizePhase4TrustContinuityPack());
3639
+ return;
3640
+ }
3641
+
3642
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/completion") {
3643
+ sendJson(res, 200, buildPhase4CompletionPack());
3644
+ return;
3645
+ }
3646
+
3647
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/completion/summary") {
3648
+ sendJson(res, 200, summarizePhase4CompletionPack());
3649
+ return;
3650
+ }
3651
+
3652
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/freeze-review") {
3653
+ sendJson(res, 200, buildPhase4FreezeReviewPack());
3654
+ return;
3655
+ }
3656
+
3657
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/freeze-baseline") {
3658
+ sendJson(res, 200, buildPhase4FreezeBaselinePack());
3659
+ return;
3660
+ }
3661
+
3662
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/freeze-baseline/summary") {
3663
+ sendJson(res, 200, summarizePhase4FreezeBaselinePack());
3664
+ return;
3665
+ }
3666
+
3667
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/freeze-review/summary") {
3668
+ sendJson(res, 200, summarizePhase4FreezeReviewPack());
3669
+ return;
3670
+ }
3671
+
3672
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/gate") {
3673
+ sendJson(res, 200, buildPhase4GatePack());
3674
+ return;
3675
+ }
3676
+
3677
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/gate/summary") {
3678
+ sendJson(res, 200, summarizePhase4GatePack());
3679
+ return;
3680
+ }
3681
+
3682
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/closeout") {
3683
+ sendJson(res, 200, buildPhase4CloseoutPack());
3684
+ return;
3685
+ }
3686
+
3687
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/closeout/summary") {
3688
+ sendJson(res, 200, summarizePhase4CloseoutPack());
3689
+ return;
3690
+ }
3691
+
3692
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/decision-record") {
3693
+ sendJson(res, 200, buildPhase4DecisionRecordPack());
3694
+ return;
3695
+ }
3696
+
3697
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/decision-record/summary") {
3698
+ sendJson(res, 200, summarizePhase4DecisionRecordPack());
3699
+ return;
3700
+ }
3701
+
3702
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/decision-resolution") {
3703
+ sendJson(res, 200, buildPhase4DecisionResolutionPack());
3704
+ return;
3705
+ }
3706
+
3707
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-4/decision-resolution/summary") {
3708
+ sendJson(res, 200, summarizePhase4DecisionResolutionPack());
3709
+ return;
3710
+ }
3711
+
3712
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5") {
3713
+ sendJson(res, 200, buildPhase5MajorRailsPack());
3714
+ return;
3715
+ }
3716
+
3717
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/summary") {
3718
+ sendJson(res, 200, summarizePhase5MajorRailsPack());
3719
+ return;
3720
+ }
3721
+
3722
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/major-rails-continuity") {
3723
+ sendJson(res, 200, buildPhase5MajorRailsContinuityPack());
3724
+ return;
3725
+ }
3726
+
3727
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/major-rails-continuity/summary") {
3728
+ sendJson(res, 200, summarizePhase5MajorRailsContinuityPack());
3729
+ return;
3730
+ }
3731
+
3732
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/completion") {
3733
+ sendJson(res, 200, buildPhase5CompletionPack());
3734
+ return;
3735
+ }
3736
+
3737
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/completion/summary") {
3738
+ sendJson(res, 200, summarizePhase5CompletionPack());
3739
+ return;
3740
+ }
3741
+
3742
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/freeze-review") {
3743
+ sendJson(res, 200, buildPhase5FreezeReviewPack());
3744
+ return;
3745
+ }
3746
+
3747
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/freeze-review/summary") {
3748
+ sendJson(res, 200, summarizePhase5FreezeReviewPack());
3749
+ return;
3750
+ }
3751
+
3752
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/freeze-baseline") {
3753
+ sendJson(res, 200, buildPhase5FreezeBaselinePack());
3754
+ return;
3755
+ }
3756
+
3757
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/freeze-baseline/summary") {
3758
+ sendJson(res, 200, summarizePhase5FreezeBaselinePack());
3759
+ return;
3760
+ }
3761
+
3762
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/gate") {
3763
+ sendJson(res, 200, buildPhase5GatePack());
3764
+ return;
3765
+ }
3766
+
3767
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/gate/summary") {
3768
+ sendJson(res, 200, summarizePhase5GatePack());
3769
+ return;
3770
+ }
3771
+
3772
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/closeout") {
3773
+ sendJson(res, 200, buildPhase5CloseoutPack());
3774
+ return;
3775
+ }
3776
+
3777
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/closeout/summary") {
3778
+ sendJson(res, 200, summarizePhase5CloseoutPack());
3779
+ return;
3780
+ }
3781
+
3782
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/decision-record") {
3783
+ sendJson(res, 200, buildPhase5DecisionRecordPack());
3784
+ return;
3785
+ }
3786
+
3787
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/decision-record/summary") {
3788
+ sendJson(res, 200, summarizePhase5DecisionRecordPack());
3789
+ return;
3790
+ }
3791
+
3792
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/decision-resolution") {
3793
+ sendJson(res, 200, buildPhase5DecisionResolutionPack());
3794
+ return;
3795
+ }
3796
+
3797
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/decision-resolution/summary") {
3798
+ sendJson(res, 200, summarizePhase5DecisionResolutionPack());
3799
+ return;
3800
+ }
3801
+
3802
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/solana") {
3803
+ sendJson(res, 200, buildPhase5SolanaRuntimePack());
3804
+ return;
3805
+ }
3806
+
3807
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/solana/summary") {
3808
+ sendJson(res, 200, summarizePhase5SolanaRuntimePack());
3809
+ return;
3810
+ }
3811
+
3812
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/antelope") {
3813
+ sendJson(res, 200, buildPhase5AntelopeRuntimePack());
3814
+ return;
3815
+ }
3816
+
3817
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/antelope/summary") {
3818
+ sendJson(res, 200, summarizePhase5AntelopeRuntimePack());
3819
+ return;
3820
+ }
3821
+
3822
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/proton-xpr") {
3823
+ sendJson(res, 200, buildPhase5ProtonXprRuntimePack());
3824
+ return;
3825
+ }
3826
+
3827
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-5/proton-xpr/summary") {
3828
+ sendJson(res, 200, summarizePhase5ProtonXprRuntimePack());
3829
+ return;
3830
+ }
3831
+
3832
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6") {
3833
+ sendJson(res, 200, buildPhase6FrameworkRuntimePack());
3834
+ return;
3835
+ }
3836
+
3837
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/summary") {
3838
+ sendJson(res, 200, summarizePhase6FrameworkRuntimePack());
3839
+ return;
3840
+ }
3841
+
3842
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/langgraph") {
3843
+ sendJson(res, 200, buildPhase6LanggraphRuntimePack());
3844
+ return;
3845
+ }
3846
+
3847
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/langgraph/summary") {
3848
+ sendJson(res, 200, summarizePhase6LanggraphRuntimePack());
3849
+ return;
3850
+ }
3851
+
3852
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/langchain") {
3853
+ sendJson(res, 200, buildPhase6LangchainRuntimePack());
3854
+ return;
3855
+ }
3856
+
3857
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/langchain/summary") {
3858
+ sendJson(res, 200, summarizePhase6LangchainRuntimePack());
3859
+ return;
3860
+ }
3861
+
3862
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/autogen") {
3863
+ sendJson(res, 200, buildPhase6AutogenRuntimePack());
3864
+ return;
3865
+ }
3866
+
3867
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/autogen/summary") {
3868
+ sendJson(res, 200, summarizePhase6AutogenRuntimePack());
3869
+ return;
3870
+ }
3871
+
3872
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/semantic-kernel") {
3873
+ sendJson(res, 200, buildPhase6SemanticKernelRuntimePack());
3874
+ return;
3875
+ }
3876
+
3877
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/semantic-kernel/summary") {
3878
+ sendJson(res, 200, summarizePhase6SemanticKernelRuntimePack());
3879
+ return;
3880
+ }
3881
+
3882
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/framework-continuity") {
3883
+ sendJson(res, 200, buildPhase6FrameworkContinuityPack());
3884
+ return;
3885
+ }
3886
+
3887
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/framework-continuity/summary") {
3888
+ sendJson(res, 200, summarizePhase6FrameworkContinuityPack());
3889
+ return;
3890
+ }
3891
+
3892
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/completion") {
3893
+ sendJson(res, 200, buildPhase6CompletionPack());
3894
+ return;
3895
+ }
3896
+
3897
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/completion/summary") {
3898
+ sendJson(res, 200, summarizePhase6CompletionPack());
3899
+ return;
3900
+ }
3901
+
3902
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/freeze-review") {
3903
+ sendJson(res, 200, buildPhase6FreezeReviewPack());
3904
+ return;
3905
+ }
3906
+
3907
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/freeze-review/summary") {
3908
+ sendJson(res, 200, summarizePhase6FreezeReviewPack());
3909
+ return;
3910
+ }
3911
+
3912
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/freeze-baseline") {
3913
+ sendJson(res, 200, buildPhase6FreezeBaselinePack());
3914
+ return;
3915
+ }
3916
+
3917
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/freeze-baseline/summary") {
3918
+ sendJson(res, 200, summarizePhase6FreezeBaselinePack());
3919
+ return;
3920
+ }
3921
+
3922
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/gate") {
3923
+ sendJson(res, 200, buildPhase6GatePack());
3924
+ return;
3925
+ }
3926
+
3927
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/gate/summary") {
3928
+ sendJson(res, 200, summarizePhase6GatePack());
3929
+ return;
3930
+ }
3931
+
3932
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/closeout") {
3933
+ sendJson(res, 200, buildPhase6CloseoutPack());
3934
+ return;
3935
+ }
3936
+
3937
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/closeout/summary") {
3938
+ sendJson(res, 200, summarizePhase6CloseoutPack());
3939
+ return;
3940
+ }
3941
+
3942
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/decision-record") {
3943
+ sendJson(res, 200, buildPhase6DecisionRecordPack());
3944
+ return;
3945
+ }
3946
+
3947
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/decision-record/summary") {
3948
+ sendJson(res, 200, summarizePhase6DecisionRecordPack());
3949
+ return;
3950
+ }
3951
+
3952
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/decision-resolution") {
3953
+ sendJson(res, 200, buildPhase6DecisionResolutionPack());
3954
+ return;
3955
+ }
3956
+
3957
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-6/decision-resolution/summary") {
3958
+ sendJson(res, 200, summarizePhase6DecisionResolutionPack());
3959
+ return;
3960
+ }
3961
+
3962
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7") {
3963
+ sendJson(res, 200, buildPhase7EventSystemPack());
3964
+ return;
3965
+ }
3966
+
3967
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/summary") {
3968
+ sendJson(res, 200, summarizePhase7EventSystemPack());
3969
+ return;
3970
+ }
3971
+
3972
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/kafka") {
3973
+ sendJson(res, 200, buildPhase7KafkaRuntimePack());
3974
+ return;
3975
+ }
3976
+
3977
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/kafka/summary") {
3978
+ sendJson(res, 200, summarizePhase7KafkaRuntimePack());
3979
+ return;
3980
+ }
3981
+
3982
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/nats") {
3983
+ sendJson(res, 200, buildPhase7NatsRuntimePack());
3984
+ return;
3985
+ }
3986
+
3987
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/nats/summary") {
3988
+ sendJson(res, 200, summarizePhase7NatsRuntimePack());
3989
+ return;
3990
+ }
3991
+
3992
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/mqtt") {
3993
+ sendJson(res, 200, buildPhase7MqttRuntimePack());
3994
+ return;
3995
+ }
3996
+
3997
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/mqtt/summary") {
3998
+ sendJson(res, 200, summarizePhase7MqttRuntimePack());
3999
+ return;
4000
+ }
4001
+
4002
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/webhook-event-bus") {
4003
+ sendJson(res, 200, buildPhase7WebhookEventBusRuntimePack());
4004
+ return;
4005
+ }
4006
+
4007
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/webhook-event-bus/summary") {
4008
+ sendJson(res, 200, summarizePhase7WebhookEventBusRuntimePack());
4009
+ return;
4010
+ }
4011
+
4012
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/event-system-continuity") {
4013
+ sendJson(res, 200, buildPhase7EventSystemContinuityPack());
4014
+ return;
4015
+ }
4016
+
4017
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/event-system-continuity/summary") {
4018
+ sendJson(res, 200, summarizePhase7EventSystemContinuityPack());
4019
+ return;
4020
+ }
4021
+
4022
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/completion") {
4023
+ sendJson(res, 200, buildPhase7CompletionPack());
4024
+ return;
4025
+ }
4026
+
4027
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/completion/summary") {
4028
+ sendJson(res, 200, summarizePhase7CompletionPack());
4029
+ return;
4030
+ }
4031
+
4032
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/freeze-review") {
4033
+ sendJson(res, 200, buildPhase7FreezeReviewPack());
4034
+ return;
4035
+ }
4036
+
4037
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/freeze-baseline") {
4038
+ sendJson(res, 200, buildPhase7FreezeBaselinePack());
4039
+ return;
4040
+ }
4041
+
4042
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/freeze-baseline/summary") {
4043
+ sendJson(res, 200, summarizePhase7FreezeBaselinePack());
4044
+ return;
4045
+ }
4046
+
4047
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/freeze-review/summary") {
4048
+ sendJson(res, 200, summarizePhase7FreezeReviewPack());
4049
+ return;
4050
+ }
4051
+
4052
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/gate") {
4053
+ sendJson(res, 200, buildPhase7GatePack());
4054
+ return;
4055
+ }
4056
+
4057
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/gate/summary") {
4058
+ sendJson(res, 200, summarizePhase7GatePack());
4059
+ return;
4060
+ }
4061
+
4062
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/closeout") {
4063
+ sendJson(res, 200, buildPhase7CloseoutPack());
4064
+ return;
4065
+ }
4066
+
4067
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/closeout/summary") {
4068
+ sendJson(res, 200, summarizePhase7CloseoutPack());
4069
+ return;
4070
+ }
4071
+
4072
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/decision-record") {
4073
+ sendJson(res, 200, buildPhase7DecisionRecordPack());
4074
+ return;
4075
+ }
4076
+
4077
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/decision-record/summary") {
4078
+ sendJson(res, 200, summarizePhase7DecisionRecordPack());
4079
+ return;
4080
+ }
4081
+
4082
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/decision-resolution") {
4083
+ sendJson(res, 200, buildPhase7DecisionResolutionPack());
4084
+ return;
4085
+ }
4086
+
4087
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-7/decision-resolution/summary") {
4088
+ sendJson(res, 200, summarizePhase7DecisionResolutionPack());
4089
+ return;
4090
+ }
4091
+
4092
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8") {
4093
+ sendJson(res, 200, buildPhase8ProofBridgesPack());
4094
+ return;
4095
+ }
4096
+
4097
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/summary") {
4098
+ sendJson(res, 200, summarizePhase8ProofBridgesPack());
4099
+ return;
4100
+ }
4101
+
4102
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/proof-bridge-continuity") {
4103
+ sendJson(res, 200, buildPhase8ProofBridgeContinuityPack());
4104
+ return;
4105
+ }
4106
+
4107
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/proof-bridge-continuity/summary") {
4108
+ sendJson(res, 200, summarizePhase8ProofBridgeContinuityPack());
4109
+ return;
4110
+ }
4111
+
4112
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/completion") {
4113
+ sendJson(res, 200, buildPhase8CompletionPack());
4114
+ return;
4115
+ }
4116
+
4117
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/completion/summary") {
4118
+ sendJson(res, 200, summarizePhase8CompletionPack());
4119
+ return;
4120
+ }
4121
+
4122
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/freeze-baseline") {
4123
+ sendJson(res, 200, buildPhase8FreezeBaselinePack());
4124
+ return;
4125
+ }
4126
+
4127
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/freeze-baseline/summary") {
4128
+ sendJson(res, 200, summarizePhase8FreezeBaselinePack());
4129
+ return;
4130
+ }
4131
+
4132
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/freeze-review") {
4133
+ sendJson(res, 200, buildPhase8FreezeReviewPack());
4134
+ return;
4135
+ }
4136
+
4137
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/freeze-review/summary") {
4138
+ sendJson(res, 200, summarizePhase8FreezeReviewPack());
4139
+ return;
4140
+ }
4141
+
4142
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/gate") {
4143
+ sendJson(res, 200, buildPhase8GatePack());
4144
+ return;
4145
+ }
4146
+
4147
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/gate/summary") {
4148
+ sendJson(res, 200, summarizePhase8GatePack());
4149
+ return;
4150
+ }
4151
+
4152
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/closeout") {
4153
+ sendJson(res, 200, buildPhase8CloseoutPack());
4154
+ return;
4155
+ }
4156
+
4157
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/closeout/summary") {
4158
+ sendJson(res, 200, summarizePhase8CloseoutPack());
4159
+ return;
4160
+ }
4161
+
4162
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/decision-record") {
4163
+ sendJson(res, 200, buildPhase8DecisionRecordPack());
4164
+ return;
4165
+ }
4166
+
4167
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/decision-record/summary") {
4168
+ sendJson(res, 200, summarizePhase8DecisionRecordPack());
4169
+ return;
4170
+ }
4171
+
4172
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/decision-resolution") {
4173
+ sendJson(res, 200, buildPhase8DecisionResolutionPack());
4174
+ return;
4175
+ }
4176
+
4177
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/decision-resolution/summary") {
4178
+ sendJson(res, 200, summarizePhase8DecisionResolutionPack());
4179
+ return;
4180
+ }
4181
+
4182
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/external-result-import") {
4183
+ sendJson(res, 200, buildPhase8ExternalResultImportRuntimePack());
4184
+ return;
4185
+ }
4186
+
4187
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/external-result-import/summary") {
4188
+ sendJson(res, 200, summarizePhase8ExternalResultImportRuntimePack());
4189
+ return;
4190
+ }
4191
+
4192
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/external-receipt-import") {
4193
+ sendJson(res, 200, buildPhase8ExternalReceiptImportRuntimePack());
4194
+ return;
4195
+ }
4196
+
4197
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/external-receipt-import/summary") {
4198
+ sendJson(res, 200, summarizePhase8ExternalReceiptImportRuntimePack());
4199
+ return;
4200
+ }
4201
+
4202
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/proof-bundle-normalization") {
4203
+ sendJson(res, 200, buildPhase8ProofBundleNormalizationRuntimePack());
4204
+ return;
4205
+ }
4206
+
4207
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-8/proof-bundle-normalization/summary") {
4208
+ sendJson(res, 200, summarizePhase8ProofBundleNormalizationRuntimePack());
4209
+ return;
4210
+ }
4211
+
4212
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9") {
4213
+ sendJson(res, 200, buildPhase9TreasuryConnectivityPack());
4214
+ return;
4215
+ }
4216
+
4217
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/summary") {
4218
+ sendJson(res, 200, summarizePhase9TreasuryConnectivityPack());
4219
+ return;
4220
+ }
4221
+
4222
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/treasury-continuity") {
4223
+ sendJson(res, 200, buildPhase9TreasuryContinuityPack());
4224
+ return;
4225
+ }
4226
+
4227
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/treasury-continuity/summary") {
4228
+ sendJson(res, 200, summarizePhase9TreasuryContinuityPack());
4229
+ return;
4230
+ }
4231
+
4232
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/completion") {
4233
+ sendJson(res, 200, buildPhase9CompletionPack());
4234
+ return;
4235
+ }
4236
+
4237
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/completion/summary") {
4238
+ sendJson(res, 200, summarizePhase9CompletionPack());
4239
+ return;
4240
+ }
4241
+
4242
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/freeze-baseline") {
4243
+ sendJson(res, 200, buildPhase9FreezeBaselinePack());
4244
+ return;
4245
+ }
4246
+
4247
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/freeze-baseline/summary") {
4248
+ sendJson(res, 200, summarizePhase9FreezeBaselinePack());
4249
+ return;
4250
+ }
4251
+
4252
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/freeze-review") {
4253
+ sendJson(res, 200, buildPhase9FreezeReviewPack());
4254
+ return;
4255
+ }
4256
+
4257
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/freeze-review/summary") {
4258
+ sendJson(res, 200, summarizePhase9FreezeReviewPack());
4259
+ return;
4260
+ }
4261
+
4262
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/gate") {
4263
+ sendJson(res, 200, buildPhase9GatePack());
4264
+ return;
4265
+ }
4266
+
4267
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/gate/summary") {
4268
+ sendJson(res, 200, summarizePhase9GatePack());
4269
+ return;
4270
+ }
4271
+
4272
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/closeout") {
4273
+ sendJson(res, 200, buildPhase9CloseoutPack());
4274
+ return;
4275
+ }
4276
+
4277
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/closeout/summary") {
4278
+ sendJson(res, 200, summarizePhase9CloseoutPack());
4279
+ return;
4280
+ }
4281
+
4282
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/decision-record") {
4283
+ sendJson(res, 200, buildPhase9DecisionRecordPack());
4284
+ return;
4285
+ }
4286
+
4287
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/decision-record/summary") {
4288
+ sendJson(res, 200, summarizePhase9DecisionRecordPack());
4289
+ return;
4290
+ }
4291
+
4292
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/decision-resolution") {
4293
+ sendJson(res, 200, buildPhase9DecisionResolutionPack());
4294
+ return;
4295
+ }
4296
+
4297
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/decision-resolution/summary") {
4298
+ sendJson(res, 200, summarizePhase9DecisionResolutionPack());
4299
+ return;
4300
+ }
4301
+
4302
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/treasury-destinations") {
4303
+ sendJson(res, 200, buildPhase9TreasuryDestinationsRuntimePack());
4304
+ return;
4305
+ }
4306
+
4307
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/treasury-destinations/summary") {
4308
+ sendJson(res, 200, summarizePhase9TreasuryDestinationsRuntimePack());
4309
+ return;
4310
+ }
4311
+
4312
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/custody-refs") {
4313
+ sendJson(res, 200, buildPhase9CustodyRefsRuntimePack());
4314
+ return;
4315
+ }
4316
+
4317
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/custody-refs/summary") {
4318
+ sendJson(res, 200, summarizePhase9CustodyRefsRuntimePack());
4319
+ return;
4320
+ }
4321
+
4322
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/operator-accounting-bridges") {
4323
+ sendJson(res, 200, buildPhase9OperatorAccountingBridgesRuntimePack());
4324
+ return;
4325
+ }
4326
+
4327
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-9/operator-accounting-bridges/summary") {
4328
+ sendJson(res, 200, summarizePhase9OperatorAccountingBridgesRuntimePack());
4329
+ return;
4330
+ }
4331
+
4332
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10") {
4333
+ sendJson(res, 200, buildPhase10LongTailEcosystemPack());
4334
+ return;
4335
+ }
4336
+
4337
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/summary") {
4338
+ sendJson(res, 200, summarizePhase10LongTailEcosystemPack());
4339
+ return;
4340
+ }
4341
+
4342
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/long-tail-continuity") {
4343
+ sendJson(res, 200, buildPhase10LongTailContinuityPack());
4344
+ return;
4345
+ }
4346
+
4347
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/long-tail-continuity/summary") {
4348
+ sendJson(res, 200, summarizePhase10LongTailContinuityPack());
4349
+ return;
4350
+ }
4351
+
4352
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/completion") {
4353
+ sendJson(res, 200, buildPhase10CompletionPack());
4354
+ return;
4355
+ }
4356
+
4357
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/completion/summary") {
4358
+ sendJson(res, 200, summarizePhase10CompletionPack());
4359
+ return;
4360
+ }
4361
+
4362
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/freeze-review") {
4363
+ sendJson(res, 200, buildPhase10FreezeReviewPack());
4364
+ return;
4365
+ }
4366
+
4367
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/freeze-review/summary") {
4368
+ sendJson(res, 200, summarizePhase10FreezeReviewPack());
4369
+ return;
4370
+ }
4371
+
4372
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/freeze-baseline") {
4373
+ sendJson(res, 200, buildPhase10FreezeBaselinePack());
4374
+ return;
4375
+ }
4376
+
4377
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/freeze-baseline/summary") {
4378
+ sendJson(res, 200, summarizePhase10FreezeBaselinePack());
4379
+ return;
4380
+ }
4381
+
4382
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/gate") {
4383
+ sendJson(res, 200, buildPhase10GatePack());
4384
+ return;
4385
+ }
4386
+
4387
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/gate/summary") {
4388
+ sendJson(res, 200, summarizePhase10GatePack());
4389
+ return;
4390
+ }
4391
+
4392
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/closeout") {
4393
+ sendJson(res, 200, buildPhase10CloseoutPack());
4394
+ return;
4395
+ }
4396
+
4397
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/closeout/summary") {
4398
+ sendJson(res, 200, summarizePhase10CloseoutPack());
4399
+ return;
4400
+ }
4401
+
4402
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/decision-record") {
4403
+ sendJson(res, 200, buildPhase10DecisionRecordPack());
4404
+ return;
4405
+ }
4406
+
4407
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/decision-record/summary") {
4408
+ sendJson(res, 200, summarizePhase10DecisionRecordPack());
4409
+ return;
4410
+ }
4411
+
4412
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/decision-resolution") {
4413
+ sendJson(res, 200, buildPhase10DecisionResolutionPack());
4414
+ return;
4415
+ }
4416
+
4417
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/decision-resolution/summary") {
4418
+ sendJson(res, 200, summarizePhase10DecisionResolutionPack());
4419
+ return;
4420
+ }
4421
+
4422
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/demand-signal-adapters") {
4423
+ sendJson(res, 200, buildPhase10DemandSignalAdaptersRuntimePack());
4424
+ return;
4425
+ }
4426
+
4427
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/demand-signal-adapters/summary") {
4428
+ sendJson(res, 200, summarizePhase10DemandSignalAdaptersRuntimePack());
4429
+ return;
4430
+ }
4431
+
4432
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/niche-extension-registry") {
4433
+ sendJson(res, 200, buildPhase10NicheExtensionRegistryRuntimePack());
4434
+ return;
4435
+ }
4436
+
4437
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/niche-extension-registry/summary") {
4438
+ sendJson(res, 200, summarizePhase10NicheExtensionRegistryRuntimePack());
4439
+ return;
4440
+ }
4441
+
4442
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/ecosystem-backlog-triage") {
4443
+ sendJson(res, 200, buildPhase10EcosystemBacklogTriageRuntimePack());
4444
+ return;
4445
+ }
4446
+
4447
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-10/ecosystem-backlog-triage/summary") {
4448
+ sendJson(res, 200, summarizePhase10EcosystemBacklogTriageRuntimePack());
4449
+ return;
4450
+ }
4451
+
4452
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/evm") {
4453
+ sendJson(res, 200, buildPhase2EvmRuntimePack());
4454
+ return;
4455
+ }
4456
+
4457
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/evm/summary") {
4458
+ sendJson(res, 200, summarizePhase2EvmRuntimePack());
4459
+ return;
4460
+ }
4461
+
4462
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/base") {
4463
+ sendJson(res, 200, buildPhase2BaseRuntimePack());
4464
+ return;
4465
+ }
4466
+
4467
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/base/summary") {
4468
+ sendJson(res, 200, summarizePhase2BaseRuntimePack());
4469
+ return;
4470
+ }
4471
+
4472
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/usdc") {
4473
+ sendJson(res, 200, buildPhase2UsdcRuntimePack());
4474
+ return;
4475
+ }
2051
4476
 
2052
- function buildPreparedContinuationAdapterDefaultOperatingPathSummary(portableHandoff, continuation) {
2053
- const operatingIntegration = buildPreparedContinuationDefaultOperatingIntegrationSummary(portableHandoff, continuation);
2054
- return {
2055
- ok: operatingIntegration.ok === true,
2056
- default_operating_integration_ref: operatingIntegration.default_operating_integration_ref || null,
2057
- operating_path_ref: operatingIntegration.default_operating_integration_ref
2058
- ? `path.${operatingIntegration.default_operating_integration_ref}`
2059
- : null,
2060
- default_operating_path_ids: Array.isArray(operatingIntegration.stable_default_operating_integration_ids)
2061
- ? operatingIntegration.stable_default_operating_integration_ids
2062
- : [],
2063
- operating_path_carry: operatingIntegration.default_operating_integration_carry || {},
2064
- adapter_ready_by_default: operatingIntegration.operating_integration_integrable_by_default === true,
2065
- next_surface: "/v1/proof-center/result-package-handoff/review/operating-path"
2066
- };
2067
- }
4477
+ if (req.method === "GET" && url.pathname === "/v1/phases/phase-2/usdc/summary") {
4478
+ sendJson(res, 200, summarizePhase2UsdcRuntimePack());
4479
+ return;
4480
+ }
2068
4481
 
2069
- function buildPreparedContinuationAdapterDefaultOperatingPathBundle(portableHandoff, continuation) {
2070
- const handoff = portableHandoff && typeof portableHandoff === "object" ? portableHandoff : {};
2071
- const summary = buildPreparedContinuationAdapterDefaultOperatingPathSummary(portableHandoff, continuation);
2072
- return {
2073
- ok: true,
2074
- operating_path_summary: summary,
2075
- operating_path_template: {
2076
- ok: true,
2077
- operating_path_ref: summary.operating_path_ref || null,
2078
- target_surface: "/v1/proof-center/result-package-handoff/review/operating-path",
2079
- request_template: {
2080
- handoff_bundle: handoff
2081
- },
2082
- stable_boundary_ids: Array.isArray(summary.default_operating_path_ids) ? summary.default_operating_path_ids : []
2083
- }
2084
- };
2085
- }
4482
+ if (req.method === "GET" && url.pathname === "/v1/publish-plan") {
4483
+ sendJson(res, 200, buildPublishPlan());
4484
+ return;
4485
+ }
2086
4486
 
2087
- function buildPreparedContinuationDefaultOperatingPathRunSummary(portableHandoff, continuation) {
2088
- const operatingPath = buildPreparedContinuationAdapterDefaultOperatingPathSummary(portableHandoff, continuation);
2089
- return {
2090
- ok: operatingPath.ok === true,
2091
- operating_path_ref: operatingPath.operating_path_ref || null,
2092
- default_operating_path_ref: operatingPath.operating_path_ref
2093
- ? `default.${operatingPath.operating_path_ref}`
2094
- : null,
2095
- stable_default_operating_path_ids: Array.isArray(operatingPath.default_operating_path_ids)
2096
- ? operatingPath.default_operating_path_ids
2097
- : [],
2098
- default_operating_path_carry: operatingPath.operating_path_carry || {},
2099
- operating_path_ready_by_default: operatingPath.adapter_ready_by_default === true,
2100
- next_surface: "/v1/proof-center/result-package-handoff/review/operating-path-run"
2101
- };
2102
- }
4487
+ if (req.method === "GET" && url.pathname === "/v1/publish-plan/summary") {
4488
+ sendJson(res, 200, summarizePublishPlan());
4489
+ return;
4490
+ }
2103
4491
 
2104
- function buildPreparedContinuationAdapterCompleteDefaultPathSummary(portableHandoff, continuation) {
2105
- const operatingPath = buildPreparedContinuationDefaultOperatingPathRunSummary(portableHandoff, continuation);
2106
- return {
2107
- ok: operatingPath.ok === true,
2108
- default_operating_path_ref: operatingPath.default_operating_path_ref || null,
2109
- complete_default_path_ref: operatingPath.default_operating_path_ref
2110
- ? `complete.${operatingPath.default_operating_path_ref}`
2111
- : null,
2112
- complete_default_path_ids: Array.isArray(operatingPath.stable_default_operating_path_ids)
2113
- ? operatingPath.stable_default_operating_path_ids
2114
- : [],
2115
- complete_default_path_carry: operatingPath.default_operating_path_carry || {},
2116
- adapter_complete_by_default: operatingPath.operating_path_ready_by_default === true,
2117
- next_surface: "/v1/proof-center/result-package-handoff/review/complete-default-path"
2118
- };
2119
- }
4492
+ if (req.method === "GET" && url.pathname === "/v1/ecosystem-entry") {
4493
+ sendJson(res, 200, buildEcosystemEntryPack());
4494
+ return;
4495
+ }
2120
4496
 
2121
- function buildPreparedContinuationAdapterCompleteDefaultPathBundle(portableHandoff, continuation) {
2122
- const handoff = portableHandoff && typeof portableHandoff === "object" ? portableHandoff : {};
2123
- const summary = buildPreparedContinuationAdapterCompleteDefaultPathSummary(portableHandoff, continuation);
2124
- return {
2125
- ok: true,
2126
- complete_default_path_summary: summary,
2127
- complete_default_path_template: {
2128
- ok: true,
2129
- complete_default_path_ref: summary.complete_default_path_ref || null,
2130
- target_surface: "/v1/proof-center/result-package-handoff/review/complete-default-path",
2131
- request_template: {
2132
- handoff_bundle: handoff
2133
- },
2134
- stable_boundary_ids: Array.isArray(summary.complete_default_path_ids) ? summary.complete_default_path_ids : []
2135
- }
2136
- };
2137
- }
4497
+ if (req.method === "GET" && url.pathname === "/v1/ecosystem-entry/summary") {
4498
+ sendJson(res, 200, summarizeEcosystemEntryPack());
4499
+ return;
4500
+ }
2138
4501
 
2139
- function buildPreparedContinuationDefaultCompletePathRunSummary(portableHandoff, continuation) {
2140
- const completePath = buildPreparedContinuationAdapterCompleteDefaultPathSummary(portableHandoff, continuation);
2141
- return {
2142
- ok: completePath.ok === true,
2143
- complete_default_path_ref: completePath.complete_default_path_ref || null,
2144
- default_complete_default_path_ref: completePath.complete_default_path_ref
2145
- ? `default.${completePath.complete_default_path_ref}`
2146
- : null,
2147
- stable_default_complete_default_path_ids: Array.isArray(completePath.complete_default_path_ids)
2148
- ? completePath.complete_default_path_ids
2149
- : [],
2150
- default_complete_default_path_carry: completePath.complete_default_path_carry || {},
2151
- complete_default_path_ready: completePath.adapter_complete_by_default === true,
2152
- next_surface: "/v1/proof-center/result-package-handoff/review/complete-default-path-run"
2153
- };
2154
- }
4502
+ if (req.method === "GET" && url.pathname === "/v1/launch-narrative") {
4503
+ sendJson(res, 200, buildLaunchNarrativePack());
4504
+ return;
4505
+ }
2155
4506
 
2156
- function buildInteractionResultPackageContinuationRequestTemplate(portableHandoff, continuation) {
2157
- const handoff = portableHandoff && typeof portableHandoff === "object" ? portableHandoff : {};
2158
- return {
2159
- ok: true,
2160
- continuation_ref: continuation && continuation.continuation_ref ? continuation.continuation_ref : null,
2161
- target_surface: "/v1/proof-center/result-package-handoff/run",
2162
- review_surface: "/v1/proof-center/result-package-handoff/review",
2163
- request_template: {
2164
- handoff_bundle: handoff,
2165
- evidence_refs: handoff.proof_ref ? [handoff.proof_ref] : [],
2166
- options: {
2167
- legacy_identity_material_hex: "<required_for_local_demo_signing>"
2168
- }
2169
- }
2170
- };
2171
- }
4507
+ if (req.method === "GET" && url.pathname === "/v1/launch-narrative/summary") {
4508
+ sendJson(res, 200, summarizeLaunchNarrativePack());
4509
+ return;
4510
+ }
2172
4511
 
2173
- function buildOperationsDashboard(filters) {
2174
- const disputes = listRecords(state.disputes, filters);
2175
- const refunds = listRecords(state.refunds, filters);
2176
- const remediationTickets = listRecords(state.remediationTickets, filters);
2177
- const transactions = listTransactionRecords(filters);
2178
- const receipts = listReceiptRecords(filters);
2179
- const deliveries = listRecords(state.deliveries, filters);
2180
- return summarizeOperationsDashboardPayload({
2181
- open_issues: {
2182
- disputes,
2183
- refunds,
2184
- remediation_tickets: remediationTickets
2185
- },
2186
- execution_exceptions: {
2187
- transactions,
2188
- receipts,
2189
- deliveries,
2190
- remediation_tickets: remediationTickets
2191
- }
2192
- });
2193
- }
4512
+ if (req.method === "GET" && url.pathname === "/v1/outreach-proof") {
4513
+ sendJson(res, 200, buildOutreachProofPack());
4514
+ return;
4515
+ }
2194
4516
 
2195
- function buildAttentionRecords(filters) {
2196
- const dashboard = buildOperationsDashboard(filters);
2197
- const refs = dashboard && dashboard.attention_refs ? dashboard.attention_refs : {};
2198
- const disputes = (Array.isArray(refs.dispute_ids) ? refs.dispute_ids : [])
2199
- .map((id) => summarizeDisputePayload(state.disputes.get(id)))
2200
- .filter((entry) => entry && entry.dispute_id);
2201
- const refunds = (Array.isArray(refs.refund_ids) ? refs.refund_ids : [])
2202
- .map((id) => summarizeRefundPayload(state.refunds.get(id)))
2203
- .filter((entry) => entry && entry.refund_id);
2204
- const remediationTickets = (Array.isArray(refs.ticket_ids) ? refs.ticket_ids : [])
2205
- .map((id) => summarizeRemediationTicketPayload(state.remediationTickets.get(id)))
2206
- .filter((entry) => entry && entry.ticket_id);
2207
- const transactions = (Array.isArray(refs.transaction_ids) ? refs.transaction_ids : [])
2208
- .map((id) => summarizeTransactionPayload(state.transactions.get(id)))
2209
- .filter((entry) => entry && entry.transaction_id);
2210
- const receipts = (Array.isArray(refs.receipt_ids) ? refs.receipt_ids : [])
2211
- .map((id) => summarizeReceiptPayload(state.receipts.get(id)))
2212
- .filter((entry) => entry && entry.receipt_id);
2213
- const deliveries = (Array.isArray(refs.delivery_ids) ? refs.delivery_ids : [])
2214
- .map((id) => summarizeDeliveryPayload(state.deliveries.get(id)))
2215
- .filter((entry) => entry && entry.delivery_id);
2216
- return {
2217
- dashboard,
2218
- disputes,
2219
- refunds,
2220
- remediation_tickets: remediationTickets,
2221
- transactions,
2222
- receipts,
2223
- deliveries
2224
- };
2225
- }
4517
+ if (req.method === "GET" && url.pathname === "/v1/outreach-proof/summary") {
4518
+ sendJson(res, 200, summarizeOutreachProofPack());
4519
+ return;
4520
+ }
2226
4521
 
2227
- function buildOperatorShellSummaryPayload(body) {
2228
- const requestBody = body && typeof body === "object" && !Array.isArray(body) ? body : {};
2229
- const accountId = requestBody.account_id || "acct_demo";
2230
- return buildOperatorShellSummary({
2231
- account_id: accountId,
2232
- operations_dashboard: buildOperationsDashboard({ account_id: accountId }),
2233
- operator_export_pack: buildOperatorExportPack(state, { account_id: accountId }, listRecords),
2234
- economics_operator_view: buildOperatorView(state, accountId),
2235
- economics_operator_dashboard: buildOperatorDashboard(state, accountId),
2236
- entitlement_replenishment_summary: buildEntitlementReplenishmentSummary(state, accountId),
2237
- hosted_checkout_operator_summary: buildHostedCheckoutOperatorSummary(state, accountId),
2238
- coordination_operator_view: buildCoordinationOperatorView(requestBody),
2239
- coordination_admin_view: buildCoordinationAdminView(requestBody)
2240
- });
2241
- }
4522
+ if (req.method === "GET" && url.pathname === "/v1/announcement-pack") {
4523
+ sendJson(res, 200, buildAnnouncementPack());
4524
+ return;
4525
+ }
2242
4526
 
2243
- async function routeRequest(req, res) {
2244
- const url = new URL(req.url, "http://127.0.0.1");
2245
- hydrateQuoteStates(state);
2246
- hydratePendingExecutions(state);
4527
+ if (req.method === "GET" && url.pathname === "/v1/announcement-pack/summary") {
4528
+ sendJson(res, 200, summarizeAnnouncementPack());
4529
+ return;
4530
+ }
2247
4531
 
2248
- if (req.method === "GET" && url.pathname === "/health") {
2249
- sendJson(res, 200, {
2250
- status: "ok",
2251
- service: "xytara",
2252
- readiness: "ready"
2253
- });
4532
+ if (req.method === "GET" && url.pathname === "/v1/release-candidate") {
4533
+ sendJson(res, 200, buildReleaseCandidatePack());
4534
+ return;
4535
+ }
4536
+
4537
+ if (req.method === "GET" && url.pathname === "/v1/release-candidate/summary") {
4538
+ sendJson(res, 200, summarizeReleaseCandidatePack());
4539
+ return;
4540
+ }
4541
+
4542
+ if (req.method === "GET" && url.pathname === "/v1/runtime/durability") {
4543
+ sendJson(res, 200, buildRuntimeDurabilitySummary());
2254
4544
  return;
2255
4545
  }
2256
4546
 
@@ -5367,6 +7657,17 @@ async function routeRequest(req, res) {
5367
7657
  return;
5368
7658
  }
5369
7659
 
7660
+ if (req.method === "GET" && url.pathname.startsWith("/v1/payment-ledger/") && url.pathname.endsWith("/operator-pack")) {
7661
+ const paymentId = getDecodedSuffixId(url.pathname, "/v1/payment-ledger/").replace(/\/operator-pack$/, "");
7662
+ const payment = findPaymentLedgerEntry(paymentId);
7663
+ if (!payment) {
7664
+ sendJson(res, 404, { ok: false, error: "payment_not_found" });
7665
+ return;
7666
+ }
7667
+ sendJson(res, 200, buildPaymentLedgerOperatorPack(payment));
7668
+ return;
7669
+ }
7670
+
5370
7671
  if (req.method === "GET" && url.pathname.startsWith("/v1/payment-ledger/")) {
5371
7672
  const paymentId = getDecodedSuffixId(url.pathname, "/v1/payment-ledger/");
5372
7673
  const paymentLedger = Array.isArray(state.paymentLedger) ? state.paymentLedger : [];
@@ -5387,6 +7688,22 @@ async function routeRequest(req, res) {
5387
7688
  return;
5388
7689
  }
5389
7690
 
7691
+ if (req.method === "GET" && url.pathname === "/v1/settlement/bsv-teranode/readiness") {
7692
+ sendJson(res, 200, buildNativeSettlementReadinessSummary());
7693
+ return;
7694
+ }
7695
+
7696
+ if (req.method === "GET" && url.pathname.startsWith("/v1/settlement/bsv-teranode/") && url.pathname.endsWith("/operator-pack")) {
7697
+ const settlementId = getDecodedSuffixId(url.pathname, "/v1/settlement/bsv-teranode/").replace(/\/operator-pack$/, "");
7698
+ const settlement = getBsvSettlementRecord(state, settlementId);
7699
+ if (!settlement) {
7700
+ sendJson(res, 404, { ok: false, error: "settlement_not_found" });
7701
+ return;
7702
+ }
7703
+ sendJson(res, 200, buildSettlementOperatorPack(settlement));
7704
+ return;
7705
+ }
7706
+
5390
7707
  if (req.method === "GET" && url.pathname.startsWith("/v1/settlement/bsv-teranode/")) {
5391
7708
  const suffix = getDecodedSuffixId(url.pathname, "/v1/settlement/bsv-teranode/");
5392
7709
  if (!suffix.endsWith("/submit") && !suffix.endsWith("/refresh")) {
@@ -5402,9 +7719,9 @@ async function routeRequest(req, res) {
5402
7719
 
5403
7720
  if (req.method === "POST" && url.pathname.startsWith("/v1/settlement/bsv-teranode/") && url.pathname.endsWith("/submit")) {
5404
7721
  const settlementId = getDecodedSuffixId(url.pathname, "/v1/settlement/bsv-teranode/").replace(/\/submit$/, "");
5405
- const result = submitBsvSettlementRecord(state, settlementId);
7722
+ const result = await submitBsvSettlementRecord(state, settlementId);
5406
7723
  if (!result.ok) {
5407
- sendJson(res, 404, { ok: false, error: result.reason });
7724
+ sendJson(res, result.reason === "settlement_not_found" ? 404 : 409, { ok: false, error: result.reason, settlement: result.settlement || null, details: result.details || null });
5408
7725
  return;
5409
7726
  }
5410
7727
  sendJson(res, 200, result);
@@ -5413,7 +7730,7 @@ async function routeRequest(req, res) {
5413
7730
 
5414
7731
  if (req.method === "POST" && url.pathname.startsWith("/v1/settlement/bsv-teranode/") && url.pathname.endsWith("/refresh")) {
5415
7732
  const settlementId = getDecodedSuffixId(url.pathname, "/v1/settlement/bsv-teranode/").replace(/\/refresh$/, "");
5416
- const result = refreshBsvSettlementRecord(state, settlementId);
7733
+ const result = await refreshBsvSettlementRecord(state, settlementId);
5417
7734
  if (!result.ok) {
5418
7735
  sendJson(res, 409, { ok: false, error: result.reason });
5419
7736
  return;
@@ -5554,7 +7871,10 @@ async function routeRequest(req, res) {
5554
7871
  }
5555
7872
 
5556
7873
  if (req.method === "GET" && url.pathname === "/v1/operator-export-pack") {
5557
- sendJson(res, 200, buildOperatorExportPack(state, getQueryFilters(url), listRecords));
7874
+ sendJson(res, 200, buildOperatorExportPack(state, getQueryFilters(url), listRecords, {
7875
+ runtime_durability: buildRuntimeDurabilitySummary(),
7876
+ native_settlement_readiness: buildNativeSettlementReadinessSummary()
7877
+ }));
5558
7878
  return;
5559
7879
  }
5560
7880
 
@@ -5623,18 +7943,40 @@ async function routeRequest(req, res) {
5623
7943
 
5624
7944
  function createServer() {
5625
7945
  return http.createServer((req, res) => {
5626
- routeRequest(req, res).catch((error) => {
5627
- sendJson(res, 500, { ok: false, reason: error.message });
5628
- });
7946
+ if (runtimeStateStore.enabled() && req.method && !["GET", "HEAD", "OPTIONS"].includes(String(req.method).toUpperCase())) {
7947
+ res.on("finish", () => {
7948
+ if (res.statusCode < 500) {
7949
+ runtimeStateStore.markDirty();
7950
+ }
7951
+ });
7952
+ }
7953
+ runtimeStateReady
7954
+ .then(() => routeRequest(req, res))
7955
+ .catch((error) => {
7956
+ sendJson(res, 500, { ok: false, reason: error.message });
7957
+ });
5629
7958
  });
5630
7959
  }
5631
7960
 
5632
7961
  if (require.main === module) {
5633
- const port = Number(process.env.XYTARA_PORT || 4320);
5634
- const host = process.env.XYTARA_HOST || "127.0.0.1";
5635
- const server = createServer();
5636
- server.listen(port, host, () => {
5637
- console.log(`xytara listening on http://${host}:${port}`);
7962
+ (async () => {
7963
+ const port = Number(process.env.XYTARA_PORT || 4320);
7964
+ const host = process.env.XYTARA_HOST || "127.0.0.1";
7965
+ const server = createServer();
7966
+ await runtimeStateReady;
7967
+ runtimeStateStore.start(state);
7968
+ server.listen(port, host, () => {
7969
+ console.log(`xytara listening on http://${host}:${port}`);
7970
+ });
7971
+ const shutdown = async () => {
7972
+ await runtimeStateStore.stop(state);
7973
+ server.close(() => process.exit(0));
7974
+ };
7975
+ process.on("SIGINT", shutdown);
7976
+ process.on("SIGTERM", shutdown);
7977
+ })().catch((error) => {
7978
+ console.error(error);
7979
+ process.exitCode = 1;
5638
7980
  });
5639
7981
  }
5640
7982