Skip to content

nudge probe counts pre-resize in-flight bytes as the first burst (replay boundary race) #137

Open

Description

@chaodu-agent

Refs #131. Found while reviewing PR #136 (nudge heuristic).

Summary

The nudge's probe takes its base offset from the pane's fed_end before the resize. Bytes the host has written before the resize but has not yet delivered to the front arrive after the base. They count as the first burst after the shrink. A pre-resize \r\n is enough to make that burst look like an answer that has no clear or home, so the nudge gives up early.

Reproduction

  • Build host: a Linux build host (x86_64), a copy of commit 4a242f8 on PR fix: nudge waits for the repaint instead of a fixed 150 ms pause #136's branch.
  • Test: a_program_that_never_answers_bounds_the_nudge_at_nudge_max (a cat pane, nothing written after the shrink), run in the same process as the other 15 nudge tests, with 4 busy loops and 4 parallel workers.
  • Result: 12 of 300 runs on that host fail the bound. In each the nudge returns after about 100 to 120 ms instead of 3 s.
  • Instrumentation (a temporary eprintln! in probe_chunk, Linux copy only): 40 runs, 2 failed. In both failing runs the first counted chunk is seq=5 len=2 base=5, with bytes \r\n. That is the newline of echo READY. The adoption read the tail when it ended at offset 5, and the newline arrived after the base was taken.
  • Macos build host, same commit: 300 runs, 0 failures.

Consequence

The gate fails closed: a burst without a clear or home leaves clear_at unset, so the pane stays replayed and its writes stay refused. No false release is known. The false negative is real, though. A program that repaints correctly after an in-flight pre-resize byte stays replayed until a person resizes the pane or the front restarts.

Direction

Option 2: take the probe base only after the host has delivered everything it wrote before the resize. The front needs a sync point with the host's reader, so that bytes written before the resize are fed before the probe starts. Option 1, ignoring whitespace-only bursts, is a heuristic and is not recommended.

Priority: p3. The false negative needs a loaded host and an adoption that lands in the middle of a line, and it fails closed.

Activity

  1. chaodu-agent commented on Nov 19, 2026

    @chaodu-agent
    CollaboratorAuthor

    Analysis from a read-only review of the failed attempt (PR #136, commit 4a242f8). Code references are to 4a242f8.

    Root cause: the nudge uses the front's fed_end as the probe base. The host read loop advances the tail before it calls sink.output, so bytes written before the resize but not yet ingested land after the base and count as the first burst.

    Secondary: a burst ends on quiet gap only, not on clear. A repaint that starts later than SETTLE_QUIET leaves the pane replayed (fail-closed).

    Proposed minimal fix: the probe ends only after a clear plus quiet, otherwise it waits to NUDGE_MAX. Cost: a program that never clears waits up to 3 s per adoption, shared deadline across panes.

    Open checks before a PR: (a) a deterministic test that delays ingest and injects a trailing CRLF after the base, then a repaint; (b) whether a clear still in the kernel buffer at attach time can be counted as release evidence (not verified).

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

    p3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions