Skip to content

Replace a fixture workspace whose Windows shell an older process claims - #603

Merged
yansfil merged 1 commit into
mainfrom
fix/flaky-583
Oct 6, 2026
Merged

yansfil merged 1 commit into
mainfrom
fix/flaky-583

Conversation

@yansfil

@yansfil yansfil commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Refs #583 #538 #593

Summary

Three Windows flakes failed the same way inside startHerdr: the first agent start waited ten seconds and Herdr kept answering agent_pane_busy for a shell that held the terminal alone.
In each, the one "child" of the shell was csrss.exe: #583 shell 736 -> 748, #538 shell 728 -> 740, #593 shell 7768 -> 7784.
csrss.exe names as its parent the smss.exe that started it and exited, Windows gave that pid to the pane's shell, and the pinned Herdr counts a shell's children by parent pid alone, so the pane refuses agents for as long as csrss.exe runs (until shutdown).
hide-children.exe now prints each child's start time and whether it started before the parent, and startHerdr replaces its two panes once when a process older than a shell names it as parent.

Review

  • 판단해 주세요: the replacement is a resource swap on a detected state, not a wait or a retry of the start: it acts only on "a process that started before the shell names the shell's pid as parent" (start times, any name), at most once, logs one line, and a claimed replacement fails setup with each process's pid, start time and name.
  • 판단해 주세요 (product): a real Windows user whose pane shell gets such a pid has agent start refused in that pane the same way; Herdr's agent start takes no start time into account, so this is an upstream candidate.
  • 조심해서 볼 파일: web/e2e/herdr-fixture.ts - the new workspace is opened while the claimed shells still hold their pids, so no new shell can be given one of them, and the claimed workspace is closed after; the two agent starts now come after both panes are ready instead of between them.
  • 조심해서 볼 파일: web/e2e/shims/hide-children.c - OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION) and GetProcessTimes; a process Windows does not answer for is unknown, never older.

Evidence

csrss.exe names as its parent the smss.exe that started it at boot and
exited, and Windows can give that pid to a pane's shell. The pinned Herdr
counts a shell's children by parent pid alone, so agent start in that pane
was refused for the whole run. hide-children.exe now prints each child's
start time and whether it started before the parent; startHerdr opens its
two panes again in a new workspace when a process older than a shell names
it as parent, at most once, and fails with each process's pid, start time
and name when the replacement is claimed too.
@yansfil
yansfil merged commit e1e8ac2 into main Oct 6, 2026
18 checks passed
@yansfil
yansfil deleted the fix/flaky-583 branch October 6, 2026 03:51
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.

1 participant