Skip to content

improve(doctor): reuse metadata snapshots during startup inspection - #149737

Merged
steipete merged 5 commits into
mainfrom
codex/startup-metadata-snapshot
Sep 17, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/startup-metadata-snapshot

Conversation

@steipete

@steipete steipete commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Related: #124407.

What Problem This Solves

Gateway startup's artifact-preserving Doctor inspection repeatedly copies metadata state and can combine captured plugin inventory with a newer discovery policy after an asynchronous check.

User Impact

Startup inspection reuses one consistent private database snapshot until its checks finish. In six balanced Windows pairs, established-state median readiness improved from 12.746 s to 12.485 s (261 ms, 2.0%), with four of six pairs faster. The shared host was variable; this is a modest observed improvement, not a startup-time guarantee. The sub-five-second goal remains unmet.

Why This Change Was Made

The existing read-snapshot owner now spans the whole inspection, including asynchronous metadata reads. Discovery policy consumes those same private bytes without replacing the live process memo. Prepared facts validate their original snapshot lifetime, cache retirement, and invalidation before reuse.

Ordinary worker-backed reads keep their existing path. Update rehearsal preserves the installed updater's markers, pending migration inputs, and retry-after-package-arrival behavior. No schema, durable-state format, operator configuration, or migration policy changes.

Evidence

  • Independent review through P2: no actionable findings after fixing the asynchronous reader's snapshot escape.
  • Seven new regression cases fail on the original production code. All 17 worker tests and 63 related state, discovery, startup-plan, and real Doctor preflight tests pass (80 total).
  • Full production build, all plugin declarations, package integrity/import-graph checks, and normal Windows npm install/rebuild pass.
  • Windows Node 26.8.2 installed-package comparison: one fresh-state launch and six established-state launches per variant, alternating pair order. All 14 launches passed health/readiness, first WebSocket status, acknowledged graceful shutdown, and final whole-install identity checks. First-status medians were 12.844 s and 12.627 s; CLI bootstrap medians were 3.812 s and 3.320 s. Nested trace spans are not additive.
  • Baseline baa836b031a26c4915670c082197f4ae9cd91546; tested five-file patch SHA-256 75c04a18f0e49ddd7d93aa4b65d00023c91ab4166b1b611ebd8f1ca8f8345975, measured on the earlier candidate; the runtime-alias integration below has separate validation. Distinct fixed install paths, identical dependency lock, synthetic isolated state, normal lifecycle/compile-cache policy, no discarded samples. Filesystem/cache carryover and concurrent host load limit attribution; the single fresh-state difference is not claimed as a speedup.
  • Formatting, source guards, and production types pass locally. The local changed gate stopped at the state/logging test typecheck's unchanged 600-second watchdog after seven earlier shards passed. Focused diagnostics with 2 GiB and the normal throttled 3 GiB compiler budget also timed out without a TypeScript diagnostic; those failures remain recorded. Both hosted core test typecheck jobs passed on the prior b83ea2a head.
  • The maintained published [email protected] updater-to-candidate Docker cell, package integrity, and npm 12 installer acceptance all passed on b83ea2a. The first update dispatch rejected an invalid lane name before building; the corrected dispatch used the catalog-owned published-upgrade-survivor base lane.
  • The prior CI run failed only inherited UI file-length, compact-test packing, and Goal read-count checks. Repairs landed through fix(cron): suppress control tokens and retain retry usage #149697 and fix(ci): accept file paths in extension packing fixtures #149726. The PR is refreshed to 937eb5e on base 9b73eb1; the complete five-file patch remains byte-identical, and package/build inputs are unchanged from the previous base. Refreshed exact-head CI passed.

Current Revision

Head 196aa92f42261b8c75b1e2ed9b986724222e42a2 merges main 68663e6c648 into the reviewed candidate, including the CI planner repair #150581. Main changed none of the five PR files; the complete product patch remains byte-identical to reviewed 6d6c32b0 and previous head 9898225. The earlier runtime-alias conflict was resolved by retaining main's lookup inside the captured metadata scope; fresh P2 review was clean and all 241 tests across nine affected state, plugin, and Doctor files passed.

The resolved 6d6c32b0 patch SHA-256 is fad411c017387b422dc3712783c6fa32413d6c7df79357f48e20b9bc0c85d068. The paired timings above belong to the earlier build. A new absolute Windows measurement of the installed 6d6c32b0 package recorded fresh readiness at 37.43 s and four established restarts at 12.73, 9.98, 12.28, and 28.72 s. Every recorded launch passed its first WebSocket status request and graceful shutdown. The next launch was refused when physical memory fell below 4 GiB; final installed hashes matched. This incomplete, heavily loaded-host series proves neither a speedup nor the sub-five-second target.

New exact-head CI passed every selected check except checks-node-changed-extensions-bundle-22, which was canceled at the one-hour job deadline while still emitting passing memory-core and Workboard tests. Its aggregate gate consequently failed. The retained log proved the planner put 185 native database-worker files in one envelope. Repair #150581 limits both each native envelope and each packed job to 20 files, preserving coverage and the broad 40-job plan. It is now included here; fresh exact-head CI passed all selected checks, including the bounded extension jobs. The failed original run remains retained; no CI gate is waived. The previous head's four failures were inherited fixture/import-closure and UI-budget failures, repaired by #150453 and #150491. The complete local changed checks passed on 6d6c32b0, including production and test types, lint, unused-export scans, and source guards. Earlier failed attempts remain recorded separately.

Refreshed Package Acceptance passed package build, integrity, and npm 12 installer acceptance. Its upgrade-survivor lane failed before installing the candidate: the registry fixture supplied candidate plugin bytes to the published baseline when their version numbers matched. The fixture repair in #150542 passed its focused regression tests and exact-head CI. Its full 2026.9.4 replay now boots the genuine published baseline and passes candidate migration rehearsal, Doctor lint, config validation, plugin resolution, and canary startup. It later correctly refuses the candidate Codex plugin: the same published version has different integrity bytes. That failed cell is retained; the integrity policy is unchanged. A separate supported published 2026.9.3 to the same immutable candidate cell passed the complete updater flow, automatic migration, state survival, Doctor, final Gateway health/readiness/status, and unavailable-plugin-path checks. The installed published updater upgraded Codex, Discord, and WhatsApp from 2026.9.3 to 2026.9.4 with no integrity drift. The failure manifest is empty. The fixture repair is now merged as c0cac428 (#150542).

Compatibility confirmation for the fresh review: this patch changes only the lifetime of a private read snapshot, not the persistent data model or migration policy. The retained run 35178808524 explicitly passes assert-automatic-migration, doctor, assert-survival, gateway-probes, and gateway-status using the installed published updater and the exact immutable 6d6c32b0 package. Its failure manifest and plugin integrity-drift list are empty. The refreshed five-file patch is byte-identical.

@clawsweeper

clawsweeper Bot commented Sep 16, 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.

@steipete
steipete marked this pull request as ready for review September 16, 2026 05:23
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: M maintainer Maintainer-authored PR labels Sep 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 17, 2026, 1:33 AM ET / 05:33 UTC (Revision 9).

ClawSweeper review

What this changes

Doctor’s startup inspection reuses one private database snapshot across asynchronous plugin checks, keeping plugin inventory and discovery policy consistent.

Merge readiness

✅ Ready for maintainer review

The PR remains useful and has no actionable correctness findings. The supplied published-updater evidence resolves the previous compatibility-proof concern; no additional review blocker remains.

Priority: P2
Reviewed head: 196aa92f42261b8c75b1e2ed9b986724222e42a2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful consistency coverage and real startup/upgrade evidence; no actionable blocker remains.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): Installed Windows runs exercise Gateway startup through Doctor, status, and shutdown; the published 2026.9.3 updater cell exercises migration, state survival, and final Gateway health using the unchanged candidate files. This resolves the prior upgrade-proof concern without claiming a reliable performance gain.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): Installed Windows runs exercise Gateway startup through Doctor, status, and shutdown; the published 2026.9.3 updater cell exercises migration, state survival, and final Gateway health using the unchanged candidate files. This resolves the prior upgrade-proof concern without claiming a reliable performance gain.
Evidence reviewed 9 items Inspection scope and unchanged migration decisions: The introduced change wraps artifact-preserving inspection in the existing read-snapshot owner and captures environment semantics. The whitespace-insensitive diff preserves plugin selection, pending-migration classification, and runtime-alias handling.
Snapshot lifetime and admission: The new accessor returns identity only for an active snapshot of the matching database. Existing disposal marks the scope inactive before cleanup, and current-authority publication reads explicitly exit the snapshot context.
Async reads preserve captured bytes: The metadata reader uses the existing synchronous row reader only when an artifact-preserving snapshot is active, retaining admission checks before and after the read. Ordinary reads retain the shared-worker path. These are OpenClaw-owned storage contracts; no Codex harness or protocol contract is changed.
Findings None None.
Security None None.

How this fits together

Doctor inspects configuration and installed plugin metadata before Gateway startup and migration planning. Its results identify available plugins and migrations that must remain pending.

flowchart TD
  A[Gateway startup] --> B[Doctor inspection]
  C[Configuration and install records] --> B
  D[Shared state database] --> E[Private read snapshot]
  E --> B
  B --> F[Plugin inventory and discovery policy]
  F --> G[Available plugins and pending migrations]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +68, Tests +103. Total +171 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 4 206 138 +68
Tests 1 104 1 +103
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 310 139 +171

Review metrics

Metric Value Why it matters
Production versus test growth production +65 net lines; tests +103 net lines Production growth supports snapshot reuse and lifetime validation, with seven regression cases covering consistency and invalidation.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor/shared/plugin-migration-availability.ts, unknown-data-model-change: src/commands/doctor/shared/plugin-migration-availability.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Keep inspection on one lifecycle-owned private snapshot while preserving live memo isolation, current admission checks, and existing migration behavior.

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

Yes, source establishes how an asynchronous metadata read can escape captured inventory and consume newer policy; the added concurrent-update cases target that mechanism. No tests or product code were executed in this review.

Is this the best way to solve the issue?

Yes. Extending the existing snapshot owner addresses the asynchronous boundary that the existing synchronous scope cannot cover, without introducing another cache or changing persistent formats.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded startup consistency and performance improvement without evidence of an urgent user-facing outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): Installed Windows runs exercise Gateway startup through Doctor, status, and shutdown; the published 2026.9.3 updater cell exercises migration, state survival, and final Gateway health using the unchanged candidate files. This resolves the prior upgrade-proof concern without claiming a reliable performance gain.
  • proof: sufficient: Contributor real behavior proof is sufficient. Installed Windows runs exercise Gateway startup through Doctor, status, and shutdown; the published 2026.9.3 updater cell exercises migration, state survival, and final Gateway health using the unchanged candidate files. This resolves the prior upgrade-proof concern without claiming a reliable performance gain.

Evidence

What I checked:

  • Inspection scope and unchanged migration decisions: The introduced change wraps artifact-preserving inspection in the existing read-snapshot owner and captures environment semantics. The whitespace-insensitive diff preserves plugin selection, pending-migration classification, and runtime-alias handling. (src/commands/doctor/shared/plugin-migration-availability.ts:52, 196aa92f4226)
  • Snapshot lifetime and admission: The new accessor returns identity only for an active snapshot of the matching database. Existing disposal marks the scope inactive before cleanup, and current-authority publication reads explicitly exit the snapshot context. (src/state/openclaw-state-db-readonly.ts:46, 196aa92f4226)
  • Async reads preserve captured bytes: The metadata reader uses the existing synchronous row reader only when an artifact-preserving snapshot is active, retaining admission checks before and after the read. Ordinary reads retain the shared-worker path. These are OpenClaw-owned storage contracts; no Codex harness or protocol contract is changed. (src/plugins/plugin-metadata-state-worker.ts:24, 196aa92f4226)
  • Meaningful consistency regressions: Six table-driven cases exercise concurrent inventory/policy changes across synchronous and asynchronous readers, populated or empty live memos, and pinned install roots. A seventh rejects a prepared fact after its original snapshot closes. The tests were inspected, not executed during this read-only review. (src/plugins/plugin-metadata-state-worker.test.ts:346, 196aa92f4226)
  • Upgrade evidence resolves prior review concern: The captured PR body records published 2026.9.3 upgrading to immutable candidate 6d6c32b, including automatic migration, Doctor, state survival, Gateway readiness/status, and unavailable-plugin checks, with empty failure and integrity-drift lists. GitHub independently reports the published-upgrade-survivor job and overall run successful: https://github.com/openclaw/openclaw/actions/runs/35178808524. The run's head identifies the repaired harness, not the candidate package. Direct log retrieval was blocked by the artifact-host allowlist; this reviewer limitation does not invalidate the supplied proof. (a8a78e6e282f)
  • Proof continuity: The comparison against tested candidate 6d6c32b is empty for all five touched files. The refreshed head therefore retains the reviewed product changes. GitHub also reports successful CI for head 196aa92. (196aa92f4226)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • pfrederiksen: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (8 earlier review cycles)
  • reviewed 2026-09-16T05:56:49.491Z sha b83ea2a :: blocked before merge. :: none
  • reviewed 2026-09-16T06:23:35.668Z sha 937eb5e :: needs maintainer review before merge. :: none
  • reviewed 2026-09-16T06:59:31.989Z sha 937eb5e :: blocked before merge. :: none
  • reviewed 2026-09-17T02:17:46.346Z sha 6d6c32b :: blocked before merge. :: none
  • reviewed 2026-09-17T03:21:59.689Z sha 9898225 :: blocked before merge. :: none
  • reviewed 2026-09-17T04:08:50.863Z sha 9898225 :: blocked before merge. :: none
  • reviewed 2026-09-17T05:03:00.478Z sha 196aa92 :: blocked before merge. :: none
  • reviewed 2026-09-17T05:12:12.929Z sha 196aa92 :: blocked before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 17, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 17, 2026
@steipete
steipete merged commit 9edc73f into main Sep 17, 2026
224 of 225 checks passed
@steipete
steipete deleted the codex/startup-metadata-snapshot branch September 17, 2026 06:01
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

1 participant