← all branches

claude/vigorous-stonebraker-41cc2d

safeviewing older commit
8ea0c8a · incrementalpre-PRreviewed 2026-07-13 04:21 UTC0H · 0M · 3L · 7I
The branch
Purpose
Energy atlas for Mexico's power grid — public visualization at apps/web/public/atlas/ showing power plants, transmission lines, and distributed generation evolution
Goal
Complete atlas feature: DG panel with metrics/charts, plant-size filter (segmented presets), tooltips, region polygons, and data fixes
Sub-goals
  • SG-1: Region polygon fixes (grid footprint, donut holes)
  • SG-2: Filter shortcuts, collapsible panel, annual defaults
  • SG-3: DG panel — metrics, cumulative/annual, size focus, region evolution
  • SG-4: Chart tooltips, region coverage gaps, CENACE region summary
  • SG-5: DG chart improvements (tooltip positioning, 2025 DG data)
  • SG-6: DG average size per size-band (not single national line)
  • SG-7: Plant-size filter as segmented presets (matching Tensión filter pattern)
  • SG-8: Annualize DG region new deltas over irregular CNE periods
  • SG-9: Note SIPyME recategorization in DG view
  • SG-10: Relocate C.C. Mexicali coordinate to La Rosita (this commit)
The changes (whole branch)
What
This incremental review covers the final commit: (1) coordinates.json — single coordinate fix moving C.C. Mexicali from T.G. substation point [32.6057,-115.4611] to La Rosita [32.5977,-115.6281]; (2) index.html — plant-size filter converted from range slider to segmented presets, DG avg chart now shows per-band averages with band isolation, annualization of irregular CNE semiannual periods via dgPeriodSpanYears(), SIPyME recategorization note in DG view, y-axis label repositioning, DGmT margin adjustment.
Why
C.C. Mexicali was plotted on the wrong point (T.G. substation ~15 km east of the actual plant). The DG chart improvements make the visualization clearer for irregular CNE reporting periods and per-band comparisons.
Areas
apps/web/public/atlas+15647
Blast
4 files, +156/-47 across the atlas visualization. Static public page — no backend, no auth, no database impact.
ci· No PR — no CI checks to aggregatecoderabbit· No .coderabbit.yaml in repo

Findings · 10

correctness3

low

dgNatAvg() is dead code — never called

apps/web/public/atlas/index.html

dgNatAvg() is defined but not called anywhere in the file. It was superseded by the new per-band dgBandAvg(). No functional impact, but it's dead weight that could confuse future contributors who might think it is part of the active code path.

info

dgBandAvg() correctly omits annualization — different time axis

apps/web/public/atlas/index.html

dgBandAvg uses dg_by_size.json whose time axis is calendar years; dgPeriodSpanYears division is correctly absent. The comment block before dgPeriodSpanYears documents this asymmetry.

info

Coordinate fix is geographically plausible

apps/web/public/atlas/data/coordinates.json

Old [32.6057, -115.4611] is ~1.3 km north of downtown Mexicali, consistent with T.G. substation. New [32.5977, -115.6281] is ~14.8 km west, placing C.C. Mexicali in the La Rosita industrial corridor where the plant is known to be located.

security1

info

No security issues — static public page, no user-controlled data paths

apps/web/public/atlas/index.html

All innerHTML assignments use hardcoded strings or numeric values from trusted GitHub data. No auth, no PII, no form submissions.

conventions1

low

Indentation regression on reset handler

apps/web/public/atlas/index.html

The reset handler line gained 2 extra spaces of indentation relative to the seg() calls directly above it. Minor in a minified file but breaks local consistency within the block.

tests1

info

Tests N/A — standalone static HTML visualization

apps/web/public/atlas/index.html

No test framework applies to this build-free HTML+JS page.

improvement4

low

dgNatAvgState omits annualization that dgStateVal applies

apps/web/public/atlas/index.html

dgStateVal divides delta by dgPeriodSpanYears(i) for annual mode. dgNatAvgState (used in the region chart's avg=ALL path) does not. Today this is safe — avg mode (kW/system) is dimensionally invariant to the period span. The risk is future maintenance: if dgNatAvgState is ever wired to a non-avg path, the missing annualization will silently produce wrong values. A short comment at the function declaration ('avg-only — period span does not apply') would make the invariant explicit.

info

y-axis label y="9" is a magic number — not derived from DGmT

apps/web/public/atlas/index.html

Both chart functions emit y="9" while DGmT=17. Using y="${DGmT-8}" would tie the label to the margin constant. Low risk since DGmT changes are visible, but worth noting.

info

SIPyME note shown for all DG views, not just annual 2024→2025

apps/web/public/atlas/index.html

The caveat banner appears whenever metric==='dg', including in cumulative mode and for periods before 2025. Gating on annual mode would prevent it from being noise in unrelated views. Low priority since the note is short and informative.

info

regs.indexOf(r) is O(n) inside a nested loop

apps/web/public/atlas/index.html

In drawDGRegionChart, regs.indexOf(r) is called per region per period. At ~9 regions this is negligible, but a precomputed index map (const regIdx=Object.fromEntries(regs.map((r,i)=>[r,i]))) would be cleaner.

History · 10 commits

  1. a081002safeincremental0H · 0M · 0L2026-07-14 01:23
  2. 64dc83dneeds attentionincremental0H · 1M · 7L2026-07-13 20:03
  3. ec4eea3needs attentionincremental1H · 3M · 7L2026-07-13 18:42
  4. f4b4129safeincremental0H · 0M · 3L2026-07-13 04:34
  5. 8ea0c8asafeincremental0H · 0M · 3L2026-07-13 04:21current
  6. 37ce28asafeincremental0H · 2M · 3L2026-07-10 17:22
  7. d28c6daneeds attentionincremental0H · 3M · 10L2026-07-10 16:59
  8. 754a65dneeds attentionincremental0H · 3M · 4L2026-07-10 16:39
  9. a9190b2safeincremental0H · 0M · 5L2026-07-10 16:14
  10. 0bf12a0blockedfull1H · 2M · 4L2026-07-10 16:06