Skip to content

Check unused TypeScript locals and trim surplus exports - #3423

Merged
max-sixty merged 1 commit into
mainfrom
unused-code-checks
Oct 21, 2026
Merged

max-sixty merged 1 commit into
mainfrom
unused-code-checks

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Enable TypeScript's existing noUnusedLocals check in the browser framework and Worker, add the Python eval fixtures to the existing Vulture scan, and remove two unused type imports plus seven surplus exports. The implementations behind those exports remain live inside their modules; the geometry ownership table now points callers at the remaining exported helpers.

Vulture 2.16 and the JavaScript export test were already installed. Vulture passes with the existing framework exclusions; removing those exclusions produces 217 findings dominated by framework callbacks and pytest declarations. A one-off Knip 6.42.1 scan, with served-path resolution and generated bundles excluded, produced 258 export/type findings and six actionable runtime exports. The rest of the inspected candidates have Python, registry, generated-code or documented public readers. A second configuration naming host entry points reduced this to 30 remaining findings after cleanup, including generated types and helpers called from Python. Knip is not added as a standing gate: it misses all seven motivating object fields/methods, and handling Leaf's non-JavaScript readers would require more integration. Removing the unused type imports also let the existing export check identify the seventh surplus export, LocalAction.

Validation: pnpm run check (131 build, 505 runtime, 84 Worker tests), rebuilt bundles, the export check and one focused keyboard browser test, and pre-commit on the changed files. Runtime tests and the browser build check passed again after the export cleanup. The full-tree pre-commit run also passed every hook except an unrelated undefined write_record in tests/model/test_codex_app_server.py, reproduced in base commit 2549c0565.

CI: the exact head was approved by the automated reviewer. The test job failed on the existing test_a_turn_that_shares_a_user_message_leaves_the_delivery_owed cases (status.json lookup and an invalid turn/started notification), as well as the Ruff error above. The completed/start-joins-follow-up case reproduces the status.json failure on main at 8a36017c09b27c90a6c41ce6ad6d2aaac19af13e; the affected Python sources are unchanged by this PR. These unrelated failures are permitted by the repository landing policy.

This was written by Codex on behalf of max-sixty

@max-sixty
max-sixty merged commit 287cbe6 into main Oct 21, 2026
2 of 3 checks passed
@max-sixty
max-sixty deleted the unused-code-checks branch October 21, 2026 04:38
max-sixty added a commit that referenced this pull request Nov 2, 2026
The JavaScript export check (`tests/journeys/test_unused_exports.py`)
ran only in the daily `journeys` tier. That run has failed every day
this week, with over a hundred failures each time, so an orphaned export
reached main and stayed until Tend triaged the daily report: #4724 and
#4873 left seven on 30 and 31 October, and #5014 removed them on 1
November. Vulture, its Python counterpart, runs as a pre-commit hook,
which both landing paths (a pull request's lint step and `wt merge`'s
pre-merge) run over the whole tree, so the change that orphans a Python
definition is the one told.

This moves the export check beside vulture:

- `leaf-dev unused-exports` holds the check, unchanged, with the test's
docstring as its module header. It takes about two seconds.
- `.pre-commit-config.yaml` runs it as `unused-exports`, woken locally
by the file kinds that export or read (`.js`, `.mjs`, `.ts`, `.py`,
`.html`, `.md`, `worker/wrangler.toml`). CI runs every hook on every
file.

It also removes what #5014's deletion of `since-seen.js` left behind:

- the `keepalive` option of `deliverBookkeeping` and `postEvent`, which
only the departing `seen` send set, and `runtime.seen`, which only
`since-seen.js` read;
- the six arrival tests skipped while `since-seen.js` was unmounted. The
module, renamed `test_changes_in_place.py`, keeps the comparison and
at-work tests;
- the prose in `change-walk.js`, `events.md`, `read_state.py`,
`agent_state.py` and `browser/AGENTS.md` that described the turned-off
marking. The server's reading of `seen` events is unchanged, and no tab
posts one.

And it drops the `uuid` devDependency, which no module imports. A
one-off knip scan of dependencies flagged 33; the other 32 are bundled
from `build/entries`, loaded by evals or `tests/*.mjs`, or resolved as
types and peers. As #2326 and #3423 found for exports, knip would need
more configuration than it saves, so it is not added as a gate.

Validation: `leaf-dev unused-exports` and every pre-commit hook pass on
the changed files; `pnpm run check:browser`, the 737 runtime tests, and
the browser test for comparison bars and the `h` walk pass.

> _This was written by Claude Code on behalf of max-sixty_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants