Repository navigation
fix(gateway): pass the session liveness predicate on every worktree gc path - #104146
ObliviateRickLin wants to merge 1 commit into
Conversation
|
Source review: this is the best current fix for #104108, and it is complementary to #103263 rather than duplicating it. I checked the full GC caller set on head No blocking code finding from this pass. The one remaining focused coverage gap is the CLI wiring: the RPC caller is identity-asserted and the predicate has active/stale/non-session/missing-owner tests, but there is no command-level regression proving Best-fix verdict: best. Alternatives considered: changing |
|
Codex review: needs maintainer review before merge. Reviewed July 11, 2026, 1:55 AM ET / 05:55 UTC. Summary PR surface: Source +8, Tests +56. Total +64 across 6 files. Reproducibility: yes. Current source exposes the missing-callback path, and the submitted real-system comparison demonstrates the active session checkout and uncommitted file being removed on current main. Review metrics: none identified. Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Next step before merge
Security Review detailsBest possible solution: Merge the shared-predicate fix after ordinary landing review, preserving one gateway-owned session-liveness policy across every production GC entry point while reviewing the complementary active-run leasing work separately. Do we have a high-confidence way to reproduce the issue? Yes. Current source exposes the missing-callback path, and the submitted real-system comparison demonstrates the active session checkout and uncommitted file being removed on current main. Is this the best way to solve the issue? Yes. Reusing the established gateway-owned predicate at all callers is narrower and more maintainable than duplicating session-key logic or making the generic worktree service discover gateway session state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 82abf7244d98. Label changesLabel justifications:
Evidence reviewedPR surface: Source +8, Tests +56. Total +64 across 6 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
…c path The worktrees.gc RPC handler and the CLI gc command called service.gc() with no isOwnerActive callback, while the scheduled maintenance sweep passes one. Session-owned worktrees take no git worktree lock (registry activity substitutes), so the callback is their only protection: the RPC and CLI paths force-removed an idle-expired worktree while its owning session was still live, destroying uncommitted work. The predicate now lives in one canonical module used by all three callers, with regressions for active/inactive session owners and the handler wiring. Fixes openclaw#104108
67a6b85 to
60d8001
Compare
|
Rebased onto current |
|
Re the The new module The |
|
Closing as superseded by #106224 (
So #104108's reported behavior — a manual |
|
Follow-up: the regression coverage from this report landed in #107989 as The landed commit preserves RickLin's co-author credit. Thanks @ObliviateRickLin for identifying and patching the liveness gap. |
What Problem This Solves
#104108 (P0): the
worktrees.gcRPC handler calledservice.gc()with no parameters, and the CLIopenclaw worktrees gcdid the same — neither passed theisOwnerActiveliveness callback that the scheduled maintenance sweep passes. Session-owned worktrees deliberately take no git worktree lock (registry activity substitutes; onlyservice.acquire()locks, and no session run path calls it), so insidegc()the owner-active guard short-circuits to false whenever the callback is absent. Result: a manual/adminworktrees.gcRPC or CLI run force-removes an idle-expired worktree while its owning session is still live, destroying any uncommitted work — the scheduled sweep, given identical inputs, retains it.Why This Change Was Made
Per the triage's best-solution shape ("one canonical session-owner activity predicate for scheduled and RPC-triggered GC … and resolve the CLI sibling without creating a second liveness policy"):
isManagedWorktreeOwnerActivemoves verbatim fromserver-maintenance.tsintosrc/gateway/worktree-owner-activity.ts— one canonical implementation (it stays in the gateway layer because it depends on the gateway session-key resolution insession-utils.loadSessionEntry, including legacy-key handling; re-deriving it elsewhere would create the second policy the triage warned about).gc()callers now pass it: scheduled maintenance (unchanged behavior, now importing the shared module), theworktrees.gcRPC handler, and the CLIworktrees gccommand.server-maintenance.tsshrinks by the moved lines.User Impact
An admin running
worktrees.gc(RPC or CLI) can no longer delete the working tree — including uncommitted changes — of a session that is actively in use. Workboard/manual worktrees are unaffected (they rely on the git-lock fallback on every path already).Evidence
Executed real-git before/after (real
ManagedWorktreeService+ realgit worktree+ real SQLite registry + real handler fromcreateWorktreesHandlers; session store shows the owner interacted now, registry idle-expired via injected clock, uncommittedwip.txtinside the worktree):worktrees.gcRPC resultwip.txtmainremoved: ["c52a19ce-…"]removed: []Regressions (all green):
worktree-owner-activity.test.ts(new): live session owner → active; idle-expired session → inactive; non-session owners → false (git-lock fallback owns them); unknown session → false. Forged real session store + runtime config snapshot.server-methods/worktrees.test.ts: the gc handler now must callservice.gc({ isOwnerActive: isManagedWorktreeOwnerActive })(asserted by identity) — fails on prior head wheregc()was called bare.agents/worktrees/service.test.ts27/27 (existing owner-activity semantics unchanged).Validation: handler + predicate suites 14/14;
tsgo:core0; oxlint/oxfmt clean; session-accessor boundary guard passed.Scope: #103263 (gc-internals leasing rework) is complementary — it re-checks
isOwnerActiveat removal time but still depends on callers supplying it, and does not touch the RPC handler or CLI; this PR closes exactly that supply gap, as the issue's sibling analysis notes.Fixes #104108
🤖 Generated with Claude Code
https://claude.ai/code/session_01AJogTw4aGDiacwqju1uod6