Repository navigation
test(client,identity): pin nonce and IPFS fail-closed guards at their entry points - #17
Conversation
… entry points Two fail-closed guards were only covered through a check elsewhere that masked their removal: - IdentityClient.exchange_code: the up-front "nonce required" check. With it removed, nonce="" was still caught later by the ID-token claim comparison, and nonce=None silently skipped the nonce check. The new test drives exchange_code with None and "" and asserts it refuses before the authorization code is redeemed (no token-endpoint request). - CitrateClient.deploy_model: an IPFS upload failure must abort the deploy. The new test makes upload_to_ipfs raise and asserts deploy_model raises and broadcasts no transaction; a positive control checks the returned CID is what lands in the calldata. Revert check: each guard neutralised in turn, full suite run, the new tests go red on assertion; restored, green. 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.
Approval at d8e7207373ed3a4e6a5d5ec50b0ddddd69e87d34 after focused differential review of changed files, history, security guards and immediate callers. All 5 targeted tests pass; both nonce-guard-removal and IPFS fail-open mutants fail assertions, restoring source returns 5/5 green.
Limits: No deployments, live authority/chain/storage operations, full cross-repository integration or full historical security audit. Required CI/branch/owner gates still apply. Both account submissions reflect the same automated review.
Matr0xshka
left a comment
There was a problem hiding this comment.
Approval at d8e7207373ed3a4e6a5d5ec50b0ddddd69e87d34 after focused differential review of changed files, history, security guards and immediate callers. All 5 targeted tests pass; both nonce-guard-removal and IPFS fail-open mutants fail assertions, restoring source returns 5/5 green.
Limits: No deployments, live authority/chain/storage operations, full cross-repository integration or full historical security audit. Required CI/branch/owner gates still apply. Both account submissions reflect the same automated review.
BerryManifold
left a comment
There was a problem hiding this comment.
Automated Codex static review of d8e7207373ed3a4e6a5d5ec50b0ddddd69e87d34 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 d8e7207373ed3a4e6a5d5ec50b0ddddd69e87d34 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 d8e7207373ed3a4e6a5d5ec50b0ddddd69e87d34 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 d8e7207373ed3a4e6a5d5ec50b0ddddd69e87d34 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 deploy; 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
3ddb4e2
BerryManifold
left a comment
There was a problem hiding this comment.
Automated Codex static review of 3ddb4e26a516b1982d10084f6e35e9ceb9b03ee6 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 3ddb4e26a516b1982d10084f6e35e9ceb9b03ee6 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.
SaulBuilds
left a comment
There was a problem hiding this comment.
Independent agent review (sweeper D): APPROVE
Checked:
- Diff is tests only: new tests/test_call_site_guard_pins.py. No changes under citrate_sdk/, and no version or dependency changes. The branch contains current main (0.9.0), so it is not superseded.
- Ran in a scratch clone with Python 3.11: the new file has 5 passed. The suite minus the economics simulation has 877 passed, 50 skipped. The counts differ from the body only because main has moved since.
- Nonce property: exchange_code has an up-front 'if not nonce' refusal. I neutralised it to 'if False'. Both parametrisations then go red (None and an empty string), so the pin is real. With None the token endpoint was otherwise reached and the ID token verified without nonce binding, which is the replay gap SPY-B-010 closes. The test also asserts that the authorization code is never redeemed (no token endpoint call). The positive control confirms the matching nonce still verifies and is carried in claims.
- IPFS fail-closed: I replaced the raise in _upload_to_ipfs with a placeholder CID return, and test_deploy_model_aborts_when_the_ipfs_upload_fails goes red. The test also asserts that no eth_sendRawTransaction is sent. The positive control decodes the RLP payload and checks the real CID.
- Fakes are in-process. No sockets. expected_genesis_hash=None is used only in the fixture, and the genesis guard is pinned elsewhere.
- CI: all checks are green, including locked-env and python / test.
Summary
Tests only. No production code, version or dependency changes.
Pins two fail-closed guards at their public entry points. Before this PR, each guard could be removed with the rest of the suite still green, because a later check masked the removal.
exchange_codeIdentityClient.exchange_codetest_exchange_code_without_a_nonce_is_refused_before_the_token_request[None],[""]. Positive control:test_exchange_code_with_the_matching_nonce_still_succeedsCitrateClient.deploy_modeltest_deploy_model_aborts_when_the_ipfs_upload_fails. Positive control:test_deploy_model_carries_the_cid_the_upload_returnednonce=""was still caught later by the ID-token claim comparison.nonce=None, however, skipped the nonce check entirely and the token verified. The new test asserts that both values raiseIdentityErrorbefore the authorization code is redeemed: no request reaches the token endpoint.upload_to_ipfsraise. It then asserts thatdeploy_modelraisesCitrateErrorand that noeth_sendRawTransactionis made.All transports are in-process fakes, so no test opens a socket.
Standard: met
if not nonce:→if False:; theraise CitrateError(...)in_upload_to_ipfs→return "fallback_…"), and the suite was run each time:test_deploy_model_aborts_when_the_ipfs_upload_fails).citrate_sdk.economics).uv run --frozen pytest -qcollects 907 → 912 tests (5 new). The new file passes, and the suite without the economics simulation runs 811 passed, 49 skipped.ruff check .andmypy .are clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01KGMeatV8UjtCB4CTbWuAv4