Skip to content

fix(dataexchange): filter subdirs before inbox eviction early check (PILOT-183)#34

Merged
matthew-pilot merged 1 commit into
mainfrom
openclaw/pilot-183-20260719-185010
Jul 20, 2026
Merged

fix(dataexchange): filter subdirs before inbox eviction early check (PILOT-183)#34
matthew-pilot merged 1 commit into
mainfrom
openclaw/pilot-183-20260719-185010

Conversation

@matthew-pilot

Copy link
Copy Markdown
Collaborator

What

The evictInboxOverflow function's early-return check uses the raw os.ReadDir entry count (including subdirectories) to decide whether eviction is needed. When a subdirectory inflates the count past the cap, eviction is skipped even though only legitimate files are at the cap — allowing the real file count to grow unchecked.

Fix

Move the IsDir() filter before the first len check, so both guards (early-return + eviction trigger) operate on file-only entries.

Verification

  • go build ./... — clean
  • go vet ./... — clean
  • go test ./... -count=1 — PASS (0.347s)
  • New PILOT-183 tests: TestEvictInboxOverflow_PILOT183_SubdirMixedWithFiles and TestEvictInboxOverflow_PILOT183_SubdirInflatesEntries both pass

Files

  • service.go — +1/-3 (moved IsDir filter before early return)
  • zz_service_errors_test.go — +1/-3 (updated comment to reflect landed fix)

Closes PILOT-183

…PILOT-183)

The evictInboxOverflow function's early-return check used the raw
os.ReadDir entry count (including subdirectories) to decide whether
eviction is needed. A directory at inboxMaxFiles + 1 entries (where
the +1 is a subdir) would skip eviction entirely, even though only
maxFiles of real files exist — allowing the real file count to grow
unchecked on subsequent saves.

Fix: move the IsDir() filter before the early-return len check, so
both guards operate on file-only entries. The byte-based eviction
path (evictInboxOverflowByBytes) was already correct.

Closes PILOT-183
@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@matthew-pilot
matthew-pilot merged commit 8c392b9 into main Jul 20, 2026
5 checks passed
@matthew-pilot
matthew-pilot deleted the openclaw/pilot-183-20260719-185010 branch July 20, 2026 16:34
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.

1 participant