Repository navigation
fix(hooks): leave mounts below the session folder to their daemons - #361
Conversation
A session in a home folder resolves to every mount on the device, and the turn-start hook walked each one in the foreground when no daemon vouched, outlasting the hook's 30 s timeout on every prompt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
runbear-bot
left a comment
There was a problem hiding this comment.
Bobb's bot(Totoro) Review
Conclusion: not-ready
- 상위 폴더의 여러 마운트가 동시에 동기화 중이면 훅이 마운트별 잠금을 순차적으로 기다려 여전히 타임아웃될 수 있습니다.
--defer에서 데몬 시작이 노트 저장보다 먼저여서 첫 스캔의 세션 출처가 누락될 수 있습니다.- 마운트 내부는 기존 사이클 경로를 유지하고, inbound spool은 별도 잠금으로 보호되는 것을 확인했습니다. 이전 리뷰 차단 사항은 없습니다.
- 깨끗한 체크아웃에 실행 환경이 없어 로컬 패키지 테스트는 실행하지 않았습니다.
| continue | ||
| } | ||
| if h, ok := runHookSync(cmd, target, sessionID, hookLabel); ok { | ||
| if h, ok := runHookSync(cmd, target, sessionID, hookLabel, !below); ok { |
There was a problem hiding this comment.
[P1] 상위 폴더에서 cycle=false여도 runHookSync는 각 마운트마다 daemonCurrent의 최대 5초 잠금 대기를 순차 실행합니다. 여러 대형 마운트의 데몬 사이클이 동시에 진행 중이면 6개만으로도 30초 훅 제한을 넘겨 이 PR이 해결하려는 타임아웃이 재현되고 뒤의 마운트는 처리되지 않습니다. 상위 폴더 경로는 잠금을 비차단/짧은 공통 예산으로 검사하거나, 검사를 건너뛰고 spool을 읽도록 해 전체 훅 지연을 제한해 주세요. --defer의 동일한 대기도 함께 처리해야 합니다.
| return st.SaveNoteForMount(proj.ID, note, noteTTL) | ||
| } | ||
| if below { | ||
| daemon.EnsureRunningAsync(vdir, 3*time.Second, 10*time.Second) |
There was a problem hiding this comment.
[P2] 노트를 저장하기 전에 데몬을 시작하면 새 워커가 먼저 변경 파일을 스캔·커밋할 수 있습니다. 그 경우 이 편집은 세션 노트 없이 영구 기록되며 이후 노트 저장으로 소급 수정되지 않습니다. 먼저 SaveNoteForMount를 성공적으로 완료한 뒤 데몬을 시작해 첫 스캔부터 출처가 적용되도록 해 주세요.
…e first Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed both in 467ef66: above a mount neither hook calls daemonCurrent, so there is no per-mount lock wait (TestHooksAboveAMountDoNotWaitForTheDaemonCycle: 5 s each before, immediate now); --defer saves the note before EnsureRunningAsync. |
runbear-bot
left a comment
There was a problem hiding this comment.
Bobb's bot(Totoro) Review
Conclusion: not-ready
- 상위 폴더에 여러 마운트가 있을 때 첫 마운트에서 전역 데몬을 시작하면 다른 마운트의 세션 노트 저장보다 초기 스캔이 먼저 실행될 수 있어 이전 출처 누락 차단 사항이 완전히 해결되지 않았습니다.
- 상위 폴더 경로에서
daemonCurrent잠금 대기를 건너뛰고, 마운트 내부에서는 기존 사이클 경로를 유지하는 것을 확인했습니다. - 깨끗한 체크아웃의 실행 환경 제약으로 로컬 패키지 테스트는 실행하지 않았습니다.
| if err := st.SaveNoteForMount(proj.ID, note, noteTTL); err != nil { | ||
| return err | ||
| } | ||
| daemon.EnsureRunningAsync(vdir, 3*time.Second, 10*time.Second) |
There was a problem hiding this comment.
[P2] 상위 폴더에 여러 마운트가 있고 데몬이 꺼져 있으면 첫 대상의 노트만 저장한 뒤 전역 supervisor를 시작합니다. supervisor는 모든 활성 볼륨의 워커를 즉시 시작하므로, 뒤쪽 대상의 SaveNoteForMount 전에 그 변경을 스캔·커밋하여 세션 출처가 누락될 수 있습니다. --hook의 대상별 데몬 시작에도 같은 문제가 있습니다. 모든 대상에 노트를 먼저 저장한 다음 데몬을 깨우거나 시작하도록 두 단계를 분리하고, 여러 마운트의 초기 스캔 순서를 검증해 주세요.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed in 714bb6f: both hooks collect the volumes and start daemons only after every target's note is saved (TestHooksAboveMountsSaveEveryNoteBeforeStartingTheDaemon; fails when the start follows each mount). The lock-wait inline at cmds.go:164 is from the previous round and was fixed in 467ef66 (TestHooksAboveAMountDoNotWaitForTheDaemonCycle). |
runbear-bot
left a comment
There was a problem hiding this comment.
Bobb's bot(Totoro) Review
Conclusion: ready
- 상위 폴더에서는 두 훅 모두 볼륨 사이클과
daemonCurrent대기를 건너뛰고, 대상 처리 후 데몬을 시작합니다. 이전 리뷰의 잠금 대기 및 다중 마운트 노트 저장 순서 차단 사항이 해결됐습니다. - 마운트 내부의 기존 동기화 경로와 일시 중지·미등록 마운트 차단을 확인했습니다.
- 깨끗한 체크아웃의 실행 환경 제약으로 로컬 패키지 테스트는 실행하지 않았습니다.
TL;DR
$HOMEtimed out its turn-start hook on every prompt ("beardrive: pulling latest files", 30 s). Its folder sits above every mount on the device, sobdrive sync . --hookresolved to all of them and ran a full cycle on each when no daemon vouched (on Liam's MacBook: a 49k-file team mount, on bdrive 0.15.0, which predates the daemon fast path from perf(hooks): leave the sync to a running daemon instead of walking the tree #343).wiki/),sync --hookandsync --defernever run a cycle of their own. They record the session for every mount first and start the daemons after (one supervisor runs every mount's worker, so starting it for one mount could scan the next before its note is saved), report what the daemon has recorded (inbound changes, secret findings, links), and start the daemon if it is not running. They also skip the wait for a daemon cycle in flight (daemonCurrent, up to 5 s per mount), which below a home folder adds up per mount. A session at or inside a mount is unchanged: it still pulls itself when the daemon cannot vouch.Changes
cmd/bdrive/helpers.go:syncTargetsBelow(folder)reports whensyncTargetsresolved to the mounts below the folder.cmd/bdrive/hooksync.go:runHookSync(..., cycle bool); withcyclefalse it skipsattachRemoteandCycleand drains what the daemon recorded.cmd/bdrive/cmds.go:--hookpasses!below;--deferabove a mount saves the note instead of cycling; both hooks start daemons (ensureDaemon, i.e.daemon.EnsureRunningAsync) after every target is handled.manual/hooks.md(sessions above synced folders),architecture/cli-sync.md(AgentHooks note).Trade-off
Tests
TestHookAboveAMountLeavesTheSyncToItsDaemon: hook in the mount's parent, no daemon: nothing committed, the mount's link still emitted.TestDeferredSyncAboveAMountOnlyRecordsTheNote:--deferin the parent: nothing committed, note recorded.TestHooksAboveAMountDoNotWaitForTheDaemonCycle: with a daemon cycle holding the volume lock, both hooks above the mount return at once (without the change, 5 s each).TestHooksAboveMountsSaveEveryNoteBeforeStartingTheDaemon: two mounts below the folder; when the daemon is first started, both already hold the session note (fails when the start follows each mount).go test ./cmd/bdrive ./internal/agenthookspasses.Architecture changes
architecture/cli-sync.md: the AgentHooks note gains the exception for mounts below the session folder.classDiagram class AgentHooks { turn-start: sync --hook post-edit: sync --defer --note } note for AgentHooks "✅ mounts below the session folder: never cycled by the hook, left to the daemon (EnsureRunningAsync)"🤖 Generated with Claude Code