Skip to content

fix(doctor): keep host-rebuilt Codex authoritative on git/dev checkouts - #145298

Closed
DonnieFi wants to merge 4 commits into
openclaw:mainfrom
DonnieFi:fix/145266-git-dev-codex-host-authority
Closed

DonnieFi wants to merge 4 commits into
openclaw:mainfrom
DonnieFi:fix/145266-git-dev-codex-host-authority

Conversation

@DonnieFi

@DonnieFi DonnieFi commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #145266

What Problem This Solves

On git/dev source checkouts, Doctor’s post-core convergence treated a version-bound Codex npm install as stale-version-bound-runtime whenever the calendar version lagged the host, then refreshed from @openclaw/codex. The published npm tarball can share the host version string while still importing a pre-#144828 SDK export (registerRetainedNativeHookRelayForBundledRuntime), while the host-rebuilt bundled plugin and SDK use the renamed export. Loader precedence then prefers the npm generation (origin: global) and every Codex harness turn fails before reply.

Why This Change Was Made

Pete’s guidance on #145266: on git/dev installs the plugin rebuilt with the host stays authoritative; an npm generation must not be admitted on the version string alone; record the decision. ClawSweeper review required (1) retirement only on the dev registry channel, (2) retained-generation markers so recovery cannot re-admit shadows, (3) per-mutation updater authority rechecks before marker writes, and (4) live loader recovery proof.

Shipped Solution

  • Detect usable source-checkout bundled Codex roots (isUsableSourceCheckoutBundledPluginRoot).
  • Host-authoritative only when resolveRegistryUpdateChannel(...) === "dev".
  • Drop shadowing npm install records; mark retained managed npm generations (including sibling leftover trees).
  • Pass beforePersistentEffect into markRetainedManagedNpmInstall and recheck immediately before each mkdir / writeFile so a revoked updater cannot publish recovery-exclusion markers.
  • Stable/beta source checkouts keep healthy npm Codex records; package hosts keep the existing npm refresh path.

User Impact

Git/dev updates keep Codex on the host-rebuilt bundle instead of a mismatched npm generation. Release-channel registry selections are preserved. Retention writes respect updater ownership across async filesystem work.

Behavior proof

Host: git/dev (/opt/openclaw), update.channel: "dev", CLI OpenClaw 2026.9.4 (15285e5).

Pre

Matching #145266: Codex origin: global from npm …g-1153…@2026.9.4; host bundle unused; npm imported registerRetained… while host SDK exports registerNative…; journal showed Doctor refresh then repeated harness failures.

Post — ledger repair

channel: "dev"
changes: ["Kept host-rebuilt bundled plugin \"codex\" authoritative on this git/dev checkout; ignored npm install that would shadow it."]
reload: hasCodexRecord=false, pluginIds=["discord"], recoveryFallbackWarnings=[]
plugins registry: installRecords.codex absent

Post — gateway reload (loader selection)

systemctl --user restart openclaw-gateway.service → new pid 1563882, connectivity probe ok.

plugins inspect codex:
  origin: bundled
  source/rootDir: /mnt/adata/opt/openclaw/dist/extensions/codex
  install: null
journal: gateway http server listening (... codex ...; 3.8s)
no registerRetained… errors after restart

Host SDK exports registerNativeHookRelayForBundledRuntime (not Retained). Bundled thread-lifecycle-*.js imports Native; dynamic import of that module succeeds (lifecycle module import: ok) — the previous crash path.

Authority-chain unit coverage: revocation after stat / after mkdir / mid-loop does not publish further retention markers (managed-npm-retention.test.ts).

Negative (stable/beta)

Unit: retains a healthy same-version npm Codex record on %s source checkouts for stable / beta.

Published-driver / fresh-install

Not run on this long-lived git/dev host. Package hosts keep the non-source-checkout npm refresh path covered in unit tests.

Evidence

  • node scripts/run-vitest.mjs src/commands/doctor/shared/missing-configured-plugin-install.test.ts src/plugins/managed-npm-retention.test.ts src/plugins/bundled-dir.test.ts
  • Live repair + reload proof above (redacted)

Status

Draft — addresses ClawSweeper rev2 ownership fence + loader recovery proof. Request @clawsweeper re-review after this body lands if automation does not pick it up.

On source checkouts, version-bound Codex rebuilt with the host must win
over an npm generation that only matches the calendar version. Doctor no
longer treats those installs as stale-version-bound for npm refresh, and
retires shadowing npm records with an explicit decision note.

Closes openclaw#145266
@clawsweeper

clawsweeper Bot commented Sep 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 commands Command implementations size: M labels Sep 11, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 11, 2026, 6:30 PM ET / 22:30 UTC (Revision 4).

ClawSweeper review

What this changes

Doctor keeps source-built Codex selected on dev checkouts, retires shadowing npm records and recoverable generations, and rechecks updater authority before retention writes.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains a useful fix for an unresolved convergence defect. Both prior code findings are addressed, and the new loader trace strengthens the evidence, but required installation and upgrade proof remains incomplete.

Priority: P1
Reviewed head: 8117af8525c07a07aab05453b10ad8b29a18baad

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused repair addresses earlier findings and now has meaningful loader evidence, but installation and upgrade coverage still limits merge confidence.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The captured real git/dev host trace demonstrates Doctor record retirement, recovery exclusion, bundled loader selection after restart, and successful lifecycle import. It does not clearly tie the running artifact to this candidate, and required fresh-install and published-driver upgrade evidence is explicitly unrun. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The captured real git/dev host trace demonstrates Doctor record retirement, recovery exclusion, bundled loader selection after restart, and successful lifecycle import. It does not clearly tie the running artifact to this candidate, and required fresh-install and published-driver upgrade evidence is explicitly unrun. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 9 items Current main still has the reported selection gap: The fetched main revision excludes externally distributed plugins from bundled protection and assesses stale runtime packages by release version; it lacks this PR's dev source-bundle exception.
Latest supplied release also lacks the exception: The same external-package exclusion and version-based stale-runtime check exist in v2026.9.4. No merged fixing PR was established.
Earlier channel-selection finding resolved: The current implementation returns no host-authoritative IDs unless the resolved registry channel is dev, then requires a bundled version-bound plugin inside a usable source-checkout tree. Stable/beta preservation and package-host refresh cases are covered by added tests.
Findings None None.
Security None None.

How this fits together

Doctor reconciles configured plugins with bundled code and installed package records. Its decisions determine which Codex plugin the Gateway loads after an update or restart.

flowchart TD
  A[Configured plugins and update channel] --> C[Doctor convergence]
  B[Bundled code and npm records] --> C
  C --> D{Usable source bundle on dev?}
  D -->|Yes| E[Retire npm shadows and exclude recovery]
  D -->|No| F[Preserve registry repair behavior]
  E --> G[Gateway selects plugin]
  F --> G
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The captured real git/dev host trace demonstrates Doctor record retirement, recovery exclusion, bundled loader selection after restart, and successful lifecycle import. It does not clearly tie the running artifact to this candidate, and required fresh-install and published-driver upgrade evidence is explicitly unrun. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - Retirement durably changes which installed generations recovery can select. Fresh-install and published-driver upgrade behavior, including preservation of stable/beta registry selections, has not been demonstrated outside unit coverage.
  • Complete next step (P2) - Add candidate-identifiable fresh-install and published-driver upgrade proof. Redacted terminal output or logs are suitable; screenshots or recordings are welcome when useful. Remove credentials, private endpoints, IP addresses, and personal data. Updating the PR body should trigger re-review; otherwise ask a maintainer to comment @clawsweeper re-review.
Agent review details

Security

None.

PR surface

Source +119, Tests +534. Total +653 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 127 8 +119
Tests 3 537 3 +534
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 664 11 +653

Review metrics

Metric Value Why it matters
Production versus regression coverage Net production +119 lines; tests +534 lines Production growth implements source-checkout admission and reuses retention ownership; most added coverage exercises selection, recovery, and revoked writes.

Stored data model

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

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #145266
Summary: This PR is the explicit candidate repair for the linked git/dev npm-shadow report; the issue should remain open until a fix lands.

Members:

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

Merge-risk options

Maintainer options:

  1. Complete installation and upgrade evidence (recommended)
    Identify the candidate used and demonstrate fresh installation plus published-driver upgrade convergence with retained npm generations and preserved release-channel selections.

Technical review

Best possible solution:

Keep the existing convergence and retention owners, preserve release-channel selections, and establish published-driver upgrade compatibility for the dev-only repair.

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

Yes, from source and the supplied host record: a matching global npm install outranks the ordinary bundle, while equal release versions do not detect SDK artifact skew. No runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Yes: repairing convergence and excluding retired generations from recovery addresses the producer of the shadowing state. The new loader/import trace addresses the previous crash-path gap, while candidate identity and upgrade compatibility remain to be established.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The linked report shows a git/dev update leaving Codex-backed turns unable to start across messaging and automation.
  • merge-risk: 🚨 compatibility: The patch changes durable install selection and recovery exclusion without completed published-driver upgrade evidence.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The captured real git/dev host trace demonstrates Doctor record retirement, recovery exclusion, bundled loader selection after restart, and successful lifecycle import. It does not clearly tie the running artifact to this candidate, and required fresh-install and published-driver upgrade evidence is explicitly unrun. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current main still has the reported selection gap: The fetched main revision excludes externally distributed plugins from bundled protection and assesses stale runtime packages by release version; it lacks this PR's dev source-bundle exception. (src/commands/doctor/shared/missing-configured-plugin-install.candidates.ts:93, 304261a77818)
  • Latest supplied release also lacks the exception: The same external-package exclusion and version-based stale-runtime check exist in v2026.9.4. No merged fixing PR was established. (src/commands/doctor/shared/missing-configured-plugin-install.candidates.ts:93, 3a9d69db306c)
  • Earlier channel-selection finding resolved: The current implementation returns no host-authoritative IDs unless the resolved registry channel is dev, then requires a bundled version-bound plugin inside a usable source-checkout tree. Stable/beta preservation and package-host refresh cases are covered by added tests. (src/commands/doctor/shared/missing-configured-plugin-install.candidates.ts:546, 8117af8525c0)
  • Earlier retention-authority finding resolved: Doctor forwards its persistent-effect guard into the existing retention owner. That owner rechecks after stat and again after mkdir, before writing the marker; added tests exercise revocation at both awaits and between generations. The recovery reader already excludes marked packages. (src/plugins/managed-npm-retention.ts:113, 8117af8525c0)
  • Maintainer direction and observed installation: The linked discussion supplies the actual global npm install record and steipete's direction to fix convergence while preserving host-built Codex on git/dev. It also requests comparison with an existing maintainer lane, rather than discarding this draft: [Bug]: Git/dev Doctor refreshes Codex from npm and shadows rebuilt bundled plugin (missing native-hook-relay export) #145266 (comment).
  • Captured real-host proof and remaining coverage: The supplied body at sourceRevision e6c1d7f2d6acda8c445c18a93646e9defbef96dc6deba787d0f0385e5e992ded records Doctor removing the Codex install record, reload without recovery fallback, bundled selection after Gateway restart, and successful lifecycle-module import. This addresses the earlier loader-selection gap; a model turn is not necessary to demonstrate that narrower import repair. However, the host identity is reported as 15285e5 without a clear mapping to the reviewed candidate, and fresh-install/published-driver checks are explicitly unrun.

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.

  • Identify the candidate source/build used for the recorded repair and Gateway reload.
  • Add fresh-install and published-driver upgrade evidence covering recovery exclusion and stable/beta selection preservation.

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 (3 earlier review cycles)
  • reviewed 2026-09-11T21:27:05.260Z sha c8b0722 :: needs real behavior proof before merge. :: [P1] Preserve registry selections on stable and beta source checkouts
  • reviewed 2026-09-11T22:06:27.161Z sha 2423adf :: needs real behavior proof before merge. :: [P1] [P1] Recheck updater authority at each retention filesystem effect
  • reviewed 2026-09-11T22:24:46.321Z sha 8117af8 :: needs real behavior proof before merge. :: none

red added 2 commits September 11, 2026 18:40
Gate bundled Codex npm-record retirement on the Doctor-resolved registry
channel so stable/beta source checkouts keep healthy registry selections.
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 11, 2026
@DonnieFi

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Ownership fence + gateway reload / bundled Codex loader proof are in the latest commits and PR body.

@clawsweeper

clawsweeper Bot commented Sep 11, 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 removed the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Sep 11, 2026
@steipete

Copy link
Copy Markdown
Contributor

Thanks @DonnieFi for the report, reproduction, and artifact-skew evidence. #145356 has landed as the canonical fix in fe05653.

The shared manifest registry now keeps the plugin rebuilt with the running source checkout authoritative, and update-source handling records why a registry artifact without matching host SDK build identity was not admitted. The same selection carries through named/bulk plugin updates and release-cohort preflight, while preserving dormant npm records and strict ownership checks for active packages.

Closing this draft as superseded by #145356. Your reporting and reproduction are credited in the landed squash commit and PR.

@steipete steipete closed this Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Git/dev Doctor refreshes Codex from npm and shadows rebuilt bundled plugin (missing native-hook-relay export)

2 participants