Skip to content

E9-1 route 2 S2a tests (lane MB): the gate bounded in all, pending (DEC-2119 items 4 and 11) - #2128

Closed
kunwarshivam wants to merge 4 commits into
mainfrom
claude/mb-reduction-gate
Closed

kunwarshivam wants to merge 4 commits into
mainfrom
claude/mb-reduction-gate

Conversation

@kunwarshivam

Copy link
Copy Markdown
Owner

Story

E9-1 route 2, slice S2a, tests first (DEC-77). Claim #758. Workspace API spec §4.10 route 2 item 3, "Bounded memory". Decisions: DEC-2119 items 4 and 11, which the coordinator ruled extend mandate_authn's gate; DEC-653. I told L1 before touching mandate_authn::reduction, and L1 has nothing in flight there.

  • ReductionLimits gains three fields:

    • max_outstanding (4,096): past it, every issue is refused;
    • reserve (3,072): once that many are outstanding, an address that already holds a challenge gets no more;
    • max_failure_keys (65,536): addresses and devices together, the key whose latest failure is oldest dropped first.

    The gate does not read them yet; the implementation PR makes it.

  • Construction sites updated: the existing Bench::new sets the new fields to u32::MAX, so every existing gate test keeps its meaning. Bench::bounded is new. mandate_api_server::reduction::limits() now sets DEC-2119's values, and its test (reduction_keys.rs) asserts them.

  • Three pending tests in mandate-authn/tests/reduction.rs. Each fails on the gate's current answer rather than at a stub, because stubbing issue or present would stop every existing route-2 test. So each is named in xtask/behaviour-only/ with that reason. The implementation PR deletes the three rows.

Spec clause → test

Spec clause or invariant Test name
4,096 in all: the cap refuses everyone, including a second before expiry; no refusal drops a held challenge; consumption and expiry free slots past_max_outstanding_the_gate_refuses_every_client_and_drops_nothing
The reserve: below it a repeat address is issued; at it an address holding one gets no more; it still binds a second before expiry; nothing held is dropped past_the_reserve_an_address_that_holds_one_gets_no_more
65,536 failure keys, oldest first; dropping changes no answer failure_keys_are_bounded_and_the_oldest_is_dropped_first

cargo xtask ci pending applies the three rows; each test runs and fails.

Dependencies

None new.

Journal events added

None.

Not done

Decisions needed

None.

Safety checklist (safety-critical changes)

  • No floats in money or quantity paths
  • No clock reads or randomness in the core (the gate takes now and the bytes)
  • No unwrap, expect, or panics on trading paths
  • Ordering: n/a
  • Replay: n/a
  • No secrets or trading content in logs or notifications
  • No x-planned or (planned: ...) marker added

Checks

  • cargo xtask ci pending: the three rows apply.
  • markers, clippy -D warnings, fmt.
  • cargo nextest run -p mandate-authn -p mandate-api-server: 435 pass, 3 pending.
  • Review agent report attached: the coordinator reviews.

Generated by Claude Code

… 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
…e, 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
…ys 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
kunwarshivam added a commit that referenced this pull request Oct 22, 2026
…ms 4 and 11) (#2131)

## Story

E9-1 — route 2's reduction gate, bounded in all (slice S2a, implementation half of DEC-77). Tests PR: #2128. Decisions: DEC-653, DEC-2119 (items 4 and 11).

This PR implements the stubs from #2128. It deletes the `#[ignore = "pending E9-1"]` lines and the four behaviour-only rows. It also makes `ReductionGate` read the three new `ReductionLimits` fields.

## Spec clause → test

| Spec clause or invariant | Test name |
|---|---|
| At `max_outstanding` (4,096), the gate refuses every client and drops nothing | `past_max_outstanding_the_gate_refuses_every_client_and_drops_nothing` |
| Past the reserve (3,072), an address that already holds a challenge gets no more | `past_the_reserve_an_address_that_holds_one_gets_no_more` |
| At most `max_failure_keys` (65,536) failure keys are held, and the oldest is dropped first | `failure_keys_are_bounded_and_the_oldest_is_dropped_first` |
| The key whose latest failure is oldest goes first; at a tie the address goes before the device; at the bound every key is kept | `the_failure_key_whose_latest_failure_is_oldest_goes_first_an_address_before_a_device` |

`bound_failure_keys` stops if a removal removes nothing, so a bad lookup cannot loop forever.

## Dependencies

None.

## Journal events added

None. Challenges and failure counts are never journaled (workspace API spec §4.10).

## Not done

- S2b: the opening route on L1's fold.
- The `rp_id` userinfo refusal and the typed `challenge_id` error (follow-up pair).

## 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

- [ ] `cargo xtask check` green: fmt, clippy `-D warnings`, markers, and `mandate-authn` nextest (76/76) pass locally; CI runs the full set.
- [x] `cargo mutants --in-diff` on the `mandate-authn` diff against main: 22 mutants, 18 caught, 4 unviable, 0 missed, 0 timeouts.
- [x] Review agent report attached

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

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

Round 1 FAIL: no test pinned a desync between `forget_before`'s index and the key map.

Round 2 PASS: #2128 at 02c128f, #2131 at 62b4f7c.
- `a_key_that_lapsed_holds_no_place_under_the_bound` fails on the desync mutant (`forget_before` pops the index but leaves the key in the map).
- The mutant that never pops lapsed keys stays equivalent: its answers are unchanged.
- #2131's test diff over #2128 is exactly the 7 `#[ignore = "pending E9-1"]` lines, and its behaviour-only rows are gone.
- `cargo test -p mandate-authn`, clippy and `cargo xtask markers` are clean.

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

Coordinator-approved-head: 62b4f7c


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

Copy link
Copy Markdown
Owner Author

Included in #2131, which landed combined (DEC-77).


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