Repository navigation
test(crypto,client,ipfs,learning,release): pin envelope, list, invite, transport and release-gate guards at their entry points - #18
Conversation
…, transport and release-gate guards at their entry points (red) The manifest check fails on main: MANIFEST.in includes requirements.txt, which no longer exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KGMeatV8UjtCB4CTbWuAv4
…s.txt pyproject.toml is the single dependency declaration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KGMeatV8UjtCB4CTbWuAv4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KGMeatV8UjtCB4CTbWuAv4
BerryManifold
left a comment
There was a problem hiding this comment.
Automated Codex static review of 07f8636b40133726f221adcf65acc76c638041e6 is complete. Result: clean; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.
Matr0xshka
left a comment
There was a problem hiding this comment.
Automated Codex static review of 07f8636b40133726f221adcf65acc76c638041e6 is complete. Result: clean; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.
BerryManifold
left a comment
There was a problem hiding this comment.
Automated Codex static review of a43ca38a1311fd225b48a10352e9ba82f2855fb7 is complete. Result: clean; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.
Matr0xshka
left a comment
There was a problem hiding this comment.
Automated Codex static review of a43ca38a1311fd225b48a10352e9ba82f2855fb7 is complete. Result: clean; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.
Signed-off-by: Larry Klosowski <larryklosowski@proton.me> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FPJzHJptQTtnapM2Jio6AY
main now checks block 0 before a pinned send; this fake RPC serves no block 0, and the guard has its own pins in test_r1006_network_guard.py. Signed-off-by: Larry Klosowski <larryklosowski@proton.me> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FPJzHJptQTtnapM2Jio6AY
ee718c5
BerryManifold
left a comment
There was a problem hiding this comment.
Automated Codex static review of ee718c532ec32e71d9339558eb86cc8db4afa6c2 is complete. Result: blockers; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.
Matr0xshka
left a comment
There was a problem hiding this comment.
Automated Codex static review of ee718c532ec32e71d9339558eb86cc8db4afa6c2 is complete. Result: blockers; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.
SaulBuilds
left a comment
There was a problem hiding this comment.
Independent agent review (sweeper D): APPROVE
Checked:
- The diff matches the body: two new test files and one MANIFEST.in line removed. No changes under citrate_sdk/, and no version bump. The branch contains current main (0.9.0).
- MANIFEST.in: requirements.txt does not exist on main. It was removed in the pyproject-canonical modernization, and git history confirms it. I built an sdist with python -m build on main and on the PR head. main logs 'no files found matching requirements.txt' and the PR does not. The sdist file lists are identical, so the sdist is not broken and is not changed beyond the warning.
- Ran in a scratch clone with Python 3.11: the 2 new files have 38 passed. The full suite minus the economics simulation has 910 passed, 50 skipped.
- Envelope crypto property: decrypt_data refuses cleartext-key envelopes, then requires scheme == V2 exactly, then requires kdf_salt. I disabled the scheme check and 4 tests went red (v1 label, missing label, empty label, case/whitespace variant on an otherwise valid V2 envelope). I disabled the kdf_salt check and 1 went red. Both pins are therefore real.
- Other mutations I reproduced: verify_model_integrity '==' in place of hmac.compare_digest turns 1 test red. A clock-derived invite secret in place of secrets.token_bytes turns 2 red. list_models unwrap, the transport scheme gate and the IPFS timeout pins were read and look sound.
- The release-artifact tests are read-only text/AST checks on examples, publish.yml, workflow SHA pins, uv.lock and MANIFEST.in. They write nothing and use no network.
- CI: all checks are green, including locked-env. The pip-audit note in the body now looks stale.
Signed-off-by: Larry Klosowski <larryklosowski@proton.me> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FPJzHNqGLdTVoFzde3Sxbw
BerryManifold
left a comment
There was a problem hiding this comment.
Automated Codex static review of 9c040b117d4227d126e40c02237b704a196a1dd0 is complete. Result: blockers; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.
Matr0xshka
left a comment
There was a problem hiding this comment.
Automated Codex static review of 9c040b117d4227d126e40c02237b704a196a1dd0 is complete. Result: blockers; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.
SaulBuilds
left a comment
There was a problem hiding this comment.
Independent agent review (sweeper D): APPROVE
Re-review after the main merge, reviewed head 9c040b1. This covers only the merge, since the content was approved at ee718c5. CI note: python / test, locked-env and ci were still in progress when I reviewed. The other checks are green.
Checked:
- The merge commit 9c040b1 has parents ee718c5 (the previously reviewed head) and 07ce7b9 (current main, #17). It is SSH-signed.
git merge-tree --write-tree ee718c53 07ce7b9cgives tree 0c7d5404, the same as the merge commit's tree. The merge is a clean automatic merge with no manual edits.- From ee718c5 to the merge, the only file that changes is tests/test_call_site_guard_pins.py, which comes from main. From main to the merge, the only files that change are the PR's own three: MANIFEST.in and the two new test files. The merge adds nothing beyond main.
- Ran in a scratch venv with Python 3.11: test_gap_guard_pins.py, test_release_artifact_pins.py and main's test_call_site_guard_pins.py together give 43 passed.
- Note: the automated Codex reviews on ee718c5 and 9c040b1 report "blockers", with details in the private review log. I cannot see those details. Because the merge changes nothing beyond main, any such blocker would also apply to the content approved earlier or to main itself. The lead should look at that log before merging.
…r key leaks Tightens the release-artifact and IPFS pins after review found checks that passed with the guard they name removed: - Examples: a new run of each example's main() with the client replaced fails if, without CITRATE_PRIVATE_KEY, it builds a signing client or writes any 32-byte hex secret to stdout/stderr (and if it echoes an env key). Examples may not call get_private_key() at all. Red here on examples/basic_usage.py, which generates a key and prints it. - Encrypted calls bind positional and keyword arguments to the public signatures and reject an absent or literal-None recipient. - publish.yml is parsed as YAML. The publish job's if: is evaluated over a context table against the policy (release, or manual from main with a version); the version-check step must run on every manual publish before the upload, and its script is executed against matching and mismatched dist/ fixtures. The pytest step and the test/build jobs may not be conditional or continue-on-error. - Workflow discovery covers *.yml and *.yaml; uses: pins are read from the parsed job and step mappings (quoted and flow-style included). - The upload test requires add then object/stat, with the CID add returned. Adds pyyaml and types-pyyaml to the dev extra (uv.lock updated). Signed-off-by: Larry Klosowski <larryklosowski@proton.me> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FPJzHNqGLdTVoFzde3Sxbw
Without CITRATE_PRIVATE_KEY the example generated a key, printed it to stdout and signed with it. It now stops with the same message as encrypted_inference.py. The README notes the key comes from the environment. Turns test_examples_never_print_a_private_key and test_examples_never_extract_a_private_key green. Signed-off-by: Larry Klosowski <larryklosowski@proton.me> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FPJzHNqGLdTVoFzde3Sxbw
BerryManifold
left a comment
There was a problem hiding this comment.
Automated Codex static review of 3b4944aad4e0c8f6e4f45993bec84804f6dd7691 is complete. Result: blockers; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.
Matr0xshka
left a comment
There was a problem hiding this comment.
Automated Codex static review of 3b4944aad4e0c8f6e4f45993bec84804f6dd7691 is complete. Result: blockers; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.
SaulBuilds
left a comment
There was a problem hiding this comment.
Independent agent review (sweeper D helper): APPROVE
Reviewed head 3b4944a (git diff origin/main...HEAD, PR body, examples/*.py, citrate_sdk/crypto.py KeyManager, citrate_sdk/ipfs.py upload path, all three workflows). Ran the two new test files from a scratch copy in the frozen uv.lock env (Python 3.11): 73 passed. CI locked-env (frozen sync, ruff, mypy, full pytest) and uv-lock-check are green on this head.
Prior findings, each checked with a mutant on a copy:
- basic_usage.py key print: closed. The example now exits without CITRATE_PRIVATE_KEY and no longer imports KeyManager. Restoring the main-branch basic_usage.py fails both test_examples_never_extract_a_private_key and test_examples_never_print_a_private_key. By inspection no shipped example prints a private key in any path, with or without the env var.
- Manual publish gate: closed. Replacing the main-ref predicate with true or with github.ref != '' fails; adding if: to the pytest step fails; the version-check script is executed against matching and mismatched dist fixtures.
- Workflow discovery and pin parsing: closed. A new extra.yaml with a flow-style unpinned uses fails; quoted and flow-style fixtures are covered.
- Encrypted-call check: closed. Positional encrypted flag, positional None recipient and recipient_public_key=None are all in the negative fixtures and refused.
- IPFS verification: closed. Removing the _verify_upload call, or passing a different CID to it, fails test_upload_and_its_verification_carry_the_timeout.
Deps: pyyaml was already in uv.lock as a transitive package, types-pyyaml is newly locked, both are added to the dev extra (the reusable CI installs .[dev], locked-env uses --all-extras). Lock is consistent (uv lock --check green in CI).
Non-blocking findings (test hardening, follow-up is fine):
a. The runtime key-leak check only exercises code before the first CitrateClient construction, because the stand-in client raises there. A print(PRIVATE_KEY) placed after the client is built passes the suite. The docstring wording (no run may write a 32-byte hex secret) is broader than what is exercised. Suggest a stand-in that returns an inert recorder so main() runs to completion, or narrow the docstring.
b. Output capture misses some channels: logging.warning(key) passes (pytest log capture intercepts it before stderr), and os.write(1, ...) passes (capsys, not capfd). Suggest capfd plus caplog.text in the scanned text.
c. Partial or reformatted keys pass: a 40-char prefix, a key split across two prints, and the bytes repr of Account.create().key all pass. The full-hex and uppercase forms, stderr, no-0x, and a key inside an exception message are caught.
d. The pytest step regex accepts any trailing arguments, so pytest --co or a narrowed test path still passes. Outside the five findings; consider pinning the exact command.
e. Pre-existing, not in this diff: encrypted_inference.py prints the first 8 bytes of the derived ECDH shared keys. Not a private key, but worth dropping in a later example pass.
None of these blocks merge: the shipped examples are clean today, and every finding the earlier review raised is closed with a test that goes red on the original regression.
…-suite pytest From the independent review of 3b4944a: - The runtime key test stops at client construction, so a print of the env key after it went unseen. A new AST check requires every read of a name bound from a *PRIVATE_KEY* env var to be a truth test or the private_key= of CitrateClient; fixtures pin print, logging, slicing and a pass-through call. - The runtime test now reads capfd (fd 1/2, so os.write is seen) and caplog, and its docstring says what it covers. - The pytest step may only add verbosity flags (-q, -v, -ra), so --co, -k or a path cannot narrow the release gate. Signed-off-by: Larry Klosowski <larryklosowski@proton.me> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FPJzHNqGLdTVoFzde3Sxbw
BerryManifold
left a comment
There was a problem hiding this comment.
Automated Codex static review of 4c9df907556abb380586d549c2d932e9efdadd76 is complete. Result: blockers; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.
Matr0xshka
left a comment
There was a problem hiding this comment.
Automated Codex static review of 4c9df907556abb380586d549c2d932e9efdadd76 is complete. Result: blockers; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.
SaulBuilds
left a comment
There was a problem hiding this comment.
Independent agent review (sweeper D helper, re-review of 4c9df90): APPROVE
Scope: git diff 3b4944a..4c9df90 plus the full PR diff vs origin/main. Ran tests/test_release_artifact_pins.py and tests/test_gap_guard_pins.py from a copy of 4c9df90 on Python 3.11 with the locked env: 80 passed. Then ran mutants against the copy.
The three claimed closures hold:
- Env key use after construction. The AST check flags every Load of an env-bound name that is not a bare truth test or the private_key= of CitrateClient. Caught: print(k) after k = PRIVATE_KEY (the alias read itself is flagged, so aliasing is covered), print(f'{PRIVATE_KEY[:10]}') after the client, logging.warning('%s', PRIVATE_KEY) after the client. No false positives on the three current examples. if/while bodies that merely test the name are correctly accepted.
- fd and log capture. os.write(1, key) and sys.stdout.write(key) before construction are now caught by capfd; caplog at DEBUG catches logging. Inline print of a freshly generated KeyManager key before the client is caught.
- pytest step. --co, a path, -k, -x, --deselect=, -p all fail the pin now; multi-line or chained commands also fail because every token must be in {-q, -v, -ra}.
SDK side: KeyManager/CitrateClient do not log or repr the key, and the construction errors do not echo it, so no example leaks the key through the SDK itself on the paths I checked.
Nothing blocking. Non-blocking nits (all hypothetical future examples, none present today):
- _env_key_names only recognises ast.Assign of os.getenv / os.environ.get. Not recognised as a key source, verified to pass undetected after the client: os.environ['CITRATE_PRIVATE_KEY'] (Subscript), an inline print(os.getenv('CITRATE_PRIVATE_KEY')), an annotated K: str | None = os.getenv(...), and from os import getenv. Adding ast.AnnAssign and an os.environ[...] Subscript source is trivially closable; inline/aliased-import reads could be handled by flagging any getenv/environ access with a PRIVATE_KEY constant outside an Assign.
- Key material not sourced from the env is only pinned up to the first CitrateClient: print(client.key_manager.account.key.hex()) after construction and print(sim_key) in the marketplace_demo simulation loop both pass. A static ban on .key.hex() / .account.key in examples would close it.
- The publish pin does not look at PYTEST_ADDOPTS in workflow/job/step env or at addopts in pyproject, either of which could narrow the run without touching the run: line. Low risk since both are reviewed files.
No code was edited by this review.
Tests-only pins for guards whose removal the existing suite did not notice, one example fix, and one hygiene fix (
MANIFEST.inno longer includes the removedrequirements.txt). No version bump, nothing published, and no source changes undercitrate_sdk/.What is pinned
tests/test_gap_guard_pins.py(call-site tests, no network, fixed throwaway test keys):decrypt_data: a well-formed envelope under any other scheme label is refused by the scheme check (the existing check used a malformed envelope, so a later step masked it). An envelope withoutkdf_saltis refused by name.verify_model_integritycompares throughhmac.compare_digest.list_modelsunwraps the node's{"models": [...]}answer (the existing test fed a bare list).ClassroomManager.create: the default invite secret comes from the OS CSPRNG and does not depend on the clock.allow_insecure_http=True.IPFSClient: upload must sendaddand thenobject/statfor the CIDaddreturned; upload, its verification stat, download and pin all carry the client timeout.tests/test_release_artifact_pins.py(shipped examples and release workflows):main()is run up to client construction withCitrateClientreplaced and no network. WithoutCITRATE_PRIVATE_KEYit must stop before building a signing client, and up to that point no 32-byte hex secret (generated or from the environment) may reach stdout or stderr at the file-descriptor level, or a log record. Past that point, an AST check requires every read of a name bound from a*PRIVATE_KEY*env var to be a truth test or theprivate_key=ofCitrateClient. Examples may not callget_private_key()at all.inference,encrypt_data) bind positional and keyword arguments to the public signatures; an encrypted call with an absent or literal-Nonerecipient fails, as do*/**arguments the check cannot bind. Negative fixtures pin each form.purchase_model_access.publish.ymlis parsed as YAML (pyyamlandtypes-pyyamladded to the dev extra;uv.lockupdated):if:is evaluated over a table of events, refs and versions against the policy: a release publishes; a manual run publishes only from main with a nonempty version. A small evaluator covers the expression subset in use and refuses anything else (for examplealways()).WANTfrominputs.publish_version, and its script is executed with bash against matching and mismatcheddist/fixtures.needs. The test and build jobs and the pytest step carry noif:, and the pytest step adds only verbosity flags (no--co,-kor path). No job or step setscontinue-on-erroror runs|| true.id-token: write, onepypa/gh-action-pypi-publishstep, no password or token inputs.*.ymland*.yaml) is parsed, and every job-level and step-leveluses:(quoted and flow-style included) is pinned to a commit SHA.uv.lockcryptography version satisfies the pyproject range.MANIFEST.inincludenames a file that exists. This was red on main and is fixed in caa4526.Example fix
examples/basic_usage.py, run withoutCITRATE_PRIVATE_KEY, generated a key, printed it to stdout and signed with it. It now stops with the same message asencrypted_inference.py. The README notes the example takes its key from the environment.Standard: met
test_manifest_includes_only_files_that_existfails against main; caa4526 is the fix. 74858a6 tightens the tests and is red onbasic_usage.py(test_examples_never_print_a_private_key,test_examples_never_extract_a_private_key); 3b4944a fixes the example. 4c9df90 closes the gaps the independent review found (uses after client construction, fd-level output and logs, a narrowed pytest step).if:moved into a YAML comment; the version-check script stops failing on a mismatched artifact; the script exits 0 early; the version-check stepif:narrowed to releases; the pytest step gainsif: github.event_name != 'release'; the pytest step gainscontinue-on-error; the test job gains anif:;always() ||prepended to the publish gate."uses"in publish.yml; a newextra.yamlwith a flow-style unpinneduses.Trueand no recipient; positionalNonerecipient;recipient_public_key=None;encrypt_data(data, None); the originalbasic_usage.py; a key generated witheth_accountand printed without building a client; the env key printed before the client, printed after it, logged, or written withos.write;pytest -q --coin the pytest step._verify_uploadremoved fromupload_bytes;_verify_uploadcalled with another CID.uv.lockenvironment (Python 3.11,uv sync --frozen --all-extras):pytest -q1002 passed, 50 skipped.ruff check .andmypy .are clean.uv lock --checkpasses.🤖 Generated with Claude Code
https://claude.ai/code/session_01FPJzHNqGLdTVoFzde3Sxbw