Skip to content

refactor(gateway): remove workspace plugin generation projections - #125990

Merged
steipete merged 2 commits into
mainfrom
steipete/gateway-plugin-generation-cleanup
Aug 18, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/gateway-plugin-generation-cleanup

Conversation

@steipete

@steipete steipete commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Related: #125595
Follow-up to #125596

What Problem This Solves

Fixes the remaining ownership ambiguity after the Gateway event-loop stall repair: reply and post-turn compaction paths could still infer or project plugin metadata from an agent workspace instead of carrying the Gateway generation that admitted the turn.

Why This Change Was Made

Gateway reply execution and native-harness compaction now receive the exact published plugin generation explicitly. With those callers migrated, this deletes the workspace-root probe, cross-workspace metadata projection, and configured-owner inference fallback while preserving standalone cold discovery, including the shipped workspace plugin contract.

This is an AI-assisted maintainer follow-up to the active production incident repair.

User Impact

No new configuration or user workflow is introduced. Gateway turns keep one lifecycle-owned plugin generation through reply execution and compaction, and request-time code has fewer paths that can rediscover plugin metadata on the event loop.

Production code shrinks by 142 lines; tests and support shrink by 44 lines.

Evidence

  • Focused branch Vitest: 9 files across 4 shards, 502 tests passed.
  • pnpm build: passed in 6m03.8s; the subsequent commit changed only the retained regression test.
  • pnpm lint:core: passed.
  • Database-first, media-download, runtime-sidecar, import-cycle, webhook-body, and pairing-scope guards: passed.
  • Changed-gate typechecks, formatting, dead-export scan, plugin boundaries, assertion ratchet, and dependency guards: passed. The monolithic wrapper exceeded the 10-minute harness ceiling after those completed, so the remaining guards were run directly and passed.
  • Fresh branch autoreview: clean, no accepted/actionable findings.
  • Exact-head CI caught one retained test still acquiring a dynamic Gateway runtime without the explicit generation; the test now models the real admitted caller and passes the published generation.
  • Diff: production +37/-179 (net -142); test/support +77/-121 (net -44).

@clawsweeper

clawsweeper Bot commented Aug 18, 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 agents Agent runtime and tooling size: M labels Aug 18, 2026
@steipete
steipete marked this pull request as ready for review August 18, 2026 20:21
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Aug 18, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 18, 2026, 4:29 PM ET / 20:29 UTC.

ClawSweeper review

What this changes

This PR removes workspace-derived plugin-generation projections and passes the Gateway-admitted plugin generation through reply execution and post-turn compaction.

Merge readiness

⛔ Blocked by patch quality or review findings - 7 items remain

Keep open: this focused follow-up is not on current main, but it regresses enabled workspace-origin plugins for Gateway replies whose reply workspace differs from the configured agent workspace.

Priority: P1
Reviewed head: 299b35b0fe9f37b996b7abcac6af2801c20bce11
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The refactor has a concrete P1 compatibility regression despite focused validation evidence.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied focused test and build evidence remains supplemental.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied focused test and build evidence remains supplemental.
Evidence reviewed 5 items Cross-workspace reply regression: The new reply lease always receives the configured dispatch generation, so it cannot discover an enabled plugin located only in a different reply workspace.
Current behavior distinguishes workspace plugins: Current main probes the reply workspace and only reuses the configured generation when that workspace has no plugin root; otherwise it builds the workspace-specific graph.
Documented plugin contract: Documentation says workspace-origin plugins are discovered from <workspace>/.openclaw/extensions and may be explicitly enabled.
Findings 1 actionable finding [P1] Preserve workspace plugins for cross-workspace replies
Security None None.

Live Verification

Command: node --import tsx scripts/bench-gateway-concurrency.ts --entry dist/entry.js --concurrency 8 --plugin-count 100 --workspace-fanout --tool-events --runs 1 --warmup 0 --cadence-ms 50 --timeout-ms 180000 --max-control-ms 500 --max-handshake-ms 1000

Result: FAIL (partial) — step 3 expect_output pluginMetadataScanCount: expected terminal output was not visible within 30 seconds: "pluginMetadataScanCount"

node --import tsx scripts/bench-gateway-concurrency.ts --entry dist/entry.js --concurrency 8 --plugin-count 100 --workspace-fanout --tool-events --runs 1 --warm
up 0 --cadence-ms 50 --timeout-ms 180000 --max-control-ms 500 --max-handshake-ms 1000
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-125990-T6gGB9/target$ node --import tsx scripts/bench-gateway-concurrency.ts --entry dist/entry.js --concurrenc
y 8 --plugin-count 100 --workspace-fanout --tool-events --runs 1 --warmup 0 --cadence-ms 50 --timeout-ms 180000 --max-control-ms 500 --max-handshake-ms 1000
pnpm build
Error: gateway did not become ready
node:internal/modules/cjs/loader:1520
  throw err;
  ^

Error: Cannot find module '/tmp/clawsweeper-live-proof-125990-T6gGB9/target/dist/entry.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1517:15)
    at wrapResolveFilename (node:internal/modules/cjs/loader:1071:27)
    at defaultResolveImplForCJSLoading (node:internal/modules/cjs/loader:1095:10)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1122:12)
    at Module._load (node:internal/modules/cjs/loader:1294:5)
    at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
    at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
    at node:internal/main/run_main_module:33:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v24.19.0

gateway stderr tail:
node:internal/modules/cjs/loader:1520
  throw err;
  ^

Error: Cannot find module '/tmp/clawsweeper-live-proof-125990-T6gGB9/target/dist/entry.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1517:15)
    at wrapResolveFilename (node:internal/modules/cjs/loader:1071:27)
    at defaultResolveImplForCJSLoading (node:internal/modules/cjs/loader:1095:10)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1122:12)
    at Module._load (node:internal/modules/cjs/loader:1294:5)
    at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
    at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
    at node:internal/main/run_main_module:33:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v24.19.0
gateway output tail:
node:internal/modules/cjs/loader:1520
  throw err;
  ^

Error: Cannot find module '/tmp/clawsweeper-live-proof-125990-T6gGB9/target/dist/entry.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1517:15)
    at wrapResolveFilename (node:internal/modules/cjs/loader:1071:27)
    at defaultResolveImplForCJSLoading (node:internal/modules/cjs/loader:1095:10)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1122:12)
    at Module._load (node:internal/modules/cjs/loader:1294:5)
    at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
    at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
    at node:internal/main/run_main_module:33:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v24.19.0

mock provider output tail:
mock-openai listening on 35841

    at runGatewaySample (/tmp/clawsweeper-live-proof-125990-T6gGB9/target/scripts/bench-gateway-concurrency.ts:958:11)
    at async runBenchmarkSamples (/tmp/clawsweeper-live-proof-125990-T6gGB9/target/scripts/bench-gateway-concurrency.ts:1033:17)
    at async main (/tmp/clawsweeper-live-proof-125990-T6gGB9/target/scripts/bench-gateway-concurrency.ts:1055:16)
[bench-gateway-concurrency] FAILED (exit 1)
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-125990-T6gGB9/target$ pnpm build
$ node --import tsx scripts/build-all.mts
node --import tsx scripts/bench-gateway-concurrency.ts --entry dist/entry.js --concurrency 8 --plugin-count 100 --workspace-fanout --tool-events --runs 1 --warm
up 0 --cadence-ms 50 --timeout-ms 180000 --max-control-ms 500 --max-handshake-ms 1000
[build-all] plugins:assets:build
$ node --import tsx scripts/bundled-plugin-assets.mts --phase build
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹
… output truncated …

Assertions:

  • FAIL expect_output: pluginMetadataScanCount

How this fits together

Gateway startup publishes plugin metadata for configured agents; reply and compaction paths later acquire prepared runtimes to run models and plugins. The change makes that generation explicit across those downstream paths.

flowchart LR
  A[Gateway startup] --> B[Published plugin generation]
  B --> C[Admitted agent turn]
  C --> D[Reply workspace]
  C --> E[Post-turn compaction]
  D --> F[Prepared runtime lease]
  E --> F
  F --> G[Plugin and model execution]
Loading

Decision needed

Question Recommendation
Should Gateway replies continue to honor enabled workspace-origin plugins when their reply workspace differs from the configured agent workspace? Preserve the workspace-plugin contract: Prepare and carry the appropriate workspace generation before reply execution, with a regression test for an enabled workspace-origin plugin.

Why: Current behavior and documentation support that workspace contract, while this refactor intentionally removes the mechanism that distinguishes such workspaces; the replacement ownership model needs maintainer direction.

Before merge

  • Preserve workspace plugins for cross-workspace replies (P1) - When context.workspaceDir differs from the configured workspace, this always supplies the configured generation. Current main deliberately declines that reuse if the reply workspace has .openclaw/extensions, so an enabled plugin there is no longer discovered or executed. Preserve that contract with a workspace-appropriate admitted generation and a regression test.
  • Resolve merge risk (P1) - Merging as written can silently omit enabled workspace-origin plugins for affected Gateway replies.
  • Resolve merge risk (P1) - The native Codex compaction path is touched, but the required sibling Codex source was unavailable locally and network DNS prevented fetching it; that external contract needs maintainer-side verification.
  • Improve patch quality - Preserve enabled workspace-origin plugins for cross-workspace Gateway replies and add a regression test.
  • Improve patch quality - Rebase onto current main and rerun exact-head Gateway, reply, and compaction validation.
  • Improve patch quality - Verify the touched Codex compaction boundary against the required Codex source checkout.

Findings

  • [P1] Preserve workspace plugins for cross-workspace replies — src/auto-reply/reply/get-reply-run.ts:44
Agent review details

Security

None.

PR surface

Source -139, Tests -51, Other -1. Total -191 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 11 40 179 -139
Tests 7 68 119 -51
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 19 108 299 -191

Review metrics

Metric Value Why it matters
Production vs test delta production -142, test/support -49 The refactor substantially removes hot-path projection code, so the remaining generation boundary must retain existing workspace-plugin behavior.

Stored data model

Persistent data-model change detected: serialized state: src/agents/prepared-model-runtime-lease.ts, unknown-data-model-change: src/auto-reply/reply/get-reply-run.prepared-metadata.test.ts, unknown-data-model-change: src/plugins/plugin-metadata-snapshot.test.ts, unknown-data-model-change: src/plugins/plugin-metadata-snapshot.ts, vector/embedding metadata: src/auto-reply/reply/get-reply-run.prepared-metadata.test.ts, vector/embedding metadata: src/plugins/plugin-metadata-snapshot.test.ts, and 2 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Keep cross-workspace plugins functional (recommended)
    Carry a workspace-appropriate lifecycle generation into the reply path and add an enabled workspace-plugin regression test before merge.
  2. Accept a documented behavior narrowing
    Approve removal of cross-workspace Gateway plugin support only with explicit user-facing migration and upgrade guidance.

Technical review

Best possible solution:

Preserve the documented workspace-plugin behavior by selecting a workspace-appropriate generation at an explicit lifecycle/admission boundary, then carry that fact through reply execution without request-time discovery.

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

Yes: current main explicitly avoids reusing the configured generation when a different reply workspace has a plugin root, while the branch always supplies that generation; an enabled workspace plugin exercises the divergent path.

Is this the best way to solve the issue?

No: the explicit carrier is appropriate for pluginless cross-workspace replies, but it bypasses the existing workspace-plugin contract instead of giving that workspace an owner-bound generation.

Full review comments:

  • [P1] Preserve workspace plugins for cross-workspace replies — src/auto-reply/reply/get-reply-run.ts:44
    When context.workspaceDir differs from the configured workspace, this always supplies the configured generation. Current main deliberately declines that reuse if the reply workspace has .openclaw/extensions, so an enabled plugin there is no longer discovered or executed. Preserve that contract with a workspace-appropriate admitted generation and a regression test.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: An existing Gateway reply path can lose enabled workspace-origin plugins.
  • add merge-risk: 🚨 compatibility: The branch changes established workspace plugin behavior for existing Gateway configurations.
  • add merge-risk: 🚨 availability: This follows a Gateway hot-path stall repair, so an incorrect ownership replacement can affect live turn execution.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied focused test and build evidence remains supplemental.

Label justifications:

  • P1: An existing Gateway reply path can lose enabled workspace-origin plugins.
  • merge-risk: 🚨 compatibility: The branch changes established workspace plugin behavior for existing Gateway configurations.
  • merge-risk: 🚨 availability: This follows a Gateway hot-path stall repair, so an incorrect ownership replacement can affect live turn execution.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied focused test and build evidence remains supplemental.

Evidence

What I checked:

Likely related people:

  • steipete: Authored both the merged Gateway metadata-stall repair and this follow-up cleanup. (role: recent area contributor; confidence: high; commits: fd216cb5509e, 299b35b0fe9f; files: src/agents/prepared-model-runtime-lease.ts, src/plugins/plugin-metadata-snapshot.ts, src/auto-reply/reply/get-reply-run.ts)

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification for exact head 94584e8404d82c4738c4e4e13496b9438347eb94:

Commands run:

node scripts/run-vitest.mjs src/auto-reply/reply/get-reply-run.prepared-metadata.test.ts src/auto-reply/reply/get-reply.config-override.test.ts src/auto-reply/reply/dispatch-from-config.test.ts src/agents/command/cli-compaction.test.ts src/agents/agent-command.compaction-rotation.test.ts src/agents/prepared-model-runtime.lifecycle.test.ts src/agents/prepared-model-runtime.plugin-context.test.ts src/plugins/plugin-metadata-snapshot.test.ts
node scripts/run-vitest.mjs src/agents/prepared-model-runtime.inbound-registry.test.ts
pnpm build
pnpm lint:core
pnpm check:database-first-legacy-stores && pnpm check:media-download-helpers && pnpm check:runtime-sidecar-loaders && pnpm check:import-cycles && pnpm lint:webhook:no-low-level-body-read && pnpm lint:auth:no-pairing-store-group && pnpm lint:auth:pairing-account-scope

The first CI attempt hit GitHub 429s while downloading actions/checkout; its rerun also exposed one retained auth-refresh test that still modeled the deleted inferred-generation path. That test now passes the configured generation explicitly, and the corrected exact-head CI run is green.

Proof gap: this cleanup has not yet been deployed independently. The underlying event-loop repair from #125596 is already live and measured; after merge, I will deploy this final cleanup and repeat the production soak before closing #125595.

@steipete
steipete merged commit fa62fcc into main Aug 18, 2026
228 checks passed
@steipete
steipete deleted the steipete/gateway-plugin-generation-cleanup branch August 18, 2026 21:03
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant