Repository navigation
Conversation
Admit ordinary archives under projection custody before snapshotting. Preserve capacity eviction's best-effort capture and deterministic recovery refs on retry. Include bounded path-redacted failure causes in slow removal diagnostics, and prevent recent btrfs stalls from averaging away between maintenance samples.
|
🦞👀 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: bfb88e65df
ℹ️ 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".
|
Codex review: needs maintainer review before merge. What this changesThis PR rejects pending workspace integrations before recovery capture, preserves useful removal diagnostics, and detects expensive Linux filesystem commit intervals. Example: Idle cleanup attempts to remove two managed worktrees with pending MERGE_HEAD state.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This useful maintainer-authored PR remains necessary on current main; the earlier cause-loss finding is resolved, and no blocking patch defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway maintenance sends eligible managed worktrees through projection custody, Git recovery capture, and checkout removal; failures preserve recovery state and emit bounded diagnostics. flowchart TD
A[Gateway maintenance] --> B[Managed worktree service]
B --> C[Projection archive admission]
C --> D[Git recovery capture]
D --> E[Archive receipt finalization]
E --> F[Checkout removal]
B --> G[Removal diagnostics]
Technical reviewBest possible solution: Keep archive admission in the existing projection owner and finalize its receipt with the required recovery snapshot under the existing custody operation. Do we have a high-confidence way to reproduce the issue? Current-main source captures the recovery snapshot before the projection owner's pending-integration refusal; committed regressions and reported parent failures directly cover that ordering, but no target code was executed during this review. Is this the best way to solve the issue? The change repairs ordering at the existing owner, migrates its callers together, and preserves snapshot and receipt contracts without introducing another state owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 11651564c067. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +21, Tests +74, Docs +10, Other +236. Total +341 across 16 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 HistoryReview history (1 earlier review cycle)
Reviewed November 14, 2026, 2:45 PM ET / 19:45 UTC (Revision 2). |
Pass complete errors to the existing diagnostic sanitizer before removing path-bearing text. Keep the bounded error class separately and cover spaced relative paths, later-line causes, and recovery-ref reuse.
|
|
Addressed the single open item from the latest review against a5ba88e:
All 101 focused diagnostics/retention/sanitizer tests pass; the cause-loss and spaced-path regressions were observed red before their fixes. Fresh independent Codex autoreview of the complete final staged candidate is scoped-clean at P0–P2. The PR body retains the physical measurement limitation and the separately attributed main dead-export regression. The additional supported CLI attempt was blocked before removal by runtime-artifact publication safety; no live service was changed. The real scheduler-to-removal synthetic fixture remains the owner-path proof. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…#199098) * fix: reject pending worktree merges before recovery capture Admit ordinary archives under projection custody before snapshotting. Preserve capacity eviction's best-effort capture and deterministic recovery refs on retry. Include bounded path-redacted failure causes in slow removal diagnostics, and prevent recent btrfs stalls from averaging away between maintenance samples. * fix(worktrees): preserve causes in path-free removal diagnostics Pass complete errors to the existing diagnostic sanitizer before removing path-bearing text. Keep the bounded error class separately and cover spaced relative paths, later-line causes, and recovery-ref reuse.
What Problem This Solves
Fixes repeated recovery capture during idle cleanup when a managed worktree still has a pending workspace integration, and makes slow removal failures diagnosable.
User Impact
Cleanup preserves the pending merge and user files without first capturing a recovery commit it cannot use. Slow failed removals report a bounded error class/message without checkout paths, retaining recognized causes even when they follow a path or appear on a later line. Linux cleanup also yields when a slow filesystem commit would otherwise be hidden by subsequent fast commits.
Why This Change Was Made
The projection owner now admits an archive before ordinary removal captures its Git snapshot, then finalizes the admitted archive with that snapshot under the existing custody operation. Capacity eviction keeps its separate best-effort snapshot behavior. Successful archival removal still requires the per-worktree recovery commit; checkout deletion already uses a retirement directory. Pre-deletion retries replace the same recovery ref, while the existing pending-removal ref pins an interrupted deletion's capture.
The btrfs kernel counter exposes a lifetime maximum, not an interval maximum. The probe therefore uses the existing interval total as a conservative upper bound instead of an average. Several shorter commits totaling one second may also defer optional cleanup for five minutes. The timing event has an explicit maintainer requirement to omit all paths; this is an intentional exception to the general raw-local-log default for that compact event. The original exception and existing cleanup warning remain unchanged. The existing sanitizer receives the complete error and owns both relative-path suppression and cause preservation. There is no product config, schema, cache or retention change.
Evidence
Regressions were red on the parent for capture before pending-merge refusal and for a 9.25-second commit followed by nine 2-ms commits. Focused maintenance/service/recovery tests passed (122 tests), archive/publication consumer tests passed (90 passed, two environment-specific skips), and the final diagnostics/capacity rerun passed (32 tests). These suites overlap; counts are per run. The post-capture fault regression verifies preserved bytes, one recovery ref across retry, and restoration of the latest edit. The review follow-up also proves Permission denied survives a relative-path tail and No space left on device survives a later absolute-path line (red on the initial PR head, green with the fix). All 101 diagnostics/retention/sanitizer tests passed on the final candidate, including a spaced relative-path privacy regression. Error class is recorded separately; ambiguous path-bearing text is conservatively removed after recognized causes are extracted. The existing fixed-prefix guard was simplified to keep the sanitizer within its line cap. Independent Codex autoreview is scoped-clean on the complete final staged candidate (P0–P2).
All selected
pnpm check:changed --base e6e62dfd30d0checks passed except the full-tree unused-export gate, which reports compaction exports added by #196550 (c9ee2646f8c6). The exact main parente6e62dfd30d0reproduces the identical eight production/four full-tree findings withnode --import ./scripts/tsx.mjs scripts/check-deadcode-exports.mts(exit 1);git show c9ee2646f8c6identifies their introduction. This is a main check regression, not a passing check or noise. All other selected checks, including core/script lint, types, formatting, import cycles and schema guards, passed. No UI-imported module changed. An additional isolatedpnpm openclaw worktrees removeattempt stopped before removal at the runtime-artifact publication guard because offline Gateway state could not be verified. No live service was changed; this is a CLI proof gap, not a removal result. The production scheduler-to-removal synthetic fixture is the owner-path evidence.Measurement contract and scope
Acceptance was recorded before measurement: two A/A controls followed by five serial interleaved A/B pairs, operation counts first, owner wall/CPU/allocation and physical SQLite/btrfs tails reported separately. Pending-merge owner runs must change two recovery-ref updates to zero while preserving checkout notes and MERGE_HEAD. Use fresh processes and reuse the preserved synthetic fixture for warm retries; keep the initial fresh-fixture result separate. A physical latency improvement is not claimed without reproduced tails.
The owner workload extends
scripts/perf/worktree-cleanup-pacing-measure.ts --pending-integration --reuse-pending-integration, with two 62,000-file / 1.143 GB checkouts and 5,000 real session metadata rows. It exercises the Gateway scheduler and removal owner on APFS; scheduler waits are accelerated, so these are owner costs rather than filesystem/chat-latency measurements. Sparse overlays pin the archive contract to parente6e62dfd30d0for baseline arms. Separate CPU/allocation profiles cover both arms.The physical workload is
scripts/perf/worktree-btrfs-pressure-measure.py: a task-owned btrfs loop filesystem, a physical 35 GiB SQLite database, 5,000 synthetic sessions, WAL synchronous=FULL, and two 62,000-file trees with 20,667 individually rewritten small-file extents each. Removal spacing is 60 seconds with a 60-second tail; kernel counters are sampled every 50 ms. This exercises the production deletion worker and admission probe, not the full Gateway transport. Setup and flushes are excluded. No production data is used.Five paired owner runs (median / p95, with p95 the maximum of five):
Warm A/A controls: wall 66.72/27.10 s, process CPU 57.96/33.78 s, allocation 1,507/1,438 MB. Host load was substantial and varied; timing estimates are less stable than the consistent operation-count and allocation reductions. CPU excludes spawned Git children. These sparse-overlay runs isolate archive ordering, not the independent pressure/diagnostic changes. Separate profile runs completed. The physical btrfs series completed with no errors and no missed commit-counter increments:
A/A physical controls: SQLite p99 22.04/63.79 ms, maximum 190.31/1,036.97 ms; fresh btrfs maxima 17/1,055 ms. The paired arms all admitted both removals, so the pressure change was not exercised by a slow interval in those runs. SQLite p99 worsened in this series, and the physical latency acceptance was not established. This evidence does not demonstrate a production-storage improvement or reproduce a 5–10-second commit. The pressure correction is supported by the deterministic counter regression; the measured work reduction is the pending-integration capture avoidance. Future production qualification remains necessary.
Production LOC grows by 21, primarily for bounded failure diagnostics and the prepared archive closure. The old late admission decision moves rather than being duplicated; recovery ownership remains unchanged.