Skip to content

Keep the IPC burst test inside the backlog and pin what a connect past it gets - #401

Merged
yansfil merged 1 commit into
mainfrom
fix/ipc-burst-contract
Oct 4, 2026
Merged

yansfil merged 1 commit into
mainfrom
fix/ipc-burst-contract

Conversation

@yansfil

@yansfil yansfil commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #396

Summary

The macOS burst test failed at connect 128 with ConnectionRefused, and the listener was not lost.
macOS queues 128 unaccepted Unix connections (SOMAXCONN), refuses the next one at once, and never makes a connect wait.
On a busy runner the test's client loop ran more than 128 connects ahead of a starved accept thread, which is load past the contract's "up to the listener's backlog".
The test is now split in two:

  • The burst stays inside the backlog: every 32nd client waits for its answer.
  • A new test fills the backlog with nobody accepting. It checks each system's refusal and that every queued client is answered once accept runs.

The contract now states what a connect past the backlog gets on each system.
Rust docs are in ipc.rs and the reason is in docs/ARCHITECTURE.md.
No product code changed: no backlog increase, retry or sleep.

Review

  • Please judge: the overflow outcome is written per system rather than as one answer:

    • macOS: ConnectionRefused, at once.
    • Windows: TimedOut, after 2s.
    • Linux: the connect waits for room.

    Is that acceptable as the contract?

  • Files to watch: hide-platform/tests/ipc.rs. The Windows pipe path was reasoned through in review, not run locally:

    • A flood client stays connected so it is not dropped as Gone.
    • About 69 connects succeed: 64 queued, 1 in send, 4 instances.

Evidence

  • Checked:
    • With nobody accepting, the connect at attempt 128 is refused with os error 61, the same index as CI.
    • The original test under 14 CPU hogs on this Mac failed 3 of 8 runs (connect 128 twice, connect 188 once), with no accept_failed line.
    • The changed test under the same load: all 26 ipc tests passed 8 of 8 runs.
    • They also passed with ulimit -n 256.
  • Checked: the hide-platform suite on macOS: lib 25, fs 60, host 15, ipc 26, process 32, watch 8 and others all pass. clippy -D warnings and fmt are clean.
  • Not checked:
    • Linux and Windows were not run locally; this PR's os contract CI is the proof.
    • The macOS leg runs in desktop e2e.
  • Not checked: windows check failed once, at web/e2e/s2.spec.ts:318: the pane was expected to leave zoom (data-zoomed true -> false). It is unrelated to this IPC change, and the signature has not been seen before. run 37215690067 / job 111475607738. Only the failed job was rerun once.
  • Quarantine: PR A (ci/main-green-quarantine, f1f5ca0) is not on main yet, so there is no ignore attribute to remove here. Whichever merges second must drop the macOS ignore on this test.

…gets

The burst test let its client loop run ahead of a starved accept thread.
macOS queues 128 unaccepted connections (SOMAXCONN) and refuses the next
at once, so a busy runner failed at connect 128 while the accept loop was
still alive (#396). The burst now waits for the accept 32 connects back,
and a separate test fills the backlog with nobody accepting and checks the
refusal each system gives and that the listener serves on afterwards.
@yansfil
yansfil merged commit f84c626 into main Oct 4, 2026
39 of 41 checks passed
@yansfil
yansfil deleted the fix/ipc-burst-contract branch October 4, 2026 23:01
yansfil added a commit that referenced this pull request Oct 5, 2026
## 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...`에 남아 있던
macOS `ignore`(닫힌 #396)를 지웠습니다. #401 본문이 "나중에 머지되는 쪽이 ignore를 지운다"고 했는데
PR A가 뒤에 머지되며 남았습니다.
- `hide-ai/src/router.rs`: leader를 `Held` backend와 `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.rs` `next_wheel...`의 `recv_timeout` 50ms를 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` + `yes` 4개) 하에서 150회, 같은 테스트를
`--ignored`로 300회 통과.
- `process.rs`: `taskpolicy -b`와 `yes` 4개 부하(살아 있음을 매 회 확인)에서 수정 전 실패
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 --lib` 44개, `herdr-core --lib`
1368개, `hide-platform --test process` 32개 통과.
  - 새 `std::thread::sleep`은 추가하지 않았습니다.
- **확인하지 못한 것**:
- **남은 실패는 기한이 아니라 제품의 hang입니다.** 부하에서 자식이 결과를 출력한 뒤 `OwnerWatch` drop의
`reader.join()`에서 11초 넘게 멈춥니다(상태 `SN`, CPU 0.01초, reader는 `recvfrom`).
30초 기한으로도 같은 곳에서 실패하고, #436 macOS job의 `only_a_guarded_launch...` 실패(출력에
`GUARDED true`가 있음)도 이 모양이라 이 PR은 그 실패를 고치지 못합니다. 주변 부하가 내려가자 재현이
사라져(0/520) 원인(shutdown과 25ms 수신 타임아웃이 둘 다 reader를 못 깨우는 이유)은 확정하지 못했습니다.
issue 초안은 로컬에 있고 등록 전 확인을 기다립니다.
- router, usage, live, handshake, watch, session_sync는 같은 부하에서 수정 전에도
0/30~120으로 흔들림이 재현되지 않았습니다. router, usage, live는 읽기로 판단한 위험이고, 순서를 테스트가
정하게 바꾼 것이라 근거를 읽기에 둡니다.
  - 수정하지 않은 항목:
- `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_DEADLINE` 10초로 바뀌어 있습니다.
- `herdr-core/src/session_sync/tests.rs`의 `wait_until` 3초 세 곳: 재현되지 않았고,
고치려면 기한을 늘리는 것뿐이라 두지 않았습니다.
- `labels/generator.rs:213`은 시계 대기가 아니라 fork가 lock 파일을 물고 있던 문제이고
1032f883으로 이미 고쳐졌습니다.
  - Linux와 Windows CI는 이 세션에서 돌리지 못했고, 로컬 macOS 기준입니다.
yansfil added a commit that referenced this pull request Oct 5, 2026
Related: #288 (flaky 정리), 격리 issue #231 #286 #287 #303 #308 #311 #400
#416 #417 #423-#428

## Summary

새 flaky 하나가 격리 PR이 머지될 때까지 모든 PR의 `verify`를 막던 구조를 도구 내장 retry로 바꿉니다.

- CI에서만 Playwright `retries: 1`(web, desktop)과 Linux Rust lane의 `cargo
nextest --profile ci`(`retries = 1`, JUnit)를 켭니다. 재시도에서 통과하면 lane은 통과하고,
두 번 실패하면 lane이 실패합니다.
- 새로 만든 것은 `scripts/ci-flaky-report.py` 하나입니다. 두 도구의 보고(JSON, JUnit)에서
flaky를 읽어 `quarantine` issue를 만들거나, 이미 그 테스트를 다루는 열린 issue(#416 #417
#423-#428 같은 손으로 쓴 것 포함)에 run을 댓글로 붙입니다. issue에는 처음 발견된 run, PR, 시스템,
만료일(7일)이 들어갑니다.
- nightly는 재시도에서도 실패한 테스트만 빨갛게 합니다. "tracked flaky tests block this
run"은 없앴고, main의 `--grep-invert @flaky`는 그대로입니다(태그가 0이 되면 지웁니다).
- 닫힌 #396에 남아 있던 `hide-platform` IPC burst test의 macOS `ignore`를
지웠습니다(수정은 #401, 최신 main에서 macOS 로컬 실행 통과).

## Review

- **판단해 주세요**: 첫 PR의 lane도 통과합니다(운영자 A안). 그 PR이 만든 회귀가 간헐로 보이면 한 번 통과할 수
있고, 막는 장치는 issue에 PR 번호가 남고 7일 기한이 붙는다는 것뿐입니다.
- **조심해서 볼 파일**: `.github/workflows/*.yml` - 호출하는 job마다 `issues: write`가
필요해 reusable workflow 호출부 6곳과 desktop/rust job에 권한이 늘었습니다(토큰은 `Report
flaky tests` step에만 전달). `scripts/verify-cargo.sh` - `nextest` 모드는
scoped 모드와 같은 인자 검사를 받습니다.
- **질문**: Windows와 macOS Rust lane은 `cargo test`로 남깁니다(`--lib x --
filter`, `-- --ignored` 인자 번역과 runner별 설치가 필요). 이 PR에 넣을지 후속으로 둘지 정해
주세요.

## Evidence

- **확인한 것**: `scripts/tests` 전체 단위 테스트 122개 통과(`test_ci_flaky_report.py`
11개, 단일 출처 검사 3개: `0.9.143`은 통과, `0.9.1`은 실패). 증거 run 37253118907에서 임시
flaky 테스트 둘을 올려 확인했습니다.
- Rust(nextest, Linux): 2212개 중 1개 FLAKY 분류, lane 통과, `Report flaky
tests`가 issue를 생성(#451, 닫음). nextest 설치 step 1초 미만, Rust job 전체 약 3분.
- Playwright(web shard 6): `retry #1`에서 통과해 `1 flaky`, lane 통과, issue
생성(#460, 닫음). 두 issue 모두 run, PR #419, 시스템, 만료일 7일을 담았습니다.
- 실제 nextest 0.9.143 JUnit과 Playwright 1.63 JSON을 스크립트가 읽는 것도 로컬에서
확인했습니다.
- **확인하지 못한 것**: 이 push 이후의 verify 전체(임시 파일 제거와 검사 수정 뒤). 두 번 실패하는 테스트가
lane을 막는 경로는 도구의 기본 동작(retry 소진 시 실패)에 맡겼고 별도 실행은 없습니다. Windows/macOS
Rust lane은 `cargo test`로 retry가 없습니다. nextest는 doc test를 돌리지 않지만
workspace에 실행되는 doc test는 0개입니다(`ignore`, `text`, `sh` 3개).

<details><summary>CI 장치 크기 (main 079b6f2 기준)</summary>

| | 079b6f2 | main 4df25a0 | 이 PR |
|---|---|---|---|
| workflow 파일 / job / step | 8 / 32 / 159 | 8 / 32 / 159 | 8 / 32 / 165
|
| workflow 줄 | 1501 | 1501 | 1576 (pr 515, web-e2e 290, nightly 215) |
| CI가 부르는 스크립트 수 / 줄 | 29 / 4195 | 29 / 4195 | 30 / 4391 |

늘어난 이유: `ci-flaky-report.py` 194줄과 그 단위 테스트 113줄, nextest 설치와 report
step, 권한 선언. 지운 것: 직접 만든 격리 장치 시안(약 490줄 + 테스트 241줄)은 main에 들어간 적이 없습니다.
</details>
HyunjunJeon pushed a commit to HyunjunJeon/hide that referenced this pull request Nov 9, 2026
… a macOS connect (with-hide#2158)

Closes with-hide/hide-private#585
Closes with-hide/hide-private#616
Closes with-hide/hide-private#603
Closes with-hide/hide-private#400
Related: with-hide/hide-private#630 (flaky-triage group 2),
with-hide/hide-private#612

## Summary

pane holder 시험이 가끔 실패하던 원인은 두 가지였습니다.

- macOS: 연결이 끝나자마자 상대가 연결을 닫으면, 연결 직후에 소켓 옵션을 다시 설정하는 단계가 `EINVAL`로
실패했습니다. macOS는 상대가 닫은 소켓의 옵션 설정을 거절합니다. 이제 macOS 연결은 소켓 옵션을 하나도 설정하지
않습니다. 원래 필요 없던 설정이었습니다.
- Windows와 macOS: "프로세스가 끝났는가"를 함수마다 다른 시점으로 읽었습니다. `start_time`은 프로세스가
끝나기 시작하자마자 끝났다고 했고, `is_alive`는 프로세스가 잡고 있던 것을 다 놓은 뒤에야 끝났다고 했습니다. 그래서
정리 코드가 아직 소켓을 쥔 holder를 "사라졌다"고 보고 소켓 파일을 남겼습니다. 이제 두 함수는 같은 시점을 끝으로
읽습니다.

스크린샷 없음: 화면을 건드리지 않는 플랫폼 계층 변경입니다.

## Review

- **판단해 주세요**: Windows에서 이미 끝나는 중인 프로세스에 `terminate`를 부르면 예전에는
`NotFound`, 이제는 `Ok`입니다(끝내 달라는 요청은 이미 이뤄지는 중). 호출자 중 이 차이에 기대는 곳은 찾지
못했습니다.
- **판단해 주세요**: macOS `start_time`은 이제 `proc_pidinfo` 대신 `is_alive`가 읽는
`KERN_PROC_PID` sysctl에서 읽습니다. 같은 커널 값(`p_start`)이라 기존 기록의 시작 시각과 일치합니다.
다른 계정 프로세스와 좀비도 이제 시작 시각을 답합니다(Linux와 같음).
- **조심해서 볼 파일**: `hide-platform/src/process.rs` - Windows `open_live`,
`ended`, `end`; failure path이고 모든 Windows 프로세스 질의가 지나갑니다.
- **조심해서 볼 파일**: `hide-platform/src/ipc.rs` - `connect_within`의 macOS
분기; Linux는 그대로입니다.

## Evidence

- **확인한 것**: 새 계약 테스트
`a_connect_the_listener_answers_and_closes_at_once_reads_the_answer_and_the_end`가
수정 전 macOS에서 300회 중 133번째에 #616과 같은 `Os { code: 22 }`로 실패, 수정 후 통과.
- **확인한 것**: 새 계약 테스트
`a_process_whose_start_time_says_it_ended_has_ended_for_is_alive_and_its_files`가
수정 전 macOS 0번째 회차에 실패(start_time은 끝, is_alive는 살아 있음), 수정 후 통과.
- **확인한 것**: macOS에서 `proc_pidinfo`와 sysctl 시작 시각을 42개 프로세스로 비교해 모두 같음.
- **확인한 것**: macOS 로컬 hide-platform 347개, hide-holder +
hide-holder-protocol 156개 전부 통과; hide-platform clippy를 macOS, Linux,
Windows 타깃으로 통과.
- **확인한 것**: 임시 반복 작업(이 PR에서 지움)으로 holder 시험과 process/ipc 계약을 시스템마다 20회,
재시도 없이: run 42202672225, Linux·macOS·Windows 각 20회(4개 작업 x 5회), 회차마다
263~296개, 실패 0. with-hide#603·#400의 records 시험이 Windows 20회에 포함됩니다.
- **확인하지 못한 것**: with-hide#612(Linux, 한 번)는 macOS에서 24개 동시 288회로도 재현되지 않았습니다. 다음
실패가 holder 로그를 남기도록 대기만 바꿨고 이슈는 열어 둡니다(#630에 기록).
- **확인하지 못한 것**: Windows는 로컬에서 실행하지 못했고 CI 반복으로만 확인했습니다.
- **닫음**: with-hide#401(2d4b791), with-hide#402(9adfa56)는 이미 고쳐진 옛 시험이라 근거와 함께 닫았습니다.

<details><summary>Verification record</summary>

</details>
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.

macOS에서 hide-platform IPC 연결 폭주 test가 ConnectionRefused로 실패한다

1 participant