openc3-cosmos-constellation 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb5edbac0bd29425edc88aec0efa8f52ca7c9ba2c1fd2055f7e24be0626cc0ae
4
- data.tar.gz: 14b8f6b2f44ea09a03870f890d05ee9e62c1fdb2527432b5314d03a8fe571f6a
3
+ metadata.gz: 2c572e1300a99399b60505111f300fbb0252d6a18f068e545bb1101543c73586
4
+ data.tar.gz: 16332d58cb180465ab2e46f4576397a4717abcab993e79eccea9e9e878259202
5
5
  SHA512:
6
- metadata.gz: 8620e33fbacc23d7512c315f38db1fb2414d5b77c6cdc78c60c0d84bf548c22ceae7782a7c8d471bc4fe3f716ddcbc0e72f636b914f6667af15442a4615b2ca2
7
- data.tar.gz: '0699f4dfd88fedd63752bf819b8d11e3a7af7105c042950569826532c6df9feb6f2e0aee1250ed1011c1a6548d4c11a7540cfba594f15a1b467bbfcc8ec6782f'
6
+ metadata.gz: a6bd56e30b1356d386fd1e09aa00da8a66f0cd1e413011fb717dc85895fe697f420986ba3323d94f6d787b39b111caa7a3432d2576c25f5931172b5028063398
7
+ data.tar.gz: 83e50e58575f8e3e134302a0bd940252d8f01845a9516e4880a7e85b28fd572bf7fae6f8f787a8f34b2261917ecf833702e41745980a2c50f9cb3eb85505a8a9
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- # Builds openc3-cosmos-constellation-<VERSION>.gem: rake build VERSION=0.9.0
2
- # (or ./openc3.sh cli rake build VERSION=0.9.0 inside a COSMOS checkout).
1
+ # Builds openc3-cosmos-constellation-<VERSION>.gem: rake build VERSION=0.10.0
2
+ # (or ./openc3.sh cli rake build VERSION=0.10.0 inside a COSMOS checkout).
3
3
  PLUGIN_NAME = Dir['*.gemspec'][0].split('.')[0..-2].join('.')
4
4
 
5
5
  # The tool draws the shared Constellation Forecast view, copied in from this repo when it is here.
@@ -13,7 +13,7 @@ SHARED_RESULTS = '../../clients/python/src/constellation_space/results.py'
13
13
  SHARED_LICENSE = '../../LICENSE'
14
14
 
15
15
  task :build do
16
- abort('VERSION is required: rake build VERSION=0.9.0') unless ENV['VERSION']
16
+ abort('VERSION is required: rake build VERSION=0.10.0') unless ENV['VERSION']
17
17
  FileUtils.cp(SHARED_VIEW, VIEW) if File.exist?(SHARED_VIEW)
18
18
  abort("#{VIEW} is missing: copy bridges/shared/forecast-view.js there") unless File.exist?(VIEW)
19
19
  if File.exist?(SHARED_RESULTS)
@@ -17,9 +17,17 @@ target's packets (targets/CONSTELLATION/cmd_tlm/tlm.txt):
17
17
  HELD the soonest swap Constellation holds for a person to decide, read from
18
18
  GET /predictions/actions, with the ids the APPROVE_SWAP and DECLINE_SWAP
19
19
  commands take (cmd_tlm/cmd.txt, with the plugin's approvals on)
20
- CAPACITY one day's capacity across the antennas, and the tightest
20
+ CAPACITY one day's antennas and the tightest, and the run's passes, minutes and GB
21
+ across them as the API totals them
21
22
  MODCOD the next pass's MODCOD plan
22
23
  RUN the latest workflow run received, of any kind
24
+ PASS_TRACE with the plugin's trace on: NEXT_PASS's pass trace as the API sent it
25
+ (usable seconds, conditions, what limits it, its worst margin); TRACED NO
26
+ for a pass without one
27
+ MINIMUM the latest contract-minimum (SLA) alert, its own feed entry: at risk,
28
+ missed or cleared (LEVEL goes yellow, then red), its scope, period and
29
+ numbers as the API sent them; each also a line in COSMOS's log messages
30
+ (a warning at risk or missed), once per alert key
23
31
 
24
32
  A packet is injected only once a run of its kind has arrived; HELD once a swap run has.
25
33
 
@@ -61,7 +69,7 @@ from typing import Any
61
69
 
62
70
  from constellation_space import results
63
71
 
64
- VERSION = "0.9.0"
72
+ VERSION = "0.10.0"
65
73
  TARGET = "CONSTELLATION"
66
74
  POLL_S = int(os.environ.get("POLL_SECONDS", "15"))
67
75
  # COSMOS shows a packet stale 30 s after its last value: re-inject every poll so a quiet feed
@@ -128,6 +136,7 @@ def packet_name(name: str) -> str:
128
136
  SATELLITES = pairs(os.environ.get("SATELLITES", ""))
129
137
  OUTCOMES = pairs(os.environ.get("OUTCOMES", ""))
130
138
  TIMELINE_ON = os.environ.get("TIMELINE", "off").strip().lower() == "on"
139
+ TRACE_ON = os.environ.get("TRACE", "off").strip().lower() == "on"
131
140
 
132
141
 
133
142
  # The bytes of each STRING item in tlm.txt, by item name (a test holds them to it). COSMOS drops
@@ -155,6 +164,21 @@ STRING_BYTES = {
155
164
  "RUN_ID": 64,
156
165
  "ITEM_ID": 64,
157
166
  "RECEIVED": 32,
167
+ "KIND": 32,
168
+ "BAND": 8,
169
+ "PERIOD": 16,
170
+ "PERIOD_START": 32,
171
+ "PERIOD_END": 32,
172
+ "MEASURE": 16,
173
+ "UNIT": 16,
174
+ "EVIDENCE": 256,
175
+ "MINIMUM_ID": 32,
176
+ "RAISED": 32,
177
+ "CONDITIONS": 16,
178
+ "LIMIT": 16,
179
+ "WORST_CAUSE": 16,
180
+ "WORST_AT": 32,
181
+ "TRUNCATED": 16,
158
182
  }
159
183
 
160
184
 
@@ -407,9 +431,13 @@ NO_SWAP: dict[str, Any] = {
407
431
  }
408
432
 
409
433
 
410
- def capacity_packet(items: list[dict[str, Any]], now: datetime) -> dict[str, Any] | None:
411
- """CAPACITY: one day's capacity across the antennas (today's, else the next day forecast),
412
- and the antenna with the least of it. None without antenna-day items."""
434
+ def capacity_packet(
435
+ items: list[dict[str, Any]], now: datetime, totals: dict[str, Any] | None = None
436
+ ) -> dict[str, Any] | None:
437
+ """CAPACITY: one day's antennas (today's, else the next day forecast) and the one with the
438
+ least, with the run's passes, minutes and GB across them as the API totals them (`totals`,
439
+ its whole window; 0 when it serves none), never summed here. None without antenna-day
440
+ items."""
413
441
  days = [
414
442
  i
415
443
  for i in items
@@ -422,15 +450,15 @@ def capacity_packet(items: list[dict[str, Any]], now: datetime) -> dict[str, Any
422
450
  day = today if today in dates else next((d for d in dates if d > today), dates[-1])
423
451
  rows = [d for d in days if d["target_at"][:10] == day]
424
452
  tightest = min(rows, key=lambda d: d["value"]["p50"])
425
- # A run that forecasts p50 only has no wet tail: 0, as the packet field cannot be empty.
426
- wet_tail = all(isinstance(r["value"].get("p10"), int | float) for r in rows)
453
+ run = (totals or {}).get("overall") or {}
427
454
  return {
428
455
  "DAY": day,
429
456
  "ANTENNAS": len(rows),
430
- "PASSES": sum(int(r["value"].get("passes") or 0) for r in rows),
431
- "SELLABLE_MIN": round(sum(float(r["value"].get("sellable_min") or 0) for r in rows), 1),
432
- "GB_P10": round(sum(r["value"]["p10"] for r in rows), 3) if wet_tail else 0.0,
433
- "GB_P50": round(sum(r["value"]["p50"] for r in rows), 3),
457
+ "PASSES": run.get("counted_passes", 0),
458
+ "SELLABLE_MIN": run.get("minutes", 0.0),
459
+ # Deprecated: the API totals no p10.
460
+ "GB_P10": 0.0,
461
+ "GB_P50": run.get("gb", 0.0),
434
462
  "TIGHTEST_ANTENNA": tightest["entity"]["id"],
435
463
  "TIGHTEST_GB_P50": round(tightest["value"]["p50"], 3),
436
464
  # The run's window covers only part of the day: its numbers are that part's.
@@ -508,6 +536,55 @@ def pass_values(item: dict[str, Any], minimum: float | None) -> dict[str, Any]:
508
536
  }
509
537
 
510
538
 
539
+ NO_TRACE: dict[str, Any] = {
540
+ "SATELLITE": "NONE",
541
+ "ANTENNA": "NONE",
542
+ "AOS": "",
543
+ "TRACED": "NO",
544
+ "USABLE_S": 0.0,
545
+ "DURATION_S": 0.0,
546
+ "CONDITIONS": "",
547
+ "LIMIT": "",
548
+ "WORST_MARGIN_DB": 0.0,
549
+ "WORST_CAUSE": "",
550
+ "WORST_AT": "",
551
+ "TRUNCATED": "",
552
+ }
553
+
554
+
555
+ def trace_packet(passes: list[dict[str, Any]], now: datetime) -> dict[str, Any]:
556
+ """PASS_TRACE: the trace of the pass NEXT_PASS shows, its values as the API sent them; a
557
+ pass without one (a run from before traces) is TRACED NO and the rest empty or 0."""
558
+ ahead = sorted(
559
+ (p for p in passes if datetime.fromisoformat(p["target_at"]) > now),
560
+ key=lambda p: p["target_at"],
561
+ )
562
+ if not ahead:
563
+ return dict(NO_TRACE)
564
+ nxt = ahead[0]
565
+ out = {
566
+ **NO_TRACE,
567
+ "SATELLITE": nxt["entity"]["satellite_id"],
568
+ "ANTENNA": nxt["entity"]["antenna_id"],
569
+ "AOS": _minute(nxt["target_at"]),
570
+ }
571
+ v = results.trace_summary(nxt)
572
+ if v is None:
573
+ return out
574
+ return {
575
+ **out,
576
+ "TRACED": "YES",
577
+ "USABLE_S": _number(v["usable_s"]),
578
+ "DURATION_S": _number(v["duration_s"]),
579
+ "CONDITIONS": v["conditions"] or "",
580
+ "LIMIT": v["limit"] or "",
581
+ "WORST_MARGIN_DB": _number(v["worst_margin_db"]),
582
+ "WORST_CAUSE": v["worst_cause"] or "",
583
+ "WORST_AT": _minute(v["worst_at"]),
584
+ "TRUNCATED": v["truncated"] or "",
585
+ }
586
+
587
+
511
588
  # With nothing held for a decision the minutes left sit far above the limits: green, not red.
512
589
  NO_HELD: dict[str, Any] = {
513
590
  "OPEN": 0,
@@ -561,6 +638,33 @@ def held_packet(waiting: list[dict[str, Any]], now: datetime) -> dict[str, Any]:
561
638
  }
562
639
 
563
640
 
641
+ def minimum_packet(alert: dict[str, Any]) -> dict[str, Any]:
642
+ """MINIMUM's values for one SLA alert, its numbers as the API sent them: an amount it lacks
643
+ (the forecast of a missed minimum, what an at-risk one delivered) is 0, as KIND says."""
644
+ v = results.sla_values(alert)
645
+ return {
646
+ # A state item: COSMOS takes its state's name for a converted value, never its number.
647
+ "LEVEL": "MISSED" if v["kind"] == "minimum_missed" else "CLEARED" if v["cleared"] else "AT_RISK",
648
+ "KIND": v["kind"],
649
+ "SATELLITE": v["satellite"] or "",
650
+ "BAND": v["band"] or "",
651
+ "PERIOD": v["period"] or "",
652
+ "PERIOD_START": _minute(v["period_start"]),
653
+ "PERIOD_END": _minute(v["period_end"]),
654
+ "MEASURE": v["measure"] or "",
655
+ "UNIT": v["unit"] or "",
656
+ "TARGET": v["target"] or 0.0,
657
+ "FORECAST": v["forecast"] or 0.0,
658
+ "DELIVERED": v["delivered"] or 0.0,
659
+ "SHORTFALL": v["shortfall"] or 0.0,
660
+ "DEADLINE": _minute(v["deadline"]),
661
+ "EVIDENCE": v["evidence"] or "",
662
+ "MINIMUM_ID": v["minimum_id"] or "",
663
+ "RUN_ID": v["run_id"] or "",
664
+ "RAISED": _minute(v["raised_at"]),
665
+ }
666
+
667
+
564
668
  def packets(
565
669
  passes: list[dict[str, Any]],
566
670
  swaps: list[dict[str, Any]],
@@ -576,8 +680,8 @@ def packets(
576
680
  `minimum` the workspace's contract minimum in GB, `satellites` those with a NEXT_PASS packet
577
681
  of their own (Constellation id to COSMOS name), `waiting` the actions read from
578
682
  GET /predictions/actions (None: no HELD packet), and `day` the pass run's totals.next_24h as
579
- the API serves it: NEXT_24H's passes and GB are its satellites', which overlap nowhere, never
580
- the passes summed here (None: no NEXT_24H)."""
683
+ the API serves it: NEXT_24H's passes and GB are its overall, never a sum here (None: no
684
+ NEXT_24H)."""
581
685
  upcoming = sorted(
582
686
  (p for p in passes if datetime.fromisoformat(p["until"]) > now),
583
687
  key=lambda p: p["target_at"],
@@ -594,13 +698,12 @@ def packets(
594
698
  "SWAP": {**NO_SWAP, "PENDING": pending},
595
699
  }
596
700
  if day is not None:
597
- satellites_day = day["by_satellite"].values()
598
701
  out = {
599
702
  "NEXT_24H": {
600
- "PASSES": sum(s["counted_passes"] for s in satellites_day),
703
+ "PASSES": day["overall"]["counted_passes"],
601
704
  # Deprecated: the API totals no p10.
602
705
  "EXPECTED_GB_P10": 0.0,
603
- "EXPECTED_GB_P50": round(sum(s["gb"] for s in satellites_day), 3),
706
+ "EXPECTED_GB_P50": day["overall"]["gb"],
604
707
  "AT_RISK": sum(at_risk(p, minimum) for p in upcoming_day),
605
708
  },
606
709
  **out,
@@ -658,6 +761,8 @@ class Forecast:
658
761
  # be approved (held_until): counted until then, not shown. None only in a 0.8.0 state.
659
762
  self.held: list[str | None] = []
660
763
  self.capacity: list[dict[str, Any]] | None = None
764
+ # The capacity run's totals as the API serves them; None when it serves none.
765
+ self.capacity_totals: dict[str, Any] | None = None
661
766
  self.plans: list[dict[str, Any]] | None = None
662
767
  # The pass run's totals.next_24h as the API serves it; None when it serves none.
663
768
  self.day: dict[str, Any] | None = None
@@ -670,6 +775,19 @@ class Forecast:
670
775
  # (GET /predictions/actions), for HELD.
671
776
  self.swap_workflows: list[str] = []
672
777
  self.waiting: list[dict[str, Any]] = []
778
+ # The latest SLA alert's MINIMUM values, and every alert key shown (results.unfired).
779
+ self.minimum_alert: dict[str, Any] | None = None
780
+ self.fired: dict[str, str] = {}
781
+
782
+ def alert(self, alert: dict[str, Any]) -> None:
783
+ """Shows an SLA alert in MINIMUM and says it in COSMOS's log messages; it counts as
784
+ fired (fire()) only once the packet is injected."""
785
+ self.minimum_alert = minimum_packet(alert)
786
+ log(f"{results.sla_level(alert)}: {results.sla_text(alert)}", warn=not alert.get("cleared"))
787
+
788
+ def fire(self, alerts: list[dict[str, Any]]) -> None:
789
+ for alert in alerts:
790
+ self.fired[alert["key"]] = results.fired_until(alert)
673
791
 
674
792
  def take(
675
793
  self,
@@ -686,6 +804,7 @@ class Forecast:
686
804
  self.swap_workflows.append(slug)
687
805
  elif answers == "antenna-capacity":
688
806
  self.capacity = items
807
+ self.capacity_totals = totals
689
808
  elif answers == "modcod-plan":
690
809
  self.plans = modcod_plans(items)
691
810
  elif answers == "pass-yield":
@@ -729,14 +848,18 @@ class Forecast:
729
848
  if self.passes is None:
730
849
  for name in [n for n in out if n == "NEXT_24H" or n.startswith("NEXT_PASS")]:
731
850
  del out[name]
851
+ elif TRACE_ON:
852
+ out["PASS_TRACE"] = trace_packet(self.passes, now)
732
853
  if self.swaps is None:
733
854
  del out["SWAP"]
734
855
  if self.capacity is not None:
735
- out["CAPACITY"] = capacity_packet(self.capacity, now) or NO_CAPACITY
856
+ out["CAPACITY"] = capacity_packet(self.capacity, now, self.capacity_totals) or NO_CAPACITY
736
857
  if self.plans is not None:
737
858
  out["MODCOD"] = modcod_packet(self.plans, now) or NO_MODCOD
738
859
  if self.run:
739
860
  out["RUN"] = self.run
861
+ if self.minimum_alert is not None:
862
+ out["MINIMUM"] = self.minimum_alert
740
863
  for packet, values in out.items():
741
864
  inject(packet, fit(values))
742
865
  return len(out)
@@ -1198,7 +1321,7 @@ def main() -> None:
1198
1321
  not only with runs."""
1199
1322
  nonlocal refreshed
1200
1323
  while seconds > 0:
1201
- if time.time() - refreshed > REFRESH_S and forecast.run:
1324
+ if time.time() - refreshed > REFRESH_S and (forecast.run or forecast.minimum_alert):
1202
1325
  try:
1203
1326
  forecast.publish(datetime.now(UTC))
1204
1327
  refreshed = time.time()
@@ -1255,6 +1378,13 @@ def main() -> None:
1255
1378
  log(lost, warn=True)
1256
1379
  for entry in page["entries"]:
1257
1380
  entry = results.whole(entry, lambda c, n: results.rest_of_run(call, consumer, c, n))
1381
+ # An SLA alert entry is no run: shown, never reported.
1382
+ alerts = results.unfired(results.sla_alerts(entry["otlp"], consumer, log), forecast.fired)
1383
+ if alerts:
1384
+ for alert in alerts:
1385
+ forecast.alert(alert)
1386
+ forecast.publish(datetime.now(UTC))
1387
+ forecast.fire(alerts)
1258
1388
  parts = results.unpack(entry["otlp"], consumer, log)
1259
1389
  if not parts:
1260
1390
  cursor = entry["cursor"]
@@ -469,14 +469,17 @@ def unpack(
469
469
  ) -> list[tuple[dict[str, Any], list[dict[str, Any]]]]:
470
470
  """A results entry's parts for this connection: each resourceLogs (one per feed output of the
471
471
  run) whose constellation.connection is `consumer`, as its resource attributes and its items.
472
- Parts for other connections are left alone; a part in an item shape this bridge does not read
473
- is skipped and logged."""
472
+ Parts for other connections, and SLA alerts (sla_alerts()), are left alone; a part in an item
473
+ shape this bridge does not read is skipped and logged."""
474
474
  parts = []
475
475
  for logs in otlp.get("resourceLogs", []):
476
476
  resource = {
477
477
  kv["key"]: plain(kv["value"]) for kv in logs.get("resource", {}).get("attributes", [])
478
478
  }
479
- if resource.get("constellation.connection") != consumer:
479
+ if (
480
+ resource.get("constellation.connection") != consumer
481
+ or resource.get("constellation.kind") == SLA_KIND
482
+ ):
480
483
  continue
481
484
  records = [r for scope in logs.get("scopeLogs", []) for r in scope.get("logRecords", [])]
482
485
  if newer := newer_shapes(records):
@@ -489,6 +492,129 @@ def unpack(
489
492
  return parts
490
493
 
491
494
 
495
+ # Contract-minimum (SLA) alerts: each its own feed entry, never a run, so a bridge shows it and
496
+ # reads on past it with nothing to apply or report (no POST /predictions/feed/deliveries).
497
+ SLA_KIND = "sla_alert"
498
+ SLA_SCHEMA = "constellation.sla_alert/v1"
499
+ SLA_KINDS = ("minimum_at_risk", "minimum_missed")
500
+
501
+
502
+ def sla_alerts(
503
+ otlp: dict[str, Any], consumer: str, log: Callable[[str], None] = print
504
+ ) -> list[dict[str, Any]]:
505
+ """The SLA alerts in a feed entry for this connection: each record of its resources whose
506
+ constellation.kind is sla_alert. One in another shape, or without the key and kind every
507
+ bridge reads, is skipped and logged; any other field may be missing, and is then not shown."""
508
+ found = []
509
+ for logs in otlp.get("resourceLogs", []):
510
+ resource = {
511
+ kv["key"]: plain(kv["value"]) for kv in logs.get("resource", {}).get("attributes", [])
512
+ }
513
+ if (
514
+ resource.get("constellation.connection") != consumer
515
+ or resource.get("constellation.kind") != SLA_KIND
516
+ ):
517
+ continue
518
+ for record in (r for s in logs.get("scopeLogs", []) for r in s.get("logRecords", [])):
519
+ (shape,) = newer_shapes([record]) or {SCHEMA}
520
+ alert = plain(record.get("body") or {})
521
+ kind = alert.get("kind") if isinstance(alert, dict) else None
522
+ if shape != SLA_SCHEMA or kind not in SLA_KINDS or not isinstance(alert.get("key"), str):
523
+ log(f"skipped an SLA alert this bridge does not read: {shape}, kind {kind}")
524
+ continue
525
+ found.append(alert)
526
+ return found
527
+
528
+
529
+ def unfired(alerts: list[dict[str, Any]], fired: dict[str, str]) -> list[dict[str, Any]]:
530
+ """The alerts not fired before, once each, by their key: the API's idempotency key, one per
531
+ minimum and period, and per re-fire or clearing of an at-risk one. `fired` is the bridge's
532
+ state, key to fired_until(), so neither the feed read again nor a restart fires one twice;
533
+ a bridge adds a key once the alert is shown, and keys long over are dropped here."""
534
+ _drop_over(fired)
535
+ return list({a["key"]: a for a in alerts if a["key"] not in fired}.values())
536
+
537
+
538
+ def fired_until(alert: dict[str, Any]) -> str:
539
+ """When a fired alert's key may be forgotten: KEEP_ACTED past its period's end, or now."""
540
+ end = parse_time(sla_field(alert, "period", "end")) or now()
541
+ return (max(end, now()) + KEEP_ACTED).isoformat(timespec="seconds")
542
+
543
+
544
+ def sla_field(alert: dict[str, Any], *path: str) -> Any:
545
+ """The value at `path` in an alert, or None where it has none."""
546
+ value: Any = alert
547
+ for key in path:
548
+ value = value.get(key) if isinstance(value, dict) else None
549
+ return value
550
+
551
+
552
+ def sla_level(alert: dict[str, Any]) -> str:
553
+ """CRITICAL for a missed minimum, INFO for an at-risk one cleared, else WARNING."""
554
+ if alert["kind"] == "minimum_missed":
555
+ return "CRITICAL"
556
+ return "INFO" if alert.get("cleared") is True else "WARNING"
557
+
558
+
559
+ def sla_values(alert: dict[str, Any]) -> dict[str, Any]:
560
+ """An alert's fields as plain values, as the API sends them: numbers never computed here, and
561
+ None for any the alert lacks (forecast on a missed minimum, delivered on an at-risk one)."""
562
+
563
+ def number(*path: str) -> float | None:
564
+ v = sla_field(alert, *path)
565
+ return float(v) if isinstance(v, int | float) and not isinstance(v, bool) else None
566
+
567
+ def text(*path: str) -> str | None:
568
+ v = sla_field(alert, *path)
569
+ return v if isinstance(v, str) else None
570
+
571
+ evidence = alert.get("evidence_pass_ids")
572
+ return {
573
+ "kind": alert["kind"],
574
+ "cleared": alert.get("cleared") is True,
575
+ "key": alert["key"],
576
+ "minimum_id": text("minimum_id"),
577
+ "satellite": text("scope", "satellite_id"),
578
+ "band": text("scope", "band"),
579
+ "period": text("period", "kind"),
580
+ "period_start": text("period", "start"),
581
+ "period_end": text("period", "end"),
582
+ "measure": text("measure"),
583
+ "unit": text("unit"),
584
+ "target": number("target"),
585
+ "forecast": number("forecast"),
586
+ "delivered": number("delivered"),
587
+ "shortfall": number("shortfall"),
588
+ "deadline": text("deadline"),
589
+ "evidence": ", ".join(e for e in evidence if isinstance(e, str))
590
+ if isinstance(evidence, list)
591
+ else None,
592
+ "run_id": text("run_id"),
593
+ "raised_at": text("raised_at"),
594
+ }
595
+
596
+
597
+ def sla_text(alert: dict[str, Any]) -> str:
598
+ """An alert as a person reads it: the API's own title and text, the words its Slack and email
599
+ alerts use, else its kind and scope."""
600
+ said = (alert.get("title"), alert.get("text"))
601
+ words = [w.rstrip(".") for w in said if isinstance(w, str) and w]
602
+ if words:
603
+ return ". ".join(words) + "."
604
+ v = sla_values(alert)
605
+ scope = (v["satellite"] or "a satellite") + (f" {v['band']}-band" if v["band"] else "")
606
+ what = "missed" if v["kind"] == "minimum_missed" else "cleared" if v["cleared"] else "at risk"
607
+ return f"{scope}: contract minimum {what}" + (
608
+ f" for the {v['period']} from {minute(v['period_start'])}" if v["period"] else ""
609
+ )
610
+
611
+
612
+ def sla_incident(alert: dict[str, Any]) -> str:
613
+ """The incident an alert is about, one per minimum and period: a later alert of it (a re-fire,
614
+ its clearing, the period missed) replaces the one shown."""
615
+ return f"{alert.get('minimum_id')}|{sla_field(alert, 'period', 'start')}"
616
+
617
+
492
618
  def expired(page: dict[str, Any], cursor: str) -> str | None:
493
619
  """Why runs were lost when the feed no longer holds `cursor` (it sorts before the page's
494
620
  oldest entry: runs after it expired unread); None when it still does."""
@@ -676,3 +802,33 @@ def expected_gb(item: dict[str, Any]) -> dict[str, Any] | None:
676
802
  ):
677
803
  return gb
678
804
  return None
805
+
806
+
807
+ def trace_summary(item: dict[str, Any]) -> dict[str, Any] | None:
808
+ """A priced pass's trace summary as the API sent it (os computes every value; none is
809
+ derived here): None for an item without one. A field the trace lacks is None."""
810
+ trace = item.get("trace")
811
+ if not isinstance(trace, dict):
812
+ return None
813
+
814
+ def number(*path: str) -> float | None:
815
+ v = sla_field(trace, *path)
816
+ return float(v) if isinstance(v, int | float) and not isinstance(v, bool) else None
817
+
818
+ def text(*path: str) -> str | None:
819
+ v = sla_field(trace, *path)
820
+ return v if isinstance(v, str) else None
821
+
822
+ truncated = trace.get("truncated")
823
+ return {
824
+ "usable_s": number("usable_s"),
825
+ "duration_s": number("duration_s"),
826
+ "conditions": text("conditions"),
827
+ "limit": text("limit"),
828
+ "worst_margin_db": number("worst", "margin_db"),
829
+ "worst_cause": text("worst", "cause"),
830
+ "worst_at": text("worst", "at"),
831
+ "truncated": ", ".join(t for t in truncated if isinstance(t, str))
832
+ if isinstance(truncated, list)
833
+ else None,
834
+ }
data/plugin.txt CHANGED
@@ -17,6 +17,14 @@ VARIABLE timeline off
17
17
  VARIABLE_DESCRIPTION "COSMOS Enterprise only. on: forecast passes of the next 48 hours as reserve activities on a CONSTELLATION timeline, which Enterprise's Calendar shows; on Core the bridge says so in its log and makes no timeline"
18
18
  VARIABLE_STATE Off off
19
19
  VARIABLE_STATE On on
20
+ VARIABLE trace off
21
+ VARIABLE_DESCRIPTION "on: a PASS_TRACE packet with the next pass's trace (usable seconds, conditions, limit, worst margin) as Constellation sends it"
22
+ VARIABLE_STATE Off off
23
+ VARIABLE_STATE On on
24
+ VARIABLE pass_profile off
25
+ VARIABLE_DESCRIPTION "Deprecated, read for one release: on is the same as trace on"
26
+ VARIABLE_STATE Off off
27
+ VARIABLE_STATE On on
20
28
 
21
29
  TARGET CONSTELLATION CONSTELLATION
22
30
 
@@ -34,6 +42,7 @@ MICROSERVICE BRIDGE constellation-bridge
34
42
  ENV SATELLITES "<%= satellites %>"
35
43
  ENV OUTCOMES "<%= outcomes %>"
36
44
  ENV TIMELINE <%= timeline %>
45
+ ENV TRACE <%= [trace, pass_profile].include?("on") ? "on" : "off" %>
37
46
  # Admin > Secrets: CONSTELLATION_API_KEY (a key with predictions:read; telemetry:write too for
38
47
  # outcomes). The bridge reads it there at each poll, so it can be added or changed after
39
48
  # installing.
@@ -99,18 +99,18 @@ TELEMETRY CONSTELLATION HELD BIG_ENDIAN "The soonest rain-fade swap Constellatio
99
99
  FORMAT_STRING "%.1f"
100
100
  LIMITS DEFAULT 1 ENABLED 15 30 100000 100000
101
101
 
102
- TELEMETRY CONSTELLATION CAPACITY BIG_ENDIAN "Forecast: one day's capacity across the antennas, and the tightest"
102
+ TELEMETRY CONSTELLATION CAPACITY BIG_ENDIAN "Forecast: one day's antennas and the tightest, and the capacity run's totals across them"
103
103
  ALLOW_SHORT
104
104
  APPEND_ITEM DAY 128 STRING "Day, UTC"
105
105
  APPEND_ITEM ANTENNAS 32 UINT "Antennas forecast"
106
- APPEND_ITEM PASSES 32 UINT "Predicted passes"
107
- APPEND_ITEM SELLABLE_MIN 64 FLOAT "Sellable contact minutes"
106
+ APPEND_ITEM PASSES 32 UINT "Passes the run counts, as Constellation totals them (0 when it serves no totals)"
107
+ APPEND_ITEM SELLABLE_MIN 64 FLOAT "Sellable contact minutes over the run, as Constellation totals them"
108
108
  UNITS Minutes min
109
109
  FORMAT_STRING "%.1f"
110
110
  APPEND_ITEM GB_P10 64 FLOAT "Deprecated, kept only so layouts do not break. Read GB_P50"
111
111
  UNITS Gigabytes GB
112
112
  FORMAT_STRING "%.3f"
113
- APPEND_ITEM GB_P50 64 FLOAT "Expected GB (p50)"
113
+ APPEND_ITEM GB_P50 64 FLOAT "Expected GB (p50) over the run, as Constellation totals them"
114
114
  UNITS Gigabytes GB
115
115
  FORMAT_STRING "%.3f"
116
116
  APPEND_ITEM TIGHTEST_ANTENNA 512 STRING "Antenna with the least expected GB that day"
@@ -142,3 +142,53 @@ TELEMETRY CONSTELLATION RUN BIG_ENDIAN "The latest workflow run received, of any
142
142
  APPEND_ITEM RUN_ID 512 STRING "Run id"
143
143
  APPEND_ITEM RESULTS 32 UINT "Results in the run"
144
144
  APPEND_ITEM RECEIVED 256 STRING "When this COSMOS received the run, UTC"
145
+
146
+ TELEMETRY CONSTELLATION MINIMUM BIG_ENDIAN "The latest contract-minimum alert: a satellite's minimum for a period at risk, missed, or cleared"
147
+ ALLOW_SHORT
148
+ APPEND_ITEM LEVEL 8 UINT "CLEARED, AT_RISK (forecast under the minimum) or MISSED (the period closed under it)"
149
+ STATE CLEARED 0 GREEN
150
+ STATE AT_RISK 1 YELLOW
151
+ STATE MISSED 2 RED
152
+ APPEND_ITEM KIND 256 STRING "minimum_at_risk or minimum_missed"
153
+ APPEND_ITEM SATELLITE 512 STRING "Satellite id"
154
+ APPEND_ITEM BAND 64 STRING "Band, empty for every band"
155
+ APPEND_ITEM PERIOD 128 STRING "day, week or month"
156
+ APPEND_ITEM PERIOD_START 256 STRING "The period's start, UTC"
157
+ APPEND_ITEM PERIOD_END 256 STRING "The period's end (exclusive), UTC"
158
+ APPEND_ITEM MEASURE 128 STRING "gb_delivered, contacts or minutes"
159
+ APPEND_ITEM UNIT 128 STRING "GB, contacts or minutes: the unit of the amounts below"
160
+ APPEND_ITEM TARGET 64 FLOAT "The minimum for the period"
161
+ FORMAT_STRING "%.3f"
162
+ APPEND_ITEM FORECAST 64 FLOAT "At risk: the forecast for the whole period (0 on a missed alert)"
163
+ FORMAT_STRING "%.3f"
164
+ APPEND_ITEM DELIVERED 64 FLOAT "Missed: what the pass logs say was delivered (0 on an at-risk alert)"
165
+ FORMAT_STRING "%.3f"
166
+ APPEND_ITEM SHORTFALL 64 FLOAT "The minimum less the forecast or delivered amount"
167
+ FORMAT_STRING "%.3f"
168
+ APPEND_ITEM DEADLINE 256 STRING "At risk: when to decide on the backups by, UTC"
169
+ APPEND_ITEM EVIDENCE 2048 STRING "Pass ids behind it: at risk, those driving the shortfall; missed, those failed, missed or unlogged"
170
+ APPEND_ITEM MINIMUM_ID 256 STRING "The contract minimum"
171
+ APPEND_ITEM RUN_ID 512 STRING "The run whose forecast raised it; empty when the period close did"
172
+ APPEND_ITEM RAISED 256 STRING "When Constellation raised it, UTC"
173
+ TELEMETRY CONSTELLATION PASS_TRACE BIG_ENDIAN "Forecast: the next pass's trace, as Constellation sent it (plugin trace on)"
174
+ ALLOW_SHORT
175
+ APPEND_ITEM SATELLITE 512 STRING "Satellite id"
176
+ APPEND_ITEM ANTENNA 512 STRING "Antenna id"
177
+ APPEND_ITEM AOS 256 STRING "Predicted acquisition of signal, UTC"
178
+ APPEND_ITEM TRACED 8 UINT "YES when the pass has a trace; NO for a run from before traces, the rest then empty or 0"
179
+ STATE NO 0
180
+ STATE YES 1
181
+ APPEND_ITEM USABLE_S 64 FLOAT "Seconds the link closes (margin at or above 0 dB)"
182
+ UNITS Seconds s
183
+ FORMAT_STRING "%.0f"
184
+ APPEND_ITEM DURATION_S 64 FLOAT "Pass length"
185
+ UNITS Seconds s
186
+ FORMAT_STRING "%.0f"
187
+ APPEND_ITEM CONDITIONS 128 STRING "clear_sky, rain, outage or no_link"
188
+ APPEND_ITEM LIMIT 128 STRING "What caps the pass's GB most: geometry, weather, interference, equipment or none"
189
+ APPEND_ITEM WORST_MARGIN_DB 64 FLOAT "Lowest link margin over the pass (p50); below 0 is an outage"
190
+ UNITS Decibels dB
191
+ FORMAT_STRING "%.2f"
192
+ APPEND_ITEM WORST_CAUSE 128 STRING "Why the margin is lowest there: rain, elevation, interference or none"
193
+ APPEND_ITEM WORST_AT 256 STRING "When the margin is lowest, UTC"
194
+ APPEND_ITEM TRUNCATED 128 STRING "The ends the run window cuts (aos, los), empty when none"
@@ -113,6 +113,50 @@ TABBOOK
113
113
  END
114
114
  END
115
115
  END
116
+ TABITEM "Contract minimum"
117
+ HORIZONTAL
118
+ VERTICAL
119
+ LABELVALUEDESC CONSTELLATION MINIMUM LEVEL "Alert" CONVERTED 18
120
+ LABELVALUEDESC CONSTELLATION MINIMUM SATELLITE "Satellite" CONVERTED 18
121
+ LABELVALUEDESC CONSTELLATION MINIMUM BAND "Band" CONVERTED 18
122
+ LABELVALUEDESC CONSTELLATION MINIMUM PERIOD "Period" CONVERTED 18
123
+ LABELVALUEDESC CONSTELLATION MINIMUM PERIOD_START "From" CONVERTED 18
124
+ LABELVALUEDESC CONSTELLATION MINIMUM DEADLINE "Decide by" CONVERTED 18
125
+ END
126
+ VERTICAL
127
+ LABELVALUEDESC CONSTELLATION MINIMUM UNIT "Unit" CONVERTED 18
128
+ LABELVALUEDESC CONSTELLATION MINIMUM TARGET "Minimum" CONVERTED 18
129
+ LABELVALUEDESC CONSTELLATION MINIMUM FORECAST "Forecast" CONVERTED 18
130
+ LABELVALUEDESC CONSTELLATION MINIMUM DELIVERED "Delivered" CONVERTED 18
131
+ LABELVALUEDESC CONSTELLATION MINIMUM SHORTFALL "Short by" CONVERTED 18
132
+ LABELVALUEDESC CONSTELLATION MINIMUM RAISED "Raised" CONVERTED 18
133
+ END
134
+ END
135
+ SPACER 0 8
136
+ TEXTBOX CONSTELLATION MINIMUM EVIDENCE 900 44
137
+ END
138
+ <%- if [trace, pass_profile].any? { |v| v.to_s.strip.downcase == "on" } -%>
139
+ TABITEM "Pass trace"
140
+ HORIZONTAL
141
+ VERTICAL
142
+ LABELVALUEDESC CONSTELLATION PASS_TRACE SATELLITE "Satellite" CONVERTED 18
143
+ LABELVALUEDESC CONSTELLATION PASS_TRACE ANTENNA "Antenna" CONVERTED 18
144
+ LABELVALUEDESC CONSTELLATION PASS_TRACE AOS "AOS" CONVERTED 18
145
+ LABELVALUEDESC CONSTELLATION PASS_TRACE TRACED "Traced" CONVERTED 18
146
+ LABELVALUEDESC CONSTELLATION PASS_TRACE TRUNCATED "Cut by window" CONVERTED 18
147
+ END
148
+ VERTICAL
149
+ LABELVALUEDESC CONSTELLATION PASS_TRACE USABLE_S "Usable" WITH_UNITS 18
150
+ LABELVALUEDESC CONSTELLATION PASS_TRACE DURATION_S "Length" WITH_UNITS 18
151
+ LABELVALUEDESC CONSTELLATION PASS_TRACE CONDITIONS "Conditions" CONVERTED 18
152
+ LABELVALUEDESC CONSTELLATION PASS_TRACE LIMIT "Limited by" CONVERTED 18
153
+ LABELVALUEDESC CONSTELLATION PASS_TRACE WORST_MARGIN_DB "Worst margin" WITH_UNITS 18
154
+ LABELVALUEDESC CONSTELLATION PASS_TRACE WORST_CAUSE "Worst from" CONVERTED 18
155
+ LABELVALUEDESC CONSTELLATION PASS_TRACE WORST_AT "Worst at" CONVERTED 18
156
+ END
157
+ END
158
+ END
159
+ <%- end -%>
116
160
  TABITEM "MODCOD plan"
117
161
  HORIZONTAL
118
162
  VERTICAL
@@ -60,8 +60,6 @@ const gbOf = (item) => {
60
60
  // A MODCOD plan's series holds each switch, the first at AOS: its changes are the steps after it,
61
61
  // as the COSMOS MODCOD packet's CHANGES and the Lattice bridge count them.
62
62
  const changes = (series) => `${series.length - 1} change${series.length === 2 ? '' : 's'}`;
63
- // A row's value for the per-key bars: the expected GB.
64
- const expected = (item) => (gbOf(item) ? { value: gbOf(item).p50 } : null);
65
63
  const ledgerOf = (item) => item.explain?.ledger?.value || {};
66
64
  // A pass's max elevation: the ledger entry the orbit wrote, under whichever node wrote it.
67
65
  const elevationOf = (item) =>
@@ -75,7 +73,6 @@ const sourceLabel = (source) =>
75
73
  const shortAntenna = (id) => (id && id.includes('__') ? id.split('__').pop() : id);
76
74
  // "SITE-000000000001__ant0" as "000001 ant0": enough of the station to tell rows apart.
77
75
  const stationTag = (id) => (id && id.includes('__') ? `${id.split('__')[0].slice(-6)} ${shortAntenna(id)}` : id);
78
- const stationOf = (item) => item.entity.ground_station_id;
79
76
  const linkLabel = (item) =>
80
77
  item.entity.type === 'antenna'
81
78
  ? `${item.entity.id}`
@@ -86,42 +83,6 @@ const linkLabel = (item) =>
86
83
  const W = 640;
87
84
  const tip = (text) => `data-tip="${esc(text)}"`;
88
85
 
89
- function axisTicks(max, n = 4) {
90
- if (!(max > 0)) return [0];
91
- const raw = max / n;
92
- const mag = 10 ** Math.floor(Math.log10(raw));
93
- const step = [1, 2, 2.5, 5, 10].map((m) => m * mag).find((s) => s >= raw) || raw;
94
- // The top tick is at or above max, so the data never runs past the axis.
95
- const out = [0];
96
- while (out[out.length - 1] < max - step * 0.01) out.push(out[out.length - 1] + step);
97
- return out;
98
- }
99
-
100
- /** The expected value as a line over time buckets. */
101
- function lineChart(buckets, { height = 180, unit = 'GB' } = {}) {
102
- const pad = { l: 44, r: 12, t: 12, b: 26 };
103
- const h = height;
104
- const max = Math.max(...buckets.map((b) => b.p50), 0.001);
105
- const ticks = axisTicks(max);
106
- const top = ticks[ticks.length - 1];
107
- const x = (i) => pad.l + (i / Math.max(buckets.length - 1, 1)) * (W - pad.l - pad.r);
108
- const y = (v) => h - pad.b - (v / top) * (h - pad.t - pad.b);
109
- const line = buckets.map((b, i) => `${i ? 'L' : 'M'}${x(i)},${y(b.p50)}`).join(' ');
110
- const grid = ticks
111
- .map((t) => `<line class="cf-grid" x1="${pad.l}" x2="${W - pad.r}" y1="${y(t)}" y2="${y(t)}"/><text class="cf-axis" x="${pad.l - 6}" y="${y(t) + 4}" text-anchor="end">${big(t)}</text>`)
112
- .join('');
113
- const labels = buckets
114
- .map((b, i) => (i % Math.ceil(buckets.length / 8) === 0 ? `<text class="cf-axis" x="${x(i)}" y="${h - 8}" text-anchor="middle">${esc(b.label)}</text>` : ''))
115
- .join('');
116
- const hits = buckets
117
- .map(
118
- (b, i) =>
119
- `<rect class="cf-hit" x="${x(i) - (W - pad.l - pad.r) / buckets.length / 2}" y="${pad.t}" width="${(W - pad.l - pad.r) / buckets.length}" height="${h - pad.t - pad.b}" ${tip(`${b.label} · ${num(b.p50)} ${unit} expected · ${b.count} passes`)}/>`,
120
- )
121
- .join('');
122
- return `<svg class="cf-chart" viewBox="0 0 ${W} ${h}" role="img" aria-label="Expected ${unit} over time">${grid}<path class="cf-line" d="${line}"/>${labels}${hits}</svg>`;
123
- }
124
-
125
86
  /** Horizontal bars, one row per key, each with an optional line from the bar to `to`. */
126
87
  function rangeBars(rows, { unit = 'GB', digits = 1 } = {}) {
127
88
  const rowH = 20;
@@ -219,34 +180,15 @@ function upcoming(run) {
219
180
  return run.items.filter((i) => !i.until || Date.parse(i.until) > now).sort((a, b) => a.target_at.localeCompare(b.target_at));
220
181
  }
221
182
 
222
- function hourly(items) {
223
- const now = Date.now();
224
- const start = Math.floor(now / 3600e3) * 3600e3;
225
- const buckets = Array.from({ length: 24 }, (_, k) => ({ label: new Date(start + k * 3600e3).toISOString().slice(11, 16), p50: 0, count: 0 }));
226
- for (const item of items) {
227
- const g = gbOf(item);
228
- const k = Math.floor((Date.parse(item.target_at) - start) / 3600e3);
229
- if (!g || !(k >= 0 && k < 24)) continue;
230
- buckets[k].p50 += g.p50;
231
- buckets[k].count += 1;
232
- }
233
- return buckets;
183
+ /** One row per group of a breakdown the run's totals serve (run.totals.by_*), largest first:
184
+ * never summed here, as overlapping passes of one radio or antenna count once only by its rule. */
185
+ function served(groups, row) {
186
+ return Object.entries(groups || {})
187
+ .map(([label, g]) => ({ label, ...row(g) }))
188
+ .sort((a, b) => b.value - a.value);
234
189
  }
235
190
 
236
- function perKey(items, key, value) {
237
- const out = new Map();
238
- for (const item of items) {
239
- const k = key(item);
240
- const g = value(item);
241
- if (!k || !g) continue;
242
- const row = out.get(k) || { label: k, value: 0, count: 0 };
243
- row.value += g.value;
244
- if (g.to !== undefined) row.to = (row.to ?? 0) + g.to;
245
- row.count += 1;
246
- out.set(k, row);
247
- }
248
- return [...out.values()].sort((a, b) => b.value - a.value);
249
- }
191
+ const unserved = '<p class="cf-empty">Constellation serves no totals for this run.</p>';
250
192
 
251
193
  const tile = (label, value, hint) => `<div class="cf-tile"><div class="cf-tile-value">${esc(value)}</div><div class="cf-tile-label">${esc(label)}</div>${hint ? `<div class="cf-tile-hint">${esc(hint)}</div>` : ''}</div>`;
252
194
  const section = (title, body, note) => `<section class="cf-section"><h3>${esc(title)}</h3>${note ? `<p class="cf-note">${esc(note)}</p>` : ''}${body}</section>`;
@@ -377,11 +319,11 @@ export const VIEWS = {
377
319
  const hint = approved || held ? `${approved} approved · ${held} awaiting approval` : `${booked} with a better backup`;
378
320
  return `<div class="cf-tiles">${tile('swaps to decide', swaps.length - approved, hint)}${tile('GB recovered', big(all?.recovered_gb), 'by the swaps that count (p50)')}${tile('soonest decision', soonest ? until(soonest.action.deadline) : '—', soonest ? `decide by ${minute(soonest.action.deadline)}` : '')}${tile('workflow version', `v${run.workflow_version}`)}</div>`;
379
321
  }
380
- // The day from when the run was made; its satellites overlap nowhere, so they add up.
381
- const day = run.totals?.next_24h && Object.values(run.totals.next_24h.by_satellite);
322
+ // The day from when the run was made.
323
+ const day = run.totals?.next_24h?.overall;
382
324
  const swaps = items.filter(actionable).length;
383
325
  const next = items.find((i) => Date.parse(i.target_at) > Date.now());
384
- return `<div class="cf-tiles">${tile('passes, next 24 h', day ? day.reduce((s, b) => s + b.counted_passes, 0) : '—')}${tile('GB expected', big(day?.reduce((s, b) => s + b.gb, 0)), 'next 24 h from the run')}${swaps ? tile('swaps advised', swaps, 'see Risk below') : tile('next pass', next ? `${hhmm(next.target_at)}Z` : '—', next ? `${next.entity.satellite_id} @ ${shortAntenna(next.entity.antenna_id)}` : '')}${tile('workflow version', `v${run.workflow_version}`)}</div>`;
326
+ return `<div class="cf-tiles">${tile('passes, next 24 h', day?.counted_passes ?? '—')}${tile('GB expected', big(day?.gb), 'next 24 h from the run')}${swaps ? tile('swaps advised', swaps, 'see Risk below') : tile('next pass', next ? `${hhmm(next.target_at)}Z` : '—', next ? `${next.entity.satellite_id} @ ${shortAntenna(next.entity.antenna_id)}` : '')}${tile('workflow version', `v${run.workflow_version}`)}</div>`;
385
327
  },
386
328
 
387
329
  chart(run, items) {
@@ -424,10 +366,10 @@ export const VIEWS = {
424
366
  );
425
367
  }
426
368
  if (run.kind === 'audit-ledger') {
427
- const rows = perKey(items, stationOf, (i) => ({ value: ledgerOf(i).delivered_gb ?? 0, to: ledgerOf(i).possible_gb ?? 0 }));
369
+ const rows = served(run.totals?.by_station, (g) => ({ value: g.delivered_gb ?? 0, to: g.possible_gb ?? 0, count: g.passes }));
428
370
  return section(
429
371
  'Delivered against possible, per station',
430
- rangeBars(rows.map((r) => ({ ...r, tip: `${r.label}: ${num(r.value)} GB delivered of ${num(r.to)} possible, ${r.count} passes` }))),
372
+ rows.length ? rangeBars(rows.map((r) => ({ ...r, tip: `${r.label}: ${num(r.value)} GB delivered of ${num(r.to)} possible, ${r.count} passes` }))) : unserved,
431
373
  'The bar is what was delivered; the line runs to what was possible.',
432
374
  );
433
375
  }
@@ -437,20 +379,23 @@ export const VIEWS = {
437
379
  const rows = [...mix.entries()].sort((a, b) => b[1] - a[1]).slice(0, 12).map(([label, value]) => ({ label, value, tip: `${label}: chosen ${value} times across the plan` }));
438
380
  return section('MODCOD mix across the plan', rangeBars(rows, { unit: 'steps', digits: 0 }), 'How often each MODCOD is planned. Select a pass below to see its own plan.');
439
381
  }
440
- return section('Expected GB over the next 24 hours', lineChart(hourly(items)), 'Hover an hour for its passes.');
382
+ const rows = served(run.totals?.next_24h?.by_satellite, (g) => ({ value: g.gb, count: g.counted_passes }));
383
+ return section(
384
+ 'Expected GB per satellite, next 24 h',
385
+ rows.length ? rangeBars(rows.map((r) => ({ ...r, tip: `${r.label}: ${num(r.value)} GB expected over ${r.count} passes` }))) : unserved,
386
+ 'From when the run was made, as Constellation totals it.',
387
+ );
441
388
  },
442
389
 
443
390
  breakdown(run, items) {
444
391
  if (['audit-ledger', 'modcod-plan', 'rfi-watch'].includes(run.kind)) return '';
392
+ const rows = served(run.totals?.by_antenna, (g) => ({ value: g.gb, count: g.counted_passes })).slice(0, 14);
445
393
  if (run.kind === 'antenna-capacity') {
446
- const rows = perKey(items, (i) => i.entity.id, expected).slice(0, 14);
447
- return section('Antennas ranked by expected GB', rangeBars(rows.map((r) => ({ ...r, label: shortAntenna(r.label) === r.label ? r.label : `${r.label.split('__')[0].slice(-6)} ${shortAntenna(r.label)}`, tip: `${r.label}: ${num(r.value)} GB expected over ${r.count} days` }))));
394
+ return section('Antennas ranked by expected GB', rows.length ? rangeBars(rows.map((r) => ({ ...r, label: shortAntenna(r.label) === r.label ? r.label : `${r.label.split('__')[0].slice(-6)} ${shortAntenna(r.label)}`, tip: `${r.label}: ${num(r.value)} GB expected over ${r.count} passes` }))) : unserved);
448
395
  }
449
- const day = items.filter((i) => Date.parse(i.target_at) < Date.now() + 86400e3);
450
- const rows = perKey(day, (i) => i.entity.antenna_id, expected).slice(0, 14);
451
396
  return section(
452
- 'Where the GB lands: antennas, next 24 h',
453
- rangeBars(rows.map((r) => ({ ...r, label: stationTag(r.label), tip: `${r.label}: ${num(r.value)} GB expected over ${r.count} passes` }))),
397
+ 'Where the GB lands: antennas, the whole run',
398
+ rows.length ? rangeBars(rows.map((r) => ({ ...r, label: stationTag(r.label), tip: `${r.label}: ${num(r.value)} GB expected over ${r.count} passes` }))) : unserved,
454
399
  );
455
400
  },
456
401
 
@@ -560,7 +505,6 @@ const STYLE = `
560
505
  .cf-note { color:var(--cf-muted); font-size:12px; margin:0 0 6px; }
561
506
  .cf-empty { color:var(--cf-muted); }
562
507
  .cf-chart { width:100%; height:auto; display:block; overflow:visible; }
563
- .cf-grid { stroke:var(--cf-line); stroke-width:1; }
564
508
  .cf-axis, .cf-label, .cf-value { font-size:9.5px; fill:var(--cf-muted); }
565
509
  .cf-chart { max-width:820px; }
566
510
  .cf-label { fill:var(--cf-ink); }
@@ -571,11 +515,9 @@ const STYLE = `
571
515
  .cf-dot { fill:var(--cf-series); stroke:var(--cf-surface); stroke-width:2; }
572
516
  .cf-dot-warn { fill:var(--cf-warn); stroke:var(--cf-surface); stroke-width:2; }
573
517
  .cf-heat { fill:var(--cf-series); fill-opacity:calc(.08 + var(--share) * .92); }
574
- .cf-hit { fill:transparent; }
575
518
  .cf-heat-label { font-size:9.5px; fill:var(--cf-ink); }
576
519
  .cf-on-dark { fill:#fff; }
577
520
  .cf-step-label { font-size:10px; fill:var(--cf-ink); }
578
- .cf-hit:hover { fill:var(--cf-line); }
579
521
  g[data-tip]:hover .cf-bar, g[data-tip]:hover .cf-dot { filter:brightness(1.15); }
580
522
  .cf-cards { display:grid; grid-template-columns:repeat(auto-fill, minmax(260px,1fr)); gap:10px; }
581
523
  .cf-card { border:1px solid var(--cf-line); border-left:3px solid var(--cf-warn); border-radius:8px; padding:10px 12px; background:var(--cf-surface); }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openc3-cosmos-constellation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Constellation Space Corp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-12-01 00:00:00.000000000 Z
11
+ date: 2026-12-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'A CONSTELLATION target whose packets a bridge microservice fills from
14
14
  the Constellation feed: the next predicted pass, the next 24 hours, the soonest