Repository navigation
fix(doctor): skip stale npm generations during host-link repair - #176121
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 46ef87fbf1
ℹ️ 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".
| !["EACCES", "EPERM", "EIO", "SQLITE_CANTOPEN", "SQLITE_IOERR"].some((code) => | ||
| hasErrnoCode(error, code), |
There was a problem hiding this comment.
Recognize Node's SQLite I/O error shape
When the installed-index read fails through the repository's Node SQLite path, the error typically has code: "ERR_SQLITE_ERROR" with primary errcode 10 for I/O failure or 14 for open failure, rather than either listed SQLITE_* string. Consequently, an unreadable database bypasses the new fallback and aborts Doctor instead of warning and inspecting all managed roots as documented. Classify the SQLite primary result code here, or reuse the repository's SQLite error classifier.
AGENTS.md reference: AGENTS.md:L83-L84
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. What this changesRestricts Doctor and post-update host-link maintenance to managed npm projects selected by plugin install records. Example: Two recorded plugins have 40 additional stale npm generations.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain This PR addresses a current maintenance-performance defect, but Windows path selection and native SQLite error handling need focused corrections before merge. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherDoctor reads persisted plugin records, and post-core convergence supplies current in-memory records; a shared selector derives managed npm roots for the existing host-link audit and repair owner. flowchart TD
A[Doctor] --> C[Plugin install records]
B[Post core convergence] --> C
C --> D[Selected managed npm roots]
D --> E[Existing host link owner]
E --> F[Audit or repair selected packages]
A --> G[Recovery and retirement discovery]
Technical reviewBest possible solution: Keep the shared record-selected maintenance path, preserve Windows path identity, and classify native SQLite storage failures without weakening invalid-record or authority refusals. Do we have a high-confidence way to reproduce the issue? Current-main source enumerates every admitted generation before host-link inspection; the PR supplies matching filesystem regression results, while this review executed no target code. Is this the best way to solve the issue? Direct selection from authoritative records removes discovery work at its source and preserves separate recovery ownership; the implementation needs the two compatibility corrections listed below. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against eec35949bda1. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +62, Tests +212, Docs +2. Total +276 across 10 files. Added test files: 0. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 18, 2026, 3:15 AM ET / 07:15 UTC. |
…claw#176121) Doctor's plugin host-link audit/repair and the post-update core plugin convergence walked every admitted plugin npm root, including stale __openclaw-generation__ trees, so their cost grew with leftover generations rather than active plugins (8.5+ minute Doctor runs on plugin-heavy installs, inside the update budget). Both now share one selector driven by plugin install records; when the records cannot be read, they fall back to the full walk with an OPENCLAW_PLUGIN_NPM_ROOTS_FALLBACK warning. Stale generation retirement keeps its existing owner. Thanks @patelmm79 for the detailed report. Fixes openclaw#176063
Prune 70 stale max-lines entries (508 -> 438). Reconcile the counted OPENCLAW_* budget from 452 -> 461 and rename the internal agent FTS schema constant. Record FACTORY_GITHUB_PROOF, FACTORY_ACTOR_ID, FACTORY_SESSION_KEY (#173668), IMAGE_ACTIVATION_CAPTURE_MARKER (#173711), UPDATE_DOCTOR_HISTORICAL_SCANS (#177933), SESSION_WATCHDOG (#176915), PACKAGE_PERMISSIONS_REPAIRED (#175423), PLUGIN_NPM_ROOTS_FALLBACK (#176121), DISABLE_CRON_HOST_EXECUTION and DISABLE_GATEWAY_LOCAL_TERMINALS (#177855), and the removal of DEVICE_NAME_PREFIX (#178345). All names above use the OPENCLAW_ prefix. AGENT_FTS_SCHEMAS is an internal constant, not an environment variable.
* fix(ci): block baseline inventory drift in CI and keep shard size advisory The max-lines suppression inventory and the OPENCLAW_* budget used the limit severity policy, so GitHub Actions only annotated a tree that disagreed with its own inventory. Main absorbed moved suppressions, stale entries, and unrecorded env names with green CI, and every later local ratchet run failed on debt the branch did not create. Inventory/tree consistency (unlisted suppression, stale entry, name count different from the budget) now blocks everywhere, like the sibling shrink ratchets. Growth relative to the merge base keeps the limit policy so owner-approved growth still lands with a CI warning. The core tsgo shard root budget is a shared cost signal its contract marks advisory; routing it through the limit reporter made it locally fatal. It now warns everywhere. Proof: new ratchet and env-budget regressions fail on the base scripts and pass with the fix; the real boundary check on main's shard layout exits 0 with four advisory warnings instead of failing. * ci(tsgo): rebalance core test shards under the root budget agents-tools (722), gateway-root (725), infra (728), and plugins-platform (728) exceeded the advisory 720-root limit. Move whole test globs to shards with headroom: src/media to messaging, src/acp to gateway-other, src/security to config-cli, and root src/gateway/github* to gateway-methods. The largest shard is now 719 roots and exactly-once ownership holds. Messaging test-root selection of the shard guard now includes src/media. * ci(tsgo): move agents CLI backend tests into the commands shard Newer main tests pushed agents-root to 722 roots. Root-level src/agents/cli-*.test.ts files join the commands shard, which already owns src/agents/command and CLI program tests: agents-root 693, commands 516. * test(ui): split chat message rendering coverage Preserve current main coverage across grouping, markdown, tools, attachments, and images, sharing render lifecycle and attachment fixtures. Keep all 59 direct cases and eight parameterized declarations, expanding to the same 79 passing tests. The image disclosure case now waits for its lazy renderer instead of depending on an earlier image test. All seven files have line-cap headroom; UI types and scoped lint pass. Independent review found no actionable P0-P2 defects. * chore(ci): reconcile max-lines baseline and env budget with main Prune 70 stale max-lines entries (508 -> 438). Reconcile the counted OPENCLAW_* budget from 452 -> 461 and rename the internal agent FTS schema constant. Record FACTORY_GITHUB_PROOF, FACTORY_ACTOR_ID, FACTORY_SESSION_KEY (#173668), IMAGE_ACTIVATION_CAPTURE_MARKER (#173711), UPDATE_DOCTOR_HISTORICAL_SCANS (#177933), SESSION_WATCHDOG (#176915), PACKAGE_PERMISSIONS_REPAIRED (#175423), PLUGIN_NPM_ROOTS_FALLBACK (#176121), DISABLE_CRON_HOST_EXECUTION and DISABLE_GATEWAY_LOCAL_TERMINALS (#177855), and the removal of DEVICE_NAME_PREFIX (#178345). All names above use the OPENCLAW_ prefix. AGENT_FTS_SCHEMAS is an internal constant, not an environment variable.
…aw#179181) * fix(ci): block baseline inventory drift in CI and keep shard size advisory The max-lines suppression inventory and the OPENCLAW_* budget used the limit severity policy, so GitHub Actions only annotated a tree that disagreed with its own inventory. Main absorbed moved suppressions, stale entries, and unrecorded env names with green CI, and every later local ratchet run failed on debt the branch did not create. Inventory/tree consistency (unlisted suppression, stale entry, name count different from the budget) now blocks everywhere, like the sibling shrink ratchets. Growth relative to the merge base keeps the limit policy so owner-approved growth still lands with a CI warning. The core tsgo shard root budget is a shared cost signal its contract marks advisory; routing it through the limit reporter made it locally fatal. It now warns everywhere. Proof: new ratchet and env-budget regressions fail on the base scripts and pass with the fix; the real boundary check on main's shard layout exits 0 with four advisory warnings instead of failing. * ci(tsgo): rebalance core test shards under the root budget agents-tools (722), gateway-root (725), infra (728), and plugins-platform (728) exceeded the advisory 720-root limit. Move whole test globs to shards with headroom: src/media to messaging, src/acp to gateway-other, src/security to config-cli, and root src/gateway/github* to gateway-methods. The largest shard is now 719 roots and exactly-once ownership holds. Messaging test-root selection of the shard guard now includes src/media. * ci(tsgo): move agents CLI backend tests into the commands shard Newer main tests pushed agents-root to 722 roots. Root-level src/agents/cli-*.test.ts files join the commands shard, which already owns src/agents/command and CLI program tests: agents-root 693, commands 516. * test(ui): split chat message rendering coverage Preserve current main coverage across grouping, markdown, tools, attachments, and images, sharing render lifecycle and attachment fixtures. Keep all 59 direct cases and eight parameterized declarations, expanding to the same 79 passing tests. The image disclosure case now waits for its lazy renderer instead of depending on an earlier image test. All seven files have line-cap headroom; UI types and scoped lint pass. Independent review found no actionable P0-P2 defects. * chore(ci): reconcile max-lines baseline and env budget with main Prune 70 stale max-lines entries (508 -> 438). Reconcile the counted OPENCLAW_* budget from 452 -> 461 and rename the internal agent FTS schema constant. Record FACTORY_GITHUB_PROOF, FACTORY_ACTOR_ID, FACTORY_SESSION_KEY (openclaw#173668), IMAGE_ACTIVATION_CAPTURE_MARKER (openclaw#173711), UPDATE_DOCTOR_HISTORICAL_SCANS (openclaw#177933), SESSION_WATCHDOG (openclaw#176915), PACKAGE_PERMISSIONS_REPAIRED (openclaw#175423), PLUGIN_NPM_ROOTS_FALLBACK (openclaw#176121), DISABLE_CRON_HOST_EXECUTION and DISABLE_GATEWAY_LOCAL_TERMINALS (openclaw#177855), and the removal of DEVICE_NAME_PREFIX (openclaw#178345). All names above use the OPENCLAW_ prefix. AGENT_FTS_SCHEMAS is an internal constant, not an environment variable.
What Problem This Solves
Fixes #176063. Doctor and post-update host-link repair walk stale managed npm generations, making update maintenance grow with accumulated installation history.
User Impact
Host-link checks and repairs inspect the install-record-selected roots. Stale generations no longer add package walks to these passes. Recovery and retirement retain broad discovery; this does not make the entire Doctor command independent of retained history.
Why This Change Was Made
A shared selector derives managed npm project roots directly from install paths, including legacy and scoped packages, while preserving the managed-path ownership checks. Doctor consumes readable persisted records without performing recovery discovery first; post-core convergence uses its current in-memory records. Recognized ledger I/O failures retain a warned full-root fallback; invalid records and lost read authority still refuse repair.
The existing Doctor retirement and Gateway cleanup owners remain responsible for stale generations. The obsolete async full-root enumerator is removed. No new deletion path, configuration, schema, or dependencies.
Thanks @patelmm79 for the report and detailed reproduction. Implemented independently; no downstream contributor code was copied or executed.
Evidence
Regression: two active plugins plus 40 stale generations. Baseline audited all 42 packages; the fix audits and repairs only the two selected packages, never enumerates the projects directory on the readable-ledger path, and leaves stale host links untouched. The measured Doctor host-link audit + repair pass fell from 172.9 ms to 109.6 ms on this synthetic fixture (single local samples; not an end-to-end fleet timing claim).
Real convergence fixture repairs the selected generation before payload smoke checks and never traverses the stale roots. Empty records, deduplication, legacy/scoped packages, warned unreadable-record fallback, and invalid-record refusal are covered.
All 13 importing test files were exercised (179 tests). Six old fixture cases across the update-caller and persistence suites assumed an unrecorded managed package was active; the fixtures now record that package and retain their original revocation/recovery assertions. Final targeted replay: 19 passed, including all ten persistence tests. Install-record and stale-generation-retirement owner suites also passed. New host-link regression: 485 ms; convergence regression: 164 ms. Final two-file replay: 39.96 s wall time, including compilation; persistence test time was about 8.5 s.
Live, isolated state with the same 42-generation fixture:
pnpm openclaw doctor --non-interactiveandpnpm openclaw doctor --fix --non-interactiveboth exited 0. After repair: 2 active host links, 0 stale host links, 40 retirement markers, all 40 stale package directories preserved. Existing non-default-state protection skipped service management; no Gateway was started or restarted.Both commands used
HOME="$PWD/.artifacts/l1684/home" OPENCLAW_STATE_DIR="$PWD/.artifacts/l1684/live-state" OPENCLAW_DISABLE_BUNDLED_PLUGINS=1. Fresh-checkout UI assets were built by Doctor. Missing optional provider/health configuration remained advisory.Core and affected-test typechecks, targeted type-aware oxlint, oxfmt,
git diff --check, and Madge passed (0 cycles). Fullcheck:changed/ SQLite inventory was skipped under the campaign's local gate budget; PR CI supplies broad proof. No remote lease was used.Final isolated Codex review: no actionable P0–P2 findings.
Production: +92 / -30 (net +62); tests: +240 / -28 (net +212); docs: +2. The remaining production growth is the shared record selector and explicit unreadable-ledger handling; the unused async full-tree walk and its duplicate tests were removed.