Files
worldmonitor/todos/017-pending-p3-simulation-package-phase2-prerequisites.md
Elie Habib 092efd4fe9 fix(panels): always fire background RPC refresh after bootstrap render (#2208)
* fix(panels): always fire background RPC refresh after bootstrap render

Bootstrap hydration (getHydratedData) is one-shot — once rendered from
it, panels never refresh and can show stale or partial data indefinitely.

Affected panels: MacroSignals, ETFFlows, Stablecoins, FuelPrices,
GulfEconomies, GroceryBasket, BigMac.

Pattern: render from bootstrap immediately for fast first paint, then
fire a background RPC call that silently updates the panel with live
data. Errors during background refresh are suppressed when bootstrap
data is already visible (no error flash over valid data).

* fix(panels): guard background RPC refresh against empty response overwriting bootstrap

Empty RPC responses (200 + empty array) no longer overwrite valid bootstrap
data with error/unavailable state across all 7 affected panels:

- ETFFlowsPanel, StablecoinPanel: wrap this.data assignment in
  `if (fresh.xxx?.length || !this.data)` guard
- FuelPricesPanel, GulfEconomiesPanel, GroceryBasketPanel, BigMacPanel:
  add `!data.xxx?.length` check in background .then() before calling render
- MacroSignalsPanel: return false early when error suppressed to skip
  redundant renderPanel() call

* fix(hormuz): fix noUncheckedIndexedAccess TypeScript errors

* fix(todos): add blank lines around headings (markdownlint MD022)

* fix(hormuz): add missing hormuz-tracker service + fix implicit any in HormuzPanel

* revert: remove HormuzPanel.ts from this branch (belongs in PR #2210)
2026-03-24 20:23:40 +04:00

2.8 KiB

status, priority, issue_id, tags
status priority issue_id tags
pending p3 017
code-review
deep-forecast
simulation-package
architecture

Phase 2 prerequisites: getSimulationPackage RPC + Redis existence key

Problem Statement

The simulation package is a write-only black box: agents cannot read it, trigger it, verify its existence, or discover its schema through any runtime interface. This is acceptable for Phase 1, but Phase 2 (MiroFish integration) requires a read path before it can proceed.

Findings

From the agent-native review:

  • 0/4 simulation-package capabilities are agent-accessible (trigger, read, check existence, discover schema)
  • There is no getSimulationPackage(runId) RPC handler in server/worldmonitor/forecast/v1/
  • The R2 key is deterministic and computable from (runId, generatedAt) but no handler exposes it
  • schemaVersion is written as R2 object metadata but never returned through any read path
  • writeSimulationPackage returns { pkgKey, theaterCount } but this result is discarded at the fire-and-forget call site — nothing writes a Redis existence key

Phase 2 gate: MiroFish or any LLM scenario-analysis workflow that consumes the package must reach it through the server layer, not by directly importing buildSimulationPackageKey from the seed script.

Proposed Solutions

Create server/worldmonitor/forecast/v1/get-simulation-package.ts that reads from R2 using buildSimulationPackageKey(runId, generatedAt). Follows the same pattern as the deep-snapshot replay handler.

Option B: Write Redis existence key on successful write

When writeSimulationPackage resolves successfully, write a Redis key:

forecast:simulation-package:latest → { runId, pkgKey, schemaVersion, theaterCount, generatedAt }

This gives agents a cheap existence check and gives health monitoring a probe point at zero R2 cost.

Both options are Phase 2 work, not Phase 1 blockers.

Acceptance Criteria (Phase 2)

  • getSimulationPackage(runId) RPC handler exists in server/worldmonitor/forecast/v1/
  • Handler reads from R2 using buildSimulationPackageKey
  • schemaVersion is included in the RPC response
  • Redis key forecast:simulation-package:latest written on successful writeSimulationPackage
  • Health check or bootstrap key added for existence monitoring

Technical Details

  • New file needed: server/worldmonitor/forecast/v1/get-simulation-package.ts
  • Wire in: server/worldmonitor/handler.ts (gateway registration)
  • Follow pattern of: server/worldmonitor/forecast/v1/get-forecasts.ts

Work Log

  • 2026-03-24: Found by compound-engineering:review:agent-native-reviewer in PR #2204 review
  • Phase 1 only — do not block PR #2204 merge on this item