Commit d76f7ba
fix: read __version__ from distribution metadata (#50)
`__version__` was a second hardcoded literal alongside `pyproject.toml` and
never moved, so it sat at "0.2.0" through both the 0.3.0 and 0.4.0 releases.
`cli.py` passes it to `@click.version_option`, so:
$ trace-tests --version
trace-tests, version 0.2.0 # from a 0.4.0 install
$ python -c "import importlib.metadata as m; \
print(m.version('agentrust-trace-tests'))"
0.4.0
Worse than a cosmetic slip. The v0.2 profile cutover shipped in 0.4.0 and a
0.2.x suite rejects every v0.2 record, so `--version` is precisely the command
someone runs to work out whether their suite matches their producer. It was the
one command that could not answer, and it actively misled: a correctly upgraded
user is told they still have the version that cannot verify their records.
Found while running the suite against a freshly minted record: the record failed
TR-ENV on the profile sentinel, and `--version` reported 0.2.0 both before and
after upgrading to 0.4.0, so it gave no signal that the upgrade had worked.
Fix reads the version from installed distribution metadata, removing the
duplicate literal so it cannot fall behind a release again. Stdlib only, no new
dependency. A source tree importable without an install has no metadata to read,
so that falls back to "0.0.0+unknown" rather than guessing a number and
reintroducing the drift.
Two regression tests: `--version` output must contain the distribution version,
and `__version__` must equal it, which fails if anyone restores a literal.
Verified: `pip install -e .` then `trace-tests --version` -> 0.4.0.
Full suite 118 passed, 5 xpassed (the 5 are pre-existing
`xfail(strict=False)` hardware-TEE cases in tests/test_level2.py, untouched).
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 9f45c97 commit d76f7ba
3 files changed
Lines changed: 50 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
5 | 11 | | |
6 | 12 | | |
7 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
0 commit comments