feat: size-capped LRU eviction for the image cache #33

Closed
opened 2026-07-04 15:43:00 +00:00 by a73x · 1 comment
a73x commented 2026-07-04 15:43:00 +00:00 (Migrated from git.a73x.sh)

[claude 2026-07-04] Fixes 9a31ed8f (DEF-1). Cache.MaxBytes (0 = off); hit refreshes mtime; evict() after every successful Ensure removes oldest-mtime .raw beyond the cap, always sparing the just-ensured image; best-effort (eviction never fails a succeeded Ensure). Agent flag --image-cache-max-gb default 20. TDD with real HTTP + real fs: evict-beyond-cap, cap-zero-off, hit-refreshes-recency, ensured-image-survives-even-over-cap. E2E in the sandbox pass (two images, tiny cap, observe eviction on the real agent). make ci green.


Migrated from git-collab patche 8d3338f9ea112f17b3ec2acabc1bb3f07519edeb.

Original author: a73x dev@a73x.sh.

Fixes git-collab issue 9a31ed8f

Historical merged patch. The original head and merge commits were not recorded. Forgejo cannot display a pull request without a head commit, so this record is preserved as a closed issue. The original diff is unavailable; no commit was guessed.

Original branches: fix/def1-image-eviction → main.

[claude 2026-07-04] Fixes 9a31ed8f (DEF-1). Cache.MaxBytes (0 = off); hit refreshes mtime; evict() after every successful Ensure removes oldest-mtime .raw beyond the cap, always sparing the just-ensured image; best-effort (eviction never fails a succeeded Ensure). Agent flag --image-cache-max-gb default 20. TDD with real HTTP + real fs: evict-beyond-cap, cap-zero-off, hit-refreshes-recency, ensured-image-survives-even-over-cap. E2E in the sandbox pass (two images, tiny cap, observe eviction on the real agent). make ci green. --- Migrated from git-collab patche `8d3338f9ea112f17b3ec2acabc1bb3f07519edeb`. Original author: a73x <dev@a73x.sh>. Fixes git-collab issue `9a31ed8f` **Historical merged patch.** The original head and merge commits were not recorded. Forgejo cannot display a pull request without a head commit, so this record is preserved as a closed issue. The original diff is unavailable; no commit was guessed. Original branches: `fix/def1-image-eviction` → `main`.
a73x commented 2026-07-04 17:58:41 +00:00 (Migrated from git.a73x.sh)

Original review: comment (revision not recorded)

[claude 2026-07-04] Reviewer verdict: approve with minor changes — applied: overflow clamp on --image-cache-max-gb (range [0,2^20], matching cloudhv's maxDiskGB precedent), per-eviction slog line, sparse-size accounting caveat documented, test comment fixed. Reviewer verified the safety claim (PrepareDisk reflink-copies the base; temps are download-*/.converting so *.raw glob can't evict them; single-threaded reconcile). E2E in sandbox with the REAL agent + 2GB cap: creating from a 700MB image evicted the 2.2G focal base (slog 'imagecache: evicted' present); a second 700MB image did NOT evict (A+B=1.4G fits) — cache held 2, exactly 1 eviction. Merging per session goal.

**Original review: comment** (revision not recorded) [claude 2026-07-04] Reviewer verdict: approve with minor changes — applied: overflow clamp on --image-cache-max-gb (range [0,2^20], matching cloudhv's maxDiskGB precedent), per-eviction slog line, sparse-size accounting caveat documented, test comment fixed. Reviewer verified the safety claim (PrepareDisk reflink-copies the base; temps are download-*/.converting so *.raw glob can't evict them; single-threaded reconcile). E2E in sandbox with the REAL agent + 2GB cap: creating from a 700MB image evicted the 2.2G focal base (slog 'imagecache: evicted' present); a second 700MB image did NOT evict (A+B=1.4G fits) — cache held 2, exactly 1 eviction. Merging per session goal.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
a73x/eitri#33
No description provided.