Repository navigation
fix: --version reports the installed package's version, not the core crate's literal - #970
thekevinbot wants to merge 6 commits into
Conversation
…alled The distcheck gates -- the tier whose whole job is to install the published artifact and run it -- asserted only that `dirsql --version` printed the word "dirsql". That blind spot let #958 ship: wheels and npm packages published at 0.4.x print `dirsql 0.2.7`, the on-disk literal of the Rust core crate compiled into them, because only the crates.io release lane rewrites it. Both gates now compare the exact string against the version the package manager installed -- the wheel filename for pip, the installed package.json for npm. The python e2e suite makes the same assertion against a dev build (and drops the binary staging that #738 made dead). `packages/python/Cargo.toml`'s placeholder moves 0.2.7 -> 0.0.1 so it stops coinciding with the core crate's. With the two equal, the python assertion passes even when the CLI is reading the core crate's version -- exactly the coincidence that hid the bug; the npm lane's placeholder already differed, which is why its gate goes red on today's code. RED on CI, both for the same reason (run 32398805851 / 32398805744): `dirsql --version` printed 'dirsql 0.2.7', expected 'dirsql 0.0.1' Refs #958 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DGHtvJMekPAB9qweTsTNK9
`--version` rendered the `dirsql` core crate's `CARGO_PKG_VERSION`. Only the crates.io release lane rewrites that literal, so the binary was right and both bindings -- which embed the same crate but publish on their own version lines -- printed `dirsql 0.2.7` on every release since 0.2.7 (#958). Each artifact now reports the version of the manifest its own publisher rewrites: crates.io binary the core crate's CARGO_PKG_VERSION (unchanged) PyPI wheel dirsql-py-ext's CARGO_PKG_VERSION, which maturin writes into the wheel and the module already exports as `__version__` -- now one constant, so the CLI and the SDK cannot disagree npm package packages/ts/package.json, read by the launcher and passed to the addon The core gains `cli::run_cli_with_version(argv, version)`; `run_cli` keeps its signature and delegates with its own version, so `cargo install dirsql --features cli` is untouched. Parsing moves from the derive's `try_parse_from` to building the command and overriding `.version()`, which needs clap's `string` feature (an owned version string). The plumbing is deliberately asymmetric across the bindings, because the manifest a publisher rewrites differs: pyo3's `run_cli(argv)` keeps its signature and bakes its crate version in, while napi's `runCli(argv, version?)` takes one, since the addon crate's version is a workspace placeholder no npm release touches. Omitted, the core's version still stands. Verified by running the artifacts, not only the tests: packages/python/.venv/bin/dirsql --version -> dirsql 0.0.1 node packages/ts/dist/cli/dirsql.js --version -> dirsql 0.0.1 ./target/debug/dirsql --version -> dirsql 0.2.7 (the crate) and both distcheck flows, which install the built wheel / packed tarball and compare against what the package manager recorded, now pass. Fixes #958 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DGHtvJMekPAB9qweTsTNK9
5206c15 to
b45d84f
Compare
The TS mutation gate surfaced `main.ts:32 BlockStatement (-> {})` as a
surviving mutant: with `try { return … } catch { return undefined }`, emptying
the catch body still yields `undefined` implicitly, so no assertion can tell
the two apart -- an equivalent mutant, and an exemption is not the fix here.
Assigning inside the `try` and returning after it makes the arm observable:
emptied, execution falls through and destructures `undefined`, which the
"falls back to undefined rather than failing the CLI" test now catches
(verified by applying the mutant by hand: TypeError, 1 failed | 10 passed).
Behavior is unchanged.
Refs #958
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DGHtvJMekPAB9qweTsTNK9
|
Closing unfixed — this belongs upstream, not here. The stale This PR worked around that by resolving the version from the host package's manifest at runtime and threading it into dirsql#958 stays open until upstream lands and dirsql re-releases. Branch Generated by Claude Code |
Fixes #958
Root cause
--versionrendersCARGO_PKG_VERSIONof thedirsqlcore crate(
packages/rust/Cargo.toml, literal0.2.7). putitoutthere rewrites that literalin the crates.io lane only — the PyPI wheel and the npm addon are built from a
checkout where it is untouched, while their own manifests are rewritten to the real
release version. So every published wheel and npm package since 0.2.7 has printed
dirsql 0.2.7, whatever version it actually was.There is no single literal to fix: the version has three correct sources, one per
publish lane.
Fix
CARGO_PKG_VERSION— unchangeddirsql-py-ext'sCARGO_PKG_VERSION, which maturin writes into the wheel and the module already exports as__version__— now one constant, so the CLI and SDK cannot disagreepackages/ts/package.json, read by the launcher and passed to the addonThe core gains
cli::run_cli_with_version(argv, version);run_clikeeps itssignature and delegates with its own version. ~35 lines of code across five files;
the rest is the tests and the fragments the gates require.
packages/python/Cargo.toml's placeholder moves0.2.7→0.0.1. It is aplaceholder either way (the release tooling rewrites it), but while it equalled the
core crate's, the python distcheck assertion below passed whether or not the CLI read
the right source — the coincidence that hid this.
Regression guard
dirsql-distcheckinstalls the published artifact and runs it; it asserted only thatthe output contained the word "dirsql". Both flows now compare the exact string
against the version the package manager installed — the wheel filename for pip, the
installed
package.jsonfor npm.RED first, on CI, both flows for the same reason
(python,
ts):
E2E Verification
cargo test --workspace --features cli --no-fail-fast)packages/python/e2e-attestation.jsonrefreshedpackages/ts/e2e-attestation.jsonrefresheduv run python -m pytest tests/e2e/ -x -q(packages/python)pnpm test:e2e(packages/ts)cargo test --workspace --features cli --no-fail-fastdirsql-distcheck node/dirsql-distcheck python— both OKrelated to this change:
vtab.rs::unreadable_file_yields_null_content_…(thesandbox runs as root, so a
chmod 000file is still readable) and onesdk.rs::it_streams_watch_eventswatcher timing flake that passed on re-run.Manual exercise (the point of the fix, not just the tests):
Changelog / Migrations
packages/<pkg>/changelog.d/for each changed package (rust, python, ts)output correct, and no API breaks. The one visible shift is that a source
checkout now reports
0.0.1where the CLI used to say0.2.7; publishedartifacts only gain the right number. Say the word and I'll add fragments.
Parity
PARITY.mdupdated. This restores parity rather than introducing drift: thecrates.io binary was already correct and both bindings now match it. The plumbing is
asymmetric on purpose (pyo3 bakes its crate version in, napi takes an optional
argument) because the manifest a publisher rewrites differs per lane; both surfaces
are launcher-facing, not SDK API.
Follow-up spotted, not fixed here
persist.rs/parsed_cache.rsstamp the same core-crate literal into the cache asan invalidation key, so a wheel or addon writes
0.2.7for every release — a corechange that alters parsing will not invalidate an existing cache. Same root cause,
different blast radius; worth its own issue rather than widening this PR.