crypto-quant-signal-mcp 1.29.0 → 1.30.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 (178) hide show
  1. package/README.md +14 -17
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +211 -39
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/account-handlers.d.ts +15 -0
  6. package/dist/lib/account-handlers.d.ts.map +1 -1
  7. package/dist/lib/account-handlers.js +82 -2
  8. package/dist/lib/account-handlers.js.map +1 -1
  9. package/dist/lib/analytics-snippet.d.ts +34 -0
  10. package/dist/lib/analytics-snippet.d.ts.map +1 -1
  11. package/dist/lib/analytics-snippet.js +38 -1
  12. package/dist/lib/analytics-snippet.js.map +1 -1
  13. package/dist/lib/attribution-sources.d.ts +1 -1
  14. package/dist/lib/attribution-sources.d.ts.map +1 -1
  15. package/dist/lib/attribution-sources.js +8 -0
  16. package/dist/lib/attribution-sources.js.map +1 -1
  17. package/dist/lib/band-outcome-lane.d.ts.map +1 -1
  18. package/dist/lib/band-outcome-lane.js +2 -1
  19. package/dist/lib/band-outcome-lane.js.map +1 -1
  20. package/dist/lib/browser-intent.d.ts +24 -0
  21. package/dist/lib/browser-intent.d.ts.map +1 -0
  22. package/dist/lib/browser-intent.js +104 -0
  23. package/dist/lib/browser-intent.js.map +1 -0
  24. package/dist/lib/carry-tracker-page.js +1 -1
  25. package/dist/lib/carry-tracker-page.js.map +1 -1
  26. package/dist/lib/conversion-copy.d.ts +88 -0
  27. package/dist/lib/conversion-copy.d.ts.map +1 -0
  28. package/dist/lib/conversion-copy.js +114 -0
  29. package/dist/lib/conversion-copy.js.map +1 -0
  30. package/dist/lib/email.d.ts +11 -10
  31. package/dist/lib/email.d.ts.map +1 -1
  32. package/dist/lib/email.js +29 -0
  33. package/dist/lib/email.js.map +1 -1
  34. package/dist/lib/entitlement-api.d.ts.map +1 -1
  35. package/dist/lib/entitlement-api.js +37 -8
  36. package/dist/lib/entitlement-api.js.map +1 -1
  37. package/dist/lib/entitlement-http.d.ts +73 -0
  38. package/dist/lib/entitlement-http.d.ts.map +1 -0
  39. package/dist/lib/entitlement-http.js +52 -0
  40. package/dist/lib/entitlement-http.js.map +1 -0
  41. package/dist/lib/footer-content.d.ts +40 -0
  42. package/dist/lib/footer-content.d.ts.map +1 -1
  43. package/dist/lib/footer-content.js +137 -1
  44. package/dist/lib/footer-content.js.map +1 -1
  45. package/dist/lib/funnel-dashboard-html.d.ts +0 -17
  46. package/dist/lib/funnel-dashboard-html.d.ts.map +1 -1
  47. package/dist/lib/funnel-dashboard-html.js +48 -5
  48. package/dist/lib/funnel-dashboard-html.js.map +1 -1
  49. package/dist/lib/funnel-scoreboard.d.ts +46 -0
  50. package/dist/lib/funnel-scoreboard.d.ts.map +1 -1
  51. package/dist/lib/funnel-scoreboard.js +116 -4
  52. package/dist/lib/funnel-scoreboard.js.map +1 -1
  53. package/dist/lib/funnel-snapshot.d.ts +4 -0
  54. package/dist/lib/funnel-snapshot.d.ts.map +1 -1
  55. package/dist/lib/funnel-snapshot.js +41 -6
  56. package/dist/lib/funnel-snapshot.js.map +1 -1
  57. package/dist/lib/lifecycle/account-usage.d.ts +8 -0
  58. package/dist/lib/lifecycle/account-usage.d.ts.map +1 -0
  59. package/dist/lib/lifecycle/account-usage.js +130 -0
  60. package/dist/lib/lifecycle/account-usage.js.map +1 -0
  61. package/dist/lib/lifecycle/census.d.ts +39 -0
  62. package/dist/lib/lifecycle/census.d.ts.map +1 -0
  63. package/dist/lib/lifecycle/census.js +130 -0
  64. package/dist/lib/lifecycle/census.js.map +1 -0
  65. package/dist/lib/lifecycle/digest.d.ts +28 -0
  66. package/dist/lib/lifecycle/digest.d.ts.map +1 -0
  67. package/dist/lib/lifecycle/digest.js +134 -0
  68. package/dist/lib/lifecycle/digest.js.map +1 -0
  69. package/dist/lib/lifecycle/engine.d.ts +57 -0
  70. package/dist/lib/lifecycle/engine.d.ts.map +1 -0
  71. package/dist/lib/lifecycle/engine.js +235 -0
  72. package/dist/lib/lifecycle/engine.js.map +1 -0
  73. package/dist/lib/lifecycle/identity.d.ts +35 -0
  74. package/dist/lib/lifecycle/identity.d.ts.map +1 -0
  75. package/dist/lib/lifecycle/identity.js +171 -0
  76. package/dist/lib/lifecycle/identity.js.map +1 -0
  77. package/dist/lib/lifecycle/ledger.d.ts +134 -0
  78. package/dist/lib/lifecycle/ledger.d.ts.map +1 -0
  79. package/dist/lib/lifecycle/ledger.js +278 -0
  80. package/dist/lib/lifecycle/ledger.js.map +1 -0
  81. package/dist/lib/lifecycle/meter.d.ts +34 -0
  82. package/dist/lib/lifecycle/meter.d.ts.map +1 -0
  83. package/dist/lib/lifecycle/meter.js +103 -0
  84. package/dist/lib/lifecycle/meter.js.map +1 -0
  85. package/dist/lib/lifecycle/render.d.ts +19 -0
  86. package/dist/lib/lifecycle/render.d.ts.map +1 -0
  87. package/dist/lib/lifecycle/render.js +109 -0
  88. package/dist/lib/lifecycle/render.js.map +1 -0
  89. package/dist/lib/lifecycle/routes.d.ts +36 -0
  90. package/dist/lib/lifecycle/routes.d.ts.map +1 -0
  91. package/dist/lib/lifecycle/routes.js +158 -0
  92. package/dist/lib/lifecycle/routes.js.map +1 -0
  93. package/dist/lib/lifecycle/schema.d.ts +5 -0
  94. package/dist/lib/lifecycle/schema.d.ts.map +1 -0
  95. package/dist/lib/lifecycle/schema.js +85 -0
  96. package/dist/lib/lifecycle/schema.js.map +1 -0
  97. package/dist/lib/lifecycle/steps.d.ts +69 -0
  98. package/dist/lib/lifecycle/steps.d.ts.map +1 -0
  99. package/dist/lib/lifecycle/steps.js +179 -0
  100. package/dist/lib/lifecycle/steps.js.map +1 -0
  101. package/dist/lib/lifecycle/suppression.d.ts +41 -0
  102. package/dist/lib/lifecycle/suppression.d.ts.map +1 -0
  103. package/dist/lib/lifecycle/suppression.js +85 -0
  104. package/dist/lib/lifecycle/suppression.js.map +1 -0
  105. package/dist/lib/lifecycle-copy.d.ts +90 -0
  106. package/dist/lib/lifecycle-copy.d.ts.map +1 -0
  107. package/dist/lib/lifecycle-copy.js +210 -0
  108. package/dist/lib/lifecycle-copy.js.map +1 -0
  109. package/dist/lib/performance-db.d.ts +78 -2
  110. package/dist/lib/performance-db.d.ts.map +1 -1
  111. package/dist/lib/performance-db.js +183 -20
  112. package/dist/lib/performance-db.js.map +1 -1
  113. package/dist/lib/pfe-mae.d.ts +36 -0
  114. package/dist/lib/pfe-mae.d.ts.map +1 -1
  115. package/dist/lib/pfe-mae.js +51 -0
  116. package/dist/lib/pfe-mae.js.map +1 -1
  117. package/dist/lib/plans-public-api.d.ts +87 -2
  118. package/dist/lib/plans-public-api.d.ts.map +1 -1
  119. package/dist/lib/plans-public-api.js +67 -3
  120. package/dist/lib/plans-public-api.js.map +1 -1
  121. package/dist/lib/plans.d.ts +52 -2
  122. package/dist/lib/plans.d.ts.map +1 -1
  123. package/dist/lib/plans.js +59 -3
  124. package/dist/lib/plans.js.map +1 -1
  125. package/dist/lib/public-performance-formatter.d.ts +1 -1
  126. package/dist/lib/public-performance-formatter.d.ts.map +1 -1
  127. package/dist/lib/public-performance-formatter.js +9 -0
  128. package/dist/lib/public-performance-formatter.js.map +1 -1
  129. package/dist/lib/referral-pages.d.ts.map +1 -1
  130. package/dist/lib/referral-pages.js +5 -0
  131. package/dist/lib/referral-pages.js.map +1 -1
  132. package/dist/lib/signup-intent.d.ts +83 -0
  133. package/dist/lib/signup-intent.d.ts.map +1 -0
  134. package/dist/lib/signup-intent.js +97 -0
  135. package/dist/lib/signup-intent.js.map +1 -0
  136. package/dist/lib/site-nav.d.ts.map +1 -1
  137. package/dist/lib/site-nav.js +24 -1
  138. package/dist/lib/site-nav.js.map +1 -1
  139. package/dist/lib/stripe.d.ts +204 -3
  140. package/dist/lib/stripe.d.ts.map +1 -1
  141. package/dist/lib/stripe.js +320 -39
  142. package/dist/lib/stripe.js.map +1 -1
  143. package/dist/lib/subscriber-attribution.d.ts +51 -0
  144. package/dist/lib/subscriber-attribution.d.ts.map +1 -1
  145. package/dist/lib/subscriber-attribution.js +240 -28
  146. package/dist/lib/subscriber-attribution.js.map +1 -1
  147. package/dist/lib/subscriber-status.d.ts +106 -0
  148. package/dist/lib/subscriber-status.d.ts.map +1 -0
  149. package/dist/lib/subscriber-status.js +150 -0
  150. package/dist/lib/subscriber-status.js.map +1 -0
  151. package/dist/lib/tier-warning.d.ts.map +1 -1
  152. package/dist/lib/tier-warning.js +19 -0
  153. package/dist/lib/tier-warning.js.map +1 -1
  154. package/dist/lib/webhook-events.d.ts.map +1 -1
  155. package/dist/lib/webhook-events.js +12 -2
  156. package/dist/lib/webhook-events.js.map +1 -1
  157. package/dist/lib/welcome-page.d.ts.map +1 -1
  158. package/dist/lib/welcome-page.js +30 -10
  159. package/dist/lib/welcome-page.js.map +1 -1
  160. package/dist/resources/signal-performance.d.ts.map +1 -1
  161. package/dist/resources/signal-performance.js +14 -3
  162. package/dist/resources/signal-performance.js.map +1 -1
  163. package/dist/scripts/backfill-outcomes.js +25 -1
  164. package/dist/scripts/backfill-outcomes.js.map +1 -1
  165. package/dist/scripts/lifecycle-dispatch.d.ts +19 -0
  166. package/dist/scripts/lifecycle-dispatch.d.ts.map +1 -0
  167. package/dist/scripts/lifecycle-dispatch.js +242 -0
  168. package/dist/scripts/lifecycle-dispatch.js.map +1 -0
  169. package/dist/scripts/lifecycle-readout.d.ts +27 -0
  170. package/dist/scripts/lifecycle-readout.d.ts.map +1 -0
  171. package/dist/scripts/lifecycle-readout.js +178 -0
  172. package/dist/scripts/lifecycle-readout.js.map +1 -0
  173. package/dist/scripts/product-updates-digest.d.ts +2 -0
  174. package/dist/scripts/product-updates-digest.d.ts.map +1 -0
  175. package/dist/scripts/product-updates-digest.js +109 -0
  176. package/dist/scripts/product-updates-digest.js.map +1 -0
  177. package/package.json +4 -2
  178. package/server.json +2 -2
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  </p>
12
12
 
13
13
  <p align="center">
14
- <span data-tr-field="pfe_wr">91.6%</span> PFE win rate across <span data-tr-field="total_calls">584,546</span>+ verified calls. Merkle-verified on Base L2. Don't trust — verify. <!-- SNAPSHOT-LINE -->
14
+ <span data-tr-field="pfe_wr">91.4%</span> PFE win rate across <span data-tr-field="total_calls">646,779</span>+ verified calls. Merkle-verified on Base L2. Don't trust — verify. <!-- SNAPSHOT-LINE -->
15
15
  </p>
16
16
 
17
17
  <p align="center">
@@ -93,7 +93,7 @@ Under the hood, a self-tuning model fuses momentum, trend structure, derivatives
93
93
  { "coin": "SOL", "timeframe": "15m", "confidence": 73 }
94
94
  ],
95
95
  "_algovault": {
96
- "version": "1.29.0",
96
+ "version": "1.30.0",
97
97
  "tool": "get_trade_call",
98
98
  "compatible_with": ["crypto-quant-risk-mcp", "crypto-quant-backtest-mcp"]
99
99
  }
@@ -111,7 +111,7 @@ The `_algovault` block makes outputs composable: downstream risk and backtest to
111
111
  scripts/snapshot-landing-data.mjs at npm-publish + Hetzner-deploy. Do NOT hand-edit the
112
112
  numbers; edit "What's new" by hand. Wired by OPS-NPM-README-SINGLE-SOT-W1 (2026-05-31). -->
113
113
  <p align="center">
114
- <strong><span data-tr-field="pfe_wr">91.6%</span> PFE Win Rate</strong> · <strong><span data-tr-field="total_calls">584,546</span> trade calls</strong> · <strong><span data-tr-field="merkle_batches">147</span> on-chain batches</strong> <!-- SNAPSHOT-LINE -->
114
+ <strong><span data-tr-field="pfe_wr">91.4%</span> PFE Win Rate</strong> · <strong><span data-tr-field="total_calls">646,779</span> trade calls</strong> · <strong><span data-tr-field="merkle_batches">153</span> on-chain batches</strong> <!-- SNAPSHOT-LINE -->
115
115
  </p>
116
116
 
117
117
  <p align="center">
@@ -255,15 +255,19 @@ Pro 6-month is currently $129 — limited-time pricing; subscribe now and renewa
255
255
 
256
256
  ---
257
257
 
258
- ## What's new in v1.29.0
258
+ ## What's new in v1.30.0
259
259
 
260
- - **📊 The track record is a tool now, not only a resource.** `get_track_record` returns the same verified aggregate as `performance://signal-performance`, so a harness that bridges tools but not resources can read it. Compact by default; `include` opens the per-asset, per-venue and recent-call sections.
261
- - **✋ HOLD means HOLD.** When a book is not currently trading, the call returns HOLD instead of a direction, and the reasoning says so and says when it resumes. Previously a still book read as a flat market.
262
- - **📡 A degraded read looks degraded.** `get_market_regime` no longer reports neutral cross-venue funding when the upstream request was refused — a refused read is now distinguishable from a genuine neutral one.
263
- - **🔓 Allowances are machine-readable.** `GET /api/plans/public` returns the current free and paid call limits, unauthenticated, so you can stop hard-coding them.
264
- - **🧩 [DeepSeek Harness](https://algovault.com/integrations/deepseek-harness) has a guide.** Plus `/.well-known/security.txt` and `/.well-known/api-catalog`, both of which used to 404.
260
+ - **🔑 Your key, one click away.** Every tool response that carries an auth block now returns `claim_url` and `claim_hint` in the `_algovault` envelope — a direct link to keep the key you are already using, and a heads-up before you reach the cap.
261
+ - **💵 Six-month pricing is machine-readable.** `GET /api/plans/public` gains `price_usd_6month` on every tier, so a client can render prepay pricing instead of hardcoding it.
262
+ - **🤝 Enterprise is quoted, not published.** The plans endpoint now returns `null` for Enterprise price and limits rather than a fixed figure. No key was removed — the values are null.
265
263
 
266
- **Upgrading from v1.28.x** — one breaking change: `BITMART` is no longer a valid `exchange` value and now returns `-32602`. Check any hard-coded `exchange` value against the published enum. `get_track_record` is new; nothing was renamed or removed from the tool list.
264
+ **Upgrading from v1.29.x** — nothing breaking, but one value changed: if you rendered an Enterprise price from `GET /api/plans/public`, it is now `null` and Enterprise is quoted directly. Every tier key is still present. Two response fields were added, no tool was added or renamed.
265
+
266
+ ### v1.29.x highlights (recap)
267
+
268
+ - **📊 The track record is a tool, not only a resource.** `get_track_record` returns the same verified aggregate as `performance://signal-performance`, so a harness that bridges tools but not resources can read it.
269
+ - **✋ HOLD means HOLD.** When a book is not currently trading, the call returns HOLD instead of a direction, and the reasoning says so and says when it resumes.
270
+ - **🔓 Allowances are machine-readable.** `GET /api/plans/public` returns the current free and paid call limits, unauthenticated.
267
271
 
268
272
  ### v1.28.x highlights (recap)
269
273
 
@@ -271,13 +275,6 @@ Pro 6-month is currently $129 — limited-time pricing; subscribe now and renewa
271
275
  - **📘 Two parameters that were always there, now documented.** `assetClass` on the trade-call tools and `minLiquidityUsd` on `scan_trade_calls`, both projected from the live schema so the docs cannot drift from the server.
272
276
  - **🤝 Pair with [Binance Agent OS](https://algovault.com/integrations/binance-agent-os).** One MCP client, two servers: AlgoVault returns the verdict, Binance Agent OS executes it. OAuth at connect time — no API keys on your machine, and trading confined to a sub-account you fund yourself.
273
277
 
274
- ### v1.27.x highlights (recap)
275
-
276
- - **🧮 Counted per call.** Your allowance covers every call the engine answers, on both the MCP and HTTP rails.
277
- - **📶 A new call ladder.** Free: 200/month plus 100/day. Starter: 10,000/month plus 1,000/day. Pro: 100,000/month plus 10,000/day.
278
- - **💳 6-month prepay replaces annual.** Starter is **$39.90** (~$6.65/mo, 33% off monthly) and Pro is **$129** (~$21.50/mo, 56% off monthly). Pick it at [signup](https://api.algovault.com/signup) with `?interval=6month`. Enterprise remains contact-us.
279
- - **⏱️ Daily limits say when they reset.** Hit a daily cap and the refusal tells you the hours remaining, not a monthly figure.
280
-
281
278
  > **Refresh your MCP client to pick up this release.** MCP clients cache `tools/list` at session start — Claude.ai/Desktop: toggle the connector off+on; Cursor/Cline: restart the MCP server connection.
282
279
 
283
280
  ---
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,SAAS,EAAuC,MAAM,yCAAyC,CAAC;AAIzG,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,YAAY,CAAC;AA+U1D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,EAAE,MAAM,GACb,MAAM,CAOR;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,OAAO,SAAS,EAAE,OAAO,EAC9B,GAAG,EAAE,OAAO,SAAS,EAAE,QAAQ,EAC/B,UAAU,EAAE,MAAM,SAAS,GAC1B,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,OAAO,SAAS,EAAE,OAAO,EAC9B,GAAG,EAAE,OAAO,SAAS,EAAE,QAAQ,EAC/B,OAAO,EAAE,WAAW,GACnB,OAAO,CAQT;AA+8JD,wBAAgB,mBAAmB,cAElC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,SAAS,EAAuC,MAAM,yCAAyC,CAAC;AAIzG,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,YAAY,CAAC;AAoW1D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,EAAE,MAAM,GACb,MAAM,CAOR;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,OAAO,SAAS,EAAE,OAAO,EAC9B,GAAG,EAAE,OAAO,SAAS,EAAE,QAAQ,EAC/B,UAAU,EAAE,MAAM,SAAS,GAC1B,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,OAAO,SAAS,EAAE,OAAO,EAC9B,GAAG,EAAE,OAAO,SAAS,EAAE,QAAQ,EAC/B,OAAO,EAAE,WAAW,GACnB,OAAO,CAQT;AA+mKD,wBAAgB,mBAAmB,cAElC"}
package/dist/index.js CHANGED
@@ -125,6 +125,15 @@ const pql_js_1 = require("./lib/pql.js");
125
125
  const track_token_js_1 = require("./lib/track-token.js");
126
126
  const tools_list_event_js_1 = require("./lib/tools-list-event.js");
127
127
  const traffic_classifier_js_1 = require("./lib/traffic-classifier.js");
128
+ // FUNNEL-TRUTH-AND-PAID-ATTRIBUTION-W1 CH1 — the navigation-intent verdict for public CTA routes.
129
+ // It PROJECTS from `classifyTraffic` above (never a second `isbot` call site) and adds the
130
+ // Sec-Fetch / Accept evidence that classifier has no input for.
131
+ const browser_intent_js_1 = require("./lib/browser-intent.js");
132
+ // FUNNEL-TRUTH-AND-PAID-ATTRIBUTION-W1 CH2: the ONE analytics region, for the two public pages
133
+ // rendered inline in this file — `/track-record` (apex-proxied, the landing's #2 CTA destination,
134
+ // 0 views in Plausible while the scoreboard counted 175 server-side in 90d) and the bare `/signup`
135
+ // plan picker (api-origin, also the body the CH1 bot branch serves).
136
+ const analytics_snippet_js_1 = require("./lib/analytics-snippet.js");
128
137
  const attribution_sources_js_1 = require("./lib/attribution-sources.js");
129
138
  const stripe_js_1 = require("./lib/stripe.js");
130
139
  const errors_js_1 = require("./lib/errors.js");
@@ -136,6 +145,7 @@ const upstream_weight_budget_js_1 = require("./lib/upstream-weight-budget.js");
136
145
  const venue_store_js_1 = require("./lib/venue-store.js");
137
146
  const bot_auth_js_1 = require("./lib/bot-auth.js");
138
147
  // PRICING-BOT-DELIVERY-METERING-W1 CH3: /api/entitlement/* route registrar.
148
+ const entitlement_http_js_1 = require("./lib/entitlement-http.js");
139
149
  const entitlement_api_js_1 = require("./lib/entitlement-api.js");
140
150
  const ops_build_api_js_1 = require("./lib/ops-build-api.js");
141
151
  // GROWTH-TG-QUOTA-PARITY-W1 CH1: GET /api/plans/public — the plan-ladder read surface.
@@ -238,6 +248,9 @@ const contact_page_js_1 = require("./lib/contact-page.js");
238
248
  const carry_tracker_public_js_1 = require("./lib/carry-tracker-public.js");
239
249
  const carry_tracker_page_js_1 = require("./lib/carry-tracker-page.js");
240
250
  const account_handlers_js_1 = require("./lib/account-handlers.js");
251
+ // IDENTITY-LIFECYCLE-W3 CH1 — the lifecycle email surfaces (unsubscribe + Resend inbound).
252
+ const routes_js_1 = require("./lib/lifecycle/routes.js");
253
+ const census_js_1 = require("./lib/lifecycle/census.js");
241
254
  const site_nav_js_1 = require("./lib/site-nav.js");
242
255
  const oi_ranking_js_1 = require("./lib/oi-ranking.js");
243
256
  /** Timing-safe string comparison to prevent side-channel attacks on admin key. */
@@ -1495,6 +1508,26 @@ async function startHttp() {
1495
1508
  // /dashboard. New endpoint: /dashboard/api/skills-analytics (JSON, admin-only).
1496
1509
  // The X-AlgoVault-Skill-Slug header interceptor in app.all('/mcp', ...) is
1497
1510
  // UNTOUCHED — slug logging continues; only the public surface was removed.
1511
+ // ── IDENTITY-LIFECYCLE-W3 CH1 — Resend inbound (raw body required, same reason as Stripe:
1512
+ // the Svix signature is computed over the exact bytes, so express.json() must not have
1513
+ // re-serialised them first). Inherits the /webhooks 20/min limiter mounted above; Resend
1514
+ // retries a non-2xx, so a limiter rejection costs a delay, never an event.
1515
+ // `type: () => true` accepts every content-type, and is a FUNCTION rather than the wildcard
1516
+ // STRING for a measured reason: the literal form contains the two characters that close a
1517
+ // block comment, and scripts/lib/dark-artifacts.mjs strips line comments BEFORE block comments
1518
+ // with a lazy `/\*[\s\S]*?\*/`. That literal therefore terminated an earlier JSDoc block
1519
+ // early and swallowed a large span of this file, zeroing the reference counts for 17 unrelated
1520
+ // exports (contact-leads, referral, turnstile) and turning the dark-artifact gate RED on
1521
+ // symbols this wave never touched. Bisected 2026-09-08: pristine origin/main n=0, +this file
1522
+ // n=17. A wildcard content-type is worth having — Resend's signature is computed over the raw
1523
+ // bytes and a type mismatch would silently hand the verifier an empty body — so the fix is the
1524
+ // function form, not a narrower type.
1525
+ app.post('/webhooks/resend', express.raw({ type: () => true }), routes_js_1.resendWebhookHandler);
1526
+ // ── IDENTITY-LIFECYCLE-W3 CH1 — RFC 8058 one-click unsubscribe + its human page.
1527
+ // GET renders a one-button form and MUTATES NOTHING (mail scanners follow every link in a
1528
+ // message); POST is the one-click endpoint named by the List-Unsubscribe header.
1529
+ app.get('/email/unsubscribe/:token', routes_js_1.unsubscribeGetHandler);
1530
+ app.post('/email/unsubscribe/:token', express.urlencoded({ extended: false }), routes_js_1.unsubscribePostHandler);
1498
1531
  // ── Stripe Webhook (raw body required — must be before express.json()) ──
1499
1532
  app.post('/webhooks/stripe', express.raw({ type: 'application/json' }), async (req, res) => {
1500
1533
  const sig = req.headers['stripe-signature'];
@@ -1608,6 +1641,67 @@ async function startHttp() {
1608
1641
  }
1609
1642
  break;
1610
1643
  }
1644
+ case 'checkout.session.expired': {
1645
+ // FUNNEL-TRUTH-AND-PAID-ATTRIBUTION-W1 CH1 R4 — abandoned checkout as a REAL stage.
1646
+ //
1647
+ // A Checkout Session Stripe never completes expires ~24h after creation. Until now
1648
+ // that produced nothing: a start with no finish left no trace, so "how many people
1649
+ // reached Stripe and did not pay?" was unanswerable and the funnel jumped straight
1650
+ // from intent to paid. This is the only event that answers it.
1651
+ //
1652
+ // It arrives on the EXISTING destination `we_1TKJVZKGleoEgU2HdSvmIUIl`
1653
+ // (`/webhooks/stripe`, same `STRIPE_WEBHOOK_SECRET`) — verified via the Stripe API at
1654
+ // Step 0: ONE destination, 10 enabled events, this one among them. Adding a SECOND
1655
+ // destination would carry its OWN signing secret and could never verify here.
1656
+ //
1657
+ // EXPECT A BURST on day one. Every crawler-minted Session created before CH1 R2 shipped
1658
+ // expires within 24h of this deploy, and those Sessions predate the metadata widening,
1659
+ // so their `metadata.classification` is absent — recorded as `unknown`, never guessed
1660
+ // at as `bot`. It IS a bot in most cases, and writing that down would be a fabrication.
1661
+ //
1662
+ // NEVER reads `customer_details.email`. The account is Malaysian, so Stripe's
1663
+ // `consent_collection.promotions` (US-only) does not exist for us — there is no consent
1664
+ // path for an abandoned-cart email, and storing an address we may never contact is
1665
+ // collection without purpose.
1666
+ // Parsing lives in `summarizeCheckoutExpired` (stripe.ts) so it is unit-testable — the
1667
+ // same split `checkout.session.completed` above already uses. This case keeps only the
1668
+ // idempotency claim and the write.
1669
+ const expired = (0, stripe_js_1.summarizeCheckoutExpired)(event);
1670
+ if (!expired) {
1671
+ console.warn(`Stripe webhook: checkout.session.expired with unparseable session payload (event ${event.id})`);
1672
+ break;
1673
+ }
1674
+ // Idempotency BEFORE the side-effect (CLAUDE.md's external-webhook rule). Keyed on the
1675
+ // EVENT id like every sibling case: Stripe delivers at-least-once, and a redelivery
1676
+ // would otherwise double-count one abandonment into a published stage.
1677
+ const isNewExpiry = await (0, stripe_events_store_js_1.tryClaimEvent)({
1678
+ event_id: event.id,
1679
+ event_type: event.type,
1680
+ session_id: expired.sessionId,
1681
+ customer_email: null,
1682
+ metadata: { source: 'checkout.session.expired' },
1683
+ });
1684
+ if (!isNewExpiry) {
1685
+ console.log(`Stripe webhook: duplicate checkout.session.expired (event ${event.id}) — already processed`);
1686
+ return res.json({ received: true, status: 'duplicate' });
1687
+ }
1688
+ try {
1689
+ const { recordFunnelEvent } = await import('./lib/performance-db.js');
1690
+ recordFunnelEvent({
1691
+ eventType: 'checkout_abandoned',
1692
+ sessionId: expired.sessionId,
1693
+ licenseTier: expired.tier,
1694
+ meta: { ...expired.metadata, session_id: expired.sessionId, classification: expired.classification },
1695
+ });
1696
+ console.log(`Stripe webhook: checkout.session.expired recorded — session=${expired.sessionId} classification=${expired.classification}`);
1697
+ }
1698
+ catch (expErr) {
1699
+ // Don't rethrow — the event-id is already claimed, so Stripe will not retry and a
1700
+ // non-2xx would only make it retry an event we will never re-record.
1701
+ console.error('Stripe webhook: checkout_abandoned write failed (fail-open):', expErr instanceof Error ? expErr.message : expErr);
1702
+ }
1703
+ break;
1704
+ }
1611
1705
  case 'invoice.paid': {
1612
1706
  // REFERRAL-LIGHT-W1 (C3): accrue 30% referral commission (idempotent on
1613
1707
  // the event id; auto Stripe-credit or usdc_pending). Fail-open internally.
@@ -1803,6 +1897,15 @@ async function startHttp() {
1803
1897
  // Derive a session-unique client_reference_id for downstream attribution
1804
1898
  // join even when UTM tags are absent (e.g. direct /signup typing).
1805
1899
  const clientReferenceId = `${utmSource ?? 'direct'}:${Date.now()}:${Math.random().toString(36).slice(2, 8)}`;
1900
+ // FUNNEL-TRUTH-AND-PAID-ATTRIBUTION-W1 CH1 R1/R2 — classify the request ONCE, here, and let
1901
+ // every writer below project from that one value (single-derivation LAW). PURE and
1902
+ // synchronous: no I/O, no await, so it cannot add latency to the revenue path.
1903
+ //
1904
+ // `classifyBrowserIntent` PROJECTS the UA verdict from the canonical `classifyTraffic()` and
1905
+ // adds the fetch-metadata evidence that classifier has no input for. It is imported
1906
+ // statically because it is a pure leaf with no DB and no network — a lazy import here would
1907
+ // put a dynamic `import()` on the redirect path for no benefit.
1908
+ const intent = (0, browser_intent_js_1.classifyBrowserIntent)(req.headers);
1806
1909
  // ACTIVATION-FUNNEL-AUDIT-W1 (2026-05-28) + LANDING-CONVERSION-TRUST-W1 (2026-06-19):
1807
1910
  // capture the CTA click BEFORE the plan-gate so keyless / plan-less landing clicks are
1808
1911
  // measured too (the early-return on an absent/invalid plan previously skipped them).
@@ -1823,6 +1926,12 @@ async function startHttp() {
1823
1926
  upgrade_from: upgradeFrom,
1824
1927
  utm_source: utmSource ?? null,
1825
1928
  utm_campaign: utmCampaign ?? null,
1929
+ // FUNNEL-TRUTH-AND-PAID-ATTRIBUTION-W1 CH1: additive TAG, never a filter. The CTA
1930
+ // stage keeps counting every click exactly as before (Data Integrity — events are
1931
+ // tagged, never dropped); this only makes the same rows separable later, the way
1932
+ // `mcp_connect` was tagged by OPS-ACTIVATION-LEAK-FIX-W1.
1933
+ classification: intent.cls,
1934
+ ua_class: intent.uaClass,
1826
1935
  },
1827
1936
  });
1828
1937
  }
@@ -1894,49 +2003,91 @@ async function startHttp() {
1894
2003
  return res.redirect(302, `/signup?${q.toString()}`);
1895
2004
  }
1896
2005
  const interval = req.query.interval === '6month' ? '6month' : 'month';
2006
+ const landingPath = typeof req.query.landing_path === 'string'
2007
+ ? req.query.landing_path
2008
+ : req.headers['referer'] ?? null;
2009
+ // SUBSCRIBER-ATTRIBUTION-SPINE-W1 (C1): persist the click attribution so
2010
+ // the conversion webhook (C2) can JOIN to it by client_reference_id —
2011
+ // closing the blind spot SUBSCRIBER-ATTRIBUTION-DIAGNOSIS-W1 hit. Lazy-
2012
+ // import + fire-and-forget + fail-open (mirrors the recordFunnelEvent arm
2013
+ // above): a capture error MUST NOT affect the 303 redirect, its latency,
2014
+ // or the client_reference_id value. ip_hash via the existing hashIp helper
2015
+ // (the requestContext ALS is only entered for /mcp, so derive the IP from
2016
+ // the proxy headers like the /mcp handler does).
2017
+ //
2018
+ // FUNNEL-TRUTH-AND-PAID-ATTRIBUTION-W1 CH1: hoisted into ONE closure because there are now
2019
+ // TWO exits that must record — the 303 and the new bot 200 — and two copies of a writer is
2020
+ // how the two drift. It is still CALLED from each exit rather than before the branch, and
2021
+ // that ordering is deliberate: `funnel-snapshot.ts` documents stage 8 as "distinct Stripe
2022
+ // Checkout Sessions CREATED", a meaning that holds only while the row is written after a
2023
+ // Session exists. The bot arm creates no Session by construction, so recording it there is
2024
+ // not an exception to that rule — those rows carry `classification='bot'` and are excluded
2025
+ // from the human stage by the same predicate CH3 reads.
2026
+ const captureAttribution = async () => {
2027
+ try {
2028
+ // OPS-MCP-DEFENSE-IN-DEPTH-W1 R2: derive from req.ip (trust proxy=1) via the
2029
+ // shared clientIp helper — byte-identical to the prior raw-XFF leftmost parse
2030
+ // under the deployed Caddy replace-mode topology, robust to a proxy reconfig.
2031
+ const ip = (0, client_ip_js_1.clientIp)(req);
2032
+ const { recordSignupAttribution } = await import('./lib/subscriber-attribution.js');
2033
+ recordSignupAttribution({
2034
+ clientReferenceId,
2035
+ utmSource: utmSource ?? null,
2036
+ utmMedium: typeof req.query.utm_medium === 'string' ? req.query.utm_medium : null,
2037
+ utmCampaign: utmCampaign ?? null,
2038
+ referrer: req.headers['referer'] ?? null,
2039
+ landingPath,
2040
+ tierRequested: plan,
2041
+ ipHash: ip ? (0, analytics_js_1.hashIp)(ip) : null,
2042
+ userAgent: req.headers['user-agent'] ?? null,
2043
+ classification: intent.cls,
2044
+ uaClass: intent.uaClass,
2045
+ });
2046
+ }
2047
+ catch (err) {
2048
+ console.warn('[/signup attribution] capture failed (fail-open):', err instanceof Error ? err.message : err);
2049
+ }
2050
+ };
2051
+ // FUNNEL-TRUTH-AND-PAID-ATTRIBUTION-W1 CH1 R2 — a positively-identified bot gets the plan
2052
+ // page, never a Checkout Session.
2053
+ //
2054
+ // The body is the EXISTING bare-`/signup` plan picker (`getSignupPageHtml()`), byte-for-byte
2055
+ // — no new copy, and a crawler still indexes a complete, correct, 200 page rather than
2056
+ // anything that reads as broken. What it does NOT get is a live `cs_live_` object: before
2057
+ // this branch, anything able to issue a GET could mint one, and 42.2 % of the 268 rows in
2058
+ // the 28d window to 2026-09-05 were `isbot`-flagged.
2059
+ //
2060
+ // `Cache-Control: no-store` because this response is CONDITIONAL on request headers a cache
2061
+ // does not key on. Without it a shared cache could serve the plan page to the human whose
2062
+ // request would have redirected — turning a measurement fix into a revenue outage.
2063
+ //
2064
+ // A misclassified human self-heals in one click: the plan page's buttons issue a real
2065
+ // navigation (`text/html` Accept + `Sec-Fetch-Mode: navigate`), which classifies as
2066
+ // `browser` and 303s. `unknown` never reaches here — it is fail-open by design.
2067
+ if (intent.cls === 'bot') {
2068
+ await captureAttribution();
2069
+ res.setHeader('Cache-Control', 'no-store');
2070
+ return res.status(200).send(getSignupPageHtml());
2071
+ }
1897
2072
  const url = await (0, stripe_js_1.createCheckoutSession)(plan, baseUrl, {
1898
2073
  utmSource,
1899
2074
  utmCampaign,
1900
2075
  clientReferenceId,
1901
2076
  refCode,
1902
2077
  interval,
2078
+ // CH1 R3 — the Stripe-side attribution copy. See `buildCheckoutMetadata` for the four
2079
+ // fields that were specified, measured fictional, and deliberately NOT added.
2080
+ utmMedium: typeof req.query.utm_medium === 'string' ? req.query.utm_medium : undefined,
2081
+ upgradeFrom,
2082
+ classification: intent.cls,
2083
+ landingPath: landingPath ?? undefined,
1903
2084
  });
1904
2085
  // A configured plan with an unconfigured interval lands here too (e.g. annual requested
1905
2086
  // before the Price exists in Stripe) — same operator-actionable failure, not a silent
1906
2087
  // downgrade to a price the caller did not choose.
1907
2088
  if (!url)
1908
2089
  return res.status(500).send('Stripe not configured or missing price IDs');
1909
- // SUBSCRIBER-ATTRIBUTION-SPINE-W1 (C1): persist the click attribution so
1910
- // the conversion webhook (C2) can JOIN to it by client_reference_id —
1911
- // closing the blind spot SUBSCRIBER-ATTRIBUTION-DIAGNOSIS-W1 hit. Lazy-
1912
- // import + fire-and-forget + fail-open (mirrors the recordFunnelEvent arm
1913
- // above): a capture error MUST NOT affect the 303 redirect, its latency,
1914
- // or the client_reference_id value. ip_hash via the existing hashIp helper
1915
- // (the requestContext ALS is only entered for /mcp, so derive the IP from
1916
- // the proxy headers like the /mcp handler does).
1917
- try {
1918
- // OPS-MCP-DEFENSE-IN-DEPTH-W1 R2: derive from req.ip (trust proxy=1) via the
1919
- // shared clientIp helper — byte-identical to the prior raw-XFF leftmost parse
1920
- // under the deployed Caddy replace-mode topology, robust to a proxy reconfig.
1921
- const ip = (0, client_ip_js_1.clientIp)(req);
1922
- const { recordSignupAttribution } = await import('./lib/subscriber-attribution.js');
1923
- recordSignupAttribution({
1924
- clientReferenceId,
1925
- utmSource: utmSource ?? null,
1926
- utmMedium: typeof req.query.utm_medium === 'string' ? req.query.utm_medium : null,
1927
- utmCampaign: utmCampaign ?? null,
1928
- referrer: req.headers['referer'] ?? null,
1929
- landingPath: typeof req.query.landing_path === 'string'
1930
- ? req.query.landing_path
1931
- : req.headers['referer'] ?? null,
1932
- tierRequested: plan,
1933
- ipHash: ip ? (0, analytics_js_1.hashIp)(ip) : null,
1934
- userAgent: req.headers['user-agent'] ?? null,
1935
- });
1936
- }
1937
- catch (err) {
1938
- console.warn('[/signup attribution] capture failed (fail-open):', err instanceof Error ? err.message : err);
1939
- }
2090
+ await captureAttribution();
1940
2091
  res.redirect(303, url);
1941
2092
  }
1942
2093
  catch (err) {
@@ -1990,6 +2141,10 @@ async function startHttp() {
1990
2141
  app.post('/account/recover-key', recoverKeyLimiter, express.urlencoded({ extended: false }), account_handlers_js_1.accountRecoverKeyHandler);
1991
2142
  // REFERRAL-LIGHT-W1 (C4): referral dashboard (paste key) + public terms page.
1992
2143
  app.post('/account/referrals', express.urlencoded({ extended: false }), account_handlers_js_1.accountReferralsHandler);
2144
+ // IDENTITY-LIFECYCLE-W3 CH3 — usage + the lifecycle-email preference. Same paste-key shape as
2145
+ // every other panel here: /account has no user session, only the admin cookie exists.
2146
+ app.post('/account/usage', express.urlencoded({ extended: false }), account_handlers_js_1.accountUsageHandler);
2147
+ app.post('/account/usage/preference', express.urlencoded({ extended: false }), account_handlers_js_1.accountUsagePreferenceHandler);
1993
2148
  // REFERRAL-PAYOUT-OPS-W1 (C1): save/clear the referrer's Base USDC payout address.
1994
2149
  app.post('/account/referrals/payout-address', express.urlencoded({ extended: false }), account_handlers_js_1.accountPayoutAddressHandler);
1995
2150
  app.get('/referral-terms', async (_req, res) => {
@@ -3619,15 +3774,15 @@ async function startHttp() {
3619
3774
  if (!apiKey) {
3620
3775
  return res.status(400).json({ error: 'api_key_required' });
3621
3776
  }
3777
+ // OPS-VALIDATE-KEY-INDETERMINATE-W1 CH2 — ONE projection, shared with /api/entitlement/*.
3778
+ // The `if (!valid || !tier) 404` this replaces answered a bare 404 for FOUR different facts,
3779
+ // including a Stripe outage that `validateApiKey` had already flagged `indeterminate`.
3622
3780
  const result = await (0, stripe_js_1.validateApiKey)(apiKey);
3623
- if (!result.valid || !result.tier) {
3624
- return res.status(404).json({ valid: false });
3625
- }
3626
- return res.json({
3627
- valid: true,
3628
- customer_id: result.customerId || null,
3629
- tier: result.tier,
3630
- });
3781
+ const p = (0, entitlement_http_js_1.projectEntitlementHttp)(result);
3782
+ // `customer_id: null` is preserved for the ENTITLED shape the bot has always parsed.
3783
+ if (p.state === 'ENTITLED' && p.body.customer_id === undefined)
3784
+ p.body.customer_id = null;
3785
+ return res.status(p.status).json(p.body);
3631
3786
  });
3632
3787
  // PRICING-BOT-DELIVERY-METERING-W1 CH3: the entitlement routes register HERE, beside
3633
3788
  // validate-key and behind the same internal-key auth. Their bodies live in
@@ -3729,6 +3884,16 @@ async function startHttp() {
3729
3884
  // once-per-session `mcp_connect` emit — byte-identical for tier!=='internal', so
3730
3885
  // `funnel_events.meta_json.is_automated` / `by_authenticity` do NOT drift. Computed
3731
3886
  // for every request; only consumed on POST tool-calls (harmless on GET/handshake).
3887
+ // IDENTITY-LIFECYCLE-W3 CH4 R2 — the elicitation census, read off the ALREADY-PARSED
3888
+ // JSON-RPC envelope. It touches no MCP semantics: it does not answer `initialize`, does not
3889
+ // implement elicitation, and does not change a byte of what the SDK returns. Fire-and-forget
3890
+ // and internally guarded, because a measurement must never be able to fail a tool call.
3891
+ try {
3892
+ const cap = (0, census_js_1.capabilityFromInitialize)(req.body);
3893
+ if (cap)
3894
+ (0, census_js_1.recordHandshake)(sessionId, cap);
3895
+ }
3896
+ catch { /* telemetry only */ }
3732
3897
  const requestAuthenticity = (0, traffic_classifier_js_1.classifyTraffic)({
3733
3898
  ua: req.headers['user-agent'],
3734
3899
  ip: (0, client_ip_js_1.clientIp)(req),
@@ -4407,6 +4572,7 @@ function getPerformanceDashboardHtml(opts) {
4407
4572
  <meta charset="utf-8">
4408
4573
  <meta name="viewport" content="width=device-width, initial-scale=1">
4409
4574
  <title>Live Track Record — AlgoVault Labs</title>
4575
+ ${(0, analytics_snippet_js_1.renderAnalyticsRegion)()}
4410
4576
  <meta name="description" content="AlgoVault's live trade-call track record. Every signal is Merkle-anchored on Base L2 for independent on-chain verification. Don't trust; verify.">
4411
4577
  <link rel="canonical" href="https://algovault.com/track-record">
4412
4578
  <!-- BEGIN: AlgoVault canonical design loader (DESIGN-W3 / C4, cross-origin) -->
@@ -5257,6 +5423,11 @@ setInterval(updateNextBatchCountdown, 60000);
5257
5423
  </div>
5258
5424
  </main>
5259
5425
  <!-- FOOTER-UNIFY-W1: canonical brand footer from the single SoT (src/lib/footer-content.ts renderBrandFooter). Was the inline DESIGN-W11 literal + PH-BADGE-COMPACT-W1 badge. -->
5426
+ <!-- CONVERSION-SURFACES-W2 CH3: the band renders on the PUBLIC /track-record only. This one
5427
+ function also serves the operator dashboard, which never sees a visitor — passing the
5428
+ operator route lets renderConversionBand's own exclusion list decide, so the rule stays in
5429
+ one place instead of becoming a branch here that the exclusion list cannot see. -->
5430
+ ${(0, footer_content_js_1.renderConversionBand)({ route: opts?.isPublic ? '/track-record' : '/dashboard' })}
5260
5431
  ${(0, footer_content_js_1.renderBrandFooter)('desktop')}
5261
5432
  </body>
5262
5433
  </html>`;
@@ -5275,6 +5446,7 @@ function getSignupPageHtml() {
5275
5446
  <meta charset="utf-8">
5276
5447
  <meta name="viewport" content="width=device-width, initial-scale=1">
5277
5448
  <title>AlgoVault — Subscribe</title>
5449
+ ${(0, analytics_snippet_js_1.renderAnalyticsRegion)()}
5278
5450
  <!-- BEGIN: AlgoVault canonical design loader (DESIGN-W2 / D2-C, cross-origin) -->
5279
5451
  <link rel="preconnect" href="https://fonts.googleapis.com">
5280
5452
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>