Skip to content

test(client,identity): pin nonce and IPFS fail-closed guards at their entry points - #17

Open
SaulBuilds wants to merge 1 commit into
mainfrom
test/call-site-guard-pins
Open

SaulBuilds wants to merge 1 commit into
mainfrom
test/call-site-guard-pins

Conversation

@SaulBuilds

Copy link
Copy Markdown
Contributor

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.

Guard Entry point New test(s)
Up-front "nonce required" check in exchange_code IdentityClient.exchange_code test_exchange_code_without_a_nonce_is_refused_before_the_token_request[None], [""]. Positive control: test_exchange_code_with_the_matching_nonce_still_succeeds
IPFS upload failure aborts the deploy (no placeholder CID) CitrateClient.deploy_model test_deploy_model_aborts_when_the_ipfs_upload_fails. Positive control: test_deploy_model_carries_the_cid_the_upload_returned
  • Without the nonce check, nonce="" 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 raise IdentityError before the authorization code is redeemed: no request reaches the token endpoint.
  • The deploy test makes upload_to_ipfs raise. It then asserts that deploy_model raises CitrateError and that no eth_sendRawTransaction is made.

All transports are in-process fakes, so no test opens a socket.

Standard: met

  • Revert check: each guard was neutralised in turn (if not nonce: → if False:; the raise CitrateError(...) in _upload_to_ipfs → return "fallback_…"), and the suite was run each time:
    • nonce check off → 2 red (both parametrisations, on assertion: "DID NOT RAISE" / message mismatch, plus the token endpoint was hit).
    • IPFS fail-closed off → 1 red (test_deploy_model_aborts_when_the_ipfs_upload_fails).
    • Restored → green.
  • Before this PR, both reverts left the suite green: 806 passed, 49 skipped (economics simulation excluded for the mutation runs; it imports only citrate_sdk.economics).
  • Suite: uv run --frozen pytest -q collects 907 → 912 tests (5 new). The new file passes, and the suite without the economics simulation runs 811 passed, 49 skipped.
  • Lint and types: ruff check . and mypy . are clean.
  • Wider sweep: 14 further guard reverts in the client, transport, identity and envelope code were checked in the same pass. Each one already went red in the existing suite, so no new tests were needed for them.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KGMeatV8UjtCB4CTbWuAv4

… 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
@SaulBuilds
SaulBuilds requested a review from a team as a code owner October 22, 2026 22:53

@BerryManifold BerryManifold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Matr0xshka left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 BerryManifold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Matr0xshka left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 BerryManifold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Matr0xshka left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants