feat(release): refuse a release whose HEAD tree is not the audited one

pkgmgr release --expect-tree TREE closes the window between an external audit and the fetch pkgmgr runs itself, where a push could ship an unaudited tree (Skills request, req 076). git_ops.ensure_head_tree compares git rev-parse HEAD^{tree} with the given sha and raises RuntimeError on mismatch; _release_impl calls it right after ensure_clean_and_synced and before any file write, release() with --retry before retry_release pushes anything. expect_tree is keyword-only without a default and every caller passes it. README section added; the --force help is reworded (MEDUSA EXA004 false positive on the old text).

| 🌿 Branch | 📊 Diff stat | 🎯 Fix | 💥 Break | 💸 Tokens | ⏱️ Velocity | 🛡️ Security | 🏆 Score | Gate |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| feature/release-expect-tree | 9 files +120/-11 | 93 % | 2 % | – | – | 100 % | 91 | ✅ 90/5, tokens and velocity <= 100, security 100 % |

Evidence: 45 targeted tests OK (5 new expect-tree tests), full unit suite 521 OK, ruff clean, MEDUSA 100 % critical 0. Break 2 %: an external caller of release() or _release_impl() must now pass expect_tree. Operator review 91234f6d (re-card of f538413a).
Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-30 19:44:29 +00:00
1 parent 2c70837d00
commit 29cb898a0a
9 files changed
+120 -11

No files matched your search

+3 -1
View File
@@ -383,7 +383,9 @@ class TestPushMirrorLeases(unittest.TestCase):
with redirect_stdout(io.StringIO()), self.assertRaises(PushRefusedError):
_release_impl(
pyproject_path=os.path.join(self.repo, "pyproject.toml"), force=True
pyproject_path=os.path.join(self.repo, "pyproject.toml"),
force=True,
expect_tree=None,
)
self.assertEqual(git(self.repo, "rev-parse", "HEAD"), head)