Skip to content

chore(scripts): prevent new wrapper shadowing - #121456

Merged
steipete merged 2 commits into
mainfrom
steipete/wrapper-shadow-lint
Aug 10, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/wrapper-shadow-lint

Conversation

@steipete

@steipete steipete commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The repository had no permanent check for same-name wrapper shadowing, so a refactor could reintroduce the naming hazard removed by #121308 and related cleanup: an inner implementation and its behavior-complete outer wrapper could both export the same canonical name.

Why This Change Was Made

This adds a wrapper-shadowing guard that extends the existing export-collision AST analysis instead of introducing a second symbol parser. It follows direct imports and one pure re-export hop, exempts pure re-exports, seeds all 77 current violations as baseline debt, and fails only when a new directed wrapper relationship appears. Existing violations are intentionally unchanged for the separate burn-down PR.

The guard is wired beside deprecated-API hygiene in aggregate checks, architecture CI, and changed-file routing. This is an AI-assisted, maintainer-directed implementation for Refactor plan 04, PR 1 of 2.

During CI, #121434 briefly left the synthetic merge with Plugin SDK hash drift. Rebasing onto current main incorporated the upstream generated refresh; the final diff contains no SDK manifest change.

User Impact

There is no runtime user-visible change. Contributors now get a deterministic CI failure when new code gives an inner implementation the canonical name that belongs to its behavior-complete wrapper; removing existing baseline debt remains allowed.

Evidence

  • node --import tsx scripts/check-wrapper-shadowing.mts — passed with 77 current / 77 baselined violations.
  • node scripts/run-vitest.mjs test/scripts/check-wrapper-shadowing.test.ts test/scripts/check-export-name-collisions.test.ts test/scripts/changed-lanes.test.ts — 181 tests passed on the rebased head.
  • node scripts/check-changed.mjs — passed, including scripts/test-root typechecks, script lint, package-lock validation, SDK checks, and the new guard. Remote providers were unavailable, so the repository wrapper used its documented trusted-source local fallback.
  • node scripts/check-changed.mjs --dry-run -- scripts/check-wrapper-shadowing.mts scripts/check-export-name-collisions.mts scripts/lib/wrapper-shadowing-baseline.json — selected pnpm check:wrapper-shadowing.
  • node --max-old-space-size=8192 --import tsx scripts/generate-plugin-sdk-api-baseline.ts --check — passed on the final rebase; no SDK manifest delta remains.
  • node scripts/run-vitest.mjs test/scripts — 1,471 tests passed; two unrelated host-load timing cases failed. The focused rerun cleared bench-cli-startup.test.ts; bench-sqlite-reliability.test.ts repeated its existing 300-second reliability timeout. No files in either benchmark are touched here.
  • .agents/skills/autoreview/scripts/autoreview --mode local --stream-engine-output — clean; no accepted/actionable findings.
  • Exact-head CI run 31362146810 — green.

@clawsweeper

clawsweeper Bot commented Aug 10, 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 size: XL maintainer Maintainer-authored PR labels Aug 10, 2026
@steipete
steipete marked this pull request as ready for review August 10, 2026 06:08
@steipete
steipete force-pushed the steipete/wrapper-shadow-lint branch from 92b7775 to b7c78d2 Compare August 10, 2026 06:24
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Aug 10, 2026
@steipete
steipete force-pushed the steipete/wrapper-shadow-lint branch from b7c78d2 to e00f8ed Compare August 10, 2026 06:28
@openclaw-barnacle openclaw-barnacle Bot removed the docs Improvements or additions to documentation label Aug 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Coordination note (session handoff): this PR extends the canonical collision checker (#121300) with detection of behavior-adding same-name wrappers — the class #121300 deliberately exempts via its forwarding-only detection. Verified complementary, not duplicative: only 2 of this PR's top-10 shadowed names appear in the canonical baseline.

The simplification campaign session owns plan 04 and has steipete/shadow-hazard-renames-0810 in flight over the same baseline surfaces — deferring the land/fold decision to that lane to avoid racing it. Top shadowed names by unique non-test importers, as burn-down intel: resolveStorePath (104), loadBundledPluginPublicSurfaceModuleSync (24), isMissingPathError (19), loadPluginManifestRegistry (19), sha256HexPrefix (17).

CI green on head e00f8ed, autoreview clean, baseline seeded with 77 violations.

@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 10, 2026, 2:50 AM ET / 06:50 UTC.

ClawSweeper review

What this changes

This PR adds a baseline-backed static check that rejects newly introduced same-name exported wrappers around imported implementations and runs it in aggregate and changed-file CI.

Merge readiness

✅ Ready for maintainer review

Keep open. This active maintainer PR adds a focused, source-backed CI guard; no concrete correctness or security defect was found in the reviewed head.

Priority: P3
Reviewed head: e00f8ed9e7ddfdebae9444bc621f2275b9b823f8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A well-scoped internal guard with focused behavioral fixtures and reported exact-head CI, with no supported blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored static CI guard is outside the external-contributor real-behavior-proof gate; the PR body supplies exact-head guard and CI results.
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 static CI guard is outside the external-contributor real-behavior-proof gate; the PR body supplies exact-head guard and CI results.
Evidence reviewed 5 items Guard implementation: The new detector builds the shared module export graph, follows direct imports or one re-export hop, and reports only same-name imported implementations absent from the baseline.
Canonical analysis reuse: The existing export-collision analyzer now exposes module/export metadata used by the new guard, avoiding a parallel TypeScript parser while retaining the prior collision behavior.
Coverage and routing: Focused fixtures cover direct wrappers, pure re-exports, baselined debt, and a one-hop barrel; the changed-file planner and aggregate architecture check invoke the new guard.
Findings None None.
Security None None.

How this fits together

OpenClaw’s script checks parse TypeScript source to enforce repository architecture rules. This guard reuses the export-analysis layer, compares detected wrapper relationships with recorded debt, and feeds failures into contributor CI.

flowchart LR
A[TypeScript source] --> B[Export analysis]
B --> C[Wrapper-shadowing detector]
D[Debt baseline] --> C
E[Changed paths] --> F[Changed-check planner]
F --> C
C --> G[Architecture and CI checks]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +146, Config +2, Other +876. Total +1024 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 146 0 +146
Docs 0 0 0 0
Config 1 3 1 +2
Generated 0 0 0 0
Other 5 885 9 +876
Total 8 1034 10 +1024

Review metrics

Metric Value Why it matters
Production versus test delta production +495/-10 (net +485); tests +146/-0; generated baseline +393/-0 The production growth is the explicit new CI capability; tests exercise its direct, baseline, and re-export cases.

Stored data model

Persistent data-model change detected: serialized state: test/scripts/check-wrapper-shadowing.test.ts, vector/embedding metadata: scripts/lib/wrapper-shadowing-baseline.json. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Retain one shared AST-analysis path and land the baseline-backed guard after normal maintainer review of the exact head.

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

Not applicable: this is a preventive static-analysis check, not a report of broken runtime behavior; its fixture scenarios define the relevant failure shapes.

Is this the best way to solve the issue?

Yes. Extending the existing export-analysis owner is preferable to adding another parser, and the check is connected to both architecture and changed-file paths.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is internal developer-experience and CI hygiene with no runtime user-visible change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P3: This is internal developer-experience and CI hygiene with no runtime user-visible change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Blame attributes the new detector to his PR-branch commit, and recent current-main history shows his work on the adjacent check-routing files. (role: recent scripts contributor and guard author; confidence: high; commits: c10f7a5f6cef, 44ffb65bee4d, 864414c5fd19; files: scripts/check-wrapper-shadowing.mts, scripts/check-changed.mts, scripts/check.mts)

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
steipete force-pushed the steipete/wrapper-shadow-lint branch from e00f8ed to 00acd8c Compare August 10, 2026 08:11
@steipete
steipete merged commit 560d172 into main Aug 10, 2026
193 of 203 checks passed
@steipete
steipete deleted the steipete/wrapper-shadow-lint branch August 10, 2026 08:40
@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 11, 2026
* chore(scripts): prevent wrapper shadowing

* chore(scripts): refresh wrapper baseline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant