Skip to content

feat(be): reap applications no anchor references any more - #4237

Closed
sea-snake wants to merge 1 commit into
feat/evict-idle-tracked-defaultsfrom
feat/reap-unreferenced-applications
Closed

feat(be): reap applications no anchor references any more#4237
sea-snake wants to merge 1 commit into
feat/evict-idle-tracked-defaultsfrom
feat/reap-unreferenced-applications

Conversation

@sea-snake

@sea-snake sea-snake commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Motivation

Changes

Tests


Design: #4222 (docs/ongoing/tracked-default-accounts.md). Overview: #4230.

Nothing has ever been removed from the application registry, so it grows for the
lifetime of the canister, and tracking every sign-in makes it grow faster. The
predicate is the existing `StorableApplication.stored_account_references`, which
is an accurate live count today because every insert is counted and nothing has
ever been removed: it only needed decrementing, which the single write path made
a property of one function.

Reaching zero removes the application row, and the origin-index entry when it
still points at that number. The number is retired rather than reissued, so an
origin signed into again allocates a fresh one. Applications created before this
change reap on the same rule, with no migration.

Implements docs/ongoing/tracked-default-accounts.md §8 (D15, D18).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sea-snake
sea-snake requested a review from a team as a code owner August 19, 2026 00:05
@zeropath-ai

zeropath-ai Bot commented Aug 19, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to dcb9613.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► src/internet_identity/src/storage.rs
    Implement application reaping logic and conditional storage of applications when references are zero
Bug Fix ► src/internet_identity/src/storage.rs
    Reap applications when no references remain and avoid stale memory entries
Test Update ► src/internet_identity/src/storage/tests.rs
    Adjust tests to reflect reaping behavior and absence of reaped applications in stable memory
Enhancement ► src/internet_identity/tests/integration/accounts.rs
    Add integration test for reaping and application reclaim behavior upon per-anchor sign-ins

@sea-snake

Copy link
Copy Markdown
Contributor Author

Folded into #4235. These three cannot be deployed separately: tracking makes every sign-in at a new origin mint an application row from an operation with no per-anchor cap, eviction is what bounds that and the only thing that makes an application's reference count fall, and reaping is dead code without it. Verified rather than assumed — with tracking alone, one anchor signing in at 2 000 origins creates 2 000 reference rows and 2 000 application rows. Shipping a prefix would mean unbounded, attacker-drivable stable-memory growth, so they are now one PR.

@sea-snake sea-snake closed this Aug 19, 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

Development

Successfully merging this pull request may close these issues.

1 participant