Leave Python bytecode out of a pack's lockfile hash - #169
Merged
Merged
Conversation
A script gate runs its implementation from the pack directory, so each gate run can add __pycache__/ files there, per interpreter version. The lockfile hash counted them: after an agent's tool calls ran the java-security gate, `chock check --only verify` reported the pack as changed with no file in it edited. Plugin packaging and skill copying already skip bytecode; the pack hash now does too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Claude <noreply@anthropic.com>
jothimani-rajendran
marked this pull request as ready for review
September 27, 2026 13:37
…ycache Signed-off-by: Claude <noreply@anthropic.com> # Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
In the first Copilot run of the java-security agent kit on Windows,
chock checkreportedjava-security: hash mismatchin a workspace where nobody had edited the pack.Cause: a script gate runs its implementation out of
.agents/policies/<id>/implementations/. Python therefore writes__pycache__/into the pack on the first gate run, per interpreter version, and more of it as more rules are imported.lock.compute_pack_hashhashed every file under the pack, bytecode included, so the lockfile ended up depending on which gates had run, on which Python.Reproduced:
kit.py doctoronce. That leaves 171.pycfiles in the pack.chock check --only verifyunder 0.11.3's hashing, and passes with this change.Fix: the pack hash leaves out
__pycache__/,.pycand.pyo, whichplugin/build.py,plugin/gate_package.pyandscaffold/skills.pyalready skip. A lockfile written while bytecode sat in a pack is reported once, andchock syncrewrites it (changelog says so).Definition of done
chock check→ 0 errors, 0 warnings, 0 infoschock check --only matrixpasses; matrix unchangedchock sync --repo . --checkcleanchock check --only verifyclean (chock's own lockfile unchanged)pytest: newtests/test_lock_ignores_bytecode.py. Bytecode leaves the hash alone (fails onmain); a source change still changes it.test_vendored_guardrails.pypasses.init,addor hook changeUnreleasedentryruff check .andruff format --check .cleanClaims
Meant to ship in 0.11.4 alongside #168.
🤖 Generated with Claude Code
https://claude.ai/code/session_01CzNYfzP8ymU3r4JB9Sz8Ha
Generated by Claude Code