Skip to content

fix(update): retain lazy sqlite catalog generation - #197095

Merged
jalehman merged 1 commit into
mainfrom
openclaw-267/sqlite-catalog-generation
Nov 11, 2026
Merged

jalehman merged 1 commit into
mainfrom
openclaw-267/sqlite-catalog-generation

Conversation

@jalehman

Copy link
Copy Markdown
Contributor

Related: #196800

What Problem This Solves

Fixes: Git updates can fail during activation when the running updater first reads a SQLite schema catalog after its installation files have been replaced.

User Impact

Updates run by a version containing this fix keep schema definitions and their diagnostic catalogs on the same generation. An already-running older updater is not repaired by selecting a newer candidate: affected source installations need the documented, external-terminal stop/build/Doctor/start procedure for their first hop. Preserve recovery artifacts and a matching pre-update state backup.

Why This Change Was Made

Retained-runtime hooks already preserve module loads, but the generated catalog readers bypassed them with lazy filesystem reads. Load JSON through createRequire instead, preserving laziness and using the existing generation owner. The build transform keeps installed JSON assets and sealed-worker module assets in their current formats. No schema definitions, catalog JSON, dependencies, or admission fallback change.

This addresses generation ownership rather than adding particular predecessor hashes: an old SQL fingerprint must be resolved against its own catalog, not whichever generation currently occupies dist. The simplification removes the filesystem-only loading path and reuses the existing module owner; production/build code is net −7 lines and focused test code is net +19 lines against the base.

Evidence

  • Regression failed before the repair at catalog.tables after replacing active assets; the sealed-worker control passed.
  • Node and Bun: 176 catalog/asset tests passed on each engine.
  • Existing retained-runtime subprocess regression: both Node and Bun cases passed.
  • Independent review of the exact diff: no verified P0–P2 findings; it also checked all 164 hashes and all ten loader/transform combinations on both runtimes.
  • Changed-file lint and tooling test typecheck passed.
  • Full pnpm build passed (7m 8.6s), including installed runtime, worker assets, declarations, and Control UI budgets.
  • Script typecheck, canonical generated-schema verification, test-line ratchet, and documentation route audit passed.
  • The optional documentation anchor audit reports two unchanged-base failures, reproduced against 44a2948a9eaf: duplicate #agent-process-environment on /tools/acp-agents-setup, and missing /providers/openai/runtimes#agents-api-mvp from releases/2026.10.1.md:849. Neither involves this PR's documentation change. ClawHub fragments were unverified because its separate checkout was absent.
  • Asset-test file wall time: Node 4.56s; Bun 2.19s. Hosted CI time is not yet available. The isolated replacement scenario adds 19 net test lines, covered by its own allocation.
  • No live update, restart, state migration, or standalone-package build was performed.
Changed-file walkthrough
File Change
scripts/lib/sqlite-schema-generation.mts Emit retained-owner-aware lazy JSON loads
scripts/lib/sqlite-schema-assets.mts Preserve installed and worker asset formats
src/state/postgres-schema.generated/sqlite-state-catalogs.ts Regenerate state loader
src/state/postgres-schema.generated/sqlite-agent-catalogs.ts Regenerate agent loader
src/state/postgres-schema.generated/sqlite-client-catalogs.ts Regenerate client loader
src/state/postgres-schema.generated/sqlite-daemon-catalogs.ts Regenerate daemon loader
src/state/postgres-schema.generated/sqlite-memory-catalogs.ts Regenerate memory loader
test/scripts/sqlite-schema-assets.test.ts Exercise cold loads after generation replacement
config/test-lines-allocations/sqlite-catalog-generation.txt Allocate the focused regression growth
docs/install/updating.md Explain first-hop recovery for older updaters

@clawsweeper

clawsweeper Bot commented Nov 11, 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 scripts Repository scripts size: S labels Nov 11, 2026
@jalehman
jalehman marked this pull request as ready for review November 11, 2026 07:06
@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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 11, 2026
@clawsweeper

clawsweeper Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR loads lazy SQLite catalogs through retained module imports so an updater keeps reading its original generation after installation replacement.

Example: Git activation replaces dist/assets/sqlite-schema/sqlite-state-catalogs.json before the running updater first loads it.

  • Before: The old reader reads replacement catalogs and can throw when its schema hash is absent.
  • After: The repaired reader loads the matching catalog from its retained runtime.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch appears correct and preserves stored formats, but required updater behavior proof is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A Git-source update can fail during activation and roll back because its running updater reads replacement schema catalogs.
Reason: The maintainer-directed repair restores the existing retained-generation contract without new configuration, schema changes, or competing ownership.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it addresses a source-confirmed updater generation mismatch through the existing owner, and no introduced correctness defect was found.

Priority: P1
Reviewed head: 8ed29122131af2d103ed37053d9d49897dff3390

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply successful shipped-updater activation evidence across catalog replacement, plus fresh-install and latest-stable upgrade coverage preserving settings and data; the reported red/green asset regression does not exercise that boundary.
Agent review details

How this fits together

Build tooling generates schema fingerprints and lazy diagnostic assets; database admission consumes them, while the updater retains its original runtime across installation replacement.

flowchart TD
  A[Schema definitions] --> B[Catalog generator]
  B --> C[Fingerprints and lazy assets]
  C --> D[Generated catalog readers]
  E[Retained updater runtime] --> D
  D --> F[Database schema admission]
  F --> G[Update activation]
Loading

Technical review

Best possible solution:

Keep catalog generation and retained runtime ownership aligned through this focused loader change.

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

Current source establishes the cross-generation filesystem read and unchecked catalog dereference, supported by the linked report; no target code was executed during this review.

Is this the best way to solve the issue?

This is the smallest complete generation-ownership repair: reuse retained module loading, preserve asset formats and admission semantics, and avoid adding historical-hash exceptions or fallback discovery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Dallin Romney: Raw commit 930e1f7 adds docs/install/updating.md:56 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 930e1f77a56c; files: docs/install/updating.md)

PR surface

Source -5, Tests +19, Docs +9, Other 0. Total +23 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 15 20 -5
Tests 1 20 1 +19
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 3 11 11 0
Total 10 55 32 +23

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 regression growth Production/build −7 lines; tests +19 lines The change removes the filesystem-only loading path and extends an existing regression with a distinct cold-read-after-replacement failure.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #196798
Summary: This PR addresses the reported cross-generation catalog read, while the sibling PR also changes historical schema declarations.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P1: A reported repeatable Git-source update failure has a matching current-source mechanism and blocks activation.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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:

  • P1: A reported repeatable Git-source update failure has a matching current-source mechanism and blocks activation.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Demonstrate the repaired updater completing activation across cold catalog replacement through the shipped update entry point.

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 11, 2026, 2:22 AM ET / 07:22 UTC.

@jalehman
jalehman merged commit 6ff8c86 into main Nov 11, 2026
224 of 227 checks passed
@jalehman
jalehman deleted the openclaw-267/sqlite-catalog-generation branch November 11, 2026 07:57
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
RomneyDa added a commit that referenced this pull request Nov 12, 2026
Cover required #196800 on the beta release through its retained-loader
prerequisite #197095. Cold lazy catalog reads must use the running
updater's retained generation instead of the replacement filesystem.

Source: 6ff8c86 (#197095)
Required scope: 1930535 (#196800)

The later device-pairing/bootstrap-deferred edits and v37-v40 history
are absent from this v36 branch; preserve its existing historical
catalogs rather than importing unrelated schema changes. Regenerate
all five loaders and exercise cold reads in installed and sealed assets.

Independent local review omitted by explicit release-owner direction.

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

Failed-update triage now captures the operator's environment before managed candidate admission, so a coding agent installed only on the operator's PATH is still offered when the Gateway service's PATH differs. Restores the operator-environment contract from openclaw#134490 and keeps the launch confirmation from openclaw#143139.

Proof: shipped CLI on isolated Linux (Crabbox) with a running systemd Gateway: accept launches the operator-only agent, decline starts nothing, base 18bee8e reports no agent found; published 2026.11.1 upgrades to the fix with settings intact.

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

(cherry picked from commit 7c702c3)

Release adaptation: Capture invoking operator env before candidate admission, forward to interactive triage only; preserve latest target selectors, confirmation and lease cleanup ordering. Exact three authorized production paths plus real lifecycle regression.

Follow-up dispositions: ad4863d fix: preserve the running installation when an agent updates its Gateway (openclaw#201570); dc73ec0 fix: let updates finish when another tool briefly reads OpenClaw's databases (openclaw#202541); d07b530 fix: clarify PostgreSQL schema upgrades for Git installs (openclaw#202098); e60ea9f test(update): add a Git release upgrade-survivor scenario (openclaw#201956); 2ef6f7b fix(update): build and serve Git releases outside node_modules (openclaw#201917); dbc1aa0 fix: keep the openclaw command and Gateway working after updating a pnpm install (openclaw#201735); f5e7641 fix: Git checkout updates across a schema change no longer end as post-update-failed after the new release starts (openclaw#201600); 2183caf fix: Git checkout updates no longer fail before the new release starts on a schema change or a busy database (openclaw#201463); 47e8649 fix: explain why Doctor cannot restore a scheduled job’s account (openclaw#201550); 8f2cfd4 fix: remove updater-only restrictions from agent maintenance guidance; cb5cfb2 fix: keep a doubtful killed-update recovery on the repair path (openclaw#201361); 24cb734 fix: keep carried-over scheduled jobs running after updates (openclaw#200653); d1276e1 feat(doctor): check OpenClaw ID member roles and honor an optional roles default (openclaw#197785); 0a39956 fix: finish updates when another tool reads OpenClaw's databases during the update (openclaw#201330); ea1c9d5 fix(update): settle remounted package publications before admission (openclaw#201336); 66b5212 fix(update): isolate malformed retained-install markers (openclaw#201199); 7e79c83 fix: let the next update finish a killed source checkout update (openclaw#201009); d905d8a fix: let the next update finish a killed update after the machine restarted (openclaw#200994); fdf0c95 fix: let the next update finish a killed update that had already installed the new version (openclaw#200866); 0c19bcd chore(release): close out 2026.11.5 on main (openclaw#200577); a1940e0 fix(matrix): keep explicit recovery available during deferred migration (openclaw#200805); 18b4776 improve: explain package baseline drift during updates (openclaw#200802); 1ad4cad fix(doctor): reclaim macOS updater runtimes blocked by non-updater processes (openclaw#200732); 427c857 fix: keep one missing archived transcript from blocking every update (openclaw#200733); 802e3f7 fix(update): keep valid cold archives from blocking updates (openclaw#200659); 23fca1a fix: let the next update continue after a killed update when nothing is left to repair (openclaw#200680); 3afe212 fix: let Doctor publish unchanged plugin migrations in any order (openclaw#200658); f65e4db fix(doctor): reclaim runtimes blocked by unrelated Linux processes (openclaw#200657); dab086c fix(update): let candidate Doctor read plugin dependencies from the staged package (openclaw#200595); 3447bee fix(update): keep updates going when the predecessor writes during its stop (openclaw#200569); 0ce9c77 fix: let the next update settle a package publication that a killed update left behind (openclaw#200550); ae31ea3 fix(update): repair handoffs in the journal-pinned lease store (openclaw#200532); 74020ea fix: continue updates when initial SQLite capture is stale (openclaw#200328); 6747b1e feat(update): run Git checkout installs from releases behind the release link (openclaw#199706); e3f8a67 fix(state): keep completed retained agent stores out of startup upgrade (openclaw#200284); 3c512c5 fix(gateway): move managed update lease operations off the main thread (openclaw#200169); ea69fcb chore(release): close out 2026.11.4 on main (openclaw#199956); 618bf31 fix(state): bound startup upgrade copies and pruning to owned state (openclaw#199929); e4a3093 perf(update): replace the candidate canary with a runtime contract check (openclaw#198268); 5dbf569 fix(update): plugin failures never fail an update or Gateway health; 764761e fix(update): refuse missing host prerequisites in one line and record a cause per attempt; 4c4fef4 fix(ui): update dialog claims installation before progress is confirmed (openclaw#199254); 136e1f6 fix(update): retrying an update from a dev checkout is refused after a killed update (openclaw#198673); 3bd03da fix(update): avoid duplicate database copies while the Gateway is stopped (openclaw#198148); 68a839b fix: isolate held agent databases until explicit restoration (openclaw#198180); e333f7e chore(ci): drop retired test-lines allocation records (3/3) (openclaw#197657); fd6fa47 fix: converge Gateway updates with environment-only service overrides (openclaw#196371); 7cf5e75 fix: clarify split-install updates and blocked Doctor repairs (openclaw#196342); 6ff8c86 fix(update): retain lazy sqlite catalog generation (openclaw#197095); 930e1f7 fix: keep stable updates and recovery free of premature migrations (openclaw#196474); a15f737 fix: preserve external plugin data during update rehearsal (openclaw#196301); 92798ae fix: updates survive interrupted heartbeat runs (openclaw#195656); c1e55e2 fix(update): restore LaunchAgent registration after repair contention (openclaw#195406); 715c610 fix(doctor): repair retained ISO session end timestamps (openclaw#194685); 689cfc8 fix(update): reclaim dead closing triage repair leases (openclaw#194503); 86bc89e fix(doctor): keep standing Codex parameter advice out of retirement blockers (openclaw#193650); 691bc8d fix(backup): read the backup engine without copying the live database (openclaw#194234); 000542f fix(backup): backups and updates fail on slow storage when a header probe batch misses its deadline (openclaw#194239); 31a65d5 fix(update): skip --no-lazy-fetch on Git versions without it (openclaw#194198); e45e99d fix(update): preserve dev update sources in tag-only Git clones (openclaw#193109)

Validation: Baseline2 intended operator-agent failures/32 controls passed; candidate34/34passed (194058-green.log). Accept launches synthetic operator-only CLI with expected env, decline starts nothing. Isolated updater flow, not live systemd/upgrade qualification.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 6689fd575ada8fe40a9593784deac18ec73041cd)
(cherry picked from commit 92e7a9fa223b0dc35801f25f70be90b472d9a6b7)
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 P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant