Repository navigation
test(qa): cover session and Workboard managed-worktree lifecycles; fix symlinked state-dir lock blindness - #120362
Conversation
Dependency graph guard clearedThis PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh
|
4a9f340 to
43255a4
Compare
|
Codex review: needs real behavior proof before merge. Reviewed August 7, 2026, 9:44 PM ET / August 8, 2026, 01:44 UTC. ClawSweeper reviewWhat this changesThis PR canonicalizes managed-worktree paths, migrates legacy persisted paths, and adds session and Workboard lifecycle QA coverage. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 4 items remain The patch appears correct and resolves the prior migration/read-only findings, but it needs attached exact-head real-behavior evidence before merge; the protected Priority: P1 Review scores
Verification
How this fits togetherManaged worktrees are Git checkouts created for agent sessions and Workboard cards. The service records their paths in the state database, then Git locks and owner cleanup determine whether they can be removed or restored. flowchart LR
A[Session or Workboard request] --> B[Managed worktree service]
B --> C[Canonical worktrees root]
C --> D[Git worktree and lock state]
B --> E[State database record]
E --> F[Doctor path migration]
D --> G[Cleanup or restore outcome]
Decision needed
Why: The source and tests are strong, but the public PR body has no inspectable after-fix runtime artifact beyond prose summaries. Before merge
Agent review detailsSecurityNone. PR surfaceSource +145, Tests +727, Other +59. Total +931 across 16 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep producer-side canonicalization and the Doctor-only legacy migration, then attach redacted exact-head behavior evidence for the session and Workboard flows before merging. Do we have a high-confidence way to reproduce the issue? Yes at source level: the focused regression constructs a symlinked state directory, creates a worktree, acquires its lock, and verifies lossless removal. The review did not execute the test under the read-only constraint. Is this the best way to solve the issue? Yes. Canonicalizing the path at the record producer repairs every downstream Git comparison, while Doctor owns migration of pre-existing persisted spellings. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5a79d19ba179. 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
History |
|
@clawsweeper re-review — the P1 (persisted-path migration for pre-upgrade rows) is applied on head c5923f2: the state-migration owner now canonicalizes legacy raw-root path spellings (live and removed rows, idempotent, read-only detection), with an end-to-end regression proving the migrated row survives the previously failing lock sequence. CI is green on this exact head. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Unblocks the check-lint gate broken by #120285's max-lines overflow.
|
@clawsweeper re-review — P2 applied on head 435ba64: legacy-state detection is now side-effect-free (no mkdir; read-only realpath fallback for missing roots; empty-state regression). Also includes the red-main check-lint repair (runs.test.ts split, #120285 overflow). CI green on this exact head. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…x symlinked state-dir lock blindness (openclaw#120362) * fix(agents): canonicalize managed worktree paths * test(qa): cover managed worktree owner lifecycles * test(agents): split worktree canonical-path regression into focused file * fix(doctor): canonicalize persisted managed-worktree paths for symlinked state dirs * fix(doctor): keep worktree path migration detection read-only * test(doctor): bound managed-worktree migration product proof * fix(doctor): keep worktree path detection from creating state dirs * test(doctor): allow state migration detection under CI load * test(agents): split embedded-runner steering runs into focused file Unblocks the check-lint gate broken by openclaw#120285's max-lines overflow.
What Problem This Solves
ClawSweeper's review of #120335 noted that the new
agent-runtime.managed-worktrees-lifecyclecoverage proves the manual-owner lifecycle only: session-owned and Workboard-owned worktree cleanup lifecycles (run-end lossless removal, session-deleteworktreePreservedreporting, gc owner protection) had no product-boundary proof.While building that proof, the Workboard e2e surfaced a real product bug: on a symlinked state directory (macOS
/tmp->/private/tmp), the managed-worktree service cannot recognize its own git lock, and Workboard run-end cleanup dies withfatal: cannot remove a locked working tree, lock reason: openclaw pid=....Why This Change Was Made
Product fix (root cause, producer-side).
git worktree listreports canonicalized paths, butrecord.pathwas minted from the rawresolveStateDir()(src/agents/worktrees/service.ts:636), solockState()ingit-lock.ts(and the siblingpath.resolvecomparisons at service.ts:146/269/304) compared a non-canonical stored path against git's canonical output and missed the service's own lock. The repo already canonicalizesrepoRoot(resolveRepositoryFromRealPath) and usescanonicalPathKeyin the orphan path; this fix extends the same invariant to the state-dir side: aworktreesRoot()helper mkdirs and realpaths the worktrees root once, used at the three minting/boundary sites (create,removeEmptyParentsboundary, orphan reconciliation). Producer-side canonicalization restores the invariant for every downstream comparison; the comparison sites stay untouched. Linux CI never saw this because/tmpis not a symlink there.QA coverage. Two new coverage IDs in the Agent Turn Execution taxonomy category, two scenarios, and two child-gateway product-proof e2e tests (QA live-lane harness, mock provider, real RPC boundary):
agent-runtime.managed-worktrees-session-lifecycle:sessions.createwithworktree: true/worktreeName/worktreeBaseRefreturns and persists the managed checkout; a real turn runs from it;worktrees.gcpreserves the live session-owned worktree; clean and dirtysessions.deletesnapshot and remove with a pinned restorable ref;worktrees.restorerebuilds dirty untracked state without the synthetic snapshot commit entering branch history; a foreigngit worktree lockmakes deletion reportworktreePreservedwith the checkout retained.agent-runtime.managed-worktrees-workboard-lifecycle:workboard.cards.dispatchmaterializes the card workspace aswb-<card-id>onopenclaw/wb-<card-id>, writes the resolved path/branch back to the card, the subagent run completes, and run-end cleanup removes the clean checkout losslessly.Intentionally not claimed: 7-day idle expiry (proving it at a product boundary would mean backdating SQLite rows; it stays unit-covered in
service.test.ts/owner-protection.test.ts) and Workboard dirty-retention (agent.waitcan resolve before the asyncsubagent_endedcleanup hook, and there is no product-boundary marker for "cleanup attempted" — a retention assertion would be false proof). Follow-up worth considering: record the run-end cleanup outcome as an observable fact on the card/registry so retention becomes provable.User Impact
Operators whose OpenClaw state directory traverses a symlink no longer hit failed Workboard run-end cleanup (and the same blind spot in lock recognition during remove/release). Session and Workboard worktree lifecycles are now covered by the QA scenario pack at the real gateway boundary.
Evidence
record.path->acquire->removeIfLosslesssucceeds.pnpm maturity:check: passed (no generated-doc changes required).gpt-5.6-sol, high): clean, no actionable findings.CI Fix Notes
check-linttripped max-lines onservice.test.tsafter the new regression test; the canonical-path tests (the new symlink regression plus the existing linked-checkout anchoring test) moved into focusedsrc/agents/worktrees/service.canonical-paths.test.ts, following theservice.orphans.test.tssibling convention.security-fastfailed on an unrelated freshly published advisory (HIGH nanoid <3.3.17, GHSA-2v37-7h3g-55p8, transitive via postcss). Fixed in this landing PR per the red-gate rule with a lockfile-only bump to nanoid 3.3.17;pnpm-audit-prodexits clean.ClawSweeper P1 (persisted rows): the state-migration owner (
state-migrations.doctor.ts) now canonicalizes legacy raw-root path spellings for live and removed rows (read-only detection, stale-safe id+old-path rewrites, idempotent), with an end-to-end regression proving the migrated row survives the previously failing lock sequence.ClawSweeper P2 (read-only detection): detection no longer mkdirs the worktrees root; missing roots resolve read-only via the state dir realpath, with an empty-state regression asserting diagnostics create nothing.
Red-main check-lint (2nd):
#120285landedruns.test.tsat 1001 lint-counted lines, failing every PR's core oxlint shard; smallest correct fix in this landing PR moves the steering/admission cluster into focusedruns.steering.test.ts(merge-ref result 748 lines, suppressions forbidden).Exact-head real-behavior proof
PR #120362 exact-head real-behavior proof
435ba64f0fed5c718a75b45a1dc5141a6af5ba7fSat Aug 8 01:53:13 UTC 2026v26.7.0<checkout>QA-enabled dist build
Session lifecycle product proof — PASS
Workboard lifecycle product proof — PASS
Worktree-path state migration proof — PASS