feat(be): record that a session is still in use - #4244
Open
sea-snake wants to merge 4 commits into
Open
Conversation
|
✅ No security or compliance issues detected. Reviewed everything up to 3cd69a2. Security Overview
Detected Code Changes
|
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 19, 2026 01:47
7d6a294 to
0b043da
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 19, 2026 02:57
0b043da to
72c91a1
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 19, 2026 03:47
72c91a1 to
d8bd528
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 19, 2026 06:28
d8bd528 to
474d22b
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 19, 2026 07:07
474d22b to
77d5897
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 19, 2026 08:17
77d5897 to
78a570f
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 19, 2026 08:37
78a570f to
b7b407e
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 19, 2026 10:21
b7b407e to
2676560
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 20, 2026 10:57
2676560 to
41a2e22
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 20, 2026 13:08
41a2e22 to
752fe5a
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 20, 2026 13:52
752fe5a to
0502a3f
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 20, 2026 15:24
0502a3f to
5c573c2
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 21, 2026 08:54
ea03fb3 to
5b47998
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 21, 2026 10:38
5b47998 to
a6543f1
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 21, 2026 17:06
a6543f1 to
b54fca0
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
2 times, most recently
from
August 22, 2026 12:52
16dfdea to
48b8e13
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 22, 2026 17:24
48b8e13 to
bcfc3c1
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
2 times, most recently
from
August 22, 2026 18:08
3b1db8f to
b23f33b
Compare
sea-snake
changed the base branch from
feat/session-create-and-cap
to
feat/app-delegation-from-session
August 22, 2026 18:10
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 22, 2026 18:44
b23f33b to
8649c71
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 22, 2026 19:06
8649c71 to
f0e74e2
Compare
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 22, 2026 19:25
f0e74e2 to
24cdc5d
Compare
"This browser used this app 3 minutes ago" against "5 weeks ago" is what makes a session list worth reading, and it is what lets someone spot a session they do not recognise still being used rather than merely still existing. It is also what the session cap evicts on, since ordering by creation would drop a months-old session in daily use in favour of one created an hour ago and never touched. Every refresh stamps it. An earlier revision of this design coalesced the write to one an hour on the grounds that finer resolution had no reader; it now has three. Two cap evictions order on these stamps, and an hour of slack there is enough to drop the wrong session or the wrong browser. The third is the reading above: a list that can be an hour stale does not answer the question it exists to answer. The write is small next to what the call already does, which inserts a canister signature and rehashes the certified tree. The same write carries the reference's `last_used`, which keeps account eviction accurate for accounts only ever reached through a session, and the device registry's `last_used`, so a browser that has an app open counts as in use rather than as idle since its last sign-in. That is an anchor write on a call that otherwise never touches the anchor; §9.3 traded it away to keep refresh cheap, and the accounting above is why it is worth paying now. Implements docs/ongoing/revocable-app-sessions.md §7.3 (S13). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
sea-snake
force-pushed
the
feat/session-refresh-stamps
branch
from
August 22, 2026 19:49
24cdc5d to
9f009c7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Design: #4224. Overview: #4230.
"This browser used this app 3 minutes ago" against "5 weeks ago" is what makes a session list worth reading, and what lets someone spot a session they do not recognise still being used rather than merely still existing.
Every refresh stamps, and three consumers make coarsening it unattractive: the session cap orders live sessions on this field, so inside a coarsening interval every session would look equally idle; the browser registry cap orders on the same signal, where an hour is long enough to drop a browser in use; and a user-facing list that can be an hour stale does not answer the question it exists to answer. The write is small next to what the call already does, which inserts a canister signature and calls
update_root_hash().The same write carries three stamps:
last_usedlast_refreshedlast_usedStamping the device is the only reason refresh touches the anchor: it authenticates by session chain and never runs
check_authorization. What that write buys is a use signal a sign-in stamp cannot give the browser list.Stable writes scale with
1/Talongside the calls, so lowering the app-delegation TTL multiplies both.Tests:
session_refresh_stamp_tests(7), including a stamp for a session that is gone writing nothing, and a refresh advancing the device'slast_usedwhile leaving its enrolment timestamp alone. PocketIC drives two refreshes a minute apart and reads the device back offidentity_info.