Skip to content

fix(cron): release idle workers when automatic scheduling is disabled - #196387

Merged
RomneyDa merged 1 commit into
mainfrom
fix/disabled-cron-lease-split-192552
Nov 10, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/disabled-cron-lease-split-192552

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: disabling automatic cron scheduling still pins the native database worker for the lifetime of the service.

Related: #192547. Extracted from #192552; implementation by @vincentkoc.

User Impact

Disabled cron can release its idle worker under memory pressure while manual runs and startup recovery remain available. Enabled scheduling retains its persistent lease. No configuration or schema changes.

Why This Change Was Made

The scheduler owner borrows a finite lease for disabled reconciliation and serializes each borrow through its finalizer. Shutdown joins active work; database retirement invalidates the current borrow. This separates the lifecycle fix from the broader cold-import and build changes in #192552.

Simplification retained one scheduler owner and existing lease machinery. The production delta is +64/-12 lines; regression coverage adds 153 lines, funded by an exact task-specific allocation without raising the shared scalar.

Evidence

  • On main d7aaafe92edfe272b7d17f9793a6feb70248956d, the new real-worker retirement test fails at its 10-second deadline with the old persistent lease (1 failed, 3 filtered; 77.39 seconds including cold worker compilation).
  • With the extracted fix, the complete lifecycle file and scheduler-worker sibling pass: 25/25 tests in 56.18 seconds including 42.36-second worker compilation. Disabled retirement/manual execution: 3.628 seconds; in-flight shutdown: 0.163 seconds. Enabled scheduling, suspension, startup/recovery and clock-change siblings remain covered.
  • Targeted lint, formatting, cron test type graph, staged test-line ratchet and diff checks passed. Local ClawSweeper completed the full committed range d7aaafe92edfe272b7d17f9793a6feb70248956d..1507bf9133fa7bd5a48d77b519b0aa4a9fd6ebea: high-confidence review, no actionable correctness or security defects, patch correct. This was source review; the test results above were executed separately.
  • Independent source review found no blocking issue after inspecting lease acquisition/release/retirement and Start/Refresh/Stop semantics.
  • Local proof: pinned Bun test runner, Node 26.12.1 orchestration, Darwin ARM64. Exact-head CI and hosted timing remain pending. This does not claim constrained-Linux ARM memory acceptance or physical-device readiness; Reduce Gateway startup memory on constrained ARM64 hosts #192547 remains open.

Extract the independently reviewable lifecycle fix from #192552. Preserve manual execution, startup recovery, enabled scheduling, and joined shutdown while allowing disabled cron workers to retire.
@clawsweeper

clawsweeper Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@RomneyDa
RomneyDa enabled auto-merge (squash) November 10, 2026 02:27
@RomneyDa
RomneyDa merged commit 4e97c6e into main Nov 10, 2026
114 checks passed
@RomneyDa
RomneyDa deleted the fix/disabled-cron-lease-split-192552 branch November 10, 2026 02:28
RomneyDa added a commit that referenced this pull request Nov 10, 2026
Move runtime-source minification and disabled-cron scheduler lease work to independent PRs #196386 and #196387. Keep the original catalog, tool, and database cold-import cutover together and preserve all contributor ancestry.

Transfer exactly 90 and 153 regression-test lines to their owning changes; reduce this change allocation from 1092 to 849 without changing the shared baseline.
@RomneyDa

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

RomneyDa added a commit that referenced this pull request Nov 10, 2026
* fix(models): reduce cold catalog memory

* fix(models): reuse captured catalog suppression metadata

* fix(openai): defer catalog auth runtime loading

* test(openai): explain catalog auth mock isolation

* fix(models): defer discovery OAuth runtime loading

* fix(process): isolate broker OOM spawn operations

* fix(pr): retain broker OOM spawn leaf in wrapper

* fix(state): load shared read query owners on demand

* fix(gateway): skip empty shared publication recovery

