perf(build): stop full-tree recompiles triggered by git activity
The jcode-build-meta build script embeds version/git metadata that every
crate in the graph (base -> app-core -> tui -> cli) consumes via
`env!("JCODE_*")`. Two design issues made routine git activity force a
full-tree recompile (~18-25s) on essentially every incremental build:
1. It declared `.git/HEAD` and `.git/index` as `rerun-if-changed` inputs.
Those mtimes change on every `git add`, `git status`, commit, and
concurrent-agent git op. Cargo treats a build script as dirty when any
declared input is newer than its output, reruns it, and then force-
recompiles all dependents via StaleDepFingerprint -- even when the
emitted output is byte-identical.
2. It auto-incremented a persistent patch counter on every rerun, so the
embedded JCODE_SEMVER/JCODE_VERSION genuinely changed each time,
guaranteeing the cascade above actually invalidated everything.
Fixes:
- Derive the dev patch number deterministically from committed git state
(`base.patch + commits-since-base-tag`) instead of a side-effecting
counter. Pure function of HEAD; stable across rebuilds. Removes ~150
lines of counter + file-locking machinery.
- Drop the `.git/HEAD`/`.git/index` rerun triggers. Keep Cargo.toml and
the JCODE_RELEASE_BUILD / JCODE_BUILD_SEMVER / JCODE_BUILD_GIT_* env
triggers so release/dist builds (which set those) still embed exact
metadata, and a version bump still refreshes it.
Measured on this machine (selfdev, warm):
git/index touch: ~18-25s -> 0.65s (~30x)
git/HEAD touch: ~18s -> 0.87s
real code edit: ~20s -> ~20s (correctly unchanged)
Dev `--version` may lag the latest in-session commit's hash until the next
real rebuild; that is cosmetic and an acceptable trade. J
jeremy committed
8d87b2c00da3fb2c774a95f5d5f5e8159ec1ae2f
Parent: 83857b1