Skip to content

ui-sdk: import link policy from render-template directly and drop the ui-kit dependency #2771

Open

Description

@schlessera

Part of #1345.

Context

Split from #1374 on 2026-10-24; the ruling below was made there.

The SDK's only source use of @schlessera/brain-ui-kit is the link policy in the show_block bridge tool: classifyLink and refusalSentence from @schlessera/brain-ui-kit/links (packages/ui-sdk/src/server/bridge-tools/show-block.ts:1). The kit's /links entry only re-exports @schlessera/brain-render-template/links (packages/ui-kit/src/links.ts:1-2), so the SDK reaches render-template through the kit. For that one import the SDK declares a runtime dependency on the kit (packages/ui-sdk/package.json:105), and the allowed-edge table records it (tests/allowed-edges.ts:75-78). Comments still name the kit as the policy's home (packages/ui-sdk/src/tool-contracts/blocks.ts:34, :423).

What that edge costs (from the 2026-10-22 review on #1374):

  • React peer leak. packages/ui-kit/package.json declares react and react-dom as required peers and depends on lucide-react. Through the SDK's dependency on the kit, a server-only consumer such as a backend inherits a required React peer, contradicting the SDK README's statement that its own optional react peer "is only exercised by ./client".
  • Workspace cycle. packages/ui-kit/package.json devDepends on @schlessera/brain-ui-sdk, so the manifests form ui-sdk → ui-kit → (dev) ui-sdk. Removing the SDK's runtime edge removes the cycle.

Maintainer decision — link-policy A (2026-10-09, on #1374)

The SDK imports directly from the public @schlessera/brain-render-template/links entry. The policy already lives there; do not copy or reimplement it. Approve SDK→render-template and remove SDK→ui-kit once all SDK uses of the kit are migrated. Update the dependency manifest and allowed-edge gate together. Keep the kit's public /links compatibility export, and preserve identical show_block/link/tracker validation and rendering verdicts. Correct stale ownership comments; no behavior or policy change is approved.

Scope

  • Import classifyLink and refusalSentence from @schlessera/brain-render-template/links in show-block.ts, and any other SDK use of the kit.
  • Add @schlessera/brain-render-template to the SDK's dependencies, remove @schlessera/brain-ui-kit, and update tests/allowed-edges.ts in the same change.
  • Correct the stale comments in packages/ui-sdk/src/tool-contracts/blocks.ts.

Out of scope

Acceptance criteria

  • git grep -n 'brain-ui-kit' -- packages/ui-sdk/src packages/ui-sdk/package.json returns no import and no dependency.
  • tests/allowed-edges.ts lists @schlessera/brain-render-template and not @schlessera/brain-ui-kit for the SDK, and bun run test tests/dependency-edges.test.ts passes.
  • No package in the SDK's runtime dependencies declares a required react or react-dom peer.
  • Real show_block handler and card fixtures keep the same accepted/refused link and tracker verdicts, including nonempty refusal controls.
  • A mutation that points show-block.ts at a divergent policy fails the agreement assertion, recorded in the PR.
  • A packed install of the SDK resolves its server handlers and browser/worker entries without the kit.

Verification

git grep -n 'brain-ui-kit' -- packages/ui-sdk/src packages/ui-sdk/package.json
bun run test packages/ui-sdk tests/dependency-edges.test.ts
bun run typecheck

Contract impact

None on exports, wire or schemas. The SDK's published dependency set changes (render-template replaces ui-kit, dropping a transitive required React peer); record it in a minor changeset.

2026-10-24: filed from #1374's split, folding in the 2026-10-22 review's React-peer and cycle findings and its suggested criteria.

Activity

  1. added
    type: refactor
    area: ui-sdk
    priority: p3
    agent-ready
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-sdkpriority: p3type: refactor

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions