Skip to content

refactor(plugin-sdk): promote shared runtime primitives - #126193

Merged
steipete merged 2 commits into
mainfrom
steipete/w7-sdk-promotions
Aug 19, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/w7-sdk-promotions

Conversation

@steipete

@steipete steipete commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Bundled plugins had accumulated local copies of four already-owned primitives: path containment, UTF-8 prefix truncation, fixed-size chunking, and object-record guards. Those copies made small semantic fixes easy to miss across sibling plugins and encouraged new imports from the deprecated broad security runtime.

Why This Change Was Made

This promotes inclusive and strict-child containment through openclaw/plugin-sdk/file-access-runtime, promotes truncateUtf8Prefix through text-utility-runtime, and migrates the requested bundled plugin adopters to those focused SDK seams plus the existing chunking and record-coercion helpers.

Existing realpath checks and inclusive-versus-strict containment decisions remain at their original call sites. Object-backed array semantics remain where they previously existed. Codex/OpenShell virtual sandbox namespaces, the embedded Codex remote reader script, and Browser Relay's duplicate-key-aware strict JSON parser remain local because their contracts are intentionally different.

Migration inventory

Primitive Migrated Kept local
Path containment QA Lab (4), Codex (4), Memory Wiki (3), Browser (2), Memory Core (2), ACPX, Anthropic, Canvas, Feishu, Lobster, migrate-hermes, MXC, WhatsApp OpenShell/Codex virtual namespace checks and the embedded Codex remote reader script; they operate in sandbox/remote path dialects rather than host filesystem containment
UTF-8 prefix truncation Browser, Codex (2), Memory Wiki, Mattermost None among the requested sites
Chunking Slack (2), Telegram (2), Buzz, Memory Core Telegram's start-aware surrogate boundary helper remains for proportional rich-block/entity slicing, which is not fixed-size chunking
Record guards Google (2), Codex (2), QA Lab (2), Browser storage, File Transfer, Voice Call Browser Relay strict JSON parsing; it rejects duplicate keys before parsing. File Transfer and Voice Call use asOptionalObjectRecord where arrays were historically accepted

The cleanup also made extensions/memory-wiki/src/markdown.ts small enough to remove its grandfathered max-lines suppression.

During exact-head CI, the freshly merged #126179 QA scenario failed twice because it required wire status=failed for a task whose authoritative domain state is internal succeeded (wire completed) plus terminalOutcome=blocked; delivery is independently delivered. Current main repaired that stale assertion in #125954. This branch was rebased onto that fix, so no unrelated QA change remains in this PR.

The next exact-head run exposed one current-main test-inventory gap: extensions/codex/src/app-server/run-attempt-tools.test.ts was not owned by any Vitest project. Three independent repairs then landed on main within minutes and claimed it in the attempt-light, attempt-extra, and app-server-tools shards. This PR rebased across that sequential registration race by retaining the focused attempt-light owner and deleting the two duplicate claims; #126236 subsequently landed the same single-owner result on main, so the cleanup is patch-equivalent in the final merge tree. It does not add or change product behavior.

User Impact

No user-visible behavior changes. Plugin maintainers get focused SDK imports with one canonical implementation, and the production diff removes 244 net lines.

Evidence

  • pnpm plugin-sdk:surface:check — passed; all 333 SDK entrypoints and 146 public package subpaths verified.
  • Focused plugin sweep: pnpm test extensions/acpx extensions/anthropic extensions/browser extensions/buzz extensions/canvas extensions/codex extensions/feishu extensions/file-transfer extensions/google extensions/lobster extensions/mattermost extensions/memory-core extensions/memory-wiki extensions/migrate-hermes extensions/mxc extensions/qa-lab extensions/slack extensions/telegram extensions/voice-call extensions/whatsapp — 97/98 shards passed on the first loaded-host run; the sole unrelated Telegram timing failure passed its exact rerun (3/3 tests).
  • pnpm check:changed — passed on the final diff. The first run correctly identified stale shrink-only assertion/max-lines baseline entries, which were pruned before the clean rerun.
  • node scripts/run-vitest.mjs test/vitest-projects-config.test.ts extensions/codex/src/app-server/run-attempt-tools.test.ts — 2 files / 21 tests passed (18 inventory ownership tests and 3 Codex tool tests).
  • pnpm build — passed in 7m29.8s, including all public SDK subpaths, external plugin local dists, runtime postbuild, and Control UI.
  • pnpm docs:check-mdx && pnpm docs:check-links — passed (778 docs files; 6,510 internal links; 0 broken).
  • .agents/skills/autoreview/scripts/autoreview --mode local ... — clean; no accepted/actionable findings.
  • Codex dependency contract checked directly in openai/codex: codex-rs/app-server-protocol/src/protocol/v2/thread.rs:57, :325, :509; codex-rs/app-server/src/bespoke_event_handling.rs:720, :991, :1211; codex-rs/protocol/src/plan_tool.rs:17; codex-rs/protocol/src/user_input.rs:15.
  • Exact-head CI run https://github.com/openclaw/openclaw/actions/runs/32220389343 failed QA Smoke CI (profile 3/6) twice on the stale fix(agents): record empty subagent completion delivery #126179 task-status assertion; all other checks passed. The exact scenario then passed locally with taskStatus=completed, taskTerminalOutcome=blocked, taskDeliveryStatus=delivered, one visible representation, and zero restart replay; current main landed the same correction in fix(build): rebuild incomplete managed-update cache hits #125954.
  • Exact-head CI run https://github.com/openclaw/openclaw/actions/runs/32225776918 passed every selected lane except checks-node-compact-large-22, whose inventory guard found the unowned Codex attempt-tools test. The focused 21-test proof above passes after registering it in the existing light shard.
  • Exact-head CI run https://github.com/openclaw/openclaw/actions/runs/32228027734 reproduced the subsequent three-owner current-main race in checks-node-compact-large-22. On current main, test/vitest-projects-config.test.ts failed with the exact duplicate owner list; after retaining only attempt-light, the same 18 ownership tests plus the 3 Codex tool tests passed.
  • node scripts/run-vitest.mjs extensions/qa-lab/src/scenario-catalog-channels.test.ts extensions/qa-lab/src/scenario-catalog.test.ts — 2 files / 74 tests passed.
  • The temporary local QA correction passed its fail-safe all lane before fix(build): rebuild incomplete managed-update cache hits #125954 superseded it; the final SDK-only current-base pnpm check:changed rerun also passed.
  • Final scoped autoreview — clean; no accepted/actionable findings (0.99 confidence).

Production LOC: +160/-404 (net -244) | Tests/test support: +0/-2 | Docs: +2/-2 | Ratchet maintenance: +6/-9

AI-assisted; the implementation, source contracts, diff, and proof were reviewed directly.

@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.

@steipete
steipete force-pushed the steipete/w7-sdk-promotions branch from 4762e00 to 8ebe631 Compare August 19, 2026 05:41
@steipete
steipete marked this pull request as ready for review August 19, 2026 05:41
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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, 3:35 AM ET / 07:35 UTC.

ClawSweeper review

What this changes

This PR exposes existing path, UTF-8, chunking, and record-coercion primitives through focused Plugin SDK facades and replaces duplicated bundled-plugin implementations.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. The central SDK refactor is not on current main, and source-level review found no blocking patch defect; the maintainer-owned PR needs its exact-head merge/CI refresh before landing.

Priority: P3
Reviewed head: e8892229be716352230d875b54136b937367a1a9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch uses existing canonical helpers with relevant source and regression coverage; current-head CI remains the merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal refactor is outside the external-contributor real-behavior-proof gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal refactor is outside the external-contributor real-behavior-proof gate.
Evidence reviewed 5 items Shared path contract: The new SDK exports point to the existing inclusive and strict containment helpers; their tests cover equality, descendants, traversal, lookalike paths, and Windows behavior.
Representative security callers: Browser, Codex, Memory, QA, and WhatsApp callers retain their prior inclusive-versus-strict decisions and retain realpath or fs-safe checks where required.
Text and chunking contract: The promoted UTF-8 helper preserves code-point-safe byte prefixes, while shared chunking preserves whitespace and surrogate-safe progress; existing Slack and Telegram tests cover their migrated boundaries.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

pnpm openclaw --helprunner@runnervmzvulz:/tmp/clawsweeper-live-proof-126193-Ud5OKj/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 400.66 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 106.74 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 13.9s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 4332ms (slowest: built plugin control-plane loads 3574ms)

OpenClaw 2026.8.1 (e889222) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console 
… output truncated …

Assertions:

  • PASS expect_output: Usage: openclaw [options] [command]

How this fits together

Bundled plugins use focused Plugin SDK runtime facades instead of importing core internals or maintaining local copies. The shared helpers then govern path containment, text boundaries, and input coercion before plugins interact with files, channels, or providers.

flowchart LR
  A[Bundled plugin inputs] --> B[Plugin runtime code]
  B --> C[Focused Plugin SDK facades]
  C --> D[Shared path text and coercion helpers]
  D --> E[Plugin file channel and provider actions]
  E --> F[Operator-visible behavior]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main and the supplied exact-head check set was still in progress; merge only after GitHub evaluates the refreshed head and required checks complete.
  • Complete next step (P2) - No concrete repair is needed; the remaining action is normal exact-head merge validation for this maintainer-owned PR.
Agent review details

Security

None.

PR surface

Source -244, Tests +1, Docs 0, Other -3. Total -246 across 48 files.

View PR surface stats
Area Files Added Removed Net
Source 44 160 404 -244
Tests 1 1 0 +1
Docs 1 2 2 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 6 9 -3
Total 48 169 415 -246

Review metrics

Metric Value Why it matters
Production versus test delta production +160/-404 (net -244); test support +1/-0; docs +2/-2; ratchet maintenance +6/-9 The refactor is strongly net-negative in production code while keeping the existing test inventory covered.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/browser/src/doctor-browser.ts, migration/backfill/repair: extensions/feishu/src/doctor.ts, serialized state: extensions/anthropic/session-catalog-scan.ts, vector/embedding metadata: extensions/codex/src/app-server/event-projector-snapshot.ts, vector/embedding metadata: extensions/memory-core/src/memory/manager-embedding-ops.ts, vector/embedding metadata: extensions/memory-core/src/memory/manager-watch-ops.ts, and 3 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Rebase or refresh onto current main so the already-landed test registration drops out, retain the canonical shared-helper migration, and land only after exact-head SDK and plugin validation is green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Rebase or refresh onto current main so the already-landed test registration drops out, retain the canonical shared-helper migration, and land only after exact-head SDK and plugin validation is green.

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

Not applicable: this PR consolidates existing internal behavior rather than reporting a user-facing defect.

Is this the best way to solve the issue?

Yes. Focused SDK facades reuse canonical helpers and remove duplicated implementations while preserving each caller's established containment and boundary semantics.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal refactor is outside the external-contributor real-behavior-proof gate.

Label justifications:

  • P3: This is a behavior-preserving maintainability refactor rather than a reported user-facing regression.
  • 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: This maintainer-authored internal refactor is outside the external-contributor real-behavior-proof gate.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the current branch and the independently merged current-main Codex test-inventory registration. (role: recent current-main contributor and proposed refactor author; confidence: high; commits: e8892229be71, b62df3a99ab9; files: src/plugin-sdk/file-access-runtime.ts, src/plugin-sdk/text-utility-runtime.ts, test/vitest/vitest.extension-codex-app-server-attempt-light.config.ts)

Rank-up moves

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

  • Refresh the branch against current main and let the exact-head required checks complete.

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-19T05:49:04.870Z sha 8ebe6317bfdf4ff6cc794bf8088af7de0bb52756 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 19, 2026
@steipete
steipete force-pushed the steipete/w7-sdk-promotions branch from 7e04ef9 to f4ee343 Compare August 19, 2026 06:59
@steipete steipete self-assigned this Aug 19, 2026
@clawsweeper clawsweeper Bot added 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
@steipete
steipete force-pushed the steipete/w7-sdk-promotions branch from e889222 to a62644a Compare August 19, 2026 07:56
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for a62644aca9e1e75e1947062c0e40ac5600741e0f:

  • pnpm plugin-sdk:surface:check passed: 333 SDK entrypoints and 146 public package subpaths.
  • The 20-plugin focused sweep passed 97/98 shards on the first loaded-host run; the sole unrelated Telegram timing case passed its exact rerun (3/3).
  • node scripts/run-vitest.mjs test/vitest-projects-config.test.ts extensions/codex/src/app-server/run-attempt-tools.test.ts passed 2 files / 21 tests after reproducing the current-main three-owner race.
  • pnpm check:changed passed on the final rebased head; pnpm build passed in 7m29.8s; docs MDX and 6,510-link validation passed.
  • Final scoped Codex autoreviews were clean with no accepted/actionable findings (0.99).
  • Exact-head CI is green: https://github.com/openclaw/openclaw/actions/runs/32230215177

The latest completed ClawSweeper review reported no findings. Its only rank-up move was a current-main refresh plus exact-head required CI; both are satisfied. A newer exact-head review refresh is still running, but repository policy does not require waiting for that publisher after the reviewed moves and exact-head CI are complete.

Production +160/-404 (net -244); test support +0/-2; docs +2/-2; shrink-only ratchets +6/-9. No user-visible behavior or live-provider boundary changed.

@steipete
steipete merged commit 3378e07 into main Aug 19, 2026
239 of 241 checks passed
@steipete
steipete deleted the steipete/w7-sdk-promotions branch August 19, 2026 08:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
)

* refactor(plugin-sdk): promote shared runtime primitives

* test(codex): keep one attempt tools owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: buzz channel: feishu Channel integration: feishu channel: mattermost Channel integration: mattermost channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web docs Improvements or additions to documentation extensions: acpx extensions: anthropic extensions: browser extensions: canvas extensions: codex extensions: google extensions: lobster Extension: lobster extensions: memory-core Extension: memory-core extensions: memory-wiki extensions: qa-lab maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. plugin: file-transfer plugin: migrate-hermes plugin: mxc rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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