why is the python package version still showing as v0.1.0
- User
why is the python package version still showing as v0.1.0
Assistant· claude-opus-4-8
Let me look into how the version is defined and reported.
Assistant· claude-opus-4-8
The version shows
v0.1.0for two compounding reasons:1. The version is hardcoded and never bumped.
pyproject.toml:3has a staticversion = "0.1.0". There's no dynamic versioning (no git-tag-derived version like hatch-vcs); the literal0.1.0has sat there since the package was created. So even a fresh install would still say0.1.0.2. The reported version comes from frozen install metadata, not the source.
_package_version()indrain_cycle/telemetry.py:109callsimportlib.metadata.version("drain-cycle"), which reads the installed package's*.dist-info/METADATA, not the livepyproject.toml. The installed copy here confirms it:code- User
yes and bump it to version 0.5.0
- User
this project is always coded by AI agents i don't use git tags i need this version bumping to happen automatically what options are there
Assistant· claude-opus-4-8
Let me check what infrastructure already exists to ground the options.
Assistant· claude-opus-4-8
Good — that clarifies the constraints. The existing git hooks are all owned by the Entire CLI (local, not checked in), there's no CI, and no version tooling. So whatever we add has to be project-owned and self-contained.
The crux is the editable-install caveat I found:
importlib.metadata.version()reads frozendist-infometadata. Anything that writes a new number intopyproject.tomlstill won't show up in the running tool untiluv tool install --forcereruns. That reshapes the options — the truly "automatic, no reinstall" paths are the runtime-derived ones.Here are the real options:
Assistant· claude-opus-4-8
Before I build this, one thing I found changes the picture — and it's worth 30 seconds to get right.
The
v0.1.0you saw is fromuv tool list(thatvprefix is uv's format). That command reads the staticVersion:field baked into the installeddist-infoat install time. Runtime derivation cannot change whatuv tool listshows — only bumpingpyproject.tomland re-runninguv tool install --forceupdates that snapshot.So "always-moving runtime number" cleanly fixes these surfaces:
- Telemetry
service.version(what Honeycomb sees) ✅ — live, every commit - A
drain-cycle --versionflag ✅ — which, by the way, doesn't exist yet; I'd add it
…but it will not make
uv tool listmove, because for an editable install that field stays frozen until a reinstall rewrites it.To make
uv tool listitself bump automatically, you'd need the heavier path: a hook that rewrites thepyproject.tomlversion on each commit re-runs — that's real ceremony for a line you rarely look at.- Telemetry
Assistant· claude-opus-4-8
Decision made. Here's my plan — I'll build the clean version of what you approved.
Rather than rewriting
pyproject.toml's version line on every commit (which would pollute every diff with a bump line), I'll make the version dynamic from git commit count via the build backend. Same outcome foruv tool list—v0.1.<count>— but git stays the single source of truth, no version churn in commits, no off-by-one.Three pieces:
- Dynamic version (
0.1.<commit-count>) computed at build/install time →uv tool listshows it after any install. - Live runtime version for a new
drain-cycle --versionflag and Honeycombservice.version(adds short SHA + dirty marker). - post-commit hook that re-runs
uv tool install --forcesouv tool listcatches up automatically (guarded to skip drained worktrees).
Let me read the files I'll touch and measure the reinstall cost.
- Dynamic version (
Assistant· claude-opus-4-8
Now I'll build it. First, the shared version module:
Assistant· claude-opus-4-8
Now the build hook:
Assistant· claude-opus-4-8
Now update
pyproject.toml— make version dynamic:Assistant· claude-opus-4-8
I configured two mechanisms that conflict. Let me keep only the metadata-hook one that
hatch_build.pyimplements:Assistant· claude-opus-4-8
Now test the build resolves the version before going further:
Assistant· claude-opus-4-8
The build resolves to
0.1.223from commit count. Now wire telemetry and the--versionflag:Assistant· claude-opus-4-8
Let me reference the fallback constant instead of hardcoding it:
Assistant· claude-opus-4-8
Now add the
--versionflag to the CLI:Assistant· claude-opus-4-8
Add
--versionto the usage text:Assistant· claude-opus-4-8
Now reinstall and verify all three surfaces, and measure the reinstall time:
Assistant· claude-opus-4-8
All three surfaces work. The telemetry error was just my bare-python invocation missing deps — let me verify it through the project env, and confirm the reinstall is fast (~0.5s, deps cached):
Assistant· claude-opus-4-8
Telemetry reports the live version too. Now run the test suite to confirm nothing broke:
Assistant· claude-opus-4-8
454 pass. Now the post-commit reinstall trigger. The existing
post-commithook is owned by the Entire CLI, so I'll chain after it rather than replace it, and guard against drained worktrees (which commit constantly and must not repoint the global install).Assistant· claude-opus-4-8
Let me verify the hook's worktree guard resolves correctly in this checkout:
Assistant· claude-opus-4-8
Guard and syntax are correct. Let me run lint and do a final check for anything I missed:
Assistant· claude-opus-4-8
ruff isn't installed (it's optional). The only remaining
0.0.0/0.1.0are the intended fallbacks. One cleanup — my first-party import landed between stdlib and third-party; let me put it in the conventional first-party position:Assistant· claude-opus-4-8
Let me clean up the test build artifact:
Assistant· claude-opus-4-8
Done. The version now tracks git commit count automatically, and all three surfaces are live.
What changed
File Role drain_cycle/_version.py(new)Computes the version from git rev-list --count HEAD. → ; adds short SHA + .- User
yes
Assistant· claude-opus-4-8
I'll add the committed installer, align the live hook to match it, note it in AGENTS.md, then commit.
Assistant· claude-opus-4-8
Now reset the live hook to Entire's original and run the installer so the live hook matches the committed script's marker format:
Assistant· claude-opus-4-8
Installer is idempotent and the live hook matches. Now add a discoverability note to AGENTS.md:
Assistant· claude-opus-4-8
Now I'll follow the workflow governance before committing. Let me read the mandatory rule files and check branch state.
Assistant· claude-opus-4-8
I'm on
feat-scorecard-dashboard, not main (it changed during the session). My version work is unrelated to scorecard — let me check the branch state before committing so I don't bundle unrelated changes.Assistant· claude-opus-4-8
Before I commit, I hit something worth flagging — the working tree isn't clean the way I assumed.
The branch switched to
feat-scorecard-dashboardduring the session, and it carries unrelated, uncommitted scorecard work that isn't mine:- My version work:
_version.py,hatch_build.py,pyproject.toml,drain_cycle/cli.py,drain_cycle/telemetry.py,uv.lock,AGENTS.md,scripts/ - Pre-existing scorecard work (not mine):
drain_cycle/scorecard.py,tests/test_scorecard_exit.py,tests/test_scorecard_rows.py,tests/test_scorecard_render.py
The branch sits at the same commit as
main(0 ahead, 0 behind), so all of this is uncommitted. My files and the scorecard files are disjoint, so I can stage just mine cleanly — the question is where, and I don't want to entangle my change with someone's in-progress scorecard work.- My version work:
Assistant· claude-opus-4-8
New branch it is. Let me create it, verify the
uv.lockchange is mine (not the scorecard work's), and stage only my 8 files.Assistant· claude-opus-4-8
uv.lockis mine (the0.1.0→0.1.223root-version line). Worth noting: because the version is now dynamic, that lock line will drift by one after each commit and re-sync on the nextuv run— cosmetic, but I'll flag it. Creating the branch and staging only my 8 files:Assistant· claude-opus-4-8
Clean split — staged is my 8 files, scorecard work left untouched. Now the governance gates: code-review and writing-refinement. I'll run both as sub-agents in parallel — the reviewer on my staged diff, the writing pass on the commit message + AGENTS.md prose.
Assistant· claude-opus-4-8
Both gates passed — review APPROVED (no Critical/Required; the one optional note about
--version --watchfalling through is standard CLI behavior, leaving it). Let me apply the refined AGENTS.md wording, re-stage, and commit with the refined message.Assistant· claude-opus-4-8
Committed (
8a5b722). The post-commit hook should have fired and rebuilt the install — let me verify it bumped to0.1.224, and confirm the scorecard work is untouched:Assistant· claude-opus-4-8
The hook fired but
uv tool liststill shows223despite count being224. That's a real bug: uv caches the editable build by source-file content, and a new commit doesn't change any tracked file — so--forcereinstalls from the cached wheel with the stale version. Let me confirm and find the right cache-busting flag:Assistant· claude-opus-4-8
--reinstallbusts the cache correctly (0.1.224); plain--forcedoesn't. Let me check if the narrower--reinstall-packageis enough (faster — rebuilds only drain-cycle, not all deps) and measure timing:Assistant· claude-opus-4-8
Found a real bug in my hook.
--forcereuses uv's cached build, so it reflects whatever version was last built, not the current commit. The fix is--reinstall-package drain-cycle, which implies--refresh-package— it busts the build cache and re-runs the version hook, in the same ~0.5s. Let me fix both the committed installer and the live hook, then amend (commit isn't pushed yet):Assistant· claude-opus-4-8
Now re-sync the live hook by removing the stale block and re-running the fixed installer:
Assistant· claude-opus-4-8
Now amend the commit with the fixed installer (only
scripts/install-git-hooks.shchanged), then verify the hook works end-to-end:Assistant· claude-opus-4-8
Hook works end-to-end: count
224→uv tool list v0.1.224→--version 0.1.224+g88b5c77.dirty(the.dirtycorrectly reflects the still-uncommitted scorecard work, which is intact). Now push and open the PR per the graphite governance:Assistant· claude-opus-4-8
The graphite rule covers reviewer-comment handling on existing stacks; this is a single standalone PR off main, so I'll push and open one PR directly (the uncommitted scorecard work stays safely out of it). Let me push and create the PR — the body reuses the already-refined commit prose:
Assistant· claude-opus-4-8
Done. PR opened: https://github.com/ababushkin/drain-cycle/pull/53
Summary
The version now tracks the git commit count automatically across all three surfaces, with no tags and no manual bumps.
What landed (branch
feat-auto-version, 8 files):_version.py+hatch_build.py— version derived fromgit rev-list --countat build time ()