Skip to content

Close an earlier spawn attempt's pane only while it runs the terminal that attempt recorded - #876

Merged
yansfil merged 1 commit into
mainfrom
fix/unstarted-attempt-pane-identity
Oct 9, 2026
Merged

yansfil merged 1 commit into
mainfrom
fix/unstarted-attempt-pane-identity

Conversation

@yansfil

@yansfil yansfil commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #874

Summary

spawn 재시도는 같은 parent/name/machine의 앞 시도 중 agent가 뜨지 않은 빈 pane을 닫습니다(#870). 그 pane은 spawn record의 pane id로만 찾았는데, Herdr는 서버가 바뀌면 pane id를 다시 내주므로 운영자가 연 무관한 빈 셸이 닫힐 수 있었습니다.

  • spawn record가 pane을 기록할 때 그 pane의 Herdr terminal_id(pane.get)를 함께 기록합니다(SpawnRecord.terminal, 같은 Advance 한 번).
  • 앞 시도의 pane은 pane.get이 지금도 그 terminal을 답할 때만 닫습니다. 다른 terminal이면 pane_replaced, terminal이 없는 예전 record면 pane_identity_unrecorded로 spawn / unstarted_attempt.close에 남기고 열어 둡니다.
  • 현재 시도 자체의 처리(agent_not_started, 시작 실패)는 그대로입니다. 나이 기준, 지연, 이름 추정은 없습니다.
격리된 pinned Herdr 0.9.3, server stop 후 재시작(복원):
before [('w1:p1', 'term_65d66b459dfdf1')]
after  [('w1:p1', 'term_65d66b46b777b1')]

Review

  • 판단해 주세요: 이 변경 전 build가 쓴 미완료 spawn record는 terminal이 없어 그 pane을 더는 자동으로 닫지 않습니다. 그런 탭이 남으면 운영자가 닫아야 합니다.
  • 조심해서 볼 파일: herdr-core/src/coordination/executor.rs - failure path: pane을 기록하던 두 갈래(기존 worktree, 새 worktree)를 하나로 모아 pane.get 뒤 Advance 한 번. pane.get 실패는 spawn 실패로 올라가고, 같은 intent 재시도는 hide:<spawn> tab label로 그 pane을 다시 찾습니다.
  • 조심해서 볼 파일: herdr-core/src/coordination/mod.rs - delivery ledger 필드 추가(#[serde(default)], ledger version 1 유지). Advance는 저장된 terminal과 다른 값이 오면 다른 필드처럼 intent_conflict.
  • 비용 검토: spawn이 pane을 기록할 때 pane.get 1회, 재시도마다 앞 시도 pane당 pane.get 1회. 고빈도 경로 아님, lock 밖.

Evidence

  • 확인한 것: 격리된 pinned Herdr 0.9.3에서 서버 재시작 뒤 복원된 pane이 같은 id(w1:p1)에 새 terminal id를 받음(위). Herdr v0.9.3 소스도 terminal마다, 복원 때도 TerminalId::alloc().
  • 확인한 것: 새 단위 테스트(FakeHerdr): 같은 terminal은 닫힘, pane id 재사용(다른 terminal)과 terminal 없는 record는 열린 채 이유와 함께 로그. 앞 시도 판정을 빼면 ["w2:p1","w2:p2","w2:p3"]가 닫혀 실패함을 확인.
  • 확인한 것: device spawn 테스트가 record에 device-terminal이 기록됨을 확인. herdr-core+hided nextest 2,255 passed, verify-cargo.sh lint pass.
  • 확인한 것: check-core-touches-no-machine.py, check-no-workstation-identity.sh, check-capability-readers-off-lock.sh, check-no-attribution.py pass.
  • 확인하지 못한 것: 운영자 Herdr에서의 실제 재현(이슈 단계 3의 서버 교체 + 무관한 빈 셸)은 운영자 서버를 건드리지 않으려고 하지 않았습니다. live handoff에서 terminal id가 유지되는지는 재지 않았습니다(유지되면 같은 pane으로 닫히고, 바뀌면 열어 둡니다). Linux/Windows는 CI에 맡깁니다.

… that attempt recorded

A spawn retry closed every earlier attempt's idle pane matched by pane id
alone. Herdr hands pane ids out again once its server is replaced, so a
record written before that could name an unrelated idle shell.

The spawn record now keeps the Herdr terminal id its pane ran when the
spawn recorded the pane, and an earlier pane is closed only while pane.get
still reports that terminal. A pane id running another terminal, and a
record written before terminals were recorded, are logged and left open.

Fixes #874
@yansfil
yansfil merged commit f2ad76a into main Oct 9, 2026
20 checks passed
@yansfil
yansfil deleted the fix/unstarted-attempt-pane-identity branch October 9, 2026 13:07
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.

A spawn retry can close an unrelated idle shell whose pane id an earlier failed attempt used

1 participant