Repository navigation
Description
What to build
Give the Console's Fleet Inbox one module that owns read ordering for periodic polls and the reads after a saved Dismissal or Undo. The Day shift should keep seeing the owning machine's latest eligible answer when a poll overlaps a save, including when another viewer closes their Inbox during its first read.
Acceptance criteria
- Polling and saved Dismissal reconciliation use the same interface to admit and complete reads. One module owns all outstanding reads, the last good answer and the point before which reads can no longer replace it.
- A saved Dismissal or Undo immediately invalidates older outstanding reads for the affected pairing and removes only the affected Command from each relevant cached answer pending a fresh owning-machine read. The acting viewer waits for their own read attempt. Other viewers' reads proceed independently.
- A failed read preserves the last good answer and its freshness timestamp and prevents actions as today. A later-started failure leaves an earlier successful read eligible if it started after the save and no newer success has been accepted.
- A pending first poll can be invalidated even after its viewer closes the page. A late completion for a discarded pairing cannot recreate the old cached answer. Periodic polls remain limited to one in flight per viewer and machine and require an Inbox subscription.
- Deterministic tests drive these cases through the module's interface in explicit completion order. Existing Fleet Console integration and browser regressions still pass.
Blocked by
None (can start immediately).
Decisions
- Keep read ordering inside the Console's Fleet Inbox. The owning machine evaluates its Inbox and applies the viewer's scopes. The watching Console decides when to retain the answer it receives. This follows ADRs 0023 and 0026 and lets the existing HTTP adapter, CLI reads and owning-machine Dismissal continue to use their current interfaces.
- Put admission, completion, saved Dismissal invalidation, pruning and answer lookup behind one private in-process module. Keep subscription leases, configuration and credential loading, HTTP reads, task scheduling, change notices and HTML presentation in the surrounding Console code. Each caller can request work or read an answer without interpreting cache state.
- Register each read before starting its task and return an opaque handle identifying the viewer, exact Fleet entry and start order. Assign increasing order under the same lock used for invalidation and completion. Periodic polls deduplicate at admission. Reads after a save can overlap a periodic poll. Reject completions for unregistered or discarded reads, so finishing a task can only update its own admitted entry.
- Handle successful Dismiss and Undo through the same transition. In one operation, advance the ordering cutoff, omit the affected Command from the last good answer and admit a fresh read for the acting viewer, subscribed viewers and retained viewers for that pairing, including those with only a pending read. An owning-machine answer can then restore a row after Undo or show a newly uncovered Needs you kind. Publish the invalidation before starting the new reads. The owner has already saved the action, so the acting viewer's read outcome affects the Inbox, while the action response keeps the owner's result.
- Advance the cutoff on a save or an accepted success. An eligible failure records the error and clears action scopes while preserving the document and the time of its last success. Keeping those decisions together lets an earlier eligible success clear a newer poll's failure, as required by the post-Undo regression.
- Keep an entry for an inactive viewer while any admitted read can still complete. On polling sweeps, prune inactive entries once their reads have finished and discard entries for pairings that are no longer current. Lookup requires the exact configured pairing and only exposes entries with a completed answer. This keeps a closed viewer's pending first poll visible to the save transition without exposing an empty placeholder in the Inbox.
- Exercise the state module through the same operations and answer lookup that production uses. Pass explicit completion times and control the order of operations directly. Cover overlapping polls and saves, rejected late successes and failures, the post-Undo success after a later failure, cleanup, and viewer and machine isolation. Keep the existing cross-viewer, Dismiss and Undo, and late-response browser regressions for the whole Console path. The state module and its production callers can land together in one Ticket.
Architecture review
Strength: Strong · Dependencies: in-process
Files: src/console/fleet_inbox.rs, src/console/dismiss.rs, src/logs/status/fleet.rs, console/tests/fleet.test.cjs
Before
flowchart LR
Poll[Periodic poll] --> Pending[Outstanding polls]
Poll -. seeds and prunes .-> Answers[Kept answers]
Save[Saved Dismissal] -. sets cutoff .-> Answers
Poll --> Complete[Read completion]
Save --> Complete
Complete -. checks cutoff .-> Answers
Inbox[Fleet Inbox] --> Answers
classDef leak stroke:#dc2626,stroke-width:2px;
class Pending,Answers leak
After
flowchart LR
Poll[Periodic poll] --> Reads
Save[Saved Dismissal] --> Reads
Complete[Read completion] --> Reads
Inbox[Fleet Inbox] --> Reads
subgraph Reads[Fleet Inbox read ordering]
direction TB
Pending[Outstanding reads] --> Answers[Kept answers]
end
classDef deep stroke-width:3px;
class Reads deep
Problem: A poll's outstanding status and its answer's ordering cutoff live in different places, so the fix for a saved Dismissal had to coordinate polling, cache retention and response acceptance. #2327, PR #2329
Solution: Deepen the Fleet Inbox read module so admitting reads, retaining answers and applying saves share one interface and the polling task's separate tracking set can be deleted.
Wins
- Locality for read ordering
- One interface for race tests
- Delete separate poll tracking
Activity