Safety demonstrations
The release gate asks that replay, issuer mix-up, cross-tenant access, stale approval, retries, restart, rollback, revocation, and rotation are demonstrated safely. Each is one named test, in both SDKs, that runs a real journey — Atlas, Ada's personal agent, with Manzanita, the reference company, over HTTP in one process with real keys — then does the unsafe thing and asserts the safe outcome: refused, or done exactly once.
pytest personal_agent_protocol/__tests__/test_security_demonstrations.py
node --test src/__tests__/security-demonstrations.test.mjs # after npm run build
| Property | What the test does | What it shows | Python test | TypeScript test |
|---|---|---|---|---|
| Replay | Sends again, byte for byte, a captured token request (its client assertion and device code), an API read, and a request with an approval. | Each is refused (400/401): assertions, device codes, and Session JWT IDs are one-time. The approved request performs nothing more; the agent, with fresh Session JWTs, carries on. | test_replay_is_refused | replay is refused |
| Issuer mix-up | Begins Direct Sign-In at Manzanita, then completes it with the answer claiming another issuer (iss, RFC 9207). | issuer_mismatch before any code reaches a token endpoint; the sign-in state is spent, so the genuine answer cannot be raced in afterwards; the Session stays signed out; starting again works. | test_issuer_mix_up_is_refused | issuer mix-up is refused |
| Cross-tenant access | Names Ada's Session from another tenant of the same agent, with another User ID, and reads her conversation as another user. | 400 invalid_session: a Session keeps its User ID, and each tenant has its own delegated key; another user's Session sees conversation_not_found. Ada's tenant is unaffected. | test_cross_tenant_access_is_refused | cross-tenant access is refused |
| Stale approval | Approves revision 1 of an exchange; Manzanita revises it to revision 2 (a price difference); sends the old approval. | A new revision comes back with the new terms, and nothing is performed until the user approves it; the old approval presented again gets the response already given and performs nothing. | test_stale_approval_is_refused | stale approval is refused |
| Retries | Sends one message ID twice; loses the answer to an approved request that Manzanita received and performed; sends it again with the same approval. | One conversation, one message; the lost answer comes back as the original response, never assumed failed; the operation is performed once. | test_retries_are_safe | retries are safe |
| Restart | Restarts Manzanita, twice, over its store (which holds the default replay cache), between a sign-in, an operation returned, and its approval. | A Session JWT seen before the restart is still refused after it; the Session and the operation carry over; the operation approved after one restart is not performed again after the next. | test_restart_is_safe | restart is safe |
| Rollback | Rolls Manzanita back to its previous release (no website) over the same store, after a refresh token rotation and a performed operation. | The rotated-away refresh token stays refused and the current one works; the earlier release does not perform the operation again; Sessions and the API continue. | test_rollback_is_safe | rollback is safe |
| Revocation | Uses two Sessions from one sign-in, then revokes the refresh token. | Both access tokens stop at once (401 invalid_token), not at expiry; the refresh token is gone locally and refused at the company; the Sessions continue signed out. | test_revocation_is_safe | revocation is safe |
| Rotation | Refreshes the refresh token twice at once; then rotates the agent's signing key with an overlap and retires the old one. | Refreshes are serialized, each rotating; the rotated-away token is refused, the live one works. Both signing keys verify during the overlap; once the company's cached key set expires, the retired key is refused (invalid_client) and the new one verifies. | test_rotation_is_safe | rotation is safe |
What a deployment must provide​
The restart and rollback demonstrations restart the company over one store,
as a deployment's replicas share one (company guide). The
default replay cache keeps its identifiers in that store (StoreReplayCache,
an atomic create with the identifier's expiry), so a Session JWT captured
just before a restart, or at another replica, is refused after it: a durable,
shared store implies a shared replay cache. With the in-memory store, the
cache is one process, as the store is. A company that contributes its own
pap.company.replayCache must share it across replicas the same way.
The same properties are also tested piecemeal, closer to the code: the
conformance cases (security.*-replay, lifecycle.rotated-token,
lifecycle.sign-out-*, operations.new-revision-on-changed-terms,
operations.lost-answer-same-approval, conversations.retry-replays), the
company store's restart test (test_company_store.py), the overlapping JWKS
test (test_guide_security.py), and, for the pap CLI and live-session
actions, the tenant tests (test_cli_protocol.py,
test_live_session_actions.py).