Skip to content

🐛 fix(storage): keep current decisions outside audit eviction - #2011

Merged
gaborbernat merged 1 commit into
mainfrom
fix/current-decisions-outside-eviction-1388
Aug 31, 2026
Merged

🐛 fix(storage): keep current decisions outside audit eviction#2011
gaborbernat merged 1 commit into
mainfrom
fix/current-decisions-outside-eviction-1388

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

prune_history dropped 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 which current_policy_decision returned None for 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 two expect calls 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;
Loading

Two record sets change shape. policy_decision_current_id holds 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_current keeps 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

@gaborbernat gaborbernat added the bug Something isn't working label Aug 31, 2026
@read-the-docs-community

read-the-docs-community Bot commented Aug 31, 2026

Copy link
Copy Markdown

Documentation build overview

📚 peryx | 🛠️ Build #34317780 | 📁 Comparing 618f5e6 against latest (5f765fe)

  🔍 Preview build  

No files changed.

@codspeed-hq

codspeed-hq Bot commented Aug 31, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 29 untouched benchmarks
⏩ 133 skipped benchmarks1


Comparing fix/current-decisions-outside-eviction-1388 (618f5e6) with main (51c3b19)

Open in CodSpeed

Footnotes

  1. 133 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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
gaborbernat force-pushed the fix/current-decisions-outside-eviction-1388 branch from 98a4860 to 618f5e6 Compare August 31, 2026 18:47
@gaborbernat
gaborbernat merged commit 37d6596 into main Aug 31, 2026
27 checks passed
@gaborbernat
gaborbernat deleted the fix/current-decisions-outside-eviction-1388 branch August 31, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep current policy decisions outside audit-history eviction

1 participant