Skip to content

fix: read a process's end by one rule and set no socket option around a macOS connect - #2158

Merged
yansfil merged 6 commits into
mainfrom
fix/flaky-holder
Nov 6, 2026
Merged

yansfil merged 6 commits into
mainfrom
fix/flaky-holder

Conversation

@yansfil

@yansfil yansfil commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

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. Replace a fixture workspace whose Windows shell an older process claims #603·#400의 records 시험이 Windows 20회에 포함됩니다.
  • 확인하지 못한 것: Read a pane focus's late tab move as its answer #612(Linux, 한 번)는 macOS에서 24개 동시 288회로도 재현되지 않았습니다. 다음 실패가 holder 로그를 남기도록 대기만 바꿨고 이슈는 열어 둡니다(#630에 기록).
  • 확인하지 못한 것: Windows는 로컬에서 실행하지 못했고 CI 반복으로만 확인했습니다.
  • 닫음: Keep the IPC burst test inside the backlog and pin what a connect past it gets #401(2d4b791), Refuse a Node whose version probe exits unsuccessfully #402(9adfa56)는 이미 고쳐진 옛 시험이라 근거와 함께 닫았습니다.
Verification record

…loses at once refuses

A pane holder past its opening bound answers the connection and closes
it at once. macOS refuses every socket option once the peer has closed,
so clearing the connect's send timeout after the system's connect
answered EINVAL to the caller (with-hide/hide-private#616). macOS
refuses a full backlog at once and never needed the send timeout; Linux
keeps it and allows it after the peer closed.
Windows start_time read a process as ended once its exit code was set,
while is_alive waited for its object to be signalled, after the system
closed the handles it held; a pane record then read its holder as gone
while the holder still held its socket (with-hide/hide-private#585).
Every Windows query now reads the end by the signal, and ending a
process whose end has begun is what was asked. macOS start_time read
proc_pidinfo, which stops answering while the process is still on its
way out; it now reads the process table is_alive reads, whose start
time is the same kernel value.
@yansfil
yansfil added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit ce1f97c Nov 6, 2026
46 checks passed
@yansfil
yansfil deleted the fix/flaky-holder branch November 6, 2026 11:29
HyunjunJeon pushed a commit to HyunjunJeon/hide that referenced this pull request Nov 9, 2026
…erdr (with-hide#2177)

Related: with-hide#2167 (앞 단계, 머지됨). 다음 단계는 `herdr-core` crate 이름 바꾸기로, 이 PR은
crate 이름과 `herdr_core::` 경로를 건드리지 않습니다.

## Summary

Herdr가 빠진 뒤에도 코드 이름이 엔진, 홀더, 노드를 여전히 "herdr"라고 불러서 읽는 사람을 헷갈리게 했습니다.
이 PR은 그 Rust와 TypeScript 식별자, 모듈, 파일 이름을 하는 일대로 바꿉니다
(`agent_sleep_herdr` -> `agent_sleep_engine`, `herdr_profiles` ->
`machine_profiles`, `HerdrTabView` -> `EngineTabView` 등).
디스크와 wire에 쓰이는 이름은 한 글자도 바꾸지 않았습니다: 바뀐 Rust 필드는 `#[serde(rename = "옛
이름")]`으로 고정했고, TypeScript의 wire 키도 그대로입니다.
그래서 1.2.1과 1.2.2 사용자는 마이그레이션 없이 업데이트됩니다.

스크린샷 없음: 식별자 이름만 바뀌었고 화면, 문구, wire 키는 그대로입니다.

## Review

- **판단해 주세요**: 아래 "남긴 이름"이 Herdr 자체를 가리키는 것만 남겼는지. 특히 `codex_trust`의
Herdr 훅 항목(`select_with_herdr`, `herdr_entry`)과
`herdr_transition`/`herdr_move`는 Herdr 통합과 Herdr 세션 이동을 다루므로 남겼습니다.
- **조심해서 볼 파일**:
- `herdr-core/src/model.rs` - snapshot wire: serde 고정 6곳 (`herdr`,
`herdr_name`, `herdr_label`, strip kind `herdr`, `herdr_profiles`)
- `herdr-core/src/model/rest.rs` - snapshot wire: section 매크로가 필드 이름을 키로
쓰므로 `as "herdr"` 같은 wire 키 지정을 추가
- `herdr-core/src/persistence.rs`,
`herdr-core/src/agent_hooks/facts.rs`,
`herdr-core/src/node_migration/reown.rs` - 디스크 형식: `focus_from_herdr`,
`herdr_session`, `*_owner_herdr_socket` 고정
- `hide-agent-adapter/src/{web,journey}.rs` - 계약 JSON의 `herdr_kind` 고정;
`HerdrIntegration { name, target }`은 읽는 곳이 없던 `target`을 빼고
`engine_kind`로 줄임
- **고정한 직렬화 이름** (Rust 이름 -> wire/디스크 키):
- `StatusSnapshot.engine` -> `herdr`, `.machine_profiles` ->
`herdr_profiles`
- `SidebarAgentSnapshot.given_name` -> `herdr_name`,
`PaneSnapshot.engine_label` -> `herdr_label`
  - `StripTabKind::Engine` -> `herdr` (id 값 `herdr:<tab>`도 그대로)
- 저장소 `focus_from_engine` -> `focus_from_herdr`, hook facts
`engine_session` -> `herdr_session`
- `OwnerChange.{old,new}_owner_engine_socket` ->
`{old,new}_owner_herdr_socket`
- 어댑터 계약 `engine_kind` -> `herdr_kind`; 이벤트 `herdr_profiles_list`,
`herdr_profile_connect`는 문자열 디코드라 그대로
- **남긴 이름** (Herdr 자체를 가리킴):
- 가져오기와 전환: `herdr_import*`, web `HerdrImport*`, `herdr_transition`,
`herdr_move`/`herdr_look`, `herdr_save`, `herdr_running`, `herdr_held`,
`engine/own/herdr_session.rs`, `Numbered::Herdr`/`HERDR_WORKSPACE`
- kit: `device_herdr`, `herdr_integration`, `herdr_hooks`, 은퇴 에이전트
`herdr_code`, hide-host kit의 옛 Herdr 사본 정리
- Herdr 자체: codex_trust의 Herdr 훅 항목, hide-platform의 Herdr 소켓/설정/세션 이름
해석, 홀더의 `HERDR_*` 환경 제거, desk `HERDR_CLOSES`, core_move
`Inspection.herdr_socket`, `HERDR_*` 환경 변수 이름
- Herdr와 비교하거나 Herdr가 없음을 확인하는 테스트 이름 (예:
`a_wheel_is_routed_as_herdr_routes_it`,
`what_an_agent_is_taught_names_no_herdr`)
- TypeScript wire 키(`herdr_label`, `herdr_name`, `herdr_profiles`,
`herdr_kind`, `herdr_socket_path`, `herdr_bin_path`, `status.herdr`),
i18n 키 문자열, e2e 파일 `agents-follow-herdr.spec.ts`,
`herdr-coexistence.spec.ts`
  - `herdr_core::` 경로: 다음 단계

## Evidence

- **확인한 것**:
- 1.2.1 형식 fixture 왕복 테스트 7개
(`herdr-core/tests/fixtures/release-1.2.1/`): 1.2.1 daemon이 실제로 쓴 hook
facts와 UI 저장소, 보낸 snapshot을 읽고 같은 키로 다시 씀. pin 하나(`herdr_label`)를 빼 보면
해당 테스트가 실패하는 것도 확인
- 격리 복원: 출시된 1.2.1 `hided`가 `/tmp` 상태 폴더(개인 HOME)에 프로젝트, 이름 붙인 탭 2개, 분할
창, 라벨 붙은 stand-in Claude 에이전트를 만든 뒤, 이 브랜치의 `hided`를 같은 폴더에서 시작
- 앱 업데이트 경우(홀더 살아 있음, 4개 adopt)와 재부팅 경우(홀더 없음, 4개 새로 시작, 에이전트 1개 resume)
모두 워크스페이스, 탭 순서와 이름, 창, 에이전트 세션과 라벨이 1.2.1과 같음
- 두 경우 snapshot의 herdr 키(`herdr`, `herdr_profiles`, `herdr_label` x5,
strip kind `herdr` x3)가 1.2.1과 같음. 끝난 뒤 남은 프로세스 0개
- 바꾼 crate 테스트: nextest `herdr-core`, `hided`(통합 테스트 포함),
`hide-agent-adapter`, `hide-desk`, `hide-kit`, `hide-node`,
`hide-node-link`, `hide-session` 5777개 중 hide-kit 밖에서 2개 말고 모두 통과;
hide-kit은 pane이 넘긴 `HIDE_*` 환경을 비우고 195/195 통과 (CI와 같은 조건)
- `web test` 292 파일 2667개 통과; fmt-check, clippy `-D warnings`, web lint,
web typecheck, desktop typecheck 통과
- **확인하지 못한 것**:
- Playwright e2e는 돌리지 않았습니다. 바꾼 것은 e2e 안의 변수 이름이고, wire 키와 DOM 속성 중 읽히는
것은 그대로입니다 (`data-herdr-message` -> `data-engine-message`는 읽는 곳이 없음)
  - 재부팅 경우 쉬던 에이전트는 잠든 상태로 돌아옵니다. 1.2.1 이후 들어온 8fc77f0f8의 동작이고 이 PR과 무관
- herdr-core `worktree_control`의 테스트
2개(`a_process_that_has_ended_is_not_waited_for`,
`a_pane_reports_each_running_process_once_and_never_the_systems_pids`)가
이 Mac에서 실패: 가짜 pid `u32::MAX - 1`을 with-hide#2158 이후 macOS가 EINVAL로 돌려줌. base에도
있는 macOS 전용 실패로 이 PR과 무관하고, PR CI에는 macOS 줄이 없음
- `herdr_name`은 격리 실행에서 이름 붙인 에이전트를 만들지 않아, 1.2.1 웹 셸이 읽는
키(`snapshot.ts`)를 기준으로 단위 테스트만 했습니다
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