Repository navigation
Recover Herdr and delegation lineage after a reboot - #257
Merged
Merged
Conversation
Herdr drops pane tokens when its server restarts, and after a reboot the hcoord daemon can start minutes before Herdr, so its startup-only repair failed for every child and left them roots. The daemon now reads each route holding a child with one pane list on a timer (5 s local, 60 s remote) and writes the tokens only to a live child that lost them.
After a reboot nothing starts Herdr, and hided only reads a missing server as absent, so the app opened to an empty shell. Before each connect the packaged host asks its bundled herdr for the server status and starts herdr server detached when none is running, with a UTF-8 character type when Finder gave it no locale. A server that answers is never touched, and development or override runs start nothing.
The start decision moves into ensureServer so its branches are tested without Electron: a running server is left alone, an unreadable status starts nothing, one start is made and waited for. The CLI and daemon paragraph no longer says nothing starts a server, and the token doc says a sessionless child is not linked again after a restart.
Herdr sets its own binary path and pane identity in every pane, so the server the app starts no longer inherits the host's copies of them. A status poll during the start wait may only use what is left of the wait, so a hung call cannot hold up the connect.
Merged
yansfil
added a commit
that referenced
this pull request
Sep 29, 2026
Related: PRD `agents/prd/device-parity/prd.md` · follows #257 (bundled Herdr server start) and meets #255 (subtree close) ## Summary - 지금까지 hide CLI 링크, Claude Code·Codex hook, 라벨 플러그인, hcoord는 기계마다 따로 맞춰야 했고 SSH 기기는 helper만 받았다. - 이제 설치 kit 하나(`hide-kit`)가 같은 구성요소를 이 Mac에는 설치된 앱의 첫 실행에, 각 기기에는 연결 때 묻지 않고 설치한다. - 업데이트, 운영자가 지운 구성요소(다시 설치 전까지 그대로), 기기 삭제(hcoord만 남김)가 이 Mac과 기기에서 같은 규칙이다. - Settings > Devices는 기계마다 구성요소별 상태와 위치를 보이고, 문제가 있는 행에만 Reinstall이 있다. Agents 탭은 기계별 hook 행을 보인다. - 기기의 agent pane은 로컬과 같은 함수로 계측을 판정한다(그 pane의 hook token과 그 기기의 kit). 기기 Memory는 범위 밖이다.  ## Review - **이번 머지의 동작**: 이 Mac의 kit는 실행 중인 앱 번들을 원본으로 쓴다. `/Applications` 위치 제한은 별도 보안 검토 대상으로 남긴다. - **이번 머지의 동작**: 같은 계정에 다른 기기 등록이 있으면 kit를 유지하고 확인창에 이유를 표시한다. 마지막 등록을 지울 때 제거한다. - **기존 결정 D-13**: 계약 2로 허용한 기기는 다음 연결에 kit 전체를 받는다. 과거 동의 문구에는 hook과 설정 변경이 없었다는 점은 Breaking change에 명시했다. - **남은 제약**: 두 Mac이 같은 기기 계정에 kit를 적용하면 마지막으로 실행한 kit가 hook과 링크를 소유한다. 계정 lock은 동시 쓰기만 막는다. - **조심해서 볼 파일**: `hide-kit/src/lib.rs` - 운영자 설정 파일과 LaunchAgent를 바꾸는 유일한 경로(계정 lock, private 폴더). - **조심해서 볼 파일**: `hide-agent-hooks/src/install.rs` - 운영자 설정 파일 쓰기의 failure path(mode와 symlink 보존, 임시 파일). - **조심해서 볼 파일**: `herdr-core/src/runtime/kit.rs` - runtime mutex 밖 worker, 늦은 응답, 기기 삭제 순서와 helper 연결 종료. - **조심해서 볼 파일**: `herdr-core/src/remote/host.rs` - 한 계정에 두 연결이 동시에 올리는 경합과 private 폴더. - **조심해서 볼 파일**: `herdr-core/src/runtime/device_catalog.rs` - regroup마다 lineage pass를 다시 돈다(#255와 만나는 곳, mutex 안의 일). - **조심해서 볼 파일**: `desktop/src/main/host.ts` - hcoord 준비 제거(kit 소유), 창은 status page 로드가 끝난 뒤에 shell을 연다. - **조심해서 볼 파일**: `herdr-core/src/model.rs`, `contracts/snapshot-wire-enums.json` - snapshot wire의 `DeviceSnapshot.kit`. ## Evidence - **확인한 것**: 격리 sshd(비루트, 세션마다 private HOME과 HCOORD_HOME)로 실제 SSH 연결: 연결 한 번에 다섯 구성요소가 설치됐다. - **확인한 것**: 같은 연결에서 다른 도구의 hook과 설정 키가 그대로였고, 기기 pane의 설치된 SessionStart hook이 Workspace 안내를 내고 Memory capsule은 없었다. - **확인한 것**: 운영자가 지운 Claude hook은 '지워짐'으로 남았다가 Reinstall이 그것만 되살렸고, 삭제는 설정 파일을 원래 바이트로 돌리고 hcoord를 남겼다. - **확인한 것**: 한 계정의 두 등록이 동시에 연결해 둘 다 설치됐고, 첫 삭제는 kit를 남기고(`device.kit_left`) 마지막 삭제가 걷어냈다. - **확인한 것**: 패키지된 hide.app의 hided를 private HOME으로 실행하면 첫 실행에 다섯 개를 설치하고, 두 번째 실행은 설정 파일 mtime을 바꾸지 않았다(3회 반복). - **확인한 것**: 전체 desktop e2e 26/26(merge 뒤), device-kit과 remote-workspace 3/3(검증 head), cargo test와 lint, verify-web, scripts, design contract 통과. - **확인한 것**: 모든 실행에서 운영자의 hcoord daemon pid가 그대로였고, 실제 `~/.claude`, `~/.codex`, `~/.local/bin`, `~/.hcoord`, `/Applications/hide.app`은 건드리지 않았다. - **확인하지 못한 것**: mini가 계약 2 동의에서 kit로 올라가는 실제 연결(merge와 설치 뒤에 일어난다, 코어 테스트만 있다). - **확인하지 못한 것**: Linux 기기(단위 테스트만, hcoord는 macOS에서만 설치), GitHub로 설치된 라벨 플러그인을 넘겨받는 경로(가짜 socket 단위 테스트만). - **확인하지 못한 것**: 재부팅 뒤 hcoord daemon이 kit 첫 pass에서 올라오는 순서(#257과 만나는 곳), `/Applications` 설치본 교체(운영자 소유라 하지 않았다). - **확인하지 못한 것**: `github::tests`의 1초 deadline 테스트가 부하(load 9~13)에서 네 번 실패했다. 이 브랜치가 건드리지 않은 모듈이고 단독 실행은 통과했다. <details><summary>추가 증거</summary>    - 창 navigation 경합: status page 로드 10~30 ms 뒤에 shell을 열면 Electron 44가 빈 code로 실패를 보고했다(20번 중 8번, 3번). 창은 shell에 도착했지만 Playwright가 멈췄다. 지금은 한 번에 하나만 연다. - 공유 머신 부하에서 remote-workspace의 hook 65회 반복 검사가 한 번 16번째에서 멈췄고, 단독 재실행은 통과했다(이 브랜치는 hook 버전 문자열만 바꿨다). </details> ## Breaking change - 설치된 앱은 실행마다 운영자 홈의 kit를 맞춘다. 전에 한 번 쓰던 hook(이제 v6)과 hcoord에 더해 `~/.local/bin/hide` 링크, Herdr 플러그인 `hide.agent-context-labels`, `~/.hide/kit/`가 새로 생긴다. - 예전 `~/.hide/agent-hooks/installed-once` 표시는 설치 기록으로 보지 않아서, Hide hook이 없는 기계는 다음 실행에 hook을 받는다. - 같은 id로 GitHub에서 설치했거나 checkout에서 link한 라벨 플러그인은 kit 복사본으로 바뀐다(플러그인 config는 남는다). - 동의가 있는 기기(계약 2 포함)는 다음 연결에 같은 kit를 받는다. helper protocol은 10이고 helper는 연결 때 스스로 바뀐다. - 이 Mac의 kit를 한 번에 걷어내는 명령은 없다. 운영자가 지운 구성요소는 다시 설치하기 전까지 그대로 둔다. **AI tooling**: 대부분 AI 도구. 사람이 손으로 대조한 것은 아직 없고, 이 PR의 리뷰가 그 대조다. <details><summary>Verification record</summary> - PRD: `agents/prd/device-parity/prd.md` (sha256 f197c2cdf41e26a237da0d79a195e42f15cc67d6df57eed17cd63789b3d9a294) - Base efb51d1 → head 755839b, verified 2026-09-29T10:00:10.099Z: PASS - Verification report: `agents/runs/device-parity/verification-report.json` and `agents/runs/device-parity/verification-report.md`; source fingerprint 9e6c848822e7523665bf50ded685362f4e9d9c8df0e12c639c228a52a4e91239 - Suites: - S1: GREEN `bash scripts/verify-cargo.sh test` (exit 0) - S2: GREEN `bash scripts/verify-cargo.sh lint` (exit 0) - Reviews: advisory, native subagents, six feature review sets through f3fac04, plus Fidelity, Code and Security follow-up reviews on verified merge head 755839b; no new actionable findings. - Fidelity (afe113d): Fix now 1, removing one of two registrations of one account kept the kit, a B23/D-16 departure; kept as a recorded deviation with tests and e2e. Fix now 2, an unread device kit judged hooks not installed; fixed 9a636c6, 749e095. Later heads: none. - Code (afe113d): Fix now 1 unread kit judged not installed, fixed 9a636c6/749e0959; 2 concurrent uploads of one account, fixed 6069955, 17108b0, 91354b0; 3 a late answer brought back a removed device, fixed 749e095; 4 hcoord failed on Linux, fixed f5155fb. 5382042: Fix now 1, a regrouped device session dropped its agents' lineage that #255's subtree close waits on, fixed f3fac04 with a regression test. Other heads: none. - Security (afe113d): Fix now 1 hook file mode and symlink replaced, fixed 0496815; 2 this Mac's kit runs from any app bundle, left for human judgment (see Review); 3 kit folders not private, fixed 68f8bc9. Later heads: none. - Follow-ups (not in this PR): a lineage pass on every device regroup even when nothing regrouped; a bounded status page wait; `.upload-*` leftovers after a crash; contract-2 carry with an unbound identity; hcoord shim ownership marker; relative PATH candidates; labels dev-link undo; `process.rs` kill/join order; digest-only reuse and payload caps before read; Herdr-down retry of labels; corrupt record healing; a lost Reinstall not requeued; blocked rows offering Reinstall; removal dialog default focus; two Macs sharing one device account; the `github::tests` 1 s deadlines under load. - Evidence: 7 registered (4 screenshot, 3 log); paths are local to the run directory - agents/runs/device-parity/evidence/this-mac-kit.png - agents/runs/device-parity/evidence/agents-hooks-per-machine.png - agents/runs/device-parity/evidence/device-kit-removed-part.png - agents/runs/device-parity/evidence/device-remove-confirm.png - agents/runs/device-parity/evidence/e2e-desktop-all-0ac13a23.log - agents/runs/device-parity/evidence/device-kit-daemon.jsonl - agents/runs/device-parity/evidence/device-kit-two-registrations-daemon.jsonl - Changed paths: 172 (see Files changed) </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.
Summary
재부팅 후 앱이 Herdr 없이 떴습니다.
Herdr 서버를 켜는 곳이 없었고, hided는 남은
herdr.sock에 연결 거부를 반복했습니다.위임 계보도 사라졌습니다.
Herdr는 서버를 재시작하면 pane 토큰을 복원하지 않습니다.
hcoord는 데몬 시작 때 한 번만 토큰을 다시 썼는데, 그 시점에는 Herdr가 아직 없었습니다.
hide connect전에 번들herdr status server --json으로 확인합니다.running:false일 때만herdr server를 분리 실행하고, 최대 5초 동안 응답을 기다립니다.not_running으로 답합니다.HERDR_BIN_PATH를 명시한 실행은 서버를 켜지 않습니다.pane list를 한 번 호출합니다. 이 Mac은 5초, 원격은 60초 간격입니다.LC_CTYPE=UTF-8을 줍니다. 이 값이 없으면 zsh가 "한글"을 6바이트로 셉니다.Review
herdr pane list12번입니다.desktop/src/main/spawn.tsstartDetached.herdr가 띄운 서버처럼, 일부러 앱보다 오래 삽니다.desktop/src/main/host.tsensureHerdrServer.plugins/hcoord/src/hcoord/transport.tsreconcileLineage.Evidence
env -i로 격리해 실행했습니다.herdr.server_started가 기록됐고, hided가 붙었습니다.LC_CTYPE=UTF-8이 있었고, 서버는 자기 프로세스 그룹에서 돌았습니다.claude --resume <id>로 resume됐고, 창에 복원된 프로젝트와 에이전트가 보였습니다.herdr server를 띄워 봤습니다.HERDR_PANE_ID와 없는HERDR_BIN_PATH를 넣었습니다.HERDR_SOCKET_PATH와LC_CTYPE=UTF-8만 남았습니다.bash scripts/verify-web.sh가 통과했습니다. hcoord unit 30, hcoord e2e 27, web 515, desktop 60개입니다.check-no-workstation-identity,check-harness-ignore-anchor,check-agent-asset-committed,check-herdr-pin-single-source,check-no-attribution이 통과했습니다.pnpm --dir desktop e2e와pnpm --dir web e2e는 로컬에서 돌리지 않았습니다. CI가 돌립니다.추가 증거
2026-09-29 재부팅 직후 운영 머신에서 본 것:
리뷰 처리
ensureServer로 분리하고 분기마다 테스트했습니다.HERDR_BIN_PATH, pane·tab·workspace id,HERDR_ENV)을 뺐습니다.statusexit code 미확인":not_running도 exit 0이고, 격리 실행에서 실제로 서버가 켜졌습니다.AI tooling: 대부분 AI 도구. 원인은 로그와 격리 실행으로 손으로 대조했습니다.