Skip to content

refactor(plugin-sdk): narrow wildcard barrels to explicit used exports - #108440

Merged
steipete merged 24 commits into
mainfrom
claude/chanref-round5-eta
Jul 16, 2026
Merged

steipete merged 24 commits into
mainfrom
claude/chanref-round5-eta

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

31 permanent (non-deprecated) public openclaw/plugin-sdk/* entrypoints were wildcard barrels (export * from) that published 3,136 exports while external plugins used 5–70 symbols each. The bloat was self-inflicted: internal star re-exports and whole-module-object escapes pinned entire surfaces public. Every wildcard-published symbol is future API contract we owe for nothing.

Why This Change Was Made

Round-5 contract-reduction ("do both" maintainer directive). Method per entrypoint, evidence-first: fresh AST-level usage extraction (77-package external corpus + all internal src/extensions/packages importers + symbols referenced in docs) → replace each wildcard with explicit export { … } from lists of exactly the used union → pin the 36 fragile symbols that externals reach through deep wildcard chains as deliberate direct re-exports → remove internal public-SDK star re-exports (qa-channel/qa-lab protocol barrels, agents runtime index, three packages/plugin-sdk mirrors).

Numbers: the 31 converted entrypoints drop 3,136 → 748 exports. Public SDK total 10,612 → 7,919 exports (callable 5,344 → 4,426); wildcard re-exports 209 → 106; deprecated-barrel list 13 → 6. Every corpus-imported symbol keeps its specifier and value/type kind — verified zero missing, zero kind drift. Unused security-runtime helper implementations are kept (un-exported) in an internal module; deleting newly-dead internals is follow-up work once they've been un-exported for a window.

User Impact

None observed-breaking: all externally-imported symbols (including larksuite's enumerated namespace members) remain exported unchanged. The public contract shrinks by ~2,700 exports; barrels become explicit, reviewable lists — adding to the public surface is now a deliberate diff line, not a side effect of exporting from an internal module.

Evidence

  • Retained-union verification: corpus + internal + docs comparison — zero missing exports, zero kind drift; zero remaining internal star re-exports of public SDK entrypoints.
  • Validation (Blacksmith Testbox tbx_01kxkjbbyp6dpqtny2yfywyzy7, exit 0, 28 min): full pnpm build twice with [INEFFECTIVE_DYNAMIC_IMPORT] scan (module graph changed for all 31 entrypoints — none found), pnpm test src/plugins src/plugin-sdk extensions/discord extensions/openai, full pnpm tsgo, pnpm check:test-types, pnpm check:changed (incl. deprecation-hygiene lanes, surface budgets, API baseline).
  • Budgets reconciled with chore(plugins): window unused and bundled-only public plugin-sdk subpaths #108415 which landed mid-flight (deprecated 2,885 + 77 windowed = 2,962 actual).
  • Autoreview (gpt-5.6-sol xhigh, branch mode, 138KB bundle): clean, "patch is correct (0.88)".
  • Research basis: sdk-contract-narrowing-2026-07-15.md (evidence archive) — per-entrypoint used-union tables, §C fragile-symbol list, §D namespace-import enumeration.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: telegram Channel integration: telegram channel: whatsapp-web Channel integration: whatsapp-web extensions: memory-core Extension: memory-core scripts Repository scripts agents Agent runtime and tooling channel: feishu Channel integration: feishu extensions: openai channel: qqbot channel: qa-channel Channel integration: qa-channel extensions: qa-lab extensions: codex size: XL maintainer Maintainer-authored PR labels Jul 15, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and hardened since the first CI round: the dead-files gate exposed that narrowing orphaned src/tools/* (descriptor tool-planning barrel) and src/agents/runtime/proxy.ts — both deleted with their tests (−2,300 LOC total; knip-verified, no prod importers). Autoreview P2 fixed (misplaced @deprecated JSDoc between SecretInput/OpenClawSchemaType). Fresh validation on tbx_01kxkqmjqkwm8j35a63acsgb2g (exit 0): pnpm build + [INEFFECTIVE_DYNAMIC_IMPORT] scan clean (earlier run tbx_01kxkjbbyp6dpqtny2yfywyzy7), src/agents + src/plugins + src/plugin-sdk + discord suites, full tsgo, check:test-types, check-deadcode-unused-files, check:changed. Known unrelated flake: src/agents/session-write-lock.test.ts stale-retry test failed once in-suite, passed 2x standalone (no diff vs main on that module); earlier clawhub stalled-body red was main's own test in the merge run. Final diff vs main: +1,042/−2,436.

@steipete
steipete force-pushed the claude/chanref-round5-eta branch 3 times, most recently from 1030bae to d585a77 Compare July 16, 2026 01:07
@steipete
steipete requested a review from a team as a code owner July 16, 2026 01:07
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes commands Command implementations labels Jul 16, 2026
@steipete
steipete force-pushed the claude/chanref-round5-eta branch 5 times, most recently from dc05612 to 3902b1d Compare July 16, 2026 06:31
@steipete steipete self-assigned this Jul 16, 2026
@steipete
steipete force-pushed the claude/chanref-round5-eta branch from 3902b1d to 3f26366 Compare July 16, 2026 07:33
@steipete

Copy link
Copy Markdown
Contributor Author

Landing refresh for exact head 3f26366cf72783bad0a957b5bbfab09923a480da:

  • Rebased onto the healed main line containing ca2d4d7354e (fix(auto-reply): expect Sol medium default in queued retarget test). Conflict resolution kept current-main contracts through explicit named Plugin SDK pins; scripts/plugin-sdk-surface-report.mjs was resolved from main and then repinned to exact merged-tree actuals.
  • Local proof: node --max-old-space-size=8192 --import tsx scripts/generate-plugin-sdk-api-baseline.ts --check; node --max-old-space-size=8192 scripts/plugin-sdk-surface-report.mjs --check; node scripts/check-deadcode-unused-files.mjs; node scripts/check-deadcode-exports.mjs; node scripts/run-vitest.mjs test/scripts/plugin-sdk-surface-report.test.ts src/plugins/contracts/plugin-sdk-subpaths.test.ts src/plugins/lazy-service-module.test.ts src/plugins/plugin-runtime-artifact-identity.test.ts src/plugins/plugin-runtime-artifact-resolution.test.ts src/plugins/contracts/tts.contract.test.ts.
  • Results: SDK API baseline OK; surface exact at public 7942 / callable 4433 / deprecated 2977 / wildcard 106; unused files 0; unused exports 0; focused Vitest 3 routed shards, 87 tests passed.
  • Autoreview: post-rebase integration patch clean; final budget/hash patch clean. A redundant whole-branch rerun was fail-closed by the review bundle secret-like scanner on auth type names in src/plugin-sdk/plugin-entry.ts; no source was redacted. The full branch had already passed review in the previous landing attempt.
  • Known local gap: the full OpenAI provider test file hits a linked-worktree-only Vitest dependency-resolution error (/node_modules/ws/wrapper.mjs); its touched regression test passes in isolation, and the OpenAI sync commit was dropped during rebase because it is already upstream.
  • Hosted exact-head checks are green.

@steipete
steipete merged commit dde90a3 into main Jul 16, 2026
117 checks passed
@steipete
steipete deleted the claude/chanref-round5-eta branch July 16, 2026 07:45
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
openclaw#108440)

* refactor(plugin-sdk): narrow wildcard barrels to explicit used exports

* refactor(tools): delete dead tool-planning module exposed by barrel narrowing

* fix(plugin-sdk): restore deprecation tag on OpenClawSchemaType alias

* test(agents): drop test for deleted runtime proxy module

* refactor(tools): trim descriptor types to cache consumers

* refactor(deadcode): harvest exports orphaned by barrel narrowing

* refactor(deadcode): harvest exports orphaned by barrel narrowing (rest)

* fix(agents): restore sdk imports and test markers via public predicate

* fix(plugin-sdk): named type re-exports in plugin-entry; trim types barrel precisely

* chore(plugin-sdk): account unmasked deprecated provider types in budgets

* fix(plugins): name star-only type rows for dts bundling

* fix(plugins): restore host-hook surface; unexport internal api compositions

* fix(plugins): named type imports for api composition; restore needed source exports

* fix(plugins): knip-visible type imports for registry surfaces

* test: adapt tests to privatized media and command internals

* fix(qa-lab): re-export snapshot conversation type

* style: format sessions sdk imports

* fix(plugins): restore smoke entry export; pin budgets to exact actuals

* fix(plugins): canonical smoke-entry import; drop orphaned root shims

* fix(plugins): allowlist manifest probe, repoint qa web import, drop dead browser barrels

* fix(plugin-sdk): pin codex auth marker and scaffold provider type

* fix(qa-lab): keep web-facing model-selection shim within boundary rules

* fix(plugin-sdk): preserve merged contracts through narrowed barrels

* chore(plugin-sdk): pin post-rebase surface budgets
Rorqualx pushed a commit to Rorqualx/cortex that referenced this pull request Jul 28, 2026
The 15 clean cherry-picks were written against a pre-resync tree, so applying
without conflict did not mean applying correctly. Autoreview and the lanes found
five real defects:

- skill-forge distiller referenced processVsOutcomeSection out of scope and read
  candidate.processVsOutcome, which the pick never added (git dropped the
  detector.ts third of that commit while reporting success). Derive the rubric in
  the distiller instead: the detector would have to import the evaluator to carry
  it, and the evaluator already type-imports Candidate.
- Delegation latency balancing returned a 0 penalty for unmeasured providers, so
  an unknown provider outranked every measured healthy one — the inverse of both
  its purpose and its own doc comment — and a provider that only ever errored was
  never demoted, since the early return skipped the error penalty. Return "no
  opinion" instead and let the stable sort keep priority order, and count errors
  even without latency samples. Adds the three tests the exported
  resetLatencyState hook implied but never had.
- The tool audit store redacted args but persisted errorMessage verbatim and
  uncapped, so a secret stripped from args_summary re-entered through the error
  column.
- Non-numeric --threshold became NaN, and every rate <= NaN is false, silently
  failing the judge audit instead of erroring.
- The weight-optimization script carried two unused symbols (red tsgo:extensions).

Also drops src/tools/index.ts rather than resurrecting it: upstream deleted that
barrel in openclaw#108440 and the audit store is imported directly.
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
openclaw#108440)

* refactor(plugin-sdk): narrow wildcard barrels to explicit used exports

* refactor(tools): delete dead tool-planning module exposed by barrel narrowing

* fix(plugin-sdk): restore deprecation tag on OpenClawSchemaType alias

* test(agents): drop test for deleted runtime proxy module

* refactor(tools): trim descriptor types to cache consumers

* refactor(deadcode): harvest exports orphaned by barrel narrowing

* refactor(deadcode): harvest exports orphaned by barrel narrowing (rest)

* fix(agents): restore sdk imports and test markers via public predicate

* fix(plugin-sdk): named type re-exports in plugin-entry; trim types barrel precisely

* chore(plugin-sdk): account unmasked deprecated provider types in budgets

* fix(plugins): name star-only type rows for dts bundling

* fix(plugins): restore host-hook surface; unexport internal api compositions

* fix(plugins): named type imports for api composition; restore needed source exports

* fix(plugins): knip-visible type imports for registry surfaces

* test: adapt tests to privatized media and command internals

* fix(qa-lab): re-export snapshot conversation type

* style: format sessions sdk imports

* fix(plugins): restore smoke entry export; pin budgets to exact actuals

* fix(plugins): canonical smoke-entry import; drop orphaned root shims

* fix(plugins): allowlist manifest probe, repoint qa web import, drop dead browser barrels

* fix(plugin-sdk): pin codex auth marker and scaffold provider type

* fix(qa-lab): keep web-facing model-selection shim within boundary rules

* fix(plugin-sdk): preserve merged contracts through narrowed barrels

* chore(plugin-sdk): pin post-rebase surface budgets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: qa-channel Channel integration: qa-channel channel: qqbot channel: telegram Channel integration: telegram channel: whatsapp-web Channel integration: whatsapp-web cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: codex extensions: memory-core Extension: memory-core extensions: openai extensions: qa-lab gateway Gateway runtime maintainer Maintainer-authored PR scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant