fix: bound git worktree helper subprocesses - #136
Conversation
ensure_openclaw_worktree and related helpers used Command::output() with no deadline. A stuck git lock blocked ocm setup and cleanup. Wait with a timeout and kill the child. Signed-off-by: Sebastien Tardif <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed September 2, 2026, 4:06 PM ET / 20:06 UTC. ClawSweeper reviewWhat this changesThe PR routes OCM’s Git worktree commands through a shared timed subprocess runner and reuses its wait logic for restart-handoff commands. Merge readiness⛔ Blocked until stronger real behavior proof is added - 7 items remain Keep open: the shared timeout approach addresses a real worktree-flow hang, but the new runner can still block forever while joining inherited output pipes, and its universal 15-second limit can reject valid slow worktrees without an approved compatibility policy. Priority: P1 Review scores
Verification
How this fits togetherOCM creates, inspects, and removes disposable OpenClaw Git worktrees for development and upgrade simulations. These CLI flows invoke local Git commands and return either a usable worktree or an actionable setup or cleanup error. flowchart LR
A[OCM dev or upgrade] --> B[Worktree manager]
B --> C[Git helper command]
C --> D{Completes before deadline?}
D -->|Yes| E[Worktree result]
D -->|No| F[Terminate process group]
F --> G[Timeout error to CLI]
Decision needed
Why: The branch changes existing successful-workflow behavior as well as fixing hangs; the appropriate tradeoff between responsiveness and slow-repository compatibility requires maintainer intent. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the shared cancellation helper, but make the deadline cover process-group lifetime and output draining, then adopt an explicitly approved timeout policy that preserves valid slow worktree operations. Do we have a high-confidence way to reproduce the issue? Yes, source inspection gives a high-confidence reproduction shape: a direct child can exit while a descendant retains inherited output, causing the introduced reader joins to block indefinitely. The supplied terminal trace only covers a foreground child that exceeds its deadline. Is this the best way to solve the issue? No, not as submitted: centralizing cancellation is maintainable, but the deadline must include output-drain completion and the 15-second compatibility policy needs maintainer approval. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: not found in the target repository. Codex review notes: model internal, reasoning high; reviewed against e04c10166d6b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
What Problem This Solves
Fixes an issue where
ocmdev, setup, and upgrade would hang forever when a git worktree helper (worktree add/remove/status/ls-files/submodule foreach) blocked on a lock or a stuck child. Those helpers calledCommand::output()with no kill deadline.On origin/main the hang is here:
ocm/src/openclaw_repo.rs
Lines 123 to 129 in e04c101
e04c101
Why This Change Was Made
Production worktree helpers now go through a shared timed runner. The child is polled, then terminated (process group TERM, then KILL) when the deadline expires. Fixture git used only to build temp repos stays unbounded.
User Impact
A wedged git during worktree setup or cleanup fails after 15s instead of blocking the CLI. Successful worktree add/remove/status behavior is unchanged.
Evidence
terminal output from a rustc one-off against
/bin/sleep 30. NaiveCommand::output()is still running after 1s. The timed runner returns an error at the 200ms deadline.The same deadline-and-kill path is what
git_outputnow uses for worktree add, remove, status, ls-files, and submodule foreach.Real behavior proof
Behavior or issue addressed: Git worktree helpers no longer block
ocmforever. A child that does not exit is killed when the 15s deadline is reached.Real environment tested: macOS (Darwin 25.6.0 arm64), rustc 1.98.0, ocm checkout
/tmp/ocm-F004onfix/git-worktree-timeoutabove origin/maine04c10166d6b58932213bf8422ccfc201cf6ac37.Exact steps or command run after this patch:
rustc
/tmp/naive_sleep_output.rsand/tmp/timed_sleep_output.rs, then run both binaries against/bin/sleep 30. Then run the built lib binaryocm-c8830440f3406352 git_timeout --nocapture.Evidence after fix: terminal output above. Naive
Command::output()was still running after 1002ms. The timed runner printedsleep timed out after 200ms after 202.924541ms.Observed result after fix: The helper returns a timeout error in about 200ms and the sleep child is gone. Worktree add/remove/status on a temp OpenClaw fixture still succeeds through the same
git_outputpath.What was not tested: A live
index.lockhang inside a full OpenClaw checkout duringocm setup, and the Windows job-object kill path.