Repository navigation
Confirm a pane's creation cwd with one read before it is placed - #569
Merged
Merged
Conversation
Herdr 0.9.1 can announce a new pane with a cwd it was not created in (/tmp for a tab created in the project, seen on CI) and sends no later event for that pane, while agent.list lists agent terminals only. The replica now holds such a cwd as unconfirmed, and the coordinator reads each pane once with pane.get right after the event, off the runtime lock, before the pane's tab can publish. At most 64 panes wait; a pane past the cap keeps its event cwd and is logged.
This was referenced Oct 6, 2026
yansfil
added a commit
that referenced
this pull request
Oct 7, 2026
…ree (#705) Closes #699 ## Summary Linux에 부하가 걸리면 Herdr 0.9.1은 새 pane의 cwd를 잠깐 상위 폴더(`/`, `/tmp`, 프로젝트의 부모)로 답하고, 그 값이 바로잡힐 때 event를 보내지 않는다. #569/#665는 event 직후 `pane.get` 한 번을 확정으로 보았기 때문에, 그 한 번마저 상위 폴더를 답하면 탭이 부모 폴더의 project row에 남았다(`toHaveCount` 실패). 이제 replica의 미확인 cwd는 pane마다 직전 값과 읽은 횟수를 들고 있다. 읽은 값이 직전 값(처음에는 event 값)과 같을 때만 확정하고, 다르면 그 값을 publish한 뒤 기존 250 ms coordinator tick에서 runtime lock 밖에서 다시 읽는다. 8번 읽어도 같은 값이 두 번 이어지지 않으면 마지막 값으로 확정하고 `pane_cwd.unsettled`를 남긴다. 새 timer, sleep, 상태는 없다. ## Review - **판단해 주세요**: event 값과 첫 읽기가 같은 일시 값이면 그대로 확정된다. Herdr가 cwd 변화 event를 주지 않는 한 남는 한계다. - **조심해서 볼 파일**: `herdr-core/src/session_sync/replica.rs` - `unconfirmed_cwds`가 set에서 map(직전 값, 횟수, tick 경과)이 됐다. 첫 읽기는 event 직후 한 번, 다음 읽기는 한 tick이 지난 뒤부터. - **조심해서 볼 파일**: `herdr-core/src/session_sync/coordinator.rs` - operation tick에 `reread_pane_cwds`가 추가됐다(high-frequency path, Herdr 호출). 실패는 event 경로와 같이 replica를 다시 만든다. - **비용 검토**: 기다리는 pane이 없으면 tick당 추가 작업 0. 기다리는 pane당 tick마다 `pane.get` 하나, pane당 최대 8회(약 2초), 동시에 최대 64 pane(기존 cap). cwd가 바뀐 tick만 publish하고, lock 안 작업은 없다. ## Evidence - **확인한 것**: 결정적 core 재현 `a_pane_cwd_settles_when_two_answers_in_a_row_agree`(FakeHerdr). event `/tmp`, 읽기 `ROOT`, `ROOT/fixture`, `ROOT/fixture`. - **확인한 것**: 같은 테스트를 main(b8a495b) API로 돌리면 실패한다: `left: Some("/tmp/hde-root")`, `right: Some("/tmp/hde-root/fixture")`. 수정 후 통과. - **확인한 것**: 표의 네 행 모두 통과. 첫 읽기 확정(1회), 다른 값 뒤 확정(2회), 위 재현(3회), 상한 도달(8회 뒤 마지막 값, 9번째 읽기 없음). - **확인한 것**: event 직후 읽은 pane은 바로 다음 tick에 다시 읽지 않는다(Herdr 호출 수로 확인). - **확인한 것**: 로컬 `verify-cargo.sh nextest -p herdr-core` 1626/1626 통과, `fmt-check`, `clippy -p herdr-core --all-targets -D warnings` 통과. - **확인한 것**: 이 PR의 CI 전 lane 녹색(Linux web 4 shard, Windows web, rust workspace, os contract 포함). - **확인한 것**: TEMP 부하 반복(Linux, 모든 CPU busy loop, 해당 테스트 `--repeat-each 100 --retries 0`): after(이 PR, #704) 100/100 통과. - **확인하지 못한 것**: e2e에서의 수정 전 실패. 같은 조건의 before(main b8a495b, #703)도 100/100 통과해, 이 규모의 반복은 #699를 재현하지 못했다(새 탭 1500개). 수정 전후를 가르는 증거는 위 core 재현이다.
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.
Refs #550
Summary
tab-strip-fit.spec.ts"Agent tabs shrink in stages..."가 Linux에서 탭 16개 중 15개만 보던 제품 원인을 고칩니다.pane_created로 알릴 때, 그 pane이 만들어진 폴더가 아닌 cwd를 실을 수 있습니다.CI 재현에서 fixture 폴더에 만든 탭의
pane_created가/tmp를 실었고, 실패 시점의session.snapshot은 같은 pane에 fixture 폴더를 답했습니다.agent.list는 agent terminal만 나열하므로(0.9.1agent_info), plain shell의 cwd를 고치는 경로가 core에 없었습니다.replace_agents의 주석은agent.list가 plain terminal도 포함한다고 잘못 적고 있었습니다./tmpproject로 놓였고, fixture project의 탭 줄에는 15개만 보였습니다.replica.rs:pane_created로 알게 된 pane의 cwd를 '확인 전'(unconfirmed_cwds)으로 둡니다.상한은 64이고, 넘은 pane은 이벤트 cwd를 유지하며
pane_cwd.unconfirmed_over_cap을 남깁니다.pane, tab, workspace가 닫히면 함께 지웁니다.
coordinator.rs: 이벤트를 적용한 직후 runtime lock 밖에서, 확인 전 pane마다pane.get을 한 번 읽어 '확인됨'으로 만듭니다.답이 다르면 cwd를 바꾸고
pane_cwd.corrected를 남깁니다.타이머, 지연, 재시도는 없습니다.
layout_updated까지 publish되지 않으므로, 확인은 pane이 화면에 닿기 전에 끝납니다.pane_cwd_read.failed로그, snapshot에서 replica 재구성).읽기 전에 닫힌 pane(
pane_not_found)은 이벤트 cwd를 유지하고, 뒤따르는pane_closed가 지웁니다.docs/ARCHITECTURE.md: event sync 문단에 이 사실과 규칙을 적었습니다.Review
pane.get한 번이 늘어나고, 그동안 다음 이벤트 적용이 기다립니다.local은 socket 왕복 한 번, remote device는 SSH 왕복 한 번입니다.
닫힌 workspace의 활성 탭을 읽는
workspace.get확인과 같은 모양입니다.확인 읽기가 같은 이벤트 처리 안에서 끝나고, 새 pane은 그 뒤에 오는 layout까지 원래 publish되지 않기 때문입니다.
publish 게이트로 만들면 이 순서에 기대지 않지만, 기존 replica test가 모두 확인 단계를 거쳐야 해서 넣지 않았습니다.
herdr-core/src/session_sync/coordinator.rs: 이벤트 경로(runtime mutex 밖, 실패 경로).herdr-core/src/session_sync/replica.rs: 상태와 상한, 닫힘 때 정리.herdr-core/src/session_sync/subscription.rs: Herdr 계약.pane.get은 pinned schema에 있고, 응답은 기존wire::pane_session이 읽습니다.Evidence
실패한 회차의 hided 진단에서 빠진 탭의
pane_createdcwd는/tmp였고, 실패 순간 Herdr snapshot은 17개 pane 모두 fixture 폴더였습니다.같은 job의 CLI probe 507회에서는 생성 직후 첫
pane.get이 모두 fixture 폴더였습니다.session_sync::coordinator::pane_cwd_confirmation_tests).확인 읽기를 빼면(수정 전 동작) 2개가 실패합니다:
left: Some("/tmp"),right: Some("/tmp/fixture")와left: [],right: ["pane.get"].수정 후 3개 모두 통과합니다.
실패 1개는 이 변경과 무관한
hided::opener_lifecycle::acceptance_timeout_ends_cli_spawned_before_watcher(부하 중 20초 초과)이고, 단독 재실행에서 10/10 통과했습니다.tab-strip-fit.spec.ts를--repeat-each=20 --workers=8 --retries=0으로 돌려 이 test(:125)는 20/20 통과했습니다.같은 spec의 다른 test "File View tabs use the same shrinking strip..."(
:173)가 2/20 실패했습니다(파일 12개를 연달아 열 때项目计划.md또는検証結果.md하나가 열리지 않음).파일 View 열기는 pane을 만들지 않아 이 변경의 경로를 지나지 않으며, 별도로 보고했습니다.
cargo fmt --check통과.Linux 확인은 이 PR의 Linux e2e lane입니다.