Intelligence, Advanced Charting & Trading Platform
feature/chartnova-multimarket-chart-ws-foundation
VELYQOR Project State
Last updated: 2026-10-07
Current phase
Phase 1 — Market Data Integrity & Data Proof.
Product scope locked for MVP
- Iran free-market USD/IRT
- Iran 18K gold/IRT market price
- Global XAU/USD
- Theoretical 18K gold/IRT
- Gold market premium/discount absolute and percentage series
- Professional charting, drawing tools, technical indicators, overlays, and persistent user workspaces
Architecture baseline
- Modular monolith for MVP, with independently schedulable ingestion workers.
- TypeScript/React/Next.js web application.
- PostgreSQL is the canonical database contract; hosting is replaceable through
DATABASE_URL. - Neon is the current zero-cost Phase 1 PostgreSQL host; it is infrastructure, not a product dependency.
- Cloudflare is edge/runtime/cache/protection. Hyperdrive is configured only when justified by the deployment path.
- Provider adapters feed immutable raw observations, normalization, quality gates, candle construction, and derived-series calculation.
- UTC canonical storage; Asia/Tehran presentation.
- No UI timeframe may imply precision not supported by observed source cadence.
Completed
- Phase 0 foundation and provider-neutral PostgreSQL schema merged.
- Canonical instruments, raw observations, ticks, candles, derived values, quality events, workspaces and drawings schema defined.
- Deterministic theoretical 18K gold and premium calculations implemented.
- Timestamp alignment, staleness, provider normalization and provider health implemented.
- Deterministic multi-timeframe candle builder implemented with no synthetic gap filling.
- Numeric quality scoring and propagation into candles/derived data implemented.
- GOOD / DEGRADED / STALE / INVALID quality classification implemented.
- Provider-neutral ingestion and derived-gold pipeline implemented.
- Navasan adapters implemented for USD_IRT_FREE and GOLD18_IRT, including IRR→IRT normalization and historical daily OHLC parsing.
- Alpha Vantage XAU/USD spot adapter implemented.
- Data Proof metrics and aggregate evidence artifact implemented for cadence, freshness, gaps, duplicates and out-of-order observations.
- Market calendar, price-spike detection, provider failure/recovery state machine and persistence hardening implemented.
- Provider source matrix documented, including unresolved domestic redundancy risk.
- PostgreSQL 18 persistence invariants execute successfully in CI.
- Reachable Neon PostgreSQL provisioned for VELYQOR.
- All three database migrations executed successfully against live Neon PostgreSQL.
- Both SQL invariant suites executed successfully against live Neon PostgreSQL.
- Live database proof recorded in
docs/data/phase1-live-postgres-proof.md. - Domain regression suite passes: 66/66 tests.
In progress
- Live Data Proof for USD_IRT_FREE, GOLD18_IRT and XAU_USD.
- Secondary legally usable Iranian source research for cross-check/failover.
External blockers
NAVASAN_API_KEYis not connected to the runtime, so live USD_IRT_FREE and GOLD18_IRT cadence/quota/freshness proof cannot yet execute.ALPHAVANTAGE_API_KEYis not connected to the runtime, so live XAU_USD proof cannot yet execute.- Cloudflare Hyperdrive is not configured yet. The Cloudflare account currently has zero Hyperdrive configs, and creating one requires the live database credential to be entered through a secure channel without exposing it in repository history or chat.
Phase 1 exit gates
- PostgreSQL migrations and invariants execute successfully against a live reachable PostgreSQL instance. PASS
- USD_IRT_FREE, GOLD18_IRT and XAU_USD each have a live tested ingestion path. BLOCKED — provider credentials
- Observed cadence, latency, gaps, duplicates, out-of-order behavior and failure/recovery are recorded for each source. BLOCKED — provider credentials
- Candle construction is deterministic and never invents missing observations. PASS
- Quality state/score propagates into candles and derived values. PASS
- At least one secondary legally usable reference is identified for Iranian market cross-check, or the lack of one is explicitly accepted as a launch risk. PASS as documented unresolved launch risk
- Secrets are runtime-only and absent from the repository. PASS
- CI is green for all Phase 1 domain behavior. PASS
- Cloudflare Hyperdrive is configured against the reachable PostgreSQL endpoint. BLOCKED — secure database credential handoff
Risks
- Iranian market-data licensing, timestamp quality, anti-bot restrictions, history and reliability.
- Free source cadence may be insufficient for intraday timeframes; unsupported timeframes must stay disabled.
- The current domestic-source stack does not yet have a second zero-cost legally usable failover source.
- Free database hosting is temporary infrastructure and must not become a product dependency.
Next checkpoint
Securely connect the Navasan and Alpha Vantage runtime credentials and the Neon database credential to Cloudflare Hyperdrive without committing or exposing secrets; execute continuous live Data Proof for all three required instruments; record provider and Hyperdrive evidence; then close Phase 1 only if all external gates pass.
Handoff update — 2026-10-11: ECB history and direct-Neon work
- Verified in production Neon: 762 licensed ECB EXR daily reference observations in
market_ticks, 254 per EUR_USD_ECB/EUR_GBP_ECB/EUR_CHF_ECB, 2025-10-13 to 2026-10-09; 0 invalid/duplicate checks. Thecandlestable remains empty. The 2026-10-11 importer--commitreported 0 new rows; do not attribute prior inserts to this run. - Verified deployed: existing
/api/historyretrieves 254-row annual observations through Cloudflare KV and line-chart UI; live smoke also passed domestic, widget, and Scriptable routes. This is not yet a live PostgreSQL read. - Implemented in isolated GitHub branch, not deployed: bounded/parameterized Neon-first API with KV fallback, 9 passing Worker history unit tests and syntax check.
- Security blocker: SQL-created
chartnova_history_rohas read access exclusively to the ECB history view but is NOLOGIN awaiting secure credential activation. An API-createdchartnova_history_readerunexpectedly inherited privilegedneon_superusermembership and must not be used; deletion was completed and confirmed absent in pg_roles after user approval. Safe Cloudflare secret handoff was blocked, andCHARTNOVA_HISTORY_DATABASE_URLis absent. - Next checkpoint: secure least-privilege role credential through approved dashboard, complete API+UI integration and live test on a reviewed Worker deployment, then continue seeking explicitly licensed OHLC sources. Details and rollback are in
docs/data/neon-history-direct-handoff-2026-10-11.md.
2026-10-11 — Security cleanup verified
With explicit user approval, the unused overprivileged Neon role chartnova_history_reader was deleted. Independent queries confirm 0 remaining matches, chartnova_history_ro still present with read access only to the ECB view and NOLOGIN, and ECB history remains 762 observations (254 per symbol). No deployed Worker secret or application code was changed. Pre-delete role configuration and post-delete evidence: docs/security/neon-history-reader-predelete-2026-10-11.md.
2026-10-11 — OHLC license gate, secure historical API and chart provenance (isolated branch)
- Added
packages/market-domain/src/licensed-ohlc-history.mjs: strict source-OHLC-only staging validation; explicit human-reviewed licensing metadata, commercial-storage/public-redistribution rights, exact base-ten IRR→IRT normalization for declared pairs, UTC offsets + IANA session zone, no invented volume/candles, duplicate and missing-session diagnostics, and strict annual-publication readiness gate. The gate verifies claims in a license manifest, not the authenticity of any signed agreement. - Added regression tests
licensed-ohlc-history.test.mjsandlicensed-ohlc-release.test.mjs. Domain suite 85/85 PASS. - Tightened
GET /api/historyinput (duplicates/empty dates), cached public-response allowlist, non-empty series gate. Addeddeploy/chartnova/history-security.test.mjs. - Synced
deploy/chartnova/history-ui.jsinto embedded Worker UI, removed hard-coded KV provenance, and addedhistory-ui-sync.test.mjs. Worker/history 14/14 PASS, Worker syntax PASS. None of these changes are deployed to Production. - Independent read-only audit of user's uncommitted
db/migrations/0005_navasan_private_daily_ohlc.sqlfound a raw currency unit discrepancy: the proposed SQL claims IRT, whereas committed Navasan adapter interprets IRR and divides by ten. Migration remains unexecuted and user's uncommitted files untouched. Must verify provider units and licensing before any import. - Source guide from Navasan documents
ohlcSearchbut not definitive commercial redistribution terms. No Navasan/TGJU/OHLC records were written to Neon.candlesremains 0 and licensed ECB remains 762 reference points. chartnova_history_roremains a database NOLOGIN role; Worker has no direct Neon secret binding. Manual secure activation and live integration tests are required; only the existing KV-based reference chart is live.- Evidence and remaining gates:
docs/data/ohlc-licensing-and-ingestion-gate.md,docs/data/neon-history-direct-handoff-2026-10-11.md.
2026-10-11 — CI gate remains RED (independent verification)
- GitHub Actions run
38172295674on PR #23 / head7d0912e1e7777cea882ddc70e49d2f6d3932dc9fwas reported completed / failure in both jobs:verifyandpostgres-invariants. The workflow-job log downloads returned GitHub 404BlobNotFoundand step summaries were empty; the precise failure cause could not be verified. - Local isolated-worktree results remain 85/85 domain and 14/14 Worker/history PASS, with Worker syntax PASS. These results do not replace a green remote CI.
- The connected Windows device has Corepack-managed
pnpm 10.17.1but no standalonepnpmon PATH, socorepack pnpm verifystopped when its nestedpnpmcommand was unavailable. The device has no availablepsqlordockerCLI for locally reproducing the PostgreSQL CI job. Do not treat this as a proven application defect or green full verify. - Release gate: keep PR #23 draft and do not merge/deploy on the strength of local tests; recover CI logs or reproducible runner diagnostics and resolve both jobs first. GitHub run: https://github.com/davoodmehraban89/VELYQOR/actions/runs/38172295674
2026-10-12 — requested multi-market REST/WS/Canvas foundation (isolated branch)
- User requested React + TradingView Lightweight Charts v5 (Canvas), bounded REST historical APIs, WebSocket live architecture, and candidates CoinGecko, Binance, yfinance, Polygon, Navasan and Bonbast. Original local Git worktree, ECB history and deployed Market/Widget APIs left unchanged.
- Branch
feature/chartnova-multimarket-chart-ws-foundationis based onfeature/chartnova-neon-direct-history, separate frommainand not deployed. - Added
packages/market-feedcanonical reference-point vs source-OHLC contracts; CoinGecko point adapter + bounded hourly query-window planner; Binance spot-kline adapter; yfinance research-only adapter; provider registry; versioned WS subscription/sequence guard; and/api/v2/historybounded/paginated REST repository-port handler (unmounted; fails closed if no licensed repository). - Added standalone
packages/chart-uiReact/TypeScript Lightweight Charts v5 component. Candles render only forsource_ohlc; ECB and CoinGecko price points use a line. The component expects a future React/Next.js host and already links TradingView. Installed its isolated package's dependencies only in an isolated test worktree; did not change the existing user's app. - Added
deploy/chartnova/realtime-gateway.mjsCloudflare Durable Object WebSocket gateway scaffold with subscription allowlist/limits and authenticated private publisher, plus a non-deployed Wrangler example. No live feed publishers, durable object instance, Cloudflare secret or public WebSocket deployment exist. - Reference documentation:
docs/architecture/ADR-0004-multimarket-rest-ws-charts.md;docs/data/multimarket-provider-matrix.md. - Local verification on an isolated worktree: 30/30 market-feed tests PASS, 115/115 total domain+market-feed tests PASS, new WebSocket gateway
node --checkPASS and client charttsc --noEmitPASS. These are pure behavior tests / type validation; provider availability, live WebSocket latency, DB I/O and license entitlement have NOT been proved. - Important guardrails: CoinGecko
market_chartonly produces price points, not OHLC; annual hourly planning ≠ Demo-tier entitlement. Binance API previously geoblocked (451). yfinance is research/personal-data-use only absent licensing. Navasan OHLC requires commercial rights and independent IRR/IRT/quote-side verification; Bonbast developer contract/API schema unavailable; Polygon WS plan not provisioned. - Neon production remained 762 ECB reference observations and zero OHLC candles at the last direct verification; no imports were triggered by this work. Existing
chartnova_history_rois still NOLOGIN, so direct read-only Neon Worker history is not activated. - Next checkpoint: written redistribution rights + provider keys via secure server-side secret manager; select initial requested instruments and quote-side/currency conventions; integrate a real React host and licensed read-only Neon repository; deploy a staging WS gateway under explicit authorization; run integration/latency/quota/staleness/reconnection/rollback tests and obtain green CI before public release.
2026-10-12 — Remote CI release gate (latest run)
- Draft PR #24: https://github.com/davoodmehraban89/VELYQOR/pull/24
- GitHub Actions run 38174358477 (CI #76) reported failure in BOTH
postgres-invariantsandverifyjobs. Download of either job log via GitHub API returned404 BlobNotFound; no reliable error stack/root cause could be established. This is an unresolved release blocker. - Despite standalone 115/115 local tests, gateway syntax and chart TypeScript checks passing, remote CI is NOT green. Do not deploy or merge as production-ready until remote CI is diagnosable/green and actual licensed sources are connected.
- Production database check:
chartnova_history_public762 reference observations;candles0 OHLC; restricted role exists and removed overprivileged role remains absent.
2026-10-12 — Standalone ChartNova terminal and REST/WS compatibility verified locally
- Added runnable
apps/market-terminalReact + Lightweight Charts v5 app, pinned npm lockfile, Vite development proxy to existing ECB REST, and visible TradingView attribution. Built twice with a cleannpm cifrom isolated Git worktree; finalnpm run buildPASS. - Selected
deploy/chartnova/market-stream-worker.mjsand its matching per-symbol DO binding template as the single future WebSocket deployment candidate.realtime-gateway.mjsremains a non-deployed alternative with a different protocol and must not be pointed at the React client without a deliberate conversion. - REST→chart integration tests now cover
serveHistoryV2consuming genuinetime/pricepoints and source OHLC into Lightweight Charts without accidental format mismatches; provider-neutral REST returns publicrightsattestation only after server license checks. WebSocket UI refetches history on sequence gaps/reconnect. Updated versioned data source adapter accordingly. - Selected gateway hardened with origin allowlist, bounded streamed request payload and per-symbol connection limits; still requires Cloudflare Access/WAF/rate limits and real E2E before any publication.
- Final local
npm test: 117/117 PASS; gateway syntax PASS;npm ci && npm run buildPASS.scripts/research-yfinance.pynot runtime-tested because no Windows Python installation. - Release remains blocked: GitHub CI remote still RED, no privileged DB credentials used, no DO deployed, no paid plan authorized, no licensed OHLC backfilled, no live WSS source established. Neon 762 ECB points and zero candles preserved. Full handoff:
docs/operations/chartnova-multimarket-checkpoint-2026-10-12.md.
2026-10-12 — Restricted Neon v2 query + WS room load-shedding (review branch)
- Added
packages/market-feed/src/neon-ecb-history.mjswith a parameterized ECB-only read adapter using the existingpublic.chartnova_history_publicview and accepting onlychartnova_history_rocredentials server-side. A newGET /api/v2/historyroute is mounted in the feature branch's Worker source only; without the optional Cloudflare secret it fails closed with 503. Live Worker remains unchanged and retains its verified KV-backed/api/history. - New server/adapter tests verify cursor and limit, exact ECB provenance, no secret leaks, zero OHLC misclassification; no live direct Neon connection yet. New WebSocket Durable Object tests verify monotonic sequence, room authorization and slow-client disconnect after >1 MiB outgoing buffer; no deployed DO yet.
- Latest isolated local checks: 126/126 domain+feed tests, 18/18 Worker/history tests, both Worker syntax checks and standalone React production build PASS.
- Real Neon still has 762 ECB reference points, 0 OHLC candles;
chartnova_history_roremains NOLOGIN, former privileged reader absent. Cloudflare bindings still only MARKET_CACHE, NAVASAN_API_KEY, OANOR_API_KEY. - PR #24 remains draft and GitHub CI RED: run 38197941929 (#93) reported both
verifyandpostgres-invariantsfailing. The job logs return 404 BlobNotFound, so no root cause is verified. No provider permissions, staging deployment, paid Cloudflare Durable Objects, or production publication approved or attempted. - Full handoff:
docs/operations/chartnova-neon-v2-ws-quality-2026-10-12.md.
2026-10-12 — CI pre-run diagnosis and real local WebSocket smoke
- GitHub Actions run 38198123692 (#95) was inspected via raw GitHub REST jobs endpoint, not merely summarized status: both
verifyandpostgres-invariantshadrunner_name="",steps=[], and completed in about 3 seconds. Therefore the tests never started; do not claim application/SQL failure or CI success. The reason for runner non-allocation remains unknown. Seedocs/operations/github-actions-pre-run-failure-2026-10-12.md. - Wrangler 4.149.0 successfully compiled the selected DO Worker through
deploy --dry-run, showing expected DO and environment bindings; no deploy happened. - Real localhost-only WSS smoke passed: HTTP 101 WebSocket handshake,
stream.subscribe→session.ready, test-only private publisher HTTP 200,market.updatedelivered to 1 client with monotonicsequence=1. The event contained fictional TEST-ONLY values, never persisted to Neon or production systems. Local Worker and childworkerdprocess were stopped. - Repeatable smoke script:
scripts/smoke-local-stream.mjs. Evidence:docs/operations/chartnova-ci-local-ws-smoke-2026-10-12.md. - No live provider entitlement, operational secret, production DO, public market data, or code deployment has been enabled. Existing dirty Windows worktree stays untouched. PR #24 remains Draft, blocked on runner allocation, security and data licenses.