Skip to content

fix: maintenance fails during transient SQLite contention - #160702

Merged
RomneyDa merged 1 commit into
mainfrom
openclaw/investigate-issue-fix-status-on-main
Sep 29, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
openclaw/investigate-issue-fix-status-on-main

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Related: #157160

What Problem This Solves

Plugin update and Doctor maintenance can fail when another state-database writer briefly holds SQLite: admission can fail immediately with database is locked, or heartbeat renewal can wait until the persisted maintenance lease expires.

User Impact

Existing-schema maintenance now waits through transient admission contention and retries contended heartbeat renewal before expiry, without blocking the heartbeat worker's ownership acknowledgements.

Why This Change Was Made

  • Existing-schema agent admission locally disabled the state database owner's canonical busy timeout. Removing that override restores the existing admission policy.
  • Heartbeat renewal must remain nonblocking because the parent can hold the writer transaction while requesting an ownership acknowledgement. On contention, the worker now retains its zero-timeout attempt and schedules another attempt after 25 ms, bounded by the persisted lease expiry.

This completes the contention path around #157696 and #157733 without duplicating their heartbeat-responsiveness or update-repair owners. It does not change the separate 250 ms Gateway lock helpers.

#157160 also reports an uncontended lease-loss case and raises the broader question of fatal readiness behavior. Those remain outside this targeted contention fix, so this PR intentionally does not close the issue.

Evidence

  • On the exact pre-fix main commit, the two new real-SQLite contention regressions failed as expected: admission raised database is locked, and heartbeat renewal lost the lease. The existing 29 tests passed.
  • pnpm test src/state/openclaw-state-lease-existing.test.ts --maxWorkers=1: 17 passed; 30.59 s wall (new contention case: 501 ms).
  • pnpm test src/state/openclaw-state-lease-heartbeat.test.ts --maxWorkers=1: 14 passed; 41.70 s wall (new contention case: 2.06 s; strengthened parent-write liveness case: 1.07 s).
  • src/state/openclaw-state-lease-heartbeat.diagnostics.test.ts: 7 passed; its four contention cases now prove no retry at 24 ms and a retry at 25 ms.
  • test/scripts/upgrade-survivor-systemd.test.ts: 17 passed, including the fixture that failed on the previous PR head before its unrelated main-branch repair.
  • Exact-head 7216a80a4c2 isolated upgrade survivor: published [email protected] installed the candidate tarball through the updater, ran Doctor, and passed Gateway health, readiness, and status (updateOutcome=success; startup 40 s; health/readiness/status 1 s each).
  • node scripts/check-changed.mjs -- <five changed files> passes conflict, line-cap, and max-lines checks, then encounters the current-main env-name ratchet (477 > 476). This PR adds no OPENCLAW_* name.
  • Deslop: no changes needed.
  • Autoreview: no accepted/actionable P0-P1 findings after resolving its worker-responsiveness finding.

@clawsweeper

clawsweeper Bot commented Sep 28, 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.

@RomneyDa
RomneyDa marked this pull request as ready for review September 28, 2026 20:40
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. 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 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 6:56 PM ET / 22:56 UTC (Revision 4).

ClawSweeper review

What this changes

The branch restores the shared SQLite admission timeout for existing-schema maintenance and retries a contended lease heartbeat after 25 ms, with regression coverage.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still has both transient SQLite contention failure paths, and the merged related PRs address different failure modes. The linked issue also retains a separate uncontended readiness failure.

Priority: P0
Reviewed head: 7216a80a4c22dc3eb1d0e1d81d6d864011c47404

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused owner-level repair has relevant real-SQLite boundary evidence and no identified introduced defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR reports pre-fix failure and after-fix recovery through the actual lease owner and heartbeat worker with a separate real SQLite writer. A published-version updater also installed the exact-head candidate and passed Doctor and readiness, though that upgrade cell did not inject contention. No stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR reports pre-fix failure and after-fix recovery through the actual lease owner and heartbeat worker with a separate real SQLite writer. A published-version updater also installed the exact-head candidate and passed Doctor and readiness, though that upgrade cell did not inject contention. No stored-data contract changes.
Evidence reviewed 10 items Current-main admission: Fetched current main passes a zero-millisecond busy timeout to existing-schema agent maintenance admission.
Current-main heartbeat: After contention, current main schedules the next renewal at the full heartbeat interval, bounded by observed expiry.
Introduced repair: The pinned merge-base-to-head patch removes the local zero timeout and schedules a 25 ms retry after a contended heartbeat renewal.
Findings None None.
Security None None.

How this fits together

Doctor and plugin updates acquire a state-database maintenance lease before checking agent database writers. A worker renews that lease while maintenance runs, and loss of ownership stops the work.

flowchart LR
A[Doctor or plugin update] --> B[Maintenance lease]
B --> C[Check agent database writers]
C --> D[Protected maintenance]
B --> E[Heartbeat worker]
E --> F{SQLite writer busy?}
F -->|yes| G[Retry before expiry]
G --> F
F -->|no| H[Renew stored lease]
H --> D
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +6, Tests +42. Total +48 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 8 2 +6
Tests 3 49 7 +42
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 57 9 +48

Review metrics

Metric Value Why it matters
Real SQLite regression cost 2 new cases; 0.50 s and 2.06 s reported case time The cases cover distinct admission and renewal failures at the storage boundary.

Technical review

Best possible solution:

Maintenance admission and heartbeat renewal should survive brief SQLite contention while retaining persisted-owner and expiry checks; the independent uncontended readiness failure remains tracked in #157160.

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

Yes, at the source level: current main disables admission waiting and delays a contended renewal by a full heartbeat interval. The PR reports pre-fix failures in real-SQLite cases; this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. The patch uses the existing SQLite timeout owner and keeps retries in the lease worker, where persisted ownership and expiry still govern renewal.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3da238d5e385.

Labels

Label changes:

No label changes.

Label justifications:

  • P0: A failed update or Doctor maintenance step can leave a Gateway unable to recover without technical intervention.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR reports pre-fix failure and after-fix recovery through the actual lease owner and heartbeat worker with a separate real SQLite writer. A published-version updater also installed the exact-head candidate and passed Doctor and readiness, though that upgrade cell did not inject contention. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports pre-fix failure and after-fix recovery through the actual lease owner and heartbeat worker with a separate real SQLite writer. A published-version updater also installed the exact-head candidate and passed Doctor and readiness, though that upgrade cell did not inject contention. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e1c2a0b adds src/state/openclaw-agent-db-existing-write.ts:24 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e1c2a0b476e1; files: src/state/openclaw-agent-db-existing-write.ts)
  • fuller-stack-dev: 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 (3 earlier review cycles)
  • reviewed 2026-09-28T20:49:38.600Z sha 8972339 :: blocked before merge. :: none
  • reviewed 2026-09-28T22:28:33.317Z sha 273a42f99ead5005ba4cec1c543a6df7d53b34aa :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T22:44:00.661Z sha 7216a80 :: needs maintainer review before merge. :: none

@RomneyDa
RomneyDa force-pushed the openclaw/investigate-issue-fix-status-on-main branch from 8972339 to 273a42f Compare September 28, 2026 22:22
@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels Sep 28, 2026
@RomneyDa
RomneyDa force-pushed the openclaw/investigate-issue-fix-status-on-main branch from 273a42f to 7216a80 Compare September 28, 2026 22:36
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 28, 2026
@RomneyDa
RomneyDa merged commit 3328283 into main Sep 29, 2026
219 checks passed
@RomneyDa
RomneyDa deleted the openclaw/investigate-issue-fix-status-on-main branch September 29, 2026 23:58
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 30, 2026
steipete added a commit that referenced this pull request Oct 1, 2026
… contention (#162750)

A stalled cron sub-agent tool call drove sustained SQLite write contention; a state.lease operation with busy_timeout 0 failed with lock contention, and the per-agent database execution admission then closed permanently until restart because the execution owner retired logical admission after recoverable native-open failures and the worker transport dropped SQLite contention codes. Admission is now preserved across recoverable native-open failures, contention retries share the 25 ms cadence introduced for the lease heartbeat in #160702 and run only before application work starts, and shutdown, FIFO ownership and unknown-outcome safeguards are unchanged. Doctor preserves nested lease-loss diagnostics instead of flattening them; a nine-transaction Doctor probe confirms #160702 closes the heartbeat loss reported in #162083.

Closes #162579
Refs #162083
BsnizND pushed a commit to BsnizND/openclaw that referenced this pull request Oct 1, 2026
RomneyDa added a commit that referenced this pull request Oct 1, 2026
RomneyDa added a commit that referenced this pull request Oct 1, 2026
* fix: preserve plugin settings through update recovery (#160344)

Keep incompatible local plugin configuration intact and complete deferred migration confirmation after unchanged package convergence. Use completion receipts to clear obsolete retry warnings without rewriting update history.

Fixes #159477. Thanks @EndeavorPioneer for the recovery report.

(cherry picked from commit 8e66b0b)

* fix: prevent duplicate Gateways during container onboarding (#160193)

* fix: prevent duplicate Gateways during container onboarding

* fix: keep QA cron controls scoped to the child

Drop inherited parent cron suppression while preserving explicit child runtime
settings. Cover the failing inheritance contract at the environment owner.

Await node-list RPC responses after acknowledged rename and reconnect events
without racing the existing RPC deadline against a separate polling timeout.

(cherry picked from commit 54b1b1b)

* fix: refuse incompatible Windows 9.4 schema upgrades (#160718)

* fix: refuse incompatible Windows 9.4 schema upgrades

Refuse shared-state migration during the shipped Windows 9.4 raw Doctor preflight while its recorded updater drivers have not positively stopped. Keep the existing delegated Doctor and 9.2 publication paths unchanged. Split manual recovery text so the shipped canary retains the reason and commands within its per-line capture limit. This contains the old callback failure; it does not complete automatic 9.4 updates.

* fix: refuse legacy Windows migration during package staging

* fix(update): load package lifecycle guard only at runtime

(cherry picked from commit 0703c21)

* fix(anthropic): prevent stuck turns after background Bash completes (#161260)

* fix(anthropic): release backgrounded Bash hold on task-notification result

* fix(anthropic): settle background replies without stalled or prematurely closed turns

Keep native Bash, agent, and workflow completions attached until consumed. Correlate queued and inline acknowledgements, preserve failure retirement, and distinguish automatic Bash timeouts from explicit background requests using authorized input. Add transport regressions; verify real Claude producer ordering and patched warm-session reuse.

Co-authored-by: VACInc <[email protected]>

---------

Co-authored-by: VACInc <[email protected]>
(cherry picked from commit 38dd3c2)

* fix: preserve maintenance leases during SQLite contention (#160702)

(cherry picked from commit 3328283)

* fix(gateway): preserve proxy policy in local TLS health probes (#161946)

(cherry picked from commit 649b19f)

* fix(telegram): prevent empty retired bindings from blocking updates (#161832)

* test(telegram): cover empty retired bindings migration

* test(doctor): cover empty Telegram migration receipt

* fix(telegram): archive verified empty retired bindings

Co-authored-by: ericcaiwx-star <[email protected]>
(cherry picked from commit 646ac9a)

* fix(doctor): keep session repair iterative on deep canonical owner chains (#162321)

Doctor's session-repair step overflowed the stack (RangeError: Maximum call stack size exceeded) on large but healthy agent databases during 2026.9.7 update activation: canonical-owner resolution followed canonicalOwnerSessionKey alias chains recursively, and row-count-sized spreads sat on the same path. Resolution is now iterative with the same terminal-owner, missing-owner, and cycle outcomes, and the spreads are linear reductions with unchanged empty-input behavior. A healthy 12,000-owner / 200,000-event fixture fails pre-fix and passes post-fix; the published-driver upgrade preserved transcript bytes.

Closes #161979

(cherry picked from commit 9fb7ba2)

* fix(launcher): keep the Node compile-cache path short on Windows (#162841)

2026.9.7 lengthened the compile-cache marker from <mtime>-<size> to build-<buildId>, which pushed cache paths on Windows into the directory-length window where Node 24's module.enableCompileCache() never returns (nodejs/node#66438); every OpenClaw process start could then spin at full CPU. The shared cache owner now uses a 16-character hash of the full build id as the marker, refuses Windows cache paths over 200 characters with a recorded warning (cache off for that process), and no longer propagates an unsafe inherited cache path to children. Legacy namespace handling and POSIX behavior are unchanged; native Windows/Node 24.18 completes the packaged CLI with a 220-character TEMP in 2.4 s.

Closes #162821

(cherry picked from commit 6e987af)

* fix(codex): prevent Gateway heap exhaustion with large agent fleets (#162912)

Closes #162802

## What Problem This Solves

Fixes Gateway heap exhaustion during Codex session discovery on large agent fleets. Thanks to @609NFT for the report and allocation profiles.

## User Impact

Large fleets can finish startup and retain their native Codex session catalog without retaining a whole fleet configuration for every agent/home pair. No schema, stored-data, configuration, or catalog-output changes are required.

## Why This Change Was Made

The existing config-identity cache now owns one captured configuration per generation. Agent/home entries keep their separate directories and cloned connection options, but share that captured configuration. Config reload isolation and source-specific backoff remain unchanged.

No overlap with Pash/Sarah changes.

Codex source inspection: `codex-rs/app-server/src/request_processors/thread_processor.rs:2524–2608` in the sibling Codex checkout confirms that `thread/list` consumes pagination and filter parameters; the fleet configuration capture being repaired belongs to OpenClaw, not the native listing protocol.

## Evidence

Compared baseline `7ef388bac8f607eb03510189922d1c6a4d786b52` with candidate `f0ae922f60922f2b357bc3d5af22a2142799fbe0` in isolated Linux arm64 Docker containers, Node 24.21.0. The synthetic profile contained 739 agents, eight explicit Codex homes, and three native sessions (380,439 bytes of configuration).

| Check | Baseline | Candidate |
| --- | --- | --- |
| Real Gateway, 2,560 MiB heap | Heap OOM at 100.3 s | Survived the six-minute window; clean shutdown |
| Sampled catalog allocations under `resolveRequestOptions` → `structuredClone` | 2.248 GB | 5.48 MB |
| Post-startup heap, 150–360 s | Process already terminated | Bounded at 377–566 MiB |
| Complete startup, separate 6,144 MiB control without profiling | 98.34 s | 93.83 s |
| HTTP listening, same startup control | 50.52 s | 49.56 s |

The larger-heap startup control lets the baseline complete startup rather than comparing a successful candidate against an OOM.

- Real `sessions.catalog.list` Gateway RPCs returned exactly the three expected native session IDs for agents `agent000`, `agent001`, and `agent738`.
- Exact-head live gate: a real OpenAI `gpt-5.4-mini` turn through the candidate Gateway's Codex harness returned `CATALOG_LIVE_OK` on the 739-agent profile (5.449 s). Its temporary read-only credential file and container were removed.
- Regression failed on baseline: four fleet config clones instead of one across multiple agents/homes. It passes on the candidate and also checks reload allocation isolation; the regression itself took 5 ms.
- All 38 focused tests passed across `session-catalog-listing-cache.test.ts`, `session-catalog-request-lifetime.test.ts`, `session-catalog-homes.test.ts`, and `session-catalog-backoff.test.ts` (38.67 s wall).
- Standalone `pnpm test extensions/codex/src/session-catalog-listing-cache.test.ts --maxWorkers=1` passed (32.61 s wall, including runner preparation).
- Built and exercised the real candidate runtime with `pnpm build`. Broader static and project-wide validation is left to CI.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit fd01246)

* fix(telegram): preserve queued preview writer authority (#160137)

* fix(telegram): preserve queued preview writer authority

Forward-port the Telegram preview correction from f488a8c. Both preview paths retain current-writer authority through the account scheduler and network admission.

WIP: the regression failed before the repair and all 86 focused tests pass. Full changed-check completion and independent review remain pending under the work-order time budget.

Co-authored-by: Ayaan Zaidi <[email protected]>

* docs(telegram): scope the preview authority note to guarded updates

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit a8907e3)

* fix(telegram): keep empty binding archive failures from blocking updates (#162290)

Follow-up to #161832: when archiving a verified-empty retired Telegram bindings file fails (for example the .migrated target already exists), the migration records a recoverable warning instead of refusing the update; non-empty or uncertain sources keep the preservation refusal. Sanitized refusal messages keep their diagnostic text.

Refs #161795

Thanks @ericcaiwx-star for the base fix in #161832.

(cherry picked from commit 1b9d7e7)

* fix(sandbox): sessions fail with EACCES after skills refresh on read-only installs (#162304)

* fix(sandbox): keep synced skill copies removable on read-only installs

Sandbox skill sync copied bundled skills with fs.cp, which keeps source
modes. From a read-only install every copied directory became 0555, so the
next full re-sync (skills version bump or Gateway restart) failed with
EACCES unlinking skills/<skill>/SKILL.md, and library-pinned sessions
failed every turn.

Copied directories are now made owner-writable (file modes unchanged), and
removal repairs legacy read-only trees inside the synced child before one
retry. The repair stays inside the skills root and never follows symlinks.
The Claude CLI skills-plugin copy fallback uses the same helper.

* fix(sandbox): classify skill removal errors without a type assertion

(cherry picked from commit be93e85)

* fix(doctor): share plugin registries across agents in the tool-schema check (#162394)

doctor --fix heap-OOMed on a 739-agent state: the runtime tool-schema check resolved a model per agent workspace, and every plugin-load cache context cloned the full runtime config and retained a registry per workspace (516 MB of config clones at 2.4 GB heap). The loader now defers config capture until a cache miss and shares prepared provider registrations within a captured config generation for agents with matching configuration and plugin sources; a reentrant load during capture joins the in-flight load instead of registering twice. 300 synthetic agents: config clones 1,802 -> 3, registries 300 -> 1, peak RSS 1.25 GB -> 0.88 GB.

Closes #161869

(cherry picked from commit e304e4f)

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Vito Cappello <[email protected]>
Co-authored-by: VACInc <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Co-authored-by: Eric Cai <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 1, 2026
* fix: preserve plugin settings through update recovery (#160344)

Keep incompatible local plugin configuration intact and complete deferred migration confirmation after unchanged package convergence. Use completion receipts to clear obsolete retry warnings without rewriting update history.

Fixes #159477. Thanks @EndeavorPioneer for the recovery report.

(cherry picked from commit 8e66b0b)

* fix: prevent duplicate Gateways during container onboarding (#160193)

* fix: prevent duplicate Gateways during container onboarding

* fix: keep QA cron controls scoped to the child

Drop inherited parent cron suppression while preserving explicit child runtime
settings. Cover the failing inheritance contract at the environment owner.

Await node-list RPC responses after acknowledged rename and reconnect events
without racing the existing RPC deadline against a separate polling timeout.

(cherry picked from commit 54b1b1b)

* fix: refuse incompatible Windows 9.4 schema upgrades (#160718)

* fix: refuse incompatible Windows 9.4 schema upgrades

Refuse shared-state migration during the shipped Windows 9.4 raw Doctor preflight while its recorded updater drivers have not positively stopped. Keep the existing delegated Doctor and 9.2 publication paths unchanged. Split manual recovery text so the shipped canary retains the reason and commands within its per-line capture limit. This contains the old callback failure; it does not complete automatic 9.4 updates.

* fix: refuse legacy Windows migration during package staging

* fix(update): load package lifecycle guard only at runtime

(cherry picked from commit 0703c21)

* fix(anthropic): prevent stuck turns after background Bash completes (#161260)

* fix(anthropic): release backgrounded Bash hold on task-notification result

* fix(anthropic): settle background replies without stalled or prematurely closed turns

Keep native Bash, agent, and workflow completions attached until consumed. Correlate queued and inline acknowledgements, preserve failure retirement, and distinguish automatic Bash timeouts from explicit background requests using authorized input. Add transport regressions; verify real Claude producer ordering and patched warm-session reuse.

Co-authored-by: VACInc <[email protected]>

---------

Co-authored-by: VACInc <[email protected]>
(cherry picked from commit 38dd3c2)

* fix: preserve maintenance leases during SQLite contention (#160702)

(cherry picked from commit 3328283)

* fix(gateway): preserve proxy policy in local TLS health probes (#161946)

(cherry picked from commit 649b19f)

* fix(telegram): prevent empty retired bindings from blocking updates (#161832)

* test(telegram): cover empty retired bindings migration

* test(doctor): cover empty Telegram migration receipt

* fix(telegram): archive verified empty retired bindings

Co-authored-by: ericcaiwx-star <[email protected]>
(cherry picked from commit 646ac9a)

* fix(doctor): keep session repair iterative on deep canonical owner chains (#162321)

Doctor's session-repair step overflowed the stack (RangeError: Maximum call stack size exceeded) on large but healthy agent databases during 2026.9.7 update activation: canonical-owner resolution followed canonicalOwnerSessionKey alias chains recursively, and row-count-sized spreads sat on the same path. Resolution is now iterative with the same terminal-owner, missing-owner, and cycle outcomes, and the spreads are linear reductions with unchanged empty-input behavior. A healthy 12,000-owner / 200,000-event fixture fails pre-fix and passes post-fix; the published-driver upgrade preserved transcript bytes.

Closes #161979

(cherry picked from commit 9fb7ba2)

* fix(launcher): keep the Node compile-cache path short on Windows (#162841)

2026.9.7 lengthened the compile-cache marker from <mtime>-<size> to build-<buildId>, which pushed cache paths on Windows into the directory-length window where Node 24's module.enableCompileCache() never returns (nodejs/node#66438); every OpenClaw process start could then spin at full CPU. The shared cache owner now uses a 16-character hash of the full build id as the marker, refuses Windows cache paths over 200 characters with a recorded warning (cache off for that process), and no longer propagates an unsafe inherited cache path to children. Legacy namespace handling and POSIX behavior are unchanged; native Windows/Node 24.18 completes the packaged CLI with a 220-character TEMP in 2.4 s.

Closes #162821

(cherry picked from commit 6e987af)

* fix(codex): prevent Gateway heap exhaustion with large agent fleets (#162912)

Closes #162802

## What Problem This Solves

Fixes Gateway heap exhaustion during Codex session discovery on large agent fleets. Thanks to @609NFT for the report and allocation profiles.

## User Impact

Large fleets can finish startup and retain their native Codex session catalog without retaining a whole fleet configuration for every agent/home pair. No schema, stored-data, configuration, or catalog-output changes are required.

## Why This Change Was Made

The existing config-identity cache now owns one captured configuration per generation. Agent/home entries keep their separate directories and cloned connection options, but share that captured configuration. Config reload isolation and source-specific backoff remain unchanged.

No overlap with Pash/Sarah changes.

Codex source inspection: `codex-rs/app-server/src/request_processors/thread_processor.rs:2524–2608` in the sibling Codex checkout confirms that `thread/list` consumes pagination and filter parameters; the fleet configuration capture being repaired belongs to OpenClaw, not the native listing protocol.

## Evidence

Compared baseline `7ef388bac8f607eb03510189922d1c6a4d786b52` with candidate `f0ae922f60922f2b357bc3d5af22a2142799fbe0` in isolated Linux arm64 Docker containers, Node 24.21.0. The synthetic profile contained 739 agents, eight explicit Codex homes, and three native sessions (380,439 bytes of configuration).

| Check | Baseline | Candidate |
| --- | --- | --- |
| Real Gateway, 2,560 MiB heap | Heap OOM at 100.3 s | Survived the six-minute window; clean shutdown |
| Sampled catalog allocations under `resolveRequestOptions` → `structuredClone` | 2.248 GB | 5.48 MB |
| Post-startup heap, 150–360 s | Process already terminated | Bounded at 377–566 MiB |
| Complete startup, separate 6,144 MiB control without profiling | 98.34 s | 93.83 s |
| HTTP listening, same startup control | 50.52 s | 49.56 s |

The larger-heap startup control lets the baseline complete startup rather than comparing a successful candidate against an OOM.

- Real `sessions.catalog.list` Gateway RPCs returned exactly the three expected native session IDs for agents `agent000`, `agent001`, and `agent738`.
- Exact-head live gate: a real OpenAI `gpt-5.4-mini` turn through the candidate Gateway's Codex harness returned `CATALOG_LIVE_OK` on the 739-agent profile (5.449 s). Its temporary read-only credential file and container were removed.
- Regression failed on baseline: four fleet config clones instead of one across multiple agents/homes. It passes on the candidate and also checks reload allocation isolation; the regression itself took 5 ms.
- All 38 focused tests passed across `session-catalog-listing-cache.test.ts`, `session-catalog-request-lifetime.test.ts`, `session-catalog-homes.test.ts`, and `session-catalog-backoff.test.ts` (38.67 s wall).
- Standalone `pnpm test extensions/codex/src/session-catalog-listing-cache.test.ts --maxWorkers=1` passed (32.61 s wall, including runner preparation).
- Built and exercised the real candidate runtime with `pnpm build`. Broader static and project-wide validation is left to CI.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit fd01246)

* fix(telegram): preserve queued preview writer authority (#160137)

* fix(telegram): preserve queued preview writer authority

Forward-port the Telegram preview correction from f488a8c. Both preview paths retain current-writer authority through the account scheduler and network admission.

WIP: the regression failed before the repair and all 86 focused tests pass. Full changed-check completion and independent review remain pending under the work-order time budget.

Co-authored-by: Ayaan Zaidi <[email protected]>

* docs(telegram): scope the preview authority note to guarded updates

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit a8907e3)

* fix(telegram): keep empty binding archive failures from blocking updates (#162290)

Follow-up to #161832: when archiving a verified-empty retired Telegram bindings file fails (for example the .migrated target already exists), the migration records a recoverable warning instead of refusing the update; non-empty or uncertain sources keep the preservation refusal. Sanitized refusal messages keep their diagnostic text.

Refs #161795

Thanks @ericcaiwx-star for the base fix in #161832.

(cherry picked from commit 1b9d7e7)

* fix(sandbox): sessions fail with EACCES after skills refresh on read-only installs (#162304)

* fix(sandbox): keep synced skill copies removable on read-only installs

Sandbox skill sync copied bundled skills with fs.cp, which keeps source
modes. From a read-only install every copied directory became 0555, so the
next full re-sync (skills version bump or Gateway restart) failed with
EACCES unlinking skills/<skill>/SKILL.md, and library-pinned sessions
failed every turn.

Copied directories are now made owner-writable (file modes unchanged), and
removal repairs legacy read-only trees inside the synced child before one
retry. The repair stays inside the skills root and never follows symlinks.
The Claude CLI skills-plugin copy fallback uses the same helper.

* fix(sandbox): classify skill removal errors without a type assertion

(cherry picked from commit be93e85)

* fix(doctor): share plugin registries across agents in the tool-schema check (#162394)

doctor --fix heap-OOMed on a 739-agent state: the runtime tool-schema check resolved a model per agent workspace, and every plugin-load cache context cloned the full runtime config and retained a registry per workspace (516 MB of config clones at 2.4 GB heap). The loader now defers config capture until a cache miss and shares prepared provider registrations within a captured config generation for agents with matching configuration and plugin sources; a reentrant load during capture joins the in-flight load instead of registering twice. 300 synthetic agents: config clones 1,802 -> 3, registries 300 -> 1, peak RSS 1.25 GB -> 0.88 GB.

Closes #161869

(cherry picked from commit e304e4f)

* fix(release): carry 2026.9.8 CI exceptions

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Vito Cappello <[email protected]>
Co-authored-by: VACInc <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Co-authored-by: Eric Cai <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
… contention (openclaw#162750)

A stalled cron sub-agent tool call drove sustained SQLite write contention; a state.lease operation with busy_timeout 0 failed with lock contention, and the per-agent database execution admission then closed permanently until restart because the execution owner retired logical admission after recoverable native-open failures and the worker transport dropped SQLite contention codes. Admission is now preserved across recoverable native-open failures, contention retries share the 25 ms cadence introduced for the lease heartbeat in openclaw#160702 and run only before application work starts, and shutdown, FIFO ownership and unknown-outcome safeguards are unchanged. Doctor preserves nested lease-loss diagnostics instead of flattening them; a nine-transaction Doctor probe confirms openclaw#160702 closes the heartbeat loss reported in openclaw#162083.

Closes openclaw#162579
Refs openclaw#162083
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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