Skip to content

fix: harden plugin import-boundary guards and remove dead scanner - #117386

Merged
steipete merged 3 commits into
mainfrom
codex/goal100k-architecture-guard-owner-0801-2d45
Aug 1, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/goal100k-architecture-guard-owner-0801-2d45

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Root cause and architectural owner

Plugin, channel, and SDK import-boundary guards owned separate source walkers and handwritten regex/string-mask scanners. Those diverging owners silently missed valid commented imports, namespace re-exports, dynamic imports with attributes, CommonJS/import-equals, import types, URL references, scoped SDK aliases, and escaped bundled-plugin path spellings.

Consolidate source inclusion and module-reference policy at the existing shared guard owners (scripts/lib/guard-inventory-utils.mjs, ts-guard-utils.mjs, and extension-import-boundary-checker.mjs). Route the existing plugin/channel/SDK guards through that canonical owner; preserve authored-source inventories, exclusions, baselines, diagnostics, JSON payloads, and exit codes.

Security, generated-asset ownership, and performance

  • Recognize ordinary and no-substitution-template imports/exports, dynamic imports with options, namespace re-exports, CommonJS require, import-equals/import-types, URL references, and both shipped SDK alias spellings.
  • Detect escaped slash, hex, Unicode/braced Unicode, identity escapes, and LF/CRLF/U+2028/U+2029 line continuations without admitting comments or unrelated paths.
  • Exclude only exact generated output paths identified by the existing listGeneratedExtensionAssetSources owner, which requires both a real package asset-build hook and an explicitly declared manifest output. Generated browser bundles are checked by plugins:assets:check; their original authored source stays guarded.
  • Preserve the unchanged 2,097,152-byte hostile-source limit: a generate-first regression creates an oversized declared bundle, runs the guard successfully, then verifies an oversized hostile handwritten JavaScript sibling is rejected.
  • Derive the escaped-path matcher directly from the canonical bundled-plugin prefix: the 7,601-file src corpus falls from 1,902 lexing candidates to 38 (37 raw + one escaped); only one AST is needed.
  • Five paired remote samples, p95: plugin guard 512→223 ms, source guard 298→439 ms, plugin-source guard 602→794 ms; combined p95 1,412→1,456 ms (+44 ms total).

CodeQL denial-of-service and scanner-completeness repair

  • Remove all three catastrophic-backtracking regex filters responsible for all eight standalone CodeQL annotations. A tiny 100–148-byte repeated-comment input previously stalled 0.1–1.75+ seconds; all three patterns are now replaced by one lazy, linear TypeScript 6.0.3 skip-trivia scanner/state machine.
  • Preserve the TypeScript preprocessor short circuit, canonical decoded token values, nested template interpolation resumption, escaped identifiers/specifiers, namespace exports, and exact source-size limit. Context-ambiguous slashes inside active interpolation fail open to the authoritative AST, avoiding unsafe regexp-vs-division inference.
  • Close 96 previously undetected valid boundary bypasses: 36 dynamic-import forms after regexp braces and 60 Unicode-escaped embedded-CommonJS forms. Ordered interpolation/slash/import gating adds only 17 cheap scans and zero full parses; the escaped-identifier gate adds three cheap scans, zero full parses, and 6.87 ms total (+0.67%).
  • 256/256 independent AST-ground-truth hostile variants pass; final old/new inventory differential across 5,493 authored files reports zero changed legitimate edges (4,996 plugin files + 497 core-owner files, 89 + 3 AST parses). Four nearly 2-MiB hostile repeated-comment families finish in 41–63 ms without an AST or violation.

Dead-detector removal proof

Remove the orphan scripts/check-architecture-smells.{mjs,d.mts}, retaining and repurposing its existing mapped test filename for hostile canonical-scanner coverage. Introduction commit 600f57c9791e8b8cf1e764ccf265387f65107b25 touched only the detector and its self-test. Exhaustive current-tree and git log -p -S searches plus tagged v2026.3.22, v2026.7.1, and v2026.7.2-beta.6 histories show no package command, workflow, docs, operator/runtime invocation, or shipped npm-files contract. No baseline, exemption inventory, routing map, or test-selection mapping changed.

Exact evidence

  • Base: aa2a5c96f69a1be639c602649d4aa2e4de8da0a8.
  • Production: 391 added / 725 removed = 334 fewer production LOC; tests: 384 added / 23 removed.
  • Authored-source inclusion: previous 5,001 paths → 5,000; the sole removed committed path is the owner-declared generated browser bundle. All eight handwritten static JavaScript assets and every authored source remain guarded.
  • Full prior guarded-source differential: 5,498 files (5,001 plugin + 497 core plugin-owner files), zero changed boundary edges; just 16 AST parses across plugin sources and zero across core-owner sources.
  • 18/18 hostile-path probes passed, including fully Unicode-escaped prefix and all supported continuations; safe controls produce zero candidates/edges.
  • 16/16 existing operator CLI invocations preserve status/stdout/stderr byte-for-byte, including all three plugin-source modes in human+JSON, plugin/core/SDK/test-helper boundaries in human+JSON, the channel guard, and the public SDK-subpath guard.
  • Fresh remote Blacksmith Testbox tbx_01kyyn4knngswepvkd90qyhq34: exact pnpm build:ci-artifacts → pnpm plugins:assets:check creates 10,214,552-byte and 4,939,681-byte declared browser bundles → all three plugin guard modes return clean inventories → the exact hosted vitest.full-core-support-boundary lane passes 113/113 tests across 12 files.
  • Same post-build checkout: 199/199 focused tests across 13 files and four Vitest projects, exact CI check-guards 10/10, and full pnpm check:changed all pass with the oversized generated bundles still present.
  • Changed gate validates 247 declaration contracts, scripts and root-test TypeScript lanes, and 876-file/245-rule oxlint with zero warnings/errors.
  • Fresh independent gpt-5.6-sol autoreview at xhigh: original cleanup clean (0.98); final generated-output/security lifecycle follow-up clean (0.97); final scanner-security follow-up clean (0.98).

No migration, schema, config surface, baseline weakening, size-limit increase, or public SDK contract change.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XL maintainer Maintainer-authored PR labels Aug 1, 2026
@steipete
steipete marked this pull request as ready for review August 1, 2026 11:50
@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 1, 2026, 9:14 AM ET / 13:14 UTC.

ClawSweeper review

What this changes

The branch consolidates plugin import-boundary guard scanning around shared TypeScript-based analysis, recognizes additional module-reference syntax, excludes declared generated bundles from authored-source checks, and deletes an unused architecture-smell scanner.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

This PR is still necessary: current main retains the older split guard implementation, while the PR centralizes boundary inventory analysis and covers syntax forms the current visitor does not inspect. No discrete correctness defect was found in the final patch, but this protected maintainer-labeled change touches a plugin trust boundary and still has exact-head CI in progress, so it needs explicit maintainer review before merge. Likely related people: Josh Avant is the recent source owner for the shared boundary checker; Tak Hoffman introduced the removed standalone scanner.

Priority: P2
Reviewed head: 62275ec9a31330f7eecdd887ea2de8f48daf06d0
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has a coherent shared-owner design and targeted regression coverage, with merge readiness contingent on the remaining exact-head CI rather than a missing contributor proof artifact.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-labeled internal CI-guard PR is not subject to the external-contributor real-behavior-proof gate; the supplied Testbox and CI evidence remains supplemental and exact-head checks should finish before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-labeled internal CI-guard PR is not subject to the external-contributor real-behavior-proof gate; the supplied Testbox and CI evidence remains supplemental and exact-head checks should finish before merge.
Evidence reviewed 6 items Current main lacks the proposed shared coverage: Current main's shared AST visitor handles import declarations, export declarations, single-argument dynamic imports, optional CommonJS require, and import.meta URL, but it has no import-type or import-equals handling and restricts dynamic imports to exactly one argument. The PR expands this shared owner rather than adding parallel guard walkers.
Canonical guard integration: The PR routes extension boundary collection through the reusable checker with an accepted-specifier filter and preserves the existing per-mode inventory shape, keeping boundary policy at the shared guard owner.
Regression coverage exercises changed security boundary: The PR adds hostile-path cases for commented imports, dynamic imports, CommonJS and import-equals references, import types, import.meta URLs, escaped plugin paths, generated bundles, and source-size enforcement.
Findings None None.
Security None None.

How this fits together

OpenClaw’s script guards scan bundled plugin and core-plugin source files, resolve their module references, and compare the resulting violations against checked-in inventories during CI. These guards protect the boundary between plugin-owned code, the public plugin SDK, and internal core implementation paths.

