Skip to content

ui-sdk: both backends import 41 worker-host helpers that exist only in /internal, against the toolkit ruling #2489

Open

Description

@schlessera

Context

The 2026-10-09 ruling on #1345 (decision 3) states that a helper both shipped backends import is public in @schlessera/brain-ui-sdk/server (docs/decisions/backend-authoring-toolkit.md:10-22). The same record says that since #1399, "neither backend imports them from /internal" (docs/decisions/backend-authoring-toolkit.md:159-161). #1399 promoted the set that existed on 2026-10-09 and closed.

Since then the worker-host, sandbox and inference-relay work has added a new shared set. Both backends now import the same 43 names from @schlessera/brain-ui-sdk/internal, and 41 of them exist only in /internal:

ANTHROPIC_INFERENCE_ROUTES, INFERENCE_PLACEHOLDER, InferenceRelay, InferenceRelayEvent, NativeFileVersions, OUTWARD_VOICE_REFUSAL, PreparedWorkerOutput, RTK_WORKER_ENV, WORKER_INFERENCE_SOCKET, WORKER_SCRATCH, WORKER_XDG_DIRS, WorkerSandbox, WorkerStateHandle, compileWorkerCommandPolicy, createLimitTracker, createTurnTempPressure, createTurnTempPromoter, denyWorkerCommand, describeClient, launchAgentWorker, launchLimits, observeOutwardPlan, outputStagingLimit, prepareNativeWorkerOutput, prepareOutwardPlan, prepareWorkerSandbox, promptPrefixFingerprint, requestPolicyPermission, requireWorkerHost, resolveTurnTempLimits, retainWorkerStartupView, sessionPromptContext, sessionReplay, startInferenceRelay, turnTempLimit, workerCleanupUnconfirmed, workerCommandPolicyNote, workerNoteLimits, workerOutwardNote, workerSandboxNote, workerSandboxWarnings.

The other two, handleTurnTemp and TurnTempAccess, are already public in ./server (api-report/ui-sdk.txt:2362, :2295; #1703), yet both backends import them through /internal (packages/ui-backend-claude/src/turn-temp-tool.ts:3, packages/ui-backend-claude/src/sdk-options.ts:21, packages/ui-backend-pi/src/bridge-tools.ts:38, packages/ui-backend-pi/src/turn-context.ts:16).

Nothing enforces the rule. No test compares the two backends' /internal import sets. The planned gate, #1400, would refuse every backend /internal import, so it cannot pass on the tree until these 41 names have a home. #1400 already declares this issue alongside #1398 and #1372 as an active blocker. Neither of those other tasks covers these 41 names; this issue’s coordinated toolkit/runtime ruling remains necessary before the gate can pass.

How the list was produced: collect every name in import { … } from "@schlessera/brain-ui-sdk/internal" under packages/ui-backend-claude/src (77 names) and packages/ui-backend-pi/src (58 names), intersect the two sets (43), then check each against the export "./server" section of api-report/ui-sdk.txt.

These names are worker-host infrastructure: launching and sandboxing the worker, the inference relay, outward-action plans, turn-temp limits. Publishing them would put a large, fast-moving surface under @experimental toolkit. That trade-off is the maintainer's call.

Decision (maintainer, 2026-10-22)

Option A selected in coordination with #2528’s approved extraction: expose all 41 listed worker-host helpers through supported @experimental APIs in the new server-only runtime package (working name @schlessera/brain-ui-worker). Both first-party and third-party backend authors use those same supported primitives.

This preserves the shared-toolkit principle while changing the owning entry for these extracted runtime helpers from the originally proposed SDK /server home. Do not create an SDK→worker reverse dependency or publish duplicate SDK runtime aliases merely to retain that old proposal. No first-party internal exception or public/internal split is selected. Existing public SDK toolkit names remain supported.

Blocked by #2528

Scope

  • Consume ui-sdk: the contract package carries the whole governed-worker runtime and a root-only storage bin #2528’s extracted package and selected supported runtime API. Reconcile the exact 41-name inventory above against the delivered public exports/reachable types and complete any remaining promotion/import gaps; do not repeat the package extraction or duplicate exports already delivered there.
  • Migrate both backends to the runtime package’s supported entries for these helpers. Switch the four existing handleTurnTemp / TurnTempAccess imports to their already-public @schlessera/brain-ui-sdk/server home without removing those SDK APIs.
  • Record the coordinated owning-package amendment in docs/decisions/backend-authoring-toolkit.md, the export-boundary record, backend-authoring guide and affected API reports/contracts. Clarify historical statements about the earlier toolkit inventory.
  • Add a guard computing shared backend internal-import sets across SDK and extracted worker entries. Reject a shared runtime helper hidden in /internal; this selected scope introduces no shared-helper internal allowlist. Prove both backend implementations compile/use supported primitives and a test-only external author can import the listed API and its signature-reachable types.
  • Keep ci: extension packages may import only public entry points #1400’s extension import-gate dependency on this issue; do not weaken that gate to permit private runtime imports. Behavioral execution, sandbox, credential and output semantics stay unchanged.

Out of scope

Acceptance criteria

  • The maintainer selected supported experimental runtime APIs (A) in the extracted owning package on 2026-10-22.
  • All 41 listed helpers and their signature-reachable types are importable from supported runtime entries, with matching API reports/docs. Both backends use supported entries; the two already-public SDK turn-temp names remain imported from SDK /server.
  • A test computes the shared backend internal-import set across SDK/worker packages and refuses a shared helper absent from supported API. Reintroducing an internal import fails the named guard; restoration passes. No first-party exception is added.
  • A test-only external backend/consumer typechecks against ordinary supported package entries, without source/internal imports, duplicated authority helpers or a reverse SDK→worker dependency. Existing backend behavior and provider-history guards remain intact.
  • The toolkit/export-boundary records explain the coordinated ownership amendment and accurate historical inventory. API report, same-commit contract updates and changesets name the actual public additions and import migration.

Verification

bun run test packages/ui-sdk packages/ui-backend-claude packages/ui-backend-pi
bun run api-report
bun run typecheck

Contract impact

Selected A adds supported @experimental runtime APIs in the extracted package. Use a CONTRACT: commit, same-commit package-API/index updates, accurate reachable-type API reports and an appropriate changeset for additions. Preserve already-supported SDK toolkit APIs; unrelated public removal is not approved. Follow the release skill before package/dependency edits during implementation.

Found by a repository review on 2026-10-22.

Coordinated readiness — 2026-10-22

The package-home and public-classification choices are settled by the maintainer. Remove needs: decision, add agent-ready, contract and blocked, and retain the canonical dependency on #2528. That extraction depends on #2530; there is no reverse #2528 implementation dependency on this issue, only the selected API requirements recorded there. Preserve priority p2, existing parent/assignment/release attribution and #1400’s downstream blocker. No API implementation, extraction, tests or runtime proof are claimed by this decision pass.

2026-10-24: ownership references updated after #1374 was split into #2770, #2771 and #2772.

Activity

  1. added
    type: refactor
    area: ui-sdk
    area: backends
    priority: p2
    needs: decision
    on Oct 21, 2026
  2. schlessera commented on Oct 21, 2026

    @schlessera
    OwnerAuthor

    2026-10-22 triage at main ca8842828ed8634a84c4e8aa4a88e487238721b4: Added a separate unapproved recommendation and tradeoffs to the current decision brief; no ruling or implementation is inferred.

  3. added
    agent-ready
    contract
    blocked
    and removed
    needs: decision
    on Oct 22, 2026
  4. schlessera commented on Oct 22, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-10-22): Option A, coordinated with #2528 extraction.

    Expose all 41 listed worker helpers through supported experimental APIs in the extracted runtime package, for first-party and third-party backend authors alike. This amends their proposed owning entry, preserving the shared-toolkit principle; no internal exception or split is selected. Preserve the existing public SDK turn-temp APIs and avoid an SDK→worker dependency cycle or duplicate runtime aliases.

    The body specifies the public inventory, backend import migration, external-consumer proof, internal-import guard and durable ownership/contract records. Remove needs: decision; add agent-ready, contract and blocked on #2528. #2528 retains #2530 and now has no unanswered classification choice. Existing metadata and #1400’s downstream dependency remain; no implementation is claimed.

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: backendsarea: ui-sdkblockedcontractpriority: p2type: refactor

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions