Skip to content

fix(install): installed content is what verify says it is (CH-4) - #309

Merged
jothimani-rajendran merged 6 commits into
mainfrom
ch-4-installed-content-verified
Oct 20, 2026
Merged

jothimani-rajendran merged 6 commits into
mainfrom
ch-4-installed-content-verified

Conversation

@jothimani-rajendran

@jothimani-rajendran jothimani-rajendran commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

What

CH-4 (chock M3, M4, S1, S3):

  • chock add and verify refuse a pack that ships __pycache__ or .pyc/.pyo. The pack hash still ignores bytecode.
  • Policy scripts run with PYTHONDONTWRITEBYTECODE=1 (guard, script gate, tool-call gate, eval harness), so running a gate leaves no bytecode in the pack.
  • The runtime loader hashes the shared runtime file's bytes before executing them and compares that to its pin. The self-declared CHOCK_RUNTIME_DIGEST constant is removed, so a modified file can no longer pass by keeping its own digest line.
  • gate.py exits 2 on stdin that is not UTF-8 at agent events, instead of reading it with replacement characters.
  • New test scaffolds each chock new policy --kind and runs chock check --only evals, and compiles the generated Python with warnings as errors. Every kind already passed on main; this pins it.

Needs the owner

The loader template and gate.py changed, so .chock/bin drifts. Run chock sync --repo . on this branch. Until then tests/test_runner_selfcontained.py::test_vendored_gate_py_matches_source and tests/test_compiled_freshness.py::test_this_repo_has_compiled_what_it_declares fail. Runtime goldens are regenerated in this PR.

Checks

Full suite on Linux/py3.13: 4638 passed, 46 failed before a fix to the packaged gate; after it, the only failures are the two drift tests above plus tests/test_properties.py, which needs a package the test environment lacks. ruff check, ruff format and the literal-duplication tool are clean.

add and verify refuse a pack shipping __pycache__ or .pyc/.pyo, and
policy scripts run with PYTHONDONTWRITEBYTECODE=1. The runtime loader
hashes the shared runtime's bytes before exec and compares that to its
pin; the self-declared digest constant is gone. gate.py exits 2 on
undecodable stdin at agent events. A test scaffolds each kind and runs
the evals.

.chock/bin and its drift tests need the owner's regeneration.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Jothi Mani Rajendran <250249270+jothimani-rajendran@users.noreply.github.com>
jothimani-rajendran and others added 5 commits October 19, 2026 16:13
…F (CH-4)

The pin is the sha256 of the LF text. A Windows text-mode write or a
checkout with autocrlf turns it into CRLF, so the byte hash never
matched and every call failed closed, refusing correct work. The loader
now hashes the bytes with CRLF read as LF and still executes the bytes
it read; a one-byte edit, with or without CRLF, still refuses.

.chock/bin still needs the owner's regeneration.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Jothi Mani Rajendran <250249270+jothimani-rajendran@users.noreply.github.com>
…ne + CH-4 bytecode-off)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Jothi Mani Rajendran <250249270+jothimani-rajendran@users.noreply.github.com>
Signed-off-by: Jothi Mani Rajendran <250249270+jothimani-rajendran@users.noreply.github.com>
… not exec (CH-4)

Signed-off-by: Jothi Mani Rajendran <250249270+jothimani-rajendran@users.noreply.github.com>
Signed-off-by: Jothi Mani Rajendran <250249270+jothimani-rajendran@users.noreply.github.com>
@jothimani-rajendran
jothimani-rajendran marked this pull request as ready for review October 20, 2026 19:47
@jothimani-rajendran
jothimani-rajendran merged commit 7ccac62 into main Oct 20, 2026
26 checks passed
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