Skip to content

Bind each checkout to its own Herdr owner workspace - #250

Merged
yansfil merged 19 commits into
mainfrom
prd/checkout-workspace-binding
Sep 29, 2026
Merged

yansfil merged 19 commits into
mainfrom
prd/checkout-workspace-binding

Conversation

@yansfil

@yansfil yansfil commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Related: PRD agents/prd/checkout-workspace-binding/prd.md

Summary

Hide가 만든 새 탭이 체크아웃과 상관없는 Herdr 워크스페이스(예: main 탭이 home-graph w8P)에 생기고, 에이전트 이름이 그 워크스페이스 라벨로 보였습니다.
이제 체크아웃마다 소유 워크스페이스 하나를 Herdr에서 읽습니다: git은 Herdr가 그 경로에 묶은 워크스페이스, 일반 폴더는 Hide 표시 토큰(hide_owner)을 가진 워크스페이스입니다.
새 탭, New agent, 에이전트 시작, Reopen Closed Tab, 등록 프로젝트 열기가 모두 소유로 가고, 소유가 없으면 worktree.open(폴더는 workspace.create+표시)으로 하나를 엽니다.
SSH 기기 체크아웃은 폴더로 식별해 mini의 w5N/w5T처럼 한 폴더의 워크스페이스 여럿이 한 줄이 되고, task 없는 에이전트는 제공자 이름(Claude, Codex)으로 부릅니다.

화면 배치는 바뀌지 않습니다. 격리된 Herdr에서 묶이지 않은 워크스페이스의 탭에서 새 탭 두 번을 누른 결과(두 탭 모두 소유 워크스페이스에 생김):

묶이지 않은 워크스페이스의 탭에서 새 탭 두 번: 두 탭 모두 소유 워크스페이스(w1)에 생김

Review

  • 판단해 주세요: 묶인 워크스페이스가 없고 묶이지 않은 워크스페이스가 이미 그 체크아웃에 있으면, Herdr 0.9.1 worktree.open이 새로 만들지 않고 그것을 묶습니다(already_open). Hide는 그대로 따르고 이름은 바꾸지 않습니다. B2의 "하나를 연다"를 이렇게 읽어도 되는지.
  • 판단해 주세요: 도우미가 아직 확인하지 않은 기기 폴더는 git인지 모르므로 소유가 없을 때 새 탭을 remote.control.checkout_unconfirmed(재시도 가능)로 거절합니다. 추측해서 잘못된 종류의 워크스페이스를 만들지 않으려는 선택입니다.
  • 판단해 주세요: Herdr가 새로 연 워크스페이스만 사이드바 이름으로 바꿉니다(workspace.rename). worktree.open에 label을 주면 이미 열린 운영자 워크스페이스 이름까지 바뀌어서 label을 보내지 않습니다.
  • 판단해 주세요: 소유 워크스페이스가 생기면서 체크아웃의 마지막 탭을 닫으면 워크스페이스가 함께 닫히는 일이 흔해졌고, 이것이 기존 결함 두 개를 드러냈습니다. 둘 다 이 PR에서 고쳤습니다.
    1. Herdr 0.9.1은 원인보다 늦거나 이른 이벤트를 보냅니다(마지막 탭을 닫으면 workspace_closed 다음에 tab_closed, 새 워크스페이스의 생성 이벤트는 그 뒤의 변경이 끝난 다음에 도착). 복제본은 이를 어긋남으로 보고 스냅샷을 새로 읽었고, 그동안 마지막 닫기가 확인되지 않아 Reopen Closed Tab이 버려졌습니다(agent-tab-groups.spec.ts:157 간헐 실패의 원인). 이제 이벤트가 지운 id를 기억해 그 id에 대한 늦은 이벤트는 이미 반영된 것으로 처리하고(event.already_applied 로그), 아직 알리지 않은 탭·창에 대한 포커스는 그것이 올 때 적용합니다. main도 같은 거절이 sidebar-menus, worktree-delete, worktree-removing-menu에서 납니다.
    2. 위임된 창 이동 요청이 Herdr의 응답만 받고 끝난 것으로 처리되어, 이벤트가 오기 전에 같은 창을 다시 옮겼습니다. 옮길 때마다 앞 이동이 만든 탭이 닫혀 레이아웃이 반영되지 않았고, main에서는 위 재동기화가 우연히 반복(실행당 2-11회)을 끊었습니다. main의 #249가 같은 문제를 같은 방식(레이아웃이 이동을 보여줄 때까지 진행 중)으로 고쳐서, 두 번째 main 병합(7e6aa9e)에서 충돌은 main 쪽을 택했습니다.
  • 조심해서 볼 파일: herdr-core/src/session_sync/replica.rs retired_ids/early_focuses - 복제본이 어긋남으로 거절하던 이벤트 중 무엇을 이제 받아들이는지. id는 64개, 보류 포커스는 16개로 제한됩니다.
  • 조심해서 볼 파일: herdr-core/src/live.rs ensure_owner/open_owner_tab - Herdr 호출과 실패 경로, 일반 폴더용 프로세스 전역 잠금.
  • 조심해서 볼 파일: herdr-core/src/device_catalog.rs group - 기기 체크아웃 id가 워크스페이스에서 폴더 해시로 바뀜, 옛 id 접힘 상태 이관(legacy_checkout_ids).
  • 조심해서 볼 파일: herdr-core/src/runtime/session.rs - 소유 계산이 runtime mutex 안에서 이미 받은 세션만 읽는지(스냅샷당 Herdr 호출·I/O 없음).
  • 조심해서 볼 파일: herdr-core/src/runtime/projects.rs agent_start_in_checkout - main 병합 충돌을 소유 경로를 유지하고 main의 시작 프롬프트(payload.prompt)를 실어 풀었습니다.
  • 조심해서 볼 파일: herdr-core/src/live.rs registered_owner - 병합 후 main에서 온 탭·워크스페이스 생성 경로를 모두 확인하다 찾은 기존 누락: 프로젝트 등록이 일반 workspace.create로 새 워크스페이스를 만들었습니다. 이제 등록도 체크아웃의 소유를 엽니다(git 하위 폴더는 체크아웃 루트, 그 밖은 폴더 표시).

Evidence

  • 확인한 것: 두 번째 main 병합 head(7e6aa9e)에서 sasu implement verify PASS(verify-cargo.sh test, lint), verify-web.sh 통과. 전체 web e2e는 84 통과, checkout-owner 4/4, hided 로그의 event.rejected 0건. 나머지 9개는 픽스처의 git commit이 이 Mac의 커밋 서명 에이전트(Secretive, 잠김)에 거절된 것이라, 서명을 끈 git 설정 사본(GIT_CONFIG_GLOBAL)으로 다시 돌려 9/9 통과했습니다. verify도 같은 설정으로 돌렸습니다(서명을 쓰는 cargo 테스트 5개가 같은 이유로 실패).
  • 확인한 것: 격리된 pinned Herdr 0.9.1에서 web/e2e/checkout-owner.spec.ts 4/4: 비소유 탭에서 요청해도 소유로, 소유 없음+묶이지 않은 것 채택(이름 유지), 링크 워크트리 새로 열고 브랜치 이름, 일반 폴더 두 번 빠른 요청에 워크스페이스 하나.
  • 확인한 것: 전체 web e2e: 고치기 전에는 agent-tab-groups.spec.ts:157이 3번 중 2번 실패(b46f728 1번, 65ccfc7 2번 중 1번), main(eb30664)은 89/89. 병합 전 head(3b43c18, 로그 이름의 44fa25b8과 같은 tree)는 두 번 모두 93/93이고, 두 실행의 hided 로그 어디에도 event.rejected가 없습니다(main은 로그 4개에 있음).
  • 확인한 것: agent-tab-groups:157만 부하 중 반복: 고치기 전 6번 중 3번 실패(모든 실행에 event.rejected), 고친 뒤 12/12와 8/8 통과, event.rejected 0건. sidebar-status.spec.ts:36: 복제본만 고친 상태에서 14번 중 10번 실패(창 이동 93-188회, main은 2-11회), 이동 대기까지 고친 뒤 6/6 통과(이동 1회).
  • 확인한 것: 격리 Herdr 탐침으로 이벤트 순서를 확인해 unit 테스트로 옮겼습니다: 마지막 탭·창 닫기, layout.apply로 새 워크스페이스의 첫 탭 바꾸기, 새 워크스페이스에 바로 포커스 탭 만들기, 창을 새 탭으로 반복 이동.
  • 확인한 것: 격리 Herdr 탐침으로 worktree.open 동작 확인: 링크 워크트리는 main worktree cwd가 필요(linked_worktree_source), label은 열린 워크스페이스도 바꿈.
  • 확인한 것: 이 Mac과 mini Herdr를 읽기만 해서 PRD 사실 확인(w9J·w5N·w3Y 묶임, w8P·w5T·w43 안 묶임). 아무것도 만들거나 옮기지 않았습니다.
  • 확인하지 못한 것: 실제 mini에 대한 기기 새 탭·포커스·purpose는 격리 e2e가 없어 unit 테스트(mini 모양 세션)로만 확인했습니다. 설치된 /Applications/hide.app에서는 확인하지 않았습니다.
  • 확인하지 못한 것: 일반 폴더 표시 토큰이 Herdr 재시작·live handoff 뒤 사라지는지(D-11 위험)는 실행해 보지 않았습니다. 사라지면 다음 탭이 새 워크스페이스를 하나 더 만듭니다.
  • 확인하지 못한 것: 빠르게 두 번 누른 새 탭이 같은 이름(Tab 2)을 받는 것은 두 요청이 같은 다음 라벨을 계산하기 때문이며 이 변경 전부터 있던 동작입니다(후속).
  • 확인하지 못한 것: github::tests::timed_out_gh_and_its_pipe_holding_helper_are_terminated(main에서 온 테스트, 이 PR은 github.rs를 바꾸지 않음)가 전체 herdr-core 테스트에서 가끔 실패합니다. 연달아 돌린 비교에서 main 0/7, 이 브랜치 12번 중 3번 실패(한 번은 같은 파일의 an_issue_panel_reads_only_its_fields...도). 가짜 gh가 1초 안에 pid를 쓰지 못해 생기며, 혼자 돌리면 두 쪽 모두 4/4 통과합니다. 새 owner 테스트의 git init을 빼도 5번 중 1번 실패해서 원인을 찾지 못했습니다(후속). sasu implement verify는 최종 head에서 통과했습니다.
  • 확인하지 못한 것: desktop e2e(pnpm --dir desktop e2e)는 돌리지 않았습니다.
추가 증거

묶인 워크스페이스 없음: Herdr가 체크아웃의 기존 워크스페이스를 묶고 이름은 그대로

링크 워크트리에 워크스페이스 없음: 하나를 열어 브랜치 이름 feature로

일반 폴더: 빠른 새 탭 두 번에 표시된 워크스페이스 하나

AI tooling: 대부분 AI 도구. PRD의 B1-B16을 코드와 격리 Herdr e2e 결과에 하나씩 대조했습니다.

Verification record
  • PRD: agents/prd/checkout-workspace-binding/prd.md (sha256 c5d637b351bbbfdbe458e1aa499c8663b5f6f311a875455b800866a9c0b291d0)
  • Base 55e0593 → head 7e6aa9e, verified 2026-09-28T23:51:07.318Z: PASS
  • Verification report: agents/runs/checkout-workspace-binding/verification-report.json and agents/runs/checkout-workspace-binding/verification-report.md; source fingerprint d23453553dc787ca7614f8dfdf0c505a49065e1d66c2616e286564f5b4fea12f
  • Suites:
    • S1: GREEN bash scripts/verify-cargo.sh test (exit 0)
    • S2: GREEN bash scripts/verify-cargo.sh lint (exit 0)
  • Reviews:
    • Fidelity (b46f728, follow-ups at 5fb5b51): Fix now 1 e2e failures -> 813a754 renames a new owner's first tab; s2 and agent-tab-groups pass (12/12 x3). Fix now 2 B11 device folds under old ids -> 0d23a72 legacy_checkout_ids; device selection is never persisted. Evidence check: the checkout-owner log is tagged 0d23a72 but ran with the adoption spec that 5fb5b51 commits (registered files are append-only, so not renamed). Follow-ups: Reopen owner-lookup unit test, mark-failure counting, SidebarAgentSnapshot.workspace_label wire cleanup.
    • Code (b46f728, follow-up at 5fb5b51): hided disconnect disproved by logs (no panic). Path canonicalization rejected: I/O under the runtime mutex (B16), and a miss only costs one worktree.open answering already_open. Global plain-folder lock kept with its reason commented. Reopen position rule documented. Purpose never opens an owner (B16). Follow-up: prune legacy ids that never resolve. Open question (split part owner only at index 0) holds by construction: part 0 is the workspace's own folder, the only path Herdr binds or Hide marks.
    • Observer plan review: device rows bring the last host-focused tab per checkout forward (b46f728).
    • Merge follow-up review (aa502a8 merge of main + 65ccfc7): no Fix now. Conflict in agent_start_in_checkout keeps the owner host and carries main's payload.prompt; every Hide tab creation on the merged head goes through tab_host/ensure_owner. Follow-up: registration's needs_herdr_workspace compares ids adopt_registration always equalizes; harmless because ensure_owner reuses a bound or marked owner.
    • Observer notice (agent-tab-groups:157 failed 2 of 3 full runs): root cause was replica rejection of Herdr 0.9.1's late/early events (trailing tab_closed/pane_closed after workspace_closed, a new workspace's creation events arriving after later changes), which resynced and dropped Reopen; main shows the same rejection in three other specs. Fixed in 819054a; the fix exposed a relocation livelock that main's resync had been masking, fixed in 3b43c18.
    • Code review of 819054a: Fix now held pane focuses never purged, and no diagnostic on the already-applied path -> 626de09 (an applied focus supersedes held ones, retiring an id drops focuses held for it, event.already_applied). Follow-up fixed in 626de09: pane_moved's created tab cancels a pending closure. Follow-up left: names_retired does not cover workspace_closed, tab_moved, pane_moved or worktree events (they still resync as before).
    • Code review of 626de09 + 3b43c18: no Fix now standing. A relocation stamp left when the child stops qualifying cannot block a later move: only a stamp younger than RELOCATION_RETRY_INTERVAL_MS holds, and the map is pruned to panes Herdr reports. Follow-ups: a unit test for pane_moved cancelling a pending closure, and for the event.already_applied diagnostic.
    • Second main merge review (7e6aa9e): no Fix now. Conflicts in agents.rs, terminal.rs and the relocation test take main's Fix the web e2e flakes on loaded runners at their causes #249 version of the same fix; the surviving doc line and ARCHITECTURE sentence match it. Fix the web e2e flakes on loaded runners at their causes #249's reopen gate runs upstream of the owner path, and its fixture changes are compatible with checkout-owner.spec.ts. Follow-up: the page's recent_closed.can_reopen gate can trail the core, and an owner open before a reopen may widen that window (not reproduced).
  • Evidence: 25 registered (11 log, 4 screenshot, 10 file); paths are local to the run directory
    • agents/runs/checkout-workspace-binding/evidence/logs-e2e/web-e2e-checkout-owner-at-0d23a72e.log
    • agents/runs/checkout-workspace-binding/evidence/e2e-final/checkout-owner-git.png
    • agents/runs/checkout-workspace-binding/evidence/e2e-final/checkout-owner-adopt.png
    • agents/runs/checkout-workspace-binding/evidence/e2e-final/checkout-owner-linked.png
    • agents/runs/checkout-workspace-binding/evidence/e2e-final/checkout-owner-folder.png
    • agents/runs/checkout-workspace-binding/evidence/logs-e2e/web-e2e-full-at-b46f7288.log
    • agents/runs/checkout-workspace-binding/evidence/logs-e2e/web-e2e-rerun-s2-atg-at-813a754f.log
    • agents/runs/checkout-workspace-binding/evidence/logs-e2e/web-e2e-agent-tab-groups-x3-at-813a754f.log
    • agents/runs/checkout-workspace-binding/evidence/live-read/mac-workspaces.jsonl
    • agents/runs/checkout-workspace-binding/evidence/live-read/mini-workspaces.jsonl
    • agents/runs/checkout-workspace-binding/evidence/logs-e2e/wt-probe3.sh
    • agents/runs/checkout-workspace-binding/evidence/logs-e2e/web-e2e-full-at-65ccfc7a.log
    • agents/runs/checkout-workspace-binding/evidence/logs-e2e/web-e2e-full-traced-at-65ccfc7a.log
    • agents/runs/checkout-workspace-binding/evidence/logs-e2e/web-e2e-full-main-eb306645.log
    • agents/runs/checkout-workspace-binding/evidence/logs-e2e/web-e2e-full-at-44fa25b8-run1.log
    • agents/runs/checkout-workspace-binding/evidence/event-order/close-order-probe2.out
    • agents/runs/checkout-workspace-binding/evidence/event-order/create-order-probe.out
    • agents/runs/checkout-workspace-binding/evidence/event-order/reopen-order-probe.out
    • agents/runs/checkout-workspace-binding/evidence/event-order/move-order-probe.out
    • agents/runs/checkout-workspace-binding/evidence/event-order/main-eb306645-rejections-per-log.txt
    • agents/runs/checkout-workspace-binding/evidence/event-order/probe-rejections-per-run.txt
    • agents/runs/checkout-workspace-binding/evidence/event-order/sidebar-status-relocations-per-run.txt
    • agents/runs/checkout-workspace-binding/evidence/logs-e2e/web-e2e-full-at-44fa25b8-run2.log
    • agents/runs/checkout-workspace-binding/evidence/logs-e2e/web-e2e-full-at-7e6aa9e4.log
    • agents/runs/checkout-workspace-binding/evidence/logs-e2e/web-e2e-rerun-nosign-at-7e6aa9e4.log
  • Changed paths: 147 (see Files changed)

A checkout's owner is the Herdr workspace bound to its path (or, for a
plain folder, the workspace carrying Hide's owner mark), read from the
session Hide already holds. New tab and New agent here create their tab
there, opening the owner with worktree.open (or a marked workspace.create)
when none is open, instead of reusing the workspace of the visible tab or
creating a 'hide <checkout>' workspace.
A closed tab or a pane whose tab is gone is made again in the checkout's
owner Herdr workspace, opened first when none is open, instead of in the
workspace it was closed from or a new workspace.create. The original
index is restored only when the tab lands in the workspace it left.
An agent's identity was its task, else the label of the Herdr workspace
it ran in, which named another checkout as often as its own. It is now
the task, else the provider (`claude`, `codex`, or the kind Herdr reports),
and the tab ladder follows it. The unread workspace label also leaves the
pane rows the shell receives.
…orkspace

One device folder held by several Herdr workspaces is now one checkout row
keyed by its path, like this machine's. A new tab there goes to the
workspace Herdr binds to the folder (or the one carrying Hide's mark), and
opens one when none is open; opening a row brings its most recent tab
forward; purpose goes to the owner. A folder the device helper has not
confirmed is refused rather than opened on a guess about its kind.
…space Herdr newly opened

worktree.open on the pinned Herdr refuses a linked worktree unless it is
opened from the repository's main worktree, and applies its label to a
workspace that was already open, which renamed an operator's workspace in
the isolated run. The open now starts from the repository root with no
label, and a workspace Herdr newly opened is renamed after it opens. The
isolated-Herdr e2e covers a new tab asked from an unbound workspace, a
linked worktree with no workspace, and a plain folder.
… opens

The core remembers, per device checkout, the last tab the device's Herdr
had in focus there, as it remembers the visible tab on this machine, and
opening the row focuses that tab while it exists; the owner's active tab
is the fallback.
The first tab of an owner Herdr opened for a request is the new tab, but
it kept Herdr's default name, so a checkout's tab numbering restarted in
the new workspace. It is renamed to the requested label; a refusal only
logs, since the tab is real.
A fold saved while a device checkout was keyed by its Herdr workspace is
renamed to the folder-keyed id once the device's session names that
workspace, so upgrading does not collapse the operator's device rows. Also
records why plain-folder owner opens share one lock and when a reopened
tab keeps Herdr's place.
Resolves agent_start_in_checkout: the checkout's owner stays the tab host,
and main's agent-start prompt is carried through it.
Registering a project Herdr has no workspace in created an unbound,
unmarked workspace, which the owner rule then passed over: a plain folder
got a second, marked workspace on its first tab. Registration now opens
the checkout's owner the same way a new tab does.
…them

Herdr 0.9.1 emits workspace_closed before the tab_closed or pane_closed that
closed a workspace's last tab or pane, and emits a new workspace's creation
events after later changes: a seed tab replaced by layout.apply is announced
closed and then focused, given a pane and laid out, and a tab given focus as it is
created is announced focused before it exists. The replica read each as a
divergence and rebuilt from a snapshot, and while it did the latest close
stayed unconfirmed, so Reopen Closed Tab was dropped.

The replica now remembers the latest ids an event removed and treats an event
about one as already applied, holds a focus event until its tab or pane
arrives, and lets a tab created in a workspace waiting for its close cancel
that wait and read the active tab. Owner workspaces make closing a checkout's
last tab close a workspace, which made this path common.
…ady retired

A held focus for a pane that never arrived stayed in the replica, and a held
focus replayed after a newer applied focus would move focus back. A focus
Herdr applies now drops the held ones it supersedes, and retiring a tab or
pane drops the focuses held for it. An event treated as already applied
logs event.already_applied. A tab that pane_moved creates in a workspace
waiting for its close cancels that wait as tab_created does.
An acknowledged pane.move cleared its request stamp before Herdr's events for
the move arrived, so the next snapshot, still showing the child beside its
parent, asked again. Each repeat moved the pane out of the tab the previous
move had made and closed it, so that tab's layout arrived for a closed tab
and the workspace never published: the moves repeated until a replica resync
happened to break the loop (2 to 11 moves per run on main). With the replica
no longer resyncing on those late events the loop ran for the whole test.

The stamp now stays until the published layout shows the child in a tab of
its own, and the retry interval still bounds a move whose events never come.
main's #249 fixed the same delegated-pane relocation repeat this branch
fixed: both keep the move in flight until the layout shows it. Its version
also runs the pass after the update's layouts are stored, so the conflicts
in agents.rs, terminal.rs and the relocation test take main's side.
@yansfil
yansfil merged commit 2e44cce into main Sep 29, 2026
8 checks passed
@yansfil
yansfil deleted the prd/checkout-workspace-binding branch September 29, 2026 00:15
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.

1 participant