Skip to content

Assert the alternate-screen wheel contract on the bytes the PTY receives - #480

Merged
yansfil merged 3 commits into
mainfrom
fix/e2e-alt-screen-fixture
Oct 5, 2026
Merged

yansfil merged 3 commits into
mainfrom
fix/e2e-alt-screen-fixture

Conversation

@yansfil

@yansfil yansfil commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Related: #478 (base branch), #475

Summary

Contract 7 of the split s2 spec ran the system less, which cannot say what reached it, and on the Windows retry (#475) the wheel and q had no visible effect on it.
This replaces less with a small pager fixture (web/e2e/alt-screen-program.ts, a fixtureProgram Node script) that enters the alternate screen, logs every byte it reads, and leaves on q.
The test now asserts the exact bytes the PTY got: one cursor key per wheel batch (down, then up) and q, nothing else, and that the shell prompt returns after the alternate screen closes.

Review

  • 판단해 주세요: the expected bytes ESC[B ESC[A q are what Herdr 0.9.1 sends on macOS for a wheel over a non-mouse alternate screen, one key per batch whatever its lines (15, 150 and 1 lines all gave one key); if Windows differs, the failure prints the actual bytes.
  • 조심해서 볼 파일: web/e2e/s2.spec.ts contract 7 only - every earlier assertion is kept (two terminal_scroll, direction, no key event for the wheel, prompt returns); new ones are added.
  • 질문: Windows e2e: s2의 재시도에서 less를 q로 끝낸 뒤 셸 프롬프트가 돌아오지 않는다 #475 stays open until a Windows run shows whether q reached the PTY.

Evidence

  • 확인한 것: contract 7 passed 3 of 3 on macOS against the Split the s2 journey into one test per contract #478 build; the shell-pane wheel test still passes; web typecheck and lint pass; the fixture ran under a pty with ESC[B ESC[A q and logged them verbatim.
  • 확인하지 못한 것: Windows (the program runs through the fixtureProgram launcher there); CI is the only check.

Base automatically changed from test/split-s2-contracts to main October 5, 2026 06:56
@yansfil
yansfil marked this pull request as ready for review October 5, 2026 06:58
@yansfil
yansfil merged commit 5cd2b0c into main Oct 5, 2026
28 checks passed
@yansfil
yansfil deleted the fix/e2e-alt-screen-fixture branch October 5, 2026 07:15
HyunjunJeon pushed a commit to HyunjunJeon/hide that referenced this pull request Nov 9, 2026
…nds at their exit (with-hide#2185)

Closes with-hide/hide-private#435
Closes with-hide/hide-private#480
Closes with-hide/hide-private#524
Related: with-hide/hide-private#158 (이 PR로 닫지 않습니다. 아래 Summary)

## Summary

휴대폰 연결(hided mobile) 시험이 가끔 실패하던 원인은 제품 쪽 둘과 시험 쪽 하나였습니다.
- with-hide#480 (tailnet 항목 두 번 셈, 제품): 설정에서 방식을 바꾸고 바로 켜면 Tailscale을 읽는 패스가 둘
돌아, 둘째가 바뀐 환경을 읽고 항목을 한 번 더 더했습니다. 설정 변경은 패스를 한 번 "빚진" 것으로만 적고 패스가 읽은
변경을 모두 갚으므로 둘째는 돌지 않습니다. Tailscale 호출도 줄어듭니다.
- with-hide#435 (승인 안 된 폰의 시작이 revoked 대신 timeout, 시험): "폰 없음" 프레임을 기다렸는데 짝짓기 전에
쌓인 낡은 프레임이 맞아, 해제가 적용되기 전에 시작이 들어갔습니다. 폰이 목록에 오른 프레임을 먼저 읽고, 그다음 해제의 빈
목록을 기다립니다.
- with-hide#524 (app executable, 제품): macOS에서는 명령의 출력 pipe를 만드는 순간(만든 뒤 따로
close-on-exec를 켭니다) 다른 스레드가 띄운 자식이 그 pipe를 쥘 수 있고, hided는 pipe가 닫히길 기다렸기
때문에 몇 ms에 끝난 `tailscale` 명령이 15초 기한까지 갔습니다. 운영에서도 pane 시작과 겹치면 상태 읽기가
실패하고, 두 번 연속이면 노출이 내려갑니다. 이제 명령이 끝난 시점에 답을 읽습니다 (플랫폼 계층에 이미 있는
`OwnedChild::capture_until`, 같은 15초 기한, 출력 1 MiB 상한). 상한을 넘는 `status
--json`이 없도록 `status`는 피어를 뺀 읽기(`--peers=false`)로 묻습니다. 전체 답은 피어당 약 1.2
KB라 약 900대 tailnet에서 상한을 넘어 Mobile이 막히는데, hided는 피어 필드를 읽지 않습니다. 앞선 시험
전용 600초 기한(`status_within`)은 없앴습니다.
- with-hide#158 (ping, 로컬 한 번): 닫지 않습니다. 실패는 셸 소켓에 15초 동안 프레임이 하나도 없었다는 뜻이고 낡은
프레임으로는 설명되지 않습니다. 패스가 `tailscale` 명령의 15초 기한에 묶인 것과 맞아 #524와 같은 원인일 가능성이
크지만, 그 실행에서 명령이 15초에 걸렸는지 기록이 없어 원인은 확정하지 못했습니다.

## Review

- **판단해 주세요**: #158을 이 PR에서 닫지 않고 두는 것이 맞는지 (이슈의 만료일 2026-10-29이 이미
지났습니다. 같은 원인이라는 증거가 없어 닫는다고 쓰지 않았습니다).
- **조심해서 볼 파일**: `hided/src/mobile/tailscale.rs` - `status`가
`--peers=false`로 묻고, 명령 실행이 `wait_with_output`(pipe 끝까지 대기)에서 blocking
작업 위의 `capture_until`로 바뀌었습니다. future가 먼저 버려져도 blocking 작업이 15초 기한 안에 자식
트리를 끝냅니다 (이전의 `kill_on_drop` 자리).
- **조심해서 볼 파일**: `hided/src/mobile/mod.rs` - 패스 합치기(`PassOwed`): `take`가
설정을 읽는 같은 `Inner` 잠금 안이라 놓치는 변경이 없고, 시계와 Settings 열기는 강제 패스라 그대로입니다.
- **조심해서 볼 파일**: `hided/tests/it/mobile.rs`, `support/fake_tailscale.rs`
- `paired_phone`이 폰이 목록에 오른 프레임까지 읽고, 대역에 `status`를 붙잡는
문(`hold-status`)과 출력을 쥔 프로세스를 남기는 문(`hold-pipes`)이 생겼습니다.
- **비용 검토**: 상시 작업 추가 없음. 명령마다 blocking 작업 하나(15초, 1 MiB 상한)이고 패스 수는
줄었습니다 (`docs/PERFORMANCE_TESTING.md` 표 갱신).

## Evidence

- **확인한 것 (with-hide#480, with-hide#435)**: 원인은 CI 실패 로그의 순서 분석으로 확정했습니다. #480은 `switched
false` 뒤에 `serve.failed add`, 그 뒤 `serve.removed`가 오고 `serve.funnel_on`은
한 번뿐이라 패스 둘이 켜진 상태로 돈 것; #435는 `start.answered revoked-1 timeout`과 그 폰의
`terminal.input_discarded`가 `phone.revoked` 로그보다 앞선 것. 20회 반복(아래)은 고치기 전
기준 비율이 없어 이 분석을 보강할 뿐 단독 증거가 아닙니다.
- **확인한 것 (with-hide#524 원인, 고치기 전 코드, 이 Mac mini macOS)**: 같은 프로세스의 스레드 6개가
`sleep 20`을 900개 띄우는 동안 `tailscale status` 대역을 동시에 4~8개씩 반복 호출했습니다. 첫 실험
4349회 중 3초 timeout 1회; 자식의 종료와 pipe 끝을 따로 잰 실험에서 `exit_after=9ms`인데 3초
안에 끝이 오지 않은 경우가 잡혔고(시작이 느린 경우는 0), 제품 호출도 같은 실행에서 1회 timeout. 한 번의 우연이
아니라 두 실행에서 같은 모양입니다.
- **확인한 것 (with-hide#524 고침, 같은 조건)**: 고친 코드로 3번 반복해 제품 호출 6335회 모두 성공, 3초 넘은 것
0. 그중 한 실행은 같은 때 옛 방식 대조군에서 `exit_after=15ms`인데 끝이 안 오는 경우가 잡혔는데도 제품 호출은
0건이었습니다.
- **확인한 것 (출력 상한과 실제 크기)**: 상한이 필요한 이유는 끝없이 쓰는 자식이 hided를 키우면 안 되기
때문이고(원칙 15) `capture_until`이 받는 최대가 1 MiB입니다. 이 Mac(Tailscale 1.96.5, 피어
27개)에서 `status --json`은 34,332바이트(피어당 약 1.16 KB), `--peers=false`는
2,967바이트(피어 0, 사용자 0), `serve status --json`은 295바이트입니다. hided가 읽는
`BackendState`, `Self`, `CurrentTailnet`, `CertDomains`는 피어 없는 답에도 그대로
있고, 이 크기는 tailnet 크기와 무관합니다. 피어를 넣은 전체 답은 약 900대에서 1 MiB를 넘습니다. 시험
`a_tailnet_too_big_to_list_its_peers_still_answers_status`는 전체 답이 1 MiB를
넘는 tailnet(1,500대)에서 플래그를 빼면 `child output exceeds 1048576 bytes`로
실패합니다.
- **확인한 것 (시험이 고침을 지킴)**: 새 시험 둘을 고침만 되돌리고 돌리면 실패합니다.
`a_process_left_holding_the_command_s_output_does_not_hold_its_answer`는
이슈 본문과 같은 `timed out after 15s`로,
`two_changes_that_meet_a_running_pass_cost_one_pass_more`는 패스 합치기를 되돌리면
`tailscale status`가 7번 돌아(고친 코드는 6번 모두 4번) 상한 4를 넘어 실패합니다. 출력 밖에 있는 보유자는
`hide-platform`의 기존 세 시스템 계약 시험
`a_pipe_holder_outside_the_tree_does_not_hold_the_answer`가 맡습니다.
- **확인한 것 (이 Mac mini)**: `hided` 단위 617개와 통합 136개 통과(36개는 원래 ignore),
clippy `-D warnings`와 fmt 깨끗. 이 Mac mini에서 `verify-cargo.sh test`가
workspace 전체를 돌 때 `hide-agent-hooks`의 메모리 시험 둘(훅 기한 1250ms 초과)이 부하 속에서
실패했고 이 PR이 건드리지 않은 크레이트입니다.
- **확인한 것 (CI 20회)**: 고친 코드(`d4f23c551`) 위에 네 시험(with-hide#435 with-hide#480 with-hide#524 #158의
것)을 각각 20번 등록한 프로브 커밋(`6b1960ad7`, 다음 커밋에서 되돌림)을 PR의 rust 레인(ubuntu,
nextest `ci` 프로필, 재시도 1회)에서 돌려 전체 4808개가 통과했고 프로브 80개가 모두 첫 시도에 통과했습니다
(재시도와 `FLAKY` 줄 없음, run 42377510005). 고치기 전 비율을 재지 않아 고침 전후를 가르는 증거는
아니고, 이 코드에서 20회 연속 통과했다는 확인입니다.
- **확인하지 못한 것**: 위 20회 반복은 PR의 rust 레인(ubuntu)이라 macOS의 pipe 상속은 재현하지
못합니다. #524의 근거는 위 mini 실험과 시험입니다. 고치기 전 코드로 같은 반복을 돌려 재현율을 재지는 않았습니다.
#158의 실패 실행에서 `tailscale` 명령이 실제로 15초에 걸렸는지는 기록이 없어 확인하지 못했습니다. 이 PR의
macOS 전용 시험 레인은 PR CI에 없고 야간 레인에 있습니다. `--peers=false`는 이 Mac의 1.96.5
도움말에서 확인했고 더 오래된 Tailscale CLI에서의 지원은 확인하지 못했습니다.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant