Intelligence, Advanced Charting & Trading Platform
phase-1/provider-recovery
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 | const BASE = Object.freeze({ GOOD: 100, DEGRADED: 80, STALE: 30, INVALID: 0 }); |
| 2 | |
| 3 | export function qualityScore({ state, flags = [], ageRatio = 0 }) { |
| 4 | if (!(state in BASE)) throw new RangeError(`unsupported quality state: ${state}`); |
| 5 | if (!Array.isArray(flags)) throw new TypeError('flags must be an array'); |
| 6 | if (!Number.isFinite(ageRatio) || ageRatio < 0) throw new RangeError('ageRatio must be non-negative and finite'); |
| 7 | if (state === 'INVALID') return 0; |
| 8 | |
| 9 | let score = BASE[state]; |
| 10 | if (flags.includes('PROVIDER_DIVERGENCE')) score -= 15; |
| 11 | if (flags.includes('STALE_SOURCE')) score -= 10; |
| 12 | if (ageRatio >= 0.75 && ageRatio <= 1) score -= 10; |
| 13 | if (ageRatio > 1) score -= Math.min(20, Math.floor(ageRatio - 1) * 5); |
| 14 | |
| 15 | if (state === 'STALE') score = Math.min(score, 30); |
| 16 | return Math.max(0, Math.min(100, score)); |
| 17 | } |