Intelligence, Advanced Charting & Trading Platform
risk/chartnova-alert-runtime-atomic-2026-10-22
VELYQOR Project State
2026-10-23 — fail-closed authorization review of Draft PR #35
- Corrected egress authorization:
alert_notification_egress_allowednow requires the database row'ssend_started_atto be set by the atomic single-usealert_notification_begin_egresspermit, so an unconsumed lease cannot be interpreted as authorization to send. PostgreSQL regressions cover denied before permit, permitted after first consumption, denied repeated permits and consent revocation. - Corrected rights provenance: the server-only
evaluateAndPersistAlertno longer trustsobservation.permissionas proof of a vendor contract. A mandatory, separately injected trustedsourceRightscallback must confirm exact provider/symbol/unit/side, dated evidence reference, effective/expiry dates, and public display + derived alerts + historical storage entitlements. Missing, expired, mismatched or unreachable registry fails closed before any PostgreSQL state query. Synthetic test grants are NOT legal permissions for any live source. - Both changes are Draft only in PR #35, with negative/mock and exact pinned PR #33 tests. No real contract registry, authenticated runtime DB role or approved outbound bot credentials exist. Production alert delivery remains تأییدنشده.
- PR #33 (domain), #34 (outbox) and #35 (integration) remain unmerged. No Cloudflare or Neon production operation authorized or performed by this security review. Cloudflare connector is not currently available to independently reconfirm live Worker status; prior v26 observation is historical.
2026-10-22 — stacked rule-state → durable outbox bridge (Draft PR #35)
- Draft PR #35 is based on unmerged PR #34, not on production or
main. It introduces0006_alert_runtime_atomic.sql, versioned per-user alert state, opaque recipient consent proof and one PostgreSQL CAS function committing a trigger plus outbox entry atomically. - The new
alert-postgres-coordinator.mjsbridges PR #33's actual pure data-quality gate and alert engine to PR #34's PostgreSQL contract with source/instrument/BUY/SELL identity validation, non-advisory labels and bounded retry. Historical data storage permission is mandatory; public display/alert rights alone are insufficient for persisting trailing/price state. - Independent disposable PostgreSQL tests check revoked/missing consent, stale revision, suspended quality data, exactly one event after concurrent claims and no public SQL role grants. GitHub CI separately checks source-pinned PR #33 modules at immutable commit
52ebe040d661d67d447d20afe5f49769ec7a095b. - An additional claim-time opt-in gate (
alert_notification_claim_consented) refuses revoked recipients, terminally suppresses unsent revoked entries and scans at most 16 pending rows to prevent one revoked user starving others. A future sender must recheck consent immediately before outbound HTTP, and least-privilege DB roles remain unimplemented. - Additional review-only safety checks: a single-use PostgreSQL
send_started_atpermit prevents parallel duplicate sends under one claim,alert_notification_egress_allowedrechecks consent at the final network boundary, andleased-bale-dispatch.mjsrequires a trusted opaque recipient resolver and binds the destination/channel in SQL. CI tests the real pinned PR #33 Bale adapter exclusively with a mock transport and checks two concurrent PostgreSQL send-permit attempts. No real delivery, secret, or third-party account was used. - Live Neon, Cloudflare, market providers and any real Bale recipient untouched. Migration
0005_navasan_private_daily_ohlc.sqlremains blocked and untouched. No Merge, Deploy, secret access, paid subscription, recipient message or real-money trade executed. - Still not complete: actual server-side authentication, least-privilege service DB role, source rights contracts, private recipient registry and delivery, device-specific v26/v27 incident, cross-PR reconciliation and independent human/AI security review. Three CI perspectives are not three independent agents.
- Implementation/evidence and release gates.
2026-10-22 — Atomic notification outbox review only, Draft PR #34
- Draft PR #34 starts independently from `main` at `4649149b1f920aecbe4c26597983d9bb35d90427`. It provides proposed `db/migrations/0004_notification_outbox.sql`, a SQL invariant test and an actual two-client PostgreSQL race test in an isolated GitHub CI job. This is NOT a live database migration or deployed feature.
- The SQL uses a unique per-user/event/channel/opaque-recipient key, transactional `FOR UPDATE SKIP LOCKED` claims, random lease tokens, capped attempts, and terminal UNKNOWN for ambiguous or expired in-flight sends. SQL permissions default to no public access; there is no bot token, chat ID, order API, or message body in the schema.
- Concurrency test run 39843468112, job 120050433647, passed on a temporary local PostgreSQL 18 GitHub Action: concurrent enqueue returned the same ID and one row, locked claim was skipped by another connection, no subsequent duplicate claim, and attempt count stayed one. Original main CI `postgres-invariants` applied 0001–0004 on ephemeral PostgreSQL and succeeded.
- Limits: no real Neon changes; service principal, RLS/tenant authorization, provider rights, recipient mapping, alert-to-outbox integration, real Bale send and verified user ACK remain تأییدنشده. No claim of exactly-once delivery. Three independent human/AI reviewers remain unavailable/not completed; three CI perspectives do not substitute.
- Protected: `db/migrations/0005_navasan_private_daily_ohlc.sql` is neither modified nor executed; user untracked worktrees are untouched. Draft PR #33 remains unmerged. No production Merge, Deploy, deletion, external message, secret access or financial order.
- Next release gates: successful exact-head CI, approved runtime authentication and migration strategy, actual valid data rights, and separate explicit approval before any Neon/schema or production Worker changes. Full threat model and remaining gaps.
Latest Stage-1 checkpoint — 2026-10-15 (DOC-ONLY / not yet merged)
Review base: main 381ba284d47f284f034afacc7d6cc41fc31af8f9. This heading supersedes all time-specific "current production" claims below without falsifying the historical events.
- Production runtime last RECORDED, not live-rechecked in this documentation stage: Cloudflare Worker v26 version ID 85177f9d-09c0-4763-b28c-2c6ba5ae5be5, 100%; rollback deployment ID 78155d6f-11fc-4d1b-ab4f-7c0a97474406 (2026-10-15 05:59 UTC). The prior v27 release 2cbeb4e2-4a3e-414f-b3ad-035e2378650b had been activated, then rolled back after the user reported the site would not open. The technical root cause is تأییدنشده. See exact evidence and incident timeline, versioned manifest, rollback-branch record. Current live version at this exact moment: تأییدنشده, because Stage 1 made no Cloudflare inspection.
- Repository: PR #29 was merged previously; its reviewed scripts/tests/docs do not provide an exact verified complete deployed Worker source for v26. PR #29 cannot be "merged again". The stale v27 heading below is retained solely as an archival account.
- PR inventory checked via GitHub (before creating Stage-1 documentation PR): 7 OPEN: #21, #22, Draft #23 → Draft #24 → Draft #27, Draft #28, Draft #30. PR #25 and #26 had already merged. Old PR inventory and old source-secret blocker paragraphs below are historical, not current authorization. Draft PR #31 is the new documentation-only review, so the open PR count became 8 at its creation; no merge or deploy was performed.
- Provider/quote integrity: Old development plans Navasan and Alpha Vantage, while later PR/deployment records mention Gheymat Online, Oanor/TGJU UI label and Gold API. Exact production mapping, quote side, commercial redistribution/storage rights and time-bounded latency are تأییدنشده. No OHLC source is promoted to production by this docs PR. Official provider matrix.
- Free service level: Official Navasan 120/month, 2h vendor updates → sustainable 30-day one-call interval 6 hours minimum; Gheymat Online 250/day → 5m45.6s minimum for one request per snapshot. Neither can guarantee threshold-alert delivery latency. Not acceptable as a time-critical day-trader alert SLA; only optional non-urgent informational pilot after license/semantics verification. Full assumptions and alternate k=2 model.
- Next implementation proposal (NOT authorized here): one USD_IRT_FREE source, one ABOVE/BELOW informational alert, one opted-in Bale Bot notification channel, quote labeled «قیمت فروش منبع X» only after provider-side SELL verification, otherwise alerts disabled. Gated minimal vertical slice. Additional ATR/OCO/Trailing, failover and Paper Trading explicitly follow actual pilot evidence.
- Security/no-change guarantees: No merge, production Worker deploy, DNS/Cloudflare config, Neon/KV mutation, paid resource, API-key access, real trade or local Worktree action in Stage 1. Untracked db/migrations/0005_navasan_private_daily_ohlc.sql stays blocked; most recent local worktree audit (2026-10-12) remains historical; present state تأییدنشده. Evidence index A–H.
- Open acceptance gates: current deployed-v26 versioned code source/hash, affected-device outage reproduction, written provider rights, exact quote side/unit, real-source cadence, actual quota consumption, and delivery-channel proof. Not complete.
Historical 2026-10-15 — ChartNova v27 performance hotfix (deployed then ROLLED BACK)
- User request: fix delayed/blank-to-loaded ChartNova initial data, prioritizing visible quote cards and avoiding unnecessary waiting.
- Actual live Worker fixed:
velyqor-previewCloudflare v272cbeb4e2-4a3e-414f-b3ad-035e2378650b, deploymentc68b8340-398a-462b-9fe0-c635aba405fe, rolled out at 100% on2026-10-15T05:22:32Z. Original v2685177f9d-09c0-4763-b28c-2c6ba5ae5be5is retained for immediate rollback. - Change scope: only production homepage inline JavaScript; progressive main-card render; explicit partial loading; lazy hidden market/technical rendering and de-duplicated refresh. No change to API response contracts, data prices/units, provider licensing, KV namespace, secrets, cron, DNS, database, trades or Worktrees.
- Verification: 4/4 isolated JS patch tests passed. Staged mobile browser found 58/58 cards and working technical chart; quotes exactly matched previous production and no JS/network failures. Under intentionally delayed 10-second
/api/markets, main USD/Gold cards and partial status appeared before the slow feed finished. Following deployment, public/,/api/domestic,/api/markets(58),/api/xau,/api/widgetall responded successfully. - Risk controls: Cloudflare API verified full binding/handler parity between versions. No secret values were read. Keep old version for one-step rollback if post-deploy errors appear. User's actual device experience still requires confirmation.
- Traceability: PR #29 and operations/rollback guide. GitHub
mainwas not changed during the direct Cloudflare rollout; PR #29 is reviewed independently. - Not completed: universal network speed guarantee; shrink of 85KB full market-history payload; new Paper Trading live deployment; Neon/WS real trading/feeds. These are separate staged milestones.
Last updated: 2026-10-07
Last checked (GitHub-only): 2026-10-14
IMPORTANT — review-branch status overlay (not yet merged into main). The detailed sections below preserve the 2026-10-07 Phase-1 baseline. Its claims about disconnected provider keys and CI do not reflect a 2026-10-14 live runtime revalidation. Cloudflare previously exposed a
NAVASAN_API_KEYsecret name (not a verified end-to-end data proof); the current connected secret values were not read.
Current safety checkpoint — 2026-10-14
- Working source of truth remains
mainat29a45cff094658c7a2722fa6fa712bef061abb8cuntil explicitly merged; review branch:safety/p0-triage-2026-10-13. - Open PRs #21, #22, #23, #24, #25, and #26. PR #23 is based on the history feature branch; PR #24 is based on #23. PR #25 and #26 are isolated reviews from
main. - GitHub CI: #21, #22, #23 succeeded on second attempts 2026-10-14; #24 succeeded on its latest verified attempt 2026-10-12; #25 and #26 succeeded on 2026-10-14. A green CI does not establish data licensing, provider uptime, a real production Neon→Worker connection, or deployed streaming.
- P0 PROTECT: last verified Windows evidence included 9 tracked modifications, 1085 untracked paths and 5 worktrees. Desktop Commander was offline on 2026-10-14. No cleaning, overwriting or migration applied.
- P0 BLOCK_IMPORT: untracked
db/migrations/0005_navasan_private_daily_ohlc.sqlconflicts with existing adapter IRR→IRT assumptions. No import or migration before source-confirmed units/quote side, rights and reviewed dry-run. - P0 BLOCK_REDISTRIBUTION: commercial source-OHLC storage and public redistribution rights remain unverified. ECB observations are reference points, not OHLC candles.
- P0 NO_LIVE_ORDERS: AI/signals cannot place live orders; independent order/risk controls and separate approval are required before any trading layer.
- Next actions: review independent #21/#22/#25/#26 for prospective merges; preserve #23/#24 as Draft until dependency, license, Neon reader, staging and end-to-end gates pass; verify Windows and provider documentation when available.
- Auditable details and ownership: P0 triage, release safety gates, PR readiness.
- Status of this checkpoint: documentation and CI pass on review branches; no merge to
main, no operational deployment, no credential changes, no trade.
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.