Skip to content

E9-1 route 2 S2b-1 tests (lane MB): the reduction-only session in the store, stubs and pending tests - #2135

Closed
kunwarshivam wants to merge 2 commits into
mainfrom
claude/mb-reduction-open-store
Closed

kunwarshivam wants to merge 2 commits into
mainfrom
claude/mb-reduction-open-store

Conversation

@kunwarshivam

Copy link
Copy Markdown
Owner

Story

E9-1, route 2: the workspace-local passkey. This is slice S2b-1, the tests half of DEC-77: the browser session store holds a reduction-only session. PRD FR-1.4; HLD §8. Spec: workspace API spec §4.10, route 2, item 5; identity spec §6.4, route 2. Decisions: DEC-816, DEC-2117.

Two stubs are added to mandate_api_server::session::Sessions. Each is todo!() under the DEC-137 #[expect(clippy::todo)]:

  • open_reduction_only(principal, standing, replaced, now) -> Result<Cookie, Unauthenticated>
  • opened_by_passkey(cookie, now) -> bool: the route-2 marker, which POST /v1/sessions/refresh will read in S2b-3.

Spec clause → test

All four tests are in crates/mandate-api-server/tests/session.rs, #[ignore = "pending E9-1"], and each fails at the stub.

Spec clause or invariant Test name
It reaches only pause, the kill switch and sign-out; lasts 15 minutes from the opening, absolute, with no idle limit; and expires_at is the opening plus 900 s a_passkey_session_reaches_pause_the_kill_switch_and_sign_out_for_fifteen_minutes_absolute
It is never refreshed or extended, and a refresh with any answer keeps it reduction-only; an outage narrows a full session but does not mark it a_passkey_session_is_never_refreshed_and_a_refresh_keeps_it
It counts toward the principal's 16 (the oldest ends); it ends a presented session only once the assertion verifies, so a refused call ends nothing; with no randomness it opens nothing a_passkey_session_counts_toward_sixteen_and_ends_a_presented_one_only_once_opened
It is refused when a deprovision came at or after the last sign-in; it fills the store as any session does a_deprovision_since_the_last_sign_in_or_a_full_store_refuses_a_passkey_session

Dependencies

None.

Journal events added

None. SessionOpened comes once the journal registers it (§4.10 item 5).

Not done

  • S2b-2: credential records and the no-oracle judge.
  • S2b-3: POST /v1/reduction-sessions and refresh answering reduction_only.
  • S2b-4: /me/session and the reach tests.
  • Where the deprovision standing comes from is a question put to the coordinator. This slice takes a SubjectStanding as input.

Decisions needed

None for this slice.

Safety checklist (safety-critical changes)

  • No floats in money or quantity paths
  • No clock reads or randomness in the core
  • No unwrap, expect, or panics on trading paths (only the DEC-77 stubs)
  • Ordering: inputs processed in journal order
  • Replay: same inputs give identical outputs
  • No secrets or trading content in logs or notifications
  • No x-planned or (planned: ...) marker added to a value the code already serves, or a reviewer signed it off (DEC-683)

Checks

  • fmt, clippy -D warnings, and cargo xtask markers are clean. cargo xtask ci pending: all 43 pending tests fail at a stub.
  • Review agent report attached

Generated by Claude Code

…wrong secret (review of #2135, B1 and B2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K
kunwarshivam added a commit that referenced this pull request Oct 22, 2026
…, implemented (#2137)

## Story

E9-1, route 2, slice S2b-1: the implementation half of DEC-77, on top of the tests PR (S2b-1 tests). Spec: workspace API spec §4.10, route 2, item 5. Decisions: DEC-816, DEC-2117.

- **`Sessions::open_reduction_only`** builds `mandate_authn::SessionRecord::open_reduction_only`, which refuses a deprovision at or after the last sign-in. It holds the session for 900 s absolute, through the same `insert` as `open`: the principal's 16, the store's 4,096, and the presented session ended only once everything that can fail has passed. `open` now shares that `insert`, and its behaviour is unchanged.
- **The cookie.** A reduction-only record keeps no refresh digest, so the entry keeps its cookie secret's digest in `passkey`. `holds` takes either one. `Some` is also the route-2 marker, which no answer exposes.
- **The subject is `Option`**: route 2 opens a session without a sign-in. A granted refresh still compares subjects, and `subject()` refuses a route-2 session.
- **`opened_by_passkey`** reads the marker on a live session whose cookie is current. A refresh of a route-2 session is refused by the record (`NotRefreshable`) and the session is kept.

The tests change only by deleting their four `#[ignore = "pending E9-1"]` lines.

## Spec clause → test

The same four tests as the tests PR, in `crates/mandate-api-server/tests/session.rs`.

## Dependencies

None.

## Journal events added

None.

## Not done

S2b-2 to S2b-4, as listed on the tests PR.

## Decisions needed

None.

## Safety checklist (safety-critical changes)

- [x] No floats in money or quantity paths
- [x] No clock reads or randomness in the core
- [x] No `unwrap`, `expect`, or panics on trading paths
- [x] Ordering: inputs processed in journal order
- [x] Replay: same inputs give identical outputs
- [x] No secrets or trading content in logs or notifications
- [x] No `x-planned` or `(planned: ...)` marker added to a value the code already serves, or a reviewer signed it off (DEC-683)

## Checks

- [x] fmt and clippy `-D warnings` clean; `mandate-api-server` nextest 368/368.
- [x] `cargo mutants --in-diff` on the `mandate-api-server` diff against main: 22 mutants, 19 caught, 3 unviable, 0 missed.
- [x] Review agent report attached

---
_Generated by [Claude Code](https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K)_

## Independent review (route-2 reviewer, different model)

Round 1: #2137 (impl) PASS at 5bd3cb9; #2135 (tests) FAIL at a4f4840 on two test gaps. A reduction-only session is 900 s absolute with no idle limit, shares the principal's 16-session cap and the oldest-ends rule, and is never refreshed into a full session (the store's `refresh` refuses for every provider answer and keeps it); a presented full session ends only on success. Gaps: nothing pinned `subject()` on a live passkey session, and no test presented a live session's id with a wrong secret.

Round 2: #2135 PASS at 734d016, #2137 PASS at d54d554. `subject()` on a live passkey session is `Err(Unauthenticated)` and on a full session `Ok`, so the `Some(String::new())` mutant now fails; a `retagged` cookie with the live id, a valid tag and a wrong secret makes `opened_by_passkey` and `reduction_only` false, so both no-`holds` mutants fail. #2137's source is unchanged from round 1 (merge-up only); its test diff is the four `#[ignore]` lines; 26 session tests pass; markers clean. The digest compare uses plain equality over SHA-256 digests of attacker-chosen input, as the refresh path already does; accepted.

Coordinator: the merge with main compiles across the workspace, all targets. Landed combined (DEC-77): #2137 contains #2135's head.

Coordinator-approved-head: d54d554


---
_Generated by [Claude Code](https://claude.ai/code)_

Copy link
Copy Markdown
Owner Author

Included in #2137 (DEC-77 tests + impl landed combined).


Generated by Claude Code

kunwarshivam added a commit that referenced this pull request Oct 25, 2026
…, implemented (#2167)

* Route 2's gate bounded in all: ReductionLimits gains max_outstanding, reserve and max_failure_keys; pending tests (E9-1 S2a, DEC-2119 items 4 and 11)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's gate bounded in all: max_outstanding, the reserve, and max_failure_keys with the oldest key dropped first (E9-1 S2a, DEC-2119 items 4 and 11)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Pin which failure key the gate drops first, address before device at a tie

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Bound the reduction gate's challenges in all and its failure keys

Stop dropping failure keys when a removal removes nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's session in the store: stubs and pending tests (E9-1 S2b-1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's session in the store: open it, mark it, never refresh it (E9-1 S2b-1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's passkey records and interim standing: stubs, pending tests, and DEC-2319 (Proposed) (E9-1 S2b-2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's passkey records and interim standing, implemented (E9-1 S2b-2, DEC-2319 item 2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Pin eviction by latest failure against earliest, with a lapsed failure, and bound a failure's cost (review of #2128, B1 and B2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Index failure keys by their latest failure, so lapsing and the bound cost no scan of the keys (review of #2131, B2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's verifier in mandate-passkey: stubs, pending tests, and DEC-2324 (E9-1 S2b-2b)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Size the 64-byte DER cases to 64 bytes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's verifier in mandate-passkey, implemented (E9-1 S2b-2b, DEC-2324)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Pin subject() on a live passkey session and a tagged cookie with the wrong secret (review of #2135, B1 and B2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's judge: stubs and pending tests (E9-1 S2b-3a, DEC-2324 item 5, DEC-2319 item 2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's judge, implemented (E9-1 S2b-3a, DEC-2324 item 5, DEC-2319 item 2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's presentations: take, settle, and the sign-in standing, stubs and pending tests (E9-1 S2b-3b)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's presentations: take, settle, and the sign-in standing, implemented (E9-1 S2b-3b)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's verifier does one ES256 and one Ed25519 check on every call: stubs, pending tests, DEC-2324 item 4 (review of #2153)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* The judge's doc names the constant-work verifier (DEC-2324 item 4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* The judge verifies with the held key or None, the verifier doing the constant work (DEC-2324 item 4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Pin that a lapsed key leaves its map with its index entry, so live keys fill the bound exactly (review of #2131)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Merge the desync test into the implementation (review of #2131)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Pin an Ed25519 key recorded as es256 refused, and DEC-2319 item 2 reads at or after the sign-in (review of #2161)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Merge the reverse-algorithm test; a key-store miss parses a decoy key, so a hit and a miss cost the same parse (review of #2162)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Pin refused presentations of taken challenges as failures, and the address limit through settle (review of #2166)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Merge the refused-presentation tests into the implementation (review of #2166)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Name E9-13 as the end of the interim standing, now DEC-2319 is accepted

Claude-Session: https://claude.ai/code/session_01XaatUQzQSGvN12QXK3pnJh

* Pin route 2's 300 s failure window, single use across threads, and a poisoned lock (review of #2166)

The review found the T0+339 assertion vacuous: settle answers false there
whether or not the failure lapsed. Two devices now pin the window to the
second, one reaching its limit at 338 s only if a failure at 39 s still
counts, the other reaching it afresh at 339 s only if it lapsed then.
Sixteen threads taking one challenge must find exactly one Some, and a
panic inside issue that poisons the store's locks must leave take and
settle working. Sessions::standing's doc names Standings as the standing's
one owner, which the session store alone writes.

Claude-Session: https://claude.ai/code/session_01XaatUQzQSGvN12QXK3pnJh

---------

Co-authored-by: Claude <noreply@anthropic.com>
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