Skip to content

desk: a machine's reconnect invisible to the reader, and an end-to-end latency budget #57

Open

Description

@SSFSKIM

Problem

The owner, 2026-10-18, after a working day from the desk: the desk shows "Reconnecting to the session…" often, and the path from a session to the web should be as fast as it can be. Both are friction on the loop the desk exists for: seeing what needs the owner and answering it.

What the machines' logs show for 2026-10-18 (01:46Z–18:50Z, about 17 h):

MacBook (macbook) Mac mini (mini)
uplink stream (re)connects 27 27
caused by the uplink process restarting (daemon restarts: plugin rolls, kickstarts) 14 8
409 stale-generation (an hb-ack or POST named a stream the hub no longer holds) 12 15
"the hub ended the stream" 0 4
500 error code: 1101 (a Worker exception) 1 0

So each machine's stream drops about 1.5 times an hour, and most drops come from the hub's side. Every drop resets the browser's session subscriptions. apps/desk-web/src/depth/view/TranscriptPane.tsx draws "Reconnecting to the session…" while the subscription is reconnecting with no rows, between a reset and its fresh snapshot. A reset clears the rows the reader was looking at and reloads them, so a machine's reconnect is visible as a blank pane and a reload, even when it lasts a second.

stale-generation is the main suspect. MachineObject (apps/desk-hub/src/objects/machine.ts) holds the machine's current stream in memory (this.stream). A POST naming a generation with no in-memory stream is refused 409. So anything that loses the object's memory while the uplink's GET still looks open (a deploy, an eviction, a runtime restart of the Durable Object) surfaces only at the next heartbeat ack, up to one heartbeat (15 s) later. One deploy today matches one drop (#55 at about 18:45Z, the drop at 18:48Z). Most drops match no deploy.

Latency today is not measured end to end. One spot check: an owner message from the web at 17:04:26.985Z (hub ts) reached the session's transcript at 17:04:27 (CI-opt, hub/1858…:1). The other direction (a session's <message> or question until it is drawn on the web), the session view's first rows, and a streaming chunk until it is drawn have no numbers.

Intent

The desk feels live. A machine's reconnect is invisible to the reader unless it really is offline. Every hop on the path between a session and the web has a measured latency and a budget it is held to.

Shape

  1. Measure first. Instrument the paths and record a per-hop breakdown on the deployment, from timestamps the frames already carry where possible:
    • owner send → session receives;
    • a session's <message>, question or permission prompt → drawn on the web;
    • opening a session view → first rows;
    • a streaming chunk → drawn.
      Count reconnects with their causes from both sides (the uplink's daemon.log, the hub's object). Keep the instrument cheap enough to leave on (a debug readout or a log line, not a dashboard).
  2. Find why the hub loses the stream (stale-generation, "the hub ended the stream", the 1101) and fix what is ours. If the Durable Object's memory is lost by design (eviction, restarts), the stream must survive it: the generation and what the uplink needs persisted, or a drop detected at once rather than at the next heartbeat.
  3. Make a reconnect invisible to the reader. After a machine reconnects, a session subscription resumes from the offset the browser already holds instead of resetting to a fresh snapshot. Presence holds through a short gap rather than flapping offline and back. The "Reconnecting…" line stays for a real outage.
  4. Fewer uplink restarts. A daemon restart for a plugin roll restarts the uplink, which drops the stream. Restart the uplink only when its own code changed, or keep the gap short enough that (3) hides it.
  5. Latency budgets set from (1)'s numbers and held by a check. Proposed until measured: an owner message reaches the session within 1 s; a session's message or request is drawn on the web within 2 s at p95; a reconnect under 30 s draws nothing.

Acceptance

  • (1)'s breakdown recorded for every path above, on the deployment, from both Macs.
  • Over a working day, both machines show a reconnect rate from hub-side causes well below today's (about 1.5 an hour each), or every remaining cause is named and outside our code.
  • Against the fake machine, a machine reconnect mid-session leaves the session view's rows in place (no "Reconnecting…", no reload) and the stream resumes. Pinned by a desk-web e2e (Linux lane) and a desk-hub test.
  • The budgets in (5) hold, with the numbers in the PR.

Notes

  • Two repositories:
    • MAWS: apps/desk-hub (the machine object, the session plane) and apps/desk-web (the subscription keeper, TranscriptPane).
    • doperpowers: skills/sminos/scripts/sminos_uplink.py and the daemon's restart rule.
  • A Durable Object storage change goes to the owner first. Deploys of master follow the standing rule.
  • The org directory (doperpowers gate: dashboard-scale and design-scale wait for the measured-job guard (MAWS #92) #93, in flight) touches the uplink's hellos and the hub's Registry. Sequence after its M2/M3 or coordinate with its executor.
  • Related: Phase 1 acceptance 10 (no loss across restarts) holds. This ticket is about what the reader sees and how fast, not about loss.

Activity

  1. added
    enhancement
    status:ready-for-architect
    priority:P1
    on Oct 18, 2026
  2. added 2 commits that reference this issue on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority:P1status:ready-for-architect

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions