Repository navigation
Make Rust tests wait on state instead of a wall-clock guess - #434
Merged
Merged
Conversation
…st test no longer needs
This was referenced Oct 5, 2026
yansfil
added a commit
that referenced
this pull request
Oct 5, 2026
… stale, refresh the size baselines
yansfil
added a commit
that referenced
this pull request
Oct 5, 2026
Related: Fixes #446. The 30 s hang limits in the `process.rs` tests are in #434. ## Summary A guarded child that had finished its work could stay alive on macOS under load, in the drop of its `OwnerWatch`. The watch's reader waited in `read` and relied on a socket shutdown or a 25 ms receive timeout to end; neither woke it. The reader now polls the owner channel and a wake channel together, and closing the watch wakes it by data and end of stream, then joins. No time or socket-shutdown behavior is involved any more. ## Review - **판단해 주세요**: 없음. 방향은 #446에서 승인된 것(`LocalListener::accept`와 같은 wake 채널 패턴)입니다. - **조심해서 볼 파일**: `hide-platform/src/process.rs` - owner 상실을 처리하는 reader의 failure path입니다. - 닫는 중인 watch는 같은 순간의 owner 종료보다 우선합니다. - 읽을 데이터가 있어도 EOF가 아니면 owner 상실로 보지 않습니다. - `poll` 오류는 owner 상실(`_exit(125)`)로 갑니다. 이전 `read` 오류와 같은 처리입니다. - **비용 검토**: reader는 이전처럼 스레드 하나이고, 25 ms마다 깨던 수신 타임아웃이 없어져 대기 중 깨어남이 0이 됩니다. 추가 fd는 watch당 socketpair 하나(close에서 해제)입니다. ## Evidence - **확인한 것**: - 결정적 회귀 테스트 `closing_the_watch_wakes_a_reader_that_is_waiting_on_a_silent_owner`: owner 끝이 연결된 채 조용한 상태에서 reader가 poll에 들어간 것을 확인한 뒤 watch를 닫고, join이 wake로 끝나는지 봅니다. 두 번 돌려 admission slot이 반환되는지도 봅니다. 순서는 테스트가 정하고 시간은 hang 한도로만 씁니다. 이 테스트는 한가한 기계에서는 수정 전 코드도 통과합니다(원인이 OS 동작이라서). 수정의 증거는 아래 부하 측정입니다. - 부하(`taskpolicy -b` + `yes` 4개, 주변 load 25-30) 하에서 같은 테스트를 수정 전/후 바이너리로 비교(8초 안에 안 끝나면 hang): `only_a_guarded_launch_returns_startup_proof` 수정 전 2/120 hang, 수정 후 0/120. `repeated_guarded_work_releases_children_and_capture_resources` 수정 전 2/100, 수정 후 0/100. `guarded_capture_keeps_stdin...`은 양쪽 0/100(재현되지 않은 항목). - `hide-platform` 전체, `hide-host`, `hide-agent-hooks` 테스트, `fmt-check`, `clippy -D warnings` 통과. - **확인하지 못한 것**: - 수정 전 hang이 왜 shutdown과 수신 타임아웃으로 안 깨졌는지는 끝내 확정하지 못했습니다. 이 수정은 그 OS 동작에 기대지 않는 쪽으로 바꾼 것입니다. - 이 hang은 부하가 높을 때만 재현돼서 hang 횟수가 작습니다(합계 수정 전 4, 수정 후 0). - Linux와 Windows CI는 돌리지 못했습니다. Windows 구현은 reader가 없어서 바뀌지 않았습니다. - 머지 후 macOS CI에서 `process.rs` 테스트가 안정적인지는 #434와 이 PR이 둘 다 들어간 뒤에 봐야 합니다.
yansfil
added a commit
that referenced
this pull request
Oct 5, 2026
Related: #433 (retried interactions), #437 (Rust sleeps), #430 (guide), #434 (clock injection and Rust waits), #429 (headless renderer), #438 (shared gate), #419 (retries) ## Summary Playwright specs in `web/e2e` and `desktop/e2e` now pass `eslint-plugin-playwright` plus two repository rules, an e2e test size budget runs in the same `lint` script, and clippy refuses `std::thread::sleep` in Rust. All of it runs in the existing lanes (`web lint`, `desktop lint`, `clippy`); no new job or workflow step. Existing violations were fixed where a state exists to wait for, and the rest carry a reasoned allow, listed below. ## Review - **판단해 주세요**: `quietFor` is the only sleep an e2e spec may use for a window in which something must not happen; its 30 call sites each state the claim. Is a time window the right form for those, or should some become a counted check? - **판단해 주세요**: `no-conditional-in-test` (98 hits, mostly `process.platform` and fold toggles) and `max-expects` (2409 hits at the default of 5) are not enabled; the size budget replaces `max-expects`. Enable either? - **조심해서 볼 파일**: `web/eslint-rules/hide-e2e.mjs` - two hand-written rules; `web/scripts/check-e2e-test-size.mjs` - the baseline logic; `web/e2e/wait.ts` - the one `eslint-disable` for `waitForTimeout`. - **조심해서 볼 파일**: `web/e2e/s3.spec.ts` (two draft recovery tests) - they must not reload the page, so they carry a line allow with the reason; adding `about:blank` made both fail. - **조심해서 볼 파일**: `web/e2e/theme.spec.ts` - `networkidle` replaced by asserting hided's empty 404 for `/gallery`; `web/e2e/agent-tab-groups.spec.ts` - a 300 ms sleep between two `tab focus` calls was removed (the CLI returns after Herdr applied it, events reach the core in order; a probe showed the first focus changes nothing visible); `web/e2e/s3.spec.ts` - the offline window now also asserts the file was not written. - **질문**: #434 merged first; this branch took main and dropped the `#437` allows on the five functions it fixed (`hide-ai/src/router.rs` x3, `usage.rs`, `live.rs`). ## Evidence - **확인한 것**: `pnpm lint` in `web` and `desktop` pass (ESLint plus the size budget); `cargo clippy --workspace --all-targets -- -D warnings` and `cargo fmt --check` pass; `scripts/tests` 108 pass; the identity and attribution checks pass. - **확인한 것**: each rule fires on a planted violation (`waitForTimeout`, an action inside `toPass`, `goto` of `#token=` after `restart()`); the size budget fails when a baselined test grows (it caught this branch's own 9-line addition to the Overview test, which moved into a helper). - **확인한 것**: ran the changed specs against a local `hided` and the pinned Herdr, all pass: theme (gallery and restart), start-panel, agent-tab-groups external focus, sidebar-pr-start, cmdk recents, both s3 draft recovery tests, s6 Main/Overview (failed once on the first run at the File Views open, passed on the immediate rerun; this PR only relabels a wait in that test), and the Overview graph test. - **확인한 것**: a reviewer found the labels above too loose in a first pass (a settle wait named `quietFor`, native captures without `compositorPresents`, Rust allows with the wrong reason); all were fixed before this PR. - **확인하지 못한 것**: known gaps in the new lint: `expect.soft(fn).toPass()`, a poll that calls an action through a helper, and a `goto` through a local `url` variable after `restart()` are not seen; a hand-written `new Promise((r) => setTimeout(r, ms))` is not seen either (mobile.spec x2, remote-workspace, browser, workspace-columns x2 exist today); clippy covers `std::thread::sleep` only, not `park_timeout`, `wait_timeout` as a delay or a spawned `sleep`. #437 lists the Rust gap. - **확인하지 못한 것**: the other edited specs (digit, keys, browser, terminal-links, session-labels, the macOS desktop specs) were not run; desktop e2e needs the macOS lane. Windows and Linux lanes run in CI. - **확인한 것**: macOS clippy does not compile `cfg(windows)` or Linux-only code, which is how the two Windows named-pipe waits in `hide-platform/src/ipc.rs` slipped through (found by the Windows OS contract job). A source scan of every `sleep(` call in the tree, regardless of cfg, now finds none outside an allowed function; a Windows-target clippy run reached `hide-platform` and `hide-ai` before `ring` failed to build on this Mac, so the Windows lane in CI is the check for the rest. - **확인하지 못한 것**: `Instant::now` and `SystemTime::now` bans in clock-injected modules. Clippy cannot scope a method to a module and #434 has injected no module yet; once it has, a per-crate `clippy.toml` or a module-level `deny` with those two methods is the follow-up. ### Sleeps and waits, before and after | | Before | After | | --- | --- | --- | | `waitForTimeout` in `web/e2e` and `desktop/e2e` | 53 | 1 (`web/e2e/wait.ts`, behind three named helpers) | | `quietFor`: a window in which something must not happen | - | 30 | | `compositorPresents`: native capture on macOS | - | 6 | | `measureFor`: idle measurement and sample pacing | - | 5 | | `animationsFinished`: waits for finite animations, not time | - | 10 | | `unchangedForFrames`: waits until a value stops changing for 30 animation frames (bounded) | - | 3 | | Waits on time removed or replaced by a state or a stronger assertion | - | 3 (agent-tab-groups ordering sleep, `networkidle`, s3 offline window) | | `no-action-in-poll` allows, all #433 | - | 10 | | `reopen-after-restart-through-blank` allows (reconnect is the subject) | - | 2 | | Rust allow (`#[allow(clippy::disallowed_methods)]`) | Count | | --- | --- | | Bounded polling helper or inline bounded poll (sleeps between observations of a state, with a deadline) | 26 | | The sleep is the subject (a slow fake peer or backend) | 1 | | A child process kept alive for the test to kill | 6 | | Production wait, not test code | 31 | | Test that sleeps for a state, tracked in #437 | 59 | The production waits are allowed line by line rather than by a crate-root allow with `deny` in test modules: that form would leave every new `mod tests` and `tests/*.rs` file unguarded until someone adds the attribute, whereas the line allows fail closed. ### Size budget `web/e2e/test-size-baseline.json` (20 tests; #447 split three of them) and `desktop/e2e/test-size-baseline.json` (13) record the tests over 120 lines or 40 `expect` calls as a ceiling that only shrinks. ## Pending guide sentences `docs/TESTING.md` names #429, #438 and #434 as pending, and #419 for retries and nextest; each of those pull requests fixes its own sentence when it takes main. <details><summary>Verification record</summary> Base `origin/main` 4df25a0. Local runs: `pnpm lint` (web, desktop), `scripts/verify-cargo.sh clippy --workspace --all-targets -- -D warnings`, `fmt-check`, `python3 -m unittest discover -s scripts/tests`, Playwright specs listed above. Review by a separate reviewer: see the PR comments. </details> Main merge (#434, #435, #431, #450): baselines were refreshed after it. Two `browser-cdp.spec.ts` tests added by main were already over the budget and are baselined (172 and 121 lines); the Overview test grew 9 lines on main and its ceiling moved with it. Rust allows: 123 in total after the merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Rust 테스트 몇 개가 상태 대신 wall-clock 추측을 기다려서 부하에서 거짓 실패했습니다.
CI에서 3회 실패한
process.rs테스트의 기한을 고치고, router, usage, pane control 테스트는 sleep 대신 채널, gate, 로그 이벤트를 기다리게 바꿨습니다.제품 코드는 바뀌지 않았고, 새
@flaky나ignore도 없습니다.hide-platform/tests/process.rs: 속도를 검사하지 않는 launch 테스트(repeated_guarded_work...,only_a_guarded_launch...,guarded_capture_keeps_stdin...,capture_reports_the_callers_byte_limit..., 자식 안의guarded_owner)의 기한 1850ms가 test binary 기동 시간까지 물었습니다. 이 다섯 곳을HANG_LIMIT(30초, 자식 기동을 기다리는ready_number와 같은 기준)으로 바꾸고, 기한을 그대로 다시 단정하던elapsed < 1850ms한 줄은 지웠습니다. 기한 계약을 검사하는 두 테스트(300ms 파이프 기한, 200ms 비협조 launch)는 그대로입니다.hide-platform/tests/ipc.rs: #401이 고친a_burst_of_clients...에 남아 있던 macOSignore(닫힌 macOS에서 hide-platform IPC 연결 폭주 test가 ConnectionRefused로 실패한다 #396)를 지웠습니다. Keep the IPC burst test inside the backlog and pin what a connect past it gets #401 본문이 "나중에 머지되는 쪽이 ignore를 지운다"고 했는데 PR A가 뒤에 머지되며 남았습니다.hide-ai/src/router.rs: leader를Heldbackend와Gate로 붙잡고, joiner가 붙었다는ai.request.joined로그를 condvar로 기다립니다. 쓰지 않게 된Scripted.delay를 지웠습니다. 같은 모양인concurrent_duplicates_share_one_provider_call도 함께 바꿨습니다.herdr-core/src/usage.rs: worker가 시작과 응답 시점을 채널로 알리고, 테스트가 응답을 놓아 줍니다(60ms sleep 제거).herdr-core/src/live.rs: pane control spawn 테스트는 Herdr가 답을 붙잡고 있는 동안 spawn이 돌아오는지를 봅니다(500ms 지연과 100ms 상한 제거).Review
process.rs의 1850ms를 30초로 바꾼 것이 "기한을 늘려 통과시키기"가 아니라고 보는지. 이 테스트의 oracle은 자식 수이고 기한은 멈춘 자식을 끝내는 용도입니다.live.rsnext_wheel...의recv_timeout50ms를 1초로 넓혔습니다. 터미널 frame을 보내지 않으므로 wheel이 도착하는 것 자체가 "frame을 기다리지 않음"의 증명이지만, 1초 미만 timer가 생기는 회귀는 이제 못 잡습니다.hide-ai/src/router.rs- 테스트 helper(Gate,Held,Recorder::wait_for_events)가 새로 생겼고, 각 대기에는 실패 경로로만 쓰는 30초 한도가 있습니다.Evidence
process.rs: 자식 기동을 2초 늦춘 임시 패치(커밋 안 함)에서 수정 전 launch 테스트 4개 모두 실패, 수정 후 모두 통과.ipc.rs: ignore 없이 부하(taskpolicy -b+yes4개) 하에서 150회, 같은 테스트를--ignored로 300회 통과.process.rs:taskpolicy -b와yes4개 부하(살아 있음을 매 회 확인)에서 수정 전 실패 CI와 같은Deadline오류가 재현됐습니다. 수정 전 5/100 (그 전에 부하가 더 높았던 구간은 8/20), 수정 후 2/120. 주변 부하에 따라 크게 흔들려서 이 수치는 방향만 보여 줍니다. 수정 후 남은 실패는 아래 "확인하지 못한 것"의 hang입니다.scripts/verify-cargo.sh로fmt-check,clippy -D warnings(hide-ai, herdr-core, hide-platform),hide-ai --lib44개,herdr-core --lib1368개,hide-platform --test process32개 통과.std::thread::sleep은 추가하지 않았습니다.OwnerWatchdrop의reader.join()에서 11초 넘게 멈춥니다(상태SN, CPU 0.01초, reader는recvfrom). 30초 기한으로도 같은 곳에서 실패하고, Run fake gh, tailscale and usage provider as Node scripts on Windows #436 macOS job의only_a_guarded_launch...실패(출력에GUARDED true가 있음)도 이 모양이라 이 PR은 그 실패를 고치지 못합니다. 주변 부하가 내려가자 재현이 사라져(0/520) 원인(shutdown과 25ms 수신 타임아웃이 둘 다 reader를 못 깨우는 이유)은 확정하지 못했습니다. issue 초안은 로컬에 있고 등록 전 확인을 기다립니다.hided/tests/handshake.rs:1083(750ms): watcher가 준비됐다는 제품 신호가 없어서 결정적으로 고치려면 신호를 제품에 추가해야 합니다(설계 판단).hided/tests/real_herdr.rs:440(2초): 셸이 키를 읽을 준비가 됐다는 신호가 없습니다. 이 테스트는#[ignore]이고 고정 Herdr 바이너리가 필요해서 이 세션에서는 돌리지 못했습니다.hide-platform/tests/watch.rs: 부하에서 재현되지 않았습니다(15회).QUIET/ARRIVES는 OS 감시 이벤트 타이밍이라 결정적으로 만들 수 없는 범위입니다.herdr-core/src/github.rs:2282: gh 기한 3초가 제품의 기한 계약을 검사하는 테스트라서 건드리지 않았습니다. 1초 가짜gh는 이미FIXTURE_DEADLINE10초로 바뀌어 있습니다.herdr-core/src/session_sync/tests.rs의wait_until3초 세 곳: 재현되지 않았고, 고치려면 기한을 늘리는 것뿐이라 두지 않았습니다.labels/generator.rs:213은 시계 대기가 아니라 fork가 lock 파일을 물고 있던 문제이고 1032f883으로 이미 고쳐졌습니다.