Intelligence, Advanced Charting & Trading Platform
fix/chartnova-progressive-loading-2026-10-15
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 | // P0 repository guard: static, read-only and deliberately fail-closed. |
| 2 | // Not a legal-license validation, runtime security audit or production deployment gate. |
| 3 | import { readFile, readdir } from 'node:fs/promises'; |
| 4 | import { dirname, join, resolve } from 'node:path'; |
| 5 | import { fileURLToPath } from 'node:url'; |
| 6 | |
| 7 | const ownRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..'); |
| 8 | const MIGRATION_BLOCK_PATTERN = /navasan_ohlc|ohlcSearch|candle_source_provenance|chartnova_navasan_candle_audit/i; |
| 9 | |
| 10 | export async function evaluateP0Safety(root = ownRoot) { |
| 11 | const violations = []; |
| 12 | const migrationDir = join(root, 'db', 'migrations'); |
| 13 | let migrations; |
| 14 | try { |
| 15 | migrations = (await readdir(migrationDir)).filter((name) => name.endsWith('.sql')); |
| 16 | } catch { |
| 17 | return { ok: false, violations: ['Cannot enumerate db/migrations; safety review required.'] }; |
| 18 | } |
| 19 | for (const filename of migrations) { |
| 20 | const contents = await readFile(join(migrationDir, filename), 'utf8'); |
| 21 | if (filename === '0005_navasan_private_daily_ohlc.sql' || MIGRATION_BLOCK_PATTERN.test(contents)) { |
| 22 | violations.push(filename + ': Navasan/OHLC migration HOLD; verify exact units, quote-side, license, provenance and review before changing this guard.'); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | try { |
| 27 | const adapter = await readFile(join(root, 'packages', 'market-domain', 'src', 'adapters', 'navasan.mjs'), 'utf8'); |
| 28 | if (!/rawUnit:\s*['"]IRR_PER_USD['"]/.test(adapter) || !/rawUnit:\s*['"]IRR_PER_GRAM['"]/.test(adapter)) { |
| 29 | violations.push('Navasan adapter raw-unit contract changed; manual unit/quote-side review required.'); |
| 30 | } |
| 31 | } catch { |
| 32 | violations.push('Navasan adapter missing or unreadable; manual review required.'); |
| 33 | } |
| 34 | |
| 35 | try { |
| 36 | const agentRules = await readFile(join(root, 'AGENTS.md'), 'utf8'); |
| 37 | if (!/AI\/signals may never directly execute an order\./.test(agentRules)) { |
| 38 | violations.push('AI-to-live-order prohibition in AGENTS.md changed or missing.'); |
| 39 | } |
| 40 | } catch { |
| 41 | violations.push('AGENTS.md missing or unreadable; manual review required.'); |
| 42 | } |
| 43 | |
| 44 | return { ok: violations.length === 0, violations }; |
| 45 | } |
| 46 | |
| 47 | if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { |
| 48 | const root = process.argv[2] ? resolve(process.argv[2]) : ownRoot; |
| 49 | const outcome = await evaluateP0Safety(root); |
| 50 | if (outcome.ok) { |
| 51 | console.log('P0 static guard: PASS (no blocked migration detected; baseline contracts present).'); |
| 52 | } else { |
| 53 | for (const item of outcome.violations) console.error('P0 static guard: BLOCK - ' + item); |
| 54 | process.exitCode = 1; |
| 55 | } |
| 56 | console.log('Reminder: PASS does not establish market-data licensing, valid live feeds or trading safety.'); |
| 57 | } |