Repository navigation
Finish the closing handshake when the daemon refuses a client - #844
Merged
Merged
Conversation
A command sends its request right behind its handshake. When the daemon refused that handshake it sent its close frame and dropped the socket with the request still unread, so the connection reset instead of ending. A reset can discard the close frame before the client reads it, which Windows does, and a command holding a reference the daemon never issued then reported hide_unavailable instead of falling back to a bare bootstrap (issue 785). On macOS the same refusal reset the connection in two of five tries. The refusal now reads what the client sent until its own close or the end of its stream, within the bound the send had. The reconnect test resumed from its first snapshot's revision, but a starting daemon publishes what its workers find about 230 ms and 2 s later, so a resume that crossed one read a moved revision (issues 773, 796). A resume that crossed a publication now resumes again from the cursor the first client applied with it, so the no-rest assertion at the current revision is checked on every run. Closes #785 Closes #773 Closes #796
yansfil
added a commit
that referenced
this pull request
Oct 9, 2026
Related: P5 OpenCode plugin #818 (이 PR이 그 위에 쌓은 플러그인 설치기와 helper), P6 session readers #804, Pi reader #826 (머지됨, 이 브랜치에 병합) ## Summary Pi와 omp 안에서 실행된 에이전트는 지금까지 Hide의 편지, 실행 가드, 하위 에이전트 수 없이 기본 지원(스킬과 Herdr 통합)만 받았습니다. 이 PR은 두 에이전트의 사용자 확장 폴더(`~/.pi/agent/extensions/hide.ts`, `~/.omp/agent/extensions/hide.ts`)에 Hide 확장 하나를 같은 원본으로 설치합니다. 확장은 pane 자신의 TUI 세션에 첫 프롬프트 안내와 대기 편지를 숨은 메시지(`display: false`)로 붙이고, 호스트가 그 메시지와 답을 기록한 뒤에만 편지를 확인합니다. 셸에서 Herdr로 에이전트를 직접 띄우려는 호출은 Claude Code 훅과 같은 사유로 막고, omp에서는 서브에이전트 수를 Herdr에 보고하고 Factory 작업자의 `ask`를 Factory 질문 가드에 넘깁니다. OpenCode 플러그인의 파일 처리는 세 파일이 함께 쓰는 소유 스크립트 파일(`hide-agent-hooks/src/plugin.rs`)로 일반화했고, 세션 한도는 세션 파일 경로를 담도록 한 규칙(4096바이트)으로 모았습니다. 그래서 설정의 Pi와 omp 행에서 `기본` 칩이 사라지고(PRD D-10, B1), P6의 Pi 세션 읽기와 합쳐진 Pi 행은 켜져 있으면 `Ready` 또는 `N sessions`를 보입니다. 벨은 두 에이전트 모두 꺼 둔 채이고, Memory는 P6의 omp 세션 읽기까지 머지된 뒤 따로 들어갑니다. ## Review - **판단해 주세요**: 확장은 Herdr pane 환경 변수만 보고 동작합니다(Hide 데몬이 그 Herdr를 소유하는지는 묻지 않음). PRD D-02/B11은 "Hide가 관리하는 pane"이라 쓰지만 Claude Code, Codex CLI 훅과 OpenCode 플러그인이 이미 같은 방식이라 맞췄습니다. 데몬이 없으면 helper가 `{}`를 답합니다. - **판단해 주세요**: OpenCode 동작 변화 하나. main의 hided는 `factory_question_guard`에서 `claude-code`와 `codex`만 받아 OpenCode의 질문 가드 요청이 wire에서 거절됐고, 그래서 Factory 작업자의 질문이 그대로 보였습니다. 이제 질문 도구를 선언한 모든 런타임을 받으므로 OpenCode 작업자의 질문도 설계대로 막힙니다. - **판단해 주세요**: 화면 변화. 어댑터 규칙(`basic()` = 프롬프트 받기나 실행 거절 중 하나라도 없음)에 따라 Pi와 omp는 `기본` 칩을 잃습니다. #818에서 OpenCode가 같은 규칙으로 바뀐 것과 같고 PRD가 정한 결과입니다. main의 설정 e2e 세 개(`agent-adapter-layer`, `agents-follow-herdr`, `agents-tab`)가 omp 칩을 기대해 CI가 실패했고, 기대를 새 규칙으로 고쳤습니다(이제 `기본`은 Grok과 Cursor뿐). - **판단해 주세요**: #811 병합 결과. `HookDialect`에 Pi, omp와 Grok, Cursor가 함께 있고, 기능 표는 두 쪽을 합쳤습니다(Grok, Cursor는 실행 가드와 하위 에이전트 수만, 편지는 없음, 그래서 계속 `기본`). Factory 질문 가드 wire는 이 PR의 4096바이트 세션 한도와 main의 `direct_ask_kind` 판정을 함께 씁니다(`claude-code`, `codex`, `opencode`, `omp`). - **판단해 주세요**: #826 병합 결과. Pi 선언은 이 PR의 hook, prompt_hook, spawn_guard와 P6의 session, sleep, fork, resume, conversation, titles를 모두 가집니다. Pi 세션은 `reports_turns`가 아니므로 편지가 턴 대기로 묶이지 않고, 확장이 쓰는 숨은 메시지(`role: custom`)는 Pi 리더에서 사람 입력으로 읽히지 않습니다. - **조심해서 볼 파일**: `hide-agent-hooks/src/pi_extension/extension.js` - 운영자의 Pi와 omp 프로세스 안에서 돕니다. 모든 콜백이 자기 예외를 잡고(omp는 타이머 콜백 예외로 세션이 끝남), 모든 helper 호출이 예산과 개수 상한을 가집니다. - **조심해서 볼 파일**: `hide-agent-hooks/src/plugin.rs`, `src/plugin/helper.rs` - 운영자 소유 폴더에 쓰는 코드이고 OpenCode와 공유합니다. OpenCode 파일의 바이트는 고정 테스트가 그대로임을 보입니다. - **조심해서 볼 파일**: `herdr-core/src/runtime/factory.rs`, `hided/src/server.rs`, `herdr-core/src/runtime/delivery.rs` - 세션 한도 256 -> 4096바이트(failure path). 해시 전에 길이를 검사합니다. - **비용 검토**: 셸 호출마다 `herdr` 문자열 검사 한 번, 그 문자열이 있을 때만 helper 1회(2.5초 예산). 프롬프트마다 helper 1회(1.85초), 확인 1회(2초). 동시 helper 8개, 출력 64KiB, 대기 항목 16개(10분), 하위 에이전트 64개 상한. 세션 종료 때 진행 중인 prompt, tool, start helper를 끊습니다. ## Evidence - **확인한 것**: sealed `verify-cargo.sh test`와 `lint` PASS(head a8996db). herdr-core, hided, hide-agent-hooks, hide-kit, hide-agent-adapter 전체 nextest 3585개 통과(#826, #811 병합 뒤). - **확인한 것**: Node 22+에서 생성된 확장을 실제 Pi 1.0.4, omp 18.7.0에서 잡은 사건 표본으로 재생: 밖에서는 등록 안 함, 숨은 메시지 모양, 답 뒤 한 번만 확인, 실패한 확인의 재시도, omp 재진입에서도 안내 유지, 예산, omp 수와 `ask`, 어떤 입력에도 예외 없음. - **확인한 것**: Playwright e2e(고정 Herdr 0.9.3, 격리 서버)에서 kit이 두 파일을 쓰고 Pi와 omp 대역 host가 이를 읽음: 양방향 편지와 기록 후 확인, 두 에이전트의 실행 거절 사유, omp 서브에이전트 수(Herdr 토큰과 snapshot), 서브에이전트 프롬프트에는 편지 없음. 확인 호출을 지운 결함을 심으면 실패함을 확인. - **확인한 것**: 실제 Pi 1.0.4와 omp 18.7.0 TUI를 pty로 띄워(비공개 HOME, 가짜 provider, 대역 helper) 확장 파일 그대로 실측: start, prompt, confirm 순서, 숨은 메시지가 세션 파일에 `display:false`와 `details.hide`로 남고 화면에는 그려지지 않으며 모델에는 닿음, omp TUI의 `ctx.mode`는 `tui`, Pi RPC 모드에서는 helper 호출 0. - **확인하지 못한 것**: 로그인된 에이전트로 한 실측. `scripts/agent-live-check.py --agents pi,omp`를 격리 Herdr에서 돌렸지만 두 에이전트 모두 `not_authenticated`였습니다. Pi는 startup 장면만 닿아 판정 `unsafe`(벨 뒤 비공개 설정 쓰기), rest는 시간 초과, 나머지는 건너뜀. omp는 모든 장면 건너뜀. 로그인은 하지 않았고 벨은 꺼 둡니다. - **확인하지 못한 것**: 실제 omp의 재진입과 실제 서브에이전트 수(합성 사건으로만), 사이드바 배지 표시(issue 810), 기기에서 도는 Pi와 omp, Windows(확장을 쓰지 않음), Memory(P6 뒤 별도 PR). - **확인한 것**: 고친 설정 e2e 세 개, `pi-omp-extension`, `opencode-plugin`, P6의 `session-readers`와 `link-graph`를 병합한 트리에서 로컬 통과. `pi-omp-extension`은 20회 중 1회 `native_identity_required`(코어가 pane의 세션을 아직 못 들음)로 실패해, 두 pane에서 `hide inbox`가 답할 때까지 기다리도록 고친 뒤 24회 모두 통과. - **확인하지 못한 것**: sealed 실행에서 `spawn_guard::a_pane_run_or_send_text_launch_leaves_the_name_and_intent_for_the_agent`가 한 번 빈 stdout으로 실패했고 단독 3회, 전체 binary 2회는 통과했습니다(이 PR이 건드리지 않은 테스트, `bell_intake`와 같은 부하 기한 부류). - **확인하지 못한 것**: sealed 실행 한 번에서 `bell_intake::a_prompt_that_only_starts_like_the_bell_is_an_operator_prompt`가 0.5초 payload 읽기 기한을 넘겨 실패했고, 단독과 이후 네 번은 통과했습니다. 같은 binary에서 두 Node 테스트가 동시에 돌던 것을 순서대로 돌게 바꿨습니다. <details><summary>Verification record</summary> - PRD: `agents/prd/pi-omp-extension/prd.md` (sha256 676a51347370bcc57965ce68ef407ee2585d2fdab6d3c30b64a5ce9ff7113f7d) - Base ba980fa → head a8996db, verified 2026-10-09T00:08:11.704Z: PASS - Verification report: `agents/runs/pi-omp-extension/verification-report.json` and `agents/runs/pi-omp-extension/verification-report.md`; source fingerprint af86a6093a02254b19bcf251c29d027666767d7cd5d857f3bd2d85198399727a - Suites: - S1: GREEN `bash scripts/verify-cargo.sh test` (exit 0) - S2: GREEN `bash scripts/verify-cargo.sh lint` (exit 0) - Reviews (advisory): - Fidelity, Code, Security on 274e824: Fix now = Factory 질문 가드의 256바이트 세션 한도(세 리뷰 모두), 확인 전 confirmed 기록(세 리뷰 모두), 준비 시점에 안내를 준 것으로 기록(Fidelity, Code), omp RPC를 pane의 루트로 셈(Security), 문서의 범위 과장(Fidelity). 모두 3236fdd, 95e9876, a301065, 4e5808444에서 고침. - Follow-up on 4e58084: 고친 8건 모두 닫힘, 새 코드 결함 없음; head에서 omp TUI 재실측, 치환 순서 테스트, 문서 한 문장 요청 -> 2ed0090f4에서 처리. - Follow-up on 2ed0090: 새 테스트의 rustfmt 위반 -> d5fbf81. - Follow-up on 37b60ff: fmt 닫힘, 두 Node 테스트를 순서대로 돈 변경은 결함을 가리지 않는 부분 완화, main 병합(#832)은 상호작용 없음; Fix now 없음. bell_intake는 `cargo test` 레인에서 재발할 때 issue로(그때는 부하에 기대지 않는 payload 기한으로 고침). - Follow-up on 1337720 (CI 설정 spec 수정): Fix now 없음; UI_BEHAVIOR 세션 수 문장과 AgentsTab 단위 테스트의 omp 모델링 -> da63cfd. - Follow-up on 27c8409 (#826 병합): Fix now = UI_BEHAVIOR의 Pi `Basic popover` 문장 -> 고침. 낡은 주석 둘, factory.md 작업자 문단, 단위 테스트 fixture도 함께 고침. 잠든 Pi 부모의 계보(경로 digest vs native id)는 P6 영역의 Follow-up. - Follow-up on 30d351f: Fix now = factory.md 작업자 문단이 Pi의 sleep과 OpenCode, Pi, omp의 다음 프롬프트 편지를 뭉갬 -> 54af6dc14에서 기능별로 나눠 고침, model.rs 주석도 실제 이유로. - Closure on 54af6dc: 두 항목 닫힘, Fix now 없음. - Follow-up on 428ac77 (#811 Grok, Cursor hooks 병합): Fix now 없음; 안 쓰는 `HookDialect::plugin()` 삭제, kit hook status와 질문 가드 parse 테스트에 Pi, omp 추가, 문서와 테스트 이름 정리 -> 32f9e2c. - Closure on 32f9e2c (+ main #842, #844 병합 a8996db): 닫힘, Fix now 없음. - Follow-up improvements: 잠든 Pi 부모 아래 자식의 계보가 깨어날 때까지 끊김(`SleepRecord`에 살아 있던 행의 계보 digest 보관), Herdr pane이면 Hide 데몬 여부와 무관하게 동작(OpenCode 플러그인과 같음), 다음 프롬프트 편지 pull이 pane 자신의 세션인지 코어에서 확인, 256KiB를 넘는 herdr 셸 명령, symlink로 된 hide.ts, Memory 전 프롬프트 본문 전달, 확장 미동작 에이전트의 편지 대기, CI 부하에서 Node 기동과 제품 예산의 경쟁. - Evidence: 13 registered (9 log, 4 file); paths are local to the run directory - agents/runs/pi-omp-extension/evidence/host-smoke/README.md - agents/runs/pi-omp-extension/evidence/host-smoke/pi-helper-calls.jsonl - agents/runs/pi-omp-extension/evidence/host-smoke/pi-session-hidden-entry.jsonl - agents/runs/pi-omp-extension/evidence/host-smoke/omp-helper-calls.jsonl - agents/runs/pi-omp-extension/evidence/host-smoke/omp-session-hidden-entry.jsonl - agents/runs/pi-omp-extension/evidence/host-smoke-tui/README.md - agents/runs/pi-omp-extension/evidence/host-smoke-tui/pi-helper-calls.jsonl - agents/runs/pi-omp-extension/evidence/host-smoke-tui/pi-session-hidden-entry.jsonl - agents/runs/pi-omp-extension/evidence/host-smoke-tui/omp-helper-calls.jsonl - agents/runs/pi-omp-extension/evidence/host-smoke-tui/omp-session-hidden-entry.jsonl - agents/runs/pi-omp-extension/live-check-1/report.md - agents/runs/pi-omp-extension/evidence/host-smoke-tui-head/README.md - agents/runs/pi-omp-extension/evidence/host-smoke-tui-head/omp-ctx-mode.txt - Changed paths: 64 (see Files changed) - Delivery: mode pr, branch `feat/pi-omp-extension`, base `main` </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.
Closes #785
Closes #773
Closes #796
Summary
hide_unavailable을 냈습니다.refuse가 close frame을 보낸 뒤 client의 close나 stream 끝까지 읽고 닫습니다(WebSocket closing handshake). 기존과 같은 10 s 상한 안입니다.Review
hided/src/server.rsrefuse- failure path: 13개 거절 경로가 모두 이제 client의 close를 기다립니다. 응답하지 않는 client는 10 s 상한까지 task 하나를 잡습니다.Evidence
BrokenPipe). 수정 후 5/5 정상 종료.a_refused_client_that_already_sent_its_request_reads_the_refusal는 main의refuse에서 실패하고 이 변경에서 통과합니다.a delta at the current revision has no rest로 실패하고, 새 테스트는 통과합니다.verify-cargo.sh test -p hided의 hided·herdr-core 테스트, lint 통과.hide-hostgit::a_registered_subfolder_keeps_its_history_without_exposing_siblings가 한 번 실패했고 단독 3회는 통과했습니다. 이 변경과 무관한 crate입니다.