Skip to content

feat(workers): maintain bounded ready capacity for prepared projects - #143372

Merged
steipete merged 2 commits into
mainfrom
codex/ready-worker-pool
Sep 10, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/ready-worker-pool

Conversation

@steipete

@steipete steipete commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Related: #134931. Builds on #143227; public-repository admission remains separate in #143410.

What Problem This Solves

Prepared images save setup work, but each new cloud session still waits for a machine to start and enroll. This change keeps bounded ready capacity for the next session on the same eligible local project and profile.

Why This Change Was Made

Successful session activation creates demand for a spare worker. Assigning that worker and its placement happens atomically, each enrolled node can be consumed once, and refill stays within the capacity limit and demand's original idle window. Expiry, restart and failed cleanup retain ownership until provider deletion is confirmed.

Allocation, consumption, demand and cleanup stay together because they jointly define usable capacity. The completed-workspace foundation has already landed, so this PR contains only the pool change and its integration fixes. It uses schema 17 fields from that foundation. Doctor migrates the Crabbox warm-image envelope from v2 to v3 while preserving allocations, captures and retirement obligations.

User Impact

A matching session can use an already prepared worker while its replacement starts in the background. The default is one spare per eligible local project/profile, capped at four across the Gateway. Ready workers incur running-machine charges; preparing workers and unconfirmed cleanup count against the cap. Setting either applicable limit to zero drains unused capacity while preserving active sessions and ordinary image reuse.

Reserves require an eligible dedicated Linux profile. Failed dispatch does not renew demand, and refill or Gateway restart does not extend expiry. A miss retains ordinary provisioning and image refresh. Repository-only admission is a separate PR.

Evidence

Reviewed head: 691a2aa4b21c018e680587f8629302256330a06b.

  • Exact-head CI passed. The earlier three integration failures were reproduced and repaired: shared record types moved to a leaf module, and two fixture owners now create the real attached environments required by activation. Store modules emit identical JavaScript; assertions and activation guards are unchanged.
  • The 200 focused owner/platform/Doctor cases and full changed gate passed before those corrections; the correction's focused red/green tests, architecture checks and independent review passed afterward. Historical overlapping test totals are not added together.
  • All nine package-qualification phases passed for this head, including actual installed Gateway/transferred-worker execution, exact command correlation and linked polls. All recorded processes/groups exited and local ports closed. The earlier fixture-order shutdown warning did not recur.
  • Installed Doctor migration, idempotence and older-reader refusal passed on a3a6f832 for migration code unchanged by the final correction. Synthetic capture and retirement records retained their ownership facts; schema remained 17.
  • AWS native pool qualification passed in 32m36s. Cold dispatch reached first worker-command output in 696.7s; a ready-worker hit became active in 2.8s and reached first output in 6.4s. Full validation, including hashing and executing the 158MB compiled binary, finished in 29.8s. The build count stayed at one, with matching build receipts, binary hashes, stable cache paths and isolated session overlays.
  • The same run verified one durable reserve claim, rejection of active-session redispatch, background refill, Gateway restart preserving the original demand and expiry, and Gateway-owned deletion after natural expiry. All three instances and the snapshot were deleted. All 86 native and nine local commands settled; a heartbeat canceled during teardown remains recorded.
  • Unchanged passing boundary tests cover omitted settings creating one reserve after activation, shared-cap/zero enforcement, profile/global reductions from three to one to zero, preservation of the attached active session, and disabling queued provisioning. Those cases verify retirement/provisioning decisions; the native run used explicit limits of one. The runtime defaults are one per project/profile and four Gateway-wide.

The native proof uses synthetic model responses with real installed Gateway/worker processes and AWS operations. Timings are host-observed and include transport. Concurrent contention, omitted-limit saturation to four, and a live zero-toggle were outside this native campaign; focused tests cover the relevant ownership and policy branches. Machine0 and Daytona remain unqualified because current working access is unavailable.

@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling extensions: crabbox size: XL maintainer Maintainer-authored PR labels Sep 9, 2026
@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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 9, 2026
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 9, 2026, 10:29 PM ET / September 10, 2026, 02:29 UTC (Revision 4).

ClawSweeper review

What this changes

Adds a bounded pool of prepared cloud workers that later local-project sessions can consume once, with background refill, demand-based expiry, configurable limits, and warm-image state migration.

Merge readiness

⛔ Blocked before merge - 5 items remain

This remains distinct, useful work beyond the merged preparation foundation. No discrete blocking code defect was established; package and migration qualification have progressed, while the explicitly stated native qualification hold remains.

Priority: P2
Reviewed head: 691a2aa4b21c018e680587f8629302256330a06b

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation has coherent ownership and meaningful boundary coverage, but the central native pool behavior and default-enable upgrade outcome remain unproven.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: The ordinary external-contributor gate is exempt for this maintainer-authored PR. Reported installed Gateway/transferred-worker execution and unchanged Doctor migration evidence are credited, but they do not demonstrate the prepared pool's native ready-hit, refill, restart, expiry, and deletion path; the author's explicit landing hold remains.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary external-contributor gate is exempt for this maintainer-authored PR. Reported installed Gateway/transferred-worker execution and unchanged Doctor migration evidence are credited, but they do not demonstrate the prepared pool's native ready-hit, refill, restart, expiry, and deletion path; the author's explicit landing hold remains.
Evidence reviewed 9 items Pinned introduction and review continuity: Reviewed merge-base 411ea27 through head 691a2aa. The previous completed review examined this same head and reported no findings. The supplied test merge is stale, so endpoint drift was not treated as introduced removal.
Current main still excludes reserve allocation: Current-main schema documentation explicitly leaves the five lifecycle fields null and says completed-checkout adoption does not allocate reserves. The latest supplied release, v2026.9.3, also lacks the new reserve settings.
Merged foundation is a dependency, not a replacement: GitHub confirms #143227 merged as 411ea27. Its body explicitly separates ready capacity from completed-workspace reuse.
Findings None None.
Security None None.

How this fits together

The Gateway places sessions on cloud workers provisioned by provider plugins such as Crabbox. This pool uses successful project activity to prepare spare workers, then supplies them to matching session dispatches or cleans them up when demand expires.

flowchart TD
  A[Successful project session] --> B[Demand and capacity limits]
  B --> C[Prepare spare cloud worker]
  C --> D[Ready worker inventory]
  E[Matching session dispatch] --> D
  D --> F[Atomic one-use assignment]
  F --> B
  D --> G[Expiry or disabled capacity]
  G --> H[Confirmed provider deletion]
Loading

Before merge

  • Resolve merge risk (P1) - Existing eligible profiles acquire chargeable spare workers when the new settings are omitted; native evidence has not yet demonstrated default enablement and zero-value draining while preserving active sessions.
  • Resolve merge risk (P1) - Warm-image v3 requires Doctor migration before runtime provisioning and introduces provider lifecycle hooks; reported installed migration success does not establish the unfinished native restart, expiry, and confirmed-cleanup behavior.
  • Complete next step (P2) - Complete the stated native pool qualification and document omitted-setting/default-enable and zero-limit draining results, including preservation of active sessions and confirmed provider deletion.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Reserve controls 2 numeric settings; defaults 1 per project/profile and 4 Gateway-wide Omitting the settings enables additional running cloud machines, making upgrade behavior operationally significant.
Production versus test growth Production net +1,977 lines; tests/support net +3,848 lines The stated justification is keeping allocation, consumption, expiry, and cleanup ownership together, with substantial boundary coverage.
Persisted-format transition Warm-image envelope v2 → v3; state schema remains 17 Plugin-state migration is required despite the unchanged global schema number.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/crabbox/doctor-contract-api.ts, unknown-data-model-change: extensions/crabbox/doctor-contract-api.ts, unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Finish the declared qualification (recommended)
    Retain the landing hold until native reserve lifecycle and omitted-setting/zero-limit upgrade results establish bounded charges, preserved active sessions, and confirmed cleanup.
  2. Narrow initial enablement
    If default-on upgrade behavior cannot be qualified, have the feature owner choose explicit opt-in reserves while retaining ordinary image reuse.