* fix(state): defer subagent completion imports during queue recovery

* fix(state): isolate placement startup worker imports

* fix(state): defer ACP imports for session maintenance

* fix(startup): defer unused transcript and hook imports

* fix(ci): fund the empty publication recovery regression

* fix(startup): defer plugin session event execution

* fix(startup): defer catalog migration and process helpers

* test(plugins): exercise command revocation without a process mock

* fix(startup): separate npm record metadata from command execution

* refactor(plugins): keep npm metadata types with registry helpers

* fix(gateway): keep optional runtimes out of cold discovery

* test(agents): consolidate cold catalog import checks

* fix(openai): isolate catalog discovery from runtime hooks

* test(openai): consolidate cold import boundary cases

* perf(agents): skip globally denied tool construction

* test: consolidate cold runtime regression coverage

* perf(agents): defer cold tool factory imports

Keep asynchronous tool construction independent of the legacy synchronous SDK facade. Load factories only when the shared assembly requests them and revalidate authority after each import.

Preserve policy, collector and host-tool behavior. Cover cold chat import boundaries and move consumer mocks to the asynchronous owner.

* fix(plugins): expose opaque session event target type

* fix(agents): skip auxiliary runtimes when tools are denied

* fix(gateway): keep auth policy reads on runtime snapshots

* fix(gateway): defer headless model catalog discovery

* test(gateway): account for headless catalog regressions

* test(gateway): complete cold-start regression allocation

* fix(plugins): preserve loaded provider catalogs during discovery

* fix(gateway): preserve provider scope during catalog reads

* fix(agents): retain source identity for late catalog providers

* fix(agents): preserve lazy catalogs across remote updates

* fix(gateway): defer unused workspace prewarm imports

* fix(gateway): keep headless session display work cold

* fix(agents): defer optional execution runtimes

* fix(agents): complete deferred runtime cutover

* fix(ui): calibrate budget for removed preload

* fix(state): isolate session patch publication imports

* perf(agents): defer local command and session barrel imports

* test: reuse existing cold-import line allocation

* test(agents): hook the concrete queued maintenance owner

* perf(build): reduce runtime source retained by module loaders

Shorten local bindings while preserving module markers and top-level names used by update compatibility and standalone codegen. Apply the existing name-preserving worker minification policy to standalone runtime processes.

Add an emitted-byte and relocated-runtime regression with an exact 90-line test allocation. Focused build contracts, tooling typecheck, lint, format, and the test-line ratchet pass. ARM memory acceptance remains pending.

* fix(cron): release disabled scheduler worker leases

* refactor(startup): simplify regression proof and allocation

* test(startup): account for merged publication coverage

* test(models): join native catalog refresh before logout

* refactor(startup): split independent build and cron fixes

Move runtime-source minification and disabled-cron scheduler lease work to independent PRs #196386 and #196387. Keep the original catalog, tool, and database cold-import cutover together and preserve all contributor ancestry.

Transfer exactly 90 and 153 regression-test lines to their owning changes; reduce this change allocation from 1092 to 849 without changing the shared baseline.

* test(gateway): isolate native catalog RPC demand from startup warmup

---------

Co-authored-by: Dallin Romney <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 10, 2026
Extract the independently reviewable lifecycle fix from openclaw#192552. Preserve manual execution, startup recovery, enabled scheduling, and joined shutdown while allowing disabled cron workers to retire.

Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 10, 2026
…92552)

* fix(models): reduce cold catalog memory

* fix(models): reuse captured catalog suppression metadata

* fix(openai): defer catalog auth runtime loading

* test(openai): explain catalog auth mock isolation

* fix(models): defer discovery OAuth runtime loading

* fix(process): isolate broker OOM spawn operations

* fix(pr): retain broker OOM spawn leaf in wrapper

* fix(state): load shared read query owners on demand

* fix(gateway): skip empty shared publication recovery

* fix(state): defer subagent completion imports during queue recovery

* fix(state): isolate placement startup worker imports

* fix(state): defer ACP imports for session maintenance

* fix(startup): defer unused transcript and hook imports

* fix(ci): fund the empty publication recovery regression

* fix(startup): defer plugin session event execution

* fix(startup): defer catalog migration and process helpers

* test(plugins): exercise command revocation without a process mock

* fix(startup): separate npm record metadata from command execution

* refactor(plugins): keep npm metadata types with registry helpers

* fix(gateway): keep optional runtimes out of cold discovery

* test(agents): consolidate cold catalog import checks

* fix(openai): isolate catalog discovery from runtime hooks

* test(openai): consolidate cold import boundary cases

* perf(agents): skip globally denied tool construction

* test: consolidate cold runtime regression coverage

* perf(agents): defer cold tool factory imports

Keep asynchronous tool construction independent of the legacy synchronous SDK facade. Load factories only when the shared assembly requests them and revalidate authority after each import.

Preserve policy, collector and host-tool behavior. Cover cold chat import boundaries and move consumer mocks to the asynchronous owner.

* fix(plugins): expose opaque session event target type

* fix(agents): skip auxiliary runtimes when tools are denied

* fix(gateway): keep auth policy reads on runtime snapshots

* fix(gateway): defer headless model catalog discovery

* test(gateway): account for headless catalog regressions

* test(gateway): complete cold-start regression allocation

* fix(plugins): preserve loaded provider catalogs during discovery

* fix(gateway): preserve provider scope during catalog reads

* fix(agents): retain source identity for late catalog providers

* fix(agents): preserve lazy catalogs across remote updates

* fix(gateway): defer unused workspace prewarm imports

* fix(gateway): keep headless session display work cold

* fix(agents): defer optional execution runtimes

* fix(agents): complete deferred runtime cutover

* fix(ui): calibrate budget for removed preload

* fix(state): isolate session patch publication imports

* perf(agents): defer local command and session barrel imports

* test: reuse existing cold-import line allocation

* test(agents): hook the concrete queued maintenance owner

* perf(build): reduce runtime source retained by module loaders

Shorten local bindings while preserving module markers and top-level names used by update compatibility and standalone codegen. Apply the existing name-preserving worker minification policy to standalone runtime processes.

Add an emitted-byte and relocated-runtime regression with an exact 90-line test allocation. Focused build contracts, tooling typecheck, lint, format, and the test-line ratchet pass. ARM memory acceptance remains pending.

* fix(cron): release disabled scheduler worker leases

* refactor(startup): simplify regression proof and allocation

* test(startup): account for merged publication coverage

* test(models): join native catalog refresh before logout

* refactor(startup): split independent build and cron fixes

Move runtime-source minification and disabled-cron scheduler lease work to independent PRs openclaw#196386 and openclaw#196387. Keep the original catalog, tool, and database cold-import cutover together and preserve all contributor ancestry.

Transfer exactly 90 and 153 regression-test lines to their owning changes; reduce this change allocation from 1092 to 849 without changing the shared baseline.

* test(gateway): isolate native catalog RPC demand from startup warmup

---------

Co-authored-by: Dallin Romney <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 12, 2026
Extract the independently reviewable lifecycle fix from #192552. Preserve manual execution, startup recovery, enabled scheduling, and joined shutdown while allowing disabled cron workers to retire.

Co-authored-by: Vincent Koc <[email protected]>

(cherry picked from commit 4e97c6e)

Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 12, 2026
Adapt upstream source 625945b to the beta3 runtime owners. Keep synchronous SDK compatibility while deferring tool, model, plugin, process and state-handler initialization.

Integrate on 67cc5d9, preserving #195398, #196301, #196386, #196387, #189991 and #196448. Three automatically merged overlaps retain canonical assertion/mock baseline removals and worker-turn input gating; no new behavioral adaptation.

Original source reviews and focused build/test evidence are retained. Fresh integration-only independent review found no actionable issues.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants