Skip to content

perf(plugins): read the generation registry from its leaf module - #206565

Merged
obviyus merged 1 commit into
mainfrom
perf/generation-state-leaf
Nov 27, 2026
Merged

obviyus merged 1 commit into
mainfrom
perf/generation-state-leaf

Conversation

@obviyus

@obviyus obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Problem

getPluginRuntimeGenerationRegistry lives in src/plugins/runtime/generation-state.ts, but generation-scope.ts re-exports it, and callers imported it from there. generation-scope also loads metadata snapshots, invocation frames and registry creation. src/agents/harness/registry-lifecycle.ts needs only the getter, yet it pulls that graph into the agent SQLite store worker of every one-shot openclaw agent --local turn.

Change

  • Every caller of getPluginRuntimeGenerationRegistry (6 production modules, 22 tests/test-support files) imports it from generation-state.js. Mocks that supplied the getter through a generation-scope mock now mock generation-state, so they still reach the code under test.
  • Delete the re-export from generation-scope.ts. Other generation-scope symbols are unchanged.

No behavior change: the getter is the same function.

Evidence

  • Module loads per thread before the first provider request, one fake-provider agent --local turn with a resolve/load trace in every thread, same base (main 238c6da vs 238c6da + this change), 2 runs each with identical counts: agent SQLite store worker 1,999 -> 1,915; all threads 14,870 -> 14,792.
  • rg getPluginRuntimeGenerationRegistry over src/extensions/packages/test: every reference resolves to generation-state.
  • Tests: one ocx test call over the 211 changed and importer test files: 2,819 passed, 1 skipped. Format and type-aware oxlint clean on all 29 changed files.
  • The test(cli): gate agent --local cold-start processes and workers #206466 gate counts processes, spawns and worker threads; none change here, so its budget is unchanged.

- Move every getPluginRuntimeGenerationRegistry caller and mock from generation-scope to generation-state and delete the re-export.
- The agent SQLite store worker no longer loads the full generation-scope graph (84 fewer modules before the first request).
@clawsweeper

clawsweeper Bot commented Nov 27, 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 gateway Gateway runtime commands Command implementations agents Agent runtime and tooling size: S labels Nov 27, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:other This issue has meaningful maintainer-visible impact outside the owned taxonomy. labels Nov 27, 2026
@vincentkoc vincentkoc self-assigned this Nov 27, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR imports the generation-registry getter directly from its leaf module and removes its heavier re-export.

Example: A one-shot openclaw agent --local turn reaches its first provider request.

  • Before: The PR reports 1,999 module loads in the agent SQLite store worker.
  • After: The same traced scenario reports 1,915 module loads with the import changes.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused performance improvement with production-path count evidence, preserved tests, and no actionable defects; exact-head CI is still completing.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR reports resolve/load tracing through the shipped agent --local path against a fake provider, with two matching runs per revision showing reduced worker and aggregate imports; this supports the claimed work reduction without establishing a latency improvement.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: One-shot local agent turns load unnecessary plugin metadata machinery before contacting the provider.
Reason: The maintainer-authored direction removes measured work without adding state, configuration, dependencies, or a competing registry owner.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR removes unnecessary cold-start imports through a complete internal cutover, with no actionable correctness or security defects found.

Reviewed head: 82632d45b4da11394d008e5368625fea2fbf8d4f

Before merge

None.

Findings

None.

Agent review details

How this fits together

Plugin runtime readers obtain the registry selected by the current execution frame; harness lifecycle, provider discovery, hooks, and session initialization consume that registry without needing metadata-scope construction.

flowchart TD
  A[Local agent turn] --> B[Agent SQLite store worker]
  B --> C[Harness lifecycle reader]
  C --> D[Generation state leaf]
  D --> E[Plugin execution frame]
  E --> F[Selected generation registry]
Loading

Technical review

Best possible solution:

Use the existing leaf getter everywhere while preserving generation-scope construction and all registry-selection behavior.

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

Current-main source shows the harness importing metadata-scope machinery solely to obtain the registry getter; the PR supplies repeated CLI module-load measurements supporting that unnecessary work.

Is this the best way to solve the issue?

This is the smallest complete repair: reuse the existing lightweight owner, migrate callers and mocks, and remove the import path that encouraged the excess loading.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Lightweight generation-registry reads keeps the original intent (ccd3a44: The registry state was extracted into a leaf module to keep retained reads independent of metadata discovery and plugin loading.)
  • Composed runtime execution frames keeps the original intent (1418ad7: perf(plugins): compose async runtime scopes #152602 composed generation fields into the existing invocation frame while preserving identity, selection, and cleanup.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source -4, Tests -3. Total -7 across 29 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 8 8 12 -4
Tests 21 49 52 -3
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 29 57 64 -7

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 27, 2026, 5:19 AM ET / 10:19 UTC.

@obviyus
obviyus merged commit 7cf2cff into main Nov 27, 2026
169 checks passed
@obviyus
obviyus deleted the perf/generation-state-leaf branch November 27, 2026 10:23
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…nclaw#206565)

## Problem

`getPluginRuntimeGenerationRegistry` lives in `src/plugins/runtime/generation-state.ts`, but `generation-scope.ts` re-exports it, and callers imported it from there. `generation-scope` also loads metadata snapshots, invocation frames and registry creation. `src/agents/harness/registry-lifecycle.ts` needs only the getter, yet it pulls that graph into the agent SQLite store worker of every one-shot `openclaw agent --local` turn.

## Change

- Every caller of `getPluginRuntimeGenerationRegistry` (6 production modules, 22 tests/test-support files) imports it from `generation-state.js`. Mocks that supplied the getter through a `generation-scope` mock now mock `generation-state`, so they still reach the code under test.
- Delete the re-export from `generation-scope.ts`. Other `generation-scope` symbols are unchanged.

No behavior change: the getter is the same function.

## Evidence

- Module loads per thread before the first provider request, one fake-provider `agent --local` turn with a resolve/load trace in every thread, same base (main f353fd8 vs f353fd8 + this change), 2 runs each with identical counts: agent SQLite store worker 1,999 -> 1,915; all threads 14,870 -> 14,792.
- `rg getPluginRuntimeGenerationRegistry` over src/extensions/packages/test: every reference resolves to `generation-state`.
- Tests: one `ocx test` call over the 211 changed and importer test files: 2,819 passed, 1 skipped. Format and type-aware oxlint clean on all 29 changed files.
- The openclaw#206466 gate counts processes, spawns and worker threads; none change here, so its budget is unchanged.

Co-authored-by: Ayaan Zaidi <[email protected]>
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 gateway Gateway runtime impact:other This issue has meaningful maintainer-visible impact outside the owned taxonomy. 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: 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.

2 participants