Intelligence, Advanced Charting & Trading Platform
risk/chartnova-atomic-outbox-2026-10-22
diagnostics/chartnova-blank-screen-2026-10-15
diagnostics/chartnova-stage2-v27-preview-2026-10-15
docs/chartnova-stage1-reconcile-manifest-2026-10-15
feature/chartnova-ios-widget
feature/chartnova-light-catalog-lazy-series-2026-10-15
feature/chartnova-market-terminal
feature/chartnova-multimarket-chart-ws-foundation
feature/chartnova-neon-direct-history
feature/chartnova-neon-history
feature/paper-trading-risk-controls-2026-10-14
fix/alpha-vantage-live-payload
fix/chartnova-progressive-loading-2026-10-15
fix/live-proof-runner-cwd-2026-10-14
foundation/phase-0
foundation/postgres-core
main
ops/chartnova-emergency-rollback-2026-10-15
phase-1/candle-builder
phase-1/data-proof-artifact
phase-1/data-proof-metrics
phase-1/data-proof-report
phase-1/external-gates-state
phase-1/gold-api-fallback
phase-1/ingestion-pipeline
phase-1/live-proof-runner
phase-1/market-calendar
phase-1/market-domain
phase-1/neon-live-proof
phase-1/persistence-contract
phase-1/postgres-ci
phase-1/provider-adapters
phase-1/provider-recovery
phase-1/quality-propagation
phase-1/spike-detection
phase-1/xau-provider-adapter
risk/chartnova-alert-runtime-atomic-2026-10-22
risk/chartnova-atomic-outbox-2026-10-22
risk/chartnova-seven-track-safety-2026-10-21
safety/p0-triage-2026-10-13
| 1 | import test from 'node:test'; |
| 2 | import assert from 'node:assert/strict'; |
| 3 | import { buildDataProofReport } from '../src/data-proof-report.mjs'; |
| 4 | |
| 5 | test('passes a clean provider window with explicit thresholds', () => { |
| 6 | const report = buildDataProofReport({ |
| 7 | providerCode: 'navasan', |
| 8 | canonicalSymbol: 'USD_IRT_FREE', |
| 9 | observations: [ |
| 10 | { timestamp: '2026-10-05T12:00:00Z', price: 100000 }, |
| 11 | { timestamp: '2026-10-05T12:01:00Z', price: 100100 }, |
| 12 | { timestamp: '2026-10-05T12:02:00Z', price: 100050 }, |
| 13 | ], |
| 14 | checkedAt: new Date('2026-10-05T12:02:10Z'), |
| 15 | thresholds: { maxGapMs: 90_000, maxFreshnessMs: 60_000, maxDuplicateCount: 0, maxOutOfOrderCount: 0 }, |
| 16 | }); |
| 17 | assert.equal(report.status, 'PASS'); |
| 18 | assert.deepEqual(report.failures, []); |
| 19 | assert.equal(report.metrics.freshnessMs, 10_000); |
| 20 | }); |
| 21 | |
| 22 | test('fails stale, gapped and duplicate data with auditable reasons', () => { |
| 23 | const report = buildDataProofReport({ |
| 24 | providerCode: 'navasan', |
| 25 | canonicalSymbol: 'GOLD18_IRT', |
| 26 | observations: [ |
| 27 | { timestamp: '2026-10-05T12:00:00Z', price: 100 }, |
| 28 | { timestamp: '2026-10-05T12:00:00Z', price: 100 }, |
| 29 | { timestamp: '2026-10-05T12:05:00Z', price: 101 }, |
| 30 | ], |
| 31 | checkedAt: new Date('2026-10-05T12:10:00Z'), |
| 32 | thresholds: { maxGapMs: 120_000, maxFreshnessMs: 60_000, maxDuplicateCount: 0, maxOutOfOrderCount: 0 }, |
| 33 | }); |
| 34 | assert.equal(report.status, 'FAIL'); |
| 35 | assert.ok(report.failures.includes('MAX_GAP_EXCEEDED')); |
| 36 | assert.ok(report.failures.includes('STALE_LATEST_OBSERVATION')); |
| 37 | assert.ok(report.failures.includes('DUPLICATE_TIMESTAMPS')); |
| 38 | }); |
| 39 | |
| 40 | test('refuses to certify an empty observation window', () => { |
| 41 | assert.throws(() => buildDataProofReport({ |
| 42 | providerCode: 'alpha_vantage', canonicalSymbol: 'XAU_USD', observations: [], |
| 43 | checkedAt: new Date('2026-10-05T12:00:00Z'), |
| 44 | thresholds: { maxGapMs: 60_000, maxFreshnessMs: 60_000, maxDuplicateCount: 0, maxOutOfOrderCount: 0 }, |
| 45 | }), /observation/i); |
| 46 | }); |