Repository navigation
Open
Labels
agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: backendsAgentBackend implementations and the seam they share.area: ui-reactReact chat/files/voice components, stores, WebSocket transport.area: ui-sdkWire protocol, runtime schemas, the server and client SDK surfaces.contractTouches the integration contract: CONTRACT: commit, contract doc updated in the same commit.priority: p3Someday. Needs a driving use case before it starts.type: refactorStructure changes; behaviour does not. No changeset-visible effect.
Description
Context
Small pieces of configuration and protocol logic are copied across packages with no shared source:
- Reverse-geocode configuration.
resolveLocationReverseGeocodeConfigis identical inpackages/ui-backend-claude/src/location-tool.ts:18-26andpackages/ui-backend-pi/src/bridge-tools.ts:74-82. The env descriptors behind it are also duplicated, including the literal defaults:BRAIN_UI_REVERSE_GEOCODE, the threeNOMINATIM_*variables,"https://nominatim.openstreetmap.org"and"brain-kit-ui/1.0"(packages/ui-backend-claude/src/config/env.ts:128,:172;packages/ui-backend-pi/src/config/env.ts:117,:139). If one default changes, the two backends geocode differently. - State-room exclusion list. The rule "attach
stateRoomto aresultunlessfailure.errorClassisworker_state_busy,session_too_largeorworker_state_exceeded" is the same inline string array in three packages:packages/ui-backend-claude/src/turn-runner.ts:217,packages/ui-backend-pi/src/turn-runner.ts:81andpackages/ui-react/src/hooks/websocket-handlers/chat.ts:383. The protocol already exports the class names asFIRST_PARTY_FAILURE_CLASSES(packages/ui-sdk/src/protocol.ts:1201).
git grep -n '"worker_state_busy", "session_too_large", "worker_state_exceeded"' -- packages ':!**/tests/**'
git grep -n 'function resolveLocationReverseGeocodeConfig' -- packagesScope
- Export
stateRoomEligible(failure), or an equivalent constant set built fromFIRST_PARTY_FAILURE_CLASSES, from@schlessera/brain-ui-sdk/protocol. Use it at the three sites. - Export the reverse-geocode env descriptors and
resolveReverseGeocodeConfig(env)from@schlessera/brain-ui-sdk/server, which already ownsReverseGeocodeConfig. Each backend's env chokepoint spreads the descriptors and passes its ownprocess.envread, so the "only file that reads process.env" rule still holds. Delete bothresolveLocationReverseGeocodeConfigcopies.
Out of scope
resolveExecConfigin both backends. backends: resolve the exec wrapper from the host's app config instead of process.env #1429 is reworking it (draft PR CONTRACT: fix(backends): use the host app exec wrapper #2397); fold it in only after that lands.- The two
SessionTooLargeErrorclasses (packages/ui-backend-claude/src/worker-state.ts:23,packages/ui-backend-pi/src/worker-protocol.ts:12). They share an error class, but their constructors and messages differ on purpose. EnvVarSpecredeclarations in seven packages.- Behaviour or default-value changes.
Acceptance criteria
- The first grep above returns no
src/hits; the three sites use the shared helper. -
git grep -n 'brain-kit-ui/1.0' -- packages/ui-backend-claude/src packages/ui-backend-pi/srcreturns nothing. - A ui-sdk unit test covers the state-room rule for each first-party failure class, and one covers
resolveReverseGeocodeConfigdefaults and overrides. - Both backends' location-tool tests and the ui-react state-room tests pass unchanged.
Verification
bun run test packages/ui-sdk packages/ui-backend-claude packages/ui-backend-pi packages/ui-react
bun run api-report
bun run env-docs
bun run typecheckContract impact
Additive @experimental exports on @schlessera/brain-ui-sdk/protocol and /server: CONTRACT: commit, with the API report and contract updated. Env variable names and defaults are unchanged.
Found by a repository review on 2026-10-22.
Metadata
Metadata
Assignees
Labels
agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: backendsAgentBackend implementations and the seam they share.area: ui-reactReact chat/files/voice components, stores, WebSocket transport.area: ui-sdkWire protocol, runtime schemas, the server and client SDK surfaces.contractTouches the integration contract: CONTRACT: commit, contract doc updated in the same commit.priority: p3Someday. Needs a driving use case before it starts.type: refactorStructure changes; behaviour does not. No changeset-visible effect.
Activity