Skip to content

fix(tests): a failing signer must be a real key now, not a duck type - #49

Merged
imran-siddique merged 2 commits into
mainfrom
fix/trace-0-10-key-type-check
Sep 7, 2026
Merged

fix(tests): a failing signer must be a real key now, not a duck type#49
imran-siddique merged 2 commits into
mainfrom
fix/trace-0-10-key-type-check

Conversation

@imran-siddique

Copy link
Copy Markdown
Member

CI here goes red against agentrust-trace 0.10.0, released today. This repo floors it at >=0.9,<1, so it picked the new version up immediately.

What changed upstream

0.10.0 requires the signing key to be an Ed25519PrivateKey rather than anything carrying a sign method:

ValueError: key must be an Ed25519PrivateKey, got FailsWhenUsed

That is the right direction — a signing key should be a key — and it is worth keeping. It also invalidates this test's stand-in.

What broke

test_a_failure_inside_official_signing_is_reported_as_one built a hand-rolled FailsWhenUsed class to get past the shape check, reach the signing call, and raise from inside it. Under 0.10.0 that object is refused by the type check first, so the test observed the wrong error.

Its own docstring warns against precisely this:

object() would not reach here: it is refused earlier for having no sign, so a case built that way passes on the wrong refusal.

The hazard it named was real; it just arrived one shape earlier than anticipated.

The fix

A MagicMock(spec=Ed25519PrivateKey) satisfies the isinstance check and still raises when used. That is the case this test is actually about: a real key whose hardware backing is unavailable at the moment of signing, rather than a malformed key object.

Verified against the published 0.10.0 wheel: the file's 10 tests pass, and reverting only the test file turns it red again.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XbDBXDWWvMFa7c2jGgyq9t

imran-siddique and others added 2 commits September 6, 2026 17:23
agentrust-trace 0.10.0 requires the signing key to be an
Ed25519PrivateKey rather than anything carrying a sign method. That is
the right direction: a signing key should be a key. It also invalidates
this test's stand-in.

test_a_failure_inside_official_signing_is_reported_as_one built a
hand-rolled FailsWhenUsed class to reach the signing call and raise from
inside it. Under 0.10.0 that object is refused by the type check first,
so the test saw "key must be an Ed25519PrivateKey, got FailsWhenUsed"
instead of the error it was written to observe. Its own docstring warns
against exactly this failure, passing on the wrong refusal, one shape
earlier than it anticipated.

A mock specced to Ed25519PrivateKey satisfies the isinstance check and
still raises when used, which is the case the test is about: a real key
whose hardware backing is unavailable at the moment of signing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XbDBXDWWvMFa7c2jGgyq9t
This class is skipped below Python 3.11, where the trace extra and
therefore cryptography are not installed. A module-level import breaks
collection before setUpClass can apply that skip, so the 3.10 job failed
on ModuleNotFoundError rather than skipping.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XbDBXDWWvMFa7c2jGgyq9t
@imran-siddique
imran-siddique merged commit 5d963d3 into main Sep 7, 2026
7 checks passed
@imran-siddique
imran-siddique deleted the fix/trace-0-10-key-type-check branch September 7, 2026 00:35
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