You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Automated CO₂ Offset Rate Verification with Independent Data Pipeline
Closes #243
Summary
Builds an automated pipeline that verifies project-reported CO₂ offset rates against independent scientific databases and satellite-based biomass estimation. Projects whose claimed co2_per_xlm rates deviate significantly from independent estimates are flagged and surfaced in the admin dashboard and on project detail pages.
Previously, CO₂ rate verification relied exclusively on static per-category benchmarks (CATEGORY_BENCHMARKS) and required manual admin review. A project could claim MAX_CO2_PER_XLM (100,000 g/XLM) when the scientifically-validated rate for that category and location might be 500 g/XLM. This PR introduces a multi-source automated verification pipeline with confidence band computation, severity grading, audit trail persistence, and a weekly cron schedule.
New co2_verification_runs table tracking every automated verification run with claimed rate, confidence band, reference/satellite sources, and flag reason
PR_DESCRIPTION_243.md
PR description file
Modified Files
File
Change
backend/src/services/co2Verifier.js
Major enhancement: external API integration (Gold Standard, Verra, IPCC fallback), satellite data (Global Forest Watch, IPCC tier-1 climate zones), confidence band computation, severity grading, full verifyProjectCO2Rate() pipeline, runVerificationForAllProjects() batch processor, pg-boss cron scheduler, Prometheus indigopay_co2_verifications_total counter. Backward-compatible — existing verifyCO2Rate() and applyCO2VerificationToProject() preserved.
backend/src/routes/admin/co2.js
Added POST /verify-all (batch trigger), POST /verify/:projectId (single-project), GET /flags/:projectId/history (audit trail). Enhanced GET /flags with LATERAL JOIN to surface confidence band, deviation %, severity, and reference source per row. Added audit logging for all new actions.
backend/src/server.js
Bootstrapped startCO2VerificationCron() in startServer(), registered lifecycle shutdown handler, added co2Verifier to pg-boss drain list.
frontend/pages/admin/co2-flags.tsx
Added columns: Confidence Band, Deviation % (color-coded), Reference Source. Added Re-verify button per project and Re-verify All Projects button with summary results banner.
frontend/pages/projects/[id].tsx
Added CO₂ Rate Verification section with green/amber/red status badges and link to transparency methodology page.
backend/src/services/co2Verifier.test.js
Rewrote from 12 to 45 tests covering: original benchmark comparison, external API fallback chains (Gold Standard + Verra), satellite data (GFW + IPCC zones), confidence band computation, severity thresholds, full pipeline, batch verification, cron scheduling, IPCC constants.
docs/architecture.md
Added Automated CO₂ Offset Rate Verification section with pipeline diagram, reference source hierarchy, satellite data integration, confidence band & severity table, scheduled verification docs. Added "Inflated CO₂ rates" row to security table.
Architecture
Verification Pipeline
Project registered ──► verifyProjectCO2Rate(project)
│
┌───────────┴───────────┐
▼ ▼
fetchReferenceRates() fetchSatelliteEstimate()
┌─────────────────── ┌───────────────────────
│1. Gold Standard API │1. Global Forest Watch API
│2. Verra VCS API │2. IPCC tier-1 (tropical/
│3. Static Benchmarks │ temperate/boreal zone)
│4. IPCC fallback └───────────────────────
└─────────────────── │
│ │
└───────────┬──────────────┘
▼
computeConfidenceBand()
[lower, upper] g CO₂/XLM
│
▼
computeSeverity()
none / warning / critical
│
┌───────────┴───────────┐
▼ ▼
co2_verification_runs projects.co2_verification_status
(immutable audit log) (updated if warning/critical)