flowchart LR
  A[Plugin and core source files] --> B[Source inventory]
  B --> C[Module reference analysis]
  C --> D[Resolve repository paths]
  D --> E[Plugin boundary policy]
  E --> F[Baseline comparison]
  F --> G[CI diagnostics or clean result]
Loading

Decision needed

Question Recommendation
After the remaining exact-head checks complete, should the protected plugin-boundary hardening be approved as the canonical shared guard implementation? Approve after exact-head validation: Merge when the remaining CI lanes are green and the final merge result preserves the tested guard inventories and bounded-source behavior.

Why: The patch changes the enforcement path for a plugin trust boundary and carries the repository's protected maintainer label; this requires an explicit human merge decision even though no new line-level defect was identified.

Before merge

  • Add real behavior proof - Not applicable: This maintainer-labeled internal CI-guard PR is not subject to the external-contributor real-behavior-proof gate; the supplied Testbox and CI evidence remains supplemental and exact-head checks should finish before merge.
  • Resolve merge risk (P1) - The lexical prefilter sits in front of the authoritative AST analysis; an overlooked syntax form could silently omit a plugin-boundary violation rather than merely fail a test.
  • Resolve merge risk (P1) - The branch is behind current main and several exact-head CI lanes remain in progress, so merge safety should be decided from the final merge result and completed guard/type/lint checks rather than the PR-body validation summary alone.
Agent review details

Security

None.

PR surface

Tests +361, Other -334. Total +27 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 384 23 +361
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 11 391 725 -334
Total 14 775 748 +27

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: test/scripts/extension-import-boundary-checker.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Require exact-head guard validation (recommended)
    Finish the remaining CI lanes and review the final merge result because the new lexical prefilter decides whether plugin-boundary violations reach AST verification.
  2. Pause for targeted syntax review
    Keep the PR open if maintainers want independent adversarial coverage beyond the included scanner and generated-asset tests before altering this enforcement boundary.

Technical review

Best possible solution:

Keep one shared TypeScript-backed module-reference path for all plugin-boundary guards, retain the targeted hostile-source regressions, and merge only after exact-head CI confirms the inventories and guard contracts remain stable.

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

Yes, from source: current main’s shared visitor omits several module-reference forms that the boundary policy is meant to observe, and the PR supplies focused hostile-source cases for those forms. This read-only environment could not run the focused tests because the checkout’s usable TypeScript compiler dependency is unavailable.

Is this the best way to solve the issue?

Yes, with pending merge proof: consolidating the policy behind the existing shared guard/checker owner is preferable to retaining separate source walkers and scanners. The remaining requirement is exact-head validation of the security-sensitive enforcement path, not a different product direction.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 automation: The patch changes shared guard execution and inventory collection used by CI, so an omission or failure could alter automated enforcement.
  • 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-labeled internal CI-guard PR is not subject to the external-contributor real-behavior-proof gate; the supplied Testbox and CI evidence remains supplemental and exact-head checks should finish before merge.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 availability: Current PR review merge-risk labels are merge-risk: 🚨 security-boundary, merge-risk: 🚨 automation.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded CI guard hardening change with meaningful architectural impact but no evidence of an active user-facing outage.
  • merge-risk: 🚨 security-boundary: The modified scanners enforce the repository boundary that prevents bundled plugins from reaching internal core or other plugin implementation paths.
  • merge-risk: 🚨 automation: The patch changes shared guard execution and inventory collection used by CI, so an omission or failure could alter automated enforcement.
  • 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-labeled internal CI-guard PR is not subject to the external-contributor real-behavior-proof gate; the supplied Testbox and CI evidence remains supplemental and exact-head checks should finish before merge.

Evidence

What I checked:

  • Current main lacks the proposed shared coverage: Current main's shared AST visitor handles import declarations, export declarations, single-argument dynamic imports, optional CommonJS require, and import.meta URL, but it has no import-type or import-equals handling and restricts dynamic imports to exactly one argument. The PR expands this shared owner rather than adding parallel guard walkers. (scripts/lib/guard-inventory-utils.mjs:25, 20ac22f647a4)
  • Canonical guard integration: The PR routes extension boundary collection through the reusable checker with an accepted-specifier filter and preserves the existing per-mode inventory shape, keeping boundary policy at the shared guard owner. (scripts/check-extension-plugin-sdk-boundary.mjs:133, 62275ec9a313)
  • Regression coverage exercises changed security boundary: The PR adds hostile-path cases for commented imports, dynamic imports, CommonJS and import-equals references, import types, import.meta URLs, escaped plugin paths, generated bundles, and source-size enforcement. (test/architecture-smells.test.ts:42, 62275ec9a313)
  • Prior review finding was addressed: The final PR commit is specifically titled "fix: make plugin boundary scanner linear and complete" after the prior ClawSweeper cycle identified backtracking candidate-filter regexes as the remaining blocker. (scripts/lib/guard-inventory-utils.mjs:117, 62275ec9a313)
  • Feature-history ownership: Blame ties the current reusable boundary-checker implementation to the recent shared guard work; the deleted architecture-smell detector dates to commit 600f57c. (scripts/lib/extension-import-boundary-checker.mjs:94, 97f8f25f0b9a)
  • Not implemented or released: The PR head is not contained by the checked-out main branch or any local release tag; current main is 20ac22f and the supplied latest release is v2026.7.1. (62275ec9a313)

Likely related people:

  • joshavant: Current-main blame attributes the reusable extension import-boundary checker and its bounded source-read lifecycle to this recent source owner. (role: recent shared-guard contributor; confidence: medium; commits: 97f8f25f0b9a; files: scripts/lib/extension-import-boundary-checker.mjs, scripts/lib/guard-inventory-utils.mjs)
  • Tak Hoffman: Commit 600f57c introduced the standalone architecture-smell detector that this PR removes and repurposes its test coverage from. (role: original detector author; confidence: high; commits: 600f57c9791e; files: scripts/check-architecture-smells.mjs, test/architecture-smells.test.ts)

Rank-up moves

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

  • Wait for the in-progress exact-head guard, type, lint, and build lanes before deciding whether to merge the protected boundary change.

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 (2 earlier review cycles)
  • reviewed 2026-08-01T11:56:31.283Z sha 00014b7 :: needs real behavior proof before merge. :: [P2] Replace the backtracking candidate-filter regexes
  • reviewed 2026-08-01T12:23:10.416Z sha 65c4c31 :: needs real behavior proof before merge. :: [P2] Replace the backtracking candidate-filter regexes

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Aug 1, 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. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. and removed 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. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 1, 2026
@steipete
steipete merged commit 6affe7c into main Aug 1, 2026
174 of 182 checks passed
@steipete
steipete deleted the codex/goal100k-architecture-guard-owner-0801-2d45 branch August 1, 2026 14:49
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

wingwkyuen pushed a commit to tcgoidc/openclaw that referenced this pull request Aug 1, 2026
…up-ownership-20260801

* origin/main:
  fix(gateway): trim audit.list exact-match filter ids (openclaw#110847)
  fix: harden plugin import-boundary guards and remove dead scanner (openclaw#117386)
  fix(ci): keep PTY tests observable and wait for completed turns (openclaw#117405)
  fix(plugins): resolve marketplace aliases without recursive cycles (openclaw#117440)
  fix: break command recovery import cycle (openclaw#116947)
  fix: clear offscreen command recovery
  fix: fence command recovery ownership
  fix: scope failed command recovery
  fix(plugins): fail closed on ambiguous uninstall targets (openclaw#117406)
pull Bot pushed a commit to mcx/moltbot that referenced this pull request Aug 1, 2026
* origin/main:
  fix(gateway): trim audit.list exact-match filter ids (openclaw#110847)
  fix: harden plugin import-boundary guards and remove dead scanner (openclaw#117386)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
…enclaw#117386)

* fix: harden plugin import-boundary enforcement

* fix: exclude generated bundles from plugin source guards

* fix: make plugin boundary scanner linear and complete
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
…up-ownership-20260801

* origin/main:
  fix(gateway): trim audit.list exact-match filter ids (openclaw#110847)
  fix: harden plugin import-boundary guards and remove dead scanner (openclaw#117386)
  fix(ci): keep PTY tests observable and wait for completed turns (openclaw#117405)
  fix(plugins): resolve marketplace aliases without recursive cycles (openclaw#117440)
  fix: break command recovery import cycle (openclaw#116947)
  fix: clear offscreen command recovery
  fix: fence command recovery ownership
  fix: scope failed command recovery
  fix(plugins): fail closed on ambiguous uninstall targets (openclaw#117406)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* origin/main:
  fix(gateway): trim audit.list exact-match filter ids (openclaw#110847)
  fix: harden plugin import-boundary guards and remove dead scanner (openclaw#117386)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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