Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
61a1333
Merge branch 'dev' into feature/step-2.11-mumbai-coverage-audit
harshada2576 Oct 3, 2026
877a662
Merge pull request #4 from harshada2576/feature/step-2.11-mumbai-cove…
harshada2576 Oct 3, 2026
9101eaa
Merge feature/phase-3-complete into dev (PR #5)
harshada2576 Oct 4, 2026
23d0cb8
Merge pull request #8 from harshada2576/main
harshada2576 Oct 11, 2026
8c93427
feat(ingestion,ml,cpo): secondary sources, Phase 5 ML runtime, OCPI/O…
harshada2576 Oct 11, 2026
8f8b6b8
Merge remote-tracking branch origin/dev into dev
harshada2576 Oct 11, 2026
fd8d2b5
fix(ingestion): handle offline database fallback gracefully in dry-ru…
harshada2576 Oct 11, 2026
6eff3e2
feat(mining): add DBSCAN spatial density clustering and coverage gap …
harshada2576 Oct 11, 2026
1bc1b9c
test(mining): add unit tests for DBSCAN haversine clustering and cove…
harshada2576 Oct 11, 2026
6bf4873
docs(ml): document DBSCAN spatial density clustering and coverage gap…
harshada2576 Oct 11, 2026
957310e
docs(readme): update test suite counts, commands, and completed phase…
harshada2576 Oct 11, 2026
25e8612
docs(memory): record completion, repair, and release assurance missio…
harshada2576 Oct 11, 2026
5b41520
fix: wire OTP simulator into LoginClient and VerifyClient
harshada2576 Oct 12, 2026
63df887
feat: complete demo data reconciliation, provenance isolation, fronte…
harshada2576 Oct 18, 2026
b4f80c5
feat: integrate real MMR dataset, stations and weather APIs, and upda…
harshada2576 Oct 21, 2026
ba0c612
feat(intelligence): complete station intelligence UI, spatial mining,…
harshada2576 Oct 21, 2026
32e417b
fix(intelligence,map): fix coverage gaps property access and omit Map…
harshada2576 Oct 21, 2026
4ab2b54
fix(scope): adopt nationwide India OCM snapshot scope, refine isolati…
harshada2576 Oct 21, 2026
5912679
fix(acceptance): reconcile isolation contract, sanitize spatial API, …
harshada2576 Oct 21, 2026
ed8250b
fix(ci): repair migration test, lint effect, spatial docs, and ml api…
harshada2576 Oct 21, 2026
e525404
docs: update README test verification counts to reflect full test suites
harshada2576 Oct 21, 2026
c05acf4
docs: finalize academic OLAP SQL suite, update warehouse docs, and po…
harshada2576 Oct 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
# be prefixed with NEXT_PUBLIC_ or imported into browser-executed components.
# ==============================================================================

# ------------------------------------------------------------------------------
# 0. OPERATIONAL MODE (DEMO vs PRODUCTION)
# ------------------------------------------------------------------------------
# Set to "true" to run in offline Demo Mode using verified local seed fixtures
# without requiring an external Supabase cloud project or third-party SMS delivery.
# In production, set to "false" (or leave unset); production fails closed if
# cloud credentials or database connections are unconfigured.
NEXT_PUBLIC_DEMO_MODE="false"

# ------------------------------------------------------------------------------
# 1. PUBLIC-SAFE CLIENT CREDENTIALS (EXPOSED TO BROWSER)
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -58,3 +67,53 @@ SUPABASE_SERVICE_ROLE_KEY="your-supabase-service-role-key"
# NEVER expose to client components or commit real keys to Git.
OPENCHARGEMAP_API_KEY="your-openchargemap-api-key"

# OpenStreetMap Overpass endpoint (secondary source: OSM community inventory)
# Used exclusively by server-side Python ingestion (backend/ingestion/adapters/osm.py).
# Default points at public Overpass infrastructure; override only with an approved
# endpoint or regional mirror. Bounding-box queries only — global extracts prohibited.
# OSM is manual/dry-run until validated; it is NOT cron-scheduled by default.
OSM_OVERPASS_ENDPOINT="https://overpass-api.de/api/interpreter"

# data.gov.in Open Government Data API key (secondary source: government registry)
# Used exclusively by server-side Python ingestion (backend/ingestion/adapters/datagovin.py).
# Register at https://data.gov.in to obtain a key. NEVER commit real keys to Git.
# Manual/dry-run until validated; NOT cron-scheduled by default.
DATAGOVIN_API_KEY="your-datagovin-api-key"

# data.gov.in dataset resource identifier for the verified EV-charging dataset.
# Resource IDs change over time — verify at https://data.gov.in before use.
# Until a verified ID is configured, the adapter fails closed with a clear
# BLOCKED_EXTERNAL_DEPENDENCY error and ingests nothing.
DATAGOVIN_RESOURCE_ID=""

# ------------------------------------------------------------------------------
# 5. ML TRAINING & INFERENCE (SERVER-ONLY / PYTHON)
# ------------------------------------------------------------------------------
# Model artifact directory (file-based approved-model registry root).
# Served only by server-side Python (backend/ml) and the /api/ml/* routes.
# NEVER expose artifact bytes, registry credentials, or control tables to clients.
ML_ARTIFACT_DIR="backend/ml/artifacts"

# Python executable used by the /api/ml/predict route to invoke the inference CLI.
# Defaults to "python" on Windows, "python3" elsewhere when unset.
# PYTHON_BIN="python3"

# ------------------------------------------------------------------------------
# 6. CPO PARTNER INTEGRATIONS — OCPI 2.2.1 / OICP 2.3 (SERVER-ONLY)
# ------------------------------------------------------------------------------
# One variable group per partner+environment. Prefix pattern:
# {PROTOCOL}_{PARTNER}_{ENV} (e.g. OCPI_TATAPOWER_SANDBOX, OICP_HUBJECT_PROD)
# Required per group: _ENDPOINT (partner interface base URL), _TOKEN (credential).
# Optional per group: _TOKEN_EXPIRES_AT (ISO-8601), _COUNTRY_CODE/_PARTY_ID
# (expected OCPI party scope; enforced as partner isolation).
#
# Every partner starts NOT_CONFIGURED. Sandbox and production credentials must
# differ — never reuse a sandbox token in production. See docs/cpo_partners.md
# for the activation checklist. NEVER commit real credentials.
#
# OCPI_TATAPOWER_SANDBOX_ENDPOINT="https://sandbox.example-cpo.com/ocpi"
# OCPI_TATAPOWER_SANDBOX_TOKEN="sandbox-token-from-partner"
# OCPI_TATAPOWER_SANDBOX_TOKEN_EXPIRES_AT=""
# OCPI_TATAPOWER_SANDBOX_COUNTRY_CODE="IN"
# OCPI_TATAPOWER_SANDBOX_PARTY_ID="TAT"

6 changes: 6 additions & 0 deletions .github/workflows/scheduled_ingestion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ jobs:
DATABASE_URL: ${{ secrets.STAGING_DATABASE_URL }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.STAGING_SUPABASE_SERVICE_ROLE_KEY }}
OPENCHARGEMAP_API_KEY: ${{ secrets.STAGING_OPENCHARGEMAP_API_KEY }}
# Secondary sources stay manual/dry-run until validated; the runner
# refuses unattended non-dry-run scheduling for them. Passed through
# so authorized manual workflow_dispatch runs can use them.
OSM_OVERPASS_ENDPOINT: ${{ secrets.STAGING_OSM_OVERPASS_ENDPOINT }}
DATAGOVIN_API_KEY: ${{ secrets.STAGING_DATAGOVIN_API_KEY }}
DATAGOVIN_RESOURCE_ID: ${{ vars.STAGING_DATAGOVIN_RESOURCE_ID }}
run: |
EXTRA_ARGS=""
DRY_RUN="${{ inputs.dry_run }}"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Thumbs.db
npm-debug.log*
yarn-debug.log*
yarn-error.log*
scratch/

# IDE / Editor configuration
.idea/
Expand Down
30 changes: 30 additions & 0 deletions Must Read/Memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -771,3 +771,33 @@ Every entry should include:




### 11 Oct 2026 - Secondary sources + Phase 5 ML + CPO integrations (completion mission)
- Phase / Step: Mission completion (secondary ingestion, Phase 5 ML, OCPI/OICP)
- What we built/changed: OSM Overpass + data.gov.in adapters through the canonical pipeline with shared retry/SSRF-hardened transport; multi-source runner (--source) + unattended-scheduling guard; ML gates/training/registry/inference/CLI + /api/ml/status + /api/ml/predict (no UI changes); OCPI 2.2.1 Locations + OICP 2.3 PullEVSEData subset with partner lifecycle, sync cursors, simulator; docs secondary_sources/phase5_ml/cpo_partners; env template + workflow least-privilege. No migrations, no Docker, no commits.
- Current state: pytest 603 passed + 2 skipped (7 pre-existing live-DB tests blocked: placeholder DB host); eslint clean; tsc clean on new files (pre-existing MapLibre + stale .next errors untouched); next build blocked by pre-existing maplibre-gl default-export drift. Production ML correctly disabled (COLD, NO_MODEL); all partners NOT_CONFIGURED; secondary sources manual/dry-run only.
- Post-script (merge 11 Oct 2026): remote dev had moved ahead (PR #8 incl. phase-6-production). Merged origin/dev into dev per owner direction: kept this mission's fail-closed ml/gates+registry+inference and test_phase5 (their weaker-gate variant + models.py removed as incompatible/unconsumed; their self-contained ml helper modules retained), adopted their workflow/warehouse/CI/tests. Merged tree: pytest 673 passed + 9 skipped, eslint clean, tsc zero source errors, next build SUCCESS (incl. /api/ml/*).
- Conceptual verification: unknown!=zero and missing!=free preserved in every adapter; STALE!=UNAVAILABLE; synthetic test data never promotable; partner isolation + credential redaction tested; no fabricated evidence anywhere.
- Blockers / waiting on: data.gov.in API key + verified resource ID; OSM approved endpoint + supervised first run; real observation history (>=500 obs / 5 stations / 30 days) for ML; bilateral CPO agreements + credentials for any partner (all external, precisely scoped in docs).
- Next step: Supervised secondary-source dry-runs; observation collection; partner onboarding per docs/cpo_partners.md.

### 11 Oct 2026 — Ultimate Repository Completion, Repair, Data Mining & Release Assurance Mission
- Phase / Step: All Phases / Release Assurance Audit & Verification
- What we built/changed:
1. Repaired `backend/ingestion/runner.py`: fixed dry-run database initialization to gracefully fall back to in-memory persistence service `IngestionPersistenceService(None)` when the configured `DATABASE_URL` is unreachable or a placeholder, allowing `--dry-run` to execute completely offline across all sources without crashes.
2. Implemented `backend/ml/spatial_clustering.py`: full DBSCAN density-based spatial clustering using true Haversine distance metric in kilometers on Earth's surface (spherical radius 6371.0088 km; zero naive Euclidean approximations), identifying station clusters, core centroids, bounding spans, and unclustered noise points. Built `find_coverage_gaps` computing nearest-neighbor distances in km to pinpoint geographically isolated stations and underserved areas.
3. Added `tests/test_spatial_clustering.py` (5 tests, 100% pass) verifying spatial cluster boundaries, zero-station edge cases, dense vs isolated geometry, and canonical Mumbai stations dataset.
4. Verified end-to-end pricing integrity (source -> adapter -> normalization -> DB views -> explore query -> UI components): confirmed missing prices remain `null`/`Price unavailable` and are never coerced to zero or free.
5. Verified all secondary sources (`open_charge_map`, `osm`, `datagovin`), multi-source runner dry-runs, and unattended scheduling guards.
6. Verified Kimball Star Schema data warehouse models, ETL pipelines, 24-rule data quality framework, and OLAP queries.
7. Verified ML maturity gates (fail-closed, COLD state when observations are 0, blocking models without real evidence), held-out evaluation baselines, artifact registry, and inference API.
8. Verified CPO OCPI 2.2.1 and OICP 2.3 frameworks, partner isolation, sync cursors, and simulator conformance suites.
- Current state:
- Python tests (`pytest`): 687 collected, 678 passed, 9 skipped (100% pass rate on runnable tests; all 9 skips strictly gated by live database target guard).
- Node tests (`npm test`): 135 collected, 134 passed, 1 skipped (live Supabase opt-in), 0 failed.
- TypeScript (`npm run typecheck`): 0 errors.
- ESLint (`npm run lint`): 0 errors.
- Next.js Production Build (`npm run build`): SUCCESS (all 23 app routes compiled and optimized).
- Conceptual verification: Hard 3-layer architecture strictly intact (public OLTP, analytics OLAP, ml metadata). Zero synthetic data manufactured in production. Unknowns preserved as NULL. Fail-safe token-bucket rate limits and structured JSON logs verified.
- Blockers / waiting on: External dashboard configurations (production domain cutover, SMS provider credentials, real partner sandbox credentials).
- Release Verdict: GO_FOR_CONTROLLED_BETA (subject to documented external credential provisioning).
37 changes: 33 additions & 4 deletions Must Read/Phases.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ We will also perform a conceptual check, not just a code check.

## Current status

- **Current Phase**: Phase 6/6 — Production & Public Beta
- **Current Phase**: Phase 7 — Final Integration, Data Reconciliation & Product Validation
- **Remaining Phases**: 0
- **Current Step**: Phase 6 VERIFIED COMPLETE — Ready for Controlled Public Beta (Final Environmental Verification Pending)
- **Current Step**: Phase 7 VERIFIED COMPLETE & SIGNED OFF
- **Phase 7**: COMPLETE — Mumbai Metropolitan Region demo dataset reconciliation (1,600 stations, 80,000 observations), strict live vs demo provenance isolation verified (`v_station_current_state`), progressive pagination & DOM optimization, weather telemetry, and multi-lingual dictionary completion (`docs/phase_7_final_integration_and_validation_report.md`).
- **Phase 6**: COMPLETE — Steps 6.1–6.13 implemented, hardened, and verified (`docs/production.md`)
- **Phase 5**: COMPLETE WITH DATA-DEPENDENT CAPABILITIES BLOCKED — Steps 5.1–5.11 verified
(`backend/ml/` methodology + `docs/phase_5_methodology.md`); no models trained, no predictions
Expand All @@ -185,6 +186,17 @@ We will also perform a conceptual check, not just a code check.
- **Phase 2**: COMPLETE & LIVE VERIFIED — Steps 2.1–2.12 verified (8 genuine MMR stations, 376 tests)
- **Phase 1**: COMPLETE & SIGNED OFF — Steps 1.1–1.10 verified (29 tables, RLS, PostGIS)

> **Dated note (11 Oct 2026) — completion mission, no phase rewritten:**
> Secondary-source ingestion (OSM Overpass + data.gov.in adapters through the
> canonical pipeline, manual/dry-run only), the Phase 5 ML runtime
> (gates/training/registry/inference + `/api/ml/*`, production inference
> fail-closed at COLD/NO_MODEL), and the CPO framework (OCPI 2.2.1 Locations
> + OICP 2.3 PullEVSEData subset, all partners NOT_CONFIGURED) are implemented
> and pytest-verified (603 passed). Phase 4 warehouse ETL, live secondary
> rollouts, real observation history for ML, and partner onboarding remain
> future/external work per `docs/secondary_sources.md`, `docs/phase5_ml.md`,
> and `docs/cpo_partners.md`. The roadmap steps above are unchanged.

### What is complete:
- **Phase 1 — Foundation & Real Database (Steps 1.1–1.10) — COMPLETE & SIGNED OFF**:
- 1.1 Create/configure Supabase project — COMPLETE
Expand Down Expand Up @@ -376,8 +388,25 @@ We will also perform a conceptual check, not just a code check.
- Is login requested only when needed? Yes (public browsing preserved, zero auth barriers for map and station detail).
- Does the existing UX remain intact? Yes (design tokens, layout, cards, sheets, and views strictly preserved).
### Current Phase Verdict:
- **Phase 7 — Final Integration, Data Reconciliation & Product Validation**: VERIFIED COMPLETE & SIGNED OFF.
- **Phase 6 — Production & Public Beta**: VERIFIED COMPLETE (Implementation complete, final environmental verification pending).
- All 6 phases of the ChargePlus build plan are complete.
- Operations runbook, backup/recovery, rate limiting, structured logging, CI/CD, and data quality suites are fully locked in `docs/production.md`.
- All phases of the ChargePlus build plan are complete.
- Operations runbook, backup/recovery, rate limiting, structured logging, CI/CD, and data quality suites are fully locked in `docs/production.md` and `docs/phase_7_final_integration_and_validation_report.md`.

---

# Phase 7 — Final Integration, Data Reconciliation & Product Validation
**Goal:** import synthetic Mumbai demo data for full spatial UX testing without compromising live operational telemetry, eliminate frontend bottlenecks, and complete end-to-end product verification.

### Steps
- 7.1 Dataset reconciliation — COMPLETE (137,641 inserted, 101 duplicate rows safely skipped via `ON CONFLICT DO NOTHING`)
- 7.2 Provenance & Live/Demo Isolation — COMPLETE (DB views prioritize `is_simulated = false`, `test_provenance_isolation.mjs` passing)
- 7.3 Frontend pagination & DOM optimization — COMPLETE (chunked PostgREST queries + progressive 30-card batching)
- 7.4 MapLibre GL GPU clustering & Demo badge — COMPLETE
- 7.5 Live Weather telemetry integration — COMPLETE (`/api/weather` Open-Meteo badge)
- 7.6 Admin console provenance splitting — COMPLETE (Live vs. Demo station breakdown)
- 7.7 Multi-lingual dictionary completion — COMPLETE (English, Hindi, Marathi)
- 7.8 Final verification — COMPLETE (192 Node tests, TypeScript compile 0 errors, build clean)



Loading
Loading