Skip to content

Refuse a Node whose version probe exits unsuccessfully - #402

Merged
yansfil merged 3 commits into
mainfrom
fix/hcoord-node-probe-exit
Oct 4, 2026
Merged

yansfil merged 3 commits into
mainfrom
fix/hcoord-node-probe-exit

Conversation

@yansfil

@yansfil yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Related: no issue. The defect and its reproduction are below. This is one of the C root-cause PRs from the CI split; PR #398 (A) does not quarantine any hide-kit test, so nothing is unquarantined here.

Summary

When a device's kit is set up, find_node picks the Node hcoord runs on, starting with the one the existing hcoord shim names.
On main it adopts any candidate whose node --version printed a valid version, even when the probe exited unsuccessfully.
So a broken Node named by the shim is kept.
Now a candidate counts only when its probe exits 0 within five seconds with 22.12 or later.
Falling back to a later Node (PATH, then the stable links) still works.
When that happens, the helper writes each earlier refusal to stderr as hcoord.node_rejected.
When no Node counts, the hcoord row's reason lists every refusal.

Reproduction on main (the new test, which fails before the fix):

a stand-in node: #!/bin/sh / echo v26.7.0 / exit 3, named by ~/.hide/hcoord/bin/hcoord
main:  find_node -> Ok(<that node>)
fixed: candidates [failing, working] -> Ok(working); [failing] -> Err("...; no Node found works (<path> exited with 3)")

Review

  • Please judge: the row reason when no Node counts now carries every refusal, for example hcoord needs Node 22.12.0 or later; no Node found works (/x/node exited with 3). Is that the right length for a row?
  • Files to watch: hide-kit/src/hcoord.rs, find_node/choose_node - this is a failure path. Before the fix the loop dropped every refusal silently; the candidate order and the fallback are unchanged.

Evidence

  • Confirmed:
    • a_node_whose_probe_fails_does_not_count fails on main's logic: with the exit check removed, it returns the failing Node. It passes with the fix.
    • The test takes its candidates as given, so the host's Node cannot stand in.
    • scripts/verify-cargo.sh test-scoped -p hide-kit: 52/52 on macOS, including the_old_homes_shim_still_names_the_node unchanged.
    • Clippy -D warnings and fmt are clean for hide-kit.
    • check-no-workstation-identity.sh passes.
    • The diff was reviewed twice by a separate agent; there were no Fix-now items on the final head.
  • Not confirmed:
    • Linux and Windows CI, which this PR's CI run covers. The tests are cfg(unix), as the existing fake-Node tests are.
    • No live device check: the hcoord.node_rejected line goes to the device helper's stderr, which Hide sees only as the stderr_tail of a host.closed diagnostic.
    • The last commit is doc-only and was not rebuilt; the machine was out of disk.
  • Unrelated, seen during the run: under load average 45, one full hide-kit run failed tests::a_running_labels_watcher_is_found_by_its_lock_and_stopped. The suite took 63s, past the fixture watcher's sleep 60. It passed alone and on the next full run (7s). This was reported separately and is not in this PR's scope.

find_node adopted any candidate that printed a version, even when the
probe exited non-zero, so a broken Node named by the existing hcoord shim
was kept. The probe must now exit successfully; each candidate turned
down before the chosen one is logged as hcoord.node_rejected, and the
error when none counts lists every refusal.
…was found

The refusal reason is asserted on a fixed candidate list, so the host's
own Node can no longer stand in for the fallback. The error no longer
says none was found when a Node was found and refused, and INSTALL.md
lists the candidate order and where the refusal log goes.
@yansfil
yansfil merged commit 5e49d35 into main Oct 4, 2026
24 checks passed
@yansfil
yansfil deleted the fix/hcoord-node-probe-exit branch October 4, 2026 16:44
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