Intelligence, Advanced Charting & Trading Platform
feature/paper-trading-risk-controls-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 | # ChartNova — Neon direct-history handoff (2026-10-11) |
| 2 | |
| 3 | ## Verified operational evidence |
| 4 | - PostgreSQL project `still-shadow-40990313`, branch `production`, database `neondb`. |
| 5 | - `market_ticks` contains **762** ECB daily EUR reference observations (254 each for EUR/USD, EUR/GBP, EUR/CHF), 2025-10-13 through 2026-10-09, with **zero** invalid provenance checks and no duplicate `(symbol,observation_at)` pairs. `candles` remains empty by design; ECB daily reference points are not OHLC. |
| 6 | - The importer dry run parsed 762 valid observations with zero source duplicates. The subsequent `--commit` run reported `insertedThisRun: 0` while the database verified 762 rows. **Do not claim 762 newly inserted by this run**; they already existed by the time the committed import ran. The record insertion timestamp was not established. |
| 7 | - On deployed `app.chartnova.ir`, historical ECB endpoints and the history navigation, domestic prices, widget feed, and Scriptable V4 downloads passed direct smoke checks. Deployed history reads a Neon-verified KV mirror, **not a live direct database connection**. |
| 8 | |
| 9 | ## Isolated implementation |
| 10 | - Branch: `feature/chartnova-neon-direct-history`, forked from existing `feature/chartnova-neon-history`. The original Windows working tree had unrelated dirty edits; they were **not touched**. |
| 11 | - Updated `deploy/chartnova/worker.mjs` to accept `symbol` in the three-symbol ECB allowlist, `from`/`to` UTC ISO dates (no more than 400 days, not in the future), and `limit` 1–500. |
| 12 | - When the optional `CHARTNOVA_HISTORY_DATABASE_URL` Cloudflare secret exists, Worker sends parameterized SELECT queries to `public.chartnova_history_public` through Neon HTTP SQL. Worker stores a short-lived read result in existing `MARKET_CACHE`. The frontend receives only allowlisted historical rates and attribution, never the credential. |
| 13 | - When direct Neon is unavailable or unconfigured, the existing KV historical snapshot remains a labeled fallback. No user-selectable table name or SQL is exposed. |
| 14 | - `deploy/chartnova/history-direct.test.mjs` uses **test fixtures only** for shape, validation, and error handling. It does not demonstrate live direct-DB connectivity. |
| 15 | |
| 16 | ## Security handoff |
| 17 | - A least-privilege PostgreSQL role `chartnova_history_ro` was created by SQL with `NOLOGIN`, `NOINHERIT`, `NOCREATEDB`, and `NOCREATEROLE`. Permission checks prove it can SELECT only `public.chartnova_history_public`, not `market_ticks`, `candles`, or `instruments`, and cannot INSERT into `market_ticks`. |
| 18 | - The Neon role-creation API also created `chartnova_history_reader`, but unexpectedly granted membership in `neon_superuser` and role/database creation privileges. Attempts to harden it using the project-owner connection were denied. **This role was subsequently deleted after explicit user approval, verified absent from pg_roles; see docs/security/neon-history-reader-predelete-2026-10-11.md.** |
| 19 | - Secret transfer to Cloudflare was blocked by the execution environment's safety controls. The least-privilege role remains `NOLOGIN`, and `CHARTNOVA_HISTORY_DATABASE_URL` is **not configured**. Do not imply a deployed Neon direct connection. |
| 20 | - **Manual secure activation later:** use the Neon Console / SQL editor under an administrator authorized to manage the role: set a strong private password and LOGIN on `chartnova_history_ro`; set a Cloudflare Worker secret named `CHARTNOVA_HISTORY_DATABASE_URL` to a PostgreSQL URL for that role using Cloudflare's secure secret manager, not source code, chat, or ordinary worker variables. Then deploy the reviewed Worker branch and run real HTTP tests, including revoking SELECT to demonstrate fail-closed behavior. |
| 21 | - No licensed one-year OHLC feed for domestic free-market USD, Iranian 18K gold or coins has been connected. Never fill `candles` from ECB reference points, point-in-time KV snapshots, or unlicensed TGJU archives. |
| 22 | |
| 23 | ## Tests and remaining acceptance |
| 24 | - Isolated Worker: 9 / 9 `history-direct.test.mjs` + existing history-endpoints tests passed; `node --check` passed. |
| 25 | - Existing deployed version: history (all 3), page navigation, widget view, domestic price, widget API, and Scriptable V4 download passed. |
| 26 | - **Blocked:** direct Worker→Neon authenticated read (the secret binding is not configured), true continuous synchronization, production deployment of new code, live integration test using restricted DB role, licensed OHLC history for required markets, model backtesting and bias measurement. |
| 27 | - Production changes must not be declared done until least-privilege credential activation, checked runtime responses, negative security tests, and fallback regression smoke pass. |
| 28 | |
| 29 | ## Rollback |
| 30 | - Keep existing KV keys `history:ecb:<SYMBOL>:1y`; removing the optional database secret forces KV-only reads. |
| 31 | - Preserve existing published Cloudflare Worker version and version ID for rollback. Do not delete the existing KV namespace or provider secrets. |
| 32 | |
| 33 | ### Security cleanup completed |
| 34 | After explicit approval, the overprivileged `chartnova_history_reader` was deleted. A separate PostgreSQL verification returned zero matching role records, retained `chartnova_history_ro` with restricted permissions, and retained all 762 ECB observations. Safe secret handoff and live Neon-backed Worker deployment remain pending. |