Astro Navigation Cancellation Design
Goal
Extend the request-diagnostics reference application so a removed Astro island
cancels its active metrics request without scheduling a replacement request.
The application owns cancellation policy; @opsydyn/astro-foldkit continues to
deliver lifecycle facts and @opsydyn/foldkit-viz remains pure and synchronous.
Scope
This slice changes the request-diagnostics application, focused unit tests, and consumer documentation. It does not add an Astro integration API, alter Viz exports, or add remote filtering controls.
Route-Exit Policy
Only Navigated({ phase: 'exited' }) requests cancellation. When the explorer
is Loading, the application returns only FetchMetrics.Interrupt(...).
coldLoad, entered, and retained-island stayed events do not cancel work.
stayed remains metadata-only. It updates the route record while preserving
the active explorer state and existing chart models, so an in-flight request can
complete when the island remains mounted across a diagnostics URL change.
Cancellation State
The application records cancellation intent in the machine’s Cancelling
state as one of two reasons:
Reload: a user requested replacement data.RouteExit: Astro removed the island and work is obsolete.
The fixed FetchMetrics interrupt key remains private to the application. The
machine does not infer cancellation policy from the command outcome or Astro
integration state.
Interrupt Outcome
CompletedCancelFetchMetrics is the only event that can complete an interrupt
sequence:
Reloadtransitions toLoadingand returnsFetchMetrics()as a new command batch.RouteExittransitions toIdleand returns no commands.
Both Interrupted and NotFound outcomes follow the recorded reason. This
preserves the existing rule that an interrupt and its replacement must never be
returned in the same update batch. Idle ignores late load-result messages.
Verification
Tests are written before the implementation and cover:
LoadingplusNavigated(exited)produces exactly one interrupt command.- Its interrupt outcome reaches
Idlewithout a replacement fetch. ReadyplusNavigated(exited)produces no interrupt command.LoadingplusNavigated(stayed)preserves active work and chart identity.- The Astro client bridge forwards
exitedbefore disposing a removed island.
The full workspace check, typecheck, and test commands remain the completion gate.
Documentation
The web demo README documents the reusable pattern for remote filter, brush, and zoom loads: use an app-owned interrupt key, record the reason before interrupting, and schedule a replacement only from the outcome Message. The Astro README reinforces lifecycle delivery as a facts-only boundary. The Viz README keeps its existing pure/synchronous guarantee.