Skip to content

fix: settle native workers in Gateway shutdown ownership order - #188496

Merged
steipete merged 3 commits into
mainfrom
codex/stop-native-worker-lifetimes
Oct 30, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/stop-native-worker-lifetimes

Conversation

@steipete

@steipete steipete commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Gateway stop retaining unfinished native snapshot reads and retiring shared-state actors before their resource leases settle.

User Impact

Stopping the Gateway cancels disposable snapshot reads and preserves resource and write settlement. Global broker retirement joins canonical shared-state cleanup, whose admission fence refuses fresh leases. Deadlines, configuration, persisted formats, and exit-status policy are unchanged.

Why This Change Was Made

The native-lifetime singleton joins domain owners before the supervisor and broker. Snapshot staging closed admission but awaited its read requests without requesting cancellation. It now sends the existing cancellation message before joining native cleanup; directory allocation still settles normally.

Shared-state retirement also had competing paths: the worker owner closed both as an ordinary database resource and as a separate singleton, while the generic broker independently sealed its clients. The canonical database close now owns resource ordering: shared actors use its existing after-resources phase, the duplicate worker reset is removed, and the broker seals fresh dispatch immediately and joins canonical close before retiring shared actor bindings and native transports. Accepted leases retain their binding until their registered resource releases them; fresh database admission is sealed throughout close. Canonical state client release avoids waiting on the host join that is itself waiting for resource release. Failed cleanup retains broker maps for retry instead of clearing custody.

Follow-up: outer server-close tracking needs a coherent sibling-module extraction of run-loop.ts. Its existing runWithProcessCleanupBudget wrapper propagates the monotonic shutdown deadline through async-local storage to server and service-child cleanup; replacing it with measurement would lose that contract. Adding measurement alongside it grew an already over-cap file from 1273 to 1275 counted lines (cap 700), so the coordinator-directed narrower fix drops that tracking change and its regression. The existing deadlines, coverage, and caps remain intact; pending close steps can still say none while that outer await is held.

The plugin-runtime diagnostic can wrap a later global-singleton timeout; it does not identify a leaking plugin. The first journal also records a separate required session-persistence failure, owned by #188402. The second journal's printed exitCode=0 is an intended outcome, not process exit: retained cleanup and the process lifeline still keep the loop alive, and the hard watchdog can kill it. This PR preserves accepted-write settlement instead of forcing process.exit. The supplied journal cannot uniquely identify every live lease holder or attribute all 73 seconds to snapshot staging.

The existing PluginRuntimeCloseRetainedError classification can treat nested cleanup rejection as retained. Whether to distinguish genuine rejected cleanup from grace-only leftovers is a separate coordinator product decision; this PR leaves that exit-status policy unchanged.

Evidence

Final head e9bd78d6bb174f7c8ff947f3e1207e4040810c4f: exact-head CI run41095810616 completed successfully. The exact-head watcher returned GREEN with zero pending checks; both required openclaw/ci-gate rows are SUCCESS. Raw rollup retains superseded aliases, which the watcher excludes. No failed job is attributable to the final head.

  • Snapshot shutdown regression: red on base 24fa8e7 under Node and pinned Bun (10-second timeout); green with the fix. Three targeted suites pass: 35 tests per runtime.
  • Shared-state native regression: red under both runtimes because global retirement seals the retained actor binding before its resource releases its lease; green with the fix. Fresh state admission is refused during the held close.
  • Six affected ownership/cleanup suites: 52 tests pass under each runtime, including accepted native commit plus queued follower, lease terminal writes, policy refusal, idle actor reuse, failure cleanup, and maintenance admission.
  • Isolated real-SIGTERM native-read process probe: base needs the probe's external safety abort (Node 1622 ms, Bun 1548 ms); fixed cleanup completes without it (Node 141 ms, Bun 53 ms), exits 0, joins native workers, and preserves committed source bytes. Stop budgets are unchanged. No live Gateway, real user state, or model/channel round trip was used.
  • Existing accepted-preference-write drain test passes under both runtimes; existing fatal-vs-retained shutdown tests and real-signal process tests pass under Node.
  • After narrowing scope, the combined shared-state/expanded contracts/snapshot run passes all 87 tests under Node and pinned Bun. Targeted state typecheck, lint, formatting, git diff --check, and all baseline ratchets pass. Database T1 calls stay 168→168; max-lines keeps 402 grandfathered suppressions; test lines are 6,300,992 against ceiling 6,312,680; all other baseline checks pass. The line-cap gate passes against origin/main; run-loop.ts and its tests have no PR delta.
  • Fresh local Codex autoreview of the candidate against the base, with full affected owners: scoped clean at P0–P2, no actionable findings. Full affected owners and lifecycle contracts were supplied; coordinator review still owns landing.
  • Simplification: existing cancellation and database resource phases, one authoritative state close, duplicate singleton reset removed. The native retirement case replaces raw-reader-only coverage and runs in the existing host-process settlement suite; unnecessary owner-test mocks are removed. Whole PR: 11 files, production +27 lines, tests -4 lines, docs +5 lines (net +28). The additional broker lines keep its admission fence synchronous while ordering native retirement after canonical resource cleanup. No new timer, manager, fallback, compatibility path, or budget increase.

Exact-head CI on 2194bb8 exposed three attributable failures, repaired in the follow-up commit: checks-node-changed-compact-large-16 (partial input staging on global close timed out), checks-node-changed-compact-small-9 (capacity waiters slipped through drain), and checks-node-compact-small-2 (one-shot fixture resource was closed twice by sequential canonical/broker drains). The broker now starts its existing admission fence before awaiting canonical close; the fixture unregisters only after successful cleanup, keeping all count and ordering assertions. These were PR regressions, not inherited failures. The failed files plus all affected owner and snapshot suites now pass: 12 files / 117 tests under each runtime (32 unit, 1 tooling, 84 native/process). Targeted state/tooling typechecks and all ratchets also pass. No rerun-only CI recovery was used.

A full Node run-loop run passed 155 tests and failed seven: six managed-package setup cases reported “No safe OpenClaw temp root is available”; a later restart-upgrade case timed out with a retained signal owner. The exact failed group reproduces all seven failures and the same signal-owner error with the four affected production owners taken byte-for-byte from main 2eef065f0f89960d0aaebfc64647386715cc9abe (7 failed, 1 passed, 154 skipped). The isolated restart-upgrade case passes on the candidate. These local failures are inherited; no policy or environment guard was bypassed.

Focused commands and incident evidence
# Run each runtime separately with RUNTIME=node and RUNTIME=bun:
OPENCLAW_VITEST_RUNTIME=$RUNTIME node scripts/run-vitest.mjs src/infra/sqlite-readonly-worker.test.ts --maxWorkers=1 -t 'shutdown cancellation'
OPENCLAW_VITEST_RUNTIME=$RUNTIME node scripts/run-vitest.mjs src/state/openclaw-state.worker.settlement.test.ts --maxWorkers=1 -t 'joins shared-state leases'

OPENCLAW_VITEST_RUNTIME=$RUNTIME node scripts/run-vitest.mjs src/state/openclaw-state.worker.settlement.test.ts src/state/openclaw-state-db-async-lifecycle.test.ts src/state/openclaw-state-worker-lease.test.ts src/state/worker-policy-regression-owner.test.ts src/infra/sqlite-worker-shared-state-idle.test.ts src/infra/sqlite-worker-lifecycle-cleanup.test.ts src/infra/sqlite-readonly-worker.test.ts src/infra/sqlite-snapshot-staging-owner.test.ts src/infra/sqlite-snapshot-staging-runtime.test.ts src/infra/sqlite-worker-broker.test.ts src/infra/sqlite-worker-input.test.ts test/non-isolated-runner.sqlite.test.ts --maxWorkers=1
# Final repair: 12 files, 117 tests pass under each runtime (32 unit + 1 tooling + 84 native/process).

node scripts/run-tsgo.mjs --project test/tsconfig/tsconfig.core.test.state-logging.json --incremental
node scripts/run-tsgo.mjs --project test/tsconfig/tsconfig.test.root.tooling.json --incremental
pnpm check:baseline-ratchets --base origin/main
pnpm check:line-cap-ratchet --base origin/main

Supplied production journal, 2026-10-30 UTC, release 5ed4aa23:

15:24:42.447 shutdown budget at shutdown: drain=74968ms shutdown=84968ms reserve=10000ms exitMargin=5000ms
15:24:51.296 shutdown step restart.close.process-supervisor settled after 5021ms
15:24:54.317 shutdown step restart.close.plugin-metadata / plugin-registry settled after ~8597ms
15:24:54.318 shutdown step failed (gateway close): Gateway resource cleanup failed | Plugin runtime still owns resources; inspect cleanup failures before retrying Gateway close. | Shutdown session persistence did not settle within 1000ms | global-singletons resources remain after grace
15:24:55 to 15:26:00 shutdown pending: restart.close.global-singleton.openclaw.nativeWorkerLifetimes=<growing>ms (every 5 s)
15:26:04.312 restart.close.global-singleton.openclaw.nativeWorkerLifetimes settled after 72999ms
15:26:07 systemd: Main process exited, code=exited, status=1/FAILURE

Additional supplied journal, 2026-10-30 UTC, old release 3c8bd4d, deployment to 562772b:

16:00:49.219 shutdown budget: drain=74978ms shutdown=84978ms
16:00:54.527 restart.close.session-admissions settled after 4996ms
16:00:54.879 shutdown.received-connection-work settled after 5159ms
16:01:04–16:01:51 repeated: Shared-state worker is retiring while its actor is in use; close its leases first
Sources: audit/events persistence; Discord ingress drain/handler; usage-cost-cache (PLUGIN_STATE_OPEN_FAILED); memory-core dreaming cron reconcile
16:01:11.684 agent DB clean-close receipt: written
16:02:14.206 shutdown deadline reached before external-restart; pending close steps: none; cleanup incomplete; exitCode=0 (stability bundle written)
16:02:16.196 hard-exit watchdog deadline reached; pending close steps: none; forcing SIGKILL
16:02:21 systemd: stop-sigterm timed out, SIGKILL; status=9/KILL. Memory peak 121.1G.
No gateway close failure line; nothing resumed after restart.

Cancel pending native snapshot preparations before joining their owner at stop. Keep directory allocation, cleanup, native exit, and accepted write settlement with their existing owners.
@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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T17:08:40.770504Z e9bd78d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Oct 30, 2026
@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 cancels unfinished native SQLite snapshot preparations before shutdown joins their cleanup.

Example: Gateway shutdown begins while a native snapshot copy is stalled.

  • Before: Shutdown waits for the read deadline or a separate caller abort.
  • After: Shutdown requests cancellation and joins the existing native cleanup.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused, correct repair with meaningful owning-boundary regression coverage; supplied proof remains a process harness rather than a shipped-entry-point demonstration.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its body reports a real-SIGTERM runGatewayLoop probe with a gated native child, completed cleanup, joined workers, and preserved source bytes under Node and pinned Bun.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Stopping the Gateway can wait on a disposable native snapshot read after admission has closed.
Reason: The maintainer-authored change repairs a verified shutdown path while preserving existing settlement guarantees and the earlier simplification direction.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR fixes a concrete shutdown blocking path still present on current main, with no actionable patch defects found.

Priority: P2
Reviewed head: 88b84de4e2d81554dde2d8186c3da670d57fd584

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied process/owner probe does not demonstrate shutdown through the shipped Gateway CLI.
Agent review details

How this fits together

The snapshot staging owner accepts read preparations and directory allocations, delegates native work, and retains cleanup until requests and temporary directories settle.

flowchart TD
  A[Gateway shutdown] --> B[Native lifetime owner]
  B --> C[Snapshot staging owner]
  C --> D[Cancel pending preparations]
  D --> E[Native copy child]
  E --> F[Join directory cleanup]
  F --> B
Loading

Technical review

Best possible solution:

Cancel pending disposable preparations through the existing staging owner, then retain normal allocation, cleanup, and accepted-write settlement.

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

The current-main shutdown join and existing cancellation channel establish the blocking path, supported by the supplied base-failing native regression; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch is the smallest complete repair: it requests cancellation before joining and adds no timer, fallback, competing lifecycle owner, or persisted state.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Snapshot shutdown join keeps the original intent (9c93bc3: Retain snapshot preparation and native cleanup custody through worker failures.)
  • Lifecycle simplification keeps the original intent (19fe879: Replace synthetic recovery graphs with ordinary owner settlement and explicit best-effort tradeoffs.)
  • Native cancellation regression keeps the original intent (76894b3: Ensure cancellation retires the original owner-allocated snapshot without modifying the source database.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +10, Tests -1, Docs +3. Total +12 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 10 0 +10
Tests 1 30 31 -1
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 43 31 +12

Labels

Label changes:

  • add P2: A stalled disposable snapshot can delay Gateway shutdown, with limited scope and no demonstrated loss of accepted writes.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A stalled disposable snapshot can delay Gateway shutdown, with limited scope and no demonstrated loss of accepted writes.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • 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, 12:09 PM ET / 16:09 UTC.

Use canonical database resource phases and join state close before broker retirement. Remove the competing singleton reset; preserve accepted writes and existing shutdown deadlines.
@steipete steipete changed the title fix: Gateway stop waits on unfinished native snapshot reads fix: settle native workers in Gateway shutdown ownership order Oct 30, 2026
Keep accepted state lease bindings until canonical resources finish without admitting generic work during drain. Avoid the state-client host-join cycle and retain broker custody on failed cleanup. Unregister the completed one-shot runner fixture resource.
@steipete
steipete merged commit 83064b3 into main Oct 30, 2026
139 of 143 checks passed
@steipete
steipete deleted the codex/stop-native-worker-lifetimes branch October 30, 2026 17:43
RomneyDa added a commit that referenced this pull request Oct 30, 2026
* fix(release): drain shared-state leases before retirement

Adapt merged main PR #188496 to the frozen stable broker API. Cancel disposable snapshot reads, fence fresh broker admission, and let canonical shared-state cleanup release accepted leases before retiring actor bindings.

(cherry picked from commit 83064b3)

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

* fix(release): restore SQLite build boundary

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

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: roboclaw-bot <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…ared-state leases (openclaw#188496)

Two Team Gateway stops on 2026-10-30 ran to their deadline: at 15:24Z restart.close.global-singleton.openclaw.nativeWorkerLifetimes held 73 s, and at 16:00Z the close stalled with "Shared-state worker is retiring while its actor is in use" until the hard-exit watchdog and systemd SIGKILLed it, which then cost a 111 s database recovery on startup.

Snapshot staging shutdown now sends its existing abort to pending native snapshot reads before joining them. Shared-state actor retirement moves into the database lifecycle's after-resources phase so registered resources release their leases first, the competing worker singleton reset is removed, and broker retirement joins canonical state close. Accepted writes and native cleanup still join; no deadlines changed. Close-step tracking for the outer server.close await is a follow-up that needs a run-loop.ts extraction.
@ChristianMoesl

ChristianMoesl commented Nov 14, 2026 •

Copy link
Copy Markdown

Is there a maintained published release/backport containing the snapshot-abort and shared-state-owner ordering changes from this PR? I checked the official npm [email protected] archive (registry integrity verified): dist/build-info.json names c0f42f6; the distributed sqlite-snapshot-staging-owner-CqW9sTZt.mjs still joins active preparations without preparation.abort(), and the shared-state owner/broker copies lack the after-resources/beforeSharedStateClose changes. This is executable-artifact inspection, not an inference from merge/publication dates. Current npm tags still point to beta2/latest2026.11.3/extended-stable2026.9.37.

We have a long-lived Gateway whose external native-service SIGTERM stop can exceed 330s despite settled inner cleanup logs. I am NOT claiming this PR conclusively explains it: an isolated official-core agent/model/state-worker fixture exits naturally, and Matrix/plugin/long-lived combinations remain under investigation. We are preserving state and update safeguards, not hotpatching or downgrading. A supported published repair target or documented lifecycle workaround would help safely resolve the blocked maintenance path. I also noted the final PR explicitly dropped outer-close observability, so pending-close-steps:none is not being treated as exit proof. Thank you.

Nov15 update (public executable artifacts only, no production upgrade): npm now offers core/Matrix2026.11.5-beta.3. Its core tarball passes registry SHA512 integrity; build-info commitc2f4dde2638502fe506e234fb43ac65d8c391072/built2026-11-14T13:59:26.056Z. Manually reading the minified MAIN sqlite-snapshot-staging-owner-aKjz9yAN.mjs, the preparation record still lacks an abort operation and its retained disposer sets closing then joins pending results BEFORE cleanup. Main worker ownerUI8dGdFx and brokerCukTnBL0 remain phase shared-state; the relay bundle has after-resources machinery, which does not establish that main has it. Literal identifier grep alone would be insufficient after minification. Other beta3 final-chat/delivery/memory fixes may still matter; this is not a claim that every possible remedy is absent, or that snapshot disposal conclusively causes our hang. Deployed core remains beta2, safeguards unchanged. Is there a maintained release target or supported live-owner diagnostic/workaround for this main-process ordering path?

Nov15 operational discriminator (same beta2, no upgrade/hotpatch): a documented exact-target committed suspension handoff was acknowledged ready/activeCount0 then committed. It passed an identity-free real-systemd fixture with shipped persistent TUI, anonymous loopback model turn, materialized state/workboard and official OTel exporter. On the long-lived real instance, however, the FIRST specific failed span now observed is metadata-retirement: resources remain after its5s grace (5031ms measured rejection, not successful late completion). plugin-metadata/registry reject afterwards; shutdown reports failed in9305ms and skips later close work. While still alive, the kernel reports83FDs/17threads/6worker threads, including two deleted read-only snapshot database+owner pairs and a deleted memory-reindex file. The existing330s native service bound ultimately ended withSIGKILL. We are not treating this as clean exit. Full account/WAL preservation plus native guard inspection allowed safe same-identity recovery; containment remains.

A separate identity-free UNIT experiment executes the exact published createStagingOwner function (module SHA256451b7e5050cbbbdf408dea3a193b9a432c5ba882d22530fb03b6823e6c9611a1), with a pending-worker test double that responds to its real MessageChannel abort. Unmodified beta2 retained disposal emits zero aborts and cannot finish until the test externally completes the request. A TEST-ONLY counterfactual retaining preparation.abort and invoking it BEFORE joining active results emits one abort and finishes disposal/pool close without external completion. Installed artifacts are unchanged. This confirms the cancellation dependency in that function, NOT which pending preparation caused the real metadata-retirement failure and NOT a deployed fix.

Can a maintained main-process release/backport or supported owner diagnostic be identified for this resource-retirement path? We will not repeat a production stop merely to obtain another330s failure. I can provide the small credential-free unit harness if useful; no crypto identity or state dump is required.

steipete added a commit that referenced this pull request Nov 17, 2026
…es (#200330)

* fix(gateway): preserve clean exit while releasing retained state leases

Keep cleanup-worker admission open until canonical state lease finalizers finish, while sealing ordinary clients and canceling queued writes immediately. Then close the SQLite host and clear its successful retirement bookkeeping.

The retained-lease singleton regression is red on the base; 73 focused tests pass with the fix. A synthetic owner process reproduces exit 1 on the base and 4bce760, and exit 0 with the fix. The current faulty callback ordering comes from 83064b3 (#188496), before the reported release range. Production delta: +3 lines. Codex autoreview: scoped-clean at P0-P2.

* style(perf): brace the shutdown measurement abort wait
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 17, 2026
…es (openclaw#200330)

* fix(gateway): preserve clean exit while releasing retained state leases

Keep cleanup-worker admission open until canonical state lease finalizers finish, while sealing ordinary clients and canceling queued writes immediately. Then close the SQLite host and clear its successful retirement bookkeeping.

The retained-lease singleton regression is red on the base; 73 focused tests pass with the fix. A synthetic owner process reproduces exit 1 on the base and 6199e71, and exit 0 with the fix. The current faulty callback ordering comes from 4807fa9 (openclaw#188496), before the reported release range. Production delta: +3 lines. Codex autoreview: scoped-clean at P0-P2.

* style(perf): brace the shutdown measurement abort wait
RomneyDa added a commit that referenced this pull request Nov 17, 2026
)

Backport 83064b3.
Keep accepted writes and native cleanup joined; retire the shared actor only
after registered resources release their leases.

Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
…es (#200330)

Backport f5d74a5 after #188496. Keep cleanup-worker admission open until retained state lease finalizers finish, then drain the host and discard successful retirement bookkeeping.

Regression first: singleton close failed with SQLite worker host is closing, while database close passed. Fixed selected lease, capacity, queued-write, and cleanup checks: 6 passed. Format, staged test-line ratchet, and diff checks passed. Lint/typecheck blocked by linked dependency declaration boundaries.

Co-authored-by: RomneyDa <[email protected]>
RomneyDa pushed a commit that referenced this pull request Nov 19, 2026
…es (#200330)

* fix(gateway): preserve clean exit while releasing retained state leases

Keep cleanup-worker admission open until canonical state lease finalizers finish, while sealing ordinary clients and canceling queued writes immediately. Then close the SQLite host and clear its successful retirement bookkeeping.

The retained-lease singleton regression is red on the base; 73 focused tests pass with the fix. A synthetic owner process reproduces exit 1 on the base and 4bce760, and exit 0 with the fix. The current faulty callback ordering comes from 83064b3 (#188496), before the reported release range. Production delta: +3 lines. Codex autoreview: scoped-clean at P0-P2.

* style(perf): brace the shutdown measurement abort wait

(cherry picked from commit f5d74a5)

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

Release adaptation: none; source change applies to the pinned beta baseline.

Follow-up disposition: bounded pinned-main same-path audit recorded in the lane report; cross-lane changes remain parent-owned.

(cherry picked from commit afe57940d76947a5931805bce036549abbb6491e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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.

2 participants