Skip to content

fix(id): isolate pending email codes by flow - #6479

Merged
dezren39 merged 3 commits into
mainfrom
queue/9971-6177-directory-auth-purpose
Nov 11, 2026
Merged

dezren39 merged 3 commits into
mainfrom
queue/9971-6177-directory-auth-purpose

Conversation

@dezren39

@dezren39 dezren39 commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Summary

- pending codes[address] = one slot shared by Confirm and SignIn
+ pending codes[(address, flow)] = independent Confirm or SignIn slot
+ check_code validates only the requested flow

Codes now retain separate resend windows and attempt counts per flow, and the digest is bound to its flow. Closes #6177.

Evidence

  • Before: fetched origin/main still keyed codes by address and consumed a matching code before the view checked its purpose.
    After: cargo test -p id --lib directory_auth — 18 passed; cargo test -p id --lib directory_view — 22 passed. rustfmt --check and git diff --check pass.

Merge Danger

Door: two-way — revertible code-only change.

Blast Radius: narrow — DirectoryAuth email-code issuance and confirmation flows.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 6, 2026 09:17
@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3d39f60c-ebfc-4074-af23-55acb57883a8
Commits

Reviewing files that changed from the base of the PR and between aaeccaf and 1fab4a5.

Files selected for processing: 2

  • pkgs/id/src/directory_auth.rs
  • pkgs/id/src/directory_view.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T09:54:02.222077Z 1fab4a5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f9db6d530

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/id/src/directory_auth.rs Resolved
@dezren39 dezren39 added queue/claimed Queue worker lifecycle state work/assigned Queue worker lifecycle state status/in-progress Queue worker lifecycle state labels Nov 11, 2026
@dezren39
dezren39 force-pushed the queue/9971-6177-directory-auth-purpose branch from 2f9db6d to 3d20f41 Compare November 11, 2026 08:30
@dezren39

Copy link
Copy Markdown
Member Author

@codex review

One P2 addressed in 3d20f41: the cross-flow test now re-issues the sign-in code past its resend window until it differs from the confirmation code, eliminating the 1-in-1,000,000 sampled-collision flake. Branch also rebased onto current main (7ff9cf5), diff otherwise unchanged.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d20f41c3a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +502 to +503
#[test]
fn confirmation_and_sign_in_codes_have_independent_slots() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add property coverage for pending-code flow isolation

The new flow-isolation invariant is covered only by fixed example sequences, whereas the root AGENTS.md testing doctrine explicitly requires property tests for meaningful state-machine invariants. The existing property test in this module covers signed-request nonce grammar, not pending codes. Add a proptest generating interleaved issuance, verification, and time advancement across both flows, checking that operations on one slot preserve the other slot's code, resend window, and attempt budget. This supplies the required coverage of operation orderings and timing boundaries beyond this single example.

AGENTS.md reference: AGENTS.md:L42-L46

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged — not disputing: the repo doctrine (AGENTS.md L42–46) does call for property coverage of state-machine invariants, and the pending-code slots qualify. This needs a properly modelled proptest (interleaved issuance/verification/time across both flows, checking slot independence for code, resend window, and attempt budget), which is more than the current lane's remaining shift budget can do carefully. The shepherd task (14041) is parked on this PR with this thread as the resume point; the resuming lane adds the proptest, re-runs the directory_auth suite, and merges. Production change and the collision-safe example test are already green: directory_auth suite 24/24 on head 3d20f41.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 1fab4a5 (branch rebased onto current origin/main; directory_auth suite 25/25, up from 24).

pending_code_slots_are_isolated_across_flows is a modelled proptest in the same module: it generates interleaved Issue / Check / Advance operations across both flows (Confirm and SignIn) for one address — checks present the slot's own code, the OTHER flow's code, or a wrong code — and validates every step against an independent per-slot model (code, sent_at, expires_at, attempts). Beyond outcome equality, it snapshots the other slot's production state (digest, sent_at, expires_at, attempts) before and after each operation: a check must leave it byte-identical (check_code does not even sweep), and an issue may change it only by sweeping an already-expired slot, which the model accounts for explicitly. Code collisions between the two flows are handled by construction: guesses are resolved to strings and compared against the model slot's code, so an equal-code draw predicts acceptance in the owning flow exactly as production behaves.

@dezren39 dezren39 added queue/parked Queue task is parked (waiting on CI, time, or an event) status/parked Deliberately paused with a recorded resume condition and removed status/in-progress Queue worker lifecycle state queue/claimed Queue worker lifecycle state labels Nov 11, 2026
developing-today[bot] and others added 3 commits November 11, 2026 03:40
… on #6479)

Interleaved issuance, verification, and time advancement across both
flows, checked step by step against an independent per-slot model:
an operation on one flow preserves the other slots code, resend
window, and attempt budget exactly; the only cross-slot effect is
the issuance sweep removing expired slots of either flow.
@dezren39
dezren39 force-pushed the queue/9971-6177-directory-auth-purpose branch from 3d20f41 to 1fab4a5 Compare November 11, 2026 09:52
@dezren39
dezren39 merged commit 410527c into main Nov 11, 2026
3 of 16 checks passed
@dezren39
dezren39 deleted the queue/9971-6177-directory-auth-purpose branch November 11, 2026 10:04
@dezren39 dezren39 removed status/parked Deliberately paused with a recorded resume condition queue/parked Queue task is parked (waiting on CI, time, or an event) work/assigned Queue worker lifecycle state labels Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant