Repository navigation
Description
Part of #1345.
Context
Delivered prerequisite outputs: #1399 (merged in #1461). RTK rewriting is already public toolkit under the later #1345 ruling and #1399; do not reopen it.
This issue originally classified four families of ui-sdk helpers that are not wire protocol. All four are ruled (2026-10-09, see comments). On 2026-10-24 it was split so each ruled family has its own task:
- Web-search configuration (this issue).
- Geo compatibility-alias removal: ui-sdk: remove the geo compatibility aliases from the SDK's public server entry #2770.
- SDK→render-template link-policy migration and removal of the SDK→ui-kit dependency: ui-sdk: import link policy from render-template directly and drop the ui-kit dependency #2771.
execWrapperSpawnOptions, a host-plus-one-backend helper the original classification missed (docs/decisions/backend-authoring-toolkit.md:46): ui-sdk: classify the SDK helpers that only the host and one backend import #2772,needs: decision.
Push handlers are not a remaining family: they stay at the public SDK ./push-handlers entry (ruling below) and are a constraint, not work.
Where web-search lives today (a6b945b). The pi-specific catalog, path, routing, override and brief logic is in packages/ui-sdk/src/server/web-search.ts and reaches its consumers through SDK /internal (packages/ui-sdk/src/internal.ts:15):
- pi imports it from
@schlessera/brain-ui-sdk/internal(packages/ui-backend-pi/src/config/env.ts:23-29), against the extension public-only rule; this is why ci: extension packages may import only public entry points #1400 is blocked by this issue. - ui-server's Settings route imports it the same way (
packages/ui-server/src/routes/web-search.ts:35-44). - Only the neutral
WebSearchBrieftype is public (packages/ui-sdk/src/server/index.ts:113).
The "cache invalidation" behaviour is currently a no-op. After a Settings PUT the route calls mod.invalidateExtensionCache?.() on the loaded pi module (packages/ui-server/src/routes/web-search.ts:309-320). #1052 removed that export from the pi root (docs/decisions/public-export-boundary.md:247; packages/ui-backend-pi/src/index.ts:10-31), so the optional call does nothing and raises nothing. packages/ui-backend-pi/src/extension-cache.ts:18 has no importer, and the route test passes only because it injects a fake module that has the export (packages/ui-server/tests/web-search-routes.test.ts:58). Pi sessions now run in worker processes (launchAgentWorker, packages/ui-backend-pi/src/worker-session.ts:181), so clearing the server process's module cache may not affect a new session even if it ran.
Maintainer decision — web-search A (2026-10-09)
Pi owns its configuration helpers, with a public configuration adapter for Settings. Move pi-specific catalog/path/routing/override/brief logic into the pi backend and expose the narrowly documented public adapter ui-server needs. UI-server uses the existing optional lazy backend loading path and keeps unrelated startup working without pi. Pi must not consume SDK /internal. Retain the public neutral WebSearchBrief prompt input if still needed by SDK prompt composition; do not move unrelated prompt-builder APIs merely because they accept that type.
Preserve configuration-file semantics, precedence, provider ordering, credential-presence reporting without key disclosure and unmanaged-key retention. This is ownership refactoring, not permission to alter search behavior, billing policy, paths or host configuration format. Inventory current public SDK exports before removal; any public removal needs explicit migration classification and documentation.
Push (2026-10-09, unchanged): keep registerPushHandlers, PushHandlerOptions and PushCapableScope at the public SDK ./push-handlers entry with their signatures and listener/notification/deep-link/renewal behavior. Nothing here moves or retypes them.
Scope
- Move the web-search configuration helpers from
packages/ui-sdk/src/server/web-search.tsintopackages/ui-backend-pi, keepingWebSearchBriefin the SDK where prompt composition needs it. - Expose a narrow, documented public pi configuration adapter that the Settings route loads through the existing optional lazy backend loading path (
loadBackendModule), and pointpackages/ui-server/src/routes/web-search.tsat it instead of SDK/internal. - Configuration refresh, not the obsolete call. First establish whether a new pi session already re-reads
web-search.jsonafter a Settings PUT under per-session workers. If it does, deleteextension-cache.tsand the route'sinvalidateExtensionCachecall, and record the evidence in the PR. If it does not, put the refresh behind the new adapter and make the route call it. Either way, a test against the real pi package proves the refreshed configuration reaches the next session. - Remove the moved names from SDK
/internal; update the API reports,docs/decisions/backend-authoring-toolkit.md,docs/decisions/public-export-boundary.mdand the pi README together.
Out of scope
- Geo aliases (ui-sdk: remove the geo compatibility aliases from the SDK's public server entry #2770), link policy and the SDK→ui-kit edge (ui-sdk: import link policy from render-template directly and drop the ui-kit dependency #2771),
execWrapperSpawnOptions(ui-sdk: classify the SDK helpers that only the host and one backend import #2772). - Push handlers, beyond keeping them as they are.
- Any change to search behavior, provider ordering, billing, paths or the configuration file format.
Acceptance criteria
-
git grep -nE 'readWebSearch|resolveWebSearchConfigPath|webSearchProvider|WEB_SEARCH_PROVIDER' -- packages/ui-backend-pi/src packages/ui-server/srcshows no import from@schlessera/brain-ui-sdk/internal. - Real Settings GET/PUT tests against the real pi package keep configuration precedence, provider ordering, unmanaged keys and key-presence reporting; no credential value appears in any response.
- A test that loads the real pi package (no injected fake module) proves a Settings PUT is visible to the next pi session, or the PR records the evidence that it already is and the dead
extension-cache.tsand route call are deleted.packages/ui-server/tests/web-search-routes.test.tsno longer injectsinvalidateExtensionCache. - UI-server loads the pi adapter optionally/lazily: a no-pi packed startup and unrelated features still work, and a configured-but-missing or incompatible adapter gives an explicit, tested result.
- Push handlers remain at
./push-handlerswith unchanged signatures;api-reportshows no push change. - A mutation that breaks precedence in the moved helpers fails a named Settings assertion, recorded in the PR.
Verification
bun run test packages/ui-sdk packages/ui-backend-pi packages/ui-server/tests/web-search-routes.test.ts
bun run api-report
bun run typecheckContract impact
Additive public pi configuration adapter (@experimental unless the decision record says otherwise): contract label, CONTRACT: commit, API report and integration contract in the same commit, minor changeset. The moved names leave SDK /internal only; no public SDK name is removed. If the inventory finds a public SDK web-search name that must go, stop and classify it on this issue first.
2026-10-24: split the geo, link-policy and execWrapperSpawnOptions families into #2770, #2771 and #2772; narrowed this issue to pi web-search ownership; folded in the 2026-10-22 finding that cache invalidation is a no-op and required real-package configuration refresh instead; removed breaking (the approved break moved to #2770); raised to p2 because #1400 depends on it.
Activity
schlessera commentedon Oct 9, 2026
Decision (maintainer, 2026-10-09): web-search family A
Move pi web-search configuration ownership into ui-backend-pi, exposing a narrow public configuration adapter for Settings. UI-server consumes it through optional lazy loading; pi no longer imports these helpers from SDK /internal. Preserve existing paths/config precedence, provider ordering, credential-presence semantics, unmanaged fields and cache invalidation. Keep neutral SDK prompt types where still needed.
The body records this family’s home and compatibility inventory requirement. RTK is already ruled public toolkit in #1399. Push handlers, geo compatibility exports and link-policy ownership remain unresolved; retain
needs: decisionand the #1399 blocker.schlessera commentedon Oct 9, 2026
Classification evidence (2026-10-09): push handlers
Keep the service-worker helpers at the existing public SDK
./push-handlersentry. The package exports it and docs/http-api.md explicitly documents its renewal dependency on the supported push-subscription lifecycle. It is SDK client-integration logic for independent PWA shells; it need not be wire schema to remain public.This follows the existing supported boundary rather than reopening it. Preserve signatures and notification/deep-link/renewal behavior; any typing cleanup must retain real service-worker compatibility. The body now records push as resolved. Geo compatibility exports and link-policy ownership remain open; keep
needs: decision.schlessera commentedon Oct 9, 2026
Decision (maintainer, 2026-10-09): geo aliases A
Remove SDK geo compatibility re-exports; consumers import directly from the canonical public
brain-geoentries. This approves a breaking import migration, with exact old-to-new import documentation and API-report/contract updates, without deprecated SDK aliases. Geometry behavior stays unchanged. Remaining protocol/implementation use of geo is not removed merely because aliases disappear.The body now records the geo home and migration. Refreshed main already puts shared link policy in render-template’s public /links entry, with UI-kit forwarding to it; SDK still depends on UI-kit for that policy. The dependency edge is the remaining choice. Retain
needs: decisionand #1399 blocker; add contract/breaking for the approved alias removal.schlessera commentedon Oct 9, 2026
Decision (maintainer, 2026-10-09): link policy A and completed classification
SDK consumes the existing public render-template /links implementation directly. Approve SDK→render-template, migrate SDK imports and remove SDK→ui-kit from its manifest/allowed edges once no uses remain. Keep UI-kit’s /links compatibility export and preserve one policy implementation and identical handler/card verdicts.
The body consolidates all family homes: pi owns web-search through a public Settings adapter; push remains its documented public SDK integration; SDK geo aliases are removed with a breaking migration; link policy remains in render-template; RTK is already public toolkit under #1399. It includes source/packed/optional-install and behavioral verification requirements and documentation updates.
No classification decision remains: remove
needs: decisionand addagent-ready, keepingblockedon #1399 andcontract/breaking. No implementation is claimed complete.schlessera commentedon Oct 10, 2026
Unblocked: #1399 is closed, so
scripts/sync-project.tsis removing theblockedlabel.schlessera commentedon Oct 10, 2026
Unblocked: #1399 merged in #1461 (02fd0b9). The helpers both backends import are now public on
@schlessera/brain-ui-sdk/server.execWrapperSpawnOptions(host + pi),bashCommand(Claude only),SUBPROCESS_ENV(host only),GIT_LOCK_KEYandcanonicalModelIdstay in/internal; see the inventory indocs/decisions/backend-authoring-toolkit.md.schlessera commentedon Oct 21, 2026
New evidence from a repository review on 2026-10-22: preserving extension-cache invalidation currently preserves a no-op.
825cd044e, released in 0.41.0) removedinvalidateExtensionCachefrom the@schlessera/brain-backend-piroot (docs/decisions/public-export-boundary.md:247). It is in neither the root (packages/ui-backend-pi/src/index.ts:9-19) nor./internal(packages/ui-backend-pi/src/internal.ts:6-8).packages/ui-server/src/routes/web-search.ts:313-317), somod.invalidateExtensionCache?.()does nothing and no error is raised.packages/ui-server/tests/web-search-routes.test.ts:58injects a fake that has it, so the test passes.packages/ui-backend-pi/src/extension-cache.tshas no importer in anysrc/.launchAgentWorker,packages/ui-backend-pi/src/worker-session.ts:180), so clearing the server process's module cache may not affect a new session even when it does run.When this issue implements the web-search acceptance criterion "cache invalidation", please first establish whether a server-side invalidation is still meaningful under per-session workers. If it is, export it through the new pi adapter and cover it with a test that loads the real package. If it is not, delete
extension-cache.tsand the route call, and record why in the PR.The same export cut also broke
createPiAuthand with it every/api/pi-auth/*route. That is filed as a separate bug from the same review.schlessera commentedon Oct 21, 2026
Repository review on 2026-10-22 (main
dcf5341aa): the SDK→UI-kit edge this issue's link-policy A removes is still there, and it costs more than the link helper suggests. Current evidence, for whoever picks this up:packages/ui-sdk/src/server/bridge-tools/show-block.ts:1(classifyLink,refusalSentencefrom@schlessera/brain-ui-kit/links), andpackages/ui-sdk/package.json:105still declares@schlessera/brain-ui-kitas a runtime dependency.packages/ui-sdk/src/tool-contracts/blocks.ts:423still names@schlessera/brain-ui-kit/linksas the classifier's home in a comment.packages/ui-kit/src/links.ts:2already only re-exports@schlessera/brain-render-template/links, so the SDK reaches render-template through the kit.packages/ui-kit/package.json:82-85declaresreactandreact-domas required peers (nopeerDependenciesMeta), and:78-81addslucide-reactas a dependency. Through the SDK's dependency on the kit, a server-only consumer such as a backend inherits a required React peer. That contradicts the SDK README's statement that its own optionalreactpeer "is only exercised by./client".packages/ui-kit/package.json:88devDepends on@schlessera/brain-ui-sdk, so today the manifests form ui-sdk → ui-kit → (dev) ui-sdk. Removing the SDK's runtime edge as approved here also removes that cycle.Suggested additions to the acceptance criteria, all checkable after the change:
git grep -n 'brain-ui-kit' packages/ui-sdk/src packages/ui-sdk/package.jsonreturns no import and no dependency (comments updated to name render-template).dependenciesdeclares a requiredreactorreact-dompeer (check each dependency'spackage.json; render-template declares none today).Found by a repository review on 2026-10-22.
[-]ui-sdk: classify the server helpers that are not wire protocol[/-][+]backends: pi owns its web-search configuration helpers behind a public Settings adapter[/+]schlessera commentedon Oct 24, 2026
2026-10-24: split and rewritten.
contract,breaking); SDK→render-template link policy and dropping the SDK→ui-kit dependency → ui-sdk: import link policy from render-template directly and drop the ui-kit dependency #2771;execWrapperSpawnOptions, which the original classification missed (docs/decisions/backend-authoring-toolkit.md:46) → ui-sdk: classify the SDK helpers that only the host and one backend import #2772 (needs: decision). This issue keeps pi web-search ownership. Push handlers remain at./push-handlersas a constraint, not work.breaking: the approved break is geo's and moved to ui-sdk: remove the geo compatibility aliases from the SDK's public server entry #2770; web-search names leave SDK/internalonly. Keptcontractfor the additive pi adapter. Addedarea: backendsandarea: ui-server. Raised to p2 because ci: extension packages may import only public entry points #1400 (p2) is blocked by this issue.