Skip to content

Consolidate merge#58

Merged
Adlgr87 merged 3 commits into
mainfrom
consolidate-merge
Jul 1, 2026
Merged

Consolidate merge#58
Adlgr87 merged 3 commits into
mainfrom
consolidate-merge

Conversation

@Adlgr87

@Adlgr87 Adlgr87 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Pull Request

Resumen de cambios

Describe brevemente qué se ha modificado y por qué.

Tipo de cambio

  • Nueva funcionalidad (feature)
  • Corrección de error (bug fix)
  • Mejora de rendimiento
  • Refactorización
  • Documentación
  • Otro

Módulos afectados

  • massive_core/data_assimilation/ — EnKF, filtro EnKF disperso
  • massive_core/network_inference/ — Reconstrucción de red (DE, CG)
  • massive_core/numerics/ — Steppers, estabilidad, motor multicapa disperso
  • massive_core/physics/ — Perturbación, mecánica estadística
  • tests/ — Pruebas unitarias
  • frontend/ — UI, generated types
  • README.md / README_ES.md — Documentación
  • massive_engine.py — Motor principal

Checklist

  • Las pruebas existentes siguen pasando (pytest tests/)
  • Se han añadido pruebas para nueva funcionalidad
  • No se han roto APIs públicas legacy
  • La documentación se ha actualizado
  • Se ha seguido el protocolo de CLAUDE.md

Notas de integración

Si este PR toca el motor principal (massive_engine.py) o el frontend, especificar cambios en las rutas de la API o la UI.


Summary by cubic

Integrates the real MASSIVE engine into the benchmark runner and adds stronger baselines and EnKF experiments. Real runs now use the actual simulator with a simple train-calibrated mapping and ship full reproducibility docs and artifacts.

  • New Features

    • Real-engine benchmark: new benchmarks/massive_real.py with deterministic seed and a 2-parameter train-fit mapping (a*opinion + b → polarization).
    • Runner: --real flag to use the actual simulator; --offline and --llm remain unchanged.
    • Stronger baselines: ETS and ARIMA (plus ridge with lags) added to benchmarks/baselines.py.
    • EnKF experiments: experiments/08_enkf_delta/exp_003_enkf.py and consolidated reports; 11/12 cases improve (mean ΔMAE +0.0063; p=0.0389).
    • Reproducibility: added benchmark and reproducibility cards, linked from README; committed reports and metrics; ignored regenerated SOTA artifacts in .gitignore.
  • Dependencies

    • Added statsmodels>=0.14.0 and scikit-learn>=1.4.0 to requirements.txt.

Written for commit f10930c. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added a new real-run benchmark mode with improved forecasting options and broader model coverage.
    • Expanded benchmark outputs with detailed results, comparison metrics, and run summaries across multiple cases.
  • Bug Fixes

    • Improved fallback behavior for forecasting when advanced models or simulations are unavailable.
    • Added more reliable handling for regeneration of benchmark artifacts.
  • Documentation

    • Updated the README and added new benchmark and reproducibility cards.
    • Added comprehensive benchmark and experiment reports for real-engine runs and EnKF evaluations.

Resolves the critical finding from ROADMAP_SOTA_MASSIVE.md: the
EMPIRICAL_VALIDATION_REPORT.md was measuring an AR(1) proxy, not the
real MASSIVE engine. This commit integrates the actual simulator.

## What changed

- benchmarks/massive_real.py (NEW, 195 lines): wraps simulator.simular()
  with heurístico mode, deterministic seed, 2-param linear calibration
  (a*opinion + b -> polarization) fit on train split.

- benchmarks/runner.py: adds --real flag that invokes the real engine.
  --offline (proxy) and --llm (LLM-backed) modes preserved.

- datasets/real_cases/<12>/timeseries.csv: fixed CRLF -> LF for
  consistent parsing on Linux.

## Results (n=12, 3 seeds)

| Metric                | MASSIVE real | MASSIVE proxy |
|-----------------------|--------------|---------------|
| Mean MAE              | 0.0929       | 0.1616        |
| Wins vs naive         | 9/12         | 1/12          |
| Wins vs proxy (self)  | 10/12        | 2/12          |
| Cross-seed determinism| 100% (std=0) | -             |

- MASSIVE real vs naive: 9/12 wins, median MAE 0.0777 vs 0.0950 (-18%)
- MASSIVE real vs proxy: 10/12 wins, paired t-test t=+3.009, **p=0.0119** (significant at α=0.05)
- Directional accuracy: 0.674 (real) vs 0.000 (naive)
- 3 losses: hong_kong, south_korea (cascade dynamics), us_election (volatility)

## What this proves

N1 criterion (ROADMAP) PASSED: real engine > proxy in 10/12 cases.
The proxy was a flat AR(1); the real engine adds mechanistic value
through the heurístico rule selector and polarization dynamics.

## Reproducibility

  export PYTHONHASHSEED=42
  python3 -m benchmarks.runner --cases datasets/real_cases --real \
      --out reports/sota_v0 --seed 42

## Files

- experiments/06_real_benchmark_v0/REPORT.md (157 lines, full analysis)
- experiments/06_real_benchmark_v0/{metrics.json, cross_seed_stats.json}
- experiments/sota_roadmap/ROADMAP_SOTA_MASSIVE.md (450 lines, the master plan)
- benchmarks/massive_real.py (new module)
- benchmarks/runner.py (--real flag added)

Refs: massive-benchmark-project memory
- Add strong baselines (ETS via statsmodels, ARIMA via SARIMAX, Ridge(lags))
- Keep proxy only for --offline; --real runs MASSIVE real (heurístico)
- Integrate cluster_id conditioning (light-touch) in massive_real wrapper
- EXP-003: EnKF delta script (n_ensemble=32, sigma_obs=0.02, interval=3)
- Full 12-case EnKF run: 11/12 improvements, mean ΔMAE=+0.0063 (p=0.0389)
- Consolidated report with per-case MAE and baseline comparisons
- Reproducibility commands and threat/limitations sections

Artifacts:
- experiments/08_enkf_delta/exp_003_enkf.py
- experiments/11_consolidation/CONSOLIDATED_REPORT.md
- reports/{sota_baselines,enkf_pilot,enkf_pilot_i3_s002,enkf_full_i3_s002,cluster_run}

Deps: requirements.txt adds statsmodels and scikit-learn
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Adlgr87 Adlgr87 merged commit 4afbc4b into main Jul 1, 2026
3 of 4 checks passed
@Adlgr87 Adlgr87 deleted the consolidate-merge branch July 1, 2026 08:00
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1b48ecf5-d8e5-4304-9fc8-9174a4125290

📥 Commits

Reviewing files that changed from the base of the PR and between 4a11532 and f10930c.

📒 Files selected for processing (30)
  • .gitignore
  • README.md
  • benchmarks/baselines.py
  • benchmarks/massive_real.py
  • benchmarks/runner.py
  • docs/cards/BENCHMARK.md
  • docs/cards/REPRODUCIBILITY.md
  • experiments/06_real_benchmark_v0/REPORT.md
  • experiments/06_real_benchmark_v0/cross_seed_stats.json
  • experiments/06_real_benchmark_v0/metrics.json
  • experiments/08_enkf_delta/exp_003_enkf.py
  • experiments/11_consolidation/CONSOLIDATED_REPORT.md
  • experiments/sota_roadmap/ROADMAP_SOTA_MASSIVE.md
  • reports/cluster_run/metrics.json
  • reports/cluster_run/report.md
  • reports/enkf_full_i3_s002/delta.json
  • reports/enkf_full_i3_s002/metrics_post.json
  • reports/enkf_full_i3_s002/metrics_pre.json
  • reports/enkf_full_i3_s002/report.md
  • reports/enkf_pilot/delta.json
  • reports/enkf_pilot/metrics_post.json
  • reports/enkf_pilot/metrics_pre.json
  • reports/enkf_pilot/report.md
  • reports/enkf_pilot_i3_s002/delta.json
  • reports/enkf_pilot_i3_s002/metrics_post.json
  • reports/enkf_pilot_i3_s002/metrics_pre.json
  • reports/enkf_pilot_i3_s002/report.md
  • reports/sota_baselines/metrics.json
  • reports/sota_baselines/report.md
  • requirements.txt

📝 Walkthrough

Walkthrough

Adds statistical/ML forecasting baselines (ETS, ARIMA, threshold-logistic, Ridge-lags) with dependency-tolerant assembly, a new real MASSIVE simulator forecasting module with linear calibration, a --real runner CLI mode, an EnKF delta-measurement experiment script, a SOTA roadmap document, documentation cards, and numerous generated benchmark reports/metrics artifacts.

Changes

Baselines and dependency management

Layer / File(s) Summary
New baseline classes and dependency-tolerant assembly
benchmarks/baselines.py, requirements.txt
Adds ETSBaseline, ARIMABaseline, ThresholdLogisticBaseline, and RidgeLagsBaseline; updates get_all_baselines() to conditionally append optional baselines via try/except; adds statsmodels and scikit-learn dependencies.

Real MASSIVE engine forecasting and runner integration

Layer / File(s) Summary
Real-engine forecast module
benchmarks/massive_real.py
New module implementing deterministic-seeded initial-state construction, a linear calibration fit, and massive_real_forecast/massive_real_forecast_with_calibration with fallback behavior on simulator failure.
Runner CLI real-mode wiring
benchmarks/runner.py
Adds _massive_real_forecast helper, a mode == "real" branch with offline fallback, a --real CLI flag, and updated mode-selection logic and usage docs.
EnKF delta-measurement experiment script
experiments/08_enkf_delta/exp_003_enkf.py
New script loading cases, running pre/post EnKF assimilation via run_case, computing MAE/RMSE/directional-accuracy deltas, and writing JSON/Markdown outputs via a CLI main.
SOTA roadmap and documentation cards
experiments/sota_roadmap/ROADMAP_SOTA_MASSIVE.md, docs/cards/BENCHMARK.md, docs/cards/REPRODUCIBILITY.md, README.md, .gitignore
Adds the SOTA roadmap with horizons/backlog/tickets, new benchmark and reproducibility documentation cards, updated README documentation links, and a .gitignore rule for regenerated SOTA artifacts.
Generated experiment and benchmark reports
experiments/06_real_benchmark_v0/*, experiments/11_consolidation/CONSOLIDATED_REPORT.md, reports/cluster_run/*, reports/enkf_full_i3_s002/*, reports/enkf_pilot*/*, reports/sota_baselines/*
Adds generated metrics JSON and Markdown report artifacts across multiple benchmark and EnKF experiment runs.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Runner as benchmarks/runner.py
  participant MassiveReal as massive_real.py
  participant Simulator as simular()
  Runner->>MassiveReal: massive_real_forecast_with_calibration(train, horizon, seed)
  MassiveReal->>MassiveReal: build_initial_state(train)
  MassiveReal->>Simulator: simular(estado, pasos)
  Simulator-->>MassiveReal: history (opinion trajectory)
  MassiveReal->>MassiveReal: fit linear calibration on train slice
  MassiveReal-->>Runner: clipped polarization forecast
  Runner->>Runner: fallback to offline AR(1) forecast if real fails
Loading
sequenceDiagram
  participant Main as exp_003_enkf.main
  participant RunCase as run_case()
  participant Simulator as simular()
  participant EnKF as assimilate_history_observations()
  Main->>RunCase: run_case(case, seed, obs_interval, sigma_obs, n_ensemble)
  RunCase->>Simulator: simular(estado, pasos=n_total)
  Simulator-->>RunCase: history
  RunCase->>RunCase: fit linear mapping, compute pre-forecast
  RunCase->>EnKF: assimilate_history_observations(history, observations)
  EnKF-->>RunCase: assimilated mean opinions
  RunCase-->>Main: pre/post metrics and deltas
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch consolidate-merge

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Biome (2.5.1)
experiments/06_real_benchmark_v0/metrics.json

File contains syntax errors that prevent linting: Line 63: String values must be double quoted.; Line 64: String values must be double quoted.; Line 66: String values must be double quoted.; Line 133: String values must be double quoted.; Line 134: String values must be double quoted.; Line 136: String values must be double quoted.; Line 203: String values must be double quoted.; Line 204: String values must be double quoted.; Line 206: String values must be double quoted.; Line 273: String values must be double quoted.; Line 274: String values must be double quoted.; Line 276: String values must be double quoted.; Line 343: String values must be double quoted.; Line 344: String values must be double quoted.; Line 346: String values must be double quoted.; Line 413: String values must be double quoted.; Line 414: String values must be double quoted.; Line 416: String values must be double quoted.; Line 483: String values must be double quoted.; Line 484: String values must be double quoted.; Line 486: String values must be double quoted.; Line 553: String values must be double quoted.; Line 554: String values must be double quoted.; Line 556: String values must be double quoted.; Line 623: String values must be double quoted.; Line 624: String values must be double quoted.; Line 626: String values must be double quoted.; Line 693: String values must be double quoted.; Line 694: String values must be double quoted.; Line 696: String values must be double quoted.; Line 763: String values must be double quoted.; Line 764: String values must be double quoted.; Line 766: String values must be double quoted.; Line 833: String values must be double quoted.; Line 836: String values must be double quoted.

reports/cluster_run/metrics.json

File contains syntax errors that prevent linting: Line 96: String values must be double quoted.; Line 97: String values must be double quoted.; Line 99: String values must be double quoted.; Line 199: String values must be double quoted.; Line 200: String values must be double quoted.; Line 202: String values must be double quoted.; Line 302: String values must be double quoted.; Line 303: String values must be double quoted.; Line 305: String values must be double quoted.; Line 405: String values must be double quoted.; Line 406: String values must be double quoted.; Line 408: String values must be double quoted.; Line 508: String values must be double quoted.; Line 509: String values must be double quoted.; Line 511: String values must be double quoted.; Line 611: String values must be double quoted.; Line 612: String values must be double quoted.; Line 614: String values must be double quoted.; Line 714: String values must be double quoted.; Line 715: String values must be double quoted.; Line 717: String values must be double quoted.; Line 817: String values must be double quoted.; Line 818: String values must be double quoted.; Line 820: String values must be double quoted.; Line 920: String values must be double quoted.; Line 921: String values must be double quoted.; Line 923: String values must be double quoted.; Line 1023: String values must be double quoted.; Line 1024: String values must be double quoted.; Line 1026: String values must be double quoted.; Line 1126: String values must be double quoted.; Line 1127: String values must be double quoted.; Line 1129: String values must be double quoted.; Line 1229: String values must be double quoted.; Line 1232: String values must be double quoted.

reports/sota_baselines/metrics.json

File contains syntax errors that prevent linting: Line 96: String values must be double quoted.; Line 97: String values must be double quoted.; Line 99: String values must be double quoted.; Line 199: String values must be double quoted.; Line 200: String values must be double quoted.; Line 202: String values must be double quoted.; Line 302: String values must be double quoted.; Line 303: String values must be double quoted.; Line 305: String values must be double quoted.; Line 405: String values must be double quoted.; Line 406: String values must be double quoted.; Line 408: String values must be double quoted.; Line 508: String values must be double quoted.; Line 509: String values must be double quoted.; Line 511: String values must be double quoted.; Line 611: String values must be double quoted.; Line 612: String values must be double quoted.; Line 614: String values must be double quoted.; Line 714: String values must be double quoted.; Line 715: String values must be double quoted.; Line 717: String values must be double quoted.; Line 817: String values must be double quoted.; Line 818: String values must be double quoted.; Line 820: String values must be double quoted.; Line 920: String values must be double quoted.; Line 921: String values must be double quoted.; Line 923: String values must be double quoted.; Line 1023: String values must be double quoted.; Line 1024: String values must be double quoted.; Line 1026: String values must be double quoted.; Line 1126: String values must be double quoted.; Line 1127: String values must be double quoted.; Line 1129: String values must be double quoted.; Line 1229: String values must be double quoted.; Line 1232: String values must be double quoted.


Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants