Skip to content

refactor(plugins): simplify prepared-runtime composition - #140667

Merged
steipete merged 1 commit into
mainfrom
refactor/prepared-runtime-hard-deslop-552e31
Sep 7, 2026
Merged

steipete merged 1 commit into
mainfrom
refactor/prepared-runtime-hard-deslop-552e31

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Related: #139911 (cold model-runtime registration repair), #139867 (original stall report).

Additional instructions

Maintainer-requested follow-up. This branch is in the upstream repository and remains editable by maintainers.

What Problem This Solves

The cold model-runtime repair retained unnecessary forwarding layers, unused auth-sync result state, and two names for the same registry operation. Restricted registration also constructed a lazy host runtime that it immediately discarded. This focused cleanup reduces that maintenance and allocation overhead without reopening the larger import-boundary refactor.

Why This Change Was Made

Return the selected auth store and provider load options directly, inline two one-use adapters, keep one registry-resolution operation, and share the existing physical-client close operation. Construct the lazy runtime only when used, while preserving the existing constructor-argument sampling point.

Native composition, synchronous hook/admission ordering, getter-only runtime facets, independent mutable method views, authored cache identity, and post-commit publication remain intact. The broader external-auth factory consolidation was intentionally excluded: it requires a separate import-boundary and fixture rewrite. This is a behavior-preserving cleanup, not a new performance architecture.

Production LOC: +45 / -93 (net -48). Tests/support: +0 / -14. Ten files; no test scenarios removed, no new configuration, SQLite/schema, dependencies, compatibility layers, timeouts, or budget changes.

User Impact

No intentional user-visible behavior change. The repaired cold-registration path stays intact; restricted registration avoids allocating an unused lazy runtime. No new operator action is required.

Evidence

  • Exact-head CI passed at 1fd0b45c6e479c5c82b83405360813938d0f33ed.
  • Pre-merge ownership and compatibility clarification: live verification established author/requester @steipete as an active maintainer of openclaw-secops. The doctor harness changes only a mock export; no schema, migration, stored representation, or persistence semantics change. The removed cacheability bit was private, in-memory, and unconsumed, so no upgrade migration is needed.
  • 264 focused tests passed, covering auth overlay precedence, exact-owner publication and rollback isolation, provider setup trust and metadata selection, native cold capability registration, authored cache identity, and shared-client retirement. Six additional doctor declaration/import-closure tests passed.
  • All four typecheck lanes passed: pnpm tsgo:core, pnpm tsgo:core:test, pnpm tsgo:extensions, and pnpm tsgo:extensions:test. Core lint, dead-export scans, formatting, and the changed-gate prefix passed.
  • The first typecheck attempt exposed an outdated local dependency install after pulling main. pnpm install --frozen-lockfile restored the pinned Node types; the unchanged tests then passed. No test was altered to mask it.
  • Local plugin lint correctly refused an ancestor-install dependency resolution from the nested checkout. The exact candidate was then validated in a fresh secretless Linux arm64 container, with Node 24.20.0 and pnpm 12.3.4: frozen install, full pnpm build (6m 7.6s), and the normal targeted plugin-lint wrapper passed (263 rules, zero warnings/errors). All remaining changed-gate checks passed there: native schema consistency, database-first legacy stores, media downloads, runtime sidecars, import cycles, webhook body reads, and pairing scope guards. No guard, dependency, or environment bypass was used.
  • Build log: zero INEFFECTIVE_DYNAMIC_IMPORT occurrences. All 38,841 tracked paths matched the frozen candidate before execution, after install, and after proof. The container was removed; no operator stores, credentials, Gateway, browser, or inference were used.
  • Independent Codex review: scoped-clean at the configured P0 threshold, on the identical patch. This is not a claim of a broader review threshold or new live-Gateway proof.
  • Direct dependency inspection: Codex v0.153.4 thread unsubscribe versus removal/shutdown. The cleanup preserves physical close rather than substituting unsubscribe.

Focused test command:

node scripts/run-vitest.mjs src/plugins/providers.test.ts src/plugins/providers.runtime.consult-current-snapshot.test.ts src/plugins/providers.setup-trust.test.ts src/plugins/loader.capability-factory.test.ts src/agents/auth-profiles/external-oauth.test.ts src/agents/auth-profiles/store-owner-publication.test.ts extensions/codex/src/app-server/shared-client.test.ts

Targeted plugin lint command (normal package-boundary preparation retained):

node scripts/run-oxlint.mjs --tsconfig extensions/tsconfig.json extensions/codex/src/app-server/shared-client-lifecycle.ts

Reviewed/tested parent: dbac2c10809f28e9d8bedb409d8b5307e200e8ad. Frozen binary patch SHA-256: 5bb32ef0939f9e59ca74260a9d1f67be5018416cfb8502e3695f52760842f6f0. Current main was checked before publication; none of the ten touched files had drifted.

Remove unused auth-sync cacheability state, single-use forwarding helpers, duplicate registry naming, and load-options envelopes. Avoid constructing a discarded lazy runtime for restricted registration and reuse the physical-client close owner. Preserve native loading, auth publication, and lifecycle behavior.

Maintainer-requested cleanup following #139911. Verified 264 focused tests, six doctor contract tests, four typecheck lanes, changed guards, and a matching-source secretless container build/lint. Production net -48 lines; tests/support net -14. Independent review completed on the identical patch.
@clawsweeper

clawsweeper Bot commented Sep 7, 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 agents Agent runtime and tooling extensions: codex size: S maintainer Maintainer-authored PR labels Sep 7, 2026
@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 Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 6, 2026, 10:51 PM ET / September 7, 2026, 02:51 UTC.

ClawSweeper review

What this changes

The PR removes redundant plugin-loading and auth-store wrappers, avoids constructing an unused runtime during restricted registration, and reuses the existing client-close operation.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: this remains a useful, behavior-preserving cleanup distinct from the merged registration repair. No actionable patch defect was found; the restricted-path ownership prerequisite remains unverified.

Priority: P3
Reviewed head: 1fd0b45c6e479c5c82b83405360813938d0f33ed

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-supported cleanup with useful reported validation and no actionable correctness findings; ownership verification is a separate merge prerequisite.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored internal refactor is exempt from the external-contributor proof gate and does not materially change authority. Reported focused tests and isolated build/lint support the changed owners but are not presented as live runtime proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored internal refactor is exempt from the external-contributor proof gate and does not materially change authority. Reported focused tests and isolated build/lint support the changed owners but are not presented as live runtime proof.
Evidence reviewed 8 items Introduced scope and current-main necessity: The complete supplied merge-base-to-head patch identifies the cleanup. Comparing all ten touched paths between the merge base and fetched main produced no differences, so fetched main retains the pre-cleanup implementation. The supplied verified test merge has the pinned base and PR head as its parents. No release implementation of this cleanup was established.
Auth synchronization remains equivalent: Before the patch, cacheable was written but never consumed; the sole caller read synced.store. The patch preserves the transaction, concurrent-profile comparison, post-commit publication call, publication-failure eviction, and selected store. Inlining the save wrapper retains filterExternalAuthProfiles: false.
Registry and runtime boundaries: The resolver keeps compatible-registry reuse, exact-load recursion protection, and nonactivating loading. Provider selection retains empty-selection handling and the same registry precedence. The deleted name has no remaining tree references; no documented SDK or package export for it was found. Runtime arguments are still sampled before choosing the supplied or lazy runtime.
Findings None None.
Security None None.

How this fits together

The plugin loader combines configuration, plugin metadata, and auth operations into registries used by model execution. The related client lifecycle code retires shared Codex connections after their users finish.

flowchart TD
  A[Configuration and plugin metadata] --> B[Native runtime composition]
  C[Auth profile store] --> B
  B --> D{Restricted registration?}
  D -->|Yes| E[Supplied runtime]
  D -->|No| F[Lazy host runtime]
  E --> G[Provider registry]
  F --> G
  G --> H[Model execution and client lifecycle]
Loading

Before merge

  • Resolve merge risk (P1) - Required secops-owner involvement for the auth-profile changes is not established by the available review context.
  • Complete next step (P2) - Establish that a listed secops owner authored, explicitly requested, or is actively reviewing the auth-profile changes before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -49, Tests -13. Total -62 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 9 45 94 -49
Tests 1 0 13 -13
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 45 107 -62

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor.e2e-harness.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain one internal registry resolver and direct return values while preserving auth ownership, post-commit publication, and graceful client retirement.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain one internal registry resolver and direct return values while preserving auth ownership, post-commit publication, and graceful client retirement.

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

Not applicable: this PR proposes internal simplification, and source inspection found no introduced failure requiring reproduction.

Is this the best way to solve the issue?

Yes: removing unused result metadata and forwarding layers is a narrow simplification that retains the existing selection, publication, and lifecycle owners.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is bounded internal cleanup with no intended change to user behavior, configuration, or stored data.
  • 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: The maintainer-authored internal refactor is exempt from the external-contributor proof gate and does not materially change authority. Reported focused tests and isolated build/lint support the changed owners but are not presented as live runtime proof.

Evidence

What I checked:

  • Introduced scope and current-main necessity: The complete supplied merge-base-to-head patch identifies the cleanup. Comparing all ten touched paths between the merge base and fetched main produced no differences, so fetched main retains the pre-cleanup implementation. The supplied verified test merge has the pinned base and PR head as its parents. No release implementation of this cleanup was established. (src/plugins/loader-runtime-registry.ts:20, 3fe748574314)
  • Auth synchronization remains equivalent: Before the patch, cacheable was written but never consumed; the sole caller read synced.store. The patch preserves the transaction, concurrent-profile comparison, post-commit publication call, publication-failure eviction, and selected store. Inlining the save wrapper retains filterExternalAuthProfiles: false. (src/agents/auth-profiles/store.ts:1338, 1fd0b45c6e47)
  • Registry and runtime boundaries: The resolver keeps compatible-registry reuse, exact-load recursion protection, and nonactivating loading. Provider selection retains empty-selection handling and the same registry precedence. The deleted name has no remaining tree references; no documented SDK or package export for it was found. Runtime arguments are still sampled before choosing the supplied or lazy runtime. (src/plugins/loader-runtime-core.ts:131, 1fd0b45c6e47)
  • Client retirement and retained coverage: The idle guard still checks retirement, active leases, pending acquisitions, and client presence before clearing closeWhenIdle. Its delegated helper clears the client reference and invokes the same physical close. The existing graceful-retirement test still checks that an active lease delays transport closure until release; provider trust scenarios remain present. (extensions/codex/src/app-server/shared-client-lifecycle.ts:136, 1fd0b45c6e47)
  • Direct dependency contract inspection: The PR explicitly claims preservation of physical close versus thread unsubscribe, establishing the dependency signal. Personally inspected the sibling checkout at rust-v0.153.4: unsubscribe removes the connection subscription, while removal separately shuts down the thread. Repository identity is corroborated by the official linked source: https://github.com/openai/codex/blob/rust-v0.153.4/codex-rs/app-server/src/request_processors/thread_processor.rs. (codex-rs/app-server/src/request_processors/thread_processor.rs:1011, 3d2ee51ca2d5)
  • Restricted-path prerequisite independently rechecked: CODEOWNERS assigns auth-profiles to openclaw/openclaw-secops, and CONTRIBUTING.md:94 requires listed-owner authorship, an explicit request, or active review. The supplied review-request event does not identify its recipient or establish that involvement. This independently supports the prior review concern without inventing a code defect. (.github/CODEOWNERS:45, 1fd0b45c6e47)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • openclaw/openclaw-secops: 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 (1 earlier review cycle)
  • reviewed 2026-09-07T02:42:42.041Z sha 1fd0b45 :: blocked before merge. :: none

@steipete
steipete marked this pull request as ready for review September 7, 2026 02:47
@steipete
steipete requested a review from a team as a code owner September 7, 2026 02:47
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Addressing the remaining pre-merge review items for head 1fd0b45c6e479c5c82b83405360813938d0f33ed:

Restricted-path ownership is satisfied. This PR is authored and explicitly requested by @steipete. Live gh api orgs/openclaw/teams/openclaw-secops/memberships/steipete verification returned state: active, role: maintainer. This establishes listed-owner involvement for the auth-profile paths; it is separate from GitHub merge enforcement and does not waive required CI.

There is no persistent data-model change. The entire change to src/commands/doctor.e2e-harness.ts deletes one obsolete getRuntimePluginRegistryForLoadOptions mock property; the canonical resolveRuntimePluginRegistry mock remains. It is test support, not a migration/backfill/repair implementation. No schema version, tables, columns, stored representation, migration, retention, or transaction semantics change. The removed cacheable field was a private in-memory function result, never persisted, and no caller consumed it. The selected store, compare-before-write transaction, and post-commit publication call remain unchanged. Existing migration-refusal, owner-publication, and rollback-isolation tests passed; the isolated native-schema and database-first guards also passed.

Accordingly, no new upgrade migration is required. Counting the doctor harness as test support gives production +45/-93 (net -48) and tests/support +0/-14, total -62, with no scenario deletion. The requested mitigation—one resolver and direct return values with the existing auth/publication/client-lifecycle owners—is the implementation already under review. No code changes or new review cycle are needed for these evidence clarifications.

@steipete
steipete merged commit d0fd1e2 into main Sep 7, 2026
255 checks passed
@steipete
steipete deleted the refactor/prepared-runtime-hard-deslop-552e31 branch September 7, 2026 03:05
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…0667)

Remove unused auth-sync cacheability state, single-use forwarding helpers, duplicate registry naming, and load-options envelopes. Avoid constructing a discarded lazy runtime for restricted registration and reuse the physical-client close owner. Preserve native loading, auth publication, and lifecycle behavior.

Maintainer-requested cleanup following openclaw#139911. Verified 264 focused tests, six doctor contract tests, four typecheck lanes, changed guards, and a matching-source secretless container build/lint. Production net -48 lines; tests/support net -14. Independent review completed on the identical patch.
steipete added a commit that referenced this pull request Sep 7, 2026
Retain missing explicit model-account selections through chat and command
admission, preserve durable user context on internal retries, and fail over
exhausted usage windows without delaying temporary throttles. Keep retired
hook listeners alive for their locator grace period and await host-owned
Claude process cleanup before replacement.

Preserve supplied lazy plugin runtime services and Gateway protocol aliases.
Refuse unreadable shared state before Doctor update admission, migrate
credentials before model-route repair, and release staged QA auth-store
leases before child maintenance.

Align isolated Doctor, Claws, Discord, plugin, UI permission, compaction,
yield, and Windows worker-compilation fixtures with their existing contracts.
Keep deadlines, explicit concurrency coverage, authority checks, and
observable assertions intact. Account for the canonical injected provider
resolver owner introduced by #140667 in its exact static boundary inventory.

Release-note context: these repairs prevent silent account substitution,
lost retry context, stale relay connections, premature CLI process reuse,
and Doctor migration ordering failures. This forward-port carries the
reviewed release validation repairs independently to main without changing
release versions or publication state.
steipete added a commit that referenced this pull request Sep 7, 2026
Retain missing explicit model-account selections through chat and command
admission, preserve durable user context on internal retries, and fail over
exhausted usage windows without delaying temporary throttles. Keep retired
hook listeners alive for their locator grace period and await host-owned
Claude process cleanup before replacement.

Preserve supplied lazy plugin runtime services and Gateway protocol aliases.
Refuse unreadable shared state before Doctor update admission, migrate
credentials before model-route repair, and release staged QA auth-store
leases before child maintenance.

Align isolated Doctor, Claws, Discord, plugin, UI permission, compaction,
yield, and Windows worker-compilation fixtures with their existing contracts.
Keep deadlines, explicit concurrency coverage, authority checks, and
observable assertions intact. Account for the canonical injected provider
resolver owner introduced by #140667 in its exact static boundary inventory.

Release-note context: these repairs prevent silent account substitution,
lost retry context, stale relay connections, premature CLI process reuse,
and Doctor migration ordering failures. This forward-port carries the
reviewed release validation repairs independently to main without changing
release versions or publication state.
steipete added a commit that referenced this pull request Sep 7, 2026
…0973)

* fix: preserve runtime ownership across auth and recovery paths

Retain missing explicit model-account selections through chat and command
admission, preserve durable user context on internal retries, and fail over
exhausted usage windows without delaying temporary throttles. Keep retired
hook listeners alive for their locator grace period and await host-owned
Claude process cleanup before replacement.

Preserve supplied lazy plugin runtime services and Gateway protocol aliases.
Refuse unreadable shared state before Doctor update admission, migrate
credentials before model-route repair, and release staged QA auth-store
leases before child maintenance.

Align isolated Doctor, Claws, Discord, plugin, UI permission, compaction,
yield, and Windows worker-compilation fixtures with their existing contracts.
Keep deadlines, explicit concurrency coverage, authority checks, and
observable assertions intact. Account for the canonical injected provider
resolver owner introduced by #140667 in its exact static boundary inventory.

Release-note context: these repairs prevent silent account substitution,
lost retry context, stale relay connections, premature CLI process reuse,
and Doctor migration ordering failures. This forward-port carries the
reviewed release validation repairs independently to main without changing
release versions or publication state.

* test(doctor): assert manual recovery for unreadable state

Match the current manual recovery contract: require process-stop and verified-backup guidance, and reject a misleading repeat-Doctor loop. Preserve the database bytes, failure cause, selected path, and no-migration assertions. Both old command-copy expectations reproduced failures after the rebase; all six admission cases, scoped checks, and P2 review now pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
…nclaw#140973)

* fix: preserve runtime ownership across auth and recovery paths

Retain missing explicit model-account selections through chat and command
admission, preserve durable user context on internal retries, and fail over
exhausted usage windows without delaying temporary throttles. Keep retired
hook listeners alive for their locator grace period and await host-owned
Claude process cleanup before replacement.

Preserve supplied lazy plugin runtime services and Gateway protocol aliases.
Refuse unreadable shared state before Doctor update admission, migrate
credentials before model-route repair, and release staged QA auth-store
leases before child maintenance.

Align isolated Doctor, Claws, Discord, plugin, UI permission, compaction,
yield, and Windows worker-compilation fixtures with their existing contracts.
Keep deadlines, explicit concurrency coverage, authority checks, and
observable assertions intact. Account for the canonical injected provider
resolver owner introduced by openclaw#140667 in its exact static boundary inventory.

Release-note context: these repairs prevent silent account substitution,
lost retry context, stale relay connections, premature CLI process reuse,
and Doctor migration ordering failures. This forward-port carries the
reviewed release validation repairs independently to main without changing
release versions or publication state.

* test(doctor): assert manual recovery for unreadable state

Match the current manual recovery contract: require process-stop and verified-backup guidance, and reject a misleading repeat-Doctor loop. Preserve the database bytes, failure cause, selected path, and no-migration assertions. Both old command-copy expectations reproduced failures after the rebase; all six admission cases, scoped checks, and P2 review now pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations extensions: codex maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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