Skip to content

Stop Codex's running shared server when the operator turns it off, so a hand-started Codex runs in its own pane - #656

Merged
yansfil merged 13 commits into
mainfrom
prd/codex-daemon-apply
Oct 7, 2026
Merged

yansfil merged 13 commits into
mainfrom
prd/codex-daemon-apply

Conversation

@yansfil

@yansfil yansfil commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #641
Related: #668 (settings-cleanup가 키트 줄을 없애고 팝오버 링크를 만듦), #669 (issue 651), #616

Summary

  • 공유 Codex daemon이 돌고 있으면 손으로 연 Codex가 그 daemon에 붙어 hide가 그 pane을 따라가지 못합니다(issue 공유 Codex daemon이 돌고 있으면 손으로 연 Codex에는 키트 설정이 적용되지 않는다 #641).
  • main의 Not connected 팝오버 링크 "Turn off Codex's shared server…"는 자동 시작만 끄고 떠 있는 daemon은 두어서, 누른 뒤에도 다음 손으로 연 Codex가 여전히 붙었습니다.
  • 이제 링크가 먼저 확인 창(대상 기계, 붙은 Codex가 끊기고 codex resume으로 이어감, hide가 연 Codex는 계속 돎)을 열고, 확인하면 자동 시작을 끈 뒤 떠 있는 daemon까지 멈춥니다(운영자 선택 C).
  • 자동 시작은 이미 꺼졌는데 daemon이 떠 있는 기계에서도 그 pane은 공유 서버 이유와 링크를 보이고, 그때 링크는 멈추기만 합니다.
  • 이 Mac과 SSH device가 같게 동작합니다(helper protocol 21). 처음 열었던 Settings 키트 줄 방식은 #668이 그 줄을 없애서 대체했습니다.

팝오버: 공유 서버 이유, Reopen, 링크 아래 "이 Mac 전체의 Codex를 바꾸고 떠 있는 서버를 멈춤"

확인 창(ko): 대상 기계, 끊김과 codex resume, hide가 연 Codex는 계속 실행, 기본 포커스 없음

Review

  • 판단해 주세요: settings-cleanup의 "A running daemon is never stopped (D-23)"를 운영자 선택 C로 의도적으로 뒤집었습니다(codex_daemon.rs 모듈 설명, UI_BEHAVIOR, ARCHITECTURE, INSTALL, status-model).
  • 판단해 주세요: 확인 창 문구(en) "Turn off Codex's shared server on {machine}?" / "Codex stops starting its shared server, and the one running now stops." / "Every Codex attached to it disconnects. In its pane, run codex resume to continue." / "Codex that Hide started doesn't use this server and keeps running." / 버튼 "Leave it running", "Turn off and stop" (ko "그대로 두기", "끄고 멈추기").
  • 판단해 주세요: PRD D-07/B9(위임된 가정). 자동 시작이 꺼졌는데 daemon이 떠 있으면 pane을 "Started before Hide was set up" 대신 공유 서버로 읽고 링크를 둡니다. 판단은 마지막 키트 읽기 기준이고 새 polling은 없습니다. 원하는 동작이 맞나요?
  • 판단해 주세요: daemon version이 실패하면 Codex의 제어 소켓(CODEX_HOME/app-server-control/app-server-control.sock)이 없을 때만 "daemon 없음"으로 봅니다. 이 규칙은 pane 이유를 정하는 읽기에만 쓰고, 확인한 끄기는 소켓으로 판단하지 않습니다: daemon version이 실행 중이라고 읽지 못하면 daemon stop을 실행하고 그 타입 있는 답(notRunning, stopped)을 믿습니다(0.160에서 관찰한 형식).
  • 판단해 주세요: 그래서 daemon이 없을 때도 끄기는 daemon stop을 한 번 실행합니다(아무것도 멈추지 않고 notRunning으로 답함). PRD B5의 "멈추기를 시도하지 않는다"와 글자로는 다르고, 보이는 결과(done, 멈춘 것 없음)는 같습니다.
  • 조심해서 볼 파일: hide-agent-hooks/src/codex_daemon.rs - failure path. daemon을 멈추는 유일한 경로와 소켓 판단.
  • 조심해서 볼 파일: herdr-core/src/runtime/kit.rs - runtime mutex 아래의 요청, 실행 번호, 연결이 끊긴 device의 요청 정리. 자식 프로세스는 키트 스레드와 helper에서만 돕니다.
  • 조심해서 볼 파일: hide-host/src/protocol.rs, hide-kit/src/lib.rs - helper 계약. protocol 21, codex_daemon_off가 멈추기까지 하므로 20 helper는 연결에서 거절됩니다.
  • 조심해서 볼 파일: web/src/PaneConnection.tsx - 확인 창, 두 번 보내지 않는 guard, 링크가 사라지면 창도 닫힘.
  • 조심해서 볼 파일: commit하는 Git test fixture의 commit.gpgsign=false - 범위 밖, 서명을 요구하는 전역 git 설정에서 실패해서 둠.
  • 비용 검토: 키트 읽기마다 daemon version 한 번이 늘어납니다(Codex에 설정이 있는 기계만, 키트 스레드와 helper에서). 멈추기는 운영자의 확인 한 번에 한 번입니다.

Evidence

  • 확인한 것: 실제 Codex CLI 0.160.0, 전용 HOME과 CODEX_HOME(daemon 소켓과 프로세스가 그 CODEX_HOME 소속임을 먼저 확인), 격리 Herdr, dev hided에서 팝오버, 확인 창 en/ko(포커스된 버튼 없음, 개수 없음), 그대로 두기는 아무것도 보내지 않음.
  • 확인한 것: 같은 환경에서 확인하면 진행 표시 뒤 done, 한 번에 자동 시작 꺼짐과 daemon 멈춤, --no-daemon Codex는 계속 답함, 새로 손으로 연 Codex는 자기 서버로 돌고 세션과 작업 라벨을 받음.
  • 확인한 것: B9 라이브. 자동 시작이 꺼진 뒤 손으로 띄운 daemon은 다음 키트 읽기에서 공유 서버 이유와 링크를 만들고, 다시 누르면 멈추기만 하며, 그 뒤 이유가 돌아옴.
  • 확인한 것: 소켓 규칙 라이브. daemon stop은 끝나기 전에 소켓을 지움(3/3), SIGKILL된 daemon은 소켓을 남기고 daemon stop은 notRunning으로 답함.
  • 확인한 것: SSH device 경로는 desktop e2e(private sshd, 가짜 codex)에서 device의 끄기가 그 device의 daemon을 멈춤. 패키징한 앱으로 local-kit.spec 통과(CI는 PR에서 macOS 패키지를 만들지 않음).
  • 확인한 것: 바뀐 4 crate는 retry 없이 전부 통과, 전체 workspace nextest(CI의 retry 1)는 통과(retry는 main의 hided opener 테스트뿐), lint, verify-web.sh, design contract 통과. 새 테스트는 결함을 심으면 각각 실패.
  • 확인하지 못한 것: 실제 Codex로 SSH device에서 멈추기(e2e는 가짜 codex), Mac mini는 쓰지 않음(운영 기계). daemon bootstrap으로 관리되는 daemon.
  • 확인하지 못한 것: sasu의 전체 cargo test suite(S1)는 이 run에서 issue 651 때문에 제외된 채로 남습니다(#669가 고쳤지만 amend는 제외를 되돌리지 못함). 대신 위의 전체 workspace 실행.
  • 확인하지 못한 것: 연결이 끊긴 device에서 거절된 확인은 화면에 새로 보이는 것이 없음(로그만, 링크는 남음).
추가 증거

확인한 뒤: pane은 "Started before Hide was set up"과 Reopen, 공유 서버가 꺼졌다는 줄

  • 후속: main의 테스트 device_kit::the_latest_agent_switch_wins_over_one_still_queued의 경쟁 조건은 #689로 남김(이 diff의 경로가 아님).

  • 후속: 격리 daemon의 자체 업데이트 루프가 검증 도중 0.160.1로 바꿈(daemon 멈춤과는 무관한 upstream 동작).

  • 코드 리뷰(옵션 C 1차)에서 남긴 것: 키트 읽기마다 daemon version 프로세스가 하나 더 돌고, 끄기 pass는 Codex 명령을 여섯 번쯤 차례로 실행합니다(마지막 읽기는 멈춤이 이미 확인한 것을 반복).

  • 코드 리뷰(옵션 C 1차)에서 남긴 것: core가 요청을 거절하면(헬퍼 연결 안 됨 등) 팝오버에 새로 보이는 것이 없고(로그만), 같은 실패가 다시 오면 진행 표시를 놓친 경우 숨을 수 있습니다.

  • 코드 리뷰(옵션 C 1차)에서 남긴 것: 잊히는 device에서 대기 중인 끄기를 정리하는 일이 잠깐 Failed 상태를 내보내고, 진행 중인 끄기는 채널 오류가 늦으면 시간 초과(180초)까지 진행 중으로 남습니다.

Verification record
  • PRD: agents/prd/codex-daemon-apply/prd.md (sha256 0855bd5e7604c29a52bb0b47c4402a201ed75b71634e776f7f65067bf34fa250)
  • Base b520d6e → head bbbded8, verified 2026-10-07T02:35:22.540Z: PASS
  • Verification report: agents/runs/codex-daemon-apply/verification-report.json and agents/runs/codex-daemon-apply/verification-report.md; source fingerprint 22fe5e7e3bda4412077198f5916ebc47ab134f32abdc17b3d73ea8cd9eccb767
  • Suites:
    • S1: EXCLUDED bash scripts/verify-cargo.sh test
    • S2: GREEN bash scripts/verify-cargo.sh lint (exit 0)
  • Reviews: kit-row version (superseded by Clean up Settings: six tabs, seven agents, a Hide AI tab and Reopen for unheard panes #668): Fidelity, Code, Security sets and two PR code review rounds, all fixed or listed. Option C (amendment 3): Fidelity, Code and Security on 755c8b4d found three (retry link lost after an unreadable stop failure, uncapped Codex text in logs, quit mid-stop read as stop_failed), fixed in 755c8b4d; all three flagged a failed daemon version read as no daemon, decided by the Observer: no daemon only while the control socket is absent (5f4d6514); follow-up Code+Security review found a crashed daemon's stale socket would block every retry, settled by daemon stop's typed notRunning inside the confirmed turn-off (4c73d043, ad77171a), verdict correct; rebase review on e008417 clean. PR code review round 1 on e008417: two fixed in cc9c309 and bbbded8 (the confirmed stop never decides from the socket and trusts daemon stop's typed answer; the unreachable line no longer claims the setting is unchanged), follow-up review met; four deferred, listed under Evidence.
  • Evidence: 138 registered (33 screenshot, 101 log, 4 file); paths are local to the run directory
    • agents/runs/codex-daemon-apply/live/screens/1-running-en.png
    • agents/runs/codex-daemon-apply/live/screens/2-confirm-en.png
    • agents/runs/codex-daemon-apply/live/screens/2-confirm-ko.png
    • agents/runs/codex-daemon-apply/live/screens/4-settled-en.png
    • agents/runs/codex-daemon-apply/live/screens/5-labels-after-stop-expanded.png
    • agents/runs/codex-daemon-apply/live/02-scope-after-start.txt
    • agents/runs/codex-daemon-apply/live/03-before-stop.txt
    • agents/runs/codex-daemon-apply/live/04-after-stop.txt
    • agents/runs/codex-daemon-apply/screens/device-e2e/codex-daemon-running.png
    • agents/runs/codex-daemon-apply/screens/device-e2e/codex-daemon-confirm.png
    • agents/runs/codex-daemon-apply/screens/device-e2e/codex-daemon-stop-failed.png
    • agents/runs/codex-daemon-apply/screens/device-e2e/codex-daemon-stopping.png
    • agents/runs/codex-daemon-apply/screens/device-e2e/codex-daemon-stopped.png
    • agents/runs/codex-daemon-apply/live/05-after-new-codex.txt
    • agents/runs/codex-daemon-apply/verify/nextest-ci-workspace.log
    • agents/runs/codex-daemon-apply/verify/strict-touched-crates.log
    • agents/runs/codex-daemon-apply/verify/opener-base-b520d6eb.log
    • agents/runs/codex-daemon-apply/verify/opener-bisect.log
    • agents/runs/codex-daemon-apply/verify/nextest-ci-workspace-f4baf4ce.log
    • agents/runs/codex-daemon-apply/verify/strict-touched-crates-f4baf4ce.log
    • agents/runs/codex-daemon-apply/verify/review-fixes-planted.log
    • agents/runs/codex-daemon-apply/verify/nextest-ci-workspace-60e83a88.log
    • agents/runs/codex-daemon-apply/verify/strict-touched-crates-60e83a88.log
    • agents/runs/codex-daemon-apply/verify/nextest-ci-workspace-1f9417dd.log
    • agents/runs/codex-daemon-apply/verify/device-kit-stress.log
    • agents/runs/codex-daemon-apply/verify/nextest-ci-workspace-0402652c.log
    • agents/runs/codex-daemon-apply/verify/strict-touched-crates-0402652c.log
    • agents/runs/codex-daemon-apply/verify/round2-device-kit-e2e.log
    • agents/runs/codex-daemon-apply/verify/round2-planted-e2e.log
    • agents/runs/codex-daemon-apply/verify/round2-planted.log
    • agents/runs/codex-daemon-apply/verify/web-0402652c.log
    • agents/runs/codex-daemon-apply/screens/device-e2e-round2/codex-daemon-confirm.png
    • agents/runs/codex-daemon-apply/screens/device-e2e-round2/codex-daemon-running.png
    • agents/runs/codex-daemon-apply/screens/device-e2e-round2/codex-daemon-stop-failed.png
    • agents/runs/codex-daemon-apply/screens/device-e2e-round2/codex-daemon-stopped.png
    • agents/runs/codex-daemon-apply/screens/device-e2e-round2/codex-daemon-stopping.png
    • agents/runs/codex-daemon-apply/verify/lint-a3e7140b.log
    • agents/runs/codex-daemon-apply/verify/nextest-ci-a3e7140b.log
    • agents/runs/codex-daemon-apply/verify/strict-touched-a3e7140b.log
    • agents/runs/codex-daemon-apply/verify/git-fixture-signing-a3e7140b.log
    • agents/runs/codex-daemon-apply/verify/verify-web-a3e7140b.log
    • agents/runs/codex-daemon-apply/verify/policy-a3e7140b.log
    • agents/runs/codex-daemon-apply/verify/device-kit-e2e-a3e7140b.log
    • agents/runs/codex-daemon-apply/screens/merged-device-kit-a3e7140b/codex-daemon-running.png
    • agents/runs/codex-daemon-apply/screens/merged-device-kit-a3e7140b/codex-daemon-confirm.png
    • agents/runs/codex-daemon-apply/screens/merged-device-kit-a3e7140b/codex-daemon-stopping.png
    • agents/runs/codex-daemon-apply/screens/merged-device-kit-a3e7140b/codex-daemon-stop-failed.png
    • agents/runs/codex-daemon-apply/screens/merged-device-kit-a3e7140b/codex-daemon-stopped.png
    • agents/runs/codex-daemon-apply/verify/strict-touched-51c416ff.log
    • agents/runs/codex-daemon-apply/verify/lint-51c416ff.log
    • agents/runs/codex-daemon-apply/verify/build-bins-51c416ff.log
    • agents/runs/codex-daemon-apply/verify/device-kit-e2e-51c416ff.log
    • agents/runs/codex-daemon-apply/screens/merged-device-kit-51c416ff/codex-daemon-confirm.png
    • agents/runs/codex-daemon-apply/screens/merged-device-kit-51c416ff/codex-daemon-stopping.png
    • agents/runs/codex-daemon-apply/screens/merged-device-kit-51c416ff/codex-daemon-stopped.png
    • agents/runs/codex-daemon-apply/verify/review1-fixes-before-8dde1c3e.log
    • agents/runs/codex-daemon-apply/verify/review1-fixes-after-8dde1c3e.log
    • agents/runs/codex-daemon-apply/verify/review1-strict-touched-8dde1c3e.log
    • agents/runs/codex-daemon-apply/verify/review1-strict-touched-signing-config-8dde1c3e.log
    • agents/runs/codex-daemon-apply/verify/review1-lint-8dde1c3e.log
    • agents/runs/codex-daemon-apply/verify/review1-verify-web-8dde1c3e.log
    • agents/runs/codex-daemon-apply/verify/review1-design-contract-8dde1c3e.log
    • agents/runs/codex-daemon-apply/verify/review1-device-kit-e2e-8dde1c3e.log
    • agents/runs/codex-daemon-apply/screens/review1-device-kit-8dde1c3e/codex-daemon-stop-failed.png
    • agents/runs/codex-daemon-apply/screens/review1-device-kit-8dde1c3e/codex-daemon-stopping.png
    • agents/runs/codex-daemon-apply/screens/review1-device-kit-8dde1c3e/codex-daemon-stop-failed-row.png
    • agents/runs/codex-daemon-apply/screens/review1-device-kit-8dde1c3e/codex-daemon-stopping-row.png
    • agents/runs/codex-daemon-apply/verify/review1b-before-6ef5f8ed.log
    • agents/runs/codex-daemon-apply/verify/review1b-after-6ef5f8ed.log
    • agents/runs/codex-daemon-apply/verify/review1b-lint-6ef5f8ed.log
    • agents/runs/codex-daemon-apply/verify/review1b-strict-touched-6ef5f8ed.log
    • agents/runs/codex-daemon-apply/verify/review1b-device-kit-e2e-6ef5f8ed.log
    • agents/runs/codex-daemon-apply/verify/review1b-package-6ef5f8ed.log
    • agents/runs/codex-daemon-apply/verify/review1b-local-kit-e2e-6ef5f8ed.log
    • agents/runs/codex-daemon-apply/verify/final-package-6ef5f8ed.log
    • agents/runs/codex-daemon-apply/verify/final-local-kit-e2e-6ef5f8ed.log
    • agents/runs/codex-daemon-apply/verify/final2-strict-hide-host-f5facb4e.log
    • agents/runs/codex-daemon-apply/live-c/02-scope-after-start.txt
    • agents/runs/codex-daemon-apply/live-c/03-before-stop.txt
    • agents/runs/codex-daemon-apply/live-c/screens/2-popover-en.png
    • agents/runs/codex-daemon-apply/live-c/screens/3-confirm-en.png
    • agents/runs/codex-daemon-apply/live-c/screens/3-confirm-ko.png
    • agents/runs/codex-daemon-apply/live-c/04-go.txt
    • agents/runs/codex-daemon-apply/live-c/screens/4-answer-en.png
    • agents/runs/codex-daemon-apply/live-c/05-after-stop.txt
    • agents/runs/codex-daemon-apply/live-c/06-after-new-codex.txt
    • agents/runs/codex-daemon-apply/live-c/screens/5-settled-en.png
    • agents/runs/codex-daemon-apply/live-c/07-b9.txt
    • agents/runs/codex-daemon-apply/live-c/08-b9-second-request.txt
    • agents/runs/codex-daemon-apply/live-c/screens/6-b9-popover-en.png
    • agents/runs/codex-daemon-apply/live-c/core.jsonl
    • agents/runs/codex-daemon-apply/e2e-c/device-kit.log
    • agents/runs/codex-daemon-apply/e2e-c/hide-desktop-kit-HgtUMT-daemon.jsonl
    • agents/runs/codex-daemon-apply/verify/c-strict-tests-3.log
    • agents/runs/codex-daemon-apply/verify/c-strict-letter-origin-rerun.log
    • agents/runs/codex-daemon-apply/verify/c-mutation-run.log
    • agents/runs/codex-daemon-apply/verify/c-mutation-run-2.log
    • agents/runs/codex-daemon-apply/verify/c-mutation-run-3.log
    • agents/runs/codex-daemon-apply/verify/c-lint.log
    • agents/runs/codex-daemon-apply/verify/c-verify-web-3.log
    • agents/runs/codex-daemon-apply/verify/c-design-contract-2.log
    • agents/runs/codex-daemon-apply/review-c/review-set.md
    • agents/runs/codex-daemon-apply/verify/c-review-fix-tests-2.log
    • agents/runs/codex-daemon-apply/verify/c-review-fix-mutation.log
    • agents/runs/codex-daemon-apply/verify/c-lint-2.log
    • agents/runs/codex-daemon-apply/verify/c-workspace-nextest.log
    • agents/runs/codex-daemon-apply/e2e-c/local-kit.log
    • agents/runs/codex-daemon-apply/verify/c-strict-tests-final.log
    • agents/runs/codex-daemon-apply/verify/c-socket-tests.log
    • agents/runs/codex-daemon-apply/verify/c-socket-mutation-a.log
    • agents/runs/codex-daemon-apply/verify/c-socket-mutation-b.log
    • agents/runs/codex-daemon-apply/verify/c-strict-tests-socket.log
    • agents/runs/codex-daemon-apply/verify/c-ssh-hosts-rerun.log
    • agents/runs/codex-daemon-apply/verify/c-lint-3.log
    • agents/runs/codex-daemon-apply/live-c/09-socket-live.txt
    • agents/runs/codex-daemon-apply/verify/c-socket-tests-2.log
    • agents/runs/codex-daemon-apply/verify/c-socket-mutations-2.log
    • agents/runs/codex-daemon-apply/verify/c-strict-tests-socket-2.log
    • agents/runs/codex-daemon-apply/verify/c-lint-4.log
    • agents/runs/codex-daemon-apply/review-c/review-socket.md
    • agents/runs/codex-daemon-apply/verify/c-socket-tests-3.log
    • agents/runs/codex-daemon-apply/verify/c-socket-mutation-widen.log
    • agents/runs/codex-daemon-apply/verify/c-lint-5.log
    • agents/runs/codex-daemon-apply/review-c/review-rebase.md
    • agents/runs/codex-daemon-apply/verify/c-rebase-strict.log
    • agents/runs/codex-daemon-apply/verify/c-rebase-lint.log
    • agents/runs/codex-daemon-apply/verify/c-rebase-verify-web.log
    • agents/runs/codex-daemon-apply/verify/c-rebase-design.log
    • agents/runs/codex-daemon-apply/e2e-rebase/device-kit.log
    • agents/runs/codex-daemon-apply/verify/c-r1-strict.log
    • agents/runs/codex-daemon-apply/verify/c-r1-codex-trust-rerun.log
    • agents/runs/codex-daemon-apply/verify/c-r1-mutation.log
    • agents/runs/codex-daemon-apply/verify/c-r1-lint.log
    • agents/runs/codex-daemon-apply/verify/c-r1-verify-web.log
    • agents/runs/codex-daemon-apply/verify/c-r1-design.log
    • agents/runs/codex-daemon-apply/review-c/review-r1.md
    • agents/runs/codex-daemon-apply/verify/c-r1-tests-2.log
    • agents/runs/codex-daemon-apply/verify/c-r1-lint-2.log
  • Changed paths: 348 (see Files changed)

yansfil added 10 commits October 7, 2026 11:13
…perator confirms turning the shared server off
…nd no daemon, keep the done line true when nothing was stopped, and say when the kit reads the daemon
… confirms again, until the core's state moves on
…read says no daemon answers, cap what the Codex CLI printed in reports and logs, and read a quit during the stop as unreachable
…ontrol socket is gone, so a daemon that cannot be asked never answers done
…ed daemon stop answer, so a crashed daemon's stale socket never blocks the retry, and log the first error line of the version check
@yansfil
yansfil force-pushed the prd/codex-daemon-apply branch from f5facb4 to e008417 Compare October 7, 2026 02:21
@yansfil yansfil changed the title Say when Codex's shared daemon keeps the per-pane setting from hand-started Codex, and stop it after the operator confirms Stop Codex's running shared server when the operator turns it off, so a hand-started Codex runs in its own pane Oct 7, 2026
… daemon stop answer, never by its control socket, and say only that an unreachable machine could not be reached
…ent off, describe the check after the stop, and pin that a quit before the version check stops nothing
@yansfil
yansfil merged commit bcfce96 into main Oct 7, 2026
22 checks passed
@yansfil
yansfil deleted the prd/codex-daemon-apply branch October 7, 2026 07:37
yansfil added a commit that referenced this pull request Oct 7, 2026
…nce (#664)

Related: core-host-node 1/5 (항상 켜진 노드에서 core 돌리기). origin/main 2c15edb
위로 rebase했습니다. #661과 #669는 main에 들어가서 이 PR에서 빠졌습니다. 저장소의 attribution 검사에
걸린 커밋 문구 두 개(제품 이름)만 고쳐 head가 b5ddca5e로 바뀌었고, tree는 030b1867과 같습니다.

## Summary

core는 자기 기계를 `local`이라는 문자열로 불렀습니다. 그래서 기기 행, 등록, 폴더 owner mark, 라벨 키,
편지, 프로젝트 id에 모두 `local`이 박혀 있었고, core를 다른 기계로 옮기면 어느 기계의 것인지 가릴 수 없었습니다.
이제 core는 자기 기계를 node id(그 기계 `machine_id`의 소문자)로 부릅니다. device를 적지 않은
이벤트는 여전히 core 자신의 node를 뜻하고, `local`을 명시하면 모르는 기기로 보고 거절합니다.
`local`로 쓰인 상태 폴더는 hided가 core를 띄우기 전에 한 번 변환합니다.
- JSON 저장소는 원자적으로 다시 씁니다.
- Memory, 세션 검색, 링크 기록(#638)은 SQLite 트랜잭션 하나로 키를 다시 붙입니다.
- 원본은 `node-migration-backup/<ms>/`에 남깁니다.
- 마지막에 `node.json`에 폴더의 주인 node를 적습니다.
변환하지 못하면 원본은 그대로 남고, 앱 창이 어느 파일 때문에 시작하지 못했는지 보여 줍니다.

```text
Can't connect to hided
hided could not start because of this file, which was left unchanged.
<state folder>/node.json
[Retry]
```
화면 캡처에는 워크스테이션의 사용자 이름과 경로가 보여서 올리지 않았습니다. 캡처는 로컬 run 기록에 있습니다.

## Review

- **정해진 것(운영자 결정)**: `node.json`은 "이 폴더에서 qualify되지 않은 키를 가진 node"를 뜻하고,
다른 node 이름이 적힌 폴더(새 Mac, Migration Assistant로 옮긴 폴더)는 layer 5의 옮기기와
되돌리기가 다룹니다. 그때까지는 그 파일을 보여 주며 시작을 거절하는 지금 동작을 유지합니다. 형식은 layer 5에서 바뀌지
않습니다(D-23).
- **판단해 주세요**: 세션 검색 인덱스(운영 기계에서 170 MB)는 백업하지 않습니다. 새 키에 이미 행이 있으면 새 행을
남기고 옛 행을 지운 뒤 개수를 기록합니다. 옛 Copied history 설정도 이 규칙을 따릅니다.
- **판단해 주세요**: 프로젝트 id가 node id를 해시에 넣으므로, 변환 전에 transcript에 찍힌 Memory
receipt는 더 이상 검증되지 않습니다.
- **조심해서 볼 파일**: `herdr-core/src/node_migration.rs` (failure path)
  - 저장소 하나라도 변환에 실패하면 시작을 멈춥니다.
  - 재시도하면 수렴합니다. pair는 지금의 Memory와 등록에서 다시 얻고, 백업은 같은 폴더에 한 번만 남깁니다.
  - 변환된 인덱스는 읽기만 합니다.
- **조심해서 볼 파일**: `hided/src/cli.rs` `wait_healthy`. `hide connect`는 자기가
띄운 daemon이 먼저 끝나면 10초를 기다리지 않습니다. 대신 Logs에서 그 pid가 spawn 이후에 쓴 거절 기록을 읽어
`state_refused`로 답합니다.
- **조심해서 볼 파일**: `herdr-core/src/checkout_owner.rs` (Herdr contract).
owner mark가 node id로 바뀌고, 기존 `local` mark도 이 node의 것으로 읽습니다.
- **조심해서 볼 파일**: rebase 뒤 main이 더한 코드에서 이 기계를 `"local"`로 부르던 곳(adea3d9,
문구를 고치기 전 e3f0688). `herdr-core/src/runtime/kit.rs`(Codex CLI shared
server 끄기와 에이전트 연결 읽기), `herdr-core/src/runtime/agents.rs`,
`web/src/PaneConnection.tsx`,
`web/src/settings/{AgentsTab,DevicesTab,HideAiTab,agentRows}.ts*`가 이제
node id 또는 기기 행의 kind로 이 기계를 찾습니다. main의 동작은 바꾸지 않았습니다.
- **조심해서 볼 파일**: `desktop/src/main/browser.ts`. node id를 받기 전에는 loopback
페이지를 원격 파티션에 두고, id가 오면 파티션이 바뀐 페이지를 다시 만듭니다.
- **질문**: 기계 id가 바뀐 Mac(새 Mac 설정, 재설치)은 자기 옛 폴더를 다른 node의 것으로 보고 거절합니다.
지금은 창에 파일을 보여 주고 문서로 "새 state 폴더로 시작"을 안내합니다. 이 경우는 layer 5의
move/restore가 맡는 것으로 보면 될까요?
- **질문**: daemon frame에 `node_id`를 더하지 않았습니다(웹은 자기 기기 행에서 읽습니다). layer
4에서 화면의 node와 core의 node가 갈라질 때 더하려고 합니다.
- **질문**: snapshot wire의 pane과 checkout id qualify는 layer 4의 요구사항으로
남깁니다.

## Evidence

- **확인한 것**: `sasu implement verify` PASS on bce1a82(S1 Rust 전체 suite,
S2 lint). 지금 head f422844b는 main #722, #725 위로 rebase만 한 것입니다.
range-diff로 본 차이: #725가 없앤 checkout caller의 pane hint 코드에 있던 node 고정이 함께
빠졌고, 배달 권한 목록은 #725의 pane 조건과 node id 확인을 함께 둡니다. #725가 더한 테스트 5곳은
`TEST_NODE`로 고정했습니다. 그 head에서 herdr-core와 hided 테스트 1982/1982, workspace
lint 통과.
- **확인한 것**: main이 더한 테스트의 fixture 경쟁을 고쳤습니다(bce1a82, 제품 동작 변경 아님,
issue 641 영역). 가짜 Codex CLI app-server의 `hang` 모드가 `hooks/list`를 받은 뒤에야
자식을 띄워서, load 65에서 요청 한도가 먼저 끝나면 시간 초과 테스트가 자식을 찾지 못했습니다. 자식을 시작 때 띄우게
했고, 요청 한도 50 ms에서 옛 fixture는 실패, 새 fixture는 통과합니다.
- **확인한 것**: rebase한 head에서 clippy 통과, Rust workspace nextest 2804/2805.
남은 1건 `hided`
`opener_lifecycle::acceptance_timeout_ends_cli_spawned_before_watcher`는
load 24에서 실패했고, 단독 5회 반복(load 24에서 34)에서 4/5 통과, 1회는 20초 pid 대기
deadline에서 실패했습니다. 이 PR은 `hided`의 spawn과 opener를 바꾸지 않습니다.
- **확인한 것**: web(129 files, 1164)과 desktop(16 files, 158) typecheck,
lint, unit, build 통과(rebase 뒤).
- **확인한 것**: 변환 계약 테스트
  - `KEYS`의 모든 키에 fixture 값이 있습니다.
  - 다시 쓴 키에서는 `local`이 사라지고, node 소유 키는 그대로입니다.
  - `KEYS`와 `UNBOUND` 어디에도 없는 파일이 있으면 실패합니다.
- 재시도 수렴, 충돌 시 rollback, 백업 1부, 변환된 폴더를 다른 writer가 잡고 있어도 시작되는 경우를 다룹니다.
- **확인한 것**: 69693b51의 debug hided로 운영자 `~/.hide/state`의 새 복사본을
변환했습니다(HOME 격리, Herdr 없음, 상태 폴더 0700).
- core-state, ledger, labels, workspace-views의 `"local"` 13/481/1/225가
0이 되었고, Memory 2개 프로젝트와 세션 검색 20,925행의 키를 다시 붙였습니다(버린 행 0).
  - 변환 후 ledger를 읽었고, 두 번째 시작은 아무것도 변환하지 않았으며 백업 폴더도 1개 그대로였습니다.
- 운영자 원본 ledger, workspace-views, Memory의 mtime과 sha256은 그대로였습니다. 운영자
폴더에는 node.json도 백업도 생기지 않았습니다.
- **확인한 것**: 네이티브 QA. 설치된 빌드(b520d6e)가 격리 Herdr에서 쓴 폴더를 candidate 앱이
열었습니다.
  - This Mac 아래에 두 프로젝트가 보였습니다.
  - 같은 Herdr workspace id와 두 번째 탭이 유지되었습니다.
  - 다른 node 폴더는 0.3초 만에 파일을 보여 주었습니다.
- **확인한 것**: rebase 전 web e2e 186/187. rebase 뒤 main이 더한 `agents-tab`,
`devices-settings` spec 6건 중 5건 통과, desktop e2e(focus 제외) 55 통과 7 skip 1
실패(아래 dense hover). `home-layout` 통과, `local-kit`은 패키지된 앱이 필요해 로컬에서
skip. Herdr schema contract(0.9.1), Herdr pin single source, design
contract, workstation identity, harness anchor, capability readers,
worktree removal boundary 통과.
- **확인하지 못한 것**: 이 diff 밖에 있고 main에서도 재현되는 실패들입니다. 고치지 않았습니다.
  - flaky #653 view-bookmarks: 전체 실행에서 1회 실패했고, 단독 2/2 통과.
- desktop terminal-links dense hover: 이 노트북 화면에서 창이 184 columns라 필요한
215를 넘지 못합니다.
- web e2e `agents-tab` 목록 테스트: kit이 `/opt/homebrew/bin`도 찾는데 이 Mac에
OpenCode가 있어 Installed가 4가 아니라 5입니다.
- `hide-platform` watch burst(#651): main의 #669가 고쳤습니다. 그 전 head들의 실패는
아래 Verification record에 남겼습니다.
- **확인하지 못한 것**: 운영자의 실제 링크 기록 레이아웃. 설치된 앱이 #638 이전 빌드라 `links.sqlite3`가
없어서 fixture 계약 테스트로만 확인했습니다.
- **확인하지 못한 것**: `check-herdr-contract.sh`의 실행 중 서버 확인. 이 PR은 Herdr 호출을
바꾸지 않습니다.

<details><summary>리뷰와 처리</summary>

rebase 뒤 리뷰(adea3d9, 문구를 고치기 전 e3f0688): 충돌 해결이 main과 layer 1의 동작을 모두
지켰는지, main이 더한 코드의 `local`이 모두 node id로 바뀌었는지, 명시한 `local`이 어디서도 통과하지
않는지 봤고 Fix now는 없었습니다. 따라온 두 가지는 030b1867에서 고쳤습니다: 이 Mac을 `local`로 적던 기기
id 주석, 그리고 활성 Memory 항목의 검색 행까지 옮기는 변환 테스트.

Fidelity, Code, Security 리뷰를 두 라운드 돌렸습니다(62b777c, e071177). Fix now
항목은 모두 이 PR에서 고쳤고, 고친 diff를 본 세 번째 라운드(4c287ce)는 Fix now가 없었습니다.
- 재시도 수렴, 조용한 `UPDATE OR IGNORE`, FTS 고아 행: 2c3f5c7, 4c287ce.
- `KEYS` 누락 필드와 `UNBOUND` 분류: 2c3f5c7.
- B2 창 표시: d63dd60.
- 매 시작마다 잡던 검색 인덱스 쓰기 잠금, 재시도마다 늘던 백업, pid만으로 맞추던 거절 기록: 4c287ce.

CI `windows check`가 4c287cec부터 실패했습니다. Windows 전용 hook 테스트가 Project를 아직
`local`로 만들고 있었기 때문이고, 06b2425f에서 node id로 바꿨습니다.

코드 리뷰 1라운드(4c287ce) 처리는 69693b51입니다.
- 두 이름으로 쓰인 `device_expanded_paths` 목록은 합칩니다(전에는 옛 목록을 버렸습니다).
- 더 긴 node id 때문에 ledger가 loader 한도(16 MiB)를 넘게 되면 시작을 멈추고 파일을 알려 줍니다.
- 밀려난 `#[cfg(unix)]`를 브라우저 alias 테스트에 되돌렸고, `hide connect` 거절 테스트를 unix
전용으로 했습니다.
- 4라운드(f93ef22 네이티브 리뷰) 처리는 6605c78c입니다. ledger 크기 확인을 어떤 파일도 쓰기 전에
하므로, 거절되면 모든 파일이 제자리에 그대로 남습니다. 이미 한도를 넘은 ledger는 loader에 맡기고, 거절 문구에 해결
방법을 적었습니다. 목록 합치기와 중복 제거는 선형이고, node 경계 테스트는 다시 모든 OS에서 돕니다.
- 2라운드(69693b5) 처리는 c85aeef4입니다.
`expanded_inactive_project_device_ids`가 이미 node를 담고 있으면 변환 뒤에도 한 번만
남깁니다.
- 2라운드에서 바꾸지 않은 것: core-state 8 MiB 한도(그 한도는 제거된 native 앱의 상태 파일에만 적용되고
core-state에는 loader 한도가 없음), 이전 앱이 다시 쓴 `local` 행과의 Memory/링크 충돌(아래 후속),
10초 health 창 안의 큰 변환(아래 후속), 등록도 Memory도 없는 프로젝트의 Sessions mode(기본값으로
돌아가고 인덱스는 다시 만듦), `hide-kit` `search_path`(이 diff 밖), 브라우저 partition(위
Review 파일).
- 바꾸지 않은 것: hook이 실행마다 기계 id를 읽는 비용(`ioreg` 0.01초, hook은 hide-kit에 의존할 수
없음), `node.json` 해석과 desktop/web 동시 배포(위 Review 질문).

후속으로 남긴 것:
- 일반 `daemon.start_failed` 기록.
- `try_wait` 오류 처리.
- 큰 변환이 10초를 넘을 때의 Retry 안내.
- 롤백한 빌드가 다시 쓴 `local` 행의 Memory와 링크 충돌. 지금은 시작을 멈추고 파일을 알려 줍니다(layer
5).
- 등록도 Memory도 없는 프로젝트의 Sessions mode 키.
- 실패한 백업 복사의 `.partial` 정리와 rename 전 fsync.
- 검색 FTS 고아 행을 직접 세는 테스트.
- `node.json`이 있는 폴더에서 실패를 재시도할 때 백업 폴더 재사용.

</details>

<details><summary>테스트 고정값 변경 (PRD changes the wire id, D-21)</summary>

아래 파일에서는 `local` 고정값만 node id로 바꿨습니다. Rust는 `crate::node::TEST_NODE`,
e2e는 daemon의 `node.json`, web 단위 테스트는 helper의 node 인자를 씁니다. assertion은
바꾸지 않았습니다.

- Rust: `herdr-core/src/runtime/tests.rs`,
`herdr-core/src/runtime/tests/*`(26 files),
`herdr-core/src/labels/tests.rs`,
`herdr-core/src/session_sync/tests.rs`, `hided/tests/mobile.rs`,
`hide-agent-hooks/tests/windows_hook_command.rs`(Windows 전용이라 macOS 검색에서
빠졌고, 06b2425f에서 고침). inline test module도 바꿨습니다: `workspace.rs`,
`runtime/delivery.rs`, `coordination/executor.rs`, `delivery/worker.rs`,
`live.rs`, `files.rs`, `labels/import.rs`, `changes.rs`,
`runtime/attachments.rs`.
- web: `web/e2e/{device-rail,home,mobile,s3,s7,start-panel}.spec.ts`,
`web/e2e/hided-fixture.ts`,
`web/src/{RequestView,addProject,areaCycle,buffers,linkPanel,numbering,revealExternal,store,viewLayout,workspaceManage}.test.*`.
- desktop:
`desktop/e2e/{add-project,agent-spawn,browser,device-home,home-layout,local-kit,remote-workspace,workspace-columns}.spec.ts`,
`desktop/src/main/{browser,browserSync}.test.ts`.
- 두 번째 rebase 뒤 main이 더한 Factory 코드와 테스트:
`herdr-core/src/runtime/delivery.rs`,
`herdr-core/src/runtime/factory.rs`, `herdr-core/src/delivery/watch.rs`,
`herdr-core/src/coordination/mod.rs`의 테스트, `web/e2e/agents-tab.spec.ts`의
session 수 단계. 운영 코드에서는 Factory의 수신자(`Actor::factory`)가 core의 node id를
받고, `hide factory` 명령의 기기 확인이 `"local"` 대신 core의 node id와
비교합니다(5d343e0).
- rebase 뒤 main이 더한 테스트:
`herdr-core/src/runtime/tests/{agent_connection,agents_settings_remote,lineage,ui_state_focus}.rs`,
`web/e2e/{agents-tab,devices-settings}.spec.ts`,
`desktop/e2e/{home-layout,local-kit}.spec.ts`의 Connection details 단계.

새 테스트만 더한 파일입니다: `hided/tests/node_owner.rs`,
`hide-session/tests/search.rs`, `desktop/e2e/desktop.spec.ts`,
`desktop/src/main/cli.test.ts`.

</details>

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

- rebase 2와 3: b5ddca5e에서 origin/main 3ee278f(#700, #702, #705, #706,
#713, #715, #724 포함)로 옮겼고, 그때 head는 34c44011이었습니다. 충돌 파일:
`herdr-core/src/delivery/worker.rs`,
`herdr-core/src/runtime/delivery.rs`,
`herdr-core/src/runtime/tests/agent_connection.rs`,
`web/e2e/agents-tab.spec.ts`, `desktop/e2e/home-layout.spec.ts`(main의
동작에 node id를 더해 해결).
- main이 더한 코드의 node id: Factory의 수신자와 `hide factory` 기기 확인(667a25c 계열),
main의 자기 기기 fixture 5곳과 #724의 show-here 테스트(e88caa6, 2a929dc). `hide
factory`의 기기 확인은 core 한 곳에서만 하고, Factory가 없을 때도 다른 기기는 main처럼
`factory_local_only`를 먼저 받습니다.
- rebase 뒤 리뷰(667a25c): Fidelity, Security Fix now 없음. Code Fix now
1(main의 자기 기기 fixture가 `"local"`로 남음) e88caa6c에서 고침. 후속:
`factory_local_only` 테스트, move 층에서 `factory:` actor의 node id 다시 쓰기, 저장된
등록이 core node와 같은 id일 때 연결에서 거르기.
- `sasu implement verify` PASS on 667a25c(S1, S2). 그 전 head 5d343e0e에서는
load 30 이상에서 main의 `gh` 5초, `lsof` 10초 시간 초과와 harness 정리 단계의 `kill
EPERM`으로 세 번 실패했고, 각 테스트는 단독으로 통과했습니다. 2a929dcd에서는 main의 GitHub 테스트가 가짜
`gh`에 준 5초 기한이 load 아래에서 다시 넘어, 34c44011에서 같은 파일의
`FIXTURE_DEADLINE`(10초)으로 맞췄습니다(GitHub 테스트 46/46). `sasu implement
verify` PASS on 34c4401(S1, S2, load 14).
- rebase 4: origin/main bcfce96(#656, #716 포함)로 옮겼고, 그때 head는
9cf059c6이었고, 그 뒤 fmt 49deea1, fixture bce1a825를 더했습니다. 충돌 파일:
`herdr-core/src/runtime/tests/agent_connection.rs`,
`herdr-core/src/runtime/agents.rs`(main의 동작에 node id를 더해 해결). #656이 더한
Codex CLI shared server 끄기의 자기 기기 확인(`runtime/kit.rs`, 연결된 helper가 필요 없는
쪽)을 core의 node id로 바꿨고, 그 테스트 9곳의 `"local"`을 `TEST_NODE`로
고정했습니다(9cf059c). web 단위 테스트 `PaneConnection.test.tsx`의 `"local"`은
snapshot이 주는 기기 id 데이터라 그대로 두었습니다(다른 web 단위 테스트와 같음).
- main이 더한 테스트의 fixture 경쟁 수정(bce1a82, 제품 동작 변경 아님, issue 641 영역):
`hide-agent-hooks/tests/fixtures/fake-codex.py`의 `hang` 모드가 자식 프로세스를
`hooks/list`를 받은 뒤에야 띄워서, load 65에서 1.5초 요청 한도가 먼저 끝나면
`a_codex_that_does_not_answer_is_stopped_and_nothing_of_it_is_left`가 "it
started a child"로 실패했습니다(verify 49deea1). 자식을 stand-in 시작 때 띄우게 바꿨습니다.
요청 한도를 50 ms로 줄이면 옛 fixture는 같은 panic으로 실패하고 새 fixture는 통과합니다. 테스트의
주장(시간 초과 뒤 app-server와 자식이 모두 끝남)은 그대로입니다. `sasu implement verify` PASS
on bce1a82.
- rebase 5: origin/main 411f34a(#722, #725 포함)로 옮겼고, 지금 head는
f422844b입니다. 충돌 파일: `herdr-core/src/runtime/delivery.rs`,
`herdr-core/src/runtime/workspace_control.rs`,
`herdr-core/src/runtime/factory.rs`. #725가 checkout caller의 pane hint를
없앴으므로 main 쪽을 따랐고, 배달 권한 목록의 자기 기기 확인만 node id로 바꿨습니다. #725가 더한 테스트의
`"local"` 5곳을 `TEST_NODE`로 고정했습니다(f422844). 관련 테스트 128/128.
- rebase: 옛 head 6605c78(base 104d308, #661 e071177f와 #669 f93ef22
포함)에서 새 base origin/main 2c15edb0로 옮겼고, 새 head는 e3f06887입니다. 두 carried
commit은 빠졌습니다. 충돌 파일:
`herdr-core/src/{lib.rs,labels/mod.rs,runtime/kit.rs,runtime/memory.rs,runtime/tests/lineage.rs}`,
`web/src/{IssueDialogs.tsx,SettingsSheet.tsx,settings.ts}`,
`desktop/e2e/{local-kit,home-layout}.spec.ts`.
- `sasu implement verify` PASS: e3f0688(S1 229.2s, rebase 뒤). 030b1867은
주석과 `hide-memory` 테스트 1건만 더했고, 그 테스트와 clippy, web lint를 따로 돌렸습니다,
6605c78(S1 179.9s), f93ef22(S1 192.6s), 4c287ce. rustc 1.99.0.
- 네이티브 Fidelity, Code, Security 리뷰: 4c287ce, f93ef22, 6605c78c에서 Fix
now 없음.
- #669 이전 head의 S1 실패 기록(모두 `hide-platform/tests/watch.rs`
`a_burst_is_bounded_and_ends_in_an_overflow_rather_than_silence`만 실패, S2
통과):
- 69693b5: 6,311에서 8,047 changes가 3회, load 11-16. 그 전 1회는 `hide-kit` 하위
프로세스 timeout 3건이었고 단독 실행으로 통과했습니다.
- c85aeef: 7,396 changes(load 6.5에서 12.4), 8,807 changes(load 7.1에서
9.5).
  - main 재현: load 14에서 3/3.
- 운영자 상태 복사본 변환: 69693b51의 debug hided(sha256 3aac76ed...).
- 네이티브 QA: a7a3d80f의 candidate 앱.

- 마지막 sasu verify head: bce1a82. 그 뒤 바뀐 것(range-diff bcfce96..bce1a82
vs 411f34a..f422844): 1, 3, 17번 commit의 충돌 해결(#725 쪽을 따름), 새 commit
f422844(#725 테스트 5곳 `TEST_NODE`). herdr-core와 hided nextest 1982/1982,
`scripts/verify-cargo.sh lint` 통과 on f422844.
</details>

## Breaking change

- 상태 폴더(`~/.hide/state`, `~/Library/Application Support/hide`의 Project
Memory)는 첫 시작에 한 번 변환됩니다. 이전 앱으로 돌아가면 이 Mac의 프로젝트가 다른 기기의 것으로 보입니다.
되돌리려면 `node-migration-backup/<ms>/`의 파일을 제자리에 복사합니다(`docs/INSTALL.md`).
- daemon wire나 `hide` 명령에서 `device_id: "local"`을 명시하면 이제 모르는 기기로 거절됩니다.
device를 적지 않으면 지금처럼 이 기계를 뜻합니다.
yansfil added a commit that referenced this pull request Oct 7, 2026
…#692)

Related: core-host-node 2a/5 (항상 켜진 노드에서 core 돌리기).
#664(병합됨, ed64668) 다음 layer입니다. base는 main입니다.

## Summary

core(`herdr-core`)는 결정과 상태만 갖고, 기계를 직접 만지지 않게 했습니다.
파일, 프로세스, Herdr 소켓, 세션 파일은 node의 일이고, core는 계약 하나(`NodeLink`, 새 crate
`hide-node-link`)로 node id를 지정해 묻습니다.
이 PR에서는 core 자신의 node(`hide_node::Local`, hided 프로세스 안)가 모든 호출에 답합니다.
화면과 동작은 바뀌지 않습니다.
- core가 하던 git, `gh`, hide-ai, 포트, agent sleep, kit, 세션 읽기, clone,
worktree, 문서 저장, 첨부, Herdr 연결이 `Call::*`로 node에 갑니다.
- 카탈로그는 경로를 직접 읽지 않고, 재빌드 전에 lock 밖에서 node에 한 번 묻습니다(`Call::PathFacts`).
새 프로젝트도 node가 만듭니다(`Call::ProjectCreate`).
- 링크 기록의 세션 파일 상태(있음/없음)도 node에 묻습니다(`Call::RealPaths`). node가 답하지 못하면
"알 수 없음"으로 둡니다.
- hided의 파일 열기(opener)와 pane 자격 증명의 커널 증거, bootstrap 소켓은 `hide-node`로
옮겼습니다.
- 탐색기 감시는 이 Mac과 device를 하나의 감시자로 합쳤습니다. 둘 다 node id로 그 node에
`Call::Stamps`를 묻습니다.
- `scripts/check-core-touches-no-machine.py`가 core의 운영 코드에서 기계 접근을 막습니다.
예외 파일마다 허용 개수를 적어 두어, 예외 파일 안에 새로 생긴 접근도 실패시킵니다. policy lane에서 돕니다.

```text
core(결정, 상태, 자기 저장소) --NodeLink(node id)--> node(파일, 프로세스, Herdr, 세션)
  이 PR: core 자신의 node만, 같은 프로세스 안에서 답함
  2b: SSH 위의 같은 계약, device helper가 hided node 역할로 합쳐짐
```

## Review

- **판단해 주세요**: 탐색기 감시를 "옮기기" 대신 "합치기"로 했습니다. 이 Mac의 핸들 polling을 지우고
device와 같은 stamp 비교로 바꿨습니다. 200 ms poll과 200 ms 묶음 창은 그대로입니다. 이 Mac의
root는 boundary가 등록 때 확인한 identity로 고정합니다(목록 읽기와 같은 identity). 그래서 같은
경로에서 바꿔치기된 root는 목록과 감시 모두 거절합니다. device root는 helper가 바꿔치기를 알리면 다시 열고
감시 폴더를 모두 한 번 알립니다.
- **판단해 주세요**: 카탈로그 행의 경로가 node의 비교 형태(실제 경로)입니다. 예전에는 pane에서만 보인 행이 이름
그대로(`/var/...`)였고, 등록 행만 실제 경로였습니다. 이제 둘 다 `/private/var/...`처럼 실제
경로입니다.
- **조심해서 볼 파일**: `herdr-core/src/session_sync/coordinator.rs`,
`runtime/session.rs` (high-frequency path, runtime mutex). 재빌드 전에 lock
밖에서 `PathFacts`를 묻고, 같은 경로 집합이면 30초 refresh까지 재사용합니다. coordinator가 카탈로그를
한 번 넘긴 runtime은 그 뒤 카탈로그 없이 들어온 session(닫기 상태 읽기 등)에서도 lock 안에서 node를
부르지 않고 마지막 답을 씁니다. coordinator가 없는 runtime(fixture, 첫 Herdr 응답 전)만 lock
안에서 자기 node에 묻습니다.
- **조심해서 볼 파일**: `herdr-core/src/live.rs` 프로젝트 생성 (failure path). 폴더와
`git init`은 node가 하고 실제 경로를 답합니다. 등록은 그 경로로 합니다.
- **조심해서 볼 파일**: `hide-project/src/lib.rs` (failure path). 저장소 안의 HEAD,
ref, 포인터 파일, config를 regular file로만, 링크를 따라가지 않고, pipe에서 막히지 않게 열고 크기
상한(포인터 64 KiB, config 1 MiB)을 둡니다. pane 안의 프로세스가 `.git/config`를 pipe로
바꿔도 카탈로그가 멈추지 않습니다.
- **조심해서 볼 파일**: `hided/src/watch.rs` (high-frequency path). 이 Mac 감시는
200 ms마다 in-process `Call::Stamps` 한 번(폴더 최대 64), device는 2초마다 한 번, 실패한
poll은 어느 쪽이든 2초 뒤에 다시 묻습니다. 답한 link는 poll 사이에 재사용해서 매 poll마다 core owner
thread를 거치지 않습니다.
- **조심해서 볼 파일**: `hided/src/env.rs` (failure path). 상대 경로
`HERDR_SOCKET_PATH`는 시작 때 `HERDR_SOCKET_PATH: invalid`로 거절합니다. 예전에는 연결은
됐지만 pane 증명이 조용히 checkout binding으로 내려갔습니다.
- **비용 검토**: 카탈로그 재빌드 1회당 node 호출 1회(경로 4,096개 단위), 경로 집합이 그대로면 30초에 1회.
lock 안에서는 node를 부르지 않습니다(테스트가 호출 수 0을 확인). 감시는 대기열 없이 직전 답을 기다린 뒤 다음
poll을 합니다.
- **조심해서 볼 파일**: `herdr-core/src/worktrees.rs` Git watch (high-frequency
path, failure path). 감시 대상이 바뀌면 새 감시를 시작하되, 새 감시가 `Watching`을 알릴 때까지 옛
감시를 유지해 두 집합에 모두 있는 저장소는 감시가 끊기지 않습니다(main은 저장소마다 watch/unwatch해서 틈이
없었습니다). 감시가 끝나거나 시작하지 못하면 30초 뒤 다시 시작하고, 다시 감시가 시작되면 모든 프로젝트를 한 번 다시
읽습니다. 시작 실패는 매번 다시 묻지 않고 30초 간격으로 다시 시도합니다.
- **조심해서 볼 파일**: `hide-node-link/src/protocol.rs` (snapshot wire 아님,
node 프로토콜). 2a가 node 호출 38개를 더해서 `PROTOCOL_VERSION`을 22로 올렸습니다(main의
#656이 공유 서버 끄기로 21을 먼저 썼습니다). 이 빌드의 helper를 아직 받지 않은 device는 Hello에서
거절되고, 새 payload의 digest가 달라서 다음 연결에서 새로 설치됩니다.
- **B1 예외로 적은 테스트 수정**: 이미 있던 테스트
`a_commit_in_one_project_does_not_rerun_status_in_another`,
`moved_remote_ref_refreshes_one_project_once_after_a_burst`,
`idle_and_working_tree_edits_do_not_reread_but_manual_refresh_does`와
helper `changes_before_sentinel`을 고쳤습니다. 저장소를 만들 때의 Git
쓰기(`symbolic-ref`)와 sentinel 자신의 늦은 쓰기가 감시 시작 뒤에 도착해 측정에 섞였기 때문입니다.
단언(프로젝트별 `git status` 횟수 1과 0, `behind_upstream`)은 그대로이고, 측정 전에
sentinel로 정리하고 이미 시작된 읽기를 기다립니다. main의 고치지 않은 테스트에도 같은 경쟁이 있는지는 돌려보지
않았습니다(같은 `Repository::new` 구조라서 있을 것으로 추정).
- **질문**: hided에 남긴 것은 자격 증명 registry(`pane_auth.rs`, 증명은 이 프로세스에서
`hide_node::pane_proof`로 읽음)와 감시자 스케줄러(`watch.rs`)입니다. registry는 layer
4에서 node 역할 hided가 link로 보내는 증명을 받도록 바꾸려 합니다. 괜찮을까요?
- **질문**: 파일 열기의 안전 규칙(`server.rs::openable`, 실행 파일과 handler가 실행하는 파일
거절)은 hided의 open handler 곁에 남았습니다. 그 handler는 main에서 이미 연결되지 않은
코드(`#[allow(dead_code)]`)라서, 연결하는 변경이 규칙을 launcher 곁으로 옮기도록 문서에 적었습니다.
- **질문**: core에 남은 기계 접근은 check에 이유와 개수로 적었습니다. SSH 전송(`remote.rs`,
`remote/`, `ssh_hosts.rs`)은 2b, terminal attach child(`live.rs`)와 첨부는
layer 3, label generator lock은 layer 4입니다. AI 선택
파일(`hide_ai::settings`)은 core 저장소로 두었습니다.
- **알려진 예외**: main이 이 PRD 뒤에 넣은 Software Factory 엔진은 이 PR 뒤에도 core의 기계에서
직접 일합니다. runner(`hide_factory::exec`, 경계 check가 이름으로 금지)가 git,
`gh`(issue와 pull request 만들기, merge, rerun, `gh::allowed`가 덮지 않는 호출), 확인
명령(`/bin/sh -c`)을 돌리고, 버리는 Task의 worktree는 node의 확인된 삭제 대신
`hide_host::worktrees::remove_worktree`로 강제 삭제하고 `branch -D`합니다. 남은 디스크와
자기 실행 파일 위치도 직접 읽고, `hide-factory` crate는 프로젝트 파일(guide, `package.json`,
`Makefile`)을 스스로 읽습니다(check가 보는 폴더 밖). 모두 main의 동작 그대로이고, `factory.rs`를
LATER_LAYERS에 2b 항목(15)으로 적었습니다. 2b가 이것을 모두 core 자신의 node로 옮기고 항목을
지웁니다(Observer 결정). `docs/ARCHITECTURE.md`에도 적었습니다. 이 PR에서 node로 가는 것은
Factory의 AI 판단(`factory_router`)과 worker pane 닫기입니다.
- **main과 달라진 동작**: Factory의 판단 thread는 core가 사라지면(`Weak` upgrade 실패)
끝납니다. main은 홈의 AI 선택을 읽어 판단을 계속했지만, 답을 받을 core가 없고 node도 core가 줍니다.

## Evidence

- **확인한 것**: `sasu implement verify` PASS on 98b6440(지금 head). S1 Rust
전체 suite, S2 lint, 격리 HOME과 긴 TMPDIR.
- **확인한 것**: CI 전 lane 통과 on 5edb1b8(98b64402는 진행 중)(rust workspace,
windows check, os contract 3종, web e2e linux 4/4, windows e2e, desktop
e2e, package linux/windows).
- **확인한 것**: 로컬 web e2e 205/206(새로 빌드한 hided, load 20 아래). 남은 1건
`agents-tab.spec.ts:46`은 이 Mac에 Homebrew로 설치된 OpenCode가 login shell
PATH로 보여 "Installed 5"가 된 환경 차이입니다. 이 PR은 agent
탐지(`hide-kit/src/agents.rs`, `hide_platform::programs`)를 바꾸지 않았고 CI에서는
통과합니다.
- **확인한 것**: Rust workspace nextest 2832/2833(load 15에서 19). 남은 1건
`opener_lifecycle acceptance_timeout`은 테스트 안의 경쟁(2초 수락 창과 가짜 helper의 pid
기록)으로, 단독 5/5 통과, 코드는 그대로 옮겼고 #664 tree에서도 같은 실패를 봤습니다.
- **확인한 것**: Git watch 테스트의 간헐 실패 2종은 flake로 두지 않고 테스트를 고쳤습니다. sentinel
자신의 늦은 쓰기가 기준선에 섞인 것(d3eb073), 저장소 준비 때의 ref 쓰기(`symbolic-ref`)가 감시 시작
뒤에 도착해 다른 프로젝트 읽기를 먼저 깨운 것(5edb1b8, 측정 전에 sentinel로 정리). 고친 뒤 worktree
behavior 테스트 전체 stress 30/30, Git watch 3건 40/40(고치기 전 1/24 실패). main의
`codex_trust` 시간 초과 1건(load 34에서 41)은 이 PR이 바꾸지 않은 테스트입니다.
- **확인한 것**: lock 안에서 node를 부르지 않음.
`reconciling_with_a_precomputed_catalog_runs_no_git`가 세는
node(`CountingNode`)로, 카탈로그를 받은 뒤 카탈로그 없는 session까지 호출 0을 확인합니다.
- **확인한 것**: 링크로 들어간 checkout 아래 중첩 worktree를 구분하는 테스트는 예전 동작으로 되돌리면
실패하고 지금 통과합니다. 바꿔치기된 root 거절(boundary identity), 상대 socket 거절, pipe와 큰
config 거절, 세션 파일 상태(있음, 없음, 알 수 없음)를 단위 테스트합니다.
- **확인한 것**: 경계 check가 심어 둔 위반, 예외 파일 안의 새 접근을 잡고, 이유가 사라진 항목을
실패시킵니다(`scripts/tests/test_core_touches_no_machine.py` 7건). clippy `-D
warnings`, fmt, design contract 통과.
- **확인한 것**: `PathFacts` 비용: 실제 worktree 경로 24개(저장소 1개)에 p50 2.8 ms, p90
3.1 ms, 최대 9.1 ms(debug 빌드, load 21에서 24).
- **확인한 것**: 저장소의 `HEAD`와 config가 링크여도 main처럼 따라가 읽습니다(regular file,
비차단, 크기 상한은 유지). `a_linked_head_and_config_are_read_through_the_link`.
- **확인한 것**: Git watch 인계와 끊긴 뒤 다시 읽기를 가짜 node로 단위
테스트합니다(`a_git_watch_restarted_after_it_ended_rereads_every_project`,
`a_change_while_the_watched_set_changes_is_kept`).
- **확인하지 못한 것**: 유휴/구동 측정은 2b에서 옮긴 reader와 함께 냅니다.
`moved_remote_ref_refreshes_one_project_once_after_a_burst`가 다른 세션이 빌드하던
중 섞어 돌린 stress에서 1/20 한 번 15초 hang guard에 걸렸습니다. 어느 대기였는지는 남기지 못했고, 그 뒤
섞어서 40/40, 단독 30/30입니다.
- **후속(2b)**: `RealPaths`의 상대 경로 하나가 묶음 전체를 실패시키는 것, `LinkAnswer` Debug의
비밀 가리기, stdio serve의 역할별 호출 허용 목록, gh argv 정확 일치, git 인자 검증,
`Local::call` timeout, SSH link의 `call_with_progress`(진행과 취소가 있는 호출을
device에 보내기 전), 세션 읽기 호출의 경로 제한과 비차단 열기(main과 같은 동작), `PathFacts` 답 전체
크기 상한, Windows의 root identity 일치 테스트.
- **후속(나중)**: 경계 check가 signature 안의 `;`(예: `[u8; 4]`)에서 test 항목을 일찍 끝내는
것(실패가 크게 나므로 숨지 않음), `test_ci_plan.py`의 `EVERY_PACKAGE` 하드코딩.

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

- base: f422844 (#664 head, on origin/main 411f34a; `git merge-tree`
against origin/main f5a9fe8 clean), head: 0b7a250
- sasu verify: PASS on 0b7a250(S1 Rust 전체 suite 344.9s, S2 lint; round
5 고침이 동작을 바꿔서 전체 verify). 그 전 PASS: 98b6440. 0b7a2506에서 workspace lint
통과, Git watch와 reader 테스트 45/45, kit, protocol, Factory 테스트 92/92, 경계
check 테스트 8/8.
- sasu verify: PASS on 98b6440 (test 296.9s, lint 34.8s); earlier PASS
on 5edb1b8
- CI on 5edb1b8: all success (package macos skipped on PRs)
- local web e2e on 5edb1b8: 205 passed, 1 failed (environment: Homebrew
OpenCode on PATH), 38.4m
- reviews round 1 (e11296d4): Fidelity, Code, Security. Fix now 12건 처리:
watcher를 boundary identity로 고정하고 실패 시 2초로 물러남(11ea411), Windows unix
gate 2건(0c6ce78), 중첩 worktree를 최신 index로 읽고 lock 안 node 호출
제거(fc97795), 상대 socket 거절(6b193d2), Git 파일 읽기 상한과 비차단(4ce9d8b), 링크 파일
상태를 node에 묻고 check에 허용 개수(e497247, 2b3d36a), 문서 정정(58c3cce). 2b로 넘긴
것: stdio serve의 역할별 호출 허용 목록, gh argv 정확 일치, git 인자 검증, `Local::call`
timeout.
- reviews round 2 (6c7e832): Security 새 발견 없음. Fidelity: CI와 e2e 증거 요청,
이번 head에서 채움. Code: policy lane `test_ci_plan`(2b898fe), hide-host gh
테스트 unix gate(586528b), 쓰지 않는 `folder_stamps` 삭제(9664628), boundary
identity 테스트가 바꾸기 전에 stamp(df6fbc4), ARCHITECTURE의 저장소 파일 읽기
규칙(ea84dd1), Git watch 테스트 2건(d3eb073, 5edb1b8).

- reviews round 3 (5edb1b8): Security Fix now 없음. Fidelity Fix now 1:
고친 기존 테스트를 B1 예외로 기록(Review 절). Code Fix now 1: 측정 전 진행 중 읽기를
기다림(589e937). 받은 follow-up: 링크 HEAD/config(1e0a905), 대기 상한(589e937),
중복 gate 삭제(78356a5).
- /code-review 1회차 (5edb1b8), 8건: protocol 21(96b411a), Git watch 인계와
끊긴 뒤 다시 읽기(4508968), 시작 실패 재시도 간격(4508968), doc 위치(78356a5) 고침. 받지
않음: 탐색기 200 ms poll(main도 200 ms poll), SSH 취소(2a에서는 device로 안 보냄, 2b),
경계 check `;`(이전 회차와 같음), 세션 경로 제한(main과 같음, 2b).
- reviews round 4 (98b6440): Fix now 3건 처리. Git watch가 어느 감시에서 끊기든 다시
읽기를 한 번 빚지는 하나의 `owes_reread`(3aad696), Git watch 테스트는 읽기와 대기가 모두 끝난
뒤에만 정리(159706c), discovery가 regular HEAD만 받는다는 문서와 그 뒤 링크 읽기
테스트(41c4289).
- reviews round 5 (d278df4, round 4 고침과 main #656, #682, #724, #725 위로의
rebase): Fidelity Fix now 1, Code Fix now 3, Security Fix now 1 처리. 옛
Git watch의 overflow도 다시 읽기를 빚게 함(6e39a90, 고치기 전 실패하는 테스트),
`join_pending` doc 위치(7b1c446), 판단 thread의 동작 변화를 Review에 적음, Factory가
아직 직접 하는 일을 Review와 ARCHITECTURE에 적음(25e3e24). 받은 follow-up: 이름을 바꾼
runner 호출도 check가 잡음(fd1e21f), 이 기계의 공유 서버 끄기가 자기 node로 가는
테스트(94ce4d9, 막는 결함을 심으면 실패). 2b로: `hide-factory` crate 전체의 기계 접근과 store
개수 분리, Factory `gh` 쓰기와 느슨한 allowlist 정확 일치, search allowlist 테스트 위치,
Git watch `collect`의 한 pass 안 경쟁, 발견 뒤 링크가 된 HEAD 테스트.

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

공유 Codex daemon이 돌고 있으면 손으로 연 Codex에는 키트 설정이 적용되지 않는다

1 participant