Repository navigation
Description
Context
Nothing in bun run lint or the test suite notices an export that no other file imports. The api-report (tests/api-surface.test.ts) only covers names reachable from a package entry point. A module-level export that no entry re-exports and no other file imports passes every gate. The repository review on 2026-10-22 (dcf5341aa) found many:
- ui-server: 207 exported declarations in
packages/ui-server/src(111 types, 96 values) whose name appears in no other file in the repo, CHANGELOGs excluded. Examples:handoffTranscriptandcheckHandoffReferences(src/ws/handoff.ts),boundFollowUpText(src/ws/turns.ts),inProcessPlannerandvalidatePlan(src/brain/application.ts),inQuietHoursand nineACTION_*constants (src/inbox/notify.ts). - ui-kit: about 15 more, for example
clusterLetter(src/blocks/MapView.tsx:385),moveRankItem(src/decisions/AskUserRankCard.tsx:34),diffRows(src/primitives/DiffBlock.tsx), and theTRACKER_*constants insrc/blocks/TrackerPillList.tsx. - ui-react: five exports used only in their own file:
selectBackendForProvider(packages/ui-react/src/stores/provider-state.ts:101),normalizeDirPath(src/stores/file-state.ts:548),isUnconfirmed(src/lib/answer-delivery/types.ts:117),CountBadge(src/components/activity/span-bits.tsx:296),ViewerError(src/components/files/file-viewer-frame.tsx:112). This issue owns dropping theirexport; ui-react: default-root wrappers left by the export cut have no caller or only test callers #2535 only deletes ui-react's default-root wrappers.
A hand clean-up would regrow, and a naive one would be wrong in places:
- Some of the 111 ui-server types are the options or result types of an exported function (
BackendRegistryOptions,src/agent/backend.ts;SubscriptionMonitorOptions,src/agent/subscription.ts). Dropping theirexportmeans a caller can no longer name the type. Keeping or dropping each is a per-case call. - A declaration the api-report records, as an entry export or as one reached from a public signature, must stay exported. The export-boundary rule says so (
docs/decisions/public-export-boundary.md:75-76: "a type reachable from a public signature is public with it").
How the ui-server count was produced:
for f in $(find packages/ui-server/src -name '*.ts'); do
grep -oE '^export (async )?(function|const|class|let|type|interface|enum) [A-Za-z0-9_]+' "$f" | awk '{print $NF}' |
while read sym; do
[ "$(git grep -lw "$sym" -- . ":!$f" ':!**/CHANGELOG.md' | wc -l)" = 0 ] && echo "$f $sym"
done
done | wc -l # 207Scope
- Add a check to
bun run lint(scripts/lint.ts) that, for thesrc/of ui-server, ui-kit and ui-react only, reports an exported declaration that (a) no other file in the repo imports, and (b) is not recorded anywhere inapi-report/<package>.txt, whether as an entry export or as a declaration reached from a public signature. - Drop the
exportkeyword from what it reports in ui-server, ui-kit and ui-react (including the five ui-react names above), or delete the declaration where it is also unused in its own file. Then make the check required for those three packages. - The package list is explicit in the check's source. Other workspace packages are not scanned by this gate; extending it to them is follow-up work, filed as its own issue from the PR.
- The check runs offline and deterministically, like the other lint gates. Choosing an existing tool or a script under
scripts/is up to the implementer. Verify the tool's current API against its installed version rather than from memory.
Out of scope
- Entry-point exports, which
tests/api-surface.test.tsalready governs. - Unused
./internalentry names (separate issues) and test-only code insrcthat some test does import. - Scanning or cleaning packages other than ui-server, ui-kit and ui-react. The required gate does not report them, so it never fails on an unreviewed package.
- Deleting ui-react's default-root wrappers (ui-react: default-root wrappers left by the export cut have no caller or only test callers #2535).
Acceptance criteria
-
bun run lintfails on a newly addedexport function unusedProbe() {}inpackages/ui-server/src, naming the file and symbol; mutation recorded in the PR. - It does not fail on a declaration recorded in the package's api-report signature section (a fixture or a named existing case proves this).
- After the clean-up, the check passes for ui-server, ui-kit and ui-react with no allowlist entries, or with each allowlist entry carrying a one-line reason.
-
git grep -nE '^export function (selectBackendForProvider|normalizeDirPath|isUnconfirmed|CountBadge|ViewerError)\b' -- packages/ui-react/srcreturns nothing. - A newly added unused export in a package outside the three (for example
packages/core/src) does not failbun run lint, proving the enforced scope is the stated one. -
bun run typecheck,bun run testandtests/api-surface.test.tspass, and no api-report changes except for removed non-entry names.
Verification
bun run lint
bun run typecheck
bun run testContract impact
None. Only names outside every entry point change.
Found by a repository review on 2026-10-22.
2026-10-24: took sole ownership of the five ui-react own-file export removals (removed from #2535) and fixed the required gate's initial enforcement to ui-server, ui-kit and ui-react, with other packages unscanned until a follow-up.
Activity
schlessera commentedon Nov 3, 2026
Claiming (token
c2536-6bcd). Branchchore/2536-unused-export-gate, based on theepic/2542-dead-codeintegration branch at9df9192f3. Citations re-checked at that base: the five ui-react names andpublic-export-boundary.md:75-76still hold.collisions.ts --pathsreports closure-only overlap with 38 open PRs that touch the ui workspaces, and no path collisions onscripts/lint.ts. The cleanup will touch many ui-server, ui-kit and ui-react files, so I'll re-run it against the PR and record the result there. This stays clear of #3413 and #3412, which only touch the ui-sdk./internalentries.schlessera commentedon Nov 3, 2026
PR #3448 (head
f54c4b768, againstepic/2542-dead-codeatb29668b29) adds the gate tobun run lintand clears 478 exports in ui-server, ui-kit and ui-react. 18 allowlist entries remain, each with a reason. Extending the gate to the other packages is #3438. This issue closes when the epic batch lands on main. Hosted proof is pending; localcheck:prpassed.chore(ci): refuse exports no other file imports in ui-server, ui-kit …