Repository navigation
fix(cli): run's cache key includes the compiler's version - #121
Merged
Merged
Conversation
The key held the compiler COMMAND, which a pixi.lock or MAX bump leaves unchanged, so after a toolchain upgrade `napi-mojo run` kept its cached binary: the new compiler never saw the code, and the old binary loaded the new runtime, since it finds libKGENCompilerRTShared through its RUNPATH (the environment's lib/) and pixi upgrades that directory in place. The key now includes what `<command> --version` prints, e.g. "Mojo 1.1.0 (8189361e)", build hash included, so one nightly to the next counts as a change. One probe per run, measured here: cached runs went from 155-192 ms to 212-252 ms (~55 ms through `pixi run`, ~17 ms calling the binary directly). A compiler that runs but reports no version turns the cache off for that run, with a warning, rather than keying on nothing; one that cannot run at all stays silent, because the compile then fails with the full advice. Two stub-compiler tests (the stub now answers --version from a file): a changed version recompiles, and a compiler that cannot report one is never served from the cache. Each of the three rules was reverted once and caught. With the real toolchain and a wrapper that only changes the reported version: unchanged, 212 ms and the binary untouched; changed, 2.2 s and rewritten. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013tXV7MkRfP97g5hPfNNXHC
codetalcott
marked this pull request as ready for review
September 26, 2026 16:27
codetalcott
enabled auto-merge
September 26, 2026 16:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the gap CLAUDE.md recorded in #120:
napi-mojo runkept its cached binary across a toolchain upgrade.What was wrong
The cache key held the compiler command (
pixi run mojo), and apixi.lockor MAX bump leaves the command unchanged. After an upgrade, the nextruntherefore:libKGENCompilerRTSharedthrough its RUNPATH, the pixi environment'slib/, and pixi upgrades that directory in place. Checked withreadelf -don a builthost.node.The fix
<command> --versionprints, e.g.Mojo 1.1.0 (8189361e). The build hash is part of that output, so moving from one nightly to the next also triggers a rebuild.Cost is one probe per run. Measured locally, cached runs went from 155–192 ms to 212–252 ms: about 55 ms through
pixi run, 17 ms calling the binary directly.Tests
tests/cli.test.js; the stub now answers--versionfrom a file:--mojowrapper that changes only the reported version:npm test: 837 passed, 12 skipped.check-doc-samples,generate-rules-extract --checkandsync-versions --checkpass.🤖 Generated with Claude Code
https://claude.ai/code/session_013tXV7MkRfP97g5hPfNNXHC
Generated by Claude Code