Skip to content

Improve cascade capacity calculation with dependency chain#166

Closed
koala73 wants to merge 1 commit into
mainfrom
claude/review-pr-139-Vtpcn
Closed

Improve cascade capacity calculation with dependency chain#166
koala73 wants to merge 1 commit into
mainfrom
claude/review-pr-139-Vtpcn

Conversation

@koala73

@koala73 koala73 commented Feb 20, 2026

Copy link
Copy Markdown
Owner

Summary

Enhanced the getCapacityForCountry function to calculate affected capacity more accurately by considering the full dependency chain and graph structure. Previously, non-cable sources defaulted to a fixed 0.1 capacity. Now the function:

  1. Checks for direct connections from the source to the target country
  2. Walks the dependency chain to calculate compound impact for indirect effects (e.g., chokepoint → port → country)
  3. Applies edge strength and redundancy factors at each step

This provides more realistic cascade impact calculations for infrastructure dependencies.

Type of change

  • Bug fix
  • Refactor / code cleanup

Affected areas

  • API endpoints (/api/*)
  • Other: Infrastructure cascade calculation logic

Checklist

  • TypeScript compiles without errors
  • Logic change is isolated to cascade calculation function
  • No API keys or secrets committed

Notes

The change passes the dependency chain and graph structure to getCapacityForCountry, enabling it to traverse the dependency graph and calculate compound impact factors rather than using a hardcoded default value.

…tyForCountry

- Accept graph and dependencyChain as parameters instead of calling
  buildDependencyGraph() internally, making the dependency explicit
- Walk the dependency chain to compute compound capacity for indirect
  impacts (e.g. chokepoint → port → country) instead of returning 0

https://claude.ai/code/session_01YKxF3DRDhYYtsNftdHjw9Y
@vercel

vercel Bot commented Feb 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
worldmonitor Error Error Feb 20, 2026 4:29am
worldmonitor-finance Error Error Feb 20, 2026 4:29am
worldmonitor-startup Error Error Feb 20, 2026 4:29am

Request Review

@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.

@koala73 koala73 closed this Feb 20, 2026
@koala73
koala73 deleted the claude/review-pr-139-Vtpcn branch February 21, 2026 06:00
koala73 added a commit that referenced this pull request Apr 11, 2026
…riter

Resolves all 5 critical findings from the multi-agent code review of PR #2940.
End-to-end smoke test passes for all 8 regions with confidence=1.0.

P1 #166: health-seed-meta-not-in-keys-loops
  - Add regionalSnapshots to STANDALONE_KEYS in api/health.js
  - Without this, the SEED_META entry was dead wiring and the 12h staleness
    budget was unobservable. Same failure mode as the 'empty data ok keys
    bootstrap blind spot' the team has hit before.

P1 #167: oref-trigger-key-not-in-freshness-registry
  - Add relay:oref:history:v1 to FRESHNESS_REGISTRY (the canonical OREF key
    written by ais-relay, not the wrong intelligence:oref-alerts:v1 that the
    code was originally reading).
  - Update trigger-evaluator to read activeAlertCount/historyCount24h from
    the actual relay:oref:history:v1 payload shape.
  - oref_cluster trigger now fires when activeAlertCount > 10 (verified
    end-to-end against mock data).

P1 #168: zombie-freshness-registry-keys
  - Remove 4 freshness registry entries that no compute module reads:
    supply_chain:shipping_stress, energy:chokepoint-flows,
    intelligence:advisories-bootstrap, market:commodities-bootstrap.
  - These were dragging snapshot_confidence below 1.0 and wasting Redis
    pipeline reads. Add a header comment forbidding speculative entries.

P1 #169: diff-field-leaks-into-persisted-snapshot
  - Change computeSnapshot to return { snapshot, diff } separately so the
    diff is consumed locally for inferTriggerReason and never serialized
    into the persisted snapshot. The diff field was not part of the
    RegionalSnapshot type and would have broken Phase 1 proto codegen.
  - Update main() to destructure { snapshot } before persistSnapshot.

P1 #170: jsdoc-types-not-enforced-jsconfig-missing
  - Add scripts/seed-regional-snapshots.mjs and scripts/regional-snapshot/**
    to scripts/jsconfig.json's include array so tsc --checkJs validates the
    JSDoc @type annotations.
  - Add // @ts-check directive to all 14 .mjs files in the regional-snapshot
    pipeline.
  - Fix 4 type-safety bugs surfaced by enabling type-checking:
      actor-scoring: explicit ActorState[] type on local actors array; cast
        leverage_domains to ActorLeverageDomain[]; typed ActorRole return on
        inferRole.
      evidence-collector: explicit EvidenceItem[] type on local out array.
      scenario-builder: typed HORIZONS as ScenarioHorizon[] and LANE_NAMES
        as ScenarioName[].
      transmission-templates: cast tpl.affectedRegions to RegionId[] when
        building TransmissionPath objects.
  - Pre-existing seed-forecasts.mjs and _r2-storage.mjs errors (46 total)
    are not part of this PR's scope and remain untouched.

Verification
  - npx tsc --noEmit -p scripts/jsconfig.json: 0 errors in regional-snapshot files
  - npm run typecheck:all: clean
  - npm run test:data: 3946/3946 pass
  - tests/regional-snapshot.test.mjs: 50/50 pass
  - End-to-end smoke test: all 8 regions compute clean with confidence=1.0
  - Verified: oref_cluster trigger fires when activeAlertCount > 10
  - Verified: persisted snapshot has no diff field
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