Fix CII v6 score attribution and climate wiring#4147
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR bumps the CII scoring methodology to
Confidence Score: 4/5Safe to merge; the scoring and attribution changes are well-tested with named city probes and the drift test enforces seed/server parity at each new border heuristic. The core logic — piecewise Rio Grande chord, DMZ interpolation, proto-enum severity mapping, and ZONE_COUNTRY_MAP expansion — is correct and backed by the expanded test suite. The two concerns are: the The Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Climate anomaly from Redis cache\nzone + severity proto-enum] --> B{Server path\nget-risk-scores.ts}
A2[Climate anomaly via gRPC\nzone + severity proto-enum] --> M[mapSeverity\nclimate/index.ts\nexact switch match]
M --> C[ClimateAnomaly\nseverity: normal/moderate/extreme]
C --> D{Browser path\ncountry-instability.ts}
B --> E[climateSeverityScore\nsubstring match on proto-enum]
E -->|ANOMALY_SEVERITY_EXTREME| F[returns 5]
E -->|ANOMALY_SEVERITY_MODERATE| G[returns 8/3]
E -->|numeric| H[pass-through]
E -->|other| I[returns 0]
F --> J[climateSeverity = max prev, 5]
G --> J
H --> J
J --> K[climateBoost = min 15, severity x 3\n extreme=15, moderate=8]
K --> L[combinedScore += climateBoost]
D --> N[ingestClimateForCII\nexact match: extreme=15, else=8]
N --> O[climateStress = max prev, stress]
O --> P[climateBoost = climateStress]
P --> L2[CII score += climateBoost]
subgraph ZONE[ZONE_COUNTRY_MAP lookup both paths]
ZA[zone name from anomaly] --> ZB{match in ZONE_COUNTRY_MAP?}
ZB -->|yes| ZC[boost all listed country codes]
ZB -->|no| ZD[no boost]
end
|
CII_FORMULA_VERSION bumped v5->v6 (#4147). No hashed coefficient changed (country weights, defaults, strategic constants, getScoreLevel cutoffs), so the v6 snapshot hash equals v5. Without this the version-keyed guard fails assert.ok(expectedHash) on main.
* test(cii): guard formula protocol docs * test(cii): harden score-level parser * test(cii): add v6 protocol snapshot entry CII_FORMULA_VERSION bumped v5->v6 (#4147). No hashed coefficient changed (country weights, defaults, strategic constants, getScoreLevel cutoffs), so the v6 snapshot hash equals v5. Without this the version-keyed guard fails assert.ok(expectedHash) on main. --------- Co-authored-by: e <e@e.co>
Summary
v6so all score-changing attribution fixes ship under one methodology/cache-key version.Root Cause
The CII seed and server had drifted in both text matching and bbox-overlap attribution, and climate anomaly producer zones did not intersect the server consumer map for several score-relevant countries. Shipping these fixes separately would split score changes across silent methodology/cache versions.
Validation
node --import tsx --test tests/seed-military-cii-table-drift.test.mts tests/seed-military-cii.test.mts tests/cii-scoring.test.mtsnode --import tsx --test tests/mcp-bootstrap-parity.test.mjsnode --test tests/regional-snapshot.test.mjsnpm run typechecknpm run typecheck:apigit diff --checkgit push -u origin codex/cii-v6-score-attribution-climatecompleted successfully, including changed tests, edge-function tests, markdown/MDX lint, and version sync.