Repository navigation
refactor: route the core's Herdr calls through one engine boundary - #1903
Merged
Merged
Conversation
herdr-core/src/engine/ holds the Engine trait the core asks for pane existence, layout, input, reads, agent starts and process facts, with one implementation, engine::herdr, which alone speaks Herdr's socket API, its generated wire types and hide-herdr-client. Every core module that took an ApiConnector now takes &dyn Engine or the SharedEngine the runtime holds. hided asks the same boundary off the owner thread through EngineHandle: a pane's proof before a credential (pane_auth), a phone's read and input, the idle probe, and a device's engine from the core. The local engine is built once with the core handle and shared by the core and hided. wire.rs and the Herdr contract constants move under engine/herdr/; outside the crate only engine::herdr::handoff (the four calls hided's Herdr handoff makes) is public, and inside it only tests may name wire.
scripts/check-engine-boundary.py fails when production code outside the engine's Herdr implementation holds a Herdr connection, names Herdr's wire types, uses hide-herdr-client or starts the Herdr program, and prints the file, the line and what to use instead. What may still speak Herdr is listed by file with its count and the bundle that deletes it. It runs in pr.yml's policy lane, premerge-check and check-hide-full.
The pin holds at v0.9.5 while Hide moves to its own engine, so the daily schedule of herdr-update.yml is off; the workflow stays for an upstream security fix, run from the Actions tab through the same checks. The provenance prose bump-herdr.sh writes says so.
Close capture and reopen move under recent_closed, the fork worker under fork, pane search and scroll under find, and owner tabs and project workspaces under checkout_owner. worktree_control, checkout_start and worktree_cleanup become the crate's own modules instead of children of live.
The suite makes a workspace, submits text and reads its output, opens a pane beside and a tab that runs a command, writes and clears Hide's metadata, closes a pane, and expects a refusal under a code and a stopped server reported as not running. The pinned Herdr runs it in the real Herdr steps on Linux and Windows.
EngineError::Unanswered replaces reading the transport's English prefix at each caller: the Herdr implementation decides it once, from the client's own reading, and the Engine trait promises it for a call that was sent and never answered.
This was referenced Oct 30, 2026
yansfil
added a commit
that referenced
this pull request
Oct 30, 2026
…nflicting branch by itself (#1908) Related: #1906 (fix/memory-press-feedback also touches the refusal shown on a row, including `branches_full`; merge-order: this stays alone and merges main once after #1906 and #1903) ## Summary `문서 고치기` and Memory's `N개 문서에 반영` no longer stop at `결정을 기다리는 브랜치가 5개예요`: a fix starts on its own branch from the base however many branches already wait. When `main에 합치기` or `main에 바로 올리기` is refused because the base moved and the branch conflicts with it (`merge_conflict`), Hide starts `다시 맞추기` itself, once per refusal, and the row shows `다시 맞추는 중` under 반영 중. When the remake is ready, Hide presses the same merge once more by itself, since the operator already asked for it; the row reads `합치는 중` and folds as any merge does. Only a second refusal, or a remake that made no commit, stops for the operator with `다시 시도`; the hand `다시 맞추기` button is gone. This replaces PRD hide-ai-branch-first-apply D-17 and B28 (operator decision 2026-10-31: "컨플릭트 나면 고쳐서 하면 되는 거 아닌가").  ## Review - **판단해 주세요**: the remade branch is merged without anyone reading the agent's conflict resolution (lead's decision: the press already asked for the merge). - **판단해 주세요**: which merge a remake finishes lives in memory only; after a restart the remade branch waits for a press rather than adding a store field and a Memory schema migration. - **조심해서 볼 파일**: `herdr-core/src/runtime/suggestion_apply.rs` - failure path: the refusal and then `LineAction::Rebase` go to the worker in that order, so the refusal is recorded before the remake begins. - **조심해서 볼 파일**: `herdr-core/src/runtime/memory_branch.rs` - failure path: a merge decision now prepares a rebase start under the lock (`promotion_start`); on `merge_conflict` the decision worker restarts the batch with `BatchPurpose::Rebase` instead of writing the refusal, and writes the refusal when no card restarts. - **조심해서 볼 파일**: `herdr-core/src/runtime/memory_branch.rs` `finish_remade_batches` - runs on each Memory read; it fires only after the batch was seen running, so the old ready rows of a stale read are never merged. - **조심해서 볼 파일**: `contracts/snapshot-wire-enums.json`, `herdr-core/src/model.rs` - snapshot wire: `suggestion_hold` loses `branches_full` and the Memory snapshot loses `branches_full`; the shell already treated it as optional. - **비용 검토**: no cap was added (principle 15). Running remake agents are bounded only by refusals, and each refusal is one operator press; nothing loops, since a remake that conflicts again needs another press. A cap on concurrent Hide AI agents per Project would be the real bound if one is wanted; this PR does not invent one. ## Evidence - **확인한 것**: core test `a_merge_that_conflicts_with_the_base_starts_the_remake_itself` on a real git repo: a conflicting merge refuses with `merge_conflict`, exactly one `LineAction::Rebase` follows, and once the remade attempt is ready main fast-forwards to the remade tip with no second press. - **확인한 것**: core test `a_remade_branch_that_conflicts_again_waits_for_the_operator`: a remake that still conflicts is refused once, no second remake starts, and a later ready attempt moves nothing. - **확인한 것**: `bash scripts/verify-cargo.sh lint` passed, and `verify-cargo.sh nextest -p herdr-core -p hided` ran 4228 tests, all passed. - **확인한 것**: `bash scripts/verify-web.sh` passed (web 264 files / 2311 tests, desktop 28 files / 302 tests, typecheck, lint, build); `node scripts/check-design-contract.mjs` passed. - **확인한 것**: gallery state `hide-ai&state=remaking` (dark, ko, 420 px) captured with headless Chromium: six ready branches, `AGENTS.md 고치기` still offered, and the remade row reading `다시 맞추는 중 1분`. - **확인하지 못한 것**: the Memory batch's automatic remake and its finishing merge have no test of their own (the decision worker needs a live Herdr spawn); they reuse the restart path `다시 맞추기` took and the operator's merge path. - **확인하지 못한 것**: no native run in the installed app; a real agent remaking a conflicting branch was not exercised end to end. <details><summary>Verification record</summary> </details>
yansfil
added a commit
that referenced
this pull request
Oct 30, 2026
…1899) ## Summary 에이전트 훅이 상태를 Herdr에 쓰고 hide가 그걸 다시 읽던 길을 없애고, 훅이 hided에 직접 보고합니다. 상태는 훅이 보고한 턴, 세션 파일, Herdr 순으로 판단합니다. Herdr의 상태는 세션에 훅 턴이 없을 때만 씁니다. 훅 턴은 같은 세션의 다음 훅 이벤트, 또는 그 턴보다 나중에 읽힌 세션 파일의 턴 끝(Claude Esc 중단 포함)까지 유지되고, 시간 기준은 없습니다. 권한 대기(Claude PermissionRequest와 Notification, Codex PermissionRequest, OpenCode permission)는 waiting 턴으로 보고됩니다. hided가 없으면 훅은 2초 안에 끝나고, 실패는 화면 경고 없이 `last-report-failure.json`과 진단 로그에 남습니다. 스크린샷 없음: 화면 코드 변경 없음 (`web/src`, `site/`, `design/`을 건드리지 않음) ## Review - **판단해 주세요**: 에이전트별로 남은 빈칸입니다. 각 항목은 다음 훅 이벤트나 Herdr 상태가 메웁니다. - OpenCode 2, Pi, omp는 권한 대기를 보고하지 않습니다(훅 이벤트가 없음). - Grok과 Antigravity는 사용자 중단(interrupt)을 보고하지 않아, 중단 뒤에도 working으로 남다가 다음 이벤트에서 바뀝니다. - Claude의 권한 대기는 턴이 아니라 호출 단위로 둡니다. `PermissionRequest`가 가리킨 호출(도구 이름과 입력 digest, 키 순서 무관)마다 열린 승인을 두고, 하나라도 열려 있으면 행은 '나를 기다림'입니다. 그 호출이 끝나거나 세션 파일에 결과가 적히면 닫힙니다. 서브에이전트가 연 승인도 같습니다. 메인 Stop은 턴만 끝내고 열린 승인은 그대로 둡니다. Claude 2.1.314는 Agent를 백그라운드로 돌리고, 서브에이전트 이벤트도 메인 session_id로 옵니다(검증 로그로 확인). 프롬프트와 중단은 열린 승인을 모두 닫습니다. 한 세션에 최대 16개입니다. - 대화창 거절은 훅 이벤트가 없습니다(`PermissionDenied`는 auto mode 전용). 두 곳에서 세션 파일의 결과로 승인을 닫습니다. helper는 다음 훅 이벤트(도구 호출이나 Stop)에서 파일 끝 256 KiB를 읽습니다. 코어는 Herdr 상태 변화마다 label worker가 이미 하는 읽기에서, 최근 64개 호출 중 키별 마지막 호출에 결과가 있는 키를 받아 승인보다 나중 seq일 때 닫습니다. 그래서 의견을 붙여 거절한 뒤 글만 쓰는 턴도 Stop 전에 working이 되고, 같은 명령을 두 번 부르면 둘째 호출의 결과를 기다립니다. 두 곳 모두 입력이 같은 호출만 봅니다. 백그라운드 서브에이전트의 호출은 메인 세션 파일에 없으니, 메인의 같은 도구 호출 결과로 서브에이전트 승인이 닫히지 않습니다. 세션 읽기가 중단(Esc)을 찾으면 턴과 함께 열린 승인도 모두 닫습니다. Mutex 아래 I/O는 없습니다. - 훅이 `updatedInput`으로 입력을 바꾸면 digest가 달라 그 호출의 끝이 대기를 풀지 못합니다. 세션 파일에 결과가 적힌 뒤의 다음 호출이나 Stop이 풉니다. - Claude에서 첫 출력 전에 Esc를 누르면 Claude 2.1.314는 프롬프트를 입력창에 되돌립니다. 세션 파일에는 프롬프트 기록과 훅 첨부만 남고, 에이전트 기록, 중단 기록, Stop, Notification은 없습니다(로컬 세션 파일에서 확인, 다시 보낸 프롬프트는 같은 `parentUuid`). 그래서 Claude 읽기에서 프롬프트 뒤에 에이전트 기록이 없는 턴을 `Unanswered`로 읽습니다. 훅 턴보다 나중 seq에서 Herdr가 at rest로 읽을 때 그 턴을 쉼(idle)으로 끝냅니다. 시간 문턱은 없습니다. 출력이 있었던 턴에는 적용되지 않습니다. 생각만 하고 아무 기록도 쓰기 전인 턴에서 Herdr가 at rest로 읽으면 잘못 끝날 수 있습니다. 다음 훅 이벤트가 working으로 되돌립니다. - hided 재시작: 열린 승인은 코어 메모리에만 있습니다. 재시작 뒤 아직 열린 대화창은 그 세션의 다음 훅 보고 전까지 세션 파일과 Herdr로 판단합니다. - 서브에이전트가 자기 대화창에서 거절하면 결과는 서브에이전트 자신의 파일에 적힙니다. 메인 세션 파일에는 없으므로 이 승인은 메인의 다음 프롬프트나 중단(Esc)까지 열려 있습니다. 후속으로 서브에이전트 자신의 세션 파일까지 읽으면 메울 수 있습니다. - 빠른 재시작: 새 세션이 이미 보고한 뒤에 Herdr가 끝난 세션의 id를 처음 말하면, 그 말이 더 새것으로 읽혀 새 세션의 턴은 다음 훅 이벤트부터 보입니다. - Claude의 `PreToolUse`와 `PostToolUse`는 매처가 없어 모든 도구에서 돕니다. Codex의 매처는 그대로라 Codex에서 MCP 도구를 승인하면 다음 셸, 질문, 파일 도구나 Stop까지 waiting입니다. - 같은 pane에서 다시 띄운 에이전트: Herdr가 낡은 세션 id를 말하고 그 id로 보고한 세션이 없으면, Herdr가 id를 바꾼 뒤 마지막으로 보고한 세션을 따릅니다. 대화형 세션의 훅이 한 번도 보고하지 않았는데 같은 pane의 `claude -p`가 보고했다면 그 턴이 보일 수 있습니다. - Herdr가 pane을 넘긴(handoff) 뒤에는 엔진이 pane에 에이전트가 없다고 알릴 때 사실이 지워집니다. - Codex 공유 서버처럼 pane에 묶이지 않은 호출은 `agent_pane_required`로 거절됩니다. - **조심해서 볼 파일**: - `herdr-core/src/agent_hooks/facts.rs` - runtime mutex 밖의 자체 잠금, 저장은 `LatestFile`; 첫 실행에 pane 파일에서 한 번 시드합니다. - `herdr-core/src/sidebar.rs` - 축 판단 순서(hook -> session file -> Herdr)가 바뀐 자리. - `hided/src/hook_request.rs`, `hided/src/cli.rs` - pane 증명 요구와 failure path(거절도 JSON으로 답함). - `herdr-core/src/agent_hooks/facts.rs`의 `end_by_session_read`와 `bound` - 세션 파일 턴 끝이 훅 턴을 끝내는 조건(그 턴이 처음 놓인 Herdr seq보다 나중의 읽기, Herdr는 idle/done), 그리고 낡은 Herdr 세션보다 훅 세션을 따르는 조건. - `hide-agent-hooks/src/bin/hide-agent-hooks.rs`의 `report_recorded_turn`과 `run_prompt_hook` - prompt 보고를 바깥 프로세스로 옮김. 안쪽 프로세스가 예산에서 잘려도 결과가 남음. 바깥 프로세스가 stdin을 먼저 읽어 그 세션으로 보고하고, 같은 바이트를 안쪽 프로세스 stdin으로 넘김(`--payload truncated|unread`로 읽기 결과 전달). 그래서 pane에서 마지막으로 보고한 `claude -p` 세션에 붙지 않음. - `hide-session/src/turns.rs`의 `TurnMark::Prompt`, `TurnMark::Reply`, `TurnEnded::Unanswered` - Claude 읽기만 응답 기록을 표시하므로 다른 에이전트 턴은 Unanswered가 되지 않음. `herdr-core/src/agent_hooks/facts.rs`가 이를 쉼으로 끝냄. - `hide-node-link/src/protocol.rs` - main의 64(PR 리뷰 상태)와 겹쳐 이 PR의 기기 훅 보고를 NodeLink 65로 올림(`docs/ARCHITECTURE.md` 함께). - `hide-agent-hooks/src/counters.rs`의 `Said`와 `fold_said` - 턴과 열린 승인 집합을 pane 파일 잠금 아래에서 한 번에 바꿈(병렬 훅이 서로 덮지 않게). `hide-session/src/calls.rs` - 호출 키와 세션 파일 결과 읽기를 helper와 세션 읽기가 함께 씀(helper가 hide-session에 의존하게 됨). - `herdr-core/src/agent_hooks/facts.rs`의 `close_answered_waits` - 보고의 `waiting`과 세션 읽기의 `answered_calls`로 승인을 닫음. - `hide-host/src/panes.rs` - 기기 pane 다리가 거절을 호출자에게 답하기 전에 먼저 기록하게 순서를 바꿈. remote mailbox 레인의 `node_contract::a_device_pane_s_proof_crosses_the_link_and_its_refusals_are_reported`가 31640faa7에서 두 번 연속 실패한 원인입니다. 테스트가 busy 답을 읽고 대기 연결 16개를 닫으면, 그 닫힘 기록이 busy 기록보다 먼저 들어갔습니다. - 엔진 경계: main의 #1903 병합 뒤 hook token restorer용 `hook_token_link`/`hook_token_connector`를 지웠고, `scripts/check-engine-boundary.py`의 임시 허용 항목 세 개(hook_tokens.rs, report.rs, hide-agent-hooks.rs)도 지웠습니다. - `hide-agent-hooks/src/report.rs`의 `deadline` - 보고 deadline을 훅 시작 기준으로 하고, entry가 쓰는 `install::hook_timeout`에서 0.5초를 뺀 안쪽으로 묶음(Codex Interrupt 3초). - `hide-agent-hooks/src/opencode/plugin.js`, `tui.js`, `pi_extension/extension.js` - 턴 보고를 합쳐 보냄(진행 중 하나, 대기 중 최신 하나). - **엔진 노드 CI allowlist**: `hide-agent-hooks/src/report.rs`의 Herdr 호출과 `herdr-core/src/coordination/hook_tokens.rs`(Restorer)를 지웠습니다. 둘 다 엔진 노드의 allowlist에 있습니다. - **비용 검토**: - Claude는 이제 모든 도구 호출의 시작과 끝마다 helper를 한 번씩 실행합니다(예전에는 셸, 질문, 파일 도구만). helper는 pane 파일 하나를 읽고, 그 호출이 턴을 working으로 되돌릴 때만 `hide` 프로세스를 하나 띄웁니다. - 턴을 말하는 다른 이벤트(prompt, Stop, 권한, 알림, 중단)는 매번 `hide` 하나로 보고합니다. 세션 시작과 서브에이전트 수 변경도 같습니다. - 코어는 보고 하나에 사실 한 칸을 바꾸고, 바뀐 경우에만 저장하고 다시 게시합니다. 같은 보고가 반복되면 게시 요청이 없습니다(런타임 테스트로 확인). - 세션 파일 읽기(Claude Esc로 턴이 끝나는 근거)는 에이전트 라벨 설정과 무관하게 돕니다. 라벨을 끄면 분석과 AI 필드만 빠지고, label worker는 Herdr 상태가 바뀔 때마다 세션을 읽어 사실을 올립니다(`labels::tests::an_interruption_is_read_from_the_session_file_with_summaries_off`, `runtime::tests::labels::a_hook_turn_ends_on_the_session_files_interruption_with_summaries_off`). - helper의 세션 파일 꼬리 읽기(거절 확인)는 세션이 이름 붙은 호출을 기다리는 동안의 도구 이벤트에서만 돕니다. 평소 도구 호출에는 없습니다. 코어가 아닌 helper 프로세스 안에서 돌고 256 KiB로 묶입니다. - 이 읽기는 고빈도 경로가 아닙니다. label worker의 읽기 스레드에서 Herdr 상태 변화 한 번에 한 번 돌고, 훅 보고나 tick마다 다시 읽지 않습니다(기존 `no per-tick reread` 테스트). 이번 PR은 새 읽기를 더하지 않았고, 이미 읽던 기록에서 턴 끝 표시를 하나 더 꺼냅니다. - `Mutex<Runtime>` 아래에서는 파일 I/O가 없습니다. 읽은 결과는 잠금 밖에서 만든 overlay로 넘어오고, 잠금 안에서는 그 읽기의 Herdr seq와 훅 턴의 seq를 비교하는 일만 합니다(`end_by_session_read`). ## Evidence - **확인한 것**: - `scripts/verify-cargo.sh lint`, `scripts/verify-cargo.sh test` 통과. - `scripts/verify-web.sh web typecheck`, `web lint` 통과. - e2e: pane-connection, opencode-plugin, pi-omp-extension, grok-cursor-hooks, direct-prompt-observation, agents-follow-herdr 통과(실제 고정 Herdr와 후보 hided). - B13(디버그 빌드, hided 없음, 부하 평균 49): SessionStart 0.45-1.65 s, Stop 0.43-1.59 s, PermissionRequest 0.43-1.13 s. 첫 실행이 가장 느림. - 실패 기록: `{"event":"PermissionRequest","error":"unavailable",...}`. 화면 경고 없음. - 훅 하나당 프로세스 비용: 턴을 말하는 이벤트는 `hide` 프로세스 1개(디버그 약 0.13 s, 부하 없을 때), 도구 이벤트는 0개. - Claude 모든 도구에서 helper 실행(디버그 빌드, 30회씩, 부하 평균 52): Grep PreToolUse 중앙값 21 ms(p90 39), Grep PostToolUse 19 ms(p90 32), 결과 300 KiB인 Read PostToolUse 25 ms(p90 67). `hide` 프로세스 0개. 잘린 Read 결과는 `format` 진단을 남기지 않음. - 검증 1회차 지적 고침: Claude Esc(세션 파일 `[Request interrupted by user]`, 2.1.314 실제 파일에서 모양 확인, 어댑터 계약 테스트), 같은 pane 재시작(런타임 테스트), 병렬/서브에이전트 호출이 대기를 지우던 것(헬퍼 통합 테스트와 단위 테스트), 사라진 prompt 보고(바깥 프로세스가 보고하고 모든 실패를 `report.failed` 로그 줄로 남김), Codex Interrupt 타임아웃 3초. - B10 런타임 테스트 `a_waiting_hook_report_reaches_the_row_as_an_approval_until_the_turn_runs_again`: Waiting 보고, 재게시 요청, 행 `approval`/`stopped`(Herdr는 working), 같은 보고 반복 시 요청 없음, Working 보고 후 `none`/`working`. - B19: `agent journey` 워크플로를 fake model로 직접 실행(run 41060503507). linux, macos, windows 각각 7개 에이전트 x 12칸 통과(Grok `guidance_memory`는 N/A). 각 행은 일하는 중을 읽고 답 뒤에 쉬는 상태를 읽음. 격리된 Herdr 0.9.5와 후보 hided. - **확인하지 못한 것**: - '나를 기다림'의 실측: journey의 에이전트는 승인 없이 돌아 권한 대기가 생기지 않습니다. 이 상태는 런타임 테스트, sidebar 테스트, e2e(opencode permission)로만 확인했습니다. - Codex `Interrupt`가 실제로 오는지는 실행으로 확인하지 못했습니다. `PermissionRequest`는 격리 검증에서 0.166.0이 실제로 보냄을 확인했습니다. - 첫 권한 대기에서 0.27초 만에 working으로 돌아간 1회 관찰은 그 실행에 호출 로그가 없어 원인을 확인하지 못했습니다. 병렬 호출과 서브에이전트 호출이 대기를 지우는 경로는 막았습니다. - 로컬 macOS에서 서명된 에이전트로 실행한 journey: 실행하지 않음(부하 평균 49-135, 디스크 여유 6-8 GiB).
yansfil
added a commit
that referenced
this pull request
Oct 30, 2026
…pane (#1910) Related: PRD session-docs-and-assistant (Desk 1차) B25, B26, B27, B29 · #1902 (thread reader) · #1907 (Desk screen parts) ## Summary Desk가 띄운 세션 하나를 스레드로 보이고, 스레드 입력칸의 말을 그 pane에만 넣습니다. 코어가 pane 하나의 스레드를 열면 그 세션이 도는 기기의 node가 잠금 밖에서 기록을 읽고, 세션이 일하는 동안 새로 쓴 부분만 다시 읽어 snapshot에 둡니다. 화면(`ThreadPanel`)은 #1907의 확정 부품 위에 store를 이어, 머리 둘째 줄에 Hide가 띄울 때 고른 모델을, 대화 안에 `hide` 명령이 만든 Hide 부품(계획, 새 세션, 편지, View, 미션)을, 받은 편지는 `✉ 보낸 이에게서 받음` 한 줄로, 도는 명령은 `실행 중 0:12`로 그립니다. 스레드가 이름을 부르는 세션은 코어가 페이지를 만들 때 지금 등록으로 pane을 찾아 두므로, 칩을 누르면 그 세션으로 갑니다(끝난 세션은 이름만). 기록을 못 읽으면 이유 한 줄과 `터미널로`가 보이고, 입력은 Enter로 보내며(IME 조합 중엔 안 보냄) pane이 받을 때까지 말이 칸에 남고, pane이 다른 세션으로 바뀌었거나 없으면 보내지 않고 이유를 보입니다. 보내기 직전(첨부 준비, pane 허락을 받은 뒤)에 pane을 한 번 더 확인하므로, 기다리는 사이 pane이 바뀌면 아무것도 치지 않습니다. 닫힌 스레드로 간 입력은 버리지 않고 `닫힘`으로 답해, 입력칸에 말이 돌아옵니다. #1907 재리뷰의 스레드 몫(hint ref, 질문 두 번, 접힌 줄 aria-label, 주석 두 곳)도 여기서 고쳤습니다. 화면이 놓일 자리(lane의 도구 칸)는 lane 노드가 붙이고, 지금은 갤러리 `scene=desk-thread`에서 store로 그려집니다.      ## Review - **판단해 주세요**: 입력은 터미널에 직접 친 것과 다릅니다(D-62). 에이전트가 bracketed paste를 켜 두면 Herdr가 말을 붙여넣기로 감싸므로, 긴 글이 Claude Code에서 `[Pasted text]` 덩어리로 보이고 줄바꿈은 제출되지 않습니다. attach와 PTY 크기를 건드리지 않으려고 고른 길이고 `docs/UI_BEHAVIOR.md`, Session thread에 적었습니다. - **판단해 주세요**: 스레드는 코어 전체에 하나만 열립니다(세션 기록과 같은 선례). 두 창이 다른 스레드를 열면 나중 것이 이깁니다. - **판단해 주세요**: pane이 바뀐 때의 말 "이 pane에서 이제 다른 세션이 돌아요. 이 스레드에서는 보내지 않아요", 없을 때 "이 세션의 pane이 없어요. 보낼 곳이 없어요". - **조심해서 볼 파일**: `herdr-core/src/runtime/session_thread.rs` - runtime mutex 안에서는 상태만 바꾸고 node 읽기, 페이지 만들기(Hide 부품, 이름 붙은 세션 찾기), activity 확인, 첨부 스테이징, `pane.send_input`은 모두 worker에서 돕니다. 입력 worker는 스테이징·permit·sleep gate를 지난 뒤 잠금을 한 번 더 잡아 `thread_input_target`(같은 generation, pane Same)을 보고, 잠금을 놓은 뒤 보냅니다. gate의 admission을 쥔 채 잠금을 잡지만, sleep 쪽 drain 대기는 잠금 밖에서 돌므로 서로 기다리지 않습니다. 열려 있지 않은 스레드로 온 입력은 request id로 `closed` 답을 받습니다. - **조심해서 볼 파일**: `herdr-core/src/coordination/mod.rs` - `registered_record`로 이름·agent id를 지금 등록에 맞춥니다(기존 resolve가 같은 함수를 씀). 페이지 worker는 ledger Arc를 잠금 밖에서 읽습니다. - **조심해서 볼 파일**: 입력은 엔진 경계(#1903)의 `delivery_engine(device).submit_text`로 보냅니다. 거절 코드 `not_found`는 `pane_gone`, 답이 없으면 `uncertain`(말이 들어갔을 수 있음), 그 밖은 `unavailable`입니다. - **조심해서 볼 파일**: `herdr-core/src/runtime/delivery.rs` - 관찰마다 thread 참조를 만들고 끝에 `follow_session_thread`를 부릅니다(Herdr 세션 읽기마다 도는 고빈도 경로, 열린 스레드가 없으면 즉시 반환). - **조심해서 볼 파일**: `hide-node-link/src/protocol.rs` - main이 65(기기 hook 상태)를 썼으므로 `Call::SessionThread`는 protocol 66입니다. - **조심해서 볼 파일**: `web/src/components/desk/thread-panel.tsx` - 보이는 동안 스레드를 열고 닫으며, 입력의 `request_id`로 보냄/거절을 맞춰 말을 지웁니다. `hided/src/server.rs`는 클라이언트가 보낸 `session_thread_input`을 경계에서 거절합니다. - **후속(리뷰 사소, 이 PR에서 안 고침)**: hided `handle_thread_input`이 첨부 stage를 commit한 뒤 코어가 거절하면(pane_changed 등) 커밋된 파일이 에이징 정리까지 남습니다(terminal attachment 선례와 같음). `delivery.rs`가 Herdr 세션 읽기마다 에이전트마다 `ThreadReference` 문자열을 복제합니다(session 필드와 같은 수준). - **비용 검토**: 스레드가 열려 있고 그 에이전트가 working일 때만 250 ms 틱이 1초마다 `SessionActivity`(크기와 시각) 하나를 띄웁니다. 바뀌면 뒤 페이지 하나(512 KiB 남짓)를 읽고, 끝이 그대로면 snapshot을 바꾸지 않습니다. 동시에 읽기 하나+빚 하나, 이전 페이지 하나, activity 하나, 입력 하나. 지난 페이지는 최대 4장. `docs/PERFORMANCE_TESTING.md` 원장에 적었습니다. - **원칙**: engineering #4·#10 거절은 이유 코드(`no_record`, `pane_changed` 등)로 화면에, 읽기 실패 세부는 진단 로그로. #5 세션 찾기는 코어(등록 원장), 그리기는 web adapter(`threadScreen`), 부품은 props만. #7 첨부는 기존 스테이징과 `terminal_attachments`를, 입력은 폰 답장의 permit·sleep gate를, 파일 고르기는 `Input` 부품을 재사용. #14 worker는 runtime을 weak로 잡고 호출 하나로 끝남. #15 페이지·요청·입력에 상한. design #5 #1907의 부품과 공용 칩을 그대로 씀, #9 읽는 중·못 읽음·막힘을 한 줄로, #13 node 연결 끊김은 `connected` false로 흐리게만, #12 한국어 글을 라이트·다크 캡처로 확인. ## Evidence - **확인한 것**: 실제 Herdr와 hided(`web/e2e/session-thread.spec.ts`, 4/4, repeat-each 3) - Pi pane의 기록이 스레드로 읽히고, 세션이 새 줄을 쓰고 Herdr에 working으로 보고하면 그 줄이 스레드에 이어지며, 입력 `계속해 주세요`가 그 pane에만 들어가고 다른 pane에는 안 감. - **확인한 것**: `bash scripts/verify-web.sh` exit 0 on 0a254f3 - web 2366, desktop 302, typecheck·lint·build; `node scripts/check-design-contract.mjs` ok. 그 안에 `thread-panel.test.tsx`(열고 닫기, Enter 보내기·IME 안 보냄·받을 때까지 말 유지, 거절 이유·pane 바뀜 막힘), `threadView.test.ts`(세션 칩 찾기, 계획 한 번, View·미션 부품), `desk.test.ts`(보낸 이별 편지 묶기, 명령 시작 시각, 질문 한 곳). - **확인한 것**: `cargo nextest` session_thread 12개 - newest 읽기 뒤 앞으로만 읽기, 512 KiB 페이지 보관, `no_record`, 이름 붙은 세션이 지금 등록의 pane으로 찾아짐, FakeHerdr로 입력이 그 pane에 한 번 가고 바뀐 pane에는 안 감, 기기 pane의 입력은 그 기기의 Herdr로. 입력 거절 셋: `input_to_a_gone_pane_is_refused_as_pane_gone_and_a_closed_pane_is_never_asked`(Herdr `pane_not_found`면 `pane_gone`, 닫힌 pane은 Herdr 요청 0), `input_whose_pane_changes_while_it_waits_for_its_permit_is_never_typed`(permit을 잡아 둔 사이 터미널이 바뀌면 Herdr 요청 0, `pane_changed`; 재확인을 빼면 실패함을 확인), `input_for_a_thread_that_is_no_longer_open_is_answered_as_closed`. protocol·node contract 16개, clippy `-D warnings`(herdr-core), fmt 통과. - **확인한 것**: `thread-panel.test.tsx` 5개 - 위 셋에 더해 다른 pane 스레드에 온 `closed` 답으로 말이 돌아옴, 위 끝 스크롤 세 번에 이전 페이지 요청 한 번, 상태가 바뀐 뒤에야 다시 한 번. - **확인한 것**: 갤러리 `scene=desk-thread` 4장면(live/asking/failed/held) 라이트·다크 캡처, 위 스크린샷. - **확인하지 못한 것**: 패키지 후보 앱에서 스레드 열기와 입력(화면이 놓일 자리가 lane 노드에서 생김). 기기 pane의 첨부 스테이징은 코드 경로만 있고 테스트 없음. 원격 코어에 node 데몬으로 붙은 화면의 스레드 첨부는 `unknown_stage`로 거절됨(말은 감), 문서에 적은 한계. <details><summary>Verification record</summary> - head: 0a254f3 (main merged at ecbfa34, origin/main 382b88c) - verify-web.sh: exit 0 on 0a254f3, web 2366 passed / 3 skipped, desktop 302 passed / 4 skipped - e2e: web/e2e/session-thread.spec.ts 4/4 (repeat-each 3) on bf4ef5b - cargo nextest session_thread: 12 passed (5 repeats); clippy -D warnings herdr-core; protocol/node_contract/hello filter: 16 passed </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
코어와 hided가 Herdr에 말하는 길을
herdr-core/src/engine/하나로 모았습니다. Herdr 연결, wire 타입,hide-herdr-client는 이제 엔진의 Herdr 구현 안에서만 씁니다.live.rs(7,401줄)에서 닫기, 다시 열기, fork, 찾기, owner 탭 로직을 각자의 모듈로 옮겨 엔진 호출만 남겼습니다(2,240줄).경계 밖에서 Herdr를 직접 부르면 새 검사가 파일:줄과 대신 쓸 것을 알려 주며 CI를 막고, 모든 엔진이 지킬 계약 테스트를 고정된 Herdr가 돌립니다.
Herdr pin 업데이트 워크플로의 매일 실행을 껐습니다. 자체 엔진으로 옮기는 동안 pin을 0.9.5에 고정하기 위해서이고, 손으로는 계속 돌릴 수 있습니다.
동작은 바뀌지 않습니다.
스크린샷 없음: 화면을 바꾸지 않는 내부 구조 변경입니다(
web/src,site/,design/변경 없음).Review
refactor: route the core's Herdr calls through one engine boundary-Engine트레이트, Herdr 구현, hided용EngineHandle; 호출자 교체. 가장 큰 커밋.ci: refuse Herdr spoken outside the engine boundary-scripts/check-engine-boundary.py와 등록(pr.yml, ci-plan, premerge-check, check-hide-full, CONTRIBUTING).ci: run the Herdr pin update only by hand-herdr-update.yml의 schedule 제거, 이유는 워크플로 머리 주석에.test: give the start fixtures the agent name every real start carries- 아래 판단 항목 참고.refactor: leave only engine calls in live.rs- 코드 이동과 경로 갱신만, 로직 변경 없음.test: hold every engine to one contract of observable results-engine/contract.rs와 CI 연결.id가 닫기, 다시 열기의 의도별 id 대신 메서드별 고정값(herdr-core:<method>)이 됐습니다. 요청마다 연결 하나라 응답 매칭에는 영향이 없습니다.agent.get한 번이 기대값에 들어갑니다.herdr-core/src/engine/herdr.rs- Herdr contract: 모든 요청이 여기서 wire로 바뀌고, 응답을EngineError종류로 나눕니다.herdr-core/src/engine/mod.rs- failure path: 호출자가 분기하는 거절, 형식 오류, 결과 모름 구분.hided/src/pane_auth.rs- 훅 요청 입구의 pane 증명. runtime mutex 없이EngineHandle로 shell pid를 묻고, 호출 모양은 그대로입니다.hided/src/core.rs-CoreHandle이 엔진을 한 번 만들어 코어와 나눠 씁니다.Evidence
scripts/verify-cargo.sh lint(fmt, clippy-D warnings) 통과,scripts/verify-cargo.sh test워크스페이스 전체 6,512개 통과, 0개 실패(157개는 외부 준비물이 필요해 ignored).pane_control_uses_the_official_socket_contract_for_every_mutation), 포커스 확인, 닫기(failed_tab_close_rechecks_membership_and_live_peers), 다시 열기(nested_split_reopen_applies_the_original_outer_and_inner_geometry), fork 여정, pane 증명, 폰 읽기와 입력 테스트가 같은 기대값으로 통과합니다.check-engine-boundary.py가 저장소에서 통과하고 단위 테스트 7개가 통과합니다. 경계 밖 위반, Herdr 실행, 데스크톱의 Herdr 경로, 허용 목록 초과와 낡은 항목을 잡습니다.check-herdr-release.py workflow,test_ci_plan통과.hided/src/hook_request.rs,hide-node-link/src/panes.rs)과의 충돌은 그쪽 머지 뒤 premerge-check가 말하는 대로 처리합니다.Verification record
scripts/verify-cargo.sh lint && scripts/verify-cargo.sh test: 통과scripts/verify-cargo.sh nextest -p herdr-core --lib -E 'test(/^engine::contract::/)' --run-ignored onlywith the pinned Herdr 0.9.5: 1 passed