mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-25 17:14:57 +02:00
3.8 KiB
3.8 KiB
status, priority, issue_id, tags, dependencies
| status | priority | issue_id | tags | dependencies | |||||
|---|---|---|---|---|---|---|---|---|---|
| pending | p3 | 191 |
|
Helper, freshness, and config cleanups (round helper duplication, num() over-coercion, generateSnapshotId entropy, matchesHorizon regex, getRegionCountries scan)
Problem Statement
Several minor cleanups across helpers and config:
_helpers.mjs:num()usesparseFloatfor strings, accepts"42abc"as42. Just useNumber(value)._helpers.mjs:clip()checksNumber.isNaNAND!Number.isFinite- the latter handles NaN._helpers.mjs:generateSnapshotId()usesMath.random(not CSPRNG). Usecrypto.randomUUID()instead. Comment claims "UUID v7-ish" - it's not.round()helper duplicated in 3+ modules (balance-vector, actor-scoring, scenario-builder, snapshot-meta). Move to_helpers.mjs.scenario-builder.mjs:matchesHorizon()regex has duplicate alternatives (/h24|24h|day|24h/).geography.js:getRegionCountries()doesObject.entriesscan per call. PrecomputeCOUNTRIES_BY_REGIONat module load.balance-vector.mjs:cVessel = 0hardcoded with 0.30 weight - dead weight that capscoercive_pressureat 0.70, makingescalation_ladderregime structurally unreachable._helpers.mjs:percentile()doesn't clamppto[0,100].triggers.config.mjs:russia_naval_buildupusestheater:eastern_europe:...(snake_case) but other theater IDs use kebab-case (eastern-europe).- Test comment at
tests/regional-snapshot.test.mjs:429has trailing "let's check actual output" exploration text.
Findings
- Batch of minor cleanups, each independently safe
- #7 is structurally important:
cVessel = 0forces coercive_pressure below the threshold that would trigger escalation_ladder regime - Phase 0 can never produce that regime even on extreme input - #9 creates ID drift that may break theater lookups silently
- Others are quality-of-life but reduce bug surface
Proposed Solutions
Option 1: Do all 10 in one PR
Small and mechanical; review them together.
Pros: Single follow-up eliminates a category of debt Cons: Mix of concerns in one change Effort: Small (each item) Risk: Low
Option 2: Split into 3 PRs
(a) helper fixes (num/clip/generateSnapshotId/round/percentile), (b) perf+config (getRegionCountries/matchesHorizon/triggers.config/test comment), (c) cVessel renormalization.
Pros: Cleaner history; smaller blast radius per change Cons: More PR overhead Effort: Small Risk: Low
Recommended Action
Technical Details
Files touched:
scripts/regional-snapshot/_helpers.mjs- num, clip, generateSnapshotId, round, percentilescripts/regional-snapshot/balance-vector.mjs- cVessel weight, duplicated roundscripts/regional-snapshot/actor-scoring.mjs- duplicated roundscripts/regional-snapshot/scenario-builder.mjs- duplicated round, matchesHorizon regexscripts/regional-snapshot/snapshot-meta.mjs- duplicated roundshared/geography.js- getRegionCountries scanscripts/regional-snapshot/triggers.config.mjs- russia_naval_buildup theater IDtests/regional-snapshot.test.mjs:429- stray comment
For #7: renormalize the coercive_pressure formula so that with cVessel stubbed at 0 the remaining weights sum to 1.0 (or drop the cVessel term entirely until Phase 1 provides data).
Acceptance Criteria
- num() drops parseFloat branch (use Number)
- clip() drops redundant isNaN check
- generateSnapshotId uses crypto.randomUUID
- round() centralized in _helpers
- matchesHorizon regex deduplicated
- getRegionCountries precomputed
- coercive_pressure renormalized so escalation_ladder is reachable in Phase 0
- percentile clamps p
- triggers.config theater names consistent
- Test comment cleaned up
Work Log
Resources
- PR #2940
- PR #2942