Repository navigation
fix: preserve managed checkouts with shared project references - #126004
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 9:28 PM ET / August 19, 2026, 01:28 UTC. ClawSweeper reviewWhat this changesThe PR serializes managed-project registration and deletion by canonical checkout path, preserves shared managed checkouts, and makes Gateway chat cleanup retain its terminal-success assertion. Merge readinessNo blocking correctness findings at the current head. The earlier lifecycle and terminal-assertion concerns are addressed; this maintainer-labeled PR should remain open for exact-head CI and normal owner review. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherManaged project records in the shared state database feed Gateway project operations and point to local checkouts. Registration, deletion, sessions, worktrees, and agent work must agree on whether a checkout remains usable. flowchart LR
A[Project add or remove request] --> B[Project registry]
B --> C[Checkout lifecycle lease]
C --> D[Shared state database]
C --> E[Managed checkout]
E --> F[Gateway project operations]
F --> G[Sessions and worktrees]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +155, Tests +198. Total +353 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the canonical checkout-lifecycle repair once exact-head CI confirms the focused registry and Gateway paths, retaining the single lease boundary rather than restoring uncoordinated early returns or deletion steps. Do we have a high-confidence way to reproduce the issue? Yes, from source: concurrent existing-project return or registration can overlap final managed-checkout deletion; the PR adds deferred-order regressions for both paths. Is this the best way to solve the issue? Yes: the checkout-root lease at the registry/clone owner is preferable to a Gateway-only guard because every existing return, registration, and final deletion passes through it. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 61eb7b932b91. 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
HistoryReview history (3 earlier review cycles)
|
f3158e1 to
6930b6f
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
6930b6f to
0b34093
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
0b34093 to
78d878b
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Land-ready evidence for prepared exact head
The final judged surface is six files: production +233/-78 (net +155), tests +202/-4 (net +198). The production growth is the canonical cross-process checkout lifecycle owner, authoritative registration/deletion coordination, and legacy ownership transfer. There are no protocol, config, dependency, schema-version, docs, or changelog changes. No external live channel proof is needed: this is deterministic internal SQLite, filesystem-checkout, and Gateway lifecycle behavior with no external API or channel boundary. |
|
Merged via squash.
|
…law#126004) * fix: preserve shared managed project checkouts * test(gateway): drain root work without agent wait * fix(projects): complete canonical checkout lifecycle
Closes #125976
What Problem This Solves
Fixes an issue where removing one managed project could delete its physical checkout while another selectable project registration still referenced the same canonical repository root. The surviving project then pointed at a directory that no longer existed.
Why This Change Was Made
Project registration and managed-checkout deletion now share a lifecycle lease keyed by the canonical repository root. Every return of an existing canonical project is serialized under that checkout lifecycle and re-read before it can be returned, while the clone lease remains the outer operation boundary. Registration deduplicates canonical roots transactionally, and deletion removes one registry reference and re-reads sibling rows immediately before physically deleting only the final managed checkout.
For legacy mixed registered/cloned rows, the removal transaction transfers managed ownership and the clone origin to the surviving registered sibling. That keeps the checkout selectable while it is referenced and preserves a later path to final managed-checkout cleanup. Existing workspace, worktree, and session protections remain in place. No SQLite schema version changes are required.
The Gateway chat test helper now drains canonical root work first, then retains the successful terminal assertion through a nonblocking
agent.wait(..., 0). This prevents the known compact-shard cleanup cascade without weakening the acceptance-path outcome check.User Impact
Operators can safely remove duplicate or overlapping managed project entries without invalidating the remaining project. Concurrent add/remove operations cannot return a selectable project whose checkout has just been deleted, and legacy mixed-source registrations do not strand a managed checkout after the final usable reference is removed.
Evidence
node scripts/run-vitest.mjs src/projects/project-registry.test.ts src/gateway/server-methods/projects.test.ts— 24 registry tests and 12 Gateway project RPC tests passed after the final rebase.OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/gateway/server.chat.gateway-server-chat.test.ts— 55/55 passed serially after the final rebase.node scripts/run-vitest.mjs src/gateway/server-methods/chat-send-dispatch-errors.test.ts src/process/gateway-work-admission.test.ts— the cleanup-owner suites passed 5/5 and 18/18 on the reviewed working tree.node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfoandnode scripts/run-tsgo-core-test-shards.mjspassed after the final rebase.pnpm check:import-cycles— zero runtime value cycles.node scripts/check-native-state-schema-version.mjs— schema remains v9.git diff --checkpassed.origin/mainreported no accepted/actionable findings (overall correctness 0.97).AI-assisted: implementation and review were performed with coding agents under maintainer supervision.