crypto-quant-signal-mcp 1.28.1 → 1.28.2

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 (148) hide show
  1. package/README.md +7 -5
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +82 -5
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/account-handlers.d.ts.map +1 -1
  6. package/dist/lib/account-handlers.js +10 -1
  7. package/dist/lib/account-handlers.js.map +1 -1
  8. package/dist/lib/analytics.d.ts +2 -0
  9. package/dist/lib/analytics.d.ts.map +1 -1
  10. package/dist/lib/analytics.js +55 -3
  11. package/dist/lib/analytics.js.map +1 -1
  12. package/dist/lib/attribution-sources.d.ts +1 -1
  13. package/dist/lib/attribution-sources.d.ts.map +1 -1
  14. package/dist/lib/attribution-sources.js +8 -0
  15. package/dist/lib/attribution-sources.js.map +1 -1
  16. package/dist/lib/contact-leads-store.d.ts +59 -0
  17. package/dist/lib/contact-leads-store.d.ts.map +1 -1
  18. package/dist/lib/contact-leads-store.js +160 -0
  19. package/dist/lib/contact-leads-store.js.map +1 -1
  20. package/dist/lib/contact-page.d.ts +9 -0
  21. package/dist/lib/contact-page.d.ts.map +1 -1
  22. package/dist/lib/contact-page.js +55 -1
  23. package/dist/lib/contact-page.js.map +1 -1
  24. package/dist/lib/contact-spam.d.ts +113 -0
  25. package/dist/lib/contact-spam.d.ts.map +1 -0
  26. package/dist/lib/contact-spam.js +190 -0
  27. package/dist/lib/contact-spam.js.map +1 -0
  28. package/dist/lib/contact-submit.d.ts +55 -2
  29. package/dist/lib/contact-submit.d.ts.map +1 -1
  30. package/dist/lib/contact-submit.js +121 -8
  31. package/dist/lib/contact-submit.js.map +1 -1
  32. package/dist/lib/detector-envelope.d.ts +25 -1
  33. package/dist/lib/detector-envelope.d.ts.map +1 -1
  34. package/dist/lib/detector-envelope.js +109 -5
  35. package/dist/lib/detector-envelope.js.map +1 -1
  36. package/dist/lib/email.d.ts +23 -5
  37. package/dist/lib/email.d.ts.map +1 -1
  38. package/dist/lib/email.js +91 -7
  39. package/dist/lib/email.js.map +1 -1
  40. package/dist/lib/emit-suppressions.d.ts +32 -2
  41. package/dist/lib/emit-suppressions.d.ts.map +1 -1
  42. package/dist/lib/emit-suppressions.js +15 -1
  43. package/dist/lib/emit-suppressions.js.map +1 -1
  44. package/dist/lib/geo-digest.d.ts.map +1 -1
  45. package/dist/lib/geo-digest.js +5 -2
  46. package/dist/lib/geo-digest.js.map +1 -1
  47. package/dist/lib/hold-decision-capture.d.ts +112 -0
  48. package/dist/lib/hold-decision-capture.d.ts.map +1 -0
  49. package/dist/lib/hold-decision-capture.js +158 -0
  50. package/dist/lib/hold-decision-capture.js.map +1 -0
  51. package/dist/lib/integrations-data/exchange-kits.d.ts +13 -2
  52. package/dist/lib/integrations-data/exchange-kits.d.ts.map +1 -1
  53. package/dist/lib/integrations-data/exchange-kits.js +41 -8
  54. package/dist/lib/integrations-data/exchange-kits.js.map +1 -1
  55. package/dist/lib/license.d.ts +28 -0
  56. package/dist/lib/license.d.ts.map +1 -1
  57. package/dist/lib/license.js +28 -0
  58. package/dist/lib/license.js.map +1 -1
  59. package/dist/lib/markdown-safe.d.ts +66 -0
  60. package/dist/lib/markdown-safe.d.ts.map +1 -0
  61. package/dist/lib/markdown-safe.js +147 -0
  62. package/dist/lib/markdown-safe.js.map +1 -0
  63. package/dist/lib/merkle-anchor-format.d.ts +50 -0
  64. package/dist/lib/merkle-anchor-format.d.ts.map +1 -0
  65. package/dist/lib/merkle-anchor-format.js +91 -0
  66. package/dist/lib/merkle-anchor-format.js.map +1 -0
  67. package/dist/lib/performance-db.d.ts +44 -0
  68. package/dist/lib/performance-db.d.ts.map +1 -1
  69. package/dist/lib/performance-db.js +224 -4
  70. package/dist/lib/performance-db.js.map +1 -1
  71. package/dist/lib/script-lifecycle.d.ts.map +1 -1
  72. package/dist/lib/script-lifecycle.js +36 -2
  73. package/dist/lib/script-lifecycle.js.map +1 -1
  74. package/dist/lib/stripe.d.ts +53 -0
  75. package/dist/lib/stripe.d.ts.map +1 -1
  76. package/dist/lib/stripe.js +60 -20
  77. package/dist/lib/stripe.js.map +1 -1
  78. package/dist/lib/subscriber-notify.d.ts +38 -3
  79. package/dist/lib/subscriber-notify.d.ts.map +1 -1
  80. package/dist/lib/subscriber-notify.js +75 -7
  81. package/dist/lib/subscriber-notify.js.map +1 -1
  82. package/dist/lib/telegram.d.ts +22 -15
  83. package/dist/lib/telegram.d.ts.map +1 -1
  84. package/dist/lib/telegram.js +62 -24
  85. package/dist/lib/telegram.js.map +1 -1
  86. package/dist/lib/turnstile.d.ts +110 -0
  87. package/dist/lib/turnstile.d.ts.map +1 -0
  88. package/dist/lib/turnstile.js +117 -0
  89. package/dist/lib/turnstile.js.map +1 -0
  90. package/dist/lib/x402-idempotency-store.d.ts +4 -2
  91. package/dist/lib/x402-idempotency-store.d.ts.map +1 -1
  92. package/dist/lib/x402-idempotency-store.js +19 -4
  93. package/dist/lib/x402-idempotency-store.js.map +1 -1
  94. package/dist/scripts/backfill-directional-labels.js +61 -35
  95. package/dist/scripts/backfill-directional-labels.js.map +1 -1
  96. package/dist/scripts/backfill-hold-decision-labels.d.ts +81 -0
  97. package/dist/scripts/backfill-hold-decision-labels.d.ts.map +1 -0
  98. package/dist/scripts/backfill-hold-decision-labels.js +385 -0
  99. package/dist/scripts/backfill-hold-decision-labels.js.map +1 -0
  100. package/dist/scripts/backfill-x402-payer-wallet.d.ts +1 -1
  101. package/dist/scripts/backfill-x402-payer-wallet.d.ts.map +1 -1
  102. package/dist/scripts/backfill-x402-payer-wallet.js +1 -1
  103. package/dist/scripts/backfill-x402-payer-wallet.js.map +1 -1
  104. package/dist/scripts/calibration-audit.d.ts +16 -2
  105. package/dist/scripts/calibration-audit.d.ts.map +1 -1
  106. package/dist/scripts/calibration-audit.js +16 -2
  107. package/dist/scripts/calibration-audit.js.map +1 -1
  108. package/dist/scripts/chat-analytics-digest.js +1 -1
  109. package/dist/scripts/chat-analytics-digest.js.map +1 -1
  110. package/dist/scripts/directional-labeler.d.ts +35 -0
  111. package/dist/scripts/directional-labeler.d.ts.map +1 -1
  112. package/dist/scripts/directional-labeler.js +36 -1
  113. package/dist/scripts/directional-labeler.js.map +1 -1
  114. package/dist/scripts/dwr-baseline-report.d.ts +305 -2
  115. package/dist/scripts/dwr-baseline-report.d.ts.map +1 -1
  116. package/dist/scripts/dwr-baseline-report.js +261 -33
  117. package/dist/scripts/dwr-baseline-report.js.map +1 -1
  118. package/dist/scripts/dwr-baseline-snapshot.d.ts +88 -0
  119. package/dist/scripts/dwr-baseline-snapshot.d.ts.map +1 -0
  120. package/dist/scripts/dwr-baseline-snapshot.js +255 -0
  121. package/dist/scripts/dwr-baseline-snapshot.js.map +1 -0
  122. package/dist/scripts/dwr-baseline.d.ts +18 -0
  123. package/dist/scripts/dwr-baseline.d.ts.map +1 -1
  124. package/dist/scripts/dwr-baseline.js +15 -0
  125. package/dist/scripts/dwr-baseline.js.map +1 -1
  126. package/dist/scripts/edge-stats.d.ts +48 -0
  127. package/dist/scripts/edge-stats.d.ts.map +1 -1
  128. package/dist/scripts/edge-stats.js +103 -0
  129. package/dist/scripts/edge-stats.js.map +1 -1
  130. package/dist/scripts/frozen-window-attribution.d.ts +86 -0
  131. package/dist/scripts/frozen-window-attribution.d.ts.map +1 -0
  132. package/dist/scripts/frozen-window-attribution.js +382 -0
  133. package/dist/scripts/frozen-window-attribution.js.map +1 -0
  134. package/dist/scripts/geo-weekly-cron.js +6 -2
  135. package/dist/scripts/geo-weekly-cron.js.map +1 -1
  136. package/dist/scripts/monitor.js +21 -2
  137. package/dist/scripts/monitor.js.map +1 -1
  138. package/dist/scripts/rate-limit-digest-weekly.js +1 -1
  139. package/dist/scripts/rate-limit-digest-weekly.js.map +1 -1
  140. package/dist/scripts/referral-payout-batch-detect.js +1 -1
  141. package/dist/scripts/referral-payout-batch-detect.js.map +1 -1
  142. package/dist/scripts/venue-readiness-report.js +1 -1
  143. package/dist/scripts/venue-readiness-report.js.map +1 -1
  144. package/dist/tools/get-trade-call.d.ts.map +1 -1
  145. package/dist/tools/get-trade-call.js +61 -2
  146. package/dist/tools/get-trade-call.js.map +1 -1
  147. package/package.json +5 -1
  148. 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.7%</span> PFE win rate across <span data-tr-field="total_calls">506,869</span>+ verified calls. Merkle-verified on Base L2. Don't trust — verify. <!-- SNAPSHOT-LINE -->
14
+ <span data-tr-field="pfe_wr">91.7%</span> PFE win rate across <span data-tr-field="total_calls">513,350</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.28.1",
96
+ "version": "1.28.2",
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.7%</span> PFE Win Rate</strong> · <strong><span data-tr-field="total_calls">506,869</span> trade calls</strong> · <strong><span data-tr-field="merkle_batches">136</span> on-chain batches</strong> <!-- SNAPSHOT-LINE -->
114
+ <strong><span data-tr-field="pfe_wr">91.7%</span> PFE Win Rate</strong> · <strong><span data-tr-field="total_calls">513,350</span> trade calls</strong> · <strong><span data-tr-field="merkle_batches">138</span> on-chain batches</strong> <!-- SNAPSHOT-LINE -->
115
115
  </p>
116
116
 
117
117
  <p align="center">
@@ -157,7 +157,7 @@ AlgoVault is drop-in for every MCP-spec client, every major agent framework, and
157
157
 
158
158
  Each demo is runnable as `python examples/<framework>/demo.py BTC 4h` — gets a real BUY/SELL/HOLD verdict from `api.algovault.com/mcp`, prints it. ≤5 minutes to first call.
159
159
 
160
- **Exchange Agent Trade Kits.** AlgoVault returns the analytics; your agent's risk policy decides what to execute. All demos run testnet/demo only.
160
+ **Exchange Agent Trade Kits.** AlgoVault returns the analytics; your agent's risk policy decides what to execute. All demos run testnet/demo only. For Binance, the Agent OS path is the recommended default for new integrations — OAuth at connect time, no API keys on the machine; the key-based kit remains right for custom order types.
161
161
 
162
162
  <!-- BUILD:README_INTEGRATIONS_TABLE -->
163
163
  | # | Exchange | Tutorial | Demo | Mirror |
@@ -174,6 +174,7 @@ Each demo is runnable as `python examples/<framework>/demo.py BTC 4h` — gets a
174
174
  | 10 | Kraken | [`docs/integrations/kraken.md`](docs/integrations/kraken.md) | [`examples/kraken/demo.mjs`](examples/kraken/demo.mjs) | [algovault.com/docs/integrations/kraken](https://algovault.com/integrations/kraken) |
175
175
  | 11 | Alpaca | [`docs/integrations/alpaca.md`](docs/integrations/alpaca.md) | [`examples/alpaca/demo.mjs`](examples/alpaca/demo.mjs) | [algovault.com/docs/integrations/alpaca](https://algovault.com/integrations/alpaca) |
176
176
  | 12 | Gate.io | [`docs/integrations/gateio.md`](docs/integrations/gateio.md) | [`examples/gateio/demo.mjs`](examples/gateio/demo.mjs) | [algovault.com/docs/integrations/gateio](https://algovault.com/integrations/gateio) |
177
+ | 13 | Binance Agent OS | [`docs/integrations/exchange-kits/binance-agent-os.md`](docs/integrations/exchange-kits/binance-agent-os.md) | — | [algovault.com/integrations/binance-agent-os](https://algovault.com/integrations/binance-agent-os) |
177
178
  <!-- /BUILD:README_INTEGRATIONS_TABLE -->
178
179
 
179
180
  ---
@@ -235,7 +236,7 @@ Two meters per paid tier, monthly and daily, enforced independently: a call is r
235
236
  | Feature | Free | Starter ($9.99/mo · $39.90/6mo) | Pro ($49/mo · $129/6mo) | Enterprise (contact us) | x402 (per call) |
236
237
  |---------|------|-------------------|-------------|---------------------|-----------------|
237
238
  | Exchanges | All 15 | All 15 | All 15 | All 15 | All 15 | <!-- SNAPSHOT-LINE-TABLE -->
238
- | Assets | All 1740+ | All 1740+ | All 1740+ | All 1740+ | All 1740+ | <!-- SNAPSHOT-LINE-TABLE -->
239
+ | Assets | All 1770+ | All 1770+ | All 1770+ | All 1770+ | All 1770+ | <!-- SNAPSHOT-LINE-TABLE -->
239
240
  | Asset classes | Crypto + TradFi | Crypto + TradFi | Crypto + TradFi | Crypto + TradFi | Crypto + TradFi |
240
241
  | Timeframes | All 11 | All 11 | All 11 | All 11 | All 11 |
241
242
  | Funding arb results | Top 5 | Unlimited | Unlimited | Unlimited | Unlimited |
@@ -261,6 +262,7 @@ Pro 6-month is currently $129 — limited-time pricing; subscribe now and renewa
261
262
  - **📗 [The docs](https://algovault.com/docs) answer the question instead of pointing at it.** Every `rankBy` lens is documented, REST is as complete as MCP, there's a proper error-code reference, and the copy-paste samples run exactly as written — CI re-checks them against the live API on every deploy.
262
263
 
263
264
  - **v1.28.1** — clearer tool descriptions for agent tool-selection; `get_trade_signal` now steers new integrations to `get_trade_call`.
265
+ - **v1.28.2** — **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, no request signing, and trading confined to an isolated sub-account you fund yourself. There is no withdrawal scope.
264
266
 
265
267
  **Upgrading from v1.27.x** — one breaking change: `EDGEX` and `WEEX` are no longer valid `exchange` values and now return `-32602`. No tool was added or renamed. Check any hard-coded `exchange` value against the published enum, and read `_algovault.auth` if you branch on auth failures.
266
268
 
@@ -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;AAkU1D;;;;;;;;;;;;;;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+vJD,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;AAkU1D;;;;;;;;;;;;;;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;AAk1JD,wBAAgB,mBAAmB,cAElC"}
package/dist/index.js CHANGED
@@ -1131,8 +1131,38 @@ async function startHttp() {
1131
1131
  // apex and are same-origin with the stylesheet, so 'self' already permits it. Leaving Caddy
1132
1132
  // stricter is safe — the keep-in-sync warning above guards against pages being left
1133
1133
  // UNCOVERED, not against Caddy being tighter than Express.
1134
+ //
1135
+ // The same holds for the Turnstile hosts added below, and it is worth stating why rather
1136
+ // than inheriting the sentence above. `/contact` is served by Express (Caddy's earlier
1137
+ // `handle /contact { reverse_proxy localhost:3000 }` block wins over the static
1138
+ // file_server), so THIS header is the one the browser receives on the only page carrying the
1139
+ // widget — verified 2026-08-25 by curling the live URL and matching the returned policy
1140
+ // against this string, not against the Caddyfile's. Widening the static-page twin for a
1141
+ // script no static page loads would be a loosening bought for nothing.
1134
1142
  res.setHeader('Content-Security-Policy', "default-src 'self'; " +
1135
- "script-src 'self' 'unsafe-inline' https://cdn.tailwindcss.com; " +
1143
+ // CONTACT-ANTISPAM-AND-REPLY-TO-W1 CH2 — challenges.cloudflare.com, in BOTH script-src
1144
+ // and frame-src. Measured 2026-08-25 against the live header: the widget was blocked
1145
+ // TWICE and each block is silent on its own.
1146
+ // 1. script-src omitted the host, so api.js never loaded.
1147
+ // 2. There was NO frame-src directive AT ALL, so the Turnstile iframe fell back to
1148
+ // `default-src 'self'` and was refused. This is the half that would have survived
1149
+ // a fix to script-src alone, and the visible symptom is identical: an empty space
1150
+ // where the widget should be, and every submission failing the challenge.
1151
+ // Cloudflare's CSP reference names exactly these two directives. `connect-src` is NOT
1152
+ // widened -- it is required only for pre-clearance mode, which this integration does
1153
+ // not use, and a speculative directive is threat surface bought for nothing.
1154
+ //
1155
+ // ⚠️ EVERY LITERAL IN THIS CALL MUST USE DOUBLE QUOTES, AND THIS COMMENT MUST CONTAIN
1156
+ // NONE. `scripts/check-token-resolution.mjs` reconstructs this policy by scraping
1157
+ // double-quoted literals out of a byte window of this file, so a single-quoted segment
1158
+ // is INVISIBLE to it and a double-quoted phrase in the prose gets spliced INTO the
1159
+ // policy. Both happened in this wave's first draft: the new directives vanished, and a
1160
+ // quoted aside landed mid-string, turning `style-src` into `casestyle-src` and failing
1161
+ // the fail-closed deploy gate. The scraper now strips comments (same commit), so only
1162
+ // the quoting convention still matters here — but it matters silently, which is why it
1163
+ // is stated at the site rather than left to be rediscovered.
1164
+ "script-src 'self' 'unsafe-inline' https://cdn.tailwindcss.com https://challenges.cloudflare.com; " +
1165
+ "frame-src 'self' https://challenges.cloudflare.com; " +
1136
1166
  "style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://algovault.com; " +
1137
1167
  "font-src 'self' https://fonts.gstatic.com data:; " +
1138
1168
  "img-src 'self' data: https:; " +
@@ -1267,7 +1297,7 @@ async function startHttp() {
1267
1297
  // INTEGRATION_HTML at startup, so the HTML must exist in the image before
1268
1298
  // a slug is listed here — a missing file only console.warns, then 404s.
1269
1299
  const INTEGRATION_EXCHANGES = ['binance', 'okx', 'bybit', 'bitget', 'gemini', 'kraken', 'alpaca',
1270
- 'hyperliquid', 'aster', 'bingx', 'kucoin', 'gateio'];
1300
+ 'hyperliquid', 'aster', 'bingx', 'kucoin', 'gateio', 'binance-agent-os'];
1271
1301
  const INTEGRATION_FRAMEWORKS = ['langchain', 'llamaindex', 'maf', 'crewai'];
1272
1302
  // INTEGRATIONS-FULL-STACK-W1 C4 (2026-05-19): 5 MCP-client landing pages
1273
1303
  // (Plain HTTP/curl stays inline-only per Q-PLAIN-HTTP=NO; not in allow-list).
@@ -1579,12 +1609,33 @@ async function startHttp() {
1579
1609
  // contract and is unit-testable (CLAUDE.md — a handler closure in index.ts is not).
1580
1610
  app.post('/contact', contactLimiter, express.urlencoded({ extended: false, limit: '8kb' }), async (req, res) => {
1581
1611
  const body = (req.body ?? {});
1582
- const [{ handleContactSubmission }, store, emailMod, tg] = await Promise.all([
1612
+ const [{ handleContactSubmission }, store, emailMod, tg, turnstile] = await Promise.all([
1583
1613
  import('./lib/contact-submit.js'),
1584
1614
  import('./lib/contact-leads-store.js'),
1585
1615
  import('./lib/email.js'),
1586
1616
  import('./lib/telegram.js'),
1617
+ import('./lib/turnstile.js'),
1587
1618
  ]);
1619
+ // ── The challenge gate (CONTACT-ANTISPAM-AND-REPLY-TO-W1 CH2) ──
1620
+ //
1621
+ // This is the ONE step that runs BEFORE the persist, and it is the only place in this route
1622
+ // that can refuse a submission outright. Everything after it obeys CH1's ordering contract.
1623
+ //
1624
+ // `remoteip` comes from CF-Connecting-IP, falling back to X-Forwarded-For. Cloudflare
1625
+ // overwrites a client-supplied CF-Connecting-IP at its edge, so it is not spoofable — the
1626
+ // same property the Caddyfile's `handle /contact` block already relies on for the limiter.
1627
+ const cfIp = req.headers['cf-connecting-ip'];
1628
+ const xff = req.headers['x-forwarded-for'];
1629
+ const remoteIp = (typeof cfIp === 'string' && cfIp)
1630
+ || (typeof xff === 'string' ? xff.split(',')[0]?.trim() : '')
1631
+ || null;
1632
+ const challenge = await turnstile.verifyTurnstile(body[turnstile.TURNSTILE_RESPONSE_FIELD], remoteIp, { getSecret: () => process.env.TURNSTILE_SECRET_KEY });
1633
+ if (challenge.kind === 'reject') {
1634
+ // ZERO ROWS WRITTEN — the persist has not happened yet. A retryable 400 with the widget
1635
+ // still on screen is materially different from a dropped row, which is why this is the one
1636
+ // sanctioned refusal on a route whose entire design is "never lose a lead".
1637
+ return res.status(400).type('html').send((0, contact_page_js_1.renderContactPage)({ error: 'turnstile_failed', src: typeof body.src === 'string' ? body.src : null }));
1638
+ }
1588
1639
  // Channel re-derived server-side; the form's hidden field is a hint, never trusted as sent.
1589
1640
  const classified = (0, attribution_sources_js_1.classifySource)({
1590
1641
  srcParam: typeof body.src === 'string' ? body.src : undefined,
@@ -1592,12 +1643,24 @@ async function startHttp() {
1592
1643
  referer: req.headers.referer,
1593
1644
  origin: req.headers.origin,
1594
1645
  });
1595
- const result = await handleContactSubmission(body, { src: classified.source ?? null, ipHash: (0, analytics_js_1.hashIp)((0, client_ip_js_1.clientIp)(req) || 'unknown') }, {
1646
+ const result = await handleContactSubmission(body, {
1647
+ src: classified.source ?? null,
1648
+ ipHash: (0, analytics_js_1.hashIp)((0, client_ip_js_1.clientIp)(req) || 'unknown'),
1649
+ // `skip` and `pass` contribute nothing; only `unverified` tags. The lead is captured and
1650
+ // notified either way — the tag makes it VISIBLE as unverified, it does not suppress it.
1651
+ spamTags: turnstile.turnstileTags(challenge),
1652
+ }, {
1596
1653
  validateEmail: email_validation_js_1.validateSignupEmail,
1597
1654
  insertLead: store.insertContactLead,
1598
1655
  markNotified: store.markContactLeadNotified,
1599
1656
  sendEmail: emailMod.sendContactLeadEmail,
1600
1657
  sendAlert: tg.sendAlert,
1658
+ // CONTACT-ANTISPAM-AND-REPLY-TO-W1 CH1 — the quarantine lane's three seams. Each fails
1659
+ // open inside the store, so a DB problem degrades to "notify the operator", never to a
1660
+ // silently swallowed lead.
1661
+ readLookback: store.readContactLeadLookback,
1662
+ markScored: store.markContactLeadScored,
1663
+ countRecentQuarantines: store.countRecentQuarantines,
1601
1664
  });
1602
1665
  switch (result.kind) {
1603
1666
  case 'ok':
@@ -4414,7 +4477,7 @@ ${(0, site_nav_js_1.renderSiteNav)()}
4414
4477
  (matches Cross-Venue ↔ On-Chain Verified visual gap per Mr.1 directive). -->
4415
4478
  <div class="space-y-2 mb-8">
4416
4479
  <h1 class="text-5xl sm:text-6xl font-semibold tracking-tight" style="color:var(--fg)">Live <span class="text-mint-400">Track Record</span></h1>
4417
- <p class="text-sm" style="color:#5BEEB3">v<span data-tr-field="pkg_version">${pkg_version_js_1.PKG_VERSION}</span> &middot; <span data-tr-field="exchange_count">${capabilities_js_1.EXCHANGE_COUNT}</span> Exchanges &middot; <span data-tr-field="asset_count">736</span> assets</p>
4480
+ <p class="text-sm" style="color:#5BEEB3">v<span data-tr-field="pkg_version">${pkg_version_js_1.PKG_VERSION}</span> &middot; <span data-tr-field="exchange_count">${capabilities_js_1.EXCHANGE_COUNT}</span> Exchanges &middot; <span data-tr-field="asset_count">&mdash;</span> assets</p>
4418
4481
  </div>
4419
4482
  <div id="loading">Loading performance data...</div>
4420
4483
  <div id="content" style="display:none">
@@ -4899,6 +4962,20 @@ async function load() {
4899
4962
  var d = await r.json();
4900
4963
  cachedData = d;
4901
4964
 
4965
+ // EXTERNAL-SURFACE-PARITY-W1 CH2b: hydrate the subtitle's asset count from the payload we
4966
+ // already have. This span was a HARDCODED 736 against a live 1,748 — a public number with no
4967
+ // producer, frozen at its authoring date on the one page whose entire pitch is verifiability.
4968
+ // It is NOT routed through the deploy-time injector: that operates on landing/*.html files and
4969
+ // /track-record is function-rendered from this module, so there is no file for it to patch.
4970
+ // Pre-load it now reads the page's own &mdash; placeholder convention, exactly as
4971
+ // merkle_batch_count / latest_batch_at do, so a fetch failure shows a placeholder rather than
4972
+ // a confident wrong number.
4973
+ if (typeof d.asset_count === 'number') {
4974
+ document.querySelectorAll('[data-tr-field="asset_count"]').forEach(function(el){
4975
+ el.textContent = d.asset_count.toLocaleString();
4976
+ });
4977
+ }
4978
+
4902
4979
  // Tier filter tabs
4903
4980
  var ttEl = document.getElementById('tier-tabs');
4904
4981
  ttEl.innerHTML = [