Skip to content

refactor: add xai plugin-sdk boundary canary#61548

Merged
vincentkoc merged 8 commits into
mainfrom
codex/real-plugin-sdk-xai-canary
Apr 6, 2026
Merged

refactor: add xai plugin-sdk boundary canary#61548
vincentkoc merged 8 commits into
mainfrom
codex/real-plugin-sdk-xai-canary

Conversation

@huntharo

@huntharo huntharo commented Apr 5, 2026

Copy link
Copy Markdown
Member

Summary

  • Problem: bundled extensions still rely on the root openclaw/plugin-sdk/* path alias, so TypeScript does not fail closed when an extension reaches outside its own package root.
  • Why it matters: an illegal import like ../../src/cli/acp-cli.ts can look valid in normal extension-local editing unless a separate boundary script catches it.
  • What changed: I added a real internal @openclaw/plugin-sdk workspace package, opted extensions/xai into a package-boundary tsconfig, and added focused contract tests that prove clean typechecking plus TS6059 failure for a bad relative import.
  • What did NOT change (scope boundary): I did not migrate the rest of the extension tree yet, and this first canary still bridges types through generated plugin-sdk declaration artifacts.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #
  • Related #
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: extension-local TypeScript projects were not resolving allowed SDK imports through a real package surface, so adding rootDir alone either did nothing or broke allowed imports along with forbidden ones.
  • Missing detection / guardrail: the repo had boundary scripts, but normal extension-local TypeScript checking did not fail closed for opted-in packages.
  • Contributing context (if known): the root repo still carries a broad openclaw/plugin-sdk/* alias for legacy extensions, so the incremental rollout needs both legacy and opt-in modes in parallel.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/plugins/contracts/extension-package-project-boundaries.test.ts and test/extension-package-tsc-boundary.test.ts
  • Scenario the test should lock in: extensions/xai typechecks through @openclaw/plugin-sdk/*, and a canary import of ../../src/cli/acp-cli.ts fails with TS6059.
  • Why this is the smallest reliable guardrail: it exercises the real extension-local tsconfig.json boundary instead of only checking custom lint or report scripts.
  • Existing test that already covers this (if any): the existing check-extension-plugin-sdk-boundary script still covers the relative-outside-package rule.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

None.

Diagram (if applicable)

Before:
[xai source] -> openclaw/plugin-sdk/* root alias -> raw src/plugin-sdk/*.ts
[xai source] -> ../../src/... -> allowed by local tsc

After:
[xai source] -> @openclaw/plugin-sdk/* -> internal package runtime + declaration bridge
[xai source] -> ../../src/... -> TS6059 failure

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local Node 22 workspace
  • Model/provider: N/A
  • Integration/channel (if any): xAI bundled plugin
  • Relevant config (redacted): default repo workspace config

Steps

  1. Run ./node_modules/.bin/tsc -p tsconfig.plugin-sdk.dts.json.
  2. Run ./node_modules/.bin/tsc -p extensions/xai/tsconfig.json --noEmit.
  3. Add a temporary import * as foo from "../../src/cli/acp-cli.ts"; canary under extensions/xai and rerun the extension typecheck.

Expected

  • extensions/xai typechecks cleanly through @openclaw/plugin-sdk/*.
  • The canary bad import fails with TS6059.

Actual

  • Verified locally.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: tsc -p tsconfig.plugin-sdk.dts.json, tsc -p extensions/xai/tsconfig.json --noEmit, pnpm test src/plugins/contracts/extension-package-project-boundaries.test.ts test/extension-package-tsc-boundary.test.ts, pnpm test extensions/xai/onboard.test.ts, and the deliberate boundary canary through both tsc and node scripts/check-extension-plugin-sdk-boundary.mjs --mode=relative-outside-package.
  • Edge cases checked: the bad relative import canary under extensions/xai fails while the clean package import path still typechecks.
  • What you did not verify: I did not migrate the other first-wave extensions yet, and I did not yet remove the declaration bridge from this canary.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps:

Risks and Mitigations

  • Risk: the canary still depends on generated plugin-sdk declaration artifacts for type resolution.
    • Mitigation: I kept the rollout to xai only and I am following this with a deeper change to make the package own its source/types end to end.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M maintainer Maintainer-authored PR labels Apr 5, 2026
@greptile-apps

greptile-apps Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces a real @openclaw/plugin-sdk workspace package under packages/plugin-sdk/ and opts extensions/xai into a rootDir-enforced tsconfig that routes @openclaw/plugin-sdk/* imports through that package's declaration bridge. The practical effect is that illegal relative imports escaping the package boundary (e.g. ../../src/cli/acp-cli.ts) now fail at tsc time with TS6059. Two contract tests lock in this canary behavior: one verifies clean compilation through the boundary tsconfig, and one verifies the expected TS6059 failure for an out-of-bounds import.

Confidence Score: 5/5

Safe to merge — only a P2 ergonomics finding remains.

All findings are P2 or lower. The boundary enforcement mechanism, workspace package structure, and test coverage are sound. The standalone tsconfig issue is a documentation gap with no gate or correctness impact.

No files require special attention before merge.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: packages/plugin-sdk/tsconfig.json
Line: 10

Comment:
**Standalone tsconfig references untracked `dist/` artifacts**

The `types/**/*.d.ts` files included here re-export from `../../../dist/plugin-sdk/src/plugin-sdk/*.js` paths, but `dist/` is gitignored and absent on a fresh clone. Running `tsc -p packages/plugin-sdk/tsconfig.json` standalone will fail with module-resolution errors until `tsc -p tsconfig.plugin-sdk.dts.json` (or `pnpm build`) has run. No current CI workflow invokes this tsconfig directly, so this is not a gate failure — and `test/extension-package-tsc-boundary.test.ts` correctly generates the artifacts in its setup step — but the file is misleading on its own. Consider adding a comment in the tsconfig (or a `README.md` in `packages/plugin-sdk/`) noting the prerequisite build step, so contributors who run it in isolation get a clear failure message instead of opaque module-not-found errors.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "build: add xai plugin-sdk boundary canar..." | Re-trigger Greptile

Comment thread packages/plugin-sdk/tsconfig.json Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa3b49b42a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/xai/index.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42f508b64a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread test/extension-package-tsc-boundary.test.ts Outdated
@huntharo huntharo force-pushed the codex/real-plugin-sdk-xai-canary branch from aac683e to 2b55dda Compare April 6, 2026 02:26
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Apr 6, 2026
@vincentkoc vincentkoc self-assigned this Apr 6, 2026
@vincentkoc vincentkoc force-pushed the codex/real-plugin-sdk-xai-canary branch from 2b55dda to 778b576 Compare April 6, 2026 13:12
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Apr 6, 2026
@vincentkoc vincentkoc merged commit 0bd0097 into main Apr 6, 2026
16 of 26 checks passed
@vincentkoc vincentkoc deleted the codex/real-plugin-sdk-xai-canary branch April 6, 2026 13:13

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 778b5761b1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"baseUrl": "..",
"ignoreDeprecations": "6.0",
"paths": {
"@openclaw/plugin-sdk/*": ["packages/plugin-sdk/dist/packages/plugin-sdk/src/*.d.ts"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop hard-requiring prebuilt SDK d.ts for xai boundary checks

Pointing @openclaw/plugin-sdk/* only to packages/plugin-sdk/dist/.../*.d.ts makes extensions/xai/tsconfig.json fail on a clean tree (or after cleaning packages/plugin-sdk/dist) with TS2307 for every SDK import until a separate manual tsc -p packages/plugin-sdk/tsconfig.json step runs first. That introduces an implicit build-order dependency for normal extension-local typechecking/editor use and undermines the canary’s “fails closed” goal; the boundary config should include a project reference or a source fallback so tsc -p extensions/xai/tsconfig.json --noEmit is self-contained.

Useful? React with 👍 / 👎.

steipete pushed a commit to leoleedev/openclaw that referenced this pull request Apr 6, 2026
* docs: plan real plugin-sdk workspace rollout

* build: add xai plugin-sdk boundary canary

* build: generate plugin-sdk package types

* build: hide plugin-sdk core export

* build: alias scoped plugin-sdk runtime imports

* build: repair plugin-sdk boundary drift

* fix(plugins): remove duplicated plugin-sdk entrypoints

* test(plugins): make tsc boundary canary portable

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
Mlightsnow pushed a commit to Mlightsnow/openclaw that referenced this pull request Apr 6, 2026
* docs: plan real plugin-sdk workspace rollout

* build: add xai plugin-sdk boundary canary

* build: generate plugin-sdk package types

* build: hide plugin-sdk core export

* build: alias scoped plugin-sdk runtime imports

* build: repair plugin-sdk boundary drift

* fix(plugins): remove duplicated plugin-sdk entrypoints

* test(plugins): make tsc boundary canary portable

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
* docs: plan real plugin-sdk workspace rollout

* build: add xai plugin-sdk boundary canary

* build: generate plugin-sdk package types

* build: hide plugin-sdk core export

* build: alias scoped plugin-sdk runtime imports

* build: repair plugin-sdk boundary drift

* fix(plugins): remove duplicated plugin-sdk entrypoints

* test(plugins): make tsc boundary canary portable

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
* docs: plan real plugin-sdk workspace rollout

* build: add xai plugin-sdk boundary canary

* build: generate plugin-sdk package types

* build: hide plugin-sdk core export

* build: alias scoped plugin-sdk runtime imports

* build: repair plugin-sdk boundary drift

* fix(plugins): remove duplicated plugin-sdk entrypoints

* test(plugins): make tsc boundary canary portable

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
* docs: plan real plugin-sdk workspace rollout

* build: add xai plugin-sdk boundary canary

* build: generate plugin-sdk package types

* build: hide plugin-sdk core export

* build: alias scoped plugin-sdk runtime imports

* build: repair plugin-sdk boundary drift

* fix(plugins): remove duplicated plugin-sdk entrypoints

* test(plugins): make tsc boundary canary portable

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* docs: plan real plugin-sdk workspace rollout

* build: add xai plugin-sdk boundary canary

* build: generate plugin-sdk package types

* build: hide plugin-sdk core export

* build: alias scoped plugin-sdk runtime imports

* build: repair plugin-sdk boundary drift

* fix(plugins): remove duplicated plugin-sdk entrypoints

* test(plugins): make tsc boundary canary portable

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants