Repository navigation
OS 경계 4: 폴더 감시와 계정 위치를 hide-platform으로 옮기고 Windows에서 워크스페이스를 빌드합니다 - #325
Merged
Merged
Conversation
…instead of dropping it hide-platform::watch watches folders and puts each changed path on one bounded queue, once however often the system reported it. A read is not a change on any system (inotify's access events are dropped there, not in each caller), FSEvents' real paths come back under the spelling the caller watched, and when more paths wait than the queue holds, or the system's own queue overflowed, the waiting paths give way to one Overflow change. Windows is watched with ReadDirectoryChangesW in the module, because notify drops the empty answer Windows gives on a buffer overflow and stops watching on ERROR_NOTIFY_ENUM_DIR. The core's Git watcher drains the queue on each coordinator wake instead of taking two locks in notify's callback, and an overflow now marks every watched project for a re-read with a git_watch.overflow diagnostic, where an inotify overflow used to be ignored.
hide_platform::host names the home and state folders, Herdr's default socket, programs on the login PATH, the default shell, the Trash, the Tailscale CLI, the machine's name and its stable id, each per system, and answers Unsupported or NotFound rather than a guessed default. The Windows lock folder now comes from the state folder, and the document move to the Trash in hide-host goes through host::trash. The default socket is checked against what the pinned Herdr itself reports.
fs::space answers what an entry takes on its volume (allocated bytes, links, identity, whether it is a folder) without following a link, and how much the volume has left. private::open_own_file opens a file only when the name itself is the account's own regular file, and fs::open_regular opens a regular file without following a link or blocking on a pipe. identity::Stamp tells whether a file changed between two looks, by length, write time and change time.
The trace stamped a key's write against a client clock (CLOCK_UPTIME_RAW on macOS) and published the interval on a terminal chunk. Only the removed native shell sent `input_trace`, and nothing reads `input_sent`, so the core kept a Unix clock call and a snapshot field for nobody.
Disk usage, free space, the label store and generator lock, attachment reads and package modes now go through hide-platform. The test fake Herdr and the session tests listen on the platform's local stream, link fixtures are made through fs::link, and tests that stand on mode bits or shell scripts are marked Unix. The SSH agent is reached over a named pipe on Windows. PaneIdentity and pane inspection move from the Unix-only workspace bridge to hide_host::pane_peer, so the helper's pane-inspect command builds everywhere. A package read where files have no mode bits is refused rather than installed with a guessed mode.
…n open file's path host gains `_from` forms of the home, state folder and Herdr default socket resolutions, so a crate that reads its environment through its own registry hands those values in, and VARIABLES lists what host reads. private::create_dir_all makes each missing folder private. identity::path_of answers the path an open file or folder is at now on each system, and the Windows path lookup no longer mistakes a just-too-small buffer for a path.
…layer The home key is USERPROFILE on Windows, hcoord is found under the home host answers, and the install kit's fallback socket follows Herdr's own config order for the core's home instead of assuming ~/.config/herdr.
The daemon's state, lock, host id, attachment staging, phone store and pane capability files are private through hide-platform; the state file is now replaced whole. Root and watched-folder identity and the path of an open root come from hide-platform instead of three hand-written copies. The host name, machine id and Tailscale CLI location come from host, PATH lookups use host::find_program, and the default Herdr socket follows Herdr's own config order, so XDG_CONFIG_HOME is honoured. A stop request on Windows is Ctrl+C, Ctrl+Break or the console closing. The pane bootstrap still stands on a Unix socket: on Windows bind answers that it is not available until the named-pipe listener holds under connect-and-drop (#315), so the daemon refuses to start there, and the daemon end-to-end tests are Unix-only for the same reason.
…atform layer hide-ai keeps its settings in the state folder the system keeps under the home (host::state_dir_under), makes the private Codex home and its auth link through fs::private and fs::link, and finds a CLI with host::find_program. hide-memory makes its database private on every system rather than only on Unix. hide-agent-hooks reads the home from host, reports to Herdr's default socket in Herdr's own order, and finds the agent CLIs it diagnoses with host::find_program.
… are reported Watcher::keeping takes a filter on the path relative to the watched folder, applied in each backend before the queue. The Git watch keeps only Git's facts, as the notify callback did before, so the objects a fetch or a gc writes neither fill the queue nor overflow it into a re-read of every watched project. A waiting reader is woken only when the queue stops being empty.
FileRoots asked for a device and inode only on Unix and pinned nothing on Windows; it now takes the identity hide_host::root::identity_of reads through the platform layer, the same one the host compares against.
inotify and Windows can overflow their own queues on an unpaced burst, which no filter prevents and which the contract already reports as an overflow.
A submodule's Git folder lies inside its repository's, and the first folder that held a path decided alone, so the outer filter dropped the submodule's ref changes on macOS and Linux.
A hard link another account plants beside the Herdr socket passes the owner and regular-file checks and would have its target truncated by the label generator's lock; open_own_file now requires a single name.
Shortening the Windows prefix only for paths that fit the classic limit made a deep file's path stop starting with its root's, so hided's root boundary would refuse it; both now keep the prefix and compare by it.
The Recycle Bin names an item by its shell display name, which drops an extension Explorer knows under its default view, so the test's .txt file was trashed but never found there.
The Home spec once read a pane cwd of the fixture's temporary folder on Linux, and nothing kept the evidence. On a failure it now writes Herdr's pane records (the cwd, which an OSC 7 report sets, and the /proc foreground cwd), the shell's own /proc cwd on Linux, each pane's foreground processes and visible text, and where Hide's path back landed, as an attachment beside the test's results. What the test asserts is unchanged.
yansfil
force-pushed
the
platform/watch-host
branch
from
October 3, 2026 05:15
41cdaad to
e8bf88e
Compare
yansfil
added a commit
that referenced
this pull request
Oct 30, 2026
…and journey flakes (#1869) Closes with-hide/hide-private#340 Closes with-hide/hide-private#325 Closes with-hide/hide-private#311 ## Summary Five desktop/journey flakes, each handled at its cause; one was a product defect. - **#311 (product fix)**: a new worktree's tab was focused before the catalog listed its pane, so the worktree came forward only sometimes. It now waits for the catalog, as an agent start already did (the contract `docs/ARCHITECTURE.md` already stated), and comes forward only while the operator has visited nothing else since, within 90 seconds and on the same Herdr connection. The page no longer sends its own focus for a worktree made on this machine (New worktree, the start panel, Start from an issue, a pull request's 맡기기): it only shows what the core selected, by the start's request id, so a visit made while the worktree was being created is kept. A worktree made on a device is still opened from the page once that device lists it. The spec also waits for the project's first pane before removing it. - **#340**: the test restarted Herdr as soon as Hide drew the agent asleep, before Herdr dropped the agent from its own list, so the cold restore listed it again. It now waits for Herdr's list. - **#325**: "Back to Hide" closes its own window, so Playwright's click could throw "Target page, context or browser has been closed" although the close was the outcome. A shared helper (`web/e2e/closing-click.ts`) keeps Playwright's real pointer click, accepts that one error only, and then waits for the page to close; the two practice.spec clicks with the same shape use it too. - **#322, #309 (cause not found, issues stay open)**: a failure now keeps what was missing. #322 keeps the woken pane's screen, processes and Herdr agent; #309 keeps the screen and Herdr's reading at each activity change of a failed journey turn. 스크린샷 없음: nothing is drawn differently; what changes is whether a created worktree is brought forward after the operator moved elsewhere. ## Review - **판단해 주세요**: #311 now brings a new worktree on this machine forward only under the start's conditions (no newer visit, 90 s, same connection), written in `docs/UI_BEHAVIOR.md`, Start panel. Before, it came forward only when the catalog already listed it, and the page could also pull it forward late over a newer visit. Say if staying behind was wanted. - **조심해서 볼 파일**: - `herdr-core/src/runtime/session.rs`, `group_starts.rs` - Herdr/core focus ownership: `worktree_create` now holds the start focus permission, so a visit made during creation cancels the follow (90 s bound, generation check), as for agent starts. - `herdr-core/src/runtime/pull_requests.rs`, `projects.rs`, `events.rs` - `pr_delegate` takes an optional `request_id`, carried to the agent start or the worktree start and onto its answer. - `web/src/actions.ts` (`createWorktree`, `delegatePullRequest`), `web/src/opening.ts` (`followStartedPane`) - the page sends a start request id and begins the opening for a start on this machine; only a device's pane is still opened from `WorkspaceNotices`. - `web/e2e/closing-click.ts` - a real `locator.click()`; only the page-closed error is tolerated, and only because the close is awaited next. - `scripts/agent_journey/journey.py` - the #309 trace is collected on every turn, not only failed ones: per activity change one `agent list` and one `pane read`, at most 8 moments (16 CLI calls, each with the existing 15 s bound) per turn; it is written to the result only for a turn that did not pass. - **질문**: #322 and #309 stay open with diagnostics only. Should their seven-day expiry move, or should they be deleted if they flake again without a cause? ## Evidence - **확인한 것**: - #311 reproduced locally before the fix, 1 of 5 then 1 of 10 runs; the dump showed the core's front checkout was the new worktree on the failing run and the main checkout on passing runs (`start.focus_disposition` with `local_checkout_owner` set vs null). - New Rust test `a_local_worktree_result_waits_for_its_catalog_before_it_comes_forward` failed before the fix (front checkout stayed main) and passes after. - New web test `createdWorktreeFollow.test.tsx` drives New worktree on the screen path: create, a newer visit, then the late listing; no `focus_pane` for the new pane is sent. With the page's old open-when-listed restored it fails (`expected 'pane-next' to be null`). It also checks that a device's worktree is still opened through `remote_control` once listed, and that 맡기기 sends a request id only on this machine. - `a_node_pull_request_with_no_checkout_gets_its_worktree_on_the_node` now also checks the request id reaches the answer; it failed until the worktree start stamped it. - herdr-core related lib tests (pull_request, node_issues, worktree, group_tabs_remote, start_focus, task_operation, group_start): 351 pass; clippy on herdr-core clean. - Whole web unit suite: 2286 pass; web typecheck and lint pass. - `practice.spec.ts` whole file 27/27 (3 runs) and desktop `first-run.spec.ts` "practice first" 5/5 with the pointer-click helper (macOS, under load). - `closing-click.ts` against a throwaway page: passes on a plain button that closes its page, fails on the same button under a transparent cover and with `pointer-events: none` (3 runs each). The previous synthetic-click helper passed both covered cases. - Earlier on this branch: `outside-home-project.spec.ts` 10/10, `herdr-coexistence.spec.ts` cold restoration 5/5, `sleep-wake-click.spec.ts` 5/5 locally (macOS). - #340 cause read from the CI failure: `herdr-coexistence.spec.ts:106` (`agent list` still had the sleeper after cold restore). - #325 cause read from CI: the click's call log ends at "performing click action" with "Target page, context or browser has been closed"; `leave()` runs `window.close()` (`web/src/practice/PracticeApp.tsx:58`). - #309: three occurrences, all macOS antigravity fork; the row went `stopped` -> `working` about 1.1 s after the prompt and stayed `working` past 180 s while the model had answered. `/fork` itself worked (pane shows "Forked conversation."), so the late-terminal-response lead does not fit. The trace does not record the final screen after the row is stuck on one activity, so it is a diagnostic, not a fix. - **확인하지 못한 것**: - #340's lag (Herdr dropping the agent after Hide draws it asleep) is inferred from the failing assertion and the passing majority, not timed directly. - #325 and #340 were never reproduced locally, so the local passes only show the new code holds; the old race is not shown gone. - The #311 page change was not checked in the native app; the screen path is covered by the web unit test and the e2e spec. - Linux and Windows are left to CI. - Not run locally: the full web and desktop e2e suites, the journey lane, clippy beyond herdr-core; CI runs them. - `docs/ARCHITECTURE.md` (about 960 KB) was read only in the start focus, sleep and worktree sections, not in full. <details><summary>Verification record</summary> </details>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs with-hide/hide-private#103
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로 알리며, 그때는 진단 하나를 남기고 감시 중인 프로젝트를 다시 읽습니다.화면 변경은 없습니다.
Review
watch(dir) -> Receiver<Change>대신Watcher(watch/unwatch) + 큐 하나로 만들었습니다. Git 감시는 루트 최대 64개를 감시자 하나로 보기 때문입니다.Unsupported를 답하기 때문이고, 데몬 e2e(handshake.rs,mobile.rs)도 그래서 Unix 전용입니다.input_trace/input_sent)를 지웠습니다. snapshot wire에서 필드 하나가 빠지지만 읽는 쪽이 없습니다.~/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(hide가 가진 파일을 ~/.hide 아래로 모으고 hcoord를 hide 전용으로 만듭니다 #319)의~/.hide/state그대로입니다.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(UnixDirBuilder0700, 새로 만드는~/.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
verify-cargo.sh lint,verify-cargo.sh test(테스트 바이너리 54개)와 check 스크립트 7개,scripts/tests32개가 통과했습니다.cargo check와clippy --workspace --all-targets -D warnings가 모두 깨끗했습니다. C 빌드 스크립트는 가짜 컴파일러로 넘겼으므로 링크는 CI가 증명합니다.watch계약 테스트 8개가 macOS에서 통과했습니다. 생성·쓰기·이름 바꾸기·삭제가 2초 안에 오고, 읽기는 변화가 아니며, 1만 개 burst는 4097개 이하로 끝나고 Overflow를 냅니다. 필터와 중첩 폴더도 확인했습니다.status server --json과 비교했습니다(real_herdr.rs, 빈 임시 HOME).14.5ms, 새 경로 14.015.6ms입니다. tick에 도착한 것은 이전 콜백 약 3,100회 대 새 경로 69개입니다. Git 재읽기는 둘 다 1회입니다..git/objects에 1만 개 burst: CPU가 이전 4854ms, 새 경로 4354ms이고 넘침은 0입니다.Watcher::keeping을 넣었습니다(커밋 41297cd).path_of접두사, 하드 링크, kit 기본 소켓입니다. 남은 하나("Windows 빌드 미확인")는 CIwindows check의cargo check --workspace --all-targets결과(outcome: success)로 답했습니다. 이 job은 그 단계가continue-on-error라서 job 색이 아니라 로그의 outcome 줄이 근거입니다.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 --ignored2개도 양쪽에서 통과했습니다. Windows 감시 백엔드(ReadDirectoryChangesW)는 이 run에서 처음 실행됐습니다.a_trashed_file_leaves_its_folder_for_the_trash하나가 실패했습니다. 파일은 휴지통에 들어갔지만, 휴지통이 Explorer 기본 보기대로.txt를 뗀 표시 이름으로 항목을 보여 줘서 테스트가 찾지 못했습니다. 테스트 파일 이름에서 확장자를 뺐습니다(41cdaad).desktop e2e는 통과했습니다.cargo fmt --all --check,verify-cargo.sh lint,verify-cargo.sh test(테스트 바이너리 54개), check 스크립트 7개와scripts/tests,weblint가 모두 통과했습니다. Windows 교차 컴파일은 로컬에서 다시 하지 못했습니다. 이 push의 CIwindows check가 그 증거가 됩니다.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 보고가 원인입니다.labels::tests::a_second_daemon_on_the_same_server_stands_by_and_shows_no_labels가 로컬 전체 실행 7회 중 1회 실패했습니다(단독 재실행과 이후 6회는 통과). lock 의미는 같으므로(flock그대로) 기존 경합으로 보지만 원인은 확인하지 못했습니다.남은 OS 코드와 후속 작업
hide-host의 FIFO 막는O_NONBLOCKopen과list.rs의readlinkat,hide-sessionboundary.rs의 루트 open(openat/ final-path 확인), WindowsShellExecuteWopener,lib.rs의 종료 신호is_private의 handle 기반 판정create_dir_all이 만든 상위 폴더도 private가 되는 점hide-agent-hooks/src/memory.rs의Library/Application Support경로와 코어의 상태 폴더 불일치 확인