Skip to content

hide가 가진 파일을 ~/.hide 아래로 모으고 hcoord를 hide 전용으로 만듭니다 - #319

Merged
yansfil merged 20 commits into
mainfrom
prd/hide-home-layout
Oct 3, 2026
Merged

yansfil merged 20 commits into
mainfrom
prd/hide-home-layout

Conversation

@yansfil

@yansfil yansfil commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Related: PRD agents/prd/hide-home-layout/prd.md · sasu 쪽 짝 PR: yansfil/sasu#14

Summary

  • hide가 가진 파일이 ~/.local/state/hide, ~/.local/share/hide, ~/.hcoord에 흩어져 있던 것을 ~/.hide 아래로 모읍니다.
  • 이 Mac: 첫 hide connect가 옛 상태 폴더를 통째로 ~/.hide/state로 옮기고, 그 폴더의 옛 daemon을 먼저 멈춥니다.
  • hcoord는 hide 전용 부품이 됩니다: kit이 ~/.hide/hcoord에 설치하고 ~/.hcoord를 한 번 옮기며, 단독 Herdr 플러그인 배포물은 지웁니다.
  • 기기: helper가 ~/.hide/host-helper로 옮겨 가고, 이미 동의한 기기는 다시 묻지 않습니다(동의를 새 기본 경로로 이어 붙임, protocol 13).
  • 옛 경로(라벨 플러그인 시절 폴더, 옛 helper 폴더와 bridge)는 새 경로가 동작한 뒤 kit 패스가 지웁니다.

This Mac의 hcoord 줄: ~/.hide/hcoord에 설치됐고, PATH의 hcoord가 다른 프로그램 것이면 그 이유를 흐린 줄로 보입니다

Review

  • 판단해 주세요: 설치 순서는 PRD D-16대로 sasu 먼저, 새 hide 앱을 바로 뒤에. 머지는 hide 먼저, sasu의 pin을 이 PR 머지 커밋으로 옮겨 CI 통과 뒤 sasu 머지, 그다음 sasu 설치, hide 앱 설치.
  • 판단해 주세요: 새 hide와 옛 sasu가 함께 있으면 옛 sasu의 hcoord 사본(고정 이름 com.hcoord.daemon, 홈 ~/.hcoord)이 ~/.hcoord를 다시 만들고 daemon을 가져갈 수 있습니다. sasu 먼저면 1분쯤 hcoord가 PATH에 없을 뿐입니다.
  • 판단해 주세요: 이 Mac에 새 앱을 설치하면 mini도 다음 연결에서 자동으로 옮겨집니다(helper, bridge, ~/.hcoord).
  • 판단해 주세요: Codex를 쓰면 ~/.codex/config.toml의 writable_roots에 ~/.hide/hcoord를 손으로 추가해야 합니다. 그 파일은 운영자 것이라 아무것도 고치지 않습니다.
  • 판단해 주세요: 기기의 bridge 폴더는 D-06대로 각 프로세스의 XDG_STATE_HOME을 따릅니다. helper와 에이전트 셸이 다르면 서로 못 찾습니다.
  • 판단해 주세요: 세션 안내가 맨 hcoord를 쓰므로 ~/.local/bin이 PATH에 없으면 위임이 안 됩니다(B17 그대로).
  • 조심해서 볼 파일: hided/src/state_move.rs, hided/src/cli.rs - failure path, 운영자 상태 폴더를 rename하고 옛 daemon에 신호를 보냄.
  • 조심해서 볼 파일: hide-kit/src/legacy.rs - 삭제 범위, 상수 경로만 lstat로 확인 뒤 지움.
  • 조심해서 볼 파일: hide-kit/src/hcoord.rs, plugins/hcoord/src/hcoord/home.ts - launchd bootout 뒤 rename, 실패하면 옛 plist로 되살림.
  • 조심해서 볼 파일: herdr-core/src/runtime/hosts.rs - 동의 이어 붙이기, 옛 기본 경로와 새 기본 경로 한 쌍만.
  • 질문: ~/.hide/hcoord가 비어 있고 ~/.hcoord에 ledger가 있으면 지금은 옮기지 않고 줄에 메모만 보입니다. 이 경우 옮겨야 할까요?

Evidence

  • 확인한 것: 데스크톱 e2e 2/2, 격리 HOME과 Herdr, 이 체크아웃으로 만든 Hide.app. 옛 daemon 정지, 폴더 이동, ~/.hcoord ledger 바이트 동일, PATH 링크, 고아 폴더 삭제, 두 번째 연결은 아무것도 안 함.
  • 확인한 것: 두 번째 e2e는 다른 프로그램의 ~/.local/bin/hcoord를 그대로 두고 설치된 줄에 이유를 보입니다(위 이미지).
  • 확인한 것: 모든 e2e에서 운영자의 com.hcoord.daemon pid가 그대로였고, 테스트는 자기 이름이 다른 label만 내립니다.
  • 확인한 것: connect_build 8건(첫 연결 이동, 재배치된 폴더는 안 옮김, 두 폴더면 새 것 사용, 잠금을 쥔 응답 없는 프로세스면 아무것도 안 옮김).
  • 확인한 것: hide-kit 40건, hcoord home adopt 단위 10건(가짜 launchctl), sasu에서 옮겨 온 daemon start 2건.
  • 확인한 것: 병합 뒤 verify-web.sh 통과(hcoord 단위 48, e2e 35, web 822, desktop 81), 전체 cargo test와 lint 통과.
  • CI 수정 뒤(897f143): hide-kit 40/40, lint 통과. plugins/hcoord/dist, hide-agent-hooks, hide-host-helper를 지우고 CI와 같은 명령으로 다시 빌드한 상태에서 desktop e2e 32 통과(5 skip; 실패 1은 CI 필수 실행에서 빠지는 @flaky @needs-focus 포커스 테스트), home-layout 2/2. 실행 전후 launchctl list | rg hcoord 동일. Linux는 이 Mac에서 돌리지 못해 PR CI가 증거.
  • 확인한 것: sasu는 이 hcoord를 PATH 대신 고정 빌드로 받아 e2e 146/146.
  • 확인하지 못한 것: 기기(SSH) 경로 전체, 실제 옛 패키지 앱에서 이 앱으로의 업그레이드, 기본 label로 실제 launchd에서 하는 ~/.hcoord 이동(테스트에서 일부러 하지 않음).
  • 확인하지 못한 것: Windows 컴파일은 CI의 windows check에 맡깁니다. hide-kit은 main처럼 플랫폼 층만 쓰도록 맞췄습니다.

Breaking change

  • 상태 폴더가 ~/.hide/state로 옮겨 갑니다. 이 PR 이전 빌드로 돌아가려면 docs/INSTALL.md의 "Going back to a build from before ~/.hide" 절차를 따르세요.
  • hcoord의 단독 Herdr 플러그인(hide.hcoord)과 install:remote가 사라집니다. hcoord는 hide 앱이 설치합니다.
  • 운영자가 손으로 할 일: Codex writable_roots에 ~/.hide/hcoord 추가.
Verification record
  • PRD: agents/prd/hide-home-layout/prd.md (sha256 342f7150c2708279cd06974776a3a9053764cd60033e6ae630fd4daace485040)
  • Base 3f920f4 → head 897f143, verified 2026-10-02T08:04:56.485Z: PASS
  • Verification report: agents/runs/hide-home-layout/verification-report.json and agents/runs/hide-home-layout/verification-report.md; source fingerprint 7f13242430d924e7192886b10ff2602f7c4ef8f4eec6fcb7a9bd84deeaa0f7e2
  • Suites:
    • S1: GREEN bash scripts/verify-cargo.sh test (exit 0)
    • S2: GREEN bash scripts/verify-cargo.sh lint (exit 0)
  • Reviews (native, advisory):
    • Fidelity (ac3b252f까지): Fix now 1건, B14 이유가 설치된 줄에 안 보임 -> c1b29d4d에서 고침(e2e와 스크린샷). 남은 Follow-up은 Review에.
    • Code (ac3b252, 병합 8e5615d 해소까지): Fix now 4건 모두 고침. 옛 상태 폴더는 hided.lock이 비었을 때만 이동, 남은 ~/.hcoord가 업데이트를 막지 않음, 이동 뒤 설치 실패는 다음 패스에 마저 설치, 다른 계정이 쓸 수 있는 옛 폴더는 옮길 때만 거부.
    • Security (ac3b252, 병합 8e5615d 해소까지): Fix now 4건 모두 고침. hcoord home adopt는 경로를 받지 않음, 위치를 옮긴 hcoord는 PATH 링크를 건드리지 않음, 응답 없는 옛 daemon 아래서 이동하지 않음, 공유 쓰기 폴더의 pid를 신호하지 않음.
    • Code follow-up (dcde2eb, CI 수정 2커밋만): 발견 없음. kit 기록 테스트는 installed/retired 목록을 정확히 비교(Linux에서 retired의 hide.hcoord가 설치로 읽히던 문제), desktop-e2e 잡이 hcoord를 빌드. 897f143(desktop-e2e가 hide-agent-hooks/hide-host-helper도 빌드, 없으면 빌드 명령을 알려줌)는 같은 범위의 CI 준비 단계라 별도 리뷰 없음.
  • Evidence: 10 registered (8 log, 2 screenshot); paths are local to the run directory
    • agents/runs/hide-home-layout/e2e/home-layout.out
    • agents/runs/hide-home-layout/e2e/home-layout-this-mac-kit.png
    • agents/runs/hide-home-layout/e2e/home-layout-2.out
    • agents/runs/hide-home-layout/e2e/home-layout-foreign-hcoord.png
    • agents/runs/hide-home-layout/e2e/home-layout-4fb8fb55.out
    • agents/runs/hide-home-layout/sasu-checks/head-fb5f079/cli-e2e.txt
    • agents/runs/hide-home-layout/sasu-checks/head-fb5f079/cli-unit.txt
    • agents/runs/hide-home-layout/sasu-checks/ci-source/cli-e2e-with-SASU_TEST_HCOORD.txt
    • agents/runs/hide-home-layout/sasu-checks/ci-source/e2e-CI1-without-SASU_TEST_HCOORD.txt
    • agents/runs/hide-home-layout/sasu-checks/ci-source/fork-test-coverage.txt
  • Changed paths: 126 (see Files changed)

yansfil added 17 commits October 2, 2026 11:36
…n connect

hide_kit::layout names every hide default path. hide connect renames
~/.local/state/hide to ~/.hide/state after stopping the daemon that runs
from it, only for the default folder; HIDE_STATE_DIR and XDG_STATE_HOME
move nothing. Device label locks and the device bridge folder are derived
from the state folder instead of HOME.
hcoord's default home is ~/.hide/hcoord and its plain LaunchAgent label
belongs to the account's default home only, read from the user database,
so a HOME-only test can no longer take it. hcoord home adopt stops the old
daemon, renames ~/.hcoord whole and drops only socket, lock and temporary
files, or restores the old daemon. The kit runs it from the build's
packaged copy before replacing the installed one, writes the shim in the
new home, links hcoord on PATH when the name is free or Hide's, takes the
standalone hcoord Herdr plugin out once, and retires the folders the old
layout left. Hardcoded ~/.hcoord paths now follow the hcoord home, and the
SessionStart text names hcoord on PATH.
… consent

The default helper root is ~/.hide/host-helper. A consent for the old
default root, with the same command folder and no HIDE_HOST_HELPER_ROOT,
is rewritten to the new root without asking, and the connection reads the
consent again after the carry so it installs at the new root. Helper
protocol 13: a helper under the default root retires the old root, once no
hook or link names it, and the old bridge folder. Settings names the new
places.
The standalone hcoord distribution goes: the Herdr plugin manifest, its
build and startup hooks, the remote shim installer and the package bin.
INSTALL names every folder under ~/.hide, what stays outside, the one-time
moves on this Mac and on devices, the Codex writable_roots line and how to
go back to an older build; the other guides follow the new paths.
…ocated or doubled homes from blocking the kit
Main moved the kit's locks, links and atomic writes onto hide-platform;
the hcoord link and the old-layout retirement now use the same layer, and
the state move stops a legacy daemon by the recorded-start rule main added.
The first-apply test matched "hcoord" anywhere in installed.json, so on
Linux the recorded retirement of the standalone hide.hcoord plugin read as
an installed hcoord part. Parse the record and compare both lists.
The home-layout spec stages plugins/hcoord/dist the way the package does,
and the desktop-e2e job never built it.
stageBuild lays out hide-agent-hooks and hide-host-helper beside hided as
the packaged app does, and the desktop-e2e job built only the hided
package. Build all three packages, and name the build command when a
binary is missing instead of failing in copyfile.
@yansfil
yansfil merged commit 1fee4eb into main Oct 3, 2026
21 checks passed
@yansfil
yansfil deleted the prd/hide-home-layout branch October 3, 2026 05:05
yansfil added a commit that referenced this pull request Oct 3, 2026
)

Refs #293

## Summary

OS 경계 4번째 조각입니다. 폴더 감시(`watch`)와 계정·기기 위치(`host`)를 `hide-platform`에 두고,
herdr-core, hided, hide-ai, hide-memory(그리고 hide-agent-hooks, hide-host
일부)에 남아 있던 손으로 쓴 OS 코드를 그 위로 옮겼습니다.
그 결과 `windows check`가 herdr-core와 hided를 포함한 워크스페이스 전체를 테스트까지 컴파일합니다(로컬
Windows sysroot로 확인했고, 이 PR의 CI 로그에서 `outcome: success`).
Git 감시는 이제 넘침을 버리지 않고 `Change::Overflow`로 알리며, 그때는 진단 하나를 남기고 감시 중인
프로젝트를 다시 읽습니다.
화면 변경은 없습니다.

```
watch: Watcher::keeping(filter) + Changes 큐(경로 4096개 상한, 중복 제거, 넘치면 Overflow 하나)
host:  home_dir, state_dir(_under), herdr_socket_default, login_path/find_program, default_shell,
       trash, tailscale_cli, name, machine_id  (+ 호출자 레지스트리용 _from 형태)
fs:    space(할당 바이트·여유 공간), private::open_own_file / create_dir_all, open_regular,
       identity::{Stamp, path_of}
```

## Review

- **판단해 주세요**: 핸드오프의 `watch(dir) -> Receiver<Change>` 대신
`Watcher`(watch/unwatch) + 큐 하나로 만들었습니다. Git 감시는 루트 최대 64개를 감시자 하나로 보기
때문입니다.
- **판단해 주세요**: hided는 Windows에서 시작을 거부합니다. pane bootstrap 소켓이 #315 전까지
`Unsupported`를 답하기 때문이고, 데몬 e2e(`handshake.rs`, `mobile.rs`)도 그래서 Unix
전용입니다.
- **판단해 주세요**: 아무도 보내지 않는 터미널 input trace(`input_trace`/`input_sent`)를
지웠습니다. snapshot wire에서 필드 하나가 빠지지만 읽는 쪽이 없습니다.
- **판단해 주세요**: Linux의 AI 설정 위치가 `~/Library/Application
Support/hide/ai.json`에서 `~/.local/state/hide/ai.json`으로 바뀝니다(macOS는
그대로). Linux는 배포 대상이 아닙니다.
- **조심해서 볼 파일**: `hide-platform/src/watch.rs` - Windows는 notify 대신
`ReadDirectoryChangesW`를 직접 씁니다(notify는 버퍼 넘침을 조용히 버림). unsafe Win32
코드입니다.
- **조심해서 볼 파일**: `herdr-core/src/worktrees.rs` - high-frequency path. 큐는
coordinator tick에서 runtime lock 밖으로 비웁니다. 감시 이벤트로 notifier를 깨우지 않는 것은 전과
같습니다.
- **조심해서 볼 파일**: `hided/src/pane_auth.rs`, `hided/src/workspace_cli.rs`,
`hided/src/boundary.rs` - failure path. 자격 증명 파일과 루트 확인이
`open_own_file`(심볼릭 링크·하드 링크·다른 계정 파일 거부), `is_private`, `FileId`,
`path_of`로 바뀌었습니다.
- **조심해서 볼 파일**: `hided/src/env.rs` - 기본 Herdr 소켓이 Herdr 자신의 순서를 따릅니다.
`XDG_CONFIG_HOME`이 있으면 그 아래를 봅니다(전에는 무시). hided 상태 폴더는 main(#319)의
`~/.hide/state` 그대로입니다.
- **판단해 주세요**: main(#319)과 충돌한 세 파일을 rebase에서 이렇게 풀었습니다.
- `hided/src/env.rs`: Windows 상태 폴더를 `%LOCALAPPDATA%\hide`로 두던 이 PR의 분기를
버리고, 모든 시스템에서 main의 `hide_kit::layout::state_dir`(`~/.hide/state`)을
따릅니다. Windows에서는 홈을 `USERPROFILE`로 읽으므로 `%USERPROFILE%\.hide\state`가
됩니다. 이제 아무도 읽지 않는 `LOCALAPPDATA`는 레지스트리에서 뺐습니다.
- `hided/src/state_file.rs`: main의 `create_private_dir`(Unix
`DirBuilder` 0700, 새로 만드는 `~/.hide`도 private)는 이름을 그대로 두고 내용만
`private::create_dir_all`로 바꿨습니다. 같은 약속을 모든 시스템에서 지킵니다. 잠금은 이 PR대로
`open_own_file`과 std 파일 잠금을 씁니다.
- `herdr-core/src/live.rs`: hcoord 명령 경로는 main의
`hide_kit::layout`(`~/.hide` 배치, `HCOORD_HOME`)을 따르고, 홈만
`host::home_dir`로 읽습니다.

## Evidence

- **확인한 것**: macOS에서 `verify-cargo.sh lint`, `verify-cargo.sh test`(테스트
바이너리 54개)와 check 스크립트 7개, `scripts/tests` 32개가 통과했습니다.
- **확인한 것**: 웹 e2e 117개가 격리된 pinned Herdr v0.9.1에서 모두 통과했습니다(리뷰 수정 전 빌드,
1 worker, 22분). 그 뒤의 수정은 cargo lane으로 다시 확인했습니다.
- **확인한 것**: 공식 rust 1.97.1 Windows/Linux sysroot로 `cargo check`와
`clippy --workspace --all-targets -D warnings`가 모두 깨끗했습니다. C 빌드 스크립트는 가짜
컴파일러로 넘겼으므로 링크는 CI가 증명합니다.
- **확인한 것**: `watch` 계약 테스트 8개가 macOS에서 통과했습니다. 생성·쓰기·이름 바꾸기·삭제가 2초 안에
오고, 읽기는 변화가 아니며, 1만 개 burst는 4097개 이하로 끝나고 Overflow를 냅니다. 필터와 중첩 폴더도
확인했습니다.
- **확인한 것**: 기본 소켓 계약을 pinned Herdr의 `status server --json`과
비교했습니다(`real_herdr.rs`, 빈 임시 HOME).
- **확인한 것**: macOS 감시 측정입니다. 이전 notify 콜백과 새 경로를 같은 debug 빌드에서 3회씩 쟀고,
쓰기는 자식 프로세스가 했습니다.
  - idle 30초: CPU가 3.5~5.7ms로 둘 다 같고, 이벤트는 0입니다.
- commit 40회: CPU가 이전 12.9~14.5ms, 새 경로 14.0~15.6ms입니다. tick에 도착한 것은 이전
콜백 약 3,100회 대 새 경로 69개입니다. Git 재읽기는 둘 다 1회입니다.
- `.git/objects`에 1만 개 burst: CPU가 이전 48~54ms, 새 경로 43~54ms이고 넘침은 0입니다.
- **확인한 것**: 필터 없이 처음 잰 새 경로는 burst에서 CPU가 2배였고, 큐가 넘쳐 모든 프로젝트 재읽기를
일으켰습니다. 그래서 `Watcher::keeping`을 넣었습니다(커밋 41297cd).
- **확인한 것**: 독립 리뷰의 Fix now 5개 중 4개를 고쳤습니다. 중첩 감시 폴더, Windows `path_of`
접두사, 하드 링크, kit 기본 소켓입니다. 남은 하나("Windows 빌드 미확인")는 CI `windows check`의
`cargo check --workspace --all-targets` 결과(`outcome: success`)로 답했습니다. 이
job은 그 단계가 `continue-on-error`라서 job 색이 아니라 로그의 outcome 줄이 근거입니다.
- **확인한 것**: CI `os contract`에서 Linux와 Windows 모두 계약 테스트가 전부 통과했습니다.
Windows는 fs 49, host 12, ipc 20, process 17, watch 8개이고, Linux는 fs 50,
host 12, ipc 21, process 18, watch 8개입니다. `real_herdr --ignored` 2개도
양쪽에서 통과했습니다. Windows 감시 백엔드(`ReadDirectoryChangesW`)는 이 run에서 처음 실행됐습니다.
- **확인한 것**: 첫 Windows run은
`a_trashed_file_leaves_its_folder_for_the_trash` 하나가 실패했습니다. 파일은 휴지통에
들어갔지만, 휴지통이 Explorer 기본 보기대로 `.txt`를 뗀 표시 이름으로 항목을 보여 줘서 테스트가 찾지 못했습니다.
테스트 파일 이름에서 확장자를 뺐습니다(41cdaad).
- **확인하지 못한 것**: Linux·Windows 감시 측정은 하지 못했습니다(macOS만).
- **확인하지 못한 것**: desktop e2e는 로컬에서 돌리지 않았습니다. CI `desktop e2e`는 통과했습니다.
- **확인한 것**: rebase한 head에서 `cargo fmt --all --check`, `verify-cargo.sh
lint`, `verify-cargo.sh test`(테스트 바이너리 54개), check 스크립트 7개와
`scripts/tests`, `web` lint가 모두 통과했습니다. Windows 교차 컴파일은 로컬에서 다시 하지
못했습니다. 이 push의 CI `windows check`가 그 증거가 됩니다.
- **확인하지 못한 것**: rebase 전 마지막 커밋의 첫 CI 시도에서 Linux 웹 e2e shard 2/6의
`e2e/home.spec.ts:29`가 한 번 실패했습니다. 기대값은 `Home/~/hide`였는데 실제로는
`Home/hde-0PpyWQ/hde-0PpyWQ`가 보였습니다. 데몬 로그상 Home 동기화와 탭
경로(`/tmp/hde-0PpyWQ/home/hide`)는 맞았습니다. 그런데 Herdr pane 하나가 fixture 임시 폴더
`/tmp/hde-0PpyWQ`를 cwd로 보고해서, Home이 아닌 체크아웃이 생겼습니다. 같은 빌드로 그 job만 다시 돌리니
통과했고, 로컬 macOS에서도 20회 모두 통과했습니다. 다른 브랜치의 최근 실패 run 60개에서는 이 테스트가 한 번도
실패하지 않았습니다. 원인을 찾지 못했으므로 알려진 flake로 보지 않습니다. 이 PR과의 관계도 확인되지 않았습니다. 판단을
부탁드립니다.
- 다음에 다시 실패하면 근거가 남도록, 이 테스트가 실패할 때만 `home-diagnostics.json`을
`test-results/`에 쓰고 첨부합니다(e8bf88e). pane마다 Herdr의 `cwd`(OSC 7 보고가 있으면 그
값)와 `foreground_cwd`(`/proc`), 포그라운드 프로세스별 cwd, Linux에서 직접 읽은 셸의
`/proc/<pid>/cwd`, 화면 내용, 그리고 Hide의 위치 표시가 어디에 닿았는지를 담습니다. 셸의 `/proc` 값은
맞는데 Herdr의 `cwd`만 틀렸다면 OSC 7 보고가 원인입니다.
- 테스트가 확인하는 내용은 그대로입니다. 일부러 실패시킨 로컬 실행에서 원래 오류가 그대로 보고되고 파일이 남는 것을
확인했습니다. 되돌린 뒤에는 20/20 통과했고 파일은 생기지 않았습니다.
- **확인하지 못한 것**: Windows에서 hided를 실제로 띄우는 것은 #315 때문에 범위 밖입니다.
- **확인하지 못한 것**:
`labels::tests::a_second_daemon_on_the_same_server_stands_by_and_shows_no_labels`가
로컬 전체 실행 7회 중 1회 실패했습니다(단독 재실행과 이후 6회는 통과). lock 의미는 같으므로(`flock` 그대로)
기존 경합으로 보지만 원인은 확인하지 못했습니다.

<details><summary>남은 OS 코드와 후속 작업</summary>

- 아직 옮기지 않은 것:
- `hide-host`의 FIFO 막는 `O_NONBLOCK` open과 `list.rs`의 `readlinkat`,
`hide-session`
- hided `boundary.rs`의 루트 open(`openat` / final-path 확인), Windows
`ShellExecuteW` opener, `lib.rs`의 종료 신호
- 설계상 Unix인 것: pane bootstrap listener, 기기 workspace bridge, opener
supervisor socketpair
- 리뷰 Follow-up:
  - watch가 끝난 폴더(삭제 후 재생성)의 침묵
  - inotify watch 한도에서 생기는 overflow 폭주
  - Windows 감시 스레드를 폴더당 하나에서 completion port로
  - `is_private`의 handle 기반 판정
  - `create_dir_all`이 만든 상위 폴더도 private가 되는 점
- `hide-agent-hooks/src/memory.rs`의 `Library/Application Support` 경로와
코어의 상태 폴더 불일치 확인
  - hide-kit의 PATH 탐색

</details>
yansfil added a commit that referenced this pull request Oct 29, 2026
Closes with-hide/hide-private#153
Closes with-hide/hide-private#152
Closes with-hide/hide-private#148
Closes with-hide/hide-private#218
Closes with-hide/hide-private#213
Closes with-hide/hide-private#227
Closes with-hide/hide-private#319
Closes with-hide/hide-private#159
Closes with-hide/hide-private#246
Closes with-hide/hide-private#186
Closes with-hide/hide-private#126

## Summary

herdr-core의 연결 노드 runtime 테스트 11개가 가끔 실패하던 원인을 고쳤습니다.
대부분은 테스트가 순서를 직접 정하지 않아 백그라운드 작업이 끼어든 경우였고, 그중 둘은 제품 쪽 문제였습니다.

- 정리(cleanup) 검토 결과가 화면에 나온 바로 그 순간 누른 "정리" 확인이 조용히 버려졌습니다. 이제 검토 결과와 다음
작업 허용이 같은 순간에 일어나서 확인이 항상 받아들여집니다.
- 새 pane의 셸 대기에서, 마감이 읽기 도중에 끼어들면 앞서 실패한 이유가 지워져 진단 기록이 "unreadable" 대신
"timeout"이 되거나 엉뚱한 이유를 남겼습니다. 이제 마감에 잘린 읽기는 결과로 치지 않습니다.

대기 시간을 늘리거나 재시도를 더하지 않았습니다.
with-hide/hide-private#274(doorbell 두 테스트)는 재현되지 않아 범위에서 뺐고, 원인 후보와 증거를
이슈에 남겼습니다.

스크린샷 없음: 화면을 바꾸지 않는 core와 테스트 변경입니다.

## Review

**제품 동작이 바뀌는 곳** (둘 다 수정 없이 실패하는 테스트로 증명, Evidence 참고):

1. `herdr-core/src/worktree_cleanup.rs` `WorkerGuard`, `worker_ended` -
정리 worker가 마지막 snapshot 전달과 lane 해제를 한 lock 안에서 합니다(전에는 lock 두 번).
`runtime/projects.rs` `confirm_cleanup`은 lane이 잡혀 있으면 확인을 거절하는데, 검토 답과
lane 해제 사이에 온 확인이 여기서 버려졌습니다(#152의 CI 로그: 10초 동안 제거 진단이 하나도 없음).
- `Mutex<Runtime>` 아래 일: 늘지 않았습니다. 같은 `ingest_cleanup`과
`cleanup_worker_finished`(필드 하나를 `None`으로)를 두 번의 lock 대신 한 번의 lock에서
합니다. 새 I/O, subprocess, 직렬화는 없고 `notify`는 전처럼 lock 밖입니다.
`scripts/check-capability-readers-off-lock.sh` 통과.
- 판단해 주세요: lane 해제가 마지막 답과 묶였으므로 `confirm_cleanup`의
`cleanup_worker.is_some()` 거절은 이제 "검토가 아직 loading 중"일 때만 걸립니다. 그 주석을
고쳤습니다.
2. `herdr-core/src/runtime/terminal_input.rs` `wait_with` - 셸 대기의 반복이
시계와 한 번의 읽기를 받아 돌고, 마감에 걸쳐 끝난 읽기(결과가 무엇이든)는 결과로 치지 않아 마지막으로 끝난 읽기의 결과가
남습니다. `shell_reads_keys`는 main과 같습니다. 결과는 `terminal.input_shell_wait`
진단의 `outcome`/`reason`에만 쓰이고, 키는 어느 경우든 그대로 써집니다.

다음 둘은 지시서에 제품 변경 후보로 적혔지만 **테스트 fixture만** 바뀝니다: #218/#213의 held
link(`runtime/tests/inbound.rs`), #227/#319의 연결
전환(`runtime/tests/links.rs`).

**조심해서 볼 파일**:
- `runtime/tests/inbound.rs` - held link의 Herdr가 link가 풀릴 때까지
`connect`에서 기다립니다(전에는 없는 socket이라 즉시 거절). 그 거절을 node session sync가 받아
테스트가 연결해 둔 node를 끊긴 상태로 덮었습니다. link를 쓰는 모든 테스트(inbound,
hide_ai_devices)가 통과하지만, 끝까지 release를 쥔 테스트가 있으면 멈출 수 있는 구조라 봐 주세요. 이전의
10초 자동 종료(`recv_timeout`)는 없앴습니다.
- `runtime/tests/node_issues.rs` - 확인을 검토 답의 announcement 안에서
누릅니다(`ChangeNotifier::announcing`). 콜백 안의 panic은 삼켜지므로 값을 모아 밖에서
assert합니다.
- `suggestions/worker.rs` `handled` - 실행 중인 run이 없는 pen 명령의 거절 답을
barrier로 씁니다. 상태를 바꾸지 않는 명령이라 골랐습니다.
- `docs/TESTING.md` - The test decides the order와 Wait for state에 규칙 네
줄을 더했습니다.

<details><summary>이슈별 원인과 처리 (main 8a865d8 기준)</summary>

| 이슈 | 테스트 | 원인 | 처리 |
| --- | --- | --- | --- |
| #153, #148 | `runtime::delivery::tests::moved_terminal_keeps_…`,
`remote_observation_without_a_local_socket_…` | `Worker::spawn`이
doorbell/watch producer를 띄워 자기 시계로 pass를 돌림. watch tick이 fixture의 옮겨진
child를 못 읽고 폴더가 없다고 보면 watch를 끝냄(`watches.len()` 0, `watches[0]` index),
store가 쓰는 중에 테스트가 파일을 읽음(`ledger_unavailable`, 로컬 재현) | #1812와 같은 규칙: 이
파일의 테스트 12개를 `Worker::store`로, 파일을 읽기 전에 store를 멈춤 |
| #152 | `node_issues::a_node_s_merged_worktree_is_removed_…` | 제품: 위 1번
| worker 마지막 답과 lane 해제를 한 lock에서. 테스트는 가장 이른 순간에 확인 |
| #218 |
`inbound::a_node_pane_s_hide_memory_reads_for_the_node_s_session` | node
session sync의 `socket_missing` 답이 테스트가 넣은 session 뒤에 도착해 node를 끊김으로
바꿈(`pane_not_connected`, 실패 0.04초) | held link의 Herdr가 link 동안 답하지 않음 |
| #213 | `inbound::a_moved_core_reads_its_own_kit_…` | 같은 원인 + kit 작업이
대기열에 남은 채 dispatch하면 node는 `checking`이 되지 않음, dispatch 뒤 lock을 놓은 사이 답이
끝날 수 있음 | 대기열까지 비기를 기다리고, dispatch와 확인을 한 lock에서 |
| #227, #319 | `links::a_native_fork_keeps_state_changes_…` (#227의 새 이름이
#319) | "다음 connect에 전환" arm을 fork worker 옆의 control lane(focus)이 가져가면,
전환이 fork worker의 확인 뒤에 적용되어 `pane.get`이 옛 서버로 감 | 전환을 fork worker 자신의
thread connect에서만(같은 fixture의 archive 테스트도) |
| #246 | `ssh_hosts_list::the_host_list_names_each_alias_…` | dispatch 뒤
lock을 놓은 사이 fake 답이 끝나 `loading`을 못 봄 | dispatch와 확인을 한 lock에서 |
| #126 |
`suggestions::worker::tests::a_weak_line_waits_fourteen_quiet_days_…` |
fixture의 barrier read가 전날의 남은 read일 수 있음. 그러면 clock이 `Wake` 처리 전에 움직여
run이 실제 3분 뒤로 밀리고 10초 대기가 끝남(로컬 재현) | 응답 채널이 있는 명령으로 barrier(`handled`)
|
| #159 | `memory_analysis::tests::a_linked_node_s_closed_session_…` |
테스트가 Memory hook의 1초 제품 예산 안에서 읽음, 부하에서 답이 비었음(로컬 37%) | hook 답 대신
scope가 가리키는 Project를 직접 확인. hook 답은 `memory_hook` 테스트의 몫이고 뒤의 receipt
확인은 hook과 무관해 그대로 |
| #186 | `terminal_input::tests::a_terminal_that_is_never_read_…` | 제품:
위 2번 | 잘린 읽기는 결과가 아님. 두 테스트(기존 것과 잘림 규칙 새 것)는 테스트가 움직이는 시계와 정해 둔 읽기로 돌아
socket과 벽시계에 기대지 않음, bound 150ms 그대로 |
| #274 | doorbell 두 테스트 | 재현 안 됨(fixture는 10-09부터 store만 띄움, 실패 둘 다
store의 5초 답 기한) | 범위 제외, 이슈에 증거 코멘트 |

</details>

## Evidence

- **확인한 것 (수정 전 재현)**: main 코드 테스트 바이너리로 12개 테스트를 각 200회, 24개 병렬, load
average 31-38에서 돌림: #159 74/200, #148 1/200(`ledger_unavailable`), #186
1/200, #126 1/200(`a read: Timeout`), 나머지 0/200.
- **확인한 것 (수정 후)**: 같은 조건(각 200회, 24병렬, load 27-42)에서 수정 후 바이너리로 12개
테스트와 새 잘림 테스트를 돌림: 2,600회 실패 0.
- **확인한 것 (수정 없이 실패)**: #152 - `worktree_cleanup.rs`와 `projects.rs`만
main으로 되돌리면 새 순서의 node 테스트가 5/5 `a confirmation pressed on the answer is
taken`으로 실패. #186 - 반복의 잘림 분기 한 줄만 지우면
`a_read_the_bound_cuts_short_leaves_the_last_failure_as_the_reason`이
`Timeout`(기대 `Unreadable("link down")`)으로 실패.
- **확인한 것 (#186 재수정 뒤)**: 두 셸 대기 테스트 각 200회, 24병렬, load 25-29: 실패 0.
- **확인한 것 (CI)**: verify run 40823301322(head 808270c) 성공, rust
workspace Linux를 포함한 모든 lane에서 재시도로 통과한 테스트 없음.
- **확인한 것**: 로컬 `verify-cargo.sh nextest -p herdr-core --retries 0`
3437/3437 통과.
- **확인한 것**: 바뀐 모듈 295개 테스트 통과, `verify-cargo.sh clippy -p herdr-core
--all-targets -D warnings`, `fmt-check`,
`check-capability-readers-off-lock.sh` 통과.
- **확인하지 못한 것**: #218, #213, #227/#319, #246, #153, #152는 로컬 부하 200회에서
수정 전에도 재현되지 않았습니다(CI Linux에서만 기록). 원인은 CI 로그(실패 시각, 진단 순서)와 코드로 정했고,
Linux 반복은 이 PR의 CI 실행으로만 봅니다. 이 맥은 Linux 호스트가 없고 디스크 여유가 3-9 GB입니다.

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

- base: main 8a865d8, head: ae7f390 (CI verify run 40826129061
success, no test passed only on retry)
- before binary: main 8a865d8, after binary: 커밋 전 작업 트리(포맷만 다름)
- load repeat: `repeat.sh <bin> <tests> 200 24`, 테스트 하나당 프로세스 하나, macOS
arm64
- CI #152 로그: run 40817735918 job 123262761058, TRY 1 FAIL 11.029s,
`worktree.*` 진단 없음
- CI #218 run 40675696797, #213 run 40485064142: TRY 1 FAIL
0.040s/0.034s, 패닉 직전 `remote.session_unavailable socket_missing`

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