Repository navigation
Recover Herdr connections without replaying read work - #115
Merged
Merged
Conversation
yansfil
added a commit
that referenced
this pull request
Oct 29, 2026
…lakes (#1819) Closes with-hide/hide-private#304 Closes with-hide/hide-private#305 ## Summary 부하에서 가끔 깨지던 Rust 테스트 두 건의 원인을 고칩니다. 같은 묶음의 나머지 세 건은 이슈별로 아래에 적었습니다. - **#304 OpenCode 사용량 읽기**: 읽기가 10 ms 시간 예산을 첫 행을 읽기 전에도 검사해서, DB를 여는 데 그 시간을 넘기면 행을 하나도 읽지 않고 끝났습니다. 이제 예산은 둘째 행부터 검사합니다(줄 파일 읽기와 같은 규칙). 그래서 읽기는 언제나 전진합니다. 테스트는 시간 예산이 자를 수 있는 정확한 개수(첫 읽기 2행) 대신, 읽기마다 scan total 이하(3 MiB 행 2개), 더 남은 읽기는 1행 이상, 전체 4행을 단언합니다. - **#305 늦게 세션을 보이는 자식의 bind**: 테스트가 session sync 대신 lineage writer를 관찰시키는데, 세션이 보인 뒤 한 번만 관찰시킵니다. writer는 이전 batch가 아직 worker에게 넘어가지 않았으면 그 관찰을 다음 관찰에서 처리하므로, 부하에서 worker가 늦으면 bind가 계획되지 않았습니다. 테스트가 이제 at-rest batch를 worker가 가져간 뒤에 세션을 보이게 합니다. - **#174** links_store_busy: main의 1a90d50(#1567)가 이미 고쳤고 그 뒤 재발이 없어 근거와 함께 닫았습니다. - **#134** agy signed in: 그 lane은 ff9b090(운영자 결정 10-27)로 CI에서 빠졌고, 남은 agy contract는 세 OS 모두 통과해 닫았습니다. - **#115** perf topology 'Build the web shell': main에서도 다시 실패합니다(원인: 웹 타입검사 시간이 catalog와 함께 커짐). 고치는 방식을 conductor에게 묻는 중이라 이 PR에는 아직 없습니다. 스크린샷 없음: 화면을 바꾸지 않는 테스트와 읽기 경로 변경입니다. ## Review - **판단해 주세요**: #305를 제품이 아니라 테스트에서 고친 판단. 운영에서는 subscription이 살아 있는 동안 session sync가 1초마다 `agent.list`를 묻고 답마다 `writer.observe`를 부릅니다(`session_sync/coordinator.rs` 318-322행, 825-836행). 미뤄진 관찰은 `pending_retry`로 남아 다음 관찰이 바뀐 것 없이도 계획하고(`a_full_pending_batch_is_retried_without_duplicating_in_flight_patches`), 재연결은 `changed=true`로 다시 관찰합니다. 그래서 운영에서 미룬 관찰을 잃지 않고, 관찰을 한 번만 하는 쪽은 테스트였습니다. - **판단해 주세요**: #304 테스트의 기대값 변경. 요구(scan total을 넘는 행은 다음 읽기가 읽는다)는 그대로이고, 시간 예산이 자를 수 있는 정확한 개수를 단언하던 테스트가 요구를 잘못 표현했던 것입니다. 시간 예산(10 ms)은 바꾸지 않았습니다. - **조심해서 볼 파일**: `hide-session/src/usage/opencode.rs` - 사용량 읽기 경로(high-frequency path). 행마다 하는 일은 그대로이고, 첫 행에서 시간 검사 하나를 건너뜁니다. - **조심해서 볼 파일**: `herdr-core/src/coordination/lineage.rs` - 테스트 전용(`#[cfg(test)]`) 조회 하나만 더했습니다. ## Evidence - **확인한 것**: #305는 worker가 batch를 가져가기 전에 300 ms 지연을 심어 이슈와 같은 실패(`timed out waiting for the core binds the late child`)를 재현했고, 수정한 테스트는 같은 지연에서 통과했습니다. 지연은 되돌렸습니다. - **확인한 것**: #304는 scan total을 끄는 결함을 심으면 새 테스트가 `read 1 took 4 rows`로 실패하는 것을 확인하고 되돌렸습니다. - **확인한 것**: `scripts/verify-cargo.sh nextest -p hide-session -p herdr-core` 3796개 통과, `scripts/verify-cargo.sh lint`(fmt, clippy 전체) 통과. 로컬 load average 15-80, 디스크 98%. - **확인한 것**: `nightly.yml` lane=agy를 main 047d0944d에서 dispatch, agy contract와 agent trust contract 6개 job 모두 통과(run 40803128207). - **확인하지 못한 것**: `perf.yml` dispatch(run 40803125317)는 main에서 'Build the web shell'이 5분을 넘겨 실패합니다(#115, 위). 이 PR은 그 lane을 고치지 않았습니다. - **확인하지 못한 것**: #304의 "첫 행은 항상 읽는다"는 시계를 주입할 수 없어 결정적인 테스트가 없습니다. 부하에서만 새 단언(더 남은 읽기는 1행 이상)이 그 결함을 잡습니다. <details><summary>Verification record</summary> - base 047d094, head 7feb3b2 </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.
Summary
Hide no longer dispatches the persisted pane restore against the initial disconnected snapshot, so relaunching does not present the internal "Waiting for the first herdr connection attempt" refusal as an operator modal.
The shell now probes the selected socket with the bundled Herdr CLI, starts one bundled server when needed, and retries recovery with a bounded five-attempt backoff after the server exits or the socket becomes unreachable.
The child server inherits the same Herdr session, config, state, and socket routing as the core.
Read records now survive a Herdr restart without turning every previously reviewed completion back into Done.
Eviction follows authoritative pane topology rather than the temporarily incomplete agent list, and a saved record is rebased only when the process-local sequence moved backwards while session identity, demand, and activity still match.
Review focus
macos/Sources/HerdrMacOS/CoreBridge.swift의 복구 태스크 수명과herdr-core/src/sidebar.rs의 read record 재조정 조건이 핵심입니다.Risk surface
pane_read_records에 optionalsession_id를 추가합니다. 이전 state는 기본값으로 그대로 읽히며 새 wire 채널은 없습니다.status server --json만 추가로 호출합니다. socket API method나 generated schema field는 추가하지 않았습니다.Evidence
origin/main을 반영한 PR head3108966에서check-hide-full.sh가 통과했습니다. Rust workspace 577 passed, 0 failed, 6 ignored. Swift 496 passed, 0 failed. 필수 저장소 게이트, design contract 7개, script suite 38개, pinned Herdr 0.9.1 schema/full contract를 모두 통과했습니다.8246616의 격리 bundle0.0.0-dev+8246616로 saved pane selection이 있는 cold launch를 실행했습니다. 앱 PID 98424가 private server PID 98476을 시작했고, 화면은 modal 없이Connected to Herdr였습니다. PID 98476 종료 뒤 같은 앱 PID가 PID 7947을 시작해 다시 연결됐습니다. 앱 종료와 server SIGKILL로 실제 stale Unix socket을 남긴 뒤 재실행했을 때 앱 PID 11392가 server PID 11425를 시작했고, 다시 modal 없이 연결됐습니다. 운영 앱 PID 6282와 기본 Herdr 서버는 변경하지 않았습니다. 이후 합친 main의 21개 변경 경로는 이 PR의 18개 변경 경로와 겹치지 않았습니다./Applications/hide.app설치와 release archive 검증도 이 PR에서는 실행하지 않았습니다.8246616의 isolated bundle과 private Herdr session입니다.Cold launch with saved pane selection
Automatic reconnect after the private server exits
Relaunch with a real stale Unix socket
AI tooling
손으로 확인한 것: 공식 Herdr CLI와 socket 계약, 최종 diff, 정확한 앱/server PID, 세 번의 native 화면 상태, 운영 앱과 기본 서버의 보존을 직접 대조했습니다.