Skip to content

fix: avoid state database clone stalls during Gateway startup - #190918

Merged
steipete merged 4 commits into
mainfrom
steipete/perf-micro-state-db-snapshot-clone-lifecycle-20260919
Nov 2, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/perf-micro-state-db-snapshot-clone-lifecycle-20260919

Conversation

@steipete

@steipete steipete commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway startup and state reads can create multi-GiB database copies, while periodic cleanup frees old clones through one large unlink. Both operations can stall serving traffic on extent-heavy filesystems.

User Impact

Normal Gateway startup, its ownership checks, and serving RPC reads use live read-only SQLite transactions. Crash restart on DELETE-journal filesystems still recovers automatically: only startup may take one private copy after SQLite actually requires hot-journal recovery. The exception is logged and its copy is removed before admission continues. No schema change, configuration option, or new cache.

The Gateway legacy-cache sweep is removed. Abandoned historical copies require explicit offline maintenance; no blanket Doctor sweep is introduced because the cache spans independently owned state directories. Active private copies receive bounded cleanup. Bounded truncation does not guarantee bounded later btrfs transaction latency.

Why This Change Was Made

Offline inspection protects exact database/WAL/SHM bytes and permits private recovery before ownership checks. Runtime consistency needs a live SQLite read transaction. This change separates source selection from inspection side-effect policy, preserving ownership, cancellation, publication safeguards, and Doctor/update artifact preservation.

For a hot rollback journal, startup inspects private ownership, passes config/live-owner guards, revalidates original main/journal fingerprints under existing schema custody, and lets SQLite recover the canonical database. Generic live readers cannot opt into this exception. Closed-WAL agent inspection also follows the live policy: SQLite may create empty coordination files while full integrity, foreign-key, ownership, and schema checks remain in the isolated read transaction. Offline and partial WAL/recovery families retain their preservation policy.

Producer custody lasts through reply delivery; surviving owners drain interrupted creation. The native staging lock is released before publication so an already-informed caller can retire immediately, even while the send callback is pending. Async cleanup truncates through the same retained descriptor. Graceful CLI draining incorporates @Frosmans's work from #178730, with co-author credit.

Evidence

Reviewed head: c18f1c86258db021831a8400d4114a977921527c, source comparison parent d9627ecb437b2a0fdaa2215137b291dbbc806137. The PR is ready; the lead accepted the exact-main inherited CI exception below. All measurement runs are complete.

Five serialized A/B pairs used synthetic state of 12.919 GB, a 37.681 GB agent DB, eight agents, 10,000 sessions, and 62,000 workspace files / 1.181 GB. Every baseline published 18 files / 153,969,655,960 logical bytes, including nine state and eight agent images. Every candidate created zero files and zero copied bytes. All ten first RPCs succeeded on their first attempt; all runs stopped without forced exit.

Metric Baseline median Candidate median Change
Ready 114.566 s 100.898 s −11.93%
First sessions reply from spawn 79.757 s 60.403 s −24.27%
Actual first RPC round trip 3.549 s 3.205 s −9.69%
Endpoint live-tree CPU 76.550 s 69.220 s −9.58%
Sampled Gateway-process peak RSS 2312.4 MiB 2167.5 MiB −6.27%
Shutdown 0.930 s 2.096 s +1.166 s

Pair 3 was slower and remains included. First-reply ranges are 75.355–85.639 s versus 45.319–85.764 s; with n=5, nearest-rank p95 is the sample maximum, not a production tail estimate. Two earlier A/A controls showed readiness 117.436/95.651 s and CPU 65.54/64.54 s; they describe their earlier time window, not concurrent controls. Measurements used Node 26.12.1 / SQLite 3.54.1 on local APFS under shared-host load, not production btrfs/RAID. CPU excludes already-exited children; RSS covers the Gateway process only.

The original +16.3% first-reply regression was real. It exposed synchronous cleanup in the RPC window and then an awaited 35 GiB agent-copy retirement costing 57.825 s through 561 async truncations. Moving cleanup off-thread did not remove that admission delay; deleting the unnecessary closed-WAL fallback did. Old slower cohorts remain retained. The fresh profile retains a slower state-admission integrity phase: 2.588 s on the baseline parent/private source versus 23.674 s on the candidate child/live source, while separate existing schema-maintenance integrity samples are 4.504→4.864 s. These are sampled wall times. Earlier same-inode cold/warm controls explain the lost bulk-read preparation from copy/coherence comparison; full startup and first-reply medians still improve with integrity checks retained. The final CPU pair records zero sync/async truncation calls across the candidate lifecycle and agent-inspector requests 16→8. Targeted schema-child profiles exist, but three short-lived integrity-worker profiles are missing across the pair; complete process-tree CPU coverage is not claimed. Shutdown logs identify the unchanged cron-maintenance owner awaiting its task scope and scheduled sweep. The diagnostic candidate stop is mostly main-thread idle (2.120 of 2.488 s), with no clone to delete. Why that sweep remains pending more often is unresolved; the 1.166 s median increase is retained, not labeled noise. First-RPC profiles show the same module loading, plugin-worker joins, filesystem admission, and SQL work, with the old synchronous-truncation hotspot absent. Chronological heap A/B/A samples were 3,895,363,704 / 3,913,751,856 / 3,849,312,272 main-thread V8 bytes. Baseline A/A is −1.18%; candidate is +0.47% versus the first baseline and +1.67% versus the later one. These descriptive samples establish neither an allocation improvement nor equivalence; native/other-process allocations are excluded. The final local btrfs probe passed on 35 GiB logical / 2.1875 GiB allocated / 573,440 extents: whole unlink 877.322 ms; async owner 559 truncations, zero sync truncations, maximum callback 3.903 ms, final 64 MiB removal 3.756 ms. Total cleanup 878.290→938.031 ms; CPU 867.477→404.374 ms. Direct-cleanup A/A was 900.140/851.763 ms. This does not bound delayed-reference transaction commits. Task-owned probe resources were cleaned up. All measurement runs and task-owned probe cleanup completed.

Focused proof includes 328 consumer tests and 58 affected-boundary tests, followed by 27 infra cases, 13 startup-integrity cases, and the exact seven previously failing Doctor cases plus six hot-journal controls. Regression proof covers concurrent writers, external ownership, source changes, hot-journal recovery, creator exit, real delayed-send handoff, CLI drain, and bounded async deletion. The new closed-WAL case fails before the fix on attempted copy creation and still rejects a corrupted foreign key afterward.

A real isolated Gateway hot-restart smoke creates zero copies on healthy boot and exactly one logged 1,454,080-byte copy for a crash-created DELETE journal, removed by readiness; committed state is recovered. A packaged CLI burst produced four valid sessions.abort replies after an expected pre-listener refusal. All five observed CLI processes created zero copies on both baseline and the prior repaired source; the reported CLI-owned producer did not reproduce. Gateway state images fell 9→0, and observed processes and snapshot paths were gone after shutdown.

pnpm check:changed completed. All other gates passed after an owned test-variable shadowing error was mechanically renamed and targeted typed lint/formatting passed. Three unused plugin-hook exports reproduce on clean source parent d962 and originated in 71e516af03a11fb1e309ff4fd2a0b8dccee506da / #190906. This is a main regression; no full-command green is claimed.

CI 41441670232 on this exact head finished with 113 successful jobs, 23 skipped, and one failed Doctor process test plus its aggregate gate. Its tested main parent is 714490716002d24b939817366f277872b6ea2825. The Doctor child exceeds 30 seconds before Gateway startup. The same failure reproduces on that clean exact parent with Node 24.22.1; the unchanged matching-runtime candidate control passes. The test/deadline originated in 2a1402cd3e3914352820a24961087f1de0c736d9 / #151025, but the runtime slowdown introducer is not established. The lead explicitly waived the introducing-commit requirement for this landing on the strength of exact-main reproduction. No timeout is raised or waived in code.

Earlier CI found the staging-lock handoff defect and stale callback fixtures, repaired with causal red/green proof. A PostgreSQL test's global schema inventory raced sibling deletion; it now owns an isolated database and preserves the full orphan assertion with a sibling-deletion control. The old Docker root-help timeout remains unexplained historically but passed fresh exact-head CI. Earlier local fleet-preflight and Bun probe failures remain investigated uncertainties; unchanged passing replays are not claimed as fixes.

Independent Codex review covered the full PR through P2. Its native-close concern was rejected after source inspection and eight cross-process lock-survival controls: SQLite-managed connections preserved competing writer locks; deliberate raw descriptor closes broke them. The final repair received fresh scoped-clean P0–P2 review with complete lifecycle-owner context.

Runtime src/ delta is +106 LOC; tests −102 LOC; proof tooling +248 LOC separately. Guarded hot-journal recovery and producer-exit custody account for growth after deleting the serving reclaimer. Older-worker cancellation still needs retained layout/cutoff validation (#154937).

Related: #178730, #188009, #190875, #191054. Their remaining transfer-policy and Doctor recovery/async-only changes are separate; no duplicate closed-WAL fix was found.

Accepted inherited-red landing

Lead accepted inherited-red admin merge; fix tracked in lane 2119

Failing checks in run 41441670232, attempt 1: checks-node-changed-compact-large-1-1 (job 125265741642) and downstream openclaw/ci-gate (job 125275803641). The failing case is src/commands/doctor-config-preflight.process.test.ts → serves canonical state after Doctor repairs cron and preserves retired plugin sidecars.

Reproduction ran from a clean checkout of the exact CI main parent 714490716002d24b939817366f277872b6ea2825:

OPENCLAW_VITEST_RUNTIME=bun \
OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/Volumes/SF1-Storage/openclaw-lanes/lane2103-ci-doctor-parent-fs-cache \
node scripts/run-vitest.mjs src/commands/doctor-config-preflight.process.test.ts \
  --maxWorkers=1 \
  -t 'serves canonical state after Doctor repairs cron and preserves retired plugin sidecars' \
  > /Volumes/SF1-Storage/openclaw-lanes/lane2103-ci-doctor-process-parent.log 2>&1

Actual output excerpt (the timeout argv separately identifies the Doctor child as Node 24.22.1):

Caused by: Error: Managed command timed out after 30000ms
Serialized Error: { code: 'ETIMEDOUT' }
 Test Files  1 failed (1)
      Tests  1 failed | 19 skipped (20)
[test] failed 1 Vitest shard in 333.94s
[test] FAILED (exit 1)

The #190906 hook-export regression is separately proven inherited by the clean d962 production Knip reproduction and introducing commit 71e516af03a11fb1e309ff4fd2a0b8dccee506da; it is a local changed-check failure, not an additional failed job in this CI attempt. All these failures remain recorded, not relabeled green.

CLI incident coverage limit

The successful gateway call sessions.abort burst created zero CLI copies on both baseline and candidate. That is not causal proof that this PR eliminates the reported CLI leaks. The Gateway startup admission path is live and retained producers now have creator-exit cleanup, but the entire generic CLI gateway call bootstrap is not placed under the live-read policy. The reported unverifiable-owner/Doctor-held sessions.abort and sessions.list producer conditions were not reproduced. The general CLI never-clone guarantee is not completed by this PR; those incident producers need a separate targeted lane. No claim is made that ordinary successful burst coverage reproduces those failure conditions.

@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations size: L labels Nov 2, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment 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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 2, 2026
@clawsweeper

clawsweeper Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR replaces Gateway shared-state copies with live read transactions and retires temporary SQLite payloads in bounded steps.

Example: Start a Gateway with a synthetic 12 GiB shared-state database.

  • Before: The author reports nine shared-state snapshot copies during baseline startup.
  • After: The author reports zero shared-state copies, successful sessions.list, and graceful shutdown.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The performance direction is useful, but a concrete source-authority regression blocks merge and its final-response boundary is unproven.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Large shared-state copies delay Gateway startup and temporary-copy cleanup can stall on copy-on-write filesystems.
Reason: Eliminating unnecessary full-database copies has clear value, and the maintainer-authored direction explains the live-read versus offline-inspection tradeoff.

Merge readiness

⛔ Blocked before merge - 7 items remain

This PR addresses worthwhile large-database stalls, but its live dispatch scope removes GitHub readiness source-revocation checks and needs correction before merge.

Priority: P2
Reviewed head: 693f6426f191191b00ccc7a650db0884dc99a6d1

Before merge

  • Add real behavior proof - Authority-chain proof required: the reported isolated Gateway startup and sessions.list run does not exercise readiness response publication after agent-source revocation or replacement; provide allowed and revoked-source results through the real dispatch owner, with sensitive details redacted, and latest-stable startup upgrade evidence. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Preserve source revocation checks for live readiness reads (P1) - Dispatch now runs sessions.github.readiness inside withLiveStateReads, so isArtifactPreservingStateRead() is false. prepareGitHubPublicationSession therefore skips both its registry witness and native source-retirement resource at github-publication-availability.ts:205–225. If the receipt read is pending while the selected agent database is closed, unregistered, or replaced, its retained entry predicate can remain current because those events need not publish a row mutation; readiness can then return facts authorized by the retired source. The existing post-await source, registry-remove, and published-replacement cases in sessions-github-readiness.test.ts exercise this boundary. Preserve these checks independently of private-copy selection and run those cases through the new dispatch scope.
  • Resolve security concern: Retired-source disclosure authority survives - A previously eligible viewer can receive a response based on the old source after registry removal or replacement because the physical-source witnesses are never installed under live dispatch.
  • Resolve merge risk - The PR owner must finish investigating the reported config-validation slowdown and establish that it is resolved or explicitly accepted before merge.
  • Complete next step - Resolve GitHub’s reported merge conflict while preserving the newer Doctor snapshot lifecycle changes.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.
  • Explain or restore the original intent of GitHub readiness source lifetime - fix(gateway): stop GitHub readiness from copying whole agent databases #188025: Live readiness reads retained registry and native-retirement witnesses so removed or replaced sources could not authorize delayed responses.

Findings

  • [P1] Preserve source revocation checks for live readiness reads — src/gateway/server-methods.ts:627-629
  • [medium] Retired-source disclosure authority survives — src/gateway/server-methods.ts:629

Provenance

Tests

  • Missing end-to-end proof: Show allowed readiness and rejection after source retirement or registry replacement at response publication, plus a latest-stable startup upgrade preserving settings and data.
Agent review details

How this fits together

Gateway startup and RPC handlers consume shared-state metadata through SQLite read owners; offline inspection retains private snapshots whose lifecycle owner controls reclamation.

flowchart TD
A[Gateway startup and RPC] --> B[Live read scope]
B --> C[Shared state read owner]
C --> D[SQLite read transaction]
E[Offline inspection] --> F[Private snapshot owner]
F --> G[Bounded payload retirement]
Loading

Technical review

Best possible solution:

Keep live transactions and bounded cleanup in the existing owners, while making publication source revocation independent of artifact-copy policy.

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

Current-main snapshot preparation and the pinned startup callers establish the copying path; the author reports a real Gateway baseline, and no target code was executed during this review.

Is this the best way to solve the issue?

The existing read and retirement owners are appropriate, but source-lifetime checks must survive independently of the scope that previously selected private copies.

Full review comments:

  • [P1] Preserve source revocation checks for live readiness reads — src/gateway/server-methods.ts:627-629
    Dispatch now runs sessions.github.readiness inside withLiveStateReads, so isArtifactPreservingStateRead() is false. prepareGitHubPublicationSession therefore skips both its registry witness and native source-retirement resource at github-publication-availability.ts:205–225. If the receipt read is pending while the selected agent database is closed, unregistered, or replaced, its retained entry predicate can remain current because those events need not publish a row mutation; readiness can then return facts authorized by the retired source. The existing post-await source, registry-remove, and published-replacement cases in sessions-github-readiness.test.ts exercise this boundary. Preserve these checks independently of private-copy selection and run those cases through the new dispatch scope.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Resolve the performance investigation (recommended)
    The PR owner should finish the matched comparisons and explain or remove the config-validation slowdown.
  2. Accept a measured tradeoff
    The feature owner may explicitly accept the slowdown once completed measurements establish its scope and overall user benefit.

Provenance checked

Testing

Proof path: in-process harness.

Security

Needs attention: Delayed readiness responses can retain disclosure authority from an agent database whose source has been revoked or replaced.

Evidence

Security concerns:

  • [medium] Retired-source disclosure authority survives — src/gateway/server-methods.ts:629
    A previously eligible viewer can receive a response based on the old source after registry removal or replacement because the physical-source witnesses are never installed under live dispatch.
    Confidence: 0.98

What I checked:

Likely related people:

  • Vincent Koc: Raw commit ed2de46 adds src/state/openclaw-state-read-snapshot-source.ts:41 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ed2de46114ea; files: src/state/openclaw-state-read-snapshot-source.ts)

PR surface

Source +98, Tests +166, Docs +14, Other +97. Total +375 across 34 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 22 235 137 +98
Tests 8 214 48 +166
Docs 1 22 8 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 3 97 0 +97
Total 34 568 193 +375

Review metrics

Metric Value Why it matters
Benchmark instrumentation 1 benchmark flag and 1 benchmark environment variable --snapshot-counts and OPENCLAW_BENCH_SNAPSHOT_COUNTS instrument the startup benchmark without adding a Gateway configuration setting.

Labels

Label changes:

  • add P2: The improvement targets startup and cleanup costs on large databases, with limited installation scope.
  • add merge-risk: 🚨 security-boundary: Live readiness dispatch skips physical-source revocation checks that protect disclosure after an agent database is removed or replaced.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: The improvement targets startup and cleanup costs on large databases, with limited installation scope.
  • merge-risk: 🚨 security-boundary: Live readiness dispatch skips physical-source revocation checks that protect disclosure after an agent database is removed or replaced.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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 November 2, 2026, 1:46 AM ET / 06:46 UTC.

@steipete
steipete marked this pull request as ready for review November 2, 2026 06:57
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 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-11-02T12:07:07.751255Z c18f1c8 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.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

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

  • Current SHA: c18f1c86258db021831a8400d4114a977921527c
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/server-methods.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e3d45f4373

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +88 to +90
const prepared = isLiveStateRead()
? undefined
: await prepareSqliteReadOnlyLocation(databasePath, {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retain private recovery for hot rollback journals

If the shared-state database has a hot rollback journal (for example, after an interrupted writer on a restored DELETE-journal-mode database), bypassing preparation makes Gateway startup fail before writable recovery can run. inspectOwnershipThroughConnection() opens the source read-only, and SQLite cannot read a hot journal without rolling it back: a native reproduction returns SQLITE_READONLY_ROLLBACK (776), while recovery on a private copy succeeds. The previous preparation path supported this case, also covered by the existing openclaw-state-db.test.ts hot-journal recovery test. Keep live reads for ordinary WAL databases, but retain an exceptional private-recovery path for hot rollback journals.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed that this failure mode also applies to supported network filesystems, where OpenClaw selects DELETE journaling; it is not limited to externally restored databases. The existing hot-journal regression exercises offline artifact-preserving reads and still passes, but it does not prove Gateway startup under the new live-read scope.

This remains unresolved and blocks landing. A private-recovery fallback conflicts with the zero-copy startup objective; native recovery before inspecting the external-ownership row would change the authority boundary. The behavior choice is being settled before implementation. The separate observation-policy/source-revocation findings were fixed in 4616962 and the affected readiness tests and exact-head CI now pass.

@steipete
steipete marked this pull request as draft November 2, 2026 08:59
steipete and others added 3 commits November 2, 2026 01:10
Reserve private state admission for a genuinely hot rollback journal during
startup, then recover the canonical database only after ownership and config
guards pass. Normal startup and runtime readers keep using live SQLite.

Remove Gateway legacy snapshot scanning. Drain active snapshot payloads with
async bounded truncation and retain producer custody through reply delivery
and parent exit. Integrate the one-shot CLI drain from #178730.

Co-authored-by: Frosmans <[email protected]>
@steipete
steipete force-pushed the steipete/perf-micro-state-db-snapshot-clone-lifecycle-20260919 branch from 4616962 to 0e6aa3d Compare November 2, 2026 10:42
Permit native closed-WAL inspection under the existing Gateway live-read policy while retaining full integrity checks and offline artifact preservation. Release producer staging locks before result publication while keeping cleanup custody through delivery.

Prove both regressions at their owning boundaries, repair callback fixtures, and isolate the PostgreSQL orphan-inventory test from sibling schema cleanup. The actual cleanup owner took 57.8 seconds to drain a synthetic 35 GiB clone, so avoiding the unnecessary agent copy removes that admission work.
@steipete
steipete merged commit e68dfaf into main Nov 2, 2026
235 of 239 checks passed
@steipete
steipete deleted the steipete/perf-micro-state-db-snapshot-clone-lifecycle-20260919 branch November 2, 2026 14:01
@steipete

steipete commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

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

wr-web added a commit to wr-web/openclaw that referenced this pull request Nov 2, 2026
…sals

main's openclaw#190918 removed the periodic reclaimer whose skip warning carried the
message; re-home the regression at the reconcile owner that still refuses
unknown staging content.
roboclaw-bot added a commit to SunnyShu0925/openclaw that referenced this pull request Nov 3, 2026
Merge the pinned main containing e68dfaf (openclaw#190918), which isolates
PostgreSQL orphan-inventory assertions from sibling schema cleanup.
The incoming PR failed that exact conformance assertion in CI41446017953;
this preserves the original three-file ENOTDIR product delta while
integrating its existing baseline repair. No timeout changes or new
unrelated repair are introduced.

Co-authored-by: SunnyShu <[email protected]>
Co-authored-by: steipete <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
…aw#190918)

* fix: prevent large-database Gateway startup and cleanup stalls

* fix: preserve observation policy for live state reads

* fix: preserve crash restart without routine state snapshots

Reserve private state admission for a genuinely hot rollback journal during
startup, then recover the canonical database only after ownership and config
guards pass. Normal startup and runtime readers keep using live SQLite.

Remove Gateway legacy snapshot scanning. Drain active snapshot payloads with
async bounded truncation and retain producer custody through reply delivery
and parent exit. Integrate the one-shot CLI drain from openclaw#178730.

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

* fix: avoid agent startup copies and preserve snapshot handoff

Permit native closed-WAL inspection under the existing Gateway live-read policy while retaining full integrity checks and offline artifact preservation. Release producer staging locks before result publication while keeping cleanup custody through delivery.

Prove both regressions at their owning boundaries, repair callback fixtures, and isolate the PostgreSQL orphan-inventory test from sibling schema cleanup. The actual cleanup owner took 57.8 seconds to drain a synthetic 35 GiB clone, so avoiding the unnecessary agent copy removes that admission work.

---------

Co-authored-by: Frosmans <[email protected]>
steipete added a commit that referenced this pull request Nov 5, 2026
Let the reconciliation owner skip read transactions for empty selections while retaining the existing composite snapshot for nonempty runs and already-pinned callers. The synthetic boot/restart workload removes eight statements with unchanged warm turns. Related: #190918, #191332.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
Let the reconciliation owner skip read transactions for empty selections while retaining the existing composite snapshot for nonempty runs and already-pinned callers. The synthetic boot/restart workload removes eight statements with unchanged warm turns. Related: openclaw#190918, openclaw#191332.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts security-sensitive-changed size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant