Skip to content

fix(agents): keep gateway prepared runtimes on built plugin artifacts - #126226

Closed
vincentkoc wants to merge 1 commit into
mainfrom
fix/gateway-built-plugin-artifacts
Closed

vincentkoc wants to merge 1 commit into
mainfrom
fix/gateway-built-plugin-artifacts

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

Related: #125595

Successor to #125957, whose contributor branch is not maintainer-editable. This keeps Dallin Romney's original diagnosis and implementation credit; the commit includes Dallin as co-author.

What Problem This Solves

Fixes an issue where Gateway-prepared agent turns could synchronously compile bundled plugin source even after Gateway startup selected built plugin artifacts. On current main, the affected prepared-runtime path performs 82 forced source transforms and spends roughly 23-27 seconds preparing runtime plugins.

Why This Change Was Made

The built-artifact choice is now an explicit literal Gateway lifecycle fact carried through prepared owner input, generation identity, initial registry loading, reused generations, and deferred load context. It is never inferred from metadata, provenance, catalogs, bindings, or global state, so standalone and direct prepared runtimes remain source-default.

This is the narrow owner-boundary repair requested by the ClawSweeper review on #125957. An exact-head local review also found that a reused Gateway plugin generation could overwrite its attached built-artifact context with a flagless run projection; the final head preserves the immutable generation-owned true fact and adds a red/green reuse regression.

User Impact

Gateway agent turns can reuse the built plugin artifacts selected at startup instead of blocking on source transforms during initial or deferred plugin loading. Source-development and standalone runtime behavior is unchanged.

No config, environment, protocol, persistent schema, storage, Plugin SDK, public API, timeout, retry, or eager-preload behavior changes.

Production LOC: +30/-2 (net +28) for the explicit lifecycle ownership boundary.
Tests and build-smoke support: +61/-22 (net +39).

Evidence

  • Current-main artifact-only performance reproduction, repeat 3: https://github.com/openclaw/openclaw/actions/runs/32222388432
    • 165 sidecar loader calls
    • 83 native artifact hits
    • 82 forced source transforms
    • roughly 23-27 seconds in prepared runtime-plugin loading
    • source startup probe failed readiness while the artifact-only guard passed
  • Exact-head focused proof on e4ad9334b4c06924a5860f49e7cdb674815cad14:
    • prepared-model-runtime.owner-selection.test.ts: 22 tests passed, including the branch-local CI regression
    • directly affected runtime lifecycle, registry, and context coverage: 88 tests passed across 4 files
  • Packaged Gateway composition on predecessor 6f30d3f1fe3afeccd9eab8af3ccaa3de3d7977a8:
    • Gateway prepared runtime -> reused dynamic owner -> deferred diffs tool
    • 8 native artifact hits
    • 0 native misses
    • 0 forced source transforms
    • 0 source-transform fallbacks
    • the successor head changes only the configured-owner lookup guard; it does not change artifact loading or deferred-tool composition
  • pnpm test:build:singleton passed from the emitted 6f30d3f1fe3afeccd9eab8af3ccaa3de3d7977a8 artifacts.
  • Local pnpm build emitted those artifacts, then its control-plane postbuild check hit a stale linked @openclaw/ai install missing current exports. The packaged proof used the built workspace package in an ignored local resolution overlay; shared dependencies and source were not modified.
  • Earlier Blacksmith Testbox build/singleton baseline: https://github.com/openclaw/openclaw/actions/runs/32224547889
    • provider blacksmith-testbox
    • lease tbx_01m0cc3gnjcfcc3ajk68ar6qqm
    • pnpm build and pnpm test:build:singleton passed after the f92e9367e8c79e55041728d9f8c21f18fcaf7d3e managed-cache repair
  • node scripts/check-changed.mjs passed all guards, formatting, boundaries, dead-code checks, and core production typecheck, then captured the unrelated existing Control UI test-type error at ui/src/pages/chat/route-loader.ts:712 (literalSessionKey). This PR does not modify that surface.
  • git diff --check passed.

The branch-local CI failure on 6f30d3f1fe3afeccd9eab8af3ccaa3de3d7977a8 was caused by a fully specified configured-owner reader omitting the Gateway-owned artifact preference bit. The resolver required exact identity before reaching its existing configured-owner wildcard match, while acquisition correctly rebound the same input. The final head lets only an absent artifact preference reach that configured-owner match; explicit artifact identities and standalone owners remain exact.

Base proof was completed on f92e9367e8c79e55041728d9f8c21f18fcaf7d3e. Later main drift through cb5c061cb36a does not overlap the reviewed prepared-model-runtime or artifact-selection owner files, so the exact-head proof was preserved without a drift-only rebase.

Punchcard-Session: frost-orchard-lantern-ze

@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 19, 2026
@vincentkoc vincentkoc self-assigned this Aug 19, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. 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 19, 2026
@clawsweeper

clawsweeper Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 7:18 AM ET / 11:18 UTC.

ClawSweeper review

What this changes

The PR preserves Gateway-selected built plugin artifacts through prepared agent runtime ownership, registry reuse, and deferred plugin-tool loading.

Regression provenance

Possible regression — probable (reviewed change; reproduction). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open: current main still lacks this lifecycle fact, while the PR consistently carries it into prepared registries and deferred plugin-tool loads. No blocking code finding; land only after exact-head required CI is green and the packaged smoke is confirmed on this head.

Priority: P1
Reviewed head: e4ad9334b4c06924a5860f49e7cdb674815cad14

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The owner-boundary fix and focused coverage are solid; exact-head packaged confirmation and green required CI remain the material merge checks.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless includes packaged artifact-smoke evidence and exact-head focused coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless includes packaged artifact-smoke evidence and exact-head focused coverage.
Evidence reviewed 6 items Gateway lifecycle boundary: The refreshed Gateway lifecycle adds the artifact preference only to configured owners, leaving standalone inputs source-default.
Deferred-load propagation: The attached prepared registry context retains the preference, and the shared load-options builder forwards it to plugin loading used by deferred tools.
Regression coverage: The owner-selection test publishes a Gateway owner with the preference and proves a flagless reader still resolves it; adjacent tests cover replacement publication, reuse, direct-host absence, and loader forwarding.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/agents/prepared-model-runtime.owner-selection.test.ts

Result: FAIL (partial) — step 2 expect_output prepared model runtime owner selection: expected terminal output was not visible within 30 seconds: "prepared model runtime owner selection"

node scripts/run-vitest.mjs src/agents/prepared-model-runtime.owner-selection.test.ts
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-126226-dr9523/target$ node scripts/run-vitest.mjs src/agents/prepared-model-runtime.owner-selection.test.ts
node scripts/run-vitest.mjs src/agents/prepared-model-runtime.owner-selection.test.ts
[test] starting test/vitest/vitest.agents-core.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-126226-dr9523/target

 ✓  agents-core  src/agents/prepared-model-runtime.owner-selection.test.ts (22 tests) 1023ms
     ✓ serializes live catalog sources for owners sharing one agent directory  683ms

 Test Files  1 passed (1)
      Tests  22 passed (22)
   Start at  11:19:52
   Duration  11.18s (transform 7.92s, setup 1.04s, import 8.75s, tests 1.02s, environment 0ms)

[test] passed 1 Vitest shard in 17.18s
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-126226-dr9523/target$ node scripts/run-vitest.mjs src/agents/prepared-model-runtime.owner-selection.test.ts
[test] starting test/vitest/vitest.agents-core.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-126226-dr9523/target

 ✓  agents-core  src/agents/prepared-model-runtime.owner-selection.test.ts (22 tests) 996ms
     ✓ serializes live catalog sources for owners sharing one agent directory  663ms

 Test Files  1 passed (1)
      Tests  22 passed (22)
   Start at  11:20:10
   Duration  5.68s (transform 2.57s, setup 500ms, import 3.94s, tests 996ms, environment 0ms)

[test] passed 1 Vitest shard in 11.67s
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-126226-dr9523/target$




















Assertions:

  • FAIL expect_output: prepared model runtime owner selection

How this fits together

Gateway startup prepares agent runtime snapshots and plugin registries for later turns. Those snapshots feed deferred plugin-tool loads, which should reuse the artifact choice made at startup rather than recompiling plugin source.

flowchart LR
  A[Gateway startup] --> B[Prepared runtime owner]
  B --> C[Built-artifact preference]
  C --> D[Plugin registry and load context]
  D --> E[Deferred plugin-tool load]
  E --> F[Built plugin artifact]
Loading

Before merge

  • Resolve merge risk (P1) - Prepared-runtime identities and deferred load contexts are availability-sensitive; a missed projection could restore synchronous source transforms on a Gateway turn.
  • Resolve merge risk (P1) - The repair adds production propagation across several lifecycle boundaries (+28 net), so the exact-head packaged path and required CI need to be green before landing.
  • Complete next step (P2) - No repair lane is needed: no actionable patch defect was found, and this maintainer-labelled PR needs normal exact-head CI and packaged-proof review.
Agent review details

Security

None.

PR surface

Source +32, Tests +29, Other +6. Total +67 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 8 34 2 +32
Tests 4 34 5 +29
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 23 17 +6
Total 13 91 24 +67

Review metrics

Metric Value Why it matters
Production versus test delta production +30/-2 (net +28); tests and test support +61/-22 (net +39) The added production lines carry one lifecycle fact through separate owner and loader boundaries; the accompanying coverage exercises those projections.

Stored data model

Persistent data-model change detected: persistent cache schema: scripts/test-built-plugin-singleton.mts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify the final packaged lifecycle path (recommended)
    Run the packaged prepared-runtime-to-deferred-tool smoke on this exact head and require the currently failed required checks to turn green before merge.

Technical review

Best possible solution:

Keep one Gateway-owned artifact fact in the prepared runtime input and verify the final packaged Gateway-to-deferred-tool path; the distinct owner, key, registry, and context boundaries make a net-neutral absorption impractical without reopening a source-default route.

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

No live reproduction was run in this read-only review, but current-main source lacks the propagated preference and the owner/loader path is directly traceable; the PR also supplies a packaged reproduction record.

Is this the best way to solve the issue?

Yes. Recording the selection at the Gateway lifecycle owner and carrying it through existing identity, registry, and load-context seams is narrower and safer than adding a new config option or a deferred-load fallback.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4af09d4961c9.

Labels

Label justifications:

  • P1: A Gateway turn can otherwise block while bundled plugin source is transformed instead of using already-selected artifacts.
  • merge-risk: 🚨 availability: This changes the runtime artifact-selection path used by prepared Gateway turns and deferred plugin loads, where an omitted projection can reintroduce a long stall.
  • 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. Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless includes packaged artifact-smoke evidence and exact-head focused coverage.

Evidence

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the earlier prepared load-context and inbound-registry performance work and dominates available history across the affected files. (role: primary recent area contributor; confidence: high; commits: a6e0002ecac0, 192885c4e811; files: src/agents/prepared-model-runtime.plugin-context.ts, src/agents/prepared-model-runtime.inbound-registry.ts)
  • fuller-stack-dev: Jason (Json) authored the Gateway prepared-runtime startup-boundary work that this change extends. (role: recent adjacent contributor; confidence: medium; commits: a67ad03eea4b; files: src/agents/prepared-model-runtime.ts)

Rank-up moves

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

  • Verify the packaged Gateway prepared-runtime-to-deferred-tool smoke on the exact head.
  • Resolve or rerun the failed required exact-head checks 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-19T06:54:41.784Z sha 97beaa5 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc force-pushed the fix/gateway-built-plugin-artifacts branch from 97beaa5 to 6f30d3f Compare August 19, 2026 08:21
@vincentkoc
vincentkoc marked this pull request as ready for review August 19, 2026 08:22
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact-head proof and the reused-generation regression fix are now on 6f30d3f1fe3afeccd9eab8af3ccaa3de3d7977a8. The PR body records the packaged Gateway prepared-runtime -> reused owner -> deferred-tool composition: 8 native artifact hits, 0 native misses, 0 forced source transforms, and 0 transform fallbacks.

@clawsweeper

clawsweeper Bot commented Aug 19, 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:

Co-authored-by: Dallin Romney <[email protected]>
Punchcard-Session: frost-orchard-lantern-ze
@vincentkoc
vincentkoc force-pushed the fix/gateway-built-plugin-artifacts branch from 6f30d3f to e4ad933 Compare August 19, 2026 08:42
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact-head CI's configured-owner lookup regression is fixed on e4ad9334b4c06924a5860f49e7cdb674815cad14. The failing owner-selection file passes 22 tests, and 88 directly affected prepared-runtime lifecycle/registry/context tests pass. The one-line owner guard keeps production net +28; the PR body has the root cause and updated proof.

@clawsweeper

clawsweeper Bot commented Aug 19, 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:

@vincentkoc

Copy link
Copy Markdown
Member Author

Superseded by #125957, landed on main as ef91c81.

The landed squash commit preserves Dallin Romney as the commit author and retains Amp as co-author. #125957 is now the canonical owner-boundary repair, so this successor is no longer needed.

@vincentkoc vincentkoc closed this Aug 21, 2026
@RomneyDa
RomneyDa deleted the fix/gateway-built-plugin-artifacts branch October 22, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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