Skip to content

feat(cache): add cache inventory and guarded pruning - #2236

Draft
kingfs wants to merge 1 commit into
DeusData:mainfrom
kingfs:feat/cache-management
Draft

kingfs wants to merge 1 commit into
DeusData:mainfrom
kingfs:feat/cache-management

Conversation

@kingfs

@kingfs kingfs commented Sep 18, 2026

Copy link
Copy Markdown

What does this PR do?

Removed Git worktrees leave project indexes behind, and caches can also contain WAL/SHM files whose database no longer exists. Add cache stats and explicit, guarded cache prune modes, with equivalent cache_stats / cache_prune MCP tools.

  • Inventory all immediate cache entries separately from project database counts, including missing roots and orphan sidecars; return complete project lists without pagination.
  • Prune projects with --missing-root and/or --older-than (AND, based on indexed_at). Use standalone --orphan-sidecars to remove orphan WAL/SHM files. Every mode supports --dry-run.
  • Keep stats and dry-run independent of daemon startup/version admission. Real deletion retains exact-build admission, nonblocking project mutation leases, eligibility rechecks, and watcher cleanup. Busy/failed deletions are reported with a nonzero exit status.
  • Preserve configuration, logs, corrupt/ambiguous databases, symlinks, and source directories. Document count/size semantics and recovery from build conflicts.

Draft for design review: this adds MCP API surface and does not yet have the prior tracking-issue discussion requested by CONTRIBUTING.md.

Validation

  • Production binary rebuilt on Linux ARM64.
  • 9 cache tests passed with ASan/UBSan; 6 product CLI tests passed, including real deletion, a running same-build daemon, and orphan sidecar cleanup.
  • Earlier cache/bootstrap/application regression run: 92 passed. Separately verified that an older daemon blocks deletion without touching files and stopping it permits a retry.
  • New cache module passed clang-tidy and cppcheck; memory-core, no-test-skips, new-file formatting, and git whitespace checks passed.
  • Whole-repository lint was attempted with the available standalone clang-format and reports formatting drift, including unchanged upstream files. The repository documents that its Homebrew LLVM formatter differs. Full suite and canonical cross-platform CI remain outstanding.

Checklist

  • Every commit is signed off (git commit -s)
  • Tests pass locally (make -f Makefile.cbm test) — focused suites passed; full suite not run
  • Lint passes (make -f Makefile.cbm lint-ci) — focused checks passed; whole-repository formatter mismatch described above
  • New behavior is covered by a test (reproduce-first for bug fixes)

Signed-off-by: kingfs <zhenzhen086@126.com>
@github-actions

Copy link
Copy Markdown

Thanks for opening this — it has been seen, and it is queued.

This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence.

Current review status: working through a backlog. 0.9.1-rc.1 is out, so the release freeze that held reviews is over — but it left a large queue of open pull requests behind it, and we are reading through them oldest-first. The background is in discussion #1144.

What that means for this PR, concretely:

  • It will not be closed for inactivity. No stale bot touches pull requests here.
  • It may still sit a while before a human reads it. That is on us, not on you.
  • Older PRs are read first, so a recent one is not being skipped — it is behind a queue.

Things that will genuinely speed it up whenever review does happen:

  • Keep it rebased on main — the tree is moving quickly right now, and a conflicting branch cannot be reviewed as the diff you intended.
  • Get CI green, or say which failures you believe are pre-existing.
  • Keep the change to one claim. Bundled features and refactors get split before they get merged, which costs you a round trip.
  • Every commit needs a sign-off (git commit -s) — CI enforces DCO.

If this fixes a bug, a reproduction we can run is worth more than a description of the symptom.

Thanks for contributing, and sorry in advance for the wait.

@kingfs
kingfs marked this pull request as ready for review September 18, 2026 10:09
@kingfs
kingfs requested a review from DeusData as a code owner September 18, 2026 10:09
@kingfs
kingfs marked this pull request as draft September 18, 2026 10:56
@DeusData

Copy link
Copy Markdown
Owner

Thank you for the contribution, including the inventory/pruning tests and the explicit notes about validation still outstanding. This draft introduces new MCP tools and CLI operations across cache, daemon, and server code, including deletion behavior, so it needs a direction and safety review before we can decide whether to integrate it.

We need more time to review the API boundary and the pruning safeguards, including behavior with active sessions, missing roots, and interrupted operations. Please keep this as a draft while we make that decision; this acknowledgement is neither acceptance nor rejection. Our review queue is quite full, and we appreciate the effort and your patience while we work through it.

@DeusData DeusData added enhancement New feature or request stability/performance Server crashes, OOM, hangs, high CPU/memory security Security vulnerabilities, hardening priority/normal Standard review queue; useful PR with ordinary maintainer urgency. labels Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority/normal Standard review queue; useful PR with ordinary maintainer urgency. security Security vulnerabilities, hardening stability/performance Server crashes, OOM, hangs, high CPU/memory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants