Skip to content

fix(cache): handle directory cache entries (#326, #327) + tests (Tier D)#331

Merged
voorhs merged 1 commit into
devfrom
cov/tier-d-cache-fix
Jun 22, 2026
Merged

fix(cache): handle directory cache entries (#326, #327) + tests (Tier D)#331
voorhs merged 1 commit into
devfrom
cov/tier-d-cache-fix

Conversation

@voorhs

@voorhs voorhs commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

What

Coverage series (follow-up to #325), Tier D — cache bug fix + tests (the double-win: fixes two real bugs and makes the previously-dead code in generation/_cache.py reachable and covered).

StructuredOutputCache treated each on-disk entry as a file, but PydanticModelDumper writes a directory (class_info.json + model_dump.json):

Tests

Regression tests for the now-reachable paths: eager-load populating memory, corrupted-entry cleanup, and sync + async disk type-mismatch eviction (the latter is the exact case that used to crash — re-adds the test I had to drop in #325 when it surfaced the bug).

Closes #326
Closes #327

Notes

  • Verified locally with ruff check, ruff format --check, and mypy --strict (Python 3.10). Execution left to CI (unit-tests job).

🤖 Generated with Claude Code

…326, #327)

StructuredOutputCache treated each on-disk entry as a file, but
PydanticModelDumper writes a *directory* (class_info.json + model_dump.json):

- Eager load filtered `iterdir()` on `is_file()`, which matched nothing and
  silently disabled batch loading entirely (#326). Switched to `is_dir()`.
- Type-mismatch / load-error eviction called `Path.unlink()` on those
  directories, raising instead of evicting (#327). Routed all five eviction
  sites (sync + async) through a `_remove_cache_entry` helper using
  `shutil.rmtree(..., ignore_errors=True)`.

Adds regression tests covering the now-reachable paths: eager load populating
memory, corrupted-entry cleanup, and sync/async disk type-mismatch eviction.

Closes #326
Closes #327

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@voorhs voorhs merged commit fc22a6e into dev Jun 22, 2026
19 checks passed
@voorhs voorhs deleted the cov/tier-d-cache-fix branch June 22, 2026 08:10
@voorhs voorhs mentioned this pull request Jun 22, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant