Skip to content

Comments

Add cable health scoring layer with NGA signal processing#134

Closed
koala73 wants to merge 6 commits intomainfrom
claude/add-cable-health-layer-3FXe5
Closed

Add cable health scoring layer with NGA signal processing#134
koala73 wants to merge 6 commits intomainfrom
claude/add-cable-health-layer-3FXe5

Conversation

@koala73
Copy link
Owner

@koala73 koala73 commented Feb 19, 2026

Summary

Adds cable health scoring via a new /api/cable-health endpoint that processes NGA maritime warnings to detect submarine cable faults and repair activity. Health status is integrated directly into the existing cables layer — no separate toggle — with only problems (fault/degraded) visually highlighted. Healthy cables retain their default appearance.

Type of change

  • New feature
  • New data source / feed
  • API endpoints (/api/*)

Affected areas

  • Map / Globe
  • API endpoints (/api/*)

Design decisions

  • Single layer, not two: Health is automatically fetched when the cables layer is enabled. No separate "Cable Health" toggle — this avoids confusing duplicate layers in the layer picker.
  • Highlight problems only: Only fault (red, thick, pulsing) and degraded (orange, medium) cables get visual treatment. Cables with ok or unknown health keep the default cyan appearance.
  • Unified popup: Clicking any cable shows the standard cable popup. When health evidence exists (fault/degraded), it's shown inline as an evidence section — no separate popup type.

Changes

Backend

  • api/cable-health.js (427 lines): New edge function that:

    • Fetches NGA maritime warnings and filters for cable-related keywords
    • Extracts cable identity via name matching (20+ known cables) or geometry proximity matching
    • Parses DMS coordinates from warning text
    • Generates two signal types: operator_fault (severity 0.6–1.0, TTL 3–5 days) and repair_activity (severity 0.5–0.8, TTL 12–24 hours)
    • Computes health scores using time-decay: effective = severity × confidence × recencyWeight
    • Applies conservative attribution rules (fault requires operator_fault signal ≥0.50 effective score)
    • Returns cached JSON with 3-minute TTL
  • api/cable-health.test.mjs (474 lines): Comprehensive test suite covering signal extraction, DMS parsing, nearest cable lookup, health map computation

  • data/landing-asn.json (108 lines): Maps 18 cables' 69 landing points to local ASNs

Frontend

  • src/services/cable-health.ts: Service layer with 1-minute local cache to fetch cable health data
  • src/types/index.ts: New types: CableHealthStatus, CableHealthRecord, CableHealthResponse, CableHealthEvidence
  • src/components/DeckGLMap.ts: Cable layer getColor/getWidth now check health map — fault → red/thick, degraded → orange/medium, everything else → default cyan
  • src/components/Map.ts: SVG fallback applies cable-health-fault/cable-health-degraded CSS classes
  • src/components/MapPopup.ts: Cable popup enriched with health evidence section when fault/degraded status detected
  • src/App.ts: Health data auto-fetched alongside cable activity when cables layer is enabled (5-min refresh)
  • src/styles/main.css: CSS for fault (dashed red + pulse animation) and degraded (orange) cable styles

Tests

  • tests/cable-health-data.test.mjs (132 lines): Data integrity checks for landing-asn.json

Test plan

  • Build passes (npm run build)
  • All 41 cable health tests pass
  • Visual: enable cables layer → fault/degraded cables highlighted, healthy cables unchanged
  • Visual: click a fault cable → popup shows evidence section
  • Visual: layer picker has single "Undersea Cables" toggle, no separate health toggle

Implement a new Cable Health layer that computes per-cable health status
(ok/degraded/fault/unknown) from NGA maritime warnings. The system uses
operator fault signals and repair ship activity as primary inputs, with
time-decayed scoring, conservative attribution rules (no fault from
inference alone), and evidence-first display.

Backend: new /api/cable-health endpoint with Upstash caching
Frontend: polling service, health-aware cable rendering on both
DeckGL and D3/SVG maps, and a detail popup showing score, confidence,
and top-3 evidence items.

https://claude.ai/code/session_013WGb1wGHvPX6amYn54fHzG
Add comprehensive test suite for cable health feature:
- 31 API unit tests covering signal processing, health computation,
  cable matching, coordinate parsing, and handler integration
- 10 data integrity tests for landing-asn.json validating structure,
  ASN format, cable coverage, and landing point consistency
- Register cable-health tests in package.json test:sidecar script

Add cable health documentation to docs/DOCUMENTATION.md covering
scoring algorithm, signal types, API endpoint, map rendering,
and configuration across variants.

https://claude.ai/code/session_013WGb1wGHvPX6amYn54fHzG
Backend (api/cable-health.js):
- Fix parseIssueDate to return epoch on failure instead of now,
  preventing malformed dates from inflating signal importance
- Remove dead code branch in computeHealthMap (ternary that always
  evaluated to 'degraded')
- Fix WACS UK landing coordinates to match London (consistent with
  landing-asn.json and geo.ts)

Frontend (DeckGLMap.ts):
- Add missing popup.setCableActivity() forwarding so cable popups
  show advisory/repair data in DeckGL mode
- Fix health cache signature to include status values, not just IDs
- Fix updateTriggers to use valid deck.gl accessor names (getColor,
  getWidth) instead of non-existent 'highlighted' key
- Remove dead getDashArray/dashJustified/extensions code (requires
  PathStyleExtension which is not installed)
- Use i18n t() for layer toggle labels

Frontend (MapPopup.ts):
- Replace all hardcoded English strings with i18n t() calls

i18n (en.json):
- Add cable health popup translation keys
- Add cableHealth layer toggle label

Documentation:
- Fix cable count (16 → 18) and landing count (60+ → 69)
- Fix fault threshold description to include both conditions

https://claude.ai/code/session_013WGb1wGHvPX6amYn54fHzG
@vercel
Copy link

vercel bot commented Feb 19, 2026

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

Project Deployment Actions Updated (UTC)
worldmonitor Ready Ready Preview, Comment Feb 20, 2026 11:23am
worldmonitor-finance Ready Ready Preview, Comment Feb 20, 2026 11:23am
worldmonitor-startup Ready Ready Preview, Comment Feb 20, 2026 11:23am

Request Review

@koala73 koala73 added the area: infrastructure Cables, pipelines, power grids, cyber threats label Feb 19, 2026
@koala73 koala73 changed the base branch from subcable to main February 19, 2026 20:36
Remove the separate cableHealth layer toggle and integrate health
status directly into the existing cables layer. When cables are
enabled, health data is automatically fetched and only problems
(fault/degraded) are visually highlighted — healthy cables keep
their default appearance. Merge health evidence into the unified
cable popup instead of having a separate popup type.
@koala73
Copy link
Owner Author

koala73 commented Feb 21, 2026

@SebastienMelki this needs to move to sebuf, we shouldn't drop it

@SebastienMelki
Copy link
Collaborator

Ok will port and merge

@koala73 koala73 closed this Feb 21, 2026
@koala73 koala73 deleted the claude/add-cable-health-layer-3FXe5 branch February 21, 2026 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: infrastructure Cables, pipelines, power grids, cyber threats needs refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants