Skip to content

[build] strip dependency debug info, add clean-stale, fix pre-push hook path bugs - #538

Merged
paulirotta merged 3 commits into
mainfrom
chore/target-cache-management
Aug 3, 2026
Merged

[build] strip dependency debug info, add clean-stale, fix pre-push hook path bugs#538
paulirotta merged 3 commits into
mainfrom
chore/target-cache-management

Conversation

@paulirotta

Copy link
Copy Markdown
Owner

Summary

  • Add [profile.dev]/[profile.test] package."*" overrides (opt-level = 2, debug = 0) to strip dependency debug symbols while keeping line-table debug info for workspace crates — the single biggest lever on target/ size in a workspace this large.
  • Add cargo xtask clean-stale [--dry-run] [--max-age-days N], wired into scripts/check-guardrails.sh and scripts/pre-push.sh. Scoped to target/*/incremental/ only: cargo only bumps a dependency artifact's mtime when it recompiles it, so age-pruning deps//build/ would evict rarely-rebuilt but still-valid caches and force pointless relinks — incremental/ is the one directory where "old" reliably means "safe to discard."
  • Fix two pre-existing bugs in the hook scripts found while verifying this PR live, both of which silently broke AGENTS.md's own documented "Optional local guard" install instructions (cp scripts/check-guardrails.sh .git/hooks/pre-push):
    • PROJECT_ROOT was computed via dirname(BASH_SOURCE)/.., correct only when run as scripts/*.sh; copied to .git/hooks/pre-push it resolved to .git instead of the repo root, so every git command in the hook failed with "fatal: this operation must be run in a work tree." Fixed via git rev-parse --show-toplevel.
    • The arg parser hard-errored on any unrecognized argument, but git invokes pre-push with positional <remote-name> <remote-url> — so a real git push failed immediately with "Unknown argument: origin" before running a single check.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --workspace — 0 warnings
  • cargo nextest run -p ahma_common -p ahma_mcp — 3356/3356 passed
  • cargo nextest run --workspace --run-ignored all — 4691/4691 passed
  • cargo deny check (full, not just advisories, per AGENTS.md — Cargo.toml touched) — advisories/bans/licenses/sources all ok
  • Installed the fixed hook as .git/hooks/pre-push and ran a real git push end-to-end to confirm both bugs are actually fixed, not just theoretically

…tale

Add [profile.dev]/[profile.test] package."*" overrides (opt-level = 2,
debug = 0) so third-party dependencies build without full debug symbols
while workspace crates keep line-table debug info — this is the single
biggest lever on target/ size in a workspace this large.

Add `cargo xtask clean-stale [--dry-run] [--max-age-days N]`, wired into
scripts/check-guardrails.sh and scripts/pre-push.sh, to prune stale
target/*/incremental/ sessions. Scoped to incremental/ only: cargo bumps
a dependency artifact's mtime solely when it recompiles it, so age-pruning
deps/ or build/ would evict rarely-rebuilt but still-valid caches and force
pointless relinks on the next build — incremental/ is the one directory
where "old" reliably means "safe to discard."
…etic

Both hook scripts computed PROJECT_ROOT as dirname(BASH_SOURCE)/.. — correct
only when run as scripts/*.sh (one level under the repo root). Copied to
.git/hooks/pre-push per AGENTS.md's own documented install instructions,
dirname resolves to .git/hooks, so ".." lands on .git itself, and every
git command the hook runs (starting with `git status --porcelain`) fails
with "fatal: this operation must be run in a work tree" — silently
disabling the guard for anyone who installs it as documented.
git invokes .git/hooks/pre-push as <hook> <remote-name> <remote-url>, with
ref updates on stdin. The arg parser only recognized --phase/--allow-dirty
and hard-errored on anything else, so a real `git push` failed immediately
with "Unknown argument: origin" — the hook never got past its own CLI
parsing to run a single check.
@paulirotta
paulirotta enabled auto-merge (squash) August 3, 2026 15:45
@paulirotta
paulirotta merged commit 2525c40 into main Aug 3, 2026
4 checks passed
@paulirotta
paulirotta deleted the chore/target-cache-management branch August 3, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant