Skip to content

Draw pane topology changes before Herdr confirms them - #743

Merged
yansfil merged 10 commits into
mainfrom
prd/instant-pane-topology
Oct 7, 2026
Merged

yansfil merged 10 commits into
mainfrom
prd/instant-pane-topology

Conversation

@yansfil

@yansfil yansfil commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #746

Related: PRD agents/prd/instant-pane-topology/prd.md · follow-up with-hide/hide-private#95 · flaky #728 #729 #731

Summary

  • split, pane 닫기, zoom/unzoom, 구분선 크기 조절, 새 탭이 Herdr의 레이아웃 확정을 기다리지 않고 바로 그려집니다; Herdr 레이아웃이 오면 그것으로 대체합니다.
  • PTY 크기는 Herdr가 geometry를 적용한 뒤에만 바뀌고, 그동안 터미널은 이전 grid를 유지합니다.
  • 새 탭과 split 직후 친 키는 새 pane으로 순서대로 가고, 여는 중인 pane의 입력은 pane당 64 KiB까지 보관합니다.
  • 보관된 키는 친 지 3초 안에 pane이 받을 수 있을 때만 들어가고, 더 오래된 키는 버리고 진단 로그에 pane id와 바이트 수만 남깁니다(운영자 결정).
  • Herdr 이벤트를 적용하는 스레드의 막히는 작업(새 socket 읽기와 cwd 재확인, lsof, codex usage HTTP, label fsync)을 worker로 옮겼습니다.
  • 운영자 규모 화면 p95, baseline -> candidate: split 1570 -> 55, 닫기 875 -> 35, zoom 1021 -> 34, 새 탭 1002 -> 68 ms.

커밋은 리뷰 단위입니다: 단계 기록(D-14), 새 탭(A), geometry(B), 이벤트 스레드(C), 문서와 측정. 빌드와 테스트는 HEAD에서만 했습니다.
base 9e9e6a94에서 만든 뒤 origin/main(Herdr 0.9.3) 위로 rebase했고, main이 이미 한 C의 일(경로와 git 탐색의 PathIndex)은 버렸습니다.

Review

  • 판단해 주세요: D-02 일부를 이 호스트에서 못 맞췄고 운영자가 "측정값으로 수용"(2026-10-07)했습니다. 재측정은 with-hide/hide-private#95.
  • 판단해 주세요: 못 맞춘 값: Hide 몫 p95 split 68/139, 새 탭 52/75 ms(목표 50), 두 배 규모 새 탭 첫 프레임 233 ms(목표 200).
  • 판단해 주세요: 3초 한도는 키마다 적용합니다(PRD 문구 그대로). 그래서 4초 전에 친 make deploy는 버려지고 1초 전에 친 Enter만 들어갈 수 있습니다. 보관분 전체를 함께 버리는 쪽은 방금 친 키까지 잃어서 택하지 않았습니다. escape sequence와 붙여넣기는 한 덩어리로 와서 중간이 잘리지 않습니다.
  • 판단해 주세요: 키보드 focus는 그림이 아니라 core의 답을 따라, ⌘D 두 번 연타는 Herdr처럼 원래 pane을 두 번 나눕니다.
  • 조심해서 볼 파일: herdr-core/src/runtime/terminal_input.rs, web/src/keyTarget.ts - 키 라우팅. 틀리면 다른 터미널에서 명령이 실행됩니다.
  • 조심해서 볼 파일: herdr-core/src/runtime/operations.rs, pane_prediction.rs, drawn_ahead.rs - runtime mutex 안의 예측과 탭별 줄.
  • 조심해서 볼 파일: herdr-core/src/session_sync/coordinator.rs, sync_reads.rs - high-frequency path; cwd 재확인도 tick마다 worker로 갑니다.
  • 조심해서 볼 파일: herdr-core/src/runtime/operations.rs의 queue_pane_close/pump_geometry_queue, session.rs의 ingest_session_with_focus_check - CI에서 찾은 회귀 수정. 닫기를 먼저 그리자 남은 pane의 ⌘W가 "close in progress"로 거절됐습니다. 이제 탭의 줄에서 기다렸다가, 앞 닫기가 끝나고 session 반영이 끝난 뒤 시작합니다.
  • 조심해서 볼 파일: herdr-core/src/worktree_control.rs - 이 기능과 무관한 main의 테스트(Wait for every process under a closed pane's shell before its worktree folder is removed #721)를 고쳤습니다. 테스트 프로세스 자신의 pid를 shell로 써서, cargo test에서는 다른 테스트의 자식(git, zsh)까지 세어 항상 실패했습니다. 자식 프로세스 하나를 띄워 shell로 씁니다(Flaky test: herdr-core worktree_control a_pane_reports_each_running_process_once_and_never_the_systems_pids #746).
  • 조심해서 볼 파일: web/src/actions.ts - main에서 이 기기 id가 node id가 되어 키 표시 조건을 localDeviceId(rest())로 비교합니다.
  • 비용 검토: 동작마다 임시 publish 1회, 상한 있는 줄 둘(탭당 대기 8, 입력 64 KiB), pane_op.timing 기록 1개.
  • 비용 검토: idle hided CPU 평균은 줄었지만(2.7 -> 2.1%, 10.2 -> 4.0%) 운영자 규모 중앙값은 0.5 -> 1.0%로 늘었습니다.
  • 비용 검토: 운영자 규모 echo p95 4.1 -> 10.4 ms(1회). 상태 변화 publish 비용은 재지 못했습니다(디스크 부족).

Evidence

  • 확인한 것: 격리 Herdr와 헤드리스 Chrome에서 키 입력부터 화면과 첫 프레임까지, 두 규모, 동작마다 20회(Herdr 0.9.1, 접힌 표).
  • 확인한 것: rebase한 헤드에서 Herdr 0.9.3 운영자 규모 spot run 10회: 화면 p50 25-42 ms로 같습니다(load 45-53).
  • 확인한 것: B9 실제 관찰: ⌘D와 새 탭 직후 친 문자열이 새 pane에 순서대로, 이전 pane에 0자. 0.9.1과 0.9.3에서 각 10/10.
  • 확인한 것: 그 관찰이 새 탭 키를 버리는 경쟁을 찾아 고쳤습니다(keys_for_a_new_tab_survive_an_update_before_herdr_lays_out_its_pane).
  • 확인한 것: 3초 한도는 split 요청 보관, 새 pane 세션 대기, 재연결 재시도 보관에서 3초 안의 키는 순서대로 들어가고 넘은 키는 0바이트이며, 진단에 pane id와 바이트 수만 있고 내용은 없음을 테스트로 고정했습니다(한도 검사를 빼면 세 테스트가 실패).
  • 확인한 것: 요구사항 대조, 코드, 보안 리뷰와 수정분 재리뷰, rebase 재리뷰. 고친 항목은 수정 전 실패를 본 회귀 테스트로 고정.
  • 확인한 것: 최신 main을 merge한 헤드에서 Rust test와 lint, verify-web.sh(web 1192, desktop 158), check-design-contract.mjs 통과.
  • 확인한 것: 닫기 회귀는 데스크톱 e2e close-policy가 수정 전 로컬 4/4 실패, 수정 후 7/7 통과입니다. 같은 경로의 Rust 테스트는 수정을 빼면 실패합니다.
  • 확인하지 못한 것: 로컬 전체 데스크톱 background 실행에서 browser-agent(앱이 앞으로 옴)와 terminal-links(화면 폭) 2개가 실패했습니다. 이 화면 환경 탓으로 보며, 둘 다 0ec8691 CI에서는 통과했습니다. 판정은 이 헤드의 CI에 맡깁니다.
  • 확인하지 못한 것: 조용한 호스트 측정. 모든 측정이 다른 세션 빌드로 load 14-58이었고, 최댓값은 프로세스 정지가 정했습니다.
  • 확인하지 못한 것: 두 규모 표는 rebase 전 헤드(13980671, Herdr 0.9.1)의 값이고, 0.9.3에서는 spot run만 다시 쟀습니다.
  • 확인하지 못한 것: 운영자 Mac의 설치 앱과 포그라운드 키보드 QA. 운영자 작업을 건드리지 않도록 격리 candidate와 CDP 입력으로 대신.
  • 확인하지 못한 것: load 40-75에서 이 브랜치가 건드리지 않은 테스트가 한 번씩 실패했고 flaky Flaky test: herdr-core::ssh_hosts resolving_runs_a_bounded_number_of_children_and_asks_each_alias_once #728 Flaky test: hide-kit retirement_without_a_herdr_server_finishes_when_no_plugin_is_registered #729 #731로 올렸습니다. main에서 온 테스트 하나는 cargo test에서 항상 실패해서 이 PR에서 고쳤습니다(Flaky test: herdr-core worktree_control a_pane_reports_each_running_process_once_and_never_the_systems_pids #746, Review 참고).
추가 증거

D-02 표 (Herdr 0.9.1, base 9e9e6a9, candidate 13980671). Key to screen, then key to the new pane's first frame (page clock, 20 rounds; p50 / p95 / max ms; target p95 100 and 200):

Scale Operation Baseline screen Candidate screen Baseline frame Candidate frame
operator split 336 / 1570 / 1955 38 / 55 / 66 436 / 1856 / 2105 122 / 175 / 216
operator zoom 188 / 1021 / 1115 23 / 34 / 56 188 / 1021 / 1115 88 / 109 / 117
operator unzoom 123 / 505 / 617 24 / 37 / 51 123 / 505 / 617 106 / 124 / 131
operator close 380 / 875 / 2716 27 / 35 / 38 380 / 875 / 2716 126 / 159 / 183
operator new tab 325 / 1002 / 1475 41 / 68 / 205 398 / 1069 / 1525 116 / 168 / 272
operator switch 13 / 50 / 107 17 / 22 / 28 13 / 50 / 107 17 / 22 / 28
double split 1332 / 2060 / 5647 45 / 71 / 152 1529 / 2521 / 5881 147 / 175 / 286
double zoom 565 / 1011 / 1189 33 / 50 / 62 565 / 1011 / 1189 94 / 128 / 216
double unzoom 459 / 873 / 1126 31 / 51 / 61 459 / 873 / 1126 101 / 127 / 134
double close 978 / 2263 / 3108 33 / 47 / 52 978 / 2263 / 3108 143 / 163 / 246
double new tab 1138 / 3455 / 4505 45 / 71 / 309 1360 / 3539 / 4589 136 / 233 / 426
double switch 71 / 205 / 247 20 / 25 / 27 71 / 205 / 247 20 / 25 / 27

Hide share, Herdr's layout event to the snapshot sent (candidate pane_op.timing; p50 / p95 / max ms; target p95 50):

Scale Operation Hide share Herdr share Core first frame
operator pane.split 40 / 68 / 87 45 / 96 / 101 90 / 159 / 185
operator pane.zoom 5 / 13 / 22 78 / 99 / 103 104 / 132 / 180
operator pane.close 22 / 36 / 41 59 / 92 / 95 -
operator tab.create 34 / 52 / 54 53 / 80 / 145 90 / 153 / 262
double pane.split 76 / 139 / 142 53 / 96 / 105 99 / 134 / 139
double pane.zoom 12 / 38 / 47 73 / 91 / 98 101 / 129 / 225
double pane.close 42 / 60 / 76 52 / 64 / 74 -
double tab.create 45 / 75 / 78 38 / 98 / 194 111 / 190 / 390

1-minute load: baseline operator 15.0, candidate operator 13.9, baseline double 43.5, candidate double 58.2.
두 배 규모 baseline은 4회차가 baseline의 느린 포커스로 측정 도구 제한 시간에 걸려 3회차 값을 썼습니다.
규모: 운영자(워크스페이스 43, 탭 62, pane 66, agent 30, 출력 중 5), 두 배(86, 124, 132, 60, 10).
idle: hided RSS 51 -> 34, 85 -> 67 MiB; Herdr CPU 중앙값은 운영자 규모 6.8 -> 8.5%. 두 배 규모 echo p95 258 -> 22 ms.

Herdr 0.9.3 spot run (rebased head a84a36ab, operator scale, 10 rounds so p95 is the max, load 44.5-53.2): screen p50 / p95 split 35 / 90, zoom 27 / 274, unzoom 27 / 37, close 25 / 63, new tab 42 / 181, switch 13 / 37 ms; Hide share p50 / p95 split 28 / 93, zoom 7 / 17, close 12 / 95, tab.create 20 / 280 ms; echo p95 18 ms.

B9 관찰 방법: 이전 pane은 cat이라 받은 키를 그대로 보여 줍니다. 단축키 직후 10-51 ms 안에 고유 문자열을 CDP 키로 친 뒤 herdr pane read로 두 pane을 읽었습니다. rebase 전 수정 전 헤드의 첫 실행에서 새 탭 1회의 키가 사라졌습니다(core 로그 terminal.input_delivered 뒤 terminal.input_discarded pane_gone). Herdr의 응답과 레이아웃 사이에 session update가 끼면, 아직 레이아웃에 없는 새 pane의 보관 입력을 사라진 pane으로 본 탓입니다.

D-13/B21을 main 설계 위에서 코드로 확인한 자리:

  • 새 socket 읽기(agent.list, pane.get, cwd 재확인, workspace.get)는 session_sync/sync_reads.rs worker로 갑니다.
  • lsof는 ports.rs의 PortsReader(BackgroundRead)로 갑니다.
  • codex usage HTTP는 usage.rs의 codex_background_read로 갑니다.
  • label fsync는 labels/store.rs의 save_later 저장 스레드로 갑니다.
  • realpath와 git 탐색은 core가 하지 않습니다. 묻는 경로 집합이 같은 동안에는 node의 PathIndex 답을 30초 refresh까지 다시 씁니다.
  • 이벤트 스레드에 남은 막히는 호출은 main에서 온 것입니다: 경로 집합이 바뀔 때의 PathIndex::ask, Settings를 보는 동안의 kit::hook_diagnosis, AI 설정 저장.

리뷰에서 고친 것:

  • 줄의 다음 작업이 앞 작업을 확정한 레이아웃을 자기 답으로 읽었습니다(the_next_operation_in_a_line_waits_for_its_own_layout).
  • 레이아웃을 떠난 pane이나 닫히는 pane의 키 요청이 열려 있었습니다.
  • 재시도가 끝난 pane의 보관 키가 수동 재연결 뒤 들어갔습니다.
  • Hide가 그리기만 한 새 탭이 시간 초과로 사라지면 진짜 pane의 키를 버렸습니다.
  • 대기 중 resize 예측이 이미 그린 레이아웃에서 계산됐습니다.
  • 문서에 버림 이유 전체를 적었습니다. 나이 제한이 없다는 남은 문제는 이후 운영자 결정으로 3초 한도가 되었습니다.

구현 중 정한 가정:

  • zoom과 resize의 changed: false 답은 그 작업을 끝냅니다.
  • 새 split pane은 grid를 보관하지 않습니다.
  • 결과를 알 수 없는 작업은 탭의 줄을 버립니다.
  • OpenOwner 경로의 새 탭은 Herdr 응답을 기다립니다.
  • task 탭의 키는 agent 시작 뒤 들어가고, 보이지 않는 탭이면 버립니다.
  • 64 KiB를 넘으면 그 pane의 보관분을 버리고 로그에 남깁니다.
  • 닫는 pane의 사이드바 행은 Herdr 확정까지 남습니다.
  • 새 pane은 cwd 확정 전에 옆 pane의 폴더나 Hide가 만든 탭의 checkout으로 먼저 publish합니다.
  • 입력 요청 id는 128자 [A-Za-z0-9_-]이고, 같은 id가 다른 출처로 오면 새 것이 이깁니다.
  • rebase는 Observer가 승인한 구현 결정입니다(PRD 변경 없음). rebase 전 헤드는 backup/instant-pane-topology-178de4fc 브랜치에 로컬로 남아 있습니다.

남은 것(Follow-up):

  • 조용한 호스트에서 두 규모 재측정과 split 확정 경로 프로파일: with-hide/hide-private#95.
  • Herdr가 이름만 알려주고 어떤 레이아웃에도 싣기 전에 없앤 pane의 요청과 보관 바이트는, 밀려나거나 Hide가 닫을 때까지 남습니다(8행, pane당 64 KiB). 다른 pane으로 가는 경우는 Herdr가 같은 id를 다시 줄 때뿐입니다. Herdr skill은 닫힌 id를 다시 쓰지 않는다고 하지만, 이 저장소의 restore 문서는 고정 버전에서 그런 사례를 적고 있습니다.
  • 화면에 없고 release되지 않는 pane의 보관 입력은 재시도가 끝나도 메모리에 남습니다(pane당 64 KiB). 3초가 지나면 다시는 들어가지 않습니다.
  • 닫힌 pane의 입력 요청 행은 8행 고리에서 밀려날 때까지 남습니다.
  • 줄에서 기다리다 거절된 닫기는 키보드를 되돌리지 않습니다.
  • split 직후 Herdr가 새 pane을 알리기 전에 누른 zoom은 main의 "pane 하나뿐인 탭은 zoom하지 않음" 규칙에 걸려 진단만 남깁니다.
  • Hide가 만든 탭의 pane이 잘못된 cwd로 알려지면 PathIndex::ask가 두 번 일어날 수 있습니다(main 설계, 0.9.3에서 재현 미확인).
  • 같은 cwd를 다시 읽은 답도 publish를 한 번 더 합니다.
  • 비차단 리뷰 항목:
    • SyncReader 단위 테스트
    • label 저장 스레드의 종료 시 flush
    • BackgroundRead 재시작 backoff
    • remote Unchanged 답
    • task 슬롯 행 시간 제한
    • unknown 진단 반복
Verification record
  • PRD: agents/prd/instant-pane-topology/prd.md (sha256 6e29d9b1a7fe1078767176f6fe97261f4e7b9687463b626bacde9865e788b861; amended 2026-10-07 for the 3 s held-input limit, D-11/B10)
  • Base 9e9e6a9 → head 3494adb, verified 2026-10-07T12:43:12.579Z: PASS
  • Rebased onto origin/main 35f480e (backup ref backup/instant-pane-topology-178de4fc), then merged origin/main 9f14487; PR diff against main: 47 files. The 481 changed paths below count from the original base 9e9e6a9.
  • Verification report: agents/runs/instant-pane-topology/verification-report.json and agents/runs/instant-pane-topology/verification-report.md; source fingerprint d8a40fb15180a5c29f645e8889697b994de183e0972a957b47ac55a54e4de0d5
  • Suites:
    • S1: GREEN bash scripts/verify-cargo.sh test (exit 0)
    • S2: GREEN bash scripts/verify-cargo.sh lint (exit 0)
  • Reviews:
    • Fidelity (13980671): three findings, all fixed.
      • The PR overstated B24/B25; echo, idle medians and the unmeasured publish cost are now stated.
      • The focus-lag line was added.
      • The discard reasons and the no-age-limit residual were added to the docs.
    • Code (13980671): two Fix now findings.
      • The line baseline was read before the update; fixed, with a regression test.
      • The queued resize was predicted from the drawn layout; fixed.
      • Follow-ups: SyncReader tests, label saver flush, BackgroundRead backoff, remote Unchanged.
    • Security (13980671): two Fix now findings.
      • A request for a gone pane could take a reused id; fixed with pane_gone.
      • Held keys survived exhausted retries; fixed with session_failed.
      • Follow-ups: task-slot timeout, unknown diagnostic churn.
    • Fix follow-up reviews:
      • 88e15ffb: found the provisional-tab expiry hole; fixed.
      • c366e433: closed, no new defect.
      • The B9 probe found the held-key race; fixed and reviewed.
    • Rebase review (a84a36ab, Fidelity + Code, key routing first): no blocking defect.
      • A stale commit message and a stale doc sentence were fixed.
      • Follow-ups are listed under 남은 것.
    • Age-limit amendment (operator decision, D-11/B10), two follow-up reviews:
      • First review: no blocking defect. It found that the whole-holder discard did not match the per-key PRD text, and that the stale diagnostic was untested; both changed.
      • Second review: no blocking defect. Its findings are now fixed:
        • stale keys counted toward the 64 KiB cap; they are now pruned on hold, with a test;
        • the resolve-time diagnostic and the mix of stale and fresh keys were untested; the runtime test now covers them;
        • two stale test comments were corrected.
      • The residual that a fresh Enter acts without its discarded command is documented in ARCHITECTURE.
    • Queued-close regression fix (1b91e61, from the CI desktop e2e failure on 0ec8691): one Code review, no blocking defect. Its findings are fixed in 941a0ea:
      • a queued close waited with no deadline behind a failed or unknown close; it now waits only behind a settling close;
      • a nested pump could drop the line;
      • the test did not start the queued close; it now does, and fails without the ingest guard.
    • Flaky test: herdr-core worktree_control a_pane_reports_each_running_process_once_and_never_the_systems_pids #746 test fix (3494adb), Observer-authorized and test-only: passes 3/3 under plain cargo test, where it had failed 7/7.
  • Evidence: 18 registered (3 file, 7 browser, 8 log); paths are local to the run directory
    • agents/runs/instant-pane-topology/evidence/d02-table.md
    • agents/runs/instant-pane-topology/evidence/idle-echo-summary.md
    • agents/runs/instant-pane-topology/evidence/candidate-operator-4/topology.json
    • agents/runs/instant-pane-topology/evidence/candidate-operator-4/timing-summary.json
    • agents/runs/instant-pane-topology/evidence/baseline-operator-4/topology.json
    • agents/runs/instant-pane-topology/evidence/baseline-operator-4/timing-summary.json
    • agents/runs/instant-pane-topology/evidence/candidate-double-4/topology.json
    • agents/runs/instant-pane-topology/evidence/candidate-double-4/timing-summary.json
    • agents/runs/instant-pane-topology/evidence/baseline-double-3/topology.json
    • agents/runs/instant-pane-topology/evidence/baseline-double-3/timing-summary.json
    • agents/runs/instant-pane-topology/evidence/verify-web-13980671.log
    • agents/runs/instant-pane-topology/evidence/b9/b9-run2-c366e433.json
    • agents/runs/instant-pane-topology/evidence/b9/b9-run1-59682273.json
    • agents/runs/instant-pane-topology/evidence/verify-web-a84a36ab.log
    • agents/runs/instant-pane-topology/evidence/spot-093-operator-summary.md
    • agents/runs/instant-pane-topology/evidence/verify-web-rebased-a84a36ab.log
    • agents/runs/instant-pane-topology/evidence/b9/b9-run3-a84a36ab-herdr093.json
    • agents/runs/instant-pane-topology/evidence/spot-093-operator/timing-summary.json
  • Changed paths: 481 from the original base (see Files changed for the 47 against main)

Every tab creation and pane operation Hide starts writes one
pane_op.timing diagnostic line with the milliseconds from the request to
Herdr's answer, the first drawn snapshot, the first and first layout
event, the confirmed layout, the snapshot that carried it and the
pane's first frame, so Herdr's share and Hide's can be read apart. Ids
and times only; at most 64 records are open, each closed within 10 s.
A tab creation is drawn as a one-pane tab of the checkout's owner
workspace as soon as Herdr's answer names its pane, and Herdr's layout
replaces it. Keys typed after New tab or a split are sent against the
request; the core holds them, capped at 64 KiB per holder and 8
requests, writes them in order to the pane Herdr's answer names, and
discards them when the creation fails. A pane whose terminal session is
still opening keeps its input instead of dropping it.
A split, zoom, resize or pane close is laid out from the confirmed
layout with the same split arithmetic that projects Herdr's layouts and
published at once (a split at the answer that names its pane); Herdr's
layout replaces the drawing, and a mismatch is recorded. While a change
is drawn ahead the tab's panes keep their terminal grid and their PTY
size; the latest view size is sent once Herdr has applied it. Each tab
runs one geometry operation at a time with at most eight waiting; a
refusal, failure or unknown result drops the line behind it and draws
the confirmed layout. A zoom or resize Herdr reports as unchanged ends
at its answer.
agent.list, a new pane's pane.get, the tick's cwd re-reads and a
workspace's workspace.get run on sync-read workers, one per kind with
one read of that kind in flight; a read that panics still answers as a
failure of its kind, and a re-read the worker cannot take yet is asked
again on the next tick. The listening-ports read and the Codex usage
read (the node's login and session files, then the usage endpoint) run
on BackgroundRead threads, and labels.json is written on the label
store's own thread. Output and intervals are unchanged; an agent list
asked for while one is out is asked again when it answers, at most
every 250 ms.

A new pane's layout publishes before Herdr confirms its cwd, standing
in the folder of a confirmed pane beside it or the checkout a tab Hide
created was asked for; only a pane with neither waits for the read.

The purpose mirror syncs only when its catalog or pending purposes
change, so an agent status change repeats no purpose work.
The architecture, UI behavior, performance and agent guides describe
the drawn-ahead layout, the held PTY size, the held keys and their
caps, the per-tab geometry line, the stage record, the event-thread
rule and the publish cost rule; the old rule that zoom, splits, closes
and resizes wait for Herdr is gone. scripts/web-shell-measure gains a
topology scenario that drives split, zoom, close, new tab and tab
switch through the web shell's own keys at the operator's scale and
twice it, with a baseline hided, and summarizes the stage records.
Keys held for a new pane or a pane whose terminal is opening keep the
time each was typed, from the creation request into the pane's hold. When
the pane can take them, keys held longer than three seconds are discarded
with a stale diagnostic naming the pane and byte count, and the rest are
written in order. The age is checked at Herdr's answer and at session open.
A close drawn ahead of Herdr leaves its sibling drawn alone, so Command W
on it arrived while the first close was in progress and was refused. The
line now decides from Herdr's layout that the pane is one of two, queues
its close without drawing it, and starts it only once the close ahead has
left the tab and the session update in progress has been applied.
… once

A close behind one that failed or whose result is unknown starts and meets
its refusal, as before, instead of waiting with no deadline. A pump that an
operation it started re-enters leaves the line to the outer pump. The test
now confirms the close ahead and checks the last pane's close starts from
the applied session and is not canceled.
The test used its own process as the pane's shell, so under cargo test,
where every test is a thread of that process, the children other tests
had running were reported as the pane's too. A spawned child now stands
for the shell; the test asserts it is reported once and that nothing
outside its tree is.

Fixes #746
@yansfil
yansfil merged commit 09b9e2c into main Oct 7, 2026
20 checks passed
@yansfil
yansfil deleted the prd/instant-pane-topology branch October 7, 2026 13:06
yansfil added a commit that referenced this pull request Oct 7, 2026
Related: PRD `agents/prd/codex-plan-approval-hold/prd.md` (local). The
reviewable contract is below.

## Summary

- Codex CLI가 plan 모드에서 "Implement this plan?"을 띄운 채 기다릴 때, 편지 종이 Enter를
쳐서 첫 항목 "Yes, implement this plan"을 골랐습니다(2026-10-07 실측 3/3). 운영자가 승인하지
않은 계획이 구현되기 시작했습니다.
- 이제 hide는 이미 읽는 Codex 세션 파일(rollout)의 턴 기록(`task_started`의 plan 모드,
Plan 항목, `task_complete`)으로 계획 승인 대기를 알아내고, 그동안 종을 보류 사유
`awaiting_operator`로 치지 않습니다.
- 같은 동안 그 Codex 행은 기존 승인 대기(approval demand)로 Needs You에 남고, 읽어도 빠지지
않으며, 다음 턴이나 사람의 메시지가 오면 빠집니다. wire와 web 변경은 없습니다.
- 판정은 Hide AI 분석이 아닌 결정적 사실이라 요약을 꺼도 같고, 읽은 Herdr `state_change_seq`에 묶여
지금 상태에 대해 읽지 못한 Codex pane은 `session_unread`로 종을 보류합니다. Claude Code
pane은 그대로입니다.
- 문서: `docs/delivery.md`, `status-model.md`, `UI_BEHAVIOR.md`,
`ARCHITECTURE.md`, 성능 ledger.

![Live: a real Codex CLI at "Implement this plan?" (Herdr reads idle)
sits in Needs You with the ! approval
mark](https://github.com/yansfil/pr-assets/blob/main/hide/codex-plan-approval-hold/84e189e/live-needs-you.png?raw=true)

![Playwright e2e on the pinned Herdr: a rollout whose plan turn ended
puts the Codex row in Needs
You](https://github.com/yansfil/pr-assets/blob/main/hide/codex-plan-approval-hold/84e189e/e2e-needs-you.png?raw=true)

## Review

- **판단해 주세요**: Herdr가 Codex의 `task_complete` 기록보다 먼저 정지 상태를 읽으면, 그 상태에서는
종만 보류되고 Needs You는 다음 상태 변화까지 뜨지 않습니다. 재읽기를 더하지 않았습니다(PRD B10).
- **판단해 주세요**: "No, stay in Plan mode"는 세션 파일에 아무것도 쓰지 않아서, 행이 다음 턴까지
Needs You에 남습니다.
- **판단해 주세요**: 세션 파일을 못 찾는 Codex pane(최근 7일 폴더 밖), 그리고 label generator
lock이 없는 daemon(같은 Herdr를 따르는 두 번째 hided, 재시작이 겹친 뒤 최대 30초)에서는 Codex 종이
보류됩니다.
- **조심해서 볼 파일**: `herdr-core/src/delivery/doorbell.rs` `judge` - failure
path. 모름을 "대기 없음"으로 읽지 않습니다.
- **조심해서 볼 파일**: `herdr-core/src/labels/overlay.rs` `waiting`,
`labels/{worker,store}.rs` - seq 묶음과 serde 기본값으로 저장되는 새 필드.
- **조심해서 볼 파일**: `herdr-core/src/session_sync/coordinator.rs` - runtime
mutex. overlay를 lock 밖에서 먼저 만들고 두 경로 모두 `observe_delivery`에 넘깁니다(main
#743과 merge 해결 지점).
- **조심해서 볼 파일**: `hide-session/src/turns.rs` - 대기를 언제 안다고 볼지 정하는 match.
- **비용 검토**: 세션 읽기는 라벨 작업이 이미 하는 상태 변화 시 증분 읽기에 실리고, 새 파일 읽기, 프로세스, lock
안 I/O는 없습니다.

## Evidence

- **확인한 것**: sealed verify S1 `cargo test --workspace`, S2 lint
PASS(merge head 267aad3). 첫 두 시도는 base에서도 실패하던 pane process 테스트 때문이었고,
main의 #743 수정으로 대체됐습니다.
- **확인한 것**: `hide-session` 계약 테스트가 합성 Codex 0.160.1 계획 턴 표본으로 대기 시작, 다음
턴, 사람 메시지, aborted 턴, 질문으로 끝난 plan 턴, 모르는 형식, 증분 읽기와 rescan을 확인합니다.
- **확인한 것**: core 테스트가 seq 묶음(이전 seq의 사실은 보류), 모름은 보류, 끝나지 않은 일반 턴은 울림,
요약 꺼짐, 재시작, 필드 없는 기기 helper, Claude Code 불변을 확인합니다. merge 뒤 focused
herdr-core 298/298을 3회 돌렸습니다.
- **확인한 것**: Playwright `codex-plan-approval.spec.ts`가 고정 Herdr와 hided
위에서 계획 대기 rollout이 행을 Needs You로 넣고, 다음 턴 기록과 상태 변화가 빼는 것을 확인합니다. 심은
결함에서 실패하는 것도 확인했습니다.
- **확인한 것**: 격리 live(private socket의 고정 Herdr 0.9.3, private HOME, 이
브랜치의 hided 1560a90, 로그인된 Codex CLI 0.160.1, hooks 꺼짐): Herdr가 계획 메뉴를
`idle`로 읽는 동안 편지가 `awaiting_operator`로 한 번 기록되고 보류됐으며, 키 입력 0회, 메뉴
그대로였습니다. 승인 뒤 다음 턴이 끝나자 종이 한 번 울렸습니다.
- **확인한 것**: Herdr는 계획 메뉴를 remote Codex manifest 2026.10.01.1에서는
`idle`로, 번들 2026.09.23.1에서는 `unknown`으로 읽습니다(문서에 manifest별로 적음).
- **확인하지 못한 것**: B1 race 경우의 live 재현, 기기 pane live, 계획 대기 중 hided 재시작
live, 운영자의 실제 Codex hook 구성(live는 hooks를 끄고 세션을 직접 보고함).
- **확인하지 못한 것**: live 검증이 `~/.codex/sessions`에 Codex rollout 3개를
남겼습니다(설정 변경 없음).

AI tooling: native review subagents read the diff; their findings and
dispositions are in the record below.

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

- PRD: `agents/prd/codex-plan-approval-hold/prd.md` (sha256
e67aa258a404f1a493a93eec74933e5324e0fcbccbbf40ab605b23e78d819012)
- Base 9f14487 → head 267aad3, verified 2026-10-07T15:55:58.411Z: PASS
- Verification report:
`agents/runs/codex-plan-approval-hold/verification-report.json` and
`agents/runs/codex-plan-approval-hold/verification-report.md`; source
fingerprint
f5b5d1bca59a1702fd81feceebf3c2c3946c71d2f7d3503bac7eb4d8b6b4cf14
- Suites:
  - S1: GREEN `bash scripts/verify-cargo.sh test` (exit 0)
  - S2: GREEN `bash scripts/verify-cargo.sh lint` (exit 0)
- Reviews:
- Fidelity (1560a90, follow-ups to 6ab4ea3): Fix now - an unknown record
format read as "nothing waits" (fb939cc, 6c96181); fixed.
- Code (1560a90, follow-ups to 6ab4ea3): Fix now - bell kind mapping
disagreed with the session-read kind (5c9342b), approving Enter not
counted as the operator's submit at `unknown` (1bd5647), e2e negative
check proved nothing (c6c9e75); fixed. A re-read of unsettled turns
(8ad7ab8) was reverted (9c0f057) under PRD B10.
  - Security (1560a90, follow-ups to 6ab4ea3): no open Fix now.
- Code, merge resolution only (84e189e): no Fix now. 267aad3 is a
conflict-free merge of main (#708) on top, verified again.
- Observer read of the doorbell verdict, the seq binding and both
coordinator call sites (6ab4ea3): no Fix now.
- Follow-up improvements: per-pane head-of-line letter judging (predates
this diff), Codex sessions outside the seven newest day folders hold
forever, turn_id length cap, phone reply typing Enter on a plan row.
- Evidence: 8 registered (1 log, 3 file, 4 screenshot); paths are local
to the run directory
  - agents/runs/codex-plan-approval-hold/evidence/live/core.jsonl
-
agents/runs/codex-plan-approval-hold/evidence/live/delivery-ledger.json
  - agents/runs/codex-plan-approval-hold/evidence/live/labels.json
-
agents/runs/codex-plan-approval-hold/evidence/live/needs-you-idle-plan-menu.png
-
agents/runs/codex-plan-approval-hold/evidence/live/needs-you-unknown-status.png
  - agents/runs/codex-plan-approval-hold/evidence/live/README.md
-
agents/runs/codex-plan-approval-hold/evidence/e2e/codex-plan-approval-waiting.png
-
agents/runs/codex-plan-approval-hold/evidence/e2e/codex-plan-approval-approved.png
- Changed paths: 29 against main (more against the run start base
9f14487, which includes main merged in)

</details>
yansfil added a commit that referenced this pull request Oct 16, 2026
Related: PRD grid-ahead-of-herdr (local), follows instant-pane-topology
(#743)

## Summary

In a tab with several panes, a zoom, divider drag, pane close or split
moved the pane rectangles at once, but the text inside kept its old grid
until Herdr confirmed the layout and the core sent the PTY size: the
terminal looked like it stretched slowly.
The core held that size on purpose, on the belief that Herdr sizes the
PTY from the geometry it applies. On the pinned Herdr 0.9.3 it does not:
the PTY is the controlling client's size through a zoom, a split and a
sibling's close, which a new contract test pins.
The hold is gone. The shell fits each terminal to the rectangle drawn
for it the moment it is drawn, the node sends that size at once, and
Herdr's later layout changes nothing when it matches. A timing record's
frame watch now starts at that resize instead of at Herdr's
confirmation.
Two measurement fixes ride along: the topology scenario presses the
current zoom chord, and a new pane's cwd answer republishes only when it
would change the screen (one full publish saved per split or new tab at
operator scale).

## Review

- **판단해 주세요**: `hide-herdr-client/tests/it/real_herdr.rs` is where the
D-14 contract test lives (the `os contract` lane runs on all three
systems); the PRD named `hided/tests/it/real_herdr.rs`, which runs on
Windows only.
- **조심해서 볼 파일**: `herdr-core/src/runtime/events.rs` - `TerminalResize`
no longer has a held branch; a resize now reaches the node whenever the
core's recorded size differs (high-frequency path, under the runtime
mutex).
- **조심해서 볼 파일**: `herdr-core/src/runtime/op_timing.rs` - a resize marks
every record on that pane that is drawn or applied; two operations on
one pane share one resize (timing only, no behaviour).
- **조심해서 볼 파일**: `herdr-core/src/session_sync/coordinator.rs` -
`pane_cwds_answer_publishes` skips a publish; the skip is wrong if a
pane the screen shows at a stand-in could stay there, which
`CatalogState::stand_ins` guards (failure path: a pane left in the wrong
folder).
- **조심해서 볼 파일**: `hide-node-link/src/lib.rs` - `TerminalControl::Resize`
lost `force`; the enum does not deny unknown fields, so an older node
reading a newer link and the reverse both parse.
- **비용 검토**: per resize, `OpTimings::resize_sent` scans at most 64 open
records with no allocation, and one `WatchFrame` goes out only when a
record starts waiting; `stand_ins` holds at most `UNCONFIRMED_CWD_LIMIT`
(64) entries and is replaced per publish; nothing new runs per tick or
per frame.

## Evidence

- **확인한 것**: the pinned Herdr 0.9.3 keeps a controller's 45x20 PTY
through a zoom on and off and a sibling pane's close, read by `stty
size` after each step and by the frame size the controller receives (new
contract test, passed locally with `HIDE_E2E_HERDR_BIN`; the code
reviewer ran it 42 times, 6 sequential and 36 concurrent, all green).
- **확인한 것**: `pane_geometry` tests pin one PTY size per zoom at the
drawing and none when Herdr confirms the same layout, a resize before
the drawing starts no frame watch, and a refused operation sends nothing
more.
- **확인한 것**: same fixture, same machine, before (the bundle installed at
the time, `0.4.1-main.e8c08186` by its Info.plist and the sha256 of its
`hided`, which now sits beside the app as
`hide-previous-0.4.1-main.e8c08186.app.bak`; it is main five commits
past the merge base 7f02ba5, and that range touches no terminal, node
or shell path, only `delivery.rs`; the installed app has since moved to
`0.4.1-main.fdc68c74`, so a rerun against it is a different baseline)
and after (release build of this branch), `MEASURE_SCENARIO=topology
--isolated-headless`, operator scale (43 workspaces, 62 tabs, 66 panes,
30 agents, 5 printing), 10 rounds each, page clock from the key press to
the first frame with the new grid:

| op | before p50 / p95 ms (load 36-58) | after p50 / p95 ms (load
25-44) |
| --- | --- | --- |
| zoom | 94.1 / 110.2 | 24.1 / 42.1 |
| unzoom | 27.4 / 412.3 | 27.9 / 33.5 |
| close | 126.6 / 160.5 | 27.6 / 44.0 |
| split | 97.4 / 1015.2 | 129.0 / 309.9 |
| new_tab | 132.2 / 581.6 | 137.3 / 960.2 |

After the change the first frame with the new grid arrives in the same
frame as the rectangle (frame = screen for zoom, unzoom and close);
split and new_tab wait for a pane that does not exist yet, so their path
is unchanged and the difference is load noise.
- **확인한 것**: `pane_op.timing` in the after run, operator scale: zoom
first_frame p50 22 ms with the resize at the drawing (drawn p50 8 ms),
and one `terminal.resize_settled` per operation (40 for 40), none on
Herdr's confirmation; `pane.prediction_mismatch` 0.
- **확인한 것**: the measured release binary was built from the tree between
310ef51 and 2bdedef; the two commits after it change only
timing-record gating, comments, tests and the cwd-answer guard, none on
the terminal path.
- **확인한 것**: the contract test passed in the `os contract` lane on
macOS, Linux and Windows (verify run 38922022691); the Windows branch
asserts the frame size after each step but not `stty`.
- **확인하지 못한 것**: the operator app's 146-170 ms split and new-tab
layout->applied (PRD D-12) was not reproduced in the fixture at load 28
(p50 18 ms); the remaining suspect and the next measurement are in a
follow-up issue the lead opens.
- **확인하지 못한 것**: a pane close's sibling grid is proven by the page clock
and by `drawn_ms` preceding `herdr_ack_ms`, not by a PTY-side read; the
fixture's close ack is 36 ms, not the 0.7-4.3 s the operator saw.
- **확인하지 못한 것**: a divider drag has no fixture scenario; its frame watch
is registered at request time and is covered by the zoom test's path
only.

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

- PRD: `agents/prd/grid-ahead-of-herdr/prd.md` (sha256
d297b23b6fc270cf96e410bfcb6a81adf775e7a9cbd73fb6b85b1da7a45bcf1f)
- Base 7f02ba5 → head c3ca056, verified 2026-10-16T15:10:33.388Z: PASS
- Verification report:
`agents/runs/grid-ahead-of-herdr/verification-report.json` and
`agents/runs/grid-ahead-of-herdr/verification-report.md`; source
fingerprint
d6f3d096ef55aca1a20af4d5c9ba0183736a567b9bbbb4babff8e1f69fde2cc1
- Suites:
  - S1: GREEN `bash scripts/verify-cargo.sh test` (exit 0)
  - S2: GREEN `bash scripts/verify-cargo.sh lint` (exit 0)
- Reviews:
- Fidelity: reviewed 89e184d, 2bdedef and c3ca056 (closure, code
read only). Fix now: stale grid-hold text in ARCHITECTURE.md and
events.rs (fixed, 2bdedef); the before/after cited the operator log
against the fixture (fixed, same-fixture runs cited above); the
cwd-answer skip could leave a pane at its sibling's folder (fixed,
c3ca056); the before run's build was unnamed (fixed, Evidence names
0.4.1-main.e8c08186 by its hided sha256, closure confirmed); the
D-12/B12 follow-up issue was not opened (stands, the lead opens it at
ship time). Follow-up improvements: no PTY-side evidence for a close's
sibling grid; the one-resize-per-operation guard is asserted for zoom
only, chains unobserved; the contract test splits before attaching and
has no divider resize; observed (non-controller) panes reattach instead
of resizing, unstated in UI_BEHAVIOR.md; no divider-drag fixture; a
chained operation can take an earlier operation's resize for its frame;
the Windows branch of the contract test asserts frame sizes only.
- Code: reviewed 89e184d, 2bdedef and c3ca056. Fix now: the
contract test judged every frame, which could fail on Windows on a
queued old-size frame (fixed, 2bdedef judges the marker frame only);
stale `force` comments in events.rs and terminal.rs (fixed, 2bdedef);
the cwd-answer skip left a stand-in on screen when the announced cwd
differed (fixed, c3ca056, closure confirmed). Follow-up improvements:
two timing records on one pane share a resize; the unchanged-grid
`incomplete` case is not asserted; no shell-layer test that a drawn zoom
reports a resize before Herdr confirms; the contract test reads the PTY
size at one instant.
- Evidence: none registered separately.
- Changed paths: 25 (see Files changed)
- Delivery: mode pr, branch `grid-ahead-of-herdr`, base `main`

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

Flaky test: herdr-core worktree_control a_pane_reports_each_running_process_once_and_never_the_systems_pids

1 participant