Technical review

Best possible solution:

Keep one canonical reserve lifecycle with atomic consumption, bounded cleanup custody, and verified upgrade behavior for both omitted settings and explicit zero limits.

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

Not applicable as a defect reproduction: this adds ready capacity beyond existing image reuse. Its native pool behavior remains explicitly unqualified in the supplied evidence.

Is this the best way to solve the issue?

Yes in architecture: extending the existing environment, placement, and provider owners avoids a competing pool store. Operational acceptance still depends on the stated native and upgrade qualification.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded cloud-session startup improvement with operational qualification remaining, not an established urgent regression.
  • merge-risk: 🚨 compatibility: Existing eligible configurations gain chargeable reserves by default, and warm-image records cross a Doctor-owned format transition.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The ordinary external-contributor gate is exempt for this maintainer-authored PR. Reported installed Gateway/transferred-worker execution and unchanged Doctor migration evidence are credited, but they do not demonstrate the prepared pool's native ready-hit, refill, restart, expiry, and deletion path; the author's explicit landing hold remains.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 411ea27 adds src/gateway/worker-environments/preparation-identity.ts:58 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 411ea27d9af1; files: src/gateway/worker-environments/preparation-identity.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the already-declared native ready-hit, single-consumption, refill, idle-restart, expiry, and confirmed-deletion qualification.
  • Include omitted-setting and zero-limit upgrade results showing preserved active sessions and confirmed reserve deletion.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-09T20:29:29.411Z sha 0118780 :: blocked before merge. :: none
  • reviewed 2026-09-09T20:47:34.218Z sha 0118780 :: blocked before merge. :: none
  • reviewed 2026-09-10T01:49:38.226Z sha 691a2aa :: blocked before merge. :: none

Base automatically changed from codex/prepared-project-workspaces to main September 10, 2026 00:13
@openclaw-barnacle openclaw-barnacle Bot added channel: voice-call Channel integration: voice-call app: macos App: macos app: web-ui App: web-ui scripts Repository scripts commands Command implementations extensions: codex labels Sep 10, 2026
Maintain bounded ready capacity after successful project activation, consume each worker once with its placement, and retain fixed demand-based expiry and cleanup ownership. Preserve foreground image refresh and migrate warm-image state through Doctor.
@steipete
steipete force-pushed the codex/ready-worker-pool branch from 0118780 to a3a6f83 Compare September 10, 2026 00:34
@steipete
steipete marked this pull request as ready for review September 10, 2026 00:35
@steipete
steipete requested a review from a team as a code owner September 10, 2026 00:35
Move shared record contracts to a leaf without changing runtime behavior. Seed attached-environment ownership in repository-editor and session-create race fixtures so their existing assertions exercise the unchanged atomic activation guard.
@openclaw-barnacle openclaw-barnacle Bot removed channel: voice-call Channel integration: voice-call app: macos App: macos app: web-ui App: web-ui labels Sep 10, 2026
@openclaw-barnacle openclaw-barnacle Bot removed scripts Repository scripts commands Command implementations extensions: codex labels Sep 10, 2026
@steipete
steipete merged commit 826ca75 into main Sep 10, 2026
201 checks passed
@steipete
steipete deleted the codex/ready-worker-pool branch September 10, 2026 02:51
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 10, 2026
…penclaw#143372)

* feat(workers): keep prepared workers ready for later sessions

Maintain bounded ready capacity after successful project activation, consume each worker once with its placement, and retain fixed demand-based expiry and cleanup ownership. Preserve foreground image refresh and migrate warm-image state through Doctor.

* fix(workers): break prepared store type cycles

Move shared record contracts to a leaf without changing runtime behavior. Seed attached-environment ownership in repository-editor and session-create race fixtures so their existing assertions exercise the unchanged atomic activation guard.
steipete added a commit that referenced this pull request Oct 14, 2026
Share completion projection and settlement, reuse existing command gates and
session-source preparation, and remove duplicate response/receipt mirrors.
Keep private-source authority, approvals, FIFO, transcript durability, bounded
retry behavior, and write-capable shutdown settlement at their existing owners.

Best-effort tradeoffs accepted:
- Idle source/config changes may retain unused capacity until expiry; allocation
  and private-source transfer still authorize use (#143372, #143410).
- Mid-read model configuration and native availability may keep prepared display
  facts for that read; catalog/account authority remains (#169253).
- Cosmetic health topology and clock rollback use normal refresh or an explicit
  probe; live lifecycle mismatch checks remain (#128222, #128503).
- Bootstrap enrollment overlapping shutdown/reload may fail and retry rather than
  reject every post-await close interleaving (#133037).
- Late internal completion reducers are not persisted; completion stays idempotent
  and final-intent receipt validation remains (#168592).
- An in-flight plugin UI catalog may finish against its selected registry;
  HTTP asset disclosure still checks current authority (#134943, #169449).

These removed guards have speculative/synthetic provenance, not cited human
actual-use incidents. Keep the human-reported memory-flush retry bound (#85645).
The Phase E standalone session memory backend and its tests are untouched.
steipete added a commit that referenced this pull request Oct 14, 2026
* refactor(gateway): consolidate reply and worker preparation paths

Share completion projection and settlement, reuse existing command gates and
session-source preparation, and remove duplicate response/receipt mirrors.
Keep private-source authority, approvals, FIFO, transcript durability, bounded
retry behavior, and write-capable shutdown settlement at their existing owners.

Best-effort tradeoffs accepted:
- Idle source/config changes may retain unused capacity until expiry; allocation
  and private-source transfer still authorize use (#143372, #143410).
- Mid-read model configuration and native availability may keep prepared display
  facts for that read; catalog/account authority remains (#169253).
- Cosmetic health topology and clock rollback use normal refresh or an explicit
  probe; live lifecycle mismatch checks remain (#128222, #128503).
- Bootstrap enrollment overlapping shutdown/reload may fail and retry rather than
  reject every post-await close interleaving (#133037).
- Late internal completion reducers are not persisted; completion stays idempotent
  and final-intent receipt validation remains (#168592).
- An in-flight plugin UI catalog may finish against its selected registry;
  HTTP asset disclosure still checks current authority (#134943, #169449).

These removed guards have speculative/synthetic provenance, not cited human
actual-use incidents. Keep the human-reported memory-flush retry bound (#85645).
The Phase E standalone session memory backend and its tests are untouched.

* refactor(gateway): consolidate dispatch and trusted result projections

* refactor(workers): trust admitted preparation facts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 15, 2026
…2342)

* refactor(gateway): consolidate reply and worker preparation paths

Share completion projection and settlement, reuse existing command gates and
session-source preparation, and remove duplicate response/receipt mirrors.
Keep private-source authority, approvals, FIFO, transcript durability, bounded
retry behavior, and write-capable shutdown settlement at their existing owners.

Best-effort tradeoffs accepted:
- Idle source/config changes may retain unused capacity until expiry; allocation
  and private-source transfer still authorize use (openclaw#143372, openclaw#143410).
- Mid-read model configuration and native availability may keep prepared display
  facts for that read; catalog/account authority remains (openclaw#169253).
- Cosmetic health topology and clock rollback use normal refresh or an explicit
  probe; live lifecycle mismatch checks remain (openclaw#128222, openclaw#128503).
- Bootstrap enrollment overlapping shutdown/reload may fail and retry rather than
  reject every post-await close interleaving (openclaw#133037).
- Late internal completion reducers are not persisted; completion stays idempotent
  and final-intent receipt validation remains (openclaw#168592).
- An in-flight plugin UI catalog may finish against its selected registry;
  HTTP asset disclosure still checks current authority (openclaw#134943, openclaw#169449).

These removed guards have speculative/synthetic provenance, not cited human
actual-use incidents. Keep the human-reported memory-flush retry bound (openclaw#85645).
The Phase E standalone session memory backend and its tests are untouched.

* refactor(gateway): consolidate dispatch and trusted result projections

* refactor(workers): trust admitted preparation facts
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 extensions: crabbox gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant