Skip to content

packages: rule on public surfaces kept only because a public declaration reaches them, before 1.0 #1053

Closed

Description

@schlessera

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. Its coordinator field is tagged @internal, so TurnCoordinator is excluded. api-report/ui-server.txt shows 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 native bun:sqlite handle) and repoRelativePathSchema;
    • ui-sdk /server's bridge-tool handlers (handleAskUser*, handleShowBlock …), wrapCommand, execWrapperSpawnOptions, describeRetry, canonicalModelId, resolveThinkingLevel, createToolRendererRegistry, pruneStoredShares, ShareTargetError, isShareTargetRequest and handleShareTargetRequest;
    • ui-kit TOKENS, LIGHT_TOKENS and canvas;
    • render-template applyExportLinkPolicy and protectExportLinkDestinations;
    • geo MAX_ROUTE_BYTES;
    • jobs runScrape;
    • Claude MEASURED_RUNTIME.

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 /internal entry, update the docs that name them, and update docs/decisions/public-export-boundary.md.

Out of scope

Acceptance criteria

  • Every item listed above has a recorded ruling on this issue (2026-10-06): WsHost and the ui-react store hooks (b) narrow; repoRelativePathSchema, MEASURED_RUNTIME and runScrape (a) keep and document; collectStats and every other listed name (c) move to the owning package's /internal entry.
  • For every narrowed or moved item, api-report/*.txt no longer records the narrowed internal shape. For example, after a WsHost narrowing, api-report/ui-server.txt contains no ClientSet or SessionCatalog block, unless the ruling keeps them.
  • Every in-tree consumer, every packed-package probe and bun scripts/check-dist-types.ts pass 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

  1. added
    type: refactor
    area: docs
    priority: p2
    needs: decision
    contract
    breaking
    on Oct 6, 2026
  2. added
    blocked
    area: core
    area: ui-sdk
    area: ui-server
    area: ui-react
    area: ui-kit
    area: render
    area: modules
    area: backends
    on Oct 6, 2026
  3. schlessera commented on Oct 6, 2026

    @schlessera
    OwnerAuthor

    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: docs stays for the decision-record update.

  4. schlessera commented on Oct 6, 2026

    @schlessera
    OwnerAuthor

    Unblocked: #534 is closed, so scripts/sync-project.ts is removing the blocked label.

  5. removed
    blocked
    on Oct 6, 2026
  6. schlessera commented on Oct 6, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-10-06): rulings for every listed item.

    Item Ruling What it means
    WsHost (ui-server) (b) narrow The entry point stays public for embedders. Fields that reach the connection, client-set, catalog and turn types are tagged @internal or retyped to the minimal interface embedders use (as documented in the ui-server README and docs/conditional-forms.md). api-report/ui-server.txt no longer records ClientSet, SessionCatalog or the other reached internals.
    ui-react store hooks (useChatStore, useFileStore, useShareStore, useUIStore, useVoiceStore) (b) narrow The hooks stay public for deployment shells, typed against minimal published state interfaces covering what shells read and call. The full zustand state shapes (ChatState, UIState …) leave the public surface.
    core repoRelativePathSchema, Claude MEASURED_RUNTIME, jobs runScrape (a) keep Already referenced as surface in docs/integration-contract.md, docs/extending/agent-backends.md and the module-jobs README. Each gets its consumer role stated in that user-facing doc.
    core collectStats (c) move to /internal Its signature takes a native bun:sqlite handle, 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.
    ui-sdk /server bridge-tool handlers (handleAskUser*, handleShowBlock …), wrapCommand, execWrapperSpawnOptions, describeRetry, canonicalModelId, resolveThinkingLevel, createToolRendererRegistry, pruneStoredShares, ShareTargetError, isShareTargetRequest, handleShareTargetRequest; ui-kit TOKENS, LIGHT_TOKENS, canvas; render-template applyExportLinkPolicy, protectExportLinkDestinations; geo MAX_ROUTE_BYTES (c) move to the owning package's /internal entry No documented consumer. A name can be added back after 1.0 in a minor once a real consumer appears.

    Every narrowing and move is a pre-1.0 break: CONTRACT: commit with the integration-contract update, docs/decisions/public-export-boundary.md updated, and a changeset naming each break. needs: decision removed; the issue is agent-ready.

  7. added
    agent-ready
    and removed
    needs: decision
    on Oct 6, 2026
  8. self-assigned this
    on Oct 6, 2026
  9. schlessera commented on Oct 6, 2026

    @schlessera
    OwnerAuthor

    Claiming for implementation (claim token w44-1053), branch refactor/1053-narrow-public-surfaces. Implementing the 2026-10-06 ruling table exactly; the collectStats move also settles the part #701 deferred here.

  10. schlessera commented on Oct 6, 2026

    @schlessera
    OwnerAuthor

    Done in #1089, squash b0815ec3 (verified an ancestor of origin/main). Every item in the 2026-10-06 ruling table is implemented as written: WsHost and the ui-react store hooks are narrowed, repoRelativePathSchema, MEASURED_RUNTIME and runScrape are documented, and collectStats and every other listed name are in the owning package's /internal entry. Geo gained an ./internal entry for MAX_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 run 6hhgdgsdpb).

    Three choices the ruling left implicit, each recorded in the decision record:

    • TokenName moved with TOKENS, because it is keyof typeof TOKENS.
    • WsHostOptions.catalog is @internal, so createApp is how a host is built.
    • BrainUiServices.stores is @internal, because it reached every state shape.

    One item is outside the ruling and was left: ActivityStream still reaches hono's WSContext.

  11. added this to the 0.41.0 milestone on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: backendsarea: corearea: docsarea: modulesarea: renderarea: ui-kitarea: ui-reactarea: ui-sdkarea: ui-serverbreakingcontractpriority: p2type: refactor

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions