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

@@ -108,6 +108,7 @@ class TestReleaseCommand(unittest.TestCase):
force=True,
close=True,
retry=False,
expect_tree=None,
)
@patch("pkgmgr.cli.commands.release.os.path.isdir", return_value=True)
@@ -143,6 +144,8 @@ class TestReleaseCommand(unittest.TestCase):
"patch",
"dummy-id",
"--preview",
"--expect-tree",
"4b825dc642cb6eb9a060e54bf8d69288fbee4904",
]
args = self._parse_release_args(argv)
@@ -157,6 +160,7 @@ class TestReleaseCommand(unittest.TestCase):
force=False,
close=False,
retry=False,
expect_tree="4b825dc642cb6eb9a060e54bf8d69288fbee4904",
)
@patch("pkgmgr.cli.commands.release.run_release")