Skip to content

bug(scripts): build leaves compiled tests for deleted sources in dist, and they still run #5641

Description

@sunrioa

What happened

npm run build compiles into each workspace's dist without removing output whose source no longer exists. After pulling a change that deletes a test file, the previously compiled copy stays in dist and test:dist keeps executing it.

Concretely, #5545 removed the Command Code GO provider along with packages/runtime/src/__tests__/commandcode-cli-language-model.test.ts and packages/runtime/src/__tests__/connection-usage.test.ts. In a working tree that had been built before that commit, npm run build afterwards left both compiled files in place, and npm --workspace @maka/runtime run test:dist ran them:

✖ resolves to the CLI wire with reasoning replayed as reasoning blocks
  error: '"commandcode-go" is retired and can no longer resolve a model runtime.'

That is six failures in one suite, all from code the repository no longer contains. The failures are deterministic and identical on Node 22 and Node 24, so they do not look environmental; the obvious reading is a real regression in the change being tested. It took several rounds of bisecting an unrelated branch to notice that the failing test had no source file.

npm run rebuild clears it, because scripts/clean-build.mjs removes each workspace dist wholesale before building. The gap is that build alone never prunes, and nothing warns.

Expected: a build either prunes output whose source is gone, or says that stale output is present.

How to reproduce

  1. Check out a commit before bd39677ec, then npm ci && npm run build.
  2. Check out current main and run npm run build again (not rebuild).
  3. ls packages/runtime/dist/__tests__/commandcode-cli-language-model.test.js — still present, with no source file.
  4. npm --workspace @maka/runtime run test:dist — six failures from the deleted suite.
  5. npm run rebuild — the file is gone and the suite passes.

Environment

  • Maka commit: 9082cf144 (main)
  • OS: macOS 26.5.2, arm64
  • Node.js: v22.23.1 and v24.21.0 (identical results)
  • npm: 11.19.0
  • Surface: build tooling

Logs, screenshots, or additional context

This is most likely to bite long-lived worktrees, where a tree may have been built weeks earlier and is never cleaned.

Cheapest fix that keeps build incremental: after compiling a workspace, list dist/**/*.test.js whose src counterpart is missing and fail, or remove them. Alternatively, document rebuild as the expected command after pulling.


Analysis produced with Claude Code; the reproduction and the referenced commits were reviewed by me.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions