fix: bound git worktree helper subprocesses - #136
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. Reviewed September 11, 2026, 12:31 PM ET / 16:31 UTC (Revision 6). ClawSweeper reviewWhat this changesAdds a shared subprocess waiter, applies a 15-second deadline to Git worktree helpers, and reuses the waiter for service restart handoffs. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 11 items remain The work remains necessary, but both prior blocking findings persist. Current main and v0.2.44 still use unbounded Git output calls; the submitted timeout implementation does not yet provide reliable completion or preserve valid slow operations. Priority: P2 Review scores
Verification
How this fits togetherOCM uses Git helpers to identify, create, validate, and remove OpenClaw source worktrees. Their results feed environment registration and simulation cleanup, so subprocess completion affects whether those workflows finish safely. flowchart TD
A[Environment or simulation request] --> B[Worktree checks]
B --> C[Git subprocess]
C --> D[Deadline and termination]
C --> E[Captured output]
D --> F[Completion result]
E --> F
F --> G[Continue or report failure]
Decision needed
Why: The proposed 15-second cutoff changes successful existing workflows, and the discussion contains no approved compatibility policy. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Bound subprocess and output completion together, preserve slow-operation compatibility by default, and make any stricter deadline an explicit policy backed by safe interruption and retry evidence. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the failure paths: a descendant retaining stdout blocks the unbounded join, and any valid Git operation exceeding 15 seconds is terminated. No runtime reproduction was executed during this read-only review. Is this the best way to solve the issue? No. Sharing the waiter is reasonable, but direct-child exit is insufficient to bound captured output, and one fixed deadline does not preserve slow worktree operations. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c5ac5392e142. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
b080857 to
0284e88
Compare
638df70 to
db422a7
Compare
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 <sebtardif@ncf.ca> (cherry picked from commit da84e02)
The 200ms deadline plus SIGTERM grace can exceed 1s on macos-latest. Keep proving we do not wait the full 30s sleep. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca> (cherry picked from commit db422a7)
db422a7 to
6a6dfd1
Compare
dev_stop_acknowledgement_refuses_live_recorded_ownership failed once on macos-latest; the same test passed on openclaw#117 and openclaw#136 from the same main. This PR does not touch that test. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
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.