Repository navigation
test(e2e): let the session's shell wait for a resize before it reports stty size - #3178
bryan-minimal wants to merge 6 commits into
Conversation
…s stty size The terminal-relay proof resizes the attached pty and, half a second later, types the line that prints `stty size` in the session. The resize travels client -> ssh -> daemon -> the session's pty, and on a loaded host that relay takes longer than the helper's pause, so the line printed the old size and the proof read as a failed resize (nine lab pre-push runs on unrelated branches, two of them tonight). The typed line now polls `stty size` for up to ten seconds until it shows the new size, then prints it. The assertion is the same: the size the session reports is the resized one. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 1 billable file and costs up to $0.25.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 47 minutes for your next included review. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Reviewed: no findings; approval withheld, 2 threads unresolved at APPROVE withheld: 2 unresolved threads — norrietaylor scripts/session-e2e.sh, norrietaylor scripts/session-e2e.sh. Resolving the last thread releases the approval on this head. Resolve the open threads. Resolving the last one releases the approval on this head; no new review is required. Clobber: none seen. |
The helper sends the detach chord once the pty has been quiet for two one-second drains, so a wait that printed nothing was cut off at about two seconds and RELAY_SIZE never printed: the 10 s budget was unusable. Each poll now prints a dot, and the size line follows on its own line. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Under load the sandbox can take longer than two seconds to mint, so the helper's quiet counter fired before the shell ran a line and the resize beat detached an empty attach. With E2E_PTY_READY set, the stream is not quiet until the shell printed the marker; the resize beat passes RELAY_READY. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The relay beat's ready check searched the stream for RELAY_READY, and the pty echoes the typed `echo RELAY_READY` back, so the marker could match the echo before the shell had run anything and quiet counting resumed early. The typed line is now `echo RELAY_"READY"`: its echo never contains the marker, only the shell's output does. The check also no longer copies the buffer on every pass. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
There was a problem hiding this comment.
Scope matches the title. The PR body does not describe the second commit, which adds E2E_PTY_READY to the helper. Update the body to describe it. Clobber: none. The diff only adds to proof_tty_relay and the helper's quiet counter. Correctness: the poll loop prints a dot on each pass, which keeps the stream busy. This fixes the problem from the first round, where the detach chord cut the wait at about 2 s. A resize that never arrives still prints the old size, and the unchanged assertion fails on it. seq and fractional sleep occur in many other session-side loops in this script. The E2E_PTY_READY guard does not protect against the slow mint that it targets. The marker is also the typed text, and the echo of the typed text satisfies the check (see the finding). The open bot thread on e2e-attach-pty.py:309-311 raises the same point. This finding adds the cooked-mode echo path and a committable fix. Not checked: a run of the e2e, which needs a build and a VM.
| # shellcheck disable=SC2086 # E2E_MINIMAL_ARGS must word-split. | ||
| relay_out="$(E2E_PTY_COMMANDS='echo RELAY_READY' E2E_PTY_SIZE='24 80' E2E_PTY_RESIZE='41 117' \ | ||
| E2E_PTY_AFTER='printf "RELAY_SIZE[%s]\n" "$(stty size)"' E2E_PTY_DETACH=1 \ | ||
| relay_out="$(E2E_PTY_COMMANDS='echo RELAY_READY' E2E_PTY_READY='RELAY_READY' E2E_PTY_SIZE='24 80' E2E_PTY_RESIZE='41 117' \ |
There was a problem hiding this comment.
medium · The ready marker is also the typed text, so the guard is satisfied before the shell runs a line. The helper writes echo RELAY_READY at 1.5 s, while min session attach can still be connecting. The local pty is then in cooked mode with ECHO on, and the kernel echoes the line into buf at once. The remote pty echoes it again before the shell reads it. READY_BYTES not in bytes(buf) searches the whole transcript, so it matches the echo. Quiet counting then starts at once, and the slow mint that the second commit targets still gets the second stage and the chord too early. The helper's default stream already avoids this: e2e-attach-pty.py:99-103 builds TOOL_%s_BEFORE with printf so the marker appears only as output. Use the same shape here. Also add one sentence to the E2E_PTY_READY docstring that says the marker must not appear in the typed text. This is the only E2E_PTY_READY caller, so the fix is local.
| relay_out="$(E2E_PTY_COMMANDS='echo RELAY_READY' E2E_PTY_READY='RELAY_READY' E2E_PTY_SIZE='24 80' E2E_PTY_RESIZE='41 117' \ | |
| relay_out="$(E2E_PTY_COMMANDS='printf "RELAY_%s\n" READY' E2E_PTY_READY='RELAY_READY' E2E_PTY_SIZE='24 80' E2E_PTY_RESIZE='41 117' \ |
There was a problem hiding this comment.
Taken, in 29e4daf, in the shape you gave: the beat types printf "RELAY_%s\n" READY, so neither the local echo nor the remote one carries the marker, and the E2E_PTY_READY docstring now says the marker must never appear in the typed text and why. The earlier push had the same effect through quoting (echo RELAY_"READY"); printf is the clearer of the two, so that is what stays.
The relay beat typed the marker with echo and quoting, which kept it out of the pty's echo but read as a trick. The typed line now builds it with printf, the shape the helper's own default stream uses, and the helper's E2E_PTY_READY docstring says the marker must never appear in the typed text, since the pty echoes what is typed into the transcript before the shell runs it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
There was a problem hiding this comment.
Scope matches the title. The diff changes the relay resize beat in scripts/session-e2e.sh and adds E2E_PTY_READY to scripts/e2e-attach-pty.py, and session-e2e.sh:8007 is its only caller. Clobber none. git log on both files shows only this PR's commits above 65e83ca3. Correctness The poll loop prints a dot every 0.25 s. That keeps quiet below 2, so the chord cannot cut the 10 s wait short. The marker is built with printf "RELAY_%s\n" READY, so neither pty echo carries RELAY_READY. The assertion at session-e2e.sh:8016 matches RELAY_SIZE[41 117]. The echoed typed line holds only RELAY_SIZE[%s] and "41 117", so the echo cannot satisfy it. A shell that never prints the marker holds quiet at 0. That wait has a bound: the helper's 240 s DEADLINE, or EOF when the attach ends. All three earlier threads are answered and taken at head. Not checked I did not run the e2e, because it needs a build and a session.
| # asserted is unchanged: the size the session reports is the resized one. | ||
| # The typed line builds the marker with printf, as the helper's own default | ||
| # stream does, so the pty's echo of the typed text never contains it: only the | ||
| # shell's output does, once it has run the command. |
There was a problem hiding this comment.
nit · The comment block tells the story of the PR's review rounds. Examples: "the chord then left before a line ran" (past tense, about the old failure) and "as the helper's own default stream does". It also restates the E2E_PTY_READY docstring in e2e-attach-pty.py:29-38. Keep the two facts the reader of this line needs: the dots keep the pty busy, and the marker is built with printf so the echo does not contain it. Point to the helper docstring for the rest.
There was a problem hiding this comment.
Trimmed in 34c7269 to the two facts the line needs, the dots keep the pty busy so the quiet-stream detach does not fire, and the marker is built with printf so the echo never contains it, with a pointer to the E2E_PTY_READY docstring for the rest.
The dots keep the pty busy so the helper's quiet-stream detach does not fire while the shell waits, and the ready marker is built with printf so the pty's echo never contains it; the helper's docstring has the rest. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Reopening to run the pr-title check, which became required after this head was pushed. |
Pull request was closed
What
The terminal-relay proof in
scripts/session-e2e.shresizes the attached pty to 41x117 and, half a second later (the helper's fixed pause), types the line that printsstty sizein the session. The resize travels client → ssh → daemon → the session's pty, and on a loaded host that relay takes longer than the pause, so the line printed the old size and the proof read as "a resize of the attached terminal did not reach the session's 'stty size'". The typed line now pollsstty sizefor up to ten seconds until it shows the new size, then prints it. The assertion is unchanged: the size the session reports is the resized one; a resize that never arrives still fails.Why now
The lab's pre-push lane saw this beat fail on nine runs of unrelated branches (two tonight, within two hours, with the host at a load of about 11), each time with every other e2e beat green. It is the lane's most frequent false red.
Verification
native-daemon-e2estep runs this beat.min-regress batch
e2e-resize-wait-1cb2796c: baserel-0bb305b9vs the candidatecand-e2e-resize-wait-1cb2796c-1daa6559, per distro:Lab evidence (min-regress batch
e2e-resize-wait-1cb2796con the lab box, ubuntu-24.04)Head:
1cb2796ca13c641c7aea86d283d5c9fe7f00a0caat 1cb2796 (lab namecand-e2e-resize-wait-1cb2796c-1daa6559). Base:rel-0bb305b9(rel-0bb305b9).Fixed since base: 0. Still reproducing on both: 0. Regressed: 0. Passing on both: 1. A verdict links to the run's trace in Cloud Trace (project access needed); the scenario link is its source with the
# issue:it reproduces.🤖 Generated with Claude Code
Summary by CodeRabbit