Skip to content

perf(doctor): avoid loading unused plugin runtimes - #134541

Merged
steipete merged 2 commits into
mainfrom
codex/cron-timeout-phase-context
Sep 1, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/cron-timeout-phase-context

Conversation

@steipete

@steipete steipete commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Doctor's public low-memory import check exposed unnecessary plugin runtime loading. A native Node 24.19 reproduction exhausted the 256 MiB heap after public repairs completed. Same-process heap snapshots then showed 71.82 MiB of retained module/compiler growth, including MatrixClient and the ACP protocol schema. The snapshots force GC and are diagnostic evidence, not a passing memory test or proof of a transcript-data leak.

This repair keeps Matrix's sync-cache codec and persistence operations in one shared owner, separate from the live SDK store class. Doctor and runtime migration use that owner; the live client keeps its existing canonical SDK entrypoint. Chunk keys, version, digest checks, write/delete order, and migration behavior are unchanged. ACPX now returns after its existing filename validation finds no legacy records, before inspecting unrelated claims or loading its runtime. Nonempty records and explicit migration retain all ownership, process-liveness, and incomplete-evidence checks. No plugin is disabled or skipped, and no heap, timeout, fixture, cache lifetime, config, or schema is changed.

The existing cron timeout assertion message remains in this PR. It identifies the missing model-request marker without changing the timeout, polling, or assertion. The earlier cron failure passed independent original-order replays, so this message is diagnostic improvement, not a claimed cron runtime fix. The Doctor repair was added after this PR's initial CI exposed the unrelated memory failure.

Validation so far:

  • The unchanged actual Doctor memory file passed all three native Linux cases in original batch → deep → public order, under 256 MiB and the existing 180-second child/test deadlines. Deep/public still use 100,000 events with 4,096-byte payloads and verify exact event digests, completed projections, and idempotence. Total Vitest time was 93.13s; public migration reported 40.18s. There was no instrumentation, forced cleanup, or remaining process. The native environment workflow was pinned to protected main cc9a9ebeb3dcc363bea09575b34eb55d58af171e; the applied candidate tree was f8c29f2d6673edb20d20a129499c35e0d2fc21e3, with all 35,923 source entries verified before and after. Final reviewed tree 092a8ba65cdaef626d4be33bd8a8fa23a873eb78 differs only by deleting the obsolete assertion-baseline entry; runtime and test bytes are identical.
  • All 72 focused tests passed on the composed candidate and current frozen lockfile: Matrix migration/store/SDK behavior, ACPX ownership migration, and the existing Doctor import-boundary guard. The Matrix import guard fails before the split; two ACPX empty/missing-directory regressions fail before the early return. A separate cold import probe verifies zero ACP runtime imports or claim inspections for those cases, with malformed-filename and unexpected-filesystem-error behavior preserved.
  • Independent Codex review of all 11 changed files found no actionable P0–P2 findings. The moved assertions now document their existing opaque-data invariants, and the obsolete five-assertion baseline is removed rather than waived.

The complete pnpm build passed all canonical stages in 5m51s, including SDK declarations, 63 external plugin builds, CLI checks, and UI size checks. The complete composed scoped gate passed, including core-test, plugin runtime/test and root-test types, all three lint lanes, Doctor declaration/import checks, ratchets, dead-export scans, and architecture guards. Exact-head CI 33457932206 passed on c105fadc04f00d05c499efa18047b2b49f98cea3: 126 successful jobs, 16 skipped, zero failures; required openclaw/ci-gate 99703031131 passed. This is not full release certification; a new frozen full verification follows the main landing. Telegram remains advisory.

Production net +30 lines implements the shared Matrix persistence boundary (+27, mostly moved code and required import/assertion documentation) and ACPX's no-work return (+3). Tests net +37, changelog +1, and assertion baseline −1. Broader Memory Wiki/Canvas import cost, Matrix's existing metadata fallback, and crypto snapshot dependency cost remain named follow-up investigations outside this proven boundary.

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 31, 2026, 9:19 PM ET / September 1, 2026, 01:19 UTC.

ClawSweeper review

What this changes

The PR extracts Matrix sync-cache persistence from the live Matrix client for Doctor and migration paths, and avoids ACPX claim/runtime work when no legacy session files are present.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. The Doctor import-boundary repair is coherent, but this PR adds a release-owned changelog entry that should be removed; the maintainer label also requires explicit maintainer handling rather than automated cleanup closure.

Priority: P3
Reviewed head: c105fadc04f00d05c499efa18047b2b49f98cea3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The runtime refactor is narrowly owner-aligned and covered by focused source tests; remove the release-owned changelog edit and complete exact-head validation.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: repository state identifies a maintainer-authored PR, so the external-contributor proof gate does not apply. The body reports native Doctor-memory and focused migration runs, while exact-head hosted checks remain in progress.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: repository state identifies a maintainer-authored PR, so the external-contributor proof gate does not apply. The body reports native Doctor-memory and focused migration runs, while exact-head hosted checks remain in progress.
Evidence reviewed 6 items Introduced release-file edit: The exact PR-head commit adds a Doctor-memory entry to the release-owned changelog.
Repository release policy: Repository policy assigns CHANGELOG.md generation to the release process and says normal PRs must not edit it; the PR body already contains the needed release-note context.
Current-main import boundary: The current PR base imports Matrix cache migration helpers from the live SDK store, whose top-level value import includes matrix-js-sdk; the PR redirects Doctor to the persistence-only module.
Findings 1 actionable finding [P3] Remove the release-owned changelog entry
Security None None.

How this fits together

Doctor loads plugin migration contracts to inspect and repair old state before the live plugin runs. Matrix cache migration and ACPX session-owner migration now avoid loading their heavier runtime dependencies on no-work paths.

flowchart LR
  A[Doctor command] --> B[Plugin migration contract]
  B --> C[Legacy state discovery]
  C --> D{Records found?}
  D -->|No| E[Return without runtime import]
  D -->|Yes| F[State codec and migration]
  F --> G[Plugin state storage]
  G --> H[Repair report]
Loading

Before merge

  • Remove the release-owned changelog entry (P3) - CHANGELOG.md is generated by the release process and repository policy says normal PRs must not edit it. The PR body already supplies the release-note context, so remove this introduced line to avoid bypassing release ownership.
  • Resolve merge risk (P1) - Matrix sync-cache migration handles persisted legacy cache data. The extracted codec replaces Matrix SDK category constants with literals; installed matrix-js-sdk source was unavailable in this node_modules-less checkout and GitHub DNS prevented direct upstream-contract inspection.
  • Complete next step (P2) - One mechanical P3 correction is safe to automate: remove the release-owned changelog entry without changing the runtime repair.

Findings

  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:37
Agent review details

Security

None.

PR surface

Source +30, Tests +37, Docs +1, Other -1. Total +67 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 5 418 388 +30
Tests 4 43 6 +37
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 11 462 395 +67

Review metrics

Metric Value Why it matters
Production versus test delta production +30, tests +37, release-owned changelog +1, baseline −1 Most Matrix code is moved into a lightweight persistence owner; the only policy-invalid production-adjacent addition is the changelog entry.

Stored data model

Persistent data-model change detected: durable storage schema: extensions/matrix/src/matrix/client/storage.ts, persistent cache schema: extensions/matrix/doctor-contract-api.ts, persistent cache schema: extensions/matrix/src/matrix/client/file-sync-store.ts, persistent cache schema: extensions/matrix/src/matrix/client/storage.ts, persistent cache schema: extensions/matrix/src/matrix/client/sync-cache-state.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify persisted-cache compatibility (recommended)
    Confirm exact-head Matrix migration coverage preserves legacy bot-storage.json data and existing plugin-state cache rows before merging.
  2. Pause for dependency-contract confirmation
    Pause if the Matrix SDK category-key contract cannot be checked before release, because the extracted persisted-state codec now encodes those keys directly.

Technical review

Best possible solution:

Retain the single lightweight Matrix cache codec and ACPX no-work return, remove the release-owned changelog line, and land only after exact-head migration coverage is green.

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

No independent reproduction was run in this read-only, node_modules-less checkout. The PR body supplies a specific native low-memory scenario and focused regression claims, but hosted exact-head checks are still incomplete.

Is this the best way to solve the issue?

Mostly yes: extracting the shared persistence codec keeps Doctor off the live Matrix SDK path and the ACPX return is at the discovery owner. Removing the release-owned changelog edit is the remaining narrow correction.

Full review comments:

  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:37
    CHANGELOG.md is generated by the release process and repository policy says normal PRs must not edit it. The PR body already supplies the release-note context, so remove this introduced line to avoid bypassing release ownership.
    Confidence: 0.99

Overall correctness: patch is correct
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3c23e2fb0eca.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The PR refactors code that reads and writes persisted Matrix sync-cache data used by upgrades and Doctor migrations.

Label justifications:

  • P3: This is a bounded internal Doctor performance and import-boundary repair with one low-risk release-process correction.
  • merge-risk: 🚨 compatibility: The PR refactors code that reads and writes persisted Matrix sync-cache data used by upgrades and Doctor migrations.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: repository state identifies a maintainer-authored PR, so the external-contributor proof gate does not apply. The body reports native Doctor-memory and focused migration runs, while exact-head hosted checks remain in progress.

Evidence

Acceptance criteria:

  • [P1] git diff --check.

What I checked:

Likely related people:

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

Rank-up moves

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

  • Remove the introduced CHANGELOG.md line; the PR body already records release-note context.
  • Confirm the exact-head Matrix migration and Doctor import-boundary checks complete successfully before merge.

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 (1 earlier review cycle)
  • reviewed 2026-08-31T23:36:18.068Z sha 00e50f0ddfbdd10bde353236f42f0dd0a6224b8d :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/cron-timeout-phase-context branch from 00e50f0 to c105fad Compare September 1, 2026 01:14
@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix extensions: acpx labels Sep 1, 2026
@steipete steipete changed the title test(cron): identify missing model requests in timeout failures perf(doctor): avoid loading unused plugin runtimes Sep 1, 2026
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

The initial CI failure in the unchanged public Doctor memory case is now addressed by two concrete import-owner repairs: Matrix's migration codec no longer loads the live client, and ACPX does not load its runtime or inspect claims when validated legacy-record discovery is empty. Nonempty ownership checks and all storage semantics remain unchanged.

The original, uninstrumented native memory test passes all three cases under the unchanged 256 MiB/180-second limits. All 72 focused tests, the complete build, the composed scoped gate, and independent P0–P2 review passed. The body records exact source/proof limits. Fresh hosted CI is running on c105fadc04f00d05c499efa18047b2b49f98cea3.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 1, 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:

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 1, 2026
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Final review disposition for exact head c105fadc04f00d05c499efa18047b2b49f98cea3:

The Matrix dependency and migration rank-up is satisfied. I directly inspected installed matrix-js-sdk 42.2.0: lib/sync-accumulator.js:43–47 defines exactly invite, leave, join, and knock, matching the extracted codec; lib/matrix.js:17–90 confirms the live SDK barrel retained by the runtime store. The persistence format, version, keys, digests, chunk sizing, and write/delete ordering are unchanged. All 72 composed focused tests passed, including Matrix migration/store/SDK cases, ACPX ownership migration, and Doctor import closure. Full build and the complete scoped gate passed. The unchanged native Doctor memory test passed all three cases in original order at 256 MiB, with the original deadlines and fixtures. These results resolve the reviewer's unavailable dependency/test environment; they do not assert a schema change or rely on mock-only memory proof.

Exact-head CI 33457932206 is now complete: 126 passed, 16 skipped, zero failed, and required openclaw/ci-gate 99703031131 passed. Independent scoped Codex review found no actionable P0–P2 finding. git diff --check passed.

The changelog rank-up is intentionally skipped: the maintainer's explicit instructions for this authorized landing require a one-line changelog entry for user-facing repairs. That task instruction takes precedence over the repository's normal release-only changelog convention. This does not authorize a release, version change, tag, or publication.

The prior intermittent cron failure remains unproven as a runtime defect; this PR only improves its timeout diagnostic. Full release certification will come from a new frozen main run after landing, not from these scoped results.

@steipete
steipete merged commit 3b758df into main Sep 1, 2026
203 of 205 checks passed
@steipete
steipete deleted the codex/cron-timeout-phase-context branch September 1, 2026 01:26
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 1, 2026
* test(cron): identify missing model requests in timeout failures

* perf(doctor): avoid loading unused plugin runtimes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix extensions: acpx maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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