Intelligence, Advanced Charting & Trading Platform
fix/live-proof-runner-cwd-2026-10-14
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 { analyzeObservationSeries } from '../src/data-proof.mjs'; |
| 4 | |
| 5 | test('measures cadence, max gap and duplicate timestamps', () => { |
| 6 | const result = analyzeObservationSeries([ |
| 7 | { timestamp: '2026-10-05T12:00:00Z', price: 100 }, |
| 8 | { timestamp: '2026-10-05T12:01:00Z', price: 101 }, |
| 9 | { timestamp: '2026-10-05T12:01:00Z', price: 101 }, |
| 10 | { timestamp: '2026-10-05T12:03:00Z', price: 102 }, |
| 11 | ]); |
| 12 | |
| 13 | assert.equal(result.count, 4); |
| 14 | assert.equal(result.uniqueTimestampCount, 3); |
| 15 | assert.equal(result.duplicateTimestampCount, 1); |
| 16 | assert.equal(result.maxGapMs, 120_000); |
| 17 | assert.equal(result.medianCadenceMs, 90_000); |
| 18 | }); |
| 19 | |
| 20 | test('reports out-of-order input without silently reclassifying it as clean', () => { |
| 21 | const result = analyzeObservationSeries([ |
| 22 | { timestamp: '2026-10-05T12:02:00Z', price: 100 }, |
| 23 | { timestamp: '2026-10-05T12:01:00Z', price: 101 }, |
| 24 | { timestamp: '2026-10-05T12:03:00Z', price: 102 }, |
| 25 | ]); |
| 26 | assert.equal(result.outOfOrderCount, 1); |
| 27 | }); |
| 28 | |
| 29 | test('rejects invalid timestamps and prices', () => { |
| 30 | assert.throws(() => analyzeObservationSeries([ |
| 31 | { timestamp: 'bad', price: 100 }, |
| 32 | ]), /timestamp/i); |
| 33 | |
| 34 | assert.throws(() => analyzeObservationSeries([ |
| 35 | { timestamp: '2026-10-05T12:00:00Z', price: 0 }, |
| 36 | ]), /price/i); |
| 37 | }); |
| 38 | |
| 39 | test('returns null cadence metrics when fewer than two unique timestamps exist', () => { |
| 40 | const result = analyzeObservationSeries([ |
| 41 | { timestamp: '2026-10-05T12:00:00Z', price: 100 }, |
| 42 | ]); |
| 43 | assert.equal(result.maxGapMs, null); |
| 44 | assert.equal(result.medianCadenceMs, null); |
| 45 | }); |