Repository navigation
perf(auth): the latest audit checkpoint's signatures are checked once per new checkpoint, not on every request - #430
Merged
Merged
Conversation
|
Warning Review limit reachedYou'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. View limit details
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. |
PiquelChips
force-pushed
the
perf/audit-latest-cache
branch
from
November 7, 2026 12:28
4fd06fb to
7e0a664
Compare
…ed checkpoint, not on every request
…d at any position, and once for concurrent requests
…ve its search, and hits take no lock
PiquelChips
force-pushed
the
perf/audit-latest-cache
branch
from
November 8, 2026 10:40
7e0a664 to
d028e11
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.
/audit/checkpoints/latestchecked Ed25519 signatures on every request. It looks for the newest checkpoint the keys verify, and may pass over up to 1,000 forged ones that someone with auth's database role inserted. A public endpoint shouldn't repeat that work for every visitor. Now each replica remembers what it found, and searches again only when another checkpoint has been stored where it could change the answer. Every request still sees the current answer, at the cost of one small query.What changes
AuditApplicationkeeps the last note it found, with two numbers:floor: the lowest position the search read. That's the trusted checkpoint's, the oldest untrusted one if it stopped at its limit of 1,000, or 0 if it read every checkpoint.floor.AuditRepository::count_checkpoints(from)andTrustedCheckpoint::floor.audit-history.mdsays when signatures are checked again.Deploying and rolling back
No migration. Each replica starts with an empty cache. Rolling back restores the search on every request.
Proof
the_latest_checkpoint_is_verified_once_per_checkpoint, on one replica:Reviewed by GPT 6.1 Sol, which found the top-position keying stale (blocking) and repeated searches under concurrent misses; both are fixed. Then re-checked by Claude Opus 5.5 while Sol was rate-limited. It confirmed both fixes, and measured an unbounded
count(*)at 7–8 ms after a year of checkpoints, held under the lock. That led to the bounded count and the lock-free hit path.Note
Written by Claude Opus 5.5 in Claude Code and reviewed by GPT 6.1 Sol and Claude Opus 5.5 (via T3 Code)
🤖 Generated with Claude Code