Skip to content

Leave Python bytecode out of a pack's lockfile hash - #169

Merged
jothimani-rajendran merged 2 commits into
mainfrom
claude/lock-ignores-pycache
Sep 27, 2026
Merged

jothimani-rajendran merged 2 commits into
mainfrom
claude/lock-ignores-pycache

Conversation

@jothimani-rajendran

Copy link
Copy Markdown
Collaborator

What

In the first Copilot run of the java-security agent kit on Windows, chock check reported java-security: hash mismatch in 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_hash hashed every file under the pack, bytecode included, so the lockfile ended up depending on which gates had run, on which Python.

Reproduced:

  1. Set up a fresh agent-kit workspace and run kit.py doctor once. That leaves 171 .pyc files in the pack.
  2. The same workspace then fails chock check --only verify under 0.11.3's hashing, and passes with this change.

Fix: the pack hash leaves out __pycache__/, .pyc and .pyo, which plugin/build.py, plugin/gate_package.py and scaffold/skills.py already skip. A lockfile written while bytecode sat in a pack is reported once, and chock sync rewrites it (changelog says so).

Definition of done

  • chock check → 0 errors, 0 warnings, 0 infos
  • chock check --only matrix passes; matrix unchanged
  • chock sync --repo . --check clean
  • chock check --only verify clean (chock's own lockfile unchanged)
  • Registry rescanned; no stale entries
  • pytest: new tests/test_lock_ignores_bytecode.py. Bytecode leaves the hash alone (fails on main); a source change still changes it. test_vendored_guardrails.py passes.
  • Acceptance: no packaging, init, add or hook change
  • Existing artifacts migrated: none needed; chock's own lock hash is unchanged
  • Touched manifests: none; changelog Unreleased entry
  • ruff check . and ruff format --check . clean

Claims

  • No surface or claim changes.

Meant to ship in 0.11.4 alongside #168.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CzNYfzP8ymU3r4JB9Sz8Ha


Generated by Claude Code

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
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
@jothimani-rajendran
jothimani-rajendran merged commit bd8ac09 into main Sep 27, 2026
19 checks passed
@jothimani-rajendran jothimani-rajendran mentioned this pull request Sep 27, 2026
11 tasks
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.

2 participants