Skip to content

fix: slow worktree cleanup blocks new sessions - #200335

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-snapshot-work-off-allocation-lease-20260919
Nov 17, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-snapshot-work-off-allocation-lease-20260919

Conversation

@steipete

@steipete steipete commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: new sessions wait behind unrelated managed-worktree snapshots, hydration, and cleanup when capacity maintenance or restore holds the global allocation lease.

User Impact

User impact: a slow snapshot no longer prevents another session from reserving an available worktree slot. Failed capacity snapshots now preserve the checkout instead of purging it. No configuration or schema migration is required.

Why This Change Was Made

Keep the allocation lease around authoritative capacity decisions and pending-slot reservation. Existing checkout mutation leases own snapshot, restore, rollback, and retirement work. Restore consumes its existing pending slot atomically when publishing the live row; removal claims and exact registry predicates arbitrate eviction versus reuse. Orphan cleanup briefly revalidates and detaches a directory, then deletes it outside allocation custody.

This adds 159 production lines: capacity reservation for restores and custody for cleanup replace protection previously supplied by the long global lease. It introduces no cache, schema, or configuration surface.

Evidence

  • The concurrent-allocation regression fails on parent 6a03a947c275d with the allocation lease held, then passes with this change. It calls the real service while snapshot completion is gated.
  • The original 235 focused tests passed. CI/review repair runs additionally passed 106 worktree tests, 29 GC tests, and 89 workspace-projection tests (overlapping suites; two existing projection cases skip). Coverage includes capacity accounting, historical and concurrent restore, exact-state retries, eviction/run exclusion, stale generations, failed-snapshot preservation, pending recovery, source lifetime, and closure-bound delegated authority. The final name-collision repair additionally passes 63 tests across pending-slot, canonical-path, and eviction suites. The new orphan-retry regression fails on the first PR head and passes after repair.
  • Staged Codex autoreviews are scoped-clean through P2, including the subsequent inferred-name collision repair. ClawSweeper reviewed final head 2a79ccf02d8d with zero findings/open items, resolving all four prior items. pnpm build passes on 1a476cb55b0f. The final two-file name-collision delta passes 63 focused tests and Codex review; check:changed --base 1a476cb55b0f --timed passes every gate except those same 116 unused exports (zero added/removed). pnpm check:changed --base 3d557fffac078 --timed also passes every gate except the same 116 parent unused exports described below (zero added/removed).
  • pnpm check:changed --base 6a03a947c275d --timed: all changed-scope type, lint, format, size, schema, and ownership guards passed. The command exits 1 only for 116 unused-export findings, exactly matching the unchanged parent (zero added/removed). Recent baseline introducers include 472cd0a2f542 (compaction exports), 94e34f956969 (Talk thinking), b868ed4c21ba / feat(update): keep each release in its own directory on OpenClaw-owned installs #198835 (package release exports), and 1ce9df608b43 / feat(openclaw-id): owners can approve a member's new browser #200088 (browser approval export). These remain main regressions, not passing checks.
  • The inferred-name regression holds the second owner after destination planning, fully publishes the first owner, then releases the second. It fails on 1a476cb55b0f with the worker uniqueness error and passes by creating release-planning-2 after repair. The short decision now considers both live owner and live name collisions before retrying; no additional worker query round trip.
  • Previous-head CI run 43998245974 timed out in the state-lease-heartbeat static-import build test. Exact CI main parent a958f1d25c1d passed focused reproduction on macOS and 2-CPU Linux ARM64 with pinned Bun; CI was Linux x64. Its cause remains unproven. No timeout increase, CI rerun, or inherited-failure waiver was used.
  • Synthetic Linux/btrfs proof: 4 CPUs / 8 GiB, 5,000 sessions in a physically allocated 35 GiB database, and 62,000 workspace files / 1.1 GB. A two-second snapshot delay starts before a slot becomes available and a concurrent real service.create runs. A/A controls precede five serial interleaved A/B pairs; production bytes match final head 2a79ccf02d8d (all recorded source hashes verified). Acceptance: available-slot admission must escape the snapshot delay, with no unexplained >20% whole-operation CPU/allocation regression.
Metric Before, median [p95] After, median [p95]
Request allocation wait 7,745 [8,110] ms 26 [48] ms
Create wall time 12,688 [29,810] ms 10,609 [32,048] ms
Whole GC/create wall time 33,987 [115,047] ms 40,017 [78,227] ms
Whole GC/create process CPU 17,979 [66,970] ms 21,014 [46,996] ms
Whole GC/create main V8 allocation 2,678.68 [2,685.53] MB 2,625.09 [2,625.47] MB

All five paired samples are retained and every paired snapshot completed. Candidate allocation wait is 6–48 ms; baseline is 5,784–8,110 ms. Whole-operation median CPU is +16.9%, wall time +17.7%, and main V8 allocation -2.0%. No >20% median CPU/allocation regression appeared. These CPU differences are not asserted causal on the shared host: A/A controls report 7,422 / 15,528 ms allocation wait, 18,893 / 29,223 ms whole CPU, and 2.670 / 2.673 GB main allocation. The second baseline control hit the old snapshot timeout/purge path; it remains recorded and flagged. Source preparation overlapped the other checks. With five samples, p95 is the maximum, not a production-tail estimate. The principal result is removal of snapshot-length allocation blocking. Earlier-candidate measurements remain in the local evidence, separately pinned.

These owner-boundary counters include the measured Node process and thread workers but exclude child-process CPU; V8 allocation is main-isolate only. The synthetic database matches file size, not production transcript distribution. The existing memory checkpoint occurs at create return, when cleanup is at different stages, so no peak-RSS or retained-memory improvement is claimed. Separate CPU profiles from the earlier candidate are diagnostic only, not final-head performance evidence. No production data is used.

Real product proof on 1a476cb55b0f before the subsequent name-collision-only repair: an isolated built Gateway ran sessions.create → chat.send → agent.wait → chat.history while a victim's actual Git object census remained paused. Allocation wait was 4 ms, session creation 482 ms, and a real OpenAI gpt-4.1 assistant reply 5,131 ms, before releasing the snapshot. The assistant returned ALLOCATION_REPLY_OK. Raising capacity while paused intentionally changed cleanup's runtime configuration; after release, cleanup rejected the stale commit and preserved the exact victim bytes. The Gateway shut down cleanly.

Reproduction command
node --import ./scripts/tsx.mjs scripts/perf/worktree-creation-measure.ts \
  --repo <synthetic-repository> --output <fresh-directory> --samples 1 \
  --eviction-delay-ms 2000 --agent-db-fixture <offline-synthetic-agent-db>

Baseline uses OPENCLAW_BENCH_BASELINE_DIR with the changed owner files frozen at 6a03a947c275d. Both arms use the same fixture and driver. Required guards, Git operations, and state workers remain active. CPU profiling runs separately from the reported timing samples.

Exact-head CI: run 44001707093 passed on 2a79ccf02d8d. ClawSweeper final-head review reports zero findings/open items. Native review and preparation completed for that head; no admin waiver or CI rerun was used.

Keep the global allocation lease around authoritative reservation decisions. Run snapshots, restoration, rollback, and retirement under their existing mutation owners; count restores through pending slots and preserve checkouts when snapshots fail.
@clawsweeper

clawsweeper Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: L labels Nov 17, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

Please check the final code at 3d557ff, particularly count-neutral restore publication, eviction/run exclusion, exact victim revalidation, closure-bound delegated authority, and failed-snapshot preservation. The remaining synthetic timing pairs are being added to the evidence; the code is frozen.

@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 17, 2026
@steipete
steipete marked this pull request as ready for review November 17, 2026 00:59
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T02:20:30.643346Z 2a79ccf New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d557fffac

ℹ️ 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".

Comment on lines +393 to +395
throw new Error(
"Worktree inventory changed during orphan planning; directory preserved",
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retry orphan planning conflicts without caching a permanent failure

When a foreground creation, removal, or activity update changes the inventory between orphan planning and this check, the resulting error reaches the catch block that stores it in orphanFailures. Subsequent GC passes skip the unchanged directory by device/inode before checking the now-current inventory, so a transient concurrency conflict prevents automatic cleanup for the remaining service lifetime unless an operator runs gc --retry-deferred. With allocations now intentionally allowed during maintenance, this can strand orphaned checkouts and their disk usage after ordinary concurrent activity. Treat inventory conflicts as retryable planning outcomes rather than persistent directory failures.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 17, 2026
@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Moves slow worktree snapshots, restore preparation, and cleanup outside the global allocation lease while preserving capacity accounting and recovery data.

Example: A new session requests an available slot while another checkout is being snapshotted.

  • Before: The request waits behind the unrelated snapshot.
  • After: The supplied Gateway run created the session in 482 ms and returned ALLOCATION_REPLY_OK before the snapshot resumed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful owner-based repair with production-flow proof, focused regression coverage, and all prior findings resolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied isolated Gateway output exercises session creation and a real model turn during blocked snapshot census; the final collision-only repair has a deterministic reported red/green service regression.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Starting a session waits for unrelated worktree snapshots, hydration, or cleanup despite available capacity.
Reason: The supplied production flow demonstrates useful concurrency, and the maintainer-authored direction explicitly accepts preservation over forced capacity reclamation.

Merge readiness

✅ Ready for maintainer review

This PR addresses a current allocation bottleneck, resolves all four prior findings, and has no new actionable defect identified; exact-head CI remains pending.

Priority: P2
Reviewed head: 2a79ccf02d8d35cc8829ff967971be8926c6d470

Before merge

None.

Findings

None.

Agent review details

How this fits together

The managed-worktree service turns session and maintenance requests into Git checkout operations and SQLite registry updates, using allocation custody for capacity reservations and checkout custody for filesystem changes.

flowchart TD
  A[Session request] --> B[Worktree service]
  B --> C[Short allocation lease]
  C --> D[Pending slot]
  D --> E[Checkout mutation lease]
  E --> F[Git preparation and restore]
  F --> G[Atomic registry publication]
  H[Background cleanup] --> E
Loading

Technical review

Best possible solution:

Retain short authoritative reservation decisions and use the existing checkout, removal-claim, and registry owners for slow work and settlement.

Do we have a high-confidence way to reproduce the issue?

Current main retains allocation custody across slow work; supplied parent-red/head-green regression evidence isolates the blocking path, and no target code was executed during this read-only review.

Is this the best way to solve the issue?

The change fixes the scheduling boundary with existing owners, preserves atomic capacity accounting, and avoids introducing a parallel manager or configuration surface.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 307e88c5e91a.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced changes and current-main behavior: The pinned introduced diff narrows allocation custody; fetched main still wraps reservation and restore in the older global-lease path. (src/agents/worktrees/service.ts:476, 2a79ccf02d8d)
  • Previous findings resolved: Live repository/name collisions now enter contention retry; historical restore bypasses creation-only owner deduplication; orphan planning conflicts avoid the failure cache; affected concurrency tests intercept checkout admission. (src/agents/worktrees/service.ts:479, 2a79ccf02d8d)
  • Real product evidence: steipete reports an isolated built Gateway exercising sessions.create, chat.send, agent.wait, and chat.history while actual Git object census was paused: allocation waited 4 ms, creation took 482 ms, and a real model returned ALLOCATION_REPLY_OK before release. The later delta changes collision handling and its regression test. (1a476cb55b0f)
  • Accepted preservation tradeoff: The maintainer-authored change explicitly replaces best-effort snapshot-and-purge behavior with checkout preservation on snapshot failure; documentation explains that admission can consequently remain blocked at capacity. Public docs: docs/gateway/config-runtime.md. (docs/gateway/config-runtime.md:56, 2a79ccf02d8d)
  • Existing-state compatibility: Restore reuses the existing state_leases pending-slot payload and state values; publication consumes that slot within the existing registry write transaction, without changing schemas, snapshot formats, or stored preferences. (src/agents/worktrees/registry-run-end.worker.ts:129, 2a79ccf02d8d)
  • Related work remains distinct: fix: stop retrying worktree cleanup that cannot preserve data #200350 explicitly separates its persistent cleanup retry policy from this PR's allocation-custody redesign; both preserve checkouts when snapshots fail.

Likely related people:

  • Peter Steinberger: Raw commit 3b16db7 adds src/agents/worktrees/capacity-owner.ts:37 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3b16db73c0b5; files: src/agents/worktrees/capacity-owner.ts)

PR surface

Source +159, Tests +223, Docs 0, Other +118. Total +500 across 33 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 17 421 262 +159
Tests 12 265 42 +223
Docs 2 5 5 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 120 2 +118
Total 33 811 311 +500

Preflight source

Source 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

Metric Value Why it matters
Runtime production versus tests Production +159 net lines; tests +223 net lines Growth supplies restore reservations and narrower cleanup custody using existing owners, with regressions for distinct concurrency and preservation failures.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Unrelated worktree maintenance delays new sessions, with a focused repair and demonstrated user benefit.
  • merge-risk: 🚨 compatibility: At a full cap, snapshot failure now preserves the checkout and can refuse creation instead of purging data; this tradeoff is explicitly selected by the maintainer-authored change and documented.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-17T01:12:30.964Z sha 3d557ff :: needs changes before merge. :: [P2] Preserve restore-by-id when the owner has a live successor | [P2] Keep orphan planning conflicts out of the failure cache | [P2] Move affected concurrency tests to checkout admission
  • reviewed 2026-11-17T02:02:12.053Z sha 1a476cb :: needs changes before merge. :: [P2] Retry inferred-name collisions with newly published live checkouts

Reviewed November 16, 2026, 9:22 PM ET / November 17, 2026, 02:22 UTC (Revision 3).

Allow explicit historical restores beside a live same-owner successor while retaining capacity and identity checks. Keep orphan planning conflicts retryable, and update checkout-custody and archive-failure consumers to prove preservation and retry.
@steipete

Copy link
Copy Markdown
Contributor Author

Addressed all three items from the review of 3d557fffac07810d1813d147ccb00e8a8219b3d1 in 1a476cb55b0f94d83558ca03d6d77d7be8d8b3b2:

  1. Restore beside a live successor: the pending-slot owner reads the authoritative historical row and applies creation-only owner deduplication only to new creation. ID, path, name, checkout custody, pending capacity, and atomic publication checks remain. See pending-slots.worker.ts:133. The existing cross-root lifecycle case passes on the exact main parent, fails on the first PR head, and passes with this repair.
  2. Retry orphan planning conflicts: only an attempted rename/delete can enter the existing inode failure cache. Registry/config/directory mismatches preserve the directory and allow the next ordinary GC to reconsider it. See gc-artifacts.ts:377 and the regression at service.gc.test.ts:150. That test is red on the first PR head and green with the fix.
  3. Checkout-admission test hooks: the queued restore and changed-origin tests now intercept the checkout mutation lease, retaining their repository-rebinding and origin-change assertions. See service.canonical-paths.test.ts:176 and service.gc-cli.test.ts:377.

CI also identified consumers of the intentionally replaced purge-after-snapshot-failure policy. They now prove checkout preservation, retry, and lossless restoration, including accepted empty directories and ignored authored bytes. Focused repair runs passed: 106 worktree tests, 29 GC tests, and 89 workspace-projection tests (overlap with the original focused proof). pnpm build passed. Final staged Codex autoreview is clean through P2. check:changed retains only the same 116 exact-parent unused exports, with zero added or removed findings; this is reported as a failure, not green.

The requested real product proof also passes. An isolated built Gateway ran sessions.create → chat.send → agent.wait → chat.history while the victim's actual Git object census was blocked. New-session allocation wait was 4 ms, creation 482 ms, and a real OpenAI gpt-4.1 assistant reply 5,131 ms. The assistant returned ALLOCATION_REPLY_OK (14,612 input / 6 output tokens) before the snapshot was released. Raising capacity during the pause deliberately changed cleanup's runtime configuration: after release, it refused the stale commit and preserved the victim's exact bytes. The Gateway shut down cleanly. All data was synthetic.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a476cb55b

ℹ️ 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".

Comment on lines +487 to +491
const currentCollision =
owner ??
currentSlots.find(
({ record, state }) =>
(state === "pending" && params.ownerId && worktreeOwnerMatches(record, params)) ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retry inferred-name collisions with newly published checkouts

When concurrent creates for different owners use the same suggestedName, both can select the same available destination before entering this allocation callback. If the first publishes before the second reads currentSlots, its pending slot has disappeared, and the live-owner lookup does not find it because the owners differ. This check therefore misses the collision, and reservePendingWorktreeInDatabase throws its generic live-name conflict instead of the retryable WorktreePendingContentionError. The second creation fails rather than replanning with an ordinal suffix, whereas previously destination selection and reservation shared allocation custody. Recheck live records by repository/name here and route collisions back through name planning.

Useful? React with 👍 / 👎.

Revalidate live name collisions alongside owner collisions inside the short allocation decision. Retry full destination planning when another owner publishes between planning and reservation. A deterministic two-owner regression fails before the repair and proves ordinal naming plus pending-slot cleanup.
@steipete

Copy link
Copy Markdown
Contributor Author

Addressed the remaining item from the review of 1a476cb55b0f on final head 2a79ccf02d8d35cc8829ff967971be8926c6d470:

  1. Retry inferred-name collisions with newly published live checkouts (P2): fixed. The short allocation decision now checks authoritative live records for both owner and repository/name collisions at service.ts:479–495. It routes either collision through the existing contention retry, which releases custody and repeats destination planning. This replaces the previous owner-only read rather than adding another query round trip; the worker still enforces final uniqueness.

    The regression at service.pending-slots.test.ts:93–135 pauses the second owner after it plans release-planning, fully publishes the first owner, and then releases the second. It fails on the preceding head with Managed worktree name or owner already has a live or pending checkout; after the repair it produces release-planning-2, retains two live records, and leaves no pending slots. All 63 tests in the pending-slot, canonical-path, and eviction suites pass. Independent staged Codex review is clean through P2. The earlier three items remain resolved as documented in the prior numbered response.

The PR body distinguishes completed proof from the ongoing check:changed and final-byte timing refresh. Fresh CI is attached to the repaired head; no previous-head timeout was waived or rerun.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 9f441ad into main Nov 17, 2026
160 of 162 checks passed
@steipete
steipete deleted the steipete/perf-micro-snapshot-work-off-allocation-lease-20260919 branch November 17, 2026 02:36
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Nov 17, 2026
Capacity admission selected a peer reservation even when that peer had no
pending writes and no stronger safety reserve. A low-space creator then
waited for unrelated planning work instead of rejecting insufficient space.
Ignore those peers when choosing capacity blockers; required byte accounting
is unchanged, and positive debts and stronger reserves still serialize.

Add a real-service regression that detects the false wait before releasing
the planning peer, plus worker coverage for selecting the actual blocker.
Correct the competing-repositories fixture to offer room for exactly one
reservation before applying pressure, preserving its one-success contract.
This repairs the capacity regression exposed after #200335 without restoring
slow I/O under the global allocation lease or increasing test timeouts.

Validation: capacity/invariants 182 tests; additional invariant consumers 49;
PostgreSQL capacity 2; full build; clean Codex review. check:changed passes
except unused exports also reproduced on exact base f52f728. The original
120-second timeout was not reproduced locally; the new false-wait regression
fails on unchanged production and passes with this fix.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 17, 2026
* fix(worktrees): unblock allocations during snapshot cleanup

Keep the global allocation lease around authoritative reservation decisions. Run snapshots, restoration, rollback, and retirement under their existing mutation owners; count restores through pending slots and preserve checkouts when snapshots fail.

* fix(worktrees): preserve restore and cleanup retry contracts

Allow explicit historical restores beside a live same-owner successor while retaining capacity and identity checks. Keep orphan planning conflicts retryable, and update checkout-custody and archive-failure consumers to prove preservation and retry.

* fix(worktrees): retry newly published inferred names

Revalidate live name collisions alongside owner collisions inside the short allocation decision. Retry full destination planning when another owner publishes between planning and reservation. A deterministic two-owner regression fails before the repair and proves ordinal naming plus pending-slot cleanup.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 17, 2026
Capacity admission selected a peer reservation even when that peer had no
pending writes and no stronger safety reserve. A low-space creator then
waited for unrelated planning work instead of rejecting insufficient space.
Ignore those peers when choosing capacity blockers; required byte accounting
is unchanged, and positive debts and stronger reserves still serialize.

Add a real-service regression that detects the false wait before releasing
the planning peer, plus worker coverage for selecting the actual blocker.
Correct the competing-repositories fixture to offer room for exactly one
reservation before applying pressure, preserving its one-success contract.
This repairs the capacity regression exposed after openclaw#200335 without restoring
slow I/O under the global allocation lease or increasing test timeouts.

Validation: capacity/invariants 182 tests; additional invariant consumers 49;
PostgreSQL capacity 2; full build; clean Codex review. check:changed passes
except unused exports also reproduced on exact base e284160. The original
120-second timeout was not reproduced locally; the new false-wait regression
fails on unchanged production and passes with this fix.
RomneyDa pushed a commit that referenced this pull request Nov 19, 2026
Capacity admission selected a peer reservation even when that peer had no
pending writes and no stronger safety reserve. A low-space creator then
waited for unrelated planning work instead of rejecting insufficient space.
Ignore those peers when choosing capacity blockers; required byte accounting
is unchanged, and positive debts and stronger reserves still serialize.

Add a real-service regression that detects the false wait before releasing
the planning peer, plus worker coverage for selecting the actual blocker.
Correct the competing-repositories fixture to offer room for exactly one
reservation before applying pressure, preserving its one-success contract.
This repairs the capacity regression exposed after #200335 without restoring
slow I/O under the global allocation lease or increasing test timeouts.

Validation: capacity/invariants 182 tests; additional invariant consumers 49;
PostgreSQL capacity 2; full build; clean Codex review. check:changed passes
except unused exports also reproduced on exact base f52f728. The original
120-second timeout was not reproduced locally; the new false-wait regression
fails on unchanged production and passes with this fix.

(cherry picked from commit fa11cdd)

Companion review: preserves positive debt and stronger reserve constraints; restores no global allocation I/O lock.
Co-authored-by: RomneyDa <[email protected]>

(cherry picked from commit 8441ab5a9d51bba10e6c6f666b42a6c9ca6789d6)
RomneyDa pushed a commit that referenced this pull request Nov 19, 2026
* fix(worktrees): unblock allocations during snapshot cleanup

Keep the global allocation lease around authoritative reservation decisions. Run snapshots, restoration, rollback, and retirement under their existing mutation owners; count restores through pending slots and preserve checkouts when snapshots fail.

* fix(worktrees): preserve restore and cleanup retry contracts

Allow explicit historical restores beside a live same-owner successor while retaining capacity and identity checks. Keep orphan planning conflicts retryable, and update checkout-custody and archive-failure consumers to prove preservation and retry.

* fix(worktrees): retry newly published inferred names

Revalidate live name collisions alongside owner collisions inside the short allocation decision. Retry full destination planning when another owner publishes between planning and reservation. A deterministic two-owner regression fails before the repair and proves ordinal naming plus pending-slot cleanup.

(cherry picked from commit 9f441ad)

Companion review: include debt-free capacity follow-up fa11cdd with this change; retain checkout-first allocation order, pending slot publication, and lossless snapshot custody. No global lease spans snapshot IO.
Co-authored-by: RomneyDa <[email protected]>

(cherry picked from commit 26cb1ccff679172ec086eee5928047f726dd1d82)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant