Skip to content

fix: enforce current cache limits when restoring entries - #95

Open
drevendev wants to merge 1 commit into
release/0.6.0from
codex/fix-cache-restore-bounds
Open

drevendev wants to merge 1 commit into
release/0.6.0from
codex/fix-cache-restore-bounds

Conversation

@drevendev

@drevendev drevendev commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Reopening a saved conditional cache with lower max_entries/max_entry_bytes currently restores every digest-valid entry, bypassing the current retention settings. Apply the serialized-body cap during admission and evict to the current entry-count cap before the restored cache can provide validators/bodies. Keep LRU ordering with a stable key tie-break when recency counters match.

Add implementation-local DEV-CACHE-RESTORE-01..06 cases covering lower/zero entry caps, Unicode serialized-byte boundary, oversized entries becoming misses, deterministic ties, preserved digest-corruption rejection and an unconditional provider refetch without the rejected ETag. Loading does not rewrite the file. Cache envelope, observation/bundle identity, thresholds and runtime dependencies are unchanged; whole-document JSON parsing is not claimed to be memory-bounded.

Validation (Python 3.13, Windows): full suite 2,392 passed; 148 conformance vectors passed; sample bundle verified. Before the fix six of the seven new test instances failed; all seven now pass. Existing rate-limit, cache-integrity and 304 fallback tests also pass. The existing CI matrix validates Python 3.12/3.13/3.14 and the installed wheel against the merge candidate.

Target: B4

Provenance: the shared 30-pair audit examined bounded cache admission in tkem/cachetools at d9615b57b5c5e6fd602047a6cc1de2cf2983e5a4. This is an original repair of Devostasis' existing cache; no donor source was carried. The owner explicitly requested implementation and this PR after the audit. Base is the active release/0.6.0 branch, as required by CONTRIBUTING.md.

CI result: run 40406159669 passed all 4 jobs: Python 3.12/3.13/3.14 suites and the installed-wheel gate. The workflow proves checkout/event revision equality for the PR merge candidate.

@andy-zen-dev andy-zen-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent exact-head review of 611b21ee19ad46b4ae6f9ad2dcf872da6dbf7156 (target release/0.6.0).

Reviewed all four changed files (src/devostasis/adapters/cache.py, tests/test_cache_restore_bounds.py, docs/spec/conformance.md, CHANGELOG.md) against the current cache and GitHubClient.get paths. Restored entries now go through the same digest and serialized-size admission criteria as fresh stores; load() enforces the lowered count cap before ETags can be returned. Stable (used descending, key ascending) eviction preserves deterministic recency ties. The existing conditional-fetch fallback requests a full body when an entry is rejected. No runtime dependencies, observation semantics or canonical bundle identities change.

Coverage checks: reduced/zero cap, serialized-size exact boundary including escaped Unicode, stable tie-breaking, tampering miss, and no stale If-None-Match on oversized-body refetch. The new case ids are implementation-local and documented. AGENTS.md absent; CONTRIBUTING.md governs. No blocking defect found in this bounded change.

CI: upstream run 40406159669 completed successfully, with three Python test jobs (3.12/3.13/3.14) and installed-wheel verification; the workflow's revision-proving step is green. These are GitHub CI results, not tests independently executed in this review environment.

APPROVE for this exact head. This is not a merge or release approval for the separate stacked #81/#75 work, and the release branch still needs its own integration/release gates.

Copy link
Copy Markdown

Maintainer closing gate — 2026-10-28 (read-only run)

Current PR #95: OPEN, non-draft, mergeable=true, head 611b21ee19ad46b4ae6f9ad2dcf872da6dbf7156, base release/0.6.0 (reported base SHA 6d935ee111e2efab7a5f7d7c8f8d050af8d35567).

Independent verdict: an existing APPROVED review by andy-zen-dev covers this exact head and all four changed files. Review threads returned none.

Hosted evidence: CI run 40406159669 was retrieved by the exact head SHA and reports completed/success; all four jobs and all reported steps were successful (tests on Python 3.12, 3.13 and 3.14; installed-wheel gate on Python 3.12). This does not cover uncommitted follow-up fixes #97/#98 and does not accept the cumulative 0.6 release.

Next maintainer action: recheck the current PR merge candidate/branch protection immediately before merging, then merge #95 into release/0.6.0 if still green. Keep #97 and #98 separate, open implementation fixes with new test/CI evidence and later independent reviews. Do not merge the downstream release PR #75 merely because #95 is green: #81/#82/#83/#86 and other release blockers remain separate gates.

Provider capability: authenticated as andy-zen-dev; repository permissions now pull=true, push=false, triage=false, maintain=false, admin=false. This worker cannot perform the authorized merge with the currently granted provider permissions. No commit/merge/release was attempted. Local full pytest in this run: NOT_RUN; hosted checks are the only execution evidence above.

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.

2 participants