Skip to content

fix(state): keep lease renewal independent of parent admission - #188391

Merged
vincentkoc merged 4 commits into
mainfrom
investigate/lease-schema-renewal-20261030
Oct 30, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
investigate/lease-schema-renewal-20261030

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

A maintenance heartbeat can wait synchronously for its busy parent after supported schema preparation invalidates cached physical facts. Its durable lease can then expire even though the heartbeat runs in a separate worker.

User Impact

Maintenance workers keep renewing while the parent performs synchronous work. Lease fencing, database authority, physical identity, snapshot validation, and schema-revision checks remain enforced.

Why This Change Was Made

Only reconstructible schema and text-encoding facts use connection-local recapture and deferred cache sharing during ongoing work. Cold readiness publishes committed facts before connection handoff; explicit schema repair publishes the current catalog after its validation pin. Failed capture or acknowledgement remains retryable, and transaction-local or historical facts cannot mark shared readiness complete.

Host authority, custody, scoped-write exchanges, lease lifetimes, and renewal scheduling are unchanged. No schema/config/protocol bump, timeout increase, retry loop, or asynchronous queue.

Runtime delta: +92/-29 (net +63), owning the distinction between physical caches and authority plus successful publication at readiness/readmission. Tests: +456/-15 (net +441), with a scoped allocation.

Evidence

Signed head 61bc7a451fa748940703d3401a9f08a7af28c026; tested merge 2f43392aa8ea8bae753251890f0010e567facaac. All 15 changed blobs match the reviewed head. Independent source/proof review and fresh correction/layout autoreviews found no remaining actionable issue.

Node 24.22.1 and Bun 191755ec each passed 102 targeted cases:

  • Physical facts and sustained maintenance: 6 physical-cache cases and 2 real-worker maintenance cases per runtime. Durable heartbeats advance beyond two original lease lifetimes with no pending parent request, including supported lazy schema preparation.
  • Cold readiness and repair publication: 11 worker-admission and 3 schema-refresh cases per runtime; unchanged one-capture serialization and post-pin/refusal assertions.
  • Retained readmission: 29 cases per runtime, including unchanged missing-index/warm/idle SQL-count assertions.
  • Native snapshots and custody: 51 cases per runtime covering rollback, retirement, physical identity, authorizers, snapshots, and native callbacks.
  • Unpatched baseline: both runtimes reproduce the actual pending admission exchange and durable expiry only after supported post-ready schema preparation.

Exact-head hosted review reports no findings or before-merge actions. Broad CI is awaiting PostgreSQL conformance; native GitHub gates enforce final CI, security, and review admission. The tested merge context includes intervening main changes; this is not blanket equivalence to older builds or conclusive attribution of an earlier deployment failure. Proof exercises production workers and SQLite through the maintenance harness, rather than a full shipped Doctor invocation. Incident Node 26.7 was not executed.

This repairs the renewal dependency itself, separately from loss-diagnostic propagation and backup-header batching.

@vincentkoc vincentkoc self-assigned this Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 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.

@vincentkoc
vincentkoc marked this pull request as ready for review October 30, 2026 13:49
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 30, 2026
@vincentkoc vincentkoc changed the title chore(state): investigate maintenance lease renewal (do not merge) fix(state): keep lease renewal independent of parent admission Oct 30, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review current head 61bc7a451fa748940703d3401a9f08a7af28c026. The PR now contains the owner-boundary repair and exact-head Node/Bun proof; prior review markers cover an older investigation revision.

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR lets active SQLite connections recapture physical schema facts without waiting for the parent, while publishing committed facts at readiness and repair handoffs.

Example: A maintenance lease lasts 10 seconds, lazy provenance preparation changes the schema, and the parent blocks for more than 20 seconds.

  • Before: The heartbeat can wait for a parent admission exchange and let its durable lease expire.
  • After: The heartbeat recaptures physical facts locally and continues renewing through the existing lease checks.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch has no identified correctness defect; supplied validation exercises real production workers through a harness rather than the shipped Doctor entry point.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence exercises the production heartbeat worker and real SQLite through lazy schema preparation and a blocked parent.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Maintenance can lose its durable lease while its independent heartbeat waits for a busy parent after schema preparation.
Reason: The maintainer-authored direction restores the independent-heartbeat contract through existing owners, with no new configuration or storage format.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR repairs a current renewal dependency at the shared admission owner; no actionable introduced defect was found.

Priority: P2
Reviewed head: 61bc7a451fa748940703d3401a9f08a7af28c026

Before merge

None.

Findings

None.

Agent review details

How this fits together

SQLite admission distributes physical database facts across handles and workers; schema readers consume those facts, while separate owners retain database authority, write custody, and durable lease renewal.

flowchart TD
  A[Doctor maintenance] --> B[Schema preparation]
  A --> C[Heartbeat worker]
  B --> D[Physical schema cache]
  C --> D
  D --> E[SQLite catalog]
  D --> F[Parent admission registry]
  C --> G[Durable lease row]
Loading

Technical review

Best possible solution:

Keep physical recapture in the existing schema owner, preserve synchronous authority exchanges, and settle committed cache publication at readiness and explicit repair boundaries.

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

Current-main cache misses and publications can enter a synchronous parent exchange during heartbeat renewal; the supplied regression exercises that path with real workers and SQLite, but no target code was run during this review.

Is this the best way to solve the issue?

The patch addresses the dependency at the shared owner without extending leases or weakening renewal predicates, and its added readiness state prevents deferred sharing from losing initial and repaired catalog handoffs.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Shared physical admission exchanges changes intended behavior with a stated reason (bb7d32e: Share completed physical validation across workers and reopens while preserving identity and authority checks.)
  • Ordered admission publication keeps the original intent (b2c4d5f: Exchange ordered deltas instead of repeatedly serializing complete admission maps, resetting the cursor after delivery failure.)
  • Physical encoding cache keeps the original intent (e550cd4: Reuse immutable encoding after the first schema object exists; the moved regression retains the empty-database exception.)
  • Agent schema refresh keeps the original intent (1e2d50c: Refresh through the selected engine with canonical validation and existing authority checks; this patch preserves the PostgreSQL branch and publishes SQLite facts after the pin.)
  • Both-host CI routing keeps the original intent (b0e65d7: Retain Bun coverage while adding Node-host coverage through the shared planner; this patch extends the existing cohort.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Current-main dependency remains: Fetched main still publishes physical facts through an unconditional parent exchange, and its schema and encoding keys lack the connection-local classification. (src/infra/sqlite-database-admission.ts:484, 23376e5f0a26)
  • Narrow cache and authority separation: Only schema and encoding keys become connection-owned caches; host-owned lookups, publisher restrictions, retirement checks, schema revisions, and scoped-write exchanges retain their existing behavior. (src/infra/sqlite-database-admission-read.ts:120, 61bc7a451fa7)
  • Readiness and repair publication: Initial admission settles committed publication once per connection; transaction-local and pinned facts cannot complete readiness, and repaired agent catalogs publish after the validation pin ends. (src/infra/sqlite-schema-facts.ts:656, 61bc7a451fa7)
  • Real-worker regression coverage: The regression starts the production heartbeat worker, observes its real admission port, blocks the parent, and checks persisted heartbeat advancement beyond two original lease lifetimes with provenance both present and lazily prepared. (src/state/openclaw-agent-db-maintenance.schema-renewal.test.ts:91, 61bc7a451fa7)
  • Supplied proof and inspection limit: GitHub confirms the linked maintenance and readiness jobs succeeded at the reviewed head. The PR records Node/Bun results and an unpatched baseline; log downloads redirect to blocked Azure storage, so their printed observations could not be independently inspected. (61bc7a451fa7)
  • Current CI: The reviewed head has no reported failing checks; PostgreSQL conformance and build-artifacts remain in progress, and the aggregate CI gate remains pending. (61bc7a451fa7)

Likely related people:

  • Dallin Romney: Raw commit 35d2e97 adds src/infra/sqlite-database-admission-context.ts:47 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 35d2e97a4af7; files: src/infra/sqlite-database-admission-context.ts)
  • Vincent Koc: Raw commit 04681a3 adds src/infra/sqlite-database-admission.ts:151 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 04681a3efcb1; files: src/infra/sqlite-database-admission.ts)

PR surface

Source +63, Tests +442, Other +8. Total +513 across 15 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 8 92 29 +63
Tests 5 457 15 +442
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 10 2 +8
Total 15 559 46 +513

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +92/-29; tests +456/-15 Growth supports the cache ownership distinction, readiness publication, and distinct renewal, rollback, snapshot, encoding, and acknowledgement regressions.

Labels

Label changes:

  • add P2: A focused maintenance reliability repair prevents durable lease expiry after supported schema preparation; broader incident attribution remains unproven.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A focused maintenance reliability repair prevents durable lease expiry after supported schema preparation; broader incident attribution remains unproven.
  • 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.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

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

Reviewed October 30, 2026, 11:13 AM ET / 15:13 UTC.

@vincentkoc
vincentkoc enabled auto-merge (squash) October 30, 2026 15:22
@vincentkoc
vincentkoc merged commit ba6cfcd into main Oct 30, 2026
183 checks passed
@vincentkoc
vincentkoc deleted the investigate/lease-schema-renewal-20261030 branch October 30, 2026 15:24
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…law#188391)

* chore(state): investigate maintenance lease renewal after schema preparation

* test(state): cover maintenance renewal on both host runtimes

* fix(state): decouple physical schema facts from parent exchanges

* fix(state): publish schema facts at readiness handoffs
tideclaw-bot added a commit that referenced this pull request Nov 5, 2026
Backport accepted fixes onto 2026.11.5-beta.2.

Base: bc061f9
Canonical source tree before commit: e6c0c39

These are adapted/squashed backports; do not claim each is an exact Git cherry-pick.
Source provenance (selected verified commits; other cohorts use their frozen patch/adoption manifests):

runtime-B:
b20a0cc fix(macos): connect with configured credentials despite stale app environment (#191468)
c4c0942 fix(update): failed updates from 10.7–10.9 crash in automatic migration recovery (#189713)
6aae408 fix(update): preserve recovery errors and async triage callbacks (#191495)
8910654 fix(macos): prevent first-launch Gateway failures after upgrades (#191436)
00b2ff4 fix: parent sessions miss child approvals with a custom session store (#189827)
c6142a8 fix: avoid copying managed plugin binaries during Gateway startup (#187865)
e72b356 fix(anthropic): avoid token profile collisions (#187875)
807075d fix(anthropic): set API workspace at login (#186976)
bafe92f fix(exec): preserve no-timeout results from macOS app nodes (#190729)
9b05a64 fix(imessage): use a PostgreSQL-safe recovery cursor key (#184919)
6ba197f fix: session search on PostgreSQL scans every transcript row instead of using the text index (#187909)
4f49aa5 fix(sessions): PostgreSQL session search scans every transcript row again after the 5th search on a connection (#188979)
de3936c fix(macos): Mac tab shows a blank or stale page when a load fails (#185432)
e977080 fix(macos): prevent duplicate voice sends and false sent feedback (#186271)

provider-compaction:
1b43c2e fix(compaction): preserve active request provenance (#180214)
7b0cfe3 fix(google): restore tool calls with Python keyword parameters (#191561)
9039ceb fix(ci): keep compaction attribution helpers internal
d6a1327 feat(google): use the Interactions API for Gemini Flash models (#189395)
fe0f8d1 fix(google): Gemini models ignore configured topP (#190695)

history:
c51d733 fix(sessions): stop expanding archive reads from exhausting memory (#190690)
3c8bd4d fix(sessions): page oversized earlier history instead of failing at 8 MiB (#188450)
b195f61 fix(sessions): page oversized transcript history in both directions (#188483)
b65482e fix(gateway): preserve older history across hidden message gaps (#188557)
3d4fc94 fix(sessions): avoid oversized listing and imported-history reads (#189284)
33e7baf fix(sessions): bound active accounting without blocking writers (#190182)
682ade7 fix: preserve chat history continuation metadata (#188612)

runtime-C:
7e005b0 fix(macos): keep secrets when a Gateway config save fails (#187734)
15cf738 fix(macos): keep Gateway auth when Tailscale exposure is turned off (#187664)
b53a06b perf(update): read candidate state inventory without copying the shared database (#187921)
970fc4e fix: restore CLI message sends with agent tool policies (#188058)
73ad731 fix: stop model fallback when session capability metadata changes (#179312)
32305db fix: subagent turns fail after session metadata changes (#183501)
d13bd0f fix(codex): include relay conversation instructions in trajectory (#189005)
e375530 fix: replies after a plugin reload from Control UI go to the session's last external chat (#190982)
9346376 fix: reasoning-only retry is refused by Anthropic as reasoning_extraction (#184434)

direct-auth-state:
1b15408 fix(models): keep the model list when one plugin-owned provider lacks a credential (#189014)
7d8dc60 fix: recover startup migration with retained worker index (#189023)

capacity:
41772e3 fix(worktrees): settle completed disk debt on refused postchecks (#188727)

command-once-189369:
8269137 fix(plugins): plugin commands that continue the agent run three times on native command turns (#189369)

pg-board-189564:
7232a8d fix(boards): publish widgets with PostgreSQL storage (#189564)

queued-edit-189869:
92b32ca fix: hold queued messages through inline edits (#189869)

Preserve source attribution from original commits. For a genuinely exact individual pick only, use the conventional (cherry picked from commit <sha>) line.
Full file-level provenance: coverage-manifest.json; reviewed patch hashes: artifact-registry.json.
No held136/native82 content adopted by this work. No release or full-candidate qualification claim.

Additional original-source identities (exact adapted hunk scope is in frozen artifacts):
release-guides-185258: 39c37e6 docs(release): define ledger-first hotfix routing (#185258)
UI-history: 10a6e4f fix(ui): scope provider-add discovery warning to its own provider (#188541), 3d7b4c4 fix(ui): never fail loading earlier chat history without a boundary (#188372)
obsolete-cache-188203: 90d82c2 fix: preserve completed reasoning and refill chat snapshots (#188203)
webhook-169778: b1f643f fix(startup): keep webhook decisions startup recorded for channels Doctor left pending (#169778)
schema-lease-188391: ba6cfcd fix(state): keep lease renewal independent of parent admission (#188391)
backfill-188976: c75a8a8 fix(gateway): stop session row backfill once the Gateway is closing (#188976)
canonical-disable-188846: 88b56ee fix(config): auto-enable reads and writes mixed-case plugin policy under the canonical id (#188846)
matrix-177272: 5a6d22c fix(matrix): stop seeding new thread sessions from the room transcript (#177272)
provider-hook-189059: 0588f51 fix(models): isolate every per-provider catalog failure (#189059)
unicode-189868: 87396e7 fix(oc-path): avoid reading and editing a different Unicode key (#189868)
replay-cohort: 2031044 fix(sessions): acknowledge committed input retries without duplicate turns (#188527), 9114431 fix: resume configured fallback after interrupted attempts (#188672)

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

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L 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