Skip to content

fix: queued workers miss cooperative checkpoints under shared pressure - #164537

Merged
steipete merged 2 commits into
mainfrom
codex/worker-runtime-package
Oct 3, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/worker-runtime-package

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #164536

What Problem This Solves

Queued worker tasks can wait unnecessarily when repeated shared-compute pressure keeps selecting an already-signaled host exchange instead of reaching a later cooperative worker.

User Impact

Repeated pressure can now reach the next eligible host exchange and let queued work progress. Worker diagnostics expose host-wait time separately from the existing run duration. Public plugin SDK entrypoints, resource limits, database ownership, and cancellation/cleanup guarantees are preserved; no configuration or migration is required.

Why This Change Was Made

Extract the existing scheduler, task protocol, native-section fences, and retained settlement into the private @openclaw/worker-runtime workspace package. OpenClaw supplies worker construction, runtime generations, database context, shared capacity, and the live-pool registry through host adapters. Separate host, worker, and lifecycle entrypoints keep worker-side imports independent of application policy, with a scoped import-boundary guard.

This retains the lifecycle contracts our callers need while making the engine easier to maintain. The scheduling fix skips exchanges whose pressure signal is already aborted. Additive hostWaitMs accounting covers replies, rejection, and cancellation without changing runMs; the existing benchmark collector consumes it.

Evidence

  • The four new regression cases failed before the fixes for the intended reasons; all 25 existing ownership cases passed after extraction.
  • 165 tests across 15 scoped suites passed. A final 53-test run covered ownership, memory reclamation, native cancellation/exchanges, snapshot staging, and supervisor-loss cleanup.
  • pnpm test src/infra/worker-task-pool.owned.test.ts --maxWorkers=1: 29 passed on the published tree; 54.07 s wrapper wall time, 42.12 s Vitest duration, with transformation accounting for 95% of that duration. CI seconds are not yet available.
  • Local production and scoped core test typechecking, changed-source lint, script/config lint, dead-export and import-cycle checks passed. Independent review found no actionable P0–P2 issue. Clean CI subsequently exposed the declaration and test-import gaps described below.
  • The extraction passed pnpm build and verification of all 151 public SDK subpaths. Final cleanup and callback-binding refinements were subsequently verified by types, scoped lint, compiled-worker tests, and review. One intermediate test-preparation attempt was invalidated by running the build concurrently; the serial rerun passed.

Full-repository lint still reports pre-existing max-lines violations in five files verified byte-identical to the starting commit fc7e71bad25845ba8c23ddd6f3c44ded11a9f427: extensions/voice-call/src/runtime.test.ts, extensions/crabbox/src/crabbox-worker-provider.ts, src/gateway/worker-environments/transcript-commit.test.ts, src/state/openclaw-state-read.worker.ts, and src/plugins/doctor-contract-registry.ts. No baseline or lint exception was added. The successful full build also reported a UI startup-size diagnostic (364.9 KiB versus 364.7 KiB); this PR does not change UI code.

CI follow-up

The first CI run exposed missing declaration aliases in clean plugin boundary builds (local package artifacts masked them), a missed core test type import, and two config-test assumptions. The follow-up maps all worker-runtime entrypoints to the SDK declaration graph, completes the type import migration, selects lint policy overrides by identity, and includes the existing heartbeat worker in the schema-inlining test. The SDK contract test keeps the declaration producer checks without freezing unrelated package inventory.

The follow-up passed isolated review at P0–P2, affected core and script typechecks, and scoped lint. A broad lint attempt timed out preparing unrelated plugin declarations; the repository core lint scope passed without that preparation. With worker-runtime package build artifacts hidden, full Codex, Telegram, Slack, and XAI declaration projects compile with zero diagnostics. The two tooling suites pass 54 tests (166.70 s wrapper wall; original CI file times 10.146 s and 0.476 s), and the package contract suite passes 10 tests (9.24 s wrapper wall; 0.821 s test time).

Other first-run failures came from main and have separate fixes: dashboard iframe sizing (11515ce5b3dad), memory-host roster boundaries (3f12395208355), and retained SQLite snapshot diagnostics (20f485c7af918). These failures are recorded as failures, not passing proof.

Compatibility review: no authored configuration, default, protocol version, database schema, stored-data shape, retention, or migration behavior changes. OAuth changes only repoint imports to the unchanged native-section owner. The dependency graph adds a private local workspace package using an existing workspace dependency; there is no new registry dependency. ClawSweeper's initial generic compatibility flags were based on an incomplete file listing; its source review found no actionable introduced bug.

Final CI disposition

Run 37156024642, attempt 1, tested merge 1de96bfd050111bb72d2113a4c13d3aaa9967881 (main 06da0de86c0a27dc1e92995f9d0a2428880ce90c plus reviewed head 91505d067ce3d84179e4862314b046262159088c). All selected checks completed; two jobs and their aggregate gate failed, with no cancelled jobs.

  • Doctor's two quarantined-audit-index cases fail identically on the exact main parent without this extraction. A fresh isolated baseline run reports GatewayLockError before snapshot cleanup fault injection (2 failed / 11 passed; 256.65 s wrapper). The new main ownership check reaches the existing quarantine refusal before repair. The separate owner repair landed on main as 6d4ee0afd92e9636b81b6e9bdb65a7367f072bc6, with all 56 Doctor/admission/Gateway-lease tests on Node 24.19, the required changed checks, and isolated review passing. The PR's source is unchanged. The same full-file baseline also reproduces on CI’s actual Node 24.19 (2 failed / 11 passed; 207.27 s wrapper); the nested cause is the existing quarantine guard, before any worker task.
  • Two native Swift outbox cases timed out: “send before restore adopts durable rows still queues behind them” and “gateway history caches a flushed background-session turn.” Their code uses local SQLite and an in-process fake transport, and the complete native apps tree is identical between the main parent and tested merge. The changed TypeScript runtime is not executed by either case. The timing cause remains unproven; these are not passing results.

These failures remain recorded for the native inherited-failure admission policy. ClawSweeper completed current-head review with no actionable source finding and explicitly resolved compatibility concerns by inspecting the complete diff.

The separate automatic ARM preparation run 37156024467 ended cancelled after its two-hour timeout window. Its live log stops after Go 1.27.1 was cached, before validation; no ARM result is claimed. This setup gap is separate from the completed main CI run and its two attributed failures.

Move scheduling, task transport, native-section fences, and retained settlement
into a private workspace package. Keep database policy, native lifetime sources,
shared admission, and the existing plugin SDK contracts with their host owners.

Skip already-signaled host exchanges when repeated queue pressure requests a
checkpoint. Record hostWaitMs separately from runMs and include it in benchmark
diagnostics. Preserve method receivers for host lifecycle callbacks.

Validation: 165 scoped tests plus 53 tests on the final refinements, full
TypeScript checks, changed-source lint, SDK export checks, and independent review.
The extraction passed the full build. Five untouched files retain pre-existing
max-lines lint failures; the build also reported the existing-scope UI startup
size diagnostic. No schema, configuration, or operator migration is required.
@clawsweeper

clawsweeper Bot commented Oct 3, 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 scripts Repository scripts agents Agent runtime and tooling size: XL labels Oct 3, 2026
@steipete
steipete marked this pull request as ready for review October 3, 2026 21:11
@steipete steipete self-assigned this Oct 3, 2026
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Dependency graph changes

This maintainer PR changes the dependency graph.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 91505d067ce3d84179e4862314b046262159088c
  • Maintainer: @steipete
  • Repository role: admin

These dependency graph changes were made:

  • pnpm-lock.yaml
  • packages/worker-runtime/package.json

Carefully review these changes before merging.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 91505d067ce3d84179e4862314b046262159088c
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/oauth-refresh-fence.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/oauth-refresh-observation.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 3, 2026, 7:54 PM ET / 23:54 UTC (Revision 5).

ClawSweeper review

What this changes

The PR moves worker scheduling into a private workspace package, lets repeated compute pressure reach another cooperative worker, and adds host-wait diagnostics.

Merge readiness

⛔ Blocked before merge - 2 items remain

This PR remains useful because fetched main and the latest release still contain the checkpoint-selection defect. No actionable introduced bug was found, and source inspection resolves the earlier generic compatibility concern.

Priority: P2
Reviewed head: 91505d067ce3d84179e4862314b046262159088c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent scheduler repair and ownership-preserving extraction with focused regression coverage and no actionable source findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The verified repository-admin author is exempt from external-contributor runtime proof. Scheduler regressions use mocked Worker transport, with reported compiled-worker lifecycle validation as supplemental evidence; no material authority change or stored-data contract change was found.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The verified repository-admin author is exempt from external-contributor runtime proof. Scheduler regressions use mocked Worker transport, with reported compiled-worker lifecycle validation as supplemental evidence; no material authority change or stored-data contract change was found.
Evidence reviewed 9 items Pinned introduction and complete surface: Reviewed the merge-base-to-head changes across all 91 paths, including paths omitted from the supplied file list. Compared extracted modules against their original blobs to distinguish moves from behavioral changes. The stale test merge was not used to attribute current-base changes to this PR.
Checkpoint repair: The shared-capacity callback now returns false for an already-aborted pressure signal, allowing capacity traversal to reach another eligible exchange. This matches the existing per-pool pressure guard.
Still necessary on main: Fetched main still checks only exchange existence and whether a response was sent; it lacks the aborted-pressure guard. The linked open issue describes the same two-active-pools and repeated-pressure scenario: #164536.
Findings None None.
Security None None.

How this fits together

OpenClaw's worker pools run bounded background computation for agents, sessions, and database readers. Shared capacity coordinates queued tasks, while host adapters retain worker creation, database context, and resource cleanup.

flowchart TD
  A[Background tasks] --> B[Worker pool admission]
  B --> C[Shared compute capacity]
  C --> D[Worker execution]
  D --> E[Host response wait]
  C -->|Queue pressure| E
  E -->|Cooperative checkpoint| C
  D --> F[Results and diagnostics]
  D --> G[Host-owned cleanup]
Loading

Before merge

  • 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
Net source growth production/tooling +318; tests/support +200, excluding docs and accounting for renames Production growth is explained by the private package contracts, host adapters, and diagnostic accounting.

Stored data model

Persistent data-model change detected: unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #164536
Summary: This PR is the implementation candidate for the explicitly linked scheduling defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Use the single extracted scheduler with host-owned lifecycle policy and preserved public SDK contracts.

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

Yes, source establishes the repeated-pressure defect, and the linked report supplies a deterministic production-pool scenario with mocked Worker transport; this review did not execute it.

Is this the best way to solve the issue?

Yes, skipping already-signaled exchanges repairs the owning scheduler invariant, and the extraction preserves existing host and SDK responsibilities.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs bounded worker scheduling fairness without evidence of a live outage or urgent user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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 verified repository-admin author is exempt from external-contributor runtime proof. Scheduler regressions use mocked Worker transport, with reported compiled-worker lifecycle validation as supplemental evidence; no material authority change or stored-data contract change was found.

Evidence

What I checked:

  • Pinned introduction and complete surface: Reviewed the merge-base-to-head changes across all 91 paths, including paths omitted from the supplied file list. Compared extracted modules against their original blobs to distinguish moves from behavioral changes. The stale test merge was not used to attribute current-base changes to this PR. (91505d067ce3)
  • Checkpoint repair: The shared-capacity callback now returns false for an already-aborted pressure signal, allowing capacity traversal to reach another eligible exchange. This matches the existing per-pool pressure guard. (packages/worker-runtime/src/worker-task-pool-core.ts:366, 91505d067ce3)
  • Still necessary on main: Fetched main still checks only exchange existence and whether a response was sent; it lacks the aborted-pressure guard. The linked open issue describes the same two-active-pools and repeated-pressure scenario: [Bug]: Shared worker pressure repeatedly signals the same blocked exchange #164536. (src/infra/worker-task-pool-core.ts:376, bf4fe3ace570)
  • Latest release also retains defect: GitHub confirms v2026.9.8 is the latest release. Its source at lines 336–340 also lacks the aborted-pressure guard. The release blob was inspected through GitHub because the local tag object was unavailable. (src/infra/worker-task-pool-core.ts:337, fc23bc864e45)
  • Compatibility concern resolved: Host adapters preserve runtime options, native lifetime sources, database-fence capture, shared capacity, and the pool registry. Public SDK exports remain available. The internal task-context rename is migrated together across producers and consumers; no authored config, default, schema, persisted format, retention, or migration changes were found. (src/infra/worker-task-host.ts:21, 91505d067ce3)
  • Security and dependency boundary: OAuth changes only redirect imports to the preserved native-section implementation. Cancellation admission and task-liveness checks remain intact. The private package uses an existing local normalization dependency, with no new registry dependency or lifecycle hook. Codex declaration compilation mentioned in the body does not establish dependency on the Codex harness contract. (packages/worker-runtime/package.json:26, 91505d067ce3)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • ceckert: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (4 earlier review cycles)
  • reviewed 2026-10-03T21:17:34.777Z sha 51bcf5c :: blocked before merge. :: none
  • reviewed 2026-10-03T21:56:23.257Z sha 91505d0 :: blocked before merge. :: none
  • reviewed 2026-10-03T22:30:10.330Z sha 91505d0 :: blocked before merge. :: none
  • reviewed 2026-10-03T23:15:28.025Z sha 91505d0 :: blocked before merge. :: none

@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review current head 91505d0. The CI follow-up fixes declaration-only package aliases and the missed test type import; 64 affected tests, scoped typechecks/lint, and an isolated review pass.

The PR body now addresses compatibility explicitly: no authored configuration/default, database schema, stored-data, retention, or migration change. The original generic compatibility flags came from an incomplete file listing. The private workspace package uses only an existing workspace dependency, and SDK entrypoints remain stable.

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 0bc061b into main Oct 3, 2026
220 of 225 checks passed
@steipete
steipete deleted the codex/worker-runtime-package branch October 3, 2026 23:56
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
openclaw#164537)

* refactor(infra): extract worker runtime and fix checkpoint fairness

Move scheduling, task transport, native-section fences, and retained settlement
into a private workspace package. Keep database policy, native lifetime sources,
shared admission, and the existing plugin SDK contracts with their host owners.

Skip already-signaled host exchanges when repeated queue pressure requests a
checkpoint. Record hostWaitMs separately from runMs and include it in benchmark
diagnostics. Preserve method receivers for host lifecycle callbacks.

Validation: 165 scoped tests plus 53 tests on the final refinements, full
TypeScript checks, changed-source lint, SDK export checks, and independent review.
The extraction passed the full build. Five untouched files retain pre-existing
max-lines lint failures; the build also reported the existing-scope UI startup
size diagnostic. No schema, configuration, or operator migration is required.

* fix(build): complete worker runtime declaration boundaries
TheAngryPit pushed a commit to TheAngryPit/openclaw that referenced this pull request Oct 5, 2026
Backport the shared worker-runtime alias-owner entries from openclaw#164537. Reuse the shared aliases in standalone UI Vitest and cover them following openclaw#164061.
TheAngryPit pushed a commit to TheAngryPit/openclaw that referenced this pull request Oct 5, 2026
Backport the worker-runtime mappings from openclaw#164537 into the shared alias owner and reuse the UI projection pattern from openclaw#164061. Exercise channel-identity add and remove through the existing real-Gateway profile E2E, including fresh reads after reload.
vyctorbrzezowski added a commit that referenced this pull request Oct 22, 2026
* improve: show configured names for shared operator profiles

* fix(ui): preserve unnamed shared owner labels across consumers

* test(ui): align sidebar shared owner name expectation

* fix(test): share package aliases with UI Vitest projects

Backport the shared worker-runtime alias-owner entries from #164537. Reuse the shared aliases in standalone UI Vitest and cover them following #164061.

* fix(ui): reconcile named shared-owner locale expectations and scan coverage

* chore: prepare reviewed contributor base integration

* fix(ui): preserve shared profile labels across main integration

* chore: remove duplicate scan target

* style(ui): format shared profile name fixture

---------

Co-authored-by: TheAngryPit <[email protected]>
Co-authored-by: Vyctor H. Brzezowski <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 23, 2026
…#164593)

* improve: show configured names for shared operator profiles

* fix(ui): preserve unnamed shared owner labels across consumers

* test(ui): align sidebar shared owner name expectation

* fix(test): share package aliases with UI Vitest projects

Backport the shared worker-runtime alias-owner entries from openclaw#164537. Reuse the shared aliases in standalone UI Vitest and cover them following openclaw#164061.

* fix(ui): reconcile named shared-owner locale expectations and scan coverage

* chore: prepare reviewed contributor base integration

* fix(ui): preserve shared profile labels across main integration

* chore: remove duplicate scan target

* style(ui): format shared profile name fixture

---------

Co-authored-by: TheAngryPit <[email protected]>
Co-authored-by: Vyctor H. Brzezowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling dependencies-changed PR changes dependency-related files docs Improvements or additions to documentation extensions: xai gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts security-sensitive-changed 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.

[Bug]: Shared worker pressure repeatedly signals the same blocked exchange

1 participant