Repository navigation
Python: Fix Purview cache size accounting when replacing entries - #8990
dhairya (dhairyajangir) wants to merge 2 commits into
Conversation
Added a test to verify cache behavior when updating entries and evicting others based on size constraints.
|
Could a maintainer authorize the waiting fork workflows for this PR and #8992 when convenient? Both fixes are ready for code-owner review; their descriptions include the regression tests, local validation, and any baseline limitations. The CLA checks have passed. I'll address any review feedback. Codex assisted with the fixes, validation, and this follow-up. |
|
/review |
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (2 commit(s)): 11225ab2b015, db8cc2e52c6f
Model: gpt-5.6-sol
Overview
The change removes an existing mapping before capacity eviction, preventing the stale heap record from subtracting the replaced value's size a second time. The operation remains atomic with respect to asyncio scheduling because set() has no suspension point, and the regression test verifies replacement retention, eviction of the other entry, exact byte accounting, and return to zero after removal. No PR-introduced Critical, High, or Medium issue was established.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
|
Eduard van Valkenburg (@eavanvalkenburg) thanks for triggering the review. On head The remaining failed merge gate reports Could you rerun the cancelled DevFlow prerequisites for this PR head and then the merge gate when convenient? The source change is unchanged; code-owner review is still pending. |
|
/review |
|
dhairya (@dhairyajangir), this pull request is waiting on your response. If there is no further activity within 4 days, it will be closed automatically. (This is an automated message.) |
|
Closing this pull request because there was no further activity after the automated warning. (This is an automated message.) |
|
The stale bot closed this PR after an inactivity warning. The issue remains open and labelled I rechecked current I attempted to reopen this PR, but GitHub returned a validation error. Could a maintainer reopen it if the fix is still welcome? The previous request regarding the cancelled DevFlow checks remains pending; no fully green CI or maintainer approval is implied. |
Motivation & Context
Growing a Purview cache entry at capacity could subtract its old size twice: once in
set()and again when eviction encountered the still-live old mapping. A cache limited to 20 bytes could retain 24 estimated bytes while reporting 16, then report a negative size when emptied.Description & Review Guide
Implemented and tested with Codex assistance on Linux/Python 3.12.14. The regression fails before the fix and passes afterward. All 200 Purview unit tests pass with 89% package coverage. Package Ruff, changed-file formatting, strict source Pyright, all five configured test type checks, source/wheel builds, and
git diff --checkpass.Optional warning-level Pyrefly output contains three existing diagnostics in unchanged middleware tests, so the no-warnings checklist item is left unchecked. The complete repository and live-service integration suites were not run.
Related Issue
Fixes #8988
AI Assistance
AI assistance details: Codex assisted with issue analysis, implementation, regression tests, validation and the PR description.
Current status (10 November 2026)
The stale bot closed this PR after an inactivity warning; it was not merged. The fix still addresses the agreed issue, which is labelled
ready-for-implementation. Currentmainat13956ad8c0c52538dc8fb5abae549019fbf2dc83has the same complete cache and cache-test files as the original base. The narrow issue reproduction against that main cache implementation still reports 16 bytes while holding 24, and -8 bytes after removal; its unused request-model import was stubbed, so this is not an end-to-end test. The preserved PR tree matches published headdb8cc2e, and all 18 cache tests pass on Linux/Python 3.12.14. The 200-test Purview result above is the earlier PR-head validation, not a fresh current-main full-suite run.Separate open draft #9607 handles values larger than the cache's total capacity; this PR handles double subtraction for replacements that fit. Both touch the same files.
The published head's Python test and quality jobs passed. The merge gate remains failed because its DevFlow prerequisite jobs were cancelled; the existing rerun request remains pending. No maintainer approval or fully green upstream CI is claimed.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.