Intelligence, Advanced Charting & Trading Platform
main
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 { mkdtemp, mkdir, writeFile, rm } from 'node:fs/promises'; |
| 4 | import { join } from 'node:path'; |
| 5 | import { tmpdir } from 'node:os'; |
| 6 | import { evaluateP0Safety } from './check-p0-safety.mjs'; |
| 7 | |
| 8 | async function fixture() { |
| 9 | const root = await mkdtemp(join(tmpdir(), 'velyqor-p0-')); |
| 10 | await mkdir(join(root, 'db', 'migrations'), { recursive: true }); |
| 11 | await mkdir(join(root, 'packages', 'market-domain', 'src', 'adapters'), { recursive: true }); |
| 12 | await writeFile(join(root, 'db', 'migrations', '0001_market_core.sql'), 'CREATE TABLE harmless(id int);'); |
| 13 | await writeFile(join(root, 'packages', 'market-domain', 'src', 'adapters', 'navasan.mjs'), "rawUnit: 'IRR_PER_USD'; rawUnit: 'IRR_PER_GRAM';"); |
| 14 | await writeFile(join(root, 'AGENTS.md'), 'AI/signals may never directly execute an order.'); |
| 15 | return root; |
| 16 | } |
| 17 | |
| 18 | async function withFixture(fn) { |
| 19 | const root = await fixture(); |
| 20 | try { await fn(root); } finally { await rm(root, { recursive: true, force: true }); } |
| 21 | } |
| 22 | |
| 23 | test('baseline passes without altering source files', () => withFixture(async (root) => { |
| 24 | assert.deepEqual(await evaluateP0Safety(root), { ok: true, violations: [] }); |
| 25 | })); |
| 26 | |
| 27 | test('unreviewed 0005 OHLC migration is blocked', () => withFixture(async (root) => { |
| 28 | await writeFile(join(root, 'db', 'migrations', '0005_navasan_private_daily_ohlc.sql'), 'SELECT 1;'); |
| 29 | const result = await evaluateP0Safety(root); |
| 30 | assert.equal(result.ok, false); |
| 31 | assert.match(result.violations.join('\n'), /0005_navasan_private_daily_ohlc/); |
| 32 | })); |
| 33 | |
| 34 | test('renamed Navasan OHLC migration is blocked', () => withFixture(async (root) => { |
| 35 | await writeFile(join(root, 'db', 'migrations', '0006_more.sql'), "INSERT INTO providers(code) VALUES ('navasan_ohlc');"); |
| 36 | assert.equal((await evaluateP0Safety(root)).ok, false); |
| 37 | })); |
| 38 | |
| 39 | test('changed unit assumptions are blocked', () => withFixture(async (root) => { |
| 40 | await writeFile(join(root, 'packages', 'market-domain', 'src', 'adapters', 'navasan.mjs'), "rawUnit: 'IRT_PER_USD'; rawUnit: 'IRT_PER_GRAM';"); |
| 41 | assert.match((await evaluateP0Safety(root)).violations.join('\n'), /raw-unit contract/); |
| 42 | })); |
| 43 | |
| 44 | test('removing no-AI-order rule is blocked', () => withFixture(async (root) => { |
| 45 | await writeFile(join(root, 'AGENTS.md'), '# Rules\n'); |
| 46 | assert.match((await evaluateP0Safety(root)).violations.join('\n'), /AI-to-live-order/); |
| 47 | })); |
| 48 | |
| 49 | test('missing migration directory fails closed', async () => { |
| 50 | const root = await mkdtemp(join(tmpdir(), 'velyqor-p0-empty-')); |
| 51 | try { assert.equal((await evaluateP0Safety(root)).ok, false); } |
| 52 | finally { await rm(root, { recursive: true, force: true }); } |
| 53 | }); |