🐛 fix(storage): keep current decisions outside audit eviction - #2011
Merged
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
A policy result was stored once, in the audit log, with the subject index holding only its identifier. Audit rows carry a global serial, so every repository's evaluations interleave in one bounded log, and pruning the oldest row deleted the subject index whenever that row was still the current one. A busy repository could therefore erase a live decision belonging to a different repository, which returned no result for a subject nothing had re-evaluated. Current decisions now hold their own copy of the record, keyed by evaluation serial in a table the audit bound does not apply to. Pruning drops an audit row and nothing else, so no amount of history churn can reach live state. Keying by serial rather than by subject keeps the newest-first scan the artifact lookup relies on, and lets that lookup read one table instead of joining back to history.
gaborbernat
force-pushed
the
fix/current-decisions-outside-eviction-1388
branch
from
August 31, 2026 18:47
98a4860 to
618f5e6
Compare
This was referenced Aug 31, 2026
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.
prune_historydropped the oldest audit row and, when that row was still current for its subject, deleted the subject index along with it. An evaluation stored its result in one place, the bounded audit log, and pointed the subject index at that row's identifier. Audit rows carry a single global serial, so every repository's evaluations interleave in one log. Traffic in one repository could evict another repository's live decision, after whichcurrent_policy_decisionreturnedNonefor a subject that nothing had re-evaluated and no policy had changed.Current decisions now hold their own copy of the record in
policy_decision_current_id, keyed by evaluation serial, outside the audit bound. Pruning removes an audit row and nothing else. Keying the current table by serial rather than by subject keeps the newest-first ordering that the per-artifact lookup walks, and lets that lookup read the record from the current table instead of joining back into history, which drops one of the twoexpectcalls on that join.flowchart LR Eval[Evaluation] --> Audit[Audit log<br/>bounded, global serial] Eval --> Current[Current decisions<br/>full record, unbounded] Audit --> Prune[Evict oldest row] Prune -. no longer reaches .-> Current classDef accent fill:#cfe4ff,stroke:#1f6feb,color:#0b1f3a; classDef warn fill:#ffe3a3,stroke:#d29200,color:#3a2c00; class Eval,Audit,Current accent; class Prune warn;Two record sets change shape.
policy_decision_current_idholds a decision record where it held a subject, so the PyPI metadata migration rewrites it with the legacy-record conversion it already applies to the audit log.policy_decision_currentkeeps its subject key and identifier value. A preserved decision still compares against its repository's input generation, so surviving eviction does not mean surviving a policy or catalog change.Closes #1388