Repository navigation
Description
Context
Part of #56. The export curation in #534 (PR #1052) classified every export of every @schlessera/brain-* entry point under the #343 question 1 ruling. Its rule kept a name public when the evidence was mixed. It also left public whatever a public declaration reaches, because narrowing those declarations is an API redesign rather than an export cleanup. docs/decisions/public-export-boundary.md ("What that left, by package") records the result. The api-report signature sections, which now cover every public export, show these surfaces in full.
What this leaves reachable or public, without a documented consumer role behind it:
WsHost(packages/ui-server/src/ws/host.ts). It is exported for embedders (ui-server README,docs/conditional-forms.md) and reaches the server's connection, client-set, catalog and turn types through its public fields. Itscoordinatorfield is tagged@internal, soTurnCoordinatoris excluded.api-report/ui-server.txtshows what remains.- ui-react store hooks (
useChatStore,useFileStore,useShareStore,useUIStore,useVoiceStore;packages/ui-react/src/stores/). A deployment shell uses them, and through them they expose their zustand state shapes (ChatState,UIState…) as supported types. - Names the classification marked uncertain, kept public:
- core
collectStats(it takes a nativebun:sqlitehandle) andrepoRelativePathSchema; - ui-sdk
/server's bridge-tool handlers (handleAskUser*,handleShowBlock…),wrapCommand,execWrapperSpawnOptions,describeRetry,canonicalModelId,resolveThinkingLevel,createToolRendererRegistry,pruneStoredShares,ShareTargetError,isShareTargetRequestandhandleShareTargetRequest; - ui-kit
TOKENS,LIGHT_TOKENSandcanvas; - render-template
applyExportLinkPolicyandprotectExportLinkDestinations; - geo
MAX_ROUTE_BYTES; - jobs
runScrape; - Claude
MEASURED_RUNTIME.
- core
Each of these becomes a 1.0 compatibility obligation unless it is narrowed first.
Scope
- For each item above, record a maintainer ruling: keep public as documented API (and document the role), narrow the declaration that reaches it, or move or remove it.
- Implement the rulings: narrow or retype the declarations, move names to the owning package's
/internalentry, update the docs that name them, and updatedocs/decisions/public-export-boundary.md.
Out of scope
- Reopening docs: decide what 1.0 freezes where the contract document does not say #343 question 1 or the classification of names already removed or moved by packages: curate public exports and align the 1.0 stability contract #534.
- Module-authoring names, which core: define the module-authoring stability contract for 1.0 #537 owns.
- Changing lockstep versioning or scheduling 1.0.
Acceptance criteria
- Every item listed above has a recorded ruling on this issue (2026-10-06):
WsHostand the ui-react store hooks (b) narrow;repoRelativePathSchema,MEASURED_RUNTIMEandrunScrape(a) keep and document;collectStatsand every other listed name (c) move to the owning package's/internalentry. - For every narrowed or moved item,
api-report/*.txtno longer records the narrowed internal shape. For example, after aWsHostnarrowing,api-report/ui-server.txtcontains noClientSetorSessionCatalogblock, unless the ruling keeps them. - Every in-tree consumer, every packed-package probe and
bun scripts/check-dist-types.tspass against the narrowed surface. - Items kept public are named with their consumer role in a user-facing doc (a README usage section or the integration contract).
- A changeset names any pre-1.0 break.
Verification
bun run api-report and read the diff; bun run test tests/api-surface.test.ts; bun run build && bun scripts/check-dist-types.ts; bun run typecheck; bun run lint.
Contract impact
Narrowing or moving a public export, or a type reached through one, is a pre-1.0 break. It needs the breaking label, the ruling recorded here before code, a CONTRACT: commit with the integration-contract update, and a changeset that names the break.
Decision framing (triage, 2026-10-06)
Question, per item: (a) keep public as documented API and document its consumer role, (b) keep the entry point public but narrow the declaration that reaches internal shapes (for example tag fields @internal or retype them to a minimal interface), or (c) move it to the owning package's /internal entry, or remove it.
Consequences: (a) makes the full current shape, including every type it reaches, a 1.0 compatibility obligation. (b) keeps today's embedder and shell use working while freeing the reached internals, at the cost of a pre-1.0 type break for anyone relying on those fields. (c) is the cheapest for 1.0, but breaks any out-of-tree consumer of the name, and none of these has a documented consumer.
Recommendation (not approval): use (b) for WsHost and the ui-react store hooks, which have documented consumers (embedders and deployment shells) but expose internal shapes through their fields and state types. Use (c) for the names listed only as "uncertain, kept public", unless the maintainer knows of a consumer. A public name can be added after 1.0 in a minor; it cannot be removed without a major.
Dependency
Satisfied 2026-10-06: #534 merged as PR #1052 (825cd044). docs/decisions/public-export-boundary.md (its "What that left, by package" list) and the full api-report/*.txt signature sections are on main at 825cd044e550b2cef5d7f2ddad2b7251f73d762a, so nothing but the rulings themselves stands between this issue and implementation.
2026-10-06 triage: added the decision framing and recommendation above, plus the #534 blocker and blocked. needs: decision remains until each listed item has a recorded ruling.
2026-10-06 triage at main 825cd044: #534 is closed as completed and its outputs are verified on main, so the active Blocked by #534 line was retired and project sync removed blocked. needs: decision remains: no item listed above has a recorded ruling yet. #701 (SQL guarantee retirement) defers the collectStats ruling to this issue.
2026-10-06 maintainer ruling recorded per item (see the decision comment). needs: decision removed; agent-ready. breaking and contract stay.
Activity
schlessera commentedon Oct 6, 2026
2026-10-06 triage: added the area labels of every package whose surface the listed items cover (core, ui-sdk, ui-server, ui-react, ui-kit, render, modules, backends).
area: docsstays for the decision-record update.schlessera commentedon Oct 6, 2026
Unblocked: #534 is closed, so
scripts/sync-project.tsis removing theblockedlabel.schlessera commentedon Oct 6, 2026
Decision (maintainer, 2026-10-06): rulings for every listed item.
WsHost(ui-server)@internalor retyped to the minimal interface embedders use (as documented in the ui-server README anddocs/conditional-forms.md).api-report/ui-server.txtno longer recordsClientSet,SessionCatalogor the other reached internals.useChatStore,useFileStore,useShareStore,useUIStore,useVoiceStore)ChatState,UIState…) leave the public surface.repoRelativePathSchema, ClaudeMEASURED_RUNTIME, jobsrunScrapedocs/integration-contract.md,docs/extending/agent-backends.mdand the module-jobs README. Each gets its consumer role stated in that user-facing doc.collectStats/internalbun:sqlitehandle, which must not become a 1.0 obligation. The integration contract's wording describes the stats behaviour, not the export. This settles the ruling #701 deferred here./serverbridge-tool handlers (handleAskUser*,handleShowBlock…),wrapCommand,execWrapperSpawnOptions,describeRetry,canonicalModelId,resolveThinkingLevel,createToolRendererRegistry,pruneStoredShares,ShareTargetError,isShareTargetRequest,handleShareTargetRequest; ui-kitTOKENS,LIGHT_TOKENS,canvas; render-templateapplyExportLinkPolicy,protectExportLinkDestinations; geoMAX_ROUTE_BYTES/internalentryEvery narrowing and move is a pre-1.0 break:
CONTRACT:commit with the integration-contract update,docs/decisions/public-export-boundary.mdupdated, and a changeset naming each break.needs: decisionremoved; the issue isagent-ready.schlessera commentedon Oct 6, 2026
Claiming for implementation (claim token
w44-1053), branchrefactor/1053-narrow-public-surfaces. Implementing the 2026-10-06 ruling table exactly; thecollectStatsmove also settles the part #701 deferred here.CONTRACT: refactor(core,geo,render-template,ui-kit,ui-sdk,ui-server,u…
CONTRACT: refactor!: narrow public surfaces left by #534 (#1053) (#1089)
schlessera commentedon Oct 6, 2026
Done in #1089, squash
b0815ec3(verified an ancestor oforigin/main). Every item in the 2026-10-06 ruling table is implemented as written:WsHostand the ui-react store hooks are narrowed,repoRelativePathSchema,MEASURED_RUNTIMEandrunScrapeare documented, andcollectStatsand every other listed name are in the owning package's/internalentry. Geo gained an./internalentry forMAX_ROUTE_BYTES. The integration contract,docs/decisions/public-export-boundary.md, the API report and the changeset changed in the same commit. CI was green on the merged head (Depot run6hhgdgsdpb).Three choices the ruling left implicit, each recorded in the decision record:
TokenNamemoved withTOKENS, because it iskeyof typeof TOKENS.WsHostOptions.catalogis@internal, socreateAppis how a host is built.BrainUiServices.storesis@internal, because it reached every state shape.One item is outside the ruling and was left:
ActivityStreamstill reaches hono'sWSContext.CONTRACT: fix(ui-server): commit inbox lifecycle writes on the write …