Repository navigation
Conversation
Route cloned project sessions and repository URL preparation through managed worktrees, including omitted or false worktree intent and retries of older pending URL sessions. Keep registered local folders selectable as current checkouts. Reuse existing scratch retention custody and preserve unregistered nested worktrees whose contents cannot be removed losslessly.
|
🦞👀 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 Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 205071f48b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (requestedProject.value.worktree || requestedProjectGitUrl) { | ||
| p.worktree = true; |
There was a problem hiding this comment.
Preserve accepted checkouts when adopting existing session keys
When an existing session bound directly to a cloned project is adopted through sessions.create with its key and the same projectId, omitting worktree or setting it to false now silently relocates it. This assignment installs the worktree preparation lifecycle even though existingTargetEntry exists; prepareSessionWorktreeCreation allocates a checkout, and projectPreparedSessionWorkspace overwrites the existing session's cwd while retaining its conversation. Uncommitted files and scratch in the previously accepted checkout consequently disappear from the agent's working context, contrary to the documented promise that existing sessions retain their accepted directories. Apply automatic managed placement only to genuinely new sessions, while preserving explicit worktree requests and pending-preparation recovery.
Useful? React with 👍 / 👎.
|
Codex review: blocked before merge. What this changesThis PR routes new cloned-project and repository-URL sessions into managed worktrees while retaining Current checkout for registered folders. Example: Create a cloned-project session with worktree=false, then write a 16 MiB temporary build.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open: the placement fix is useful, but automatic worktree selection also silently relocates existing keyed sessions. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway session admission resolves the selected project, prepares its workspace through the managed-worktree owner, and persists the cwd consumed by agents and terminals. flowchart TD
A[Session creation request] --> B[Project access and source selection]
B --> C[Managed worktree preparation]
B --> D[Registered current checkout]
C --> E[Session workspace binding]
D --> E
E --> F[Agent and terminal execution]
F --> G[Scratch maintenance]
Technical reviewBest possible solution: Apply automatic managed placement to new sessions while preserving accepted keyed-session workspaces and pending-preparation recovery. Do we have a high-confidence way to reproduce the issue? Current main binds cloned projects directly when worktree is omitted or false; the PR reports two public-handler regressions failing on its parent and passing with the change, but this review ran no target code. Is this the best way to solve the issue? Choosing placement at admission and removing direct URL-to-clone binding addresses the producer of the problem without another cleanup mechanism; automatic selection must respect existing accepted sessions. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e23c587c16f3. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource -7, Tests +137, Docs +15, Other +98. Total +243 across 10 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 9, 2026, 2:28 PM ET / 19:28 UTC. |
|
Exact-head CI attribution for Both failures are inherited. The test-lines checker passes on this PR's head: 6,604,381 lines / 6,604,387 ceiling, six lines slack. The PR adds exactly 137 test lines and already includes an exact 137-line allocation in The gateway timeout is a separate main regression introduced by Causal comparison: on that exact main parent, reversing only the introducing commit's Focused product proof and the fresh independent Codex review remain clean through P2. CI is still red, not relabeled green. Landing this exact head uses the explicitly authorized inherited-failure exception with retained checkout, baseline, differential, and source-equality evidence. No source change or CI rerun was needed for this investigation. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Route cloned project sessions and repository URL preparation through managed worktrees, including omitted or false worktree intent and retries of older pending URL sessions. Keep registered local folders selectable as current checkouts. Reuse existing scratch retention custody and preserve unregistered nested worktrees whose contents cannot be removed losslessly.
Since 97e91a1 (#196206), cloned project sessions use a managed worktree even when worktree intent is omitted, so a required-sandbox github spawn is accepted in an isolated worktree instead of failing outside the sandbox. A registered current checkout outside the sandbox is still rejected. Co-authored-by: obviyus <[email protected]>
What Problem This Solves
Fixes agent build and clone scratch accumulating in a shared project clone when a new project session omits
worktreeor explicitly sets it tofalse.User Impact
New sessions for projects cloned by OpenClaw always receive a managed worktree, including repository-URL sessions and retries of older pending URL-only sessions. The project picker offers New worktree for these projects. Registered local folders and configured agent workspaces retain Current checkout support.
Existing accepted sessions retain their working directories; start a new project session to leave a previously selected shared clone. Unknown nested worktrees are preserved because their path names do not establish ownership or lossless removal. This change does not impose a hard byte quota or migrate arbitrary raw-cwd sessions.
Why This Change Was Made
Project admission previously resolved the shared clone as the session root unless the caller opted into worktree creation. Exec and sandbox placement then consumed that accepted root, so normal workspace scratch guidance sent temporary builds into the maintenance source.
The admission owner now chooses managed placement for cloned projects and reuses the existing worktree preparation, binding, cancellation, and retention owners. The direct URL-to-clone binding path is removed. Existing hourly cleanup expires idle
.openclaw/tmpentries after 24 hours; moving new runs off the base also lets eligible legacy tmp drain. Live or queued custody still defers cleanup. Native PR-tool worktree placement is separate work tracked in #158419.Production code is net -7 lines. No new config, cache, schema, or GC implementation. Tests are net +137 lines; measurement tooling +96.
Evidence
ce7788f5a24e5e2d0ef146a5dcea3ef4d0bb0983and pass with the fix. They verify the managed registry binding, session cwd/root, and absence of scratch in the base.pnpm check:changed --staged --base HEADran. Runtime, core-test, and scripts typecheck errors found during development were corrected; all three exact typecheck lanes and affected lint/format checks now pass. Other scoped guards passed. The remaining dead-export failures reproduce identically on the exact parent (19 production / 6 full-tree diagnostics); they are existing main regressions, not waived or hidden. The introducing changes are refactor(plugins): forward auth and catalog to their owners #190205 (f63e5cd0, 11 provider exports), fix(cli): surface stale-updater launchd scan failures in deep status #195977 (fee857b4, 3 launchd exports), refactor(auth): isolate provider auth data contracts #190544 (cf1ae7bb, 4 provider types), and Dashboards gallery: Display menu with list view, ordering and grouping #194455 (cde34f11, 1 UI export). Replacing only those changed owners with their pre-change sources in the isolated parent makes all three dead-export scans pass.git diff --checkpass.Synthetic APFS fixture: 50,000 tracked + 12,000 ignored files, 1,100,004,000 logical payload bytes; no production data. A1/A2/B1/A3/B2 controls, baseline n=15 and candidate n=11:
Retained-template candidate median is 9,010 ms; the additional approximately 6.27 seconds creates an isolated checkout instead of binding the shared directory. This is a placement/correctness tradeoff, not a speedup. A/A wall medians varied 0.56%, CPU -0.91%, and allocation 52.4%; small allocation differences are not causal evidence. Timings exclude scratch writes, session-row admission, inference, remote fetch, and Git/worker CPU and allocation. These are owner-boundary measurements, not full Gateway latency or btrfs qualification. No live deployment or production deletion was performed.