{
  "summary": "The reconstructed serve worker uses ordinary blocking Whole IPC carriers, not a pump reader thread. Seed and retained Request both issue write-only subscribes; neither waits for Subscribed nor consumes intervening events. Crucially, pending-input flush calls ack=true send_effect in a tight write-only loop, whereas live input uses ack=false. This is a concrete backpressure candidate, not a proven cause. Outbound forwarding is independently write-only on a second IPC connection, whose broker handler synchronously waits for network sending.",
  "files": [
    {
      "path": ".worktrees/49-267-refresh-discriminator/crates/spt-daemon/src/attach.rs",
      "description": "367–447 request handling; 473–589 initialization/seed; 594–714 event dispatch and retained Request/input; 757–838 Subscribed/pending flush; 936–965 output and discarded acknowledgements; 252–326 gap-resume reader."
    },
    {
      "path": ".worktrees/49-267-refresh-discriminator/crates/spt-daemon/src/brain.rs",
      "description": "464–483 Whole carrier creation; 908–958 acked/no-ack input methods; 1453–1480 and 1533–1543 role attaches; 2096–2132 network send; 2367–2394 sessions query/network subscribe; 2511–2559 subscribe/send; 2582–2615 read carrier."
    },
    {
      "path": ".worktrees/49-267-refresh-discriminator/crates/spt-daemon/src/broker.rs",
      "description": "2592–2678 asynchronous controller installation; 3116–3280 lease/idempotency resolution; 3955–4038 controller writes; 6148–6159/6234–6237/6400–6403 per-connection dispatch; 8750–8810 subscribe; 8846–8952 input; 9826–9862 network send; 9964–9979 network subscribe; 10257–10259 reply writing."
    },
    {
      "path": ".worktrees/49-267-refresh-discriminator/crates/spt-daemon/src/nethost.rs",
      "description": "545–602 replay snapshot and subscriber install; 1469–1483 network operation timeout; 1888–1921 network sending; 2163–2189 stream subscription."
    },
    {
      "path": ".worktrees/49-267-refresh-discriminator/crates/spt-daemon/src/conn.rs",
      "description": "598–709 bounded serialized broker writes, watchdog, poison/cancel and retirement; applies to replies and subscription writers sharing the physical connection."
    },
    {
      "path": ".worktrees/49-267-refresh-discriminator/crates/spt-daemon/src/dispatch.rs",
      "description": "900–904 connect uses Brain::cold_start; 1100–1109 fresh worker carrier; 1169–1220 session resolution before subscribe, then serve_attach with floor_seq and durable opener."
    },
    {
      "path": ".worktrees/49-267-refresh-discriminator/crates/spt-daemon/src/msg.rs",
      "description": "604 onward SubscribeReq; 676–693 SubscribedReply; 748 onward InputReq; 860–869 AppliedEvent identities."
    },
    {
      "path": ".worktrees/49-267-refresh-discriminator/crates/spt-daemon/src/codec.rs",
      "description": "22–35 framing write consists of length write_all, body write_all, then flush; Brain::send has no reply read."
    }
  ],
  "architecture": "dispatch fresh Whole brain → pre-subscription sessions query → serve_attach subscribes stream replay on brain and creates separate Whole wire → seed/retained Request writes session subscribe on brain → independent broker stream/controller writers plus handler replies share brain's BrokerConn → serve thread reads one event at a time, sends input on brain, and forwards outbound records on wire. wire's separate broker handler calls bounded network send. No independent IPC reader drains either Whole carrier while serve executes a write.",
  "report": "Scope: source-only investigation of the named worktree. No files changed, commands/tests/builds run, or reproductions attempted. LSP is unavailable in the exposed tool inventory (xd:// exposes only spt_checkpoint); used source searches and exact implementations rather than hidden-worktree LSP absence. Existing observations remain accepted; no remedy is claimed proven.\n\nActual call and blocking map\n\n1. Reconstruction/preflight — dispatch.rs:900–904,1100–1109,1169–1220.\n   connect → Brain::cold_start → Whole stream, io_timeout=None (brain.rs:464–483). Both local and cross-node endpoint resolution call sessions BEFORE serve subscribes. sessions (2367–2378) writes KIND_SESSIONS, then reads until BrokerEvent::Sessions / KIND_SESSIONS_REPLY, discarding all other non-error events. Its reply matching is kind-based, not a request token. This is a real consume/discard round trip, but it occurs before these stream/session subscriptions, not inside handle_attach_request.\n\n2. Attach replay subscription — attach.rs:483; brain.rs:2384–2394 → send(KIND_NET_STREAM_SUBSCRIBE,{stream_id,from_seq}) → codec write_all/write_all/flush. Write-only, no success reply wait. Broker handler → dispatch_net_stream_subscribe (9964–9979) → NetHost::subscribe_stream (2163–2189) → StreamLog::begin_attach (545–602), snapshotting replay and installing a dedicated subscriber writer. It does not synchronously write replay from the handler. Replay events identify stream_id and chunk seq. A poisoned prior seat still draining can reject installation; caller learns errors only when it next reads.\n\n3. Seed and retained Request — attach.rs:554–589 and 652–685 call the SAME handle_attach_request (367–447). Access denial writes finish on wire; approval sets intent/session, calls attach_as_coded or attach_as_viewer_snap, then marks attached. These methods reset output cursor state and call subscribe_with → send(KIND_SUBSCRIBE). All write-only: no wait for Subscribed, no reading/discarding interleaved Input/Output/Applied. Successful method return means IPC frame sent, NOT broker role confirmed. Neither invocation resets role or pending_input. Thus retained Request received after confirmation leaves role=Controller; received before confirmation leaves role=None. Subsequent records within the same decoder.push batch are handled before the next broker-event read.\n\n4. Subscribe handler/identity — broker.rs:8750–8810 resolves under the session output-log lock and THEN writes subscribed_envelope through send_frame. Request identity carries session_id, from_seq, intent, by=Some(origin_node), gen, optional code/capability. Reply SubscribedReply carries session_id, outcome, note, but no gen/from_seq/request correlation. serve_attach's Subscribed arm ignores session_id (`..`) and handles every reply. Seed plus retained duplicate therefore can produce two role replies. Broker idempotency at 3209–3236 is conditional: same identity, same NONZERO gen, same physical conn, same establish_from_seq, after gate/stall-evict checks, returns Controller/idempotent without replacing the writer. A fresh reconstructed conn is NOT that same-conn case until the first request has seated it. Different conn or different floor follows the silent same-lease retake. Do not infer repeated Request necessarily replaces a writer.\n\n5. Important stale-comment correction — attach.rs:484–502 describes synchronous inline controller replay. Actual broker.rs:2592–2678 builds an initial batch and SPAWNS controller_writer. The blocking handler edge is its later Subscribed reply write, contending with the independent stream/controller writers on the same BrokerConn. Actual SharedSend writes are bounded serialized BrokerConn writes (conn.rs:598–709), not the historical mutex held over an unbounded write described in some comments. A queued writer or in-flight OS write can lead to deadline poison/cancel. send_frame discards the resulting write error.\n\n6. Input — attach.rs:687–714 buffers decoded operator input only while attached, non-viewer intent, role=None. Controller live input uses send_effect_no_ack. On Controller/TookControl reply, serve first sets role, optionally forwards seat note on wire, runs feed_rest(Wake), THEN drains pending_input (757–805). Each pending item calls send_effect, NOT send_effect_no_ack. brain.rs:919–958 proves both methods are write-only; send_effect merely sets ack=true. Its comment says the CALLER waits one-at-a-time; this implementation does not. Pending drain performs no event reads between writes and sends the entire pending batch before returning to the read loop.\n   Broker dispatch_input (8846–8952) checks rc controller identity, optionally pings translation, applies journal key {class:session_id,minter:Rc,op}, buffers/enqueues input, and conditionally writes Applied. Applied identifies {session_id,op_id,applied_now}; it does not echo minter. Deduped input still produces an Applied when ack=true. Input enqueue is nonblocking, but journal/translation/locks and the Applied write are distinct handler stages. serve_attach ultimately ignores Applied (961–965). [INFERENCE] A sufficiently large pending batch can stop the sole Whole reader while broker reply/output writes accumulate, then stall its input writes because the per-connection handler is blocked writing a reply. This predicts an unfinished pending_send_effect boundary; pending=0 at every confirmation falsifies this specific pending-flush explanation for that run.\n\n7. Egress — Output/Size/Notice/ClientPolicy and terminal forwarding call wire.net_stream_send(...,None,...). brain.rs:2101–2132 writes KIND_NET_STREAM_SEND and returns immediately for op=None. It never reads a network acknowledgement or an error. The Some(op) variant DOES read until NetSent matching ONLY op_id and discards unrelated events, but serve's forwards do not use it. Broker dispatch_net_stream_send (9826–9862), op=None, synchronously calls NetHost::send_stream; it checks stream/lease then bounded_block_on awaits the stream send lock, write_all, and optional finish (nethost.rs:1888–1921,1469–1483). No NetSent is emitted on success for None. Handler errors are sent back to wire, which this serve loop never reads. [INFERENCE] Network-side delay can stop wire's handler draining IPC, eventually blocking the serve thread's wire write, thereby stopping brain reads even though the two IPC handlers are independent. A completed forwarding call only proves local IPC submission, not network delivery.\n\n8. Event reader — serve reads unbounded (attach.rs:594–625), using Whole read_frame inline (brain.rs:2582–2595); no pump-ipc-reader thread exists for this worker. read_event_until deduplicates below-cursor output/net events rather than arbitrarily discarding useful event kinds. Controller gap recovery (attach.rs:266–326) may write another subscribe and swallow the next Subscribed while its local swallow_resume_ack flag is set; it does not correlate that reply to a particular request. Ordinary initial/duplicate-request handling never performs this swallow. [INFERENCE] Competing outstanding subscription replies could make attribution ambiguous; do not classify every missing Subscribed as request-handler consumption.\n\nFive concrete probes, maximum\n\n1. Request/reply ordering: correlate worker stream, broker physical conn, session, gen, from_seq, seed-vs-retained label, role before/after, and broker SUBSCRIBE_DECISION. Add handler boundaries immediately before/after sending Subscribed and log reply receipt. Distinguishes Request not submitted, handler stalled before reply, and reply queued behind other writes. Never log code/payload.\n2. Pending discriminator: retain existing pending-count/individual pending_send_effect boundaries; add cumulative pending bytes and correlated ack=true op IDs versus live ack=false. A stuck pending write with no next read supports pending backpressure; no pending entries or a fully completed flush before failure rejects that location.\n3. Reader position: paired brain read entry/exit with stream/session, decoded kind and seq/op, plus current worker action. For this Whole carrier, 'no read while pending/forward write is outstanding' is expected and measurable; do not hunt for a nonexistent worker pump reader thread. Separately mark gap-resume subscription and swallowed Subscribed.\n4. Broker input/reply boundary: for the exact conn/session/op, bracket controller fence, journal apply/enqueue completion, and Applied send; correlate BrokerConn gate acquisition, write completion/timeout and poison attribution. Distinguishes input processing/journal delay from blocked acknowledgement egress and establishes which frame actually poisons the carrier.\n5. Wire egress boundary: pair existing output_forward/size_forward/seat_notice/client_policy boundaries with wire conn and stream, and bracket broker dispatch_net_stream_send → stream-lock acquisition → write_all/finish completion. Correlate with brain's last read. An unfinished wire write plus outstanding broker network send supports outbound egress blockage; pending flush stalled before any such forward distinguishes the alternative. Keep feed_rest(Wake)'s existing paired marker so local wake work cannot be mislabeled either class.\n\nNo edits to by:Some promotion exclusion or any other lane; no proven remedy proposed."
}
