Files
worldmonitor/docs/api/InfrastructureService.openapi.json
Sebastien Melki e6285e3de0 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>
2026-02-22 03:22:05 +04:00

1 line
16 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{"components":{"schemas":{"BaselineAnomaly":{"description":"BaselineAnomaly describes a detected deviation from historical baseline.","properties":{"multiplier":{"description":"Ratio of current count to baseline mean.","format":"double","type":"number"},"severity":{"description":"Severity label: \"critical\", \"high\", \"medium\", \"normal\".","type":"string"},"zScore":{"description":"Number of standard deviations from the mean.","format":"double","type":"number"}},"type":"object"},"BaselineStats":{"description":"BaselineStats contains the running statistics for a baseline key.","properties":{"mean":{"description":"Running mean of observed counts.","format":"double","type":"number"},"sampleCount":{"description":"Number of samples incorporated so far.","format":"int32","type":"integer"},"stdDev":{"description":"Standard deviation derived from Welford's M2.","format":"double","type":"number"}},"type":"object"},"BaselineUpdate":{"description":"BaselineUpdate is a single metric observation to incorporate into the running baseline.","properties":{"count":{"description":"Observed count value.","format":"double","type":"number"},"region":{"description":"Geographic region key, defaults to \"global\".","type":"string"},"type":{"description":"Activity type key.","minLength":1,"type":"string"}},"required":["type"],"type":"object"},"CableHealthEvidence":{"description":"CableHealthEvidence represents a single piece of evidence supporting a health assessment.","properties":{"source":{"description":"Evidence source (e.g. \"NGA\").","type":"string"},"summary":{"description":"Human-readable summary of the evidence.","type":"string"},"ts":{"description":"Evidence timestamp, as Unix epoch milliseconds.. Warning: Values \u003e 2^53 may lose precision in JavaScript","format":"int64","type":"integer"}},"type":"object"},"CableHealthRecord":{"description":"CableHealthRecord contains the computed health status and supporting evidence for a cable.","properties":{"confidence":{"description":"Confidence in the health assessment (0.01.0).","format":"double","type":"number"},"evidence":{"items":{"$ref":"#/components/schemas/CableHealthEvidence"},"type":"array"},"lastUpdated":{"description":"Last signal update time, as Unix epoch milliseconds.. Warning: Values \u003e 2^53 may lose precision in JavaScript","format":"int64","type":"integer"},"score":{"description":"Composite health score (0.0 = healthy, 1.0 = confirmed fault).","format":"double","type":"number"},"status":{"description":"CableHealthStatus represents the computed health status of a submarine cable.","enum":["CABLE_HEALTH_STATUS_UNSPECIFIED","CABLE_HEALTH_STATUS_OK","CABLE_HEALTH_STATUS_DEGRADED","CABLE_HEALTH_STATUS_FAULT"],"type":"string"}},"type":"object"},"CablesEntry":{"properties":{"key":{"type":"string"},"value":{"$ref":"#/components/schemas/CableHealthRecord"}},"type":"object"},"Error":{"description":"Error is returned when a handler encounters an error. It contains a simple error message that the developer can customize.","properties":{"message":{"description":"Error message (e.g., 'user not found', 'database connection failed')","type":"string"}},"type":"object"},"FieldViolation":{"description":"FieldViolation describes a single validation error for a specific field.","properties":{"description":{"description":"Human-readable description of the validation violation (e.g., 'must be a valid email address', 'required field missing')","type":"string"},"field":{"description":"The field path that failed validation (e.g., 'user.email' for nested fields). For header validation, this will be the header name (e.g., 'X-API-Key')","type":"string"}},"required":["field","description"],"type":"object"},"GeoCoordinates":{"description":"GeoCoordinates represents a geographic location using WGS84 coordinates.","properties":{"latitude":{"description":"Latitude in decimal degrees (-90 to 90).","format":"double","maximum":90,"minimum":-90,"type":"number"},"longitude":{"description":"Longitude in decimal degrees (-180 to 180).","format":"double","maximum":180,"minimum":-180,"type":"number"}},"type":"object"},"GetCableHealthRequest":{"description":"GetCableHealthRequest requests the current health status of all monitored submarine cables.","type":"object"},"GetCableHealthResponse":{"description":"GetCableHealthResponse contains health status for submarine cables with active signals.","properties":{"cables":{"additionalProperties":{"$ref":"#/components/schemas/CableHealthRecord"},"description":"Health records keyed by cable identifier.","type":"object"},"generatedAt":{"description":"Generation timestamp, as Unix epoch milliseconds.. Warning: Values \u003e 2^53 may lose precision in JavaScript","format":"int64","type":"integer"}},"type":"object"},"GetTemporalBaselineRequest":{"description":"GetTemporalBaselineRequest checks current activity count against stored baseline.","properties":{"count":{"description":"Current observed count to compare against baseline.","format":"double","type":"number"},"region":{"description":"Geographic region key, defaults to \"global\".","type":"string"},"type":{"description":"Activity type: \"military_flights\", \"vessels\", \"protests\", \"news\", \"ais_gaps\", \"satellite_fires\".","minLength":1,"type":"string"}},"required":["type"],"type":"object"},"GetTemporalBaselineResponse":{"description":"GetTemporalBaselineResponse returns anomaly info or learning status.","properties":{"anomaly":{"$ref":"#/components/schemas/BaselineAnomaly"},"baseline":{"$ref":"#/components/schemas/BaselineStats"},"error":{"description":"Error message if request was invalid.","type":"string"},"learning":{"description":"True if insufficient samples have been collected.","type":"boolean"},"sampleCount":{"description":"Current number of samples stored.","format":"int32","type":"integer"},"samplesNeeded":{"description":"Minimum samples required before anomaly detection activates.","format":"int32","type":"integer"}},"type":"object"},"InternetOutage":{"description":"InternetOutage represents a detected internet outage event from Cloudflare Radar.","properties":{"categories":{"items":{"description":"Affected infrastructure categories.","type":"string"},"type":"array"},"cause":{"description":"Root cause, if determined.","type":"string"},"country":{"description":"Affected country (ISO 3166-1 alpha-2).","type":"string"},"description":{"description":"Outage description.","type":"string"},"detectedAt":{"description":"Detection time, as Unix epoch milliseconds.. Warning: Values \u003e 2^53 may lose precision in JavaScript","format":"int64","type":"integer"},"endedAt":{"description":"End time of the outage, as Unix epoch milliseconds. Zero if ongoing.. Warning: Values \u003e 2^53 may lose precision in JavaScript","format":"int64","type":"integer"},"id":{"description":"Unique outage identifier.","minLength":1,"type":"string"},"link":{"description":"URL to the outage report.","type":"string"},"location":{"$ref":"#/components/schemas/GeoCoordinates"},"outageType":{"description":"Outage type classification.","type":"string"},"region":{"description":"Affected region within the country.","type":"string"},"severity":{"description":"OutageSeverity represents the severity of an internet outage.\n Maps to TS union: 'partial' | 'major' | 'total'.","enum":["OUTAGE_SEVERITY_UNSPECIFIED","OUTAGE_SEVERITY_PARTIAL","OUTAGE_SEVERITY_MAJOR","OUTAGE_SEVERITY_TOTAL"],"type":"string"},"title":{"description":"Outage title.","type":"string"}},"required":["id"],"type":"object"},"ListInternetOutagesRequest":{"description":"ListInternetOutagesRequest specifies filters for retrieving internet outages.","properties":{"country":{"description":"Optional country filter (ISO 3166-1 alpha-2).","type":"string"},"pagination":{"$ref":"#/components/schemas/PaginationRequest"},"timeRange":{"$ref":"#/components/schemas/TimeRange"}},"type":"object"},"ListInternetOutagesResponse":{"description":"ListInternetOutagesResponse contains internet outages matching the request.","properties":{"outages":{"items":{"$ref":"#/components/schemas/InternetOutage"},"type":"array"},"pagination":{"$ref":"#/components/schemas/PaginationResponse"}},"type":"object"},"ListServiceStatusesRequest":{"description":"ListServiceStatusesRequest specifies filters for retrieving service statuses.","properties":{"status":{"description":"ServiceOperationalStatus represents the current status of a service.","enum":["SERVICE_OPERATIONAL_STATUS_UNSPECIFIED","SERVICE_OPERATIONAL_STATUS_OPERATIONAL","SERVICE_OPERATIONAL_STATUS_DEGRADED","SERVICE_OPERATIONAL_STATUS_PARTIAL_OUTAGE","SERVICE_OPERATIONAL_STATUS_MAJOR_OUTAGE","SERVICE_OPERATIONAL_STATUS_MAINTENANCE"],"type":"string"}},"type":"object"},"ListServiceStatusesResponse":{"description":"ListServiceStatusesResponse contains service operational statuses.","properties":{"statuses":{"items":{"$ref":"#/components/schemas/ServiceStatus"},"type":"array"}},"type":"object"},"PaginationRequest":{"description":"PaginationRequest specifies cursor-based pagination parameters for list endpoints.","properties":{"cursor":{"description":"Opaque cursor for fetching the next page. Empty string for the first page.","type":"string"},"pageSize":{"description":"Maximum number of items to return per page (1 to 100).","format":"int32","maximum":100,"minimum":1,"type":"integer"}},"type":"object"},"PaginationResponse":{"description":"PaginationResponse contains pagination metadata returned alongside list results.","properties":{"nextCursor":{"description":"Cursor for fetching the next page. Empty string indicates no more pages.","type":"string"},"totalCount":{"description":"Total count of items matching the query, if known. Zero if the total is unknown.","format":"int32","type":"integer"}},"type":"object"},"RecordBaselineSnapshotRequest":{"description":"RecordBaselineSnapshotRequest batch-updates baselines using Welford's online algorithm.","properties":{"updates":{"items":{"$ref":"#/components/schemas/BaselineUpdate"},"type":"array"}},"type":"object"},"RecordBaselineSnapshotResponse":{"description":"RecordBaselineSnapshotResponse reports how many baselines were successfully updated.","properties":{"error":{"description":"Error message if the request was invalid.","type":"string"},"updated":{"description":"Number of baselines that were written.","format":"int32","type":"integer"}},"type":"object"},"ServiceStatus":{"description":"ServiceStatus represents the operational status of a monitored external service.","properties":{"checkedAt":{"description":"Last status check time, as Unix epoch milliseconds.. Warning: Values \u003e 2^53 may lose precision in JavaScript","format":"int64","type":"integer"},"description":{"description":"Status description.","type":"string"},"id":{"description":"Service identifier.","type":"string"},"latencyMs":{"description":"Response latency in milliseconds.","format":"int32","type":"integer"},"name":{"description":"Service display name.","type":"string"},"status":{"description":"ServiceOperationalStatus represents the current status of a service.","enum":["SERVICE_OPERATIONAL_STATUS_UNSPECIFIED","SERVICE_OPERATIONAL_STATUS_OPERATIONAL","SERVICE_OPERATIONAL_STATUS_DEGRADED","SERVICE_OPERATIONAL_STATUS_PARTIAL_OUTAGE","SERVICE_OPERATIONAL_STATUS_MAJOR_OUTAGE","SERVICE_OPERATIONAL_STATUS_MAINTENANCE"],"type":"string"},"url":{"description":"Service URL or homepage.","type":"string"}},"type":"object"},"TimeRange":{"description":"TimeRange represents a time interval defined by a start and end timestamp.\n Used for filtering data within a specific time period.","properties":{"end":{"description":"End of the time range (inclusive), as Unix epoch milliseconds.. Warning: Values \u003e 2^53 may lose precision in JavaScript","format":"int64","type":"integer"},"start":{"description":"Start of the time range (inclusive), as Unix epoch milliseconds.. Warning: Values \u003e 2^53 may lose precision in JavaScript","format":"int64","type":"integer"}},"type":"object"},"ValidationError":{"description":"ValidationError is returned when request validation fails. It contains a list of field violations describing what went wrong.","properties":{"violations":{"description":"List of validation violations","items":{"$ref":"#/components/schemas/FieldViolation"},"type":"array"}},"required":["violations"],"type":"object"}}},"info":{"title":"InfrastructureService API","version":"1.0.0"},"openapi":"3.1.0","paths":{"/api/infrastructure/v1/get-cable-health":{"post":{"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":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetCableHealthResponse"}}},"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"},"default":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Error response"}},"summary":"GetCableHealth","tags":["InfrastructureService"]}},"/api/infrastructure/v1/get-temporal-baseline":{"post":{"description":"GetTemporalBaseline checks current activity count against stored baseline for anomaly detection.","operationId":"GetTemporalBaseline","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetTemporalBaselineRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetTemporalBaselineResponse"}}},"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"},"default":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Error response"}},"summary":"GetTemporalBaseline","tags":["InfrastructureService"]}},"/api/infrastructure/v1/list-internet-outages":{"post":{"description":"ListInternetOutages retrieves detected internet outages from Cloudflare Radar.","operationId":"ListInternetOutages","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListInternetOutagesRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListInternetOutagesResponse"}}},"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"},"default":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Error response"}},"summary":"ListInternetOutages","tags":["InfrastructureService"]}},"/api/infrastructure/v1/list-service-statuses":{"post":{"description":"ListServiceStatuses retrieves operational status of monitored external services.","operationId":"ListServiceStatuses","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListServiceStatusesRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListServiceStatusesResponse"}}},"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"},"default":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Error response"}},"summary":"ListServiceStatuses","tags":["InfrastructureService"]}},"/api/infrastructure/v1/record-baseline-snapshot":{"post":{"description":"RecordBaselineSnapshot batch-updates baseline statistics using Welford's online algorithm.","operationId":"RecordBaselineSnapshot","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordBaselineSnapshotRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordBaselineSnapshotResponse"}}},"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"},"default":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Error response"}},"summary":"RecordBaselineSnapshot","tags":["InfrastructureService"]}}}}