Repository navigation
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1bb10333-1d49-4426-896d-d9a04178b836
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1bb10333-1d49-4426-896d-d9a04178b836
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1bb10333-1d49-4426-896d-d9a04178b836
There was a problem hiding this comment.
🟡 Changes recommended
Administrator session restoration without provider-backed assignments can deadlock with authorization continuation or Copilot changes because of inconsistent lock ordering, aborting requests.
4 open issues
What changed in this PR
This PR strengthens authority locking across Hub session restoration, global sign-out, and sensitive administrator operations to reduce deadlocks and prevent use of revoked sessions.
Changes:
- Adds ordered provider locks and an exclusive global-revocation lock helper.
- Acquires authority locks before sensitive work and rechecks revocation during session restoration.
- Adds regression coverage for lock ordering and overlapping revocation.
| File | Description |
|---|---|
hub/server/repositories/session-revocation-states/lock-session-revocation-state-for-update/index.ts |
Adds exclusive locking of global revocation state. |
hub/server/repositories/authentication-providers/lock-authentication-providers-for-session-authority/index.ts |
Locks provider rows in key order. |
hub/server/domains/session-revocation/end-all-hub-sessions/index.ts |
Locks providers and revocation state before ending sessions. |
hub/server/domains/session-revocation/end-all-hub-sessions/index.db.test.ts |
Tests revocation lock order and concurrent administrator continuation. |
hub/server/domains/copilot-connection/run-copilot-connection-transaction/index.ts |
Acquires authority locks before Copilot operations. |
hub/server/domains/copilot-connection/copilot-connection.db.test.ts |
Tests authority locking before session and connection locks. |
hub/server/domains/admission/run-session-restore-transaction/types.ts |
Adds the restoration revocation-lock interface. |
hub/server/domains/admission/run-session-restore-transaction/index.ts |
Wires the revocation-lock repository into restoration. |
hub/server/domains/admission/restore-hub-session/index.ts |
Rechecks revocation under lock before membership checks. |
hub/server/domains/admission/restore-hub-session/index.test.ts |
Expands restoration lock-order assertions. |
hub/server/domains/admission/authority-locks.db.test.ts |
Tests restoration waiting and rejection after revocation. |
hub/server/domains/administrator-authorization/continue-administrator-authorization/index.ts |
Acquires provider and revocation locks before continuation. |
Review effort: Max (dynamic)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1bb10333-1d49-4426-896d-d9a04178b836
There was a problem hiding this comment.
🟡 Changes recommended
The review flags incomplete session-revocation/restoration lock-order documentation and ambiguous waiter-versus-blocker PID handling in a database-test helper.
2 open issues
4 resolved since last review
Review effort: Max (dynamic)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1bb10333-1d49-4426-896d-d9a04178b836
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1bb10333-1d49-4426-896d-d9a04178b836
There was a problem hiding this comment.
🔵 Needs a closer look
Human judgment is needed to assess whether the shared test helper keeps case-specific setup, mutable state, and assertions sufficiently visible under the project's testing conventions.
No open issues 🎉
2 resolved since last review
Review effort: Max (dynamic)


Why
Ending all Hub sessions can overlap with edits and other sensitive operations. These operations need a consistent order so they do not deadlock or continue with revoked authority.
What changes
Session restoration, revocation, and sensitive operations now acquire authority locks in the same order. Operations that wait for revocation recheck the session before continuing.
Storybook screenshots
No story presentation changes.