mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-28 10:28:51 +02:00
Add cable health scoring via sebuf InfrastructureService (#220)
* feat: add cable health scoring via sebuf InfrastructureService Port submarine cable health monitoring from PR #134 to the sebuf architecture. Adds GetCableHealth RPC to InfrastructureService that analyzes NGA maritime warnings to detect cable faults and repair activity, computing health scores with time-decay. - Proto: GetCableHealthRequest/Response, CableHealthRecord, evidence - Handler: NGA warning fetch, cable matching (name + proximity), signal processing, health computation with redis caching - Client: circuit breaker, proto enum → frontend string adapter, 1-min cache - Frontend: health-based cable coloring (fault=red, degraded=orange), evidence display in cable popup, SVG + DeckGL support Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address PR review feedback for cable health scoring - Fix geographic proximity: use cosine-latitude correction instead of raw Euclidean distance on lat/lon degrees, return distanceKm directly - Fix signal kind: use 'cable_advisory' (not 'operator_fault') for non-fault NGA warnings so advisories don't trigger fault status - Parallelize loadCableActivity + loadCableHealth with Promise.all - Remove console.log from client-side cable-health service - Add in-memory fallback cache on server so transient Redis+NGA failures serve stale data instead of empty response Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -131,6 +131,38 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
/api/infrastructure/v1/get-cable-health:
|
||||
post:
|
||||
tags:
|
||||
- InfrastructureService
|
||||
summary: GetCableHealth
|
||||
description: GetCableHealth computes health status for submarine cables from NGA maritime warning signals.
|
||||
operationId: GetCableHealth
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GetCableHealthRequest'
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
description: Successful response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GetCableHealthResponse'
|
||||
"400":
|
||||
description: Validation error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ValidationError'
|
||||
default:
|
||||
description: Error response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
components:
|
||||
schemas:
|
||||
Error:
|
||||
@@ -457,3 +489,68 @@ components:
|
||||
type: string
|
||||
description: Error message if the request was invalid.
|
||||
description: RecordBaselineSnapshotResponse reports how many baselines were successfully updated.
|
||||
GetCableHealthRequest:
|
||||
type: object
|
||||
description: GetCableHealthRequest requests the current health status of all monitored submarine cables.
|
||||
GetCableHealthResponse:
|
||||
type: object
|
||||
properties:
|
||||
generatedAt:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 'Generation timestamp, as Unix epoch milliseconds.. Warning: Values > 2^53 may lose precision in JavaScript'
|
||||
cables:
|
||||
type: object
|
||||
additionalProperties:
|
||||
$ref: '#/components/schemas/CableHealthRecord'
|
||||
description: Health records keyed by cable identifier.
|
||||
description: GetCableHealthResponse contains health status for submarine cables with active signals.
|
||||
CablesEntry:
|
||||
type: object
|
||||
properties:
|
||||
key:
|
||||
type: string
|
||||
value:
|
||||
$ref: '#/components/schemas/CableHealthRecord'
|
||||
CableHealthRecord:
|
||||
type: object
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- CABLE_HEALTH_STATUS_UNSPECIFIED
|
||||
- CABLE_HEALTH_STATUS_OK
|
||||
- CABLE_HEALTH_STATUS_DEGRADED
|
||||
- CABLE_HEALTH_STATUS_FAULT
|
||||
description: CableHealthStatus represents the computed health status of a submarine cable.
|
||||
score:
|
||||
type: number
|
||||
format: double
|
||||
description: Composite health score (0.0 = healthy, 1.0 = confirmed fault).
|
||||
confidence:
|
||||
type: number
|
||||
format: double
|
||||
description: Confidence in the health assessment (0.0–1.0).
|
||||
lastUpdated:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 'Last signal update time, as Unix epoch milliseconds.. Warning: Values > 2^53 may lose precision in JavaScript'
|
||||
evidence:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/CableHealthEvidence'
|
||||
description: CableHealthRecord contains the computed health status and supporting evidence for a cable.
|
||||
CableHealthEvidence:
|
||||
type: object
|
||||
properties:
|
||||
source:
|
||||
type: string
|
||||
description: Evidence source (e.g. "NGA").
|
||||
summary:
|
||||
type: string
|
||||
description: Human-readable summary of the evidence.
|
||||
ts:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 'Evidence timestamp, as Unix epoch milliseconds.. Warning: Values > 2^53 may lose precision in JavaScript'
|
||||
description: CableHealthEvidence represents a single piece of evidence supporting a health assessment.
|
||||
|
||||
Reference in New Issue
Block a user