Skip to content

fix(doctor): defer update session-entry inspection when snapshot space runs out - #196370

Merged
fuller-stack-dev merged 4 commits into
openclaw:mainfrom
fuller-stack-dev:fix/update-defers-session-entry-snapshot-capacity
Nov 10, 2026
Merged

fuller-stack-dev merged 4 commits into
openclaw:mainfrom
fuller-stack-dev:fix/update-defers-session-entry-snapshot-capacity

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Related: #196346, #192699

What Problem This Solves

Fixes: an update stops mid-activation and leaves the Gateway stopped when Doctor has no temporary space for the read-only snapshot it uses to inspect session entry state, even though it read and changed nothing.

User Impact

User impact: on a host short of temporary space, the update now finishes and reports a warning such as Session entry state inspection deferred for agent main: … Free temporary snapshot space, then run openclaw doctor --fix after the update. Previously session-entry-state refused (step-refused), which halted every later migration step and kept the Gateway stopped. On the affected Gateway the snapshot needed 21 GiB with the disk already full. No configuration or migration is needed.

Why This Change Was Made

session-entry-state is a required step. Its read-only scan stages a private snapshot of each agent database, and any scan error became a step refusal. A SqliteSnapshotCapacityError only means the disposable snapshot location ran out of space or quota: the scan never opened the source and wrote nothing. The memory-core Doctor check already treats this error class as a deferrable warning (#192699).

prepareSessionEntryRepairs now skips a target whose raw scan fails with SqliteSnapshotCapacityError while an update is in progress (OPENCLAW_UPDATE_IN_PROGRESS, which shipped updaters already set). It records a warning for that target, and the prelude reports the step as deferred with a recoverable disposition, so later steps continue. That target's media migration stays deferred too. Deferred receipts already flow into the update's post-install warnings. Config preflight forwards the same warning.

Unchanged: any other scan error, any failure after the scan (backup, apply), and every run outside an update still refuse. A row the scan skipped stays in its legacy shape. Canonical readers keep refusing such rows with the existing migration-required error until doctor --fix runs.

This complements #196346, which removes the snapshot entirely for drained databases. This change covers databases that still have WAL frames, and any other snapshot shortfall.

Update behavior: the change lives in the candidate's Doctor and keys on a marker published updaters already set, so it applies to updates driven by existing updaters as soon as the candidate includes it.

Evidence

  • New src/commands/doctor-session-entry-state.update-capacity.test.ts runs the repair inside the update's migration capture with a legacy row, as activation does. Snapshot staging is made to fail with a capacity error.
    • Deferral: on main this fails with Failing check session-entry-state (step-refused): SQLite read-only worker failed while creating its private snapshot, the production failure. Here the repair returns the deferral warning, the capture receipt reports the database unchanged, and the source bytes are identical.
    • Activation migration: the real prelude steps (session-entry-state-preparation, media-persistence, session-entry-state, cold-navigation) record session-entry-state as deferred and run cold-navigation afterwards. On main the run throws.
    • Negative controls, which pass on main and here: the same capacity failure outside an update, and a non-capacity failure during an update, both still refuse with the injected error.
  • The 82 test files that import the touched modules pass (1,086 tests). node scripts/check-changed.mjs passes typecheck, lint, format, docs and the ratchets, with the dead-export scan skipped because it already fails on main for untouched files. Autoreview (P0–P2) is scoped-clean.
  • Interaction with fix(doctor): updates fail on a full disk because Doctor copies a stopped database just to read it #196346 (merged): a drained, custodied family is now read in place and needs no snapshot, so this deferral covers families that still hold WAL frames when the scan runs. The capacity fixtures keep their WAL sidecars, and the full-sequence test holds a read transaction so a step's checkpoint cannot drain the family. With the old drained fixture all four tests failed on a tree combining both PRs; with this fixture, the 31 doctor-session-entry-state tests pass on that tree and on the rebased head (c8a297e5), and main still fails with the production error.
  • Test budget: 196370-update-session-entry-capacity.txt allocates this PR's 203 lines. fix(doctor): updates fail on a full disk because Doctor copies a stopped database just to read it #196346 merged without an allocation after main had used its headroom, which left main 128 lines over the ceiling; 196346-drained-capture-in-place.txt allocates exactly those 128 lines. The ratchet passes with slack 0. check-changed passes on c8a297e5.
  • Published-driver × candidate Docker cell, run locally with OPENCLAW_PUBLISHED_DRIVER_LEGACY_SQLITE=1 bash scripts/e2e/published-driver-update-docker.sh against 6dd06f64: PASS published 2026.11.2 → candidate 2026.11.2 (6dd06f64…): finished, readyz=200, running version verified. The shipped latest updater drove the update (205 s) and the repeat maintenance run. Both agent databases (main, second) migrated from schema 27 to 41 with an unchanged logical SHA-256, integrity: ok, and no foreign-key failures. With normal disk space the session-entry inspection ran without deferring: the update output has no Session entry state inspection deferred warning.
    • Gap: this cell does not constrain snapshot storage, so it proves the unchanged path and data compatibility, not the deferral itself. The deferral is covered by the in-process capture tests above.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

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 commands Command implementations size: M labels Nov 10, 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR defers session-entry inspection during updates when disposable SQLite snapshot storage is exhausted.

Example: Agent main needs a 21 GiB inspection snapshot, but temporary storage is full.

  • Before: The required session-entry-state step refuses and stops subsequent activation work.
  • After: The inspection returns a recoverable warning, preserves the database, and allows subsequent migration steps to run.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, useful repair with meaningful harness coverage, a concrete test-budget blocker, and unverified upgrade compatibility.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An update can stop activation and leave the Gateway stopped because a disposable inspection snapshot cannot fit in temporary storage.
Reason: The maintainer-authored direction fits the update recovery contract and explicitly accepts deferred legacy-row repair without weakening backup or write checks.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this maintainer-authored PR addresses a current update failure, but its new tests exceed the repository’s test-line budget.

Priority: P1
Reviewed head: d080ebf2ce737a15575794c78c18056273841bed

Before merge

  • Allocate the justified regression-test growth (P2) - The new file adds 187 counted test lines without a corresponding allocation. The base has 41 lines of headroom, so the reviewed tree exceeds the ceiling by 146 and fails checks-fast-baseline-ratchets/test-lines. Add a justified config/test-lines-allocations record for the regression growth, keeping the shared scalar and distinct behavioral coverage intact.
  • 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.

Findings

  • [P2] Allocate the justified regression-test growth — src/commands/doctor-session-entry-state.update-capacity.test.ts:114-118

Tests

  • Missing end-to-end proof: Show a latest-stable-to-candidate update with constrained snapshot storage reaching Gateway readiness with settings and data intact, followed by successful deferred repair after space is freed.
Agent review details

How this fits together

Update activation invokes Doctor’s config preflight and ordered migration steps; session-entry repair inspects agent databases and returns changes, warnings, and receipts to the updater.

flowchart TD
  A[Update activation] --> B[Doctor config preflight]
  B --> C[Session entry repair]
  C --> D[SQLite snapshot staging]
  D --> E[Capacity warning]
  E --> F[Deferred migration receipt]
  F --> G[Later activation steps]
Loading

Technical review

Best possible solution:

Retain the focused deferral in the existing repair owner and add the justified test-budget allocation.

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

Current source shows snapshot-capacity errors becoming a required-step refusal, and the PR supplies a matching injected-failure regression; no product execution was performed during this read-only review.

Is this the best way to solve the issue?

The smallest fix belongs in the existing raw repair owner: classify disposable capacity failure, preserve the source and genuine refusals, and propagate a recoverable receipt through its callers.

Full review comments:

  • [P2] Allocate the justified regression-test growth — src/commands/doctor-session-entry-state.update-capacity.test.ts:114-118
    The new file adds 187 counted test lines without a corresponding allocation. The base has 41 lines of headroom, so the reviewed tree exceeds the ceiling by 146 and fails checks-fast-baseline-ratchets/test-lines. Add a justified config/test-lines-allocations record for the regression growth, keeping the shared scalar and distinct behavioral coverage intact.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Required session-entry normalization changes intended behavior with a stated reason (e25e244: Persist legacy scalar normalization in Doctor with verified backups before canonical readers consume rows.)
  • Entry preparation before media migration keeps the original intent (697ed2c3413181f6495dfb082f52ee4635b7db: Readable legacy entries must be repaired before media preservation invokes canonical readers; unreadable targets remain deferred to their preparation owner.)
  • Awaited snapshot inspection keeps the original intent (7ce05f4: Keep large Doctor inspections cancellable, preserve source artifacts, and classify insufficient snapshot capacity explicitly.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/commands/doctor-session-entry-state.update-capacity.test.ts --maxWorkers=1
  • pnpm check:test-lines-ratchet --base 5aa6d59 --no-merge-base
  • git diff --check

What I checked:

PR surface

Source +26, Tests +187, Docs +7. Total +220 across 5 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 38 12 +26
Tests 1 187 0 +187
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 232 12 +220

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test growth Production +38/-12; tests +187/-0 The production growth carries typed deferral through existing owners; the tests cover preservation, negative controls, and migration continuation.

Labels

Label changes:

  • add P1: The reported capacity failure interrupts update activation and leaves the Gateway stopped; current main retains the blocking path.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: The reported capacity failure interrupts update activation and leaves the Gateway stopped; current main retains the blocking path.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 9, 2026, 8:29 PM ET / November 10, 2026, 01:29 UTC.

@fuller-stack-dev
fuller-stack-dev force-pushed the fix/update-defers-session-entry-snapshot-capacity branch from d080ebf to 6dd06f6 Compare November 10, 2026 14:51
…e runs out

During an update, a SqliteSnapshotCapacityError while staging the read-only
session-entry snapshot refused the required session-entry-state step and
stopped activation, even though nothing had been read or changed. Skip that
target with a recoverable deferred warning instead, and let doctor --fix
finish it after the update. Other failures, and runs outside an update,
still refuse.
A drained, custodied family is now read in place, so the capacity
deferral applies to families that still hold WAL frames.
@fuller-stack-dev
fuller-stack-dev force-pushed the fix/update-defers-session-entry-snapshot-capacity branch from 6dd06f6 to c8a297e Compare November 10, 2026 19:36
@fuller-stack-dev
fuller-stack-dev enabled auto-merge (squash) November 10, 2026 19:44
@fuller-stack-dev
fuller-stack-dev merged commit ef47e2e into openclaw:main Nov 10, 2026
131 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the fix/update-defers-session-entry-snapshot-capacity branch November 10, 2026 20:24
@fuller-stack-dev

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 Nov 11, 2026
…e runs out (openclaw#196370)

* fix(doctor): defer update session-entry inspection when snapshot space runs out

During an update, a SqliteSnapshotCapacityError while staging the read-only
session-entry snapshot refused the required session-entry-state step and
stopped activation, even though nothing had been read or changed. Skip that
target with a recoverable deferred warning instead, and let doctor --fix
finish it after the update. Other failures, and runs outside an update,
still refuse.

* test: allocate update session-entry capacity regression lines

* test(doctor): keep update capacity fixtures on the private-snapshot path

A drained, custodied family is now read in place, so the capacity
deferral applies to families that still hold WAL frames.

* test: allocate drained capture test lines from openclaw#196346
vincentkoc added a commit that referenced this pull request Nov 12, 2026
Preserve the upstream test-growth policy and dynamic dependency roots:
#196370
#197250
#197602

Remove only the superseded task-owned 128-line grant. Keep the original
157-line record, upstream Doctor allocation and retired scalar deletion.

The staged checker against 0626eb5 passed: net +157, allowance 400,
allocation credit 157. The measured workload remains frozen at
79f5aeb.
RomneyDa added a commit that referenced this pull request Nov 17, 2026
…e runs out (#196370)

* fix(doctor): defer update session-entry inspection when snapshot space runs out

During an update, a SqliteSnapshotCapacityError while staging the read-only
session-entry snapshot refused the required session-entry-state step and
stopped activation, even though nothing had been read or changed. Skip that
target with a recoverable deferred warning instead, and let doctor --fix
finish it after the update. Other failures, and runs outside an update,
still refuse.

* test: allocate update session-entry capacity regression lines

* test(doctor): keep update capacity fixtures on the private-snapshot path

A drained, custodied family is now read in place, so the capacity
deferral applies to families that still hold WAL frames.

* test: allocate drained capture test lines from #196346

(cherry picked from commit ef47e2e)

Co-authored-by: RomneyDa <[email protected]>
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
…law#194599)

An agent database on an older schema is now reported as a required state migration, so the managed service is parked with the existing "run openclaw doctor --fix" guidance instead of restart-looping the Gateway. The session-SQLite import still defers such a target and processes the others (fixes openclaw#194580).

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: steipete <[email protected]>

(cherry picked from commit 8bea0c1)

Release adaptation: Classify only older canonical agent schemas as existing state-migrations maintenance; Doctor continues deferring matching targets. Keep newer schema refusal/media migration identity. No schema/version/data migration changes; retain focused Gateway parking, committed reader and Doctor regressions. Later cancellation-owner and unrelated Doctor repairs are not prerequisites.

Follow-up dispositions: 410c0dd refactor(infra): read SQLite cancellation from its scope owner (openclaw#200179); 8cd7d87 chore(ci): drop retired test-lines allocation records (1/3) (openclaw#197655); 0e966cc fix: avoid agent database stalls after worker retirement (openclaw#194484); ef47e2e fix(doctor): defer update session-entry inspection when snapshot space runs out (openclaw#196370); 715c610 fix(doctor): repair retained ISO session end timestamps (openclaw#194685)

Validation: Source baseline old-schema error was generic SqliteSchemaMismatchError and did not trigger service maintenance parking. Matching existing maintenance codec and Doctor catch reviewed; exact regression group queued. diff check passed.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit f61a73edfda73dc6452f3e0e534cb9e891c05ae6)
(cherry picked from commit 4e8445923f2522eb6b42ab705e15624a1a674a39)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant