Skip to content

test(contract): add the §10.1 rule-8 guardrail regression tests - #13

Merged
ilpanich merged 1 commit into
mainfrom
claude/rule8-guardrail-tests
Aug 4, 2026
Merged

test(contract): add the §10.1 rule-8 guardrail regression tests#13
ilpanich merged 1 commit into
mainfrom
claude/rule8-guardrail-tests

Conversation

@ilpanich

@ilpanich ilpanich commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Adds the CONTRACT.md §10.1 rule-8 guardrail regression tests — the one part of the local-verification set with no test outside PHP, TypeScript and Python.

The rule

Rules 1-7 ask whether the token is good. Rule 8 asks whether it is the token the decision is even about. SEC-085 satisfied all seven and was still an authentication bypass: the PHP guard routed a failed verification into a second, successful one against the application's own session, admitting the caller as the app's service account.

This SDK is structurally safe from that shape — TokenAuthenticator holds a JwksVerifier and a tenant id, never a Client with a session — so these tests pin the property rather than fix a defect. §15.1 hand-verified every guard already rejects correctly; this closes a missing guardrail.

Tests (3)

  • rule 8 — a failed caller token is rejected while another valid token exists — an app-owned token (same key, same tenant, genuinely fresh) is first asserted to verify, so a fallback would really have succeeded. The caller's expired token fails rule 2 and nothing else.
  • rule 8 — the guard authenticator decides on the request's own credential — exercises the AxiamGuard path, not just the authenticator. A recording extractor proves exactly one credential was consulted, and it was the caller's.
  • rule 8 — the authenticator holds no client and therefore no session — a static_assert that TokenAuthenticator remains constructible from a verifier and tenant alone, so making a Client the only way to build one would have to be a deliberate act rather than silent drift.

Falsified: adding an SEC-085 fallback to try_authenticate fails test 1 on both assertions.

Verified locally: 110 test cases, 389 checks, 0 failed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SkTHvZQMV47t3UwkEtmB1D


Generated by Claude Code

CONTRACT.md §10.1 rule 8 — "subject of the decision" — was the one part
of the local-verification set with no regression test outside PHP,
TypeScript and Python. §15.1 hand-verified that every guard rejects
correctly, so this closes a missing guardrail rather than a live defect.

Rules 1-7 ask whether the token is good. Rule 8 asks whether it is the
token the decision is even about. SEC-085 satisfied all seven and was
still an authentication bypass: the PHP guard routed a failed
verification into a second, successful one against the application's
own session, admitting the caller as the app's service account.

Each test asserts its precondition rather than assuming it: a second,
fully valid credential for a more privileged principal is first shown
to pass the same guard, so a fallback would genuinely have succeeded.
Without that, the tests would pass merely because nothing was available
to substitute — the trap the PHP reference test documents at length.

Every test was falsified by injecting the SEC-085 fallback into the
guard and confirming it fails.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SkTHvZQMV47t3UwkEtmB1D
@ilpanich
ilpanich merged commit b7be270 into main Aug 4, 2026
10 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.

2 participants