Skip to content

feat(findings): cap findings stored per run and add cora findings prune - #732

Merged
ajianaz merged 2 commits into
developfrom
feat/findings-retention
Nov 16, 2026
Merged

ajianaz merged 2 commits into
developfrom
feat/findings-retention

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

What

Two parts of #725: a review or scan now stores at most debt.max_stored_findings findings (default 500, most severe first), and a new cora findings prune removes stale projects and old closed findings.

Why

Partly closes #725. A real cora.db had 339 projects rows for about 20 live repositories (every worktree or temp clone ever indexed stays forever), and one full-repository scan stored 5,557 open findings, 96% of all open findings, so cora findings list and cora debt drowned in scan noise. Not in this PR: recurring-finding aggregation (a recurrence counter / last_seen) and auto-dismissing old info findings, which need a schema migration and their own design.

How

  • review_store.rs: ReviewRecord.max_stored_findings. record_review stores stored_subset(issues, max): the most severe first (Severity derives Ord as Critical < Major < Minor < Info, so ascending order), stable for equal severities. The stored summary gets a note when findings were left out. The score and the fingerprints used by resolve_stale still come from the whole run, so a finding that was not stored is not auto-resolved.
  • ReviewStore::prune(PruneOptions): one transaction. stale_projects deletes projects whose root_path is gone (foreign keys cascade to symbols, files, edges, reviews, findings, events); the current project is never removed. older_than_days deletes closed findings older than the cutoff, then reviews of that age with no findings left. dry_run rolls the transaction back, so the report is exactly what a real run removes.
  • commands/findings.rs: cora findings prune [--stale-projects] [--older-than DAYS] [--dry-run]; at least one criterion is required.
  • finalize::save_history now takes the config to read the cap (six call sites).
  • Deliberately explicit: pruning is a command, not automatic. A project on an unmounted drive looks stale, and deleting history unprompted is not reversible. debt.retention_days stays reserved for a later automatic policy.
  • Known limitation: prune only edits cora.db. The vector index is one shared file (cora_index.usearch) keyed by symbol id; vectors of removed projects stay in it until it is rebuilt. The app never removed vectors on re-index either, so this is existing behaviour, now documented. VectorIndex::remove exists if a follow-up wants to clean them.
  • Docs (cli-reference.md, configuration.md) and the changelog are updated.

Testing

  • cargo test --features tree-sitter passes (1338 unit tests + integration suites)
  • cargo fmt --all -- --check passes
  • cargo clippy --all-targets --features tree-sitter -- -D warnings passes
  • cargo build --release --features tree-sitter passes (left to CI)
  • Manual check with the real binary and a throwaway CODECORA_HOME:
    • a deterministic review with 700 findings (with rules_engine.max_findings: 0) stored 500 and the summary ended with "[500 of 700 findings stored; the rest were left out by debt.max_stored_findings = 500]";
    • two project directories were deleted; cora findings prune --stale-projects --dry-run listed both ("2 review(s) with them") and left the database unchanged (3 projects); the real run removed them, leaving 1 project, 2 reviews and integrity_check = ok;
    • cora findings prune with no criterion is a usage error (exit 2).

New unit tests: the cap keeps the most severe findings and notes it in the summary (this test caught my first version sorting the wrong way); 0 and a roomy cap store everything with no note; stale-project pruning cascades to reviews, findings and events, honours keep_root, and a dry run changes nothing; pruning by age keeps open findings and removes only closed and emptied ones. This touches the review schema's data and a destructive command, so I checked the cascade on the real database file, not only in memory.

Related Issues

Part of #725. Related: #724 (#731).

Checklist

  • Branch name follows convention (feat/)
  • Branch is from develop
  • Commit messages follow Conventional Commits
  • No secrets or credentials committed
  • One logical change per PR (no mixed concerns)

ajianaz added a commit that referenced this pull request Nov 16, 2026
…729)

## What
The three CI fixes that only work together, in one PR: the Clippy
`needless_bool` rewrite, the `Cargo.lock` bumps for `rustix` and
`libz-sys`, the `rusqlite` 0.41 upgrade for the SQLite CVE, and the
sorted directory walk that de-flakes a test. It supersedes #728 and
#730, whose commits are included here.

## Why
Every PR to `develop` fails the same three checks, none of them caused
by the PR, so no single fix can be green on its own and none can be
merged under the required checks:
- **Clippy**: `clippy::needless_bool` at `src/engine/rules/builtin.rs`
on Rust 1.100 (the CI toolchain; local 1.97 does not report it).
- **Security Audit (CVE)**: `rustix 1.1.5` (RUSTSEC-2026-0486),
`libz-sys 1.1.30` (RUSTSEC-2026-0418) and `libsqlite3-sys 0.28.0`
(CVE-2026-119375, SQLite before 3.54.0).
- **Test**:
`mcp::agent_tools::tests::finalize_agrees_with_prepare_only_for_the_same_filters`
depends on the filesystem's `readdir` order.

## How
- `26768e8` (#728): `builtin.rs` returns the condition directly;
`Cargo.lock` only: `rustix` 1.1.6, `libz-sys` 1.1.33.
- `beee771`: `rusqlite` 0.31 to 0.41 (`libsqlite3-sys` 0.39.1, SQLite
3.54.1), `rust-version` 1.85 to 1.89, `usize` binds as `i64` in
`index/brain.rs`, and `[lints.clippy] collapsible_if = "allow"` because
Rust 1.89 enables let-chains and clippy would report 56 hits in
untouched code (a wide mechanical rewrite for a later change).
- `1275b71` (#730): `WalkBuilder::sort_by_file_name`, and the test uses
a selection whose `path` and `source-first` orders differ by
construction.
- Two merge commits bring #728 and #730 in with no conflicts.
- MSRV 1.89 is user-visible for anyone building with `cargo install` on
an older toolchain; the release notes should say so.

## Testing

- [x] `cargo test --features tree-sitter` passes (1313 unit tests +
integration suites)
- [x] `cargo fmt --all -- --check` passes
- [x] `cargo clippy --all-targets --features tree-sitter -- -D warnings`
passes (the CI Clippy check on Rust 1.100 is the real proof for
`needless_bool`)
- [ ] `cargo build --release --features tree-sitter` passes (left to CI)
- [x] Locked versions after the merges: rustix 1.1.6, libz-sys 1.1.33,
libsqlite3-sys 0.39.1, rusqlite 0.41.1.
- [x] Database compatibility of the `rusqlite` upgrade was checked in
both directions (old release binary indexed 800 symbols, new build read,
re-indexed and ran a `brain` search on the same `cora.db`, old binary
read it back, `PRAGMA integrity_check` = `ok`).
- Individually, the earlier runs showed: #728 Clippy green (fix proven),
#730 Test green (flake fixed), #729 Audit with only `rustix`/`libz-sys`
left.

## Related Issues
Supersedes #728 and #730. Unblocks #727, #731, #732, #733, #734, #735,
#736, #737.

## Checklist

- [x] Branch name follows convention (`chore/`)
- [x] Branch is from `develop`
- [x] Commit messages follow [Conventional
Commits](https://www.conventionalcommits.org/)
- [x] No secrets or credentials committed
- [x] One logical change per PR: one logical goal (a green CI), several
small causes that cannot be separated under the required checks

🤖 Generated with [Claude Code](https://claude.ai/code)

https://claude.ai/code/session_01F36Uc6swK21c7x7J14k1wc

---------

Co-authored-by: Claude <[email protected]>
…une` (#725)

- debt.max_stored_findings (default 500, 0 = no limit): a run stores at most
  this many findings, the most severe first. The stored summary says how many
  were left out; the score still uses the whole run and the fingerprints of the
  whole run still drive auto-resolution.
- `cora findings prune --stale-projects` removes projects whose root directory
  no longer exists (foreign keys cascade to symbols, files, edges, reviews,
  findings and events). `--older-than DAYS` removes resolved/dismissed findings
  of that age and the reviews left empty; open findings are kept. `--dry-run`
  runs the same transaction and rolls it back. The current project is kept.
- save_history takes the config so it can read the cap.
…es alone (#725)

The configuration page never got the max_stored_findings entry: the edit was
written against text that only exists on another branch and did nothing.
@ajianaz
ajianaz force-pushed the feat/findings-retention branch from 3a81426 to 4b379d7 Compare November 16, 2026 00:56
@ajianaz
ajianaz merged commit ebeb942 into develop Nov 16, 2026
16 checks passed
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.

feat(findings): retention & hygiene — stale project roots, scan blow-up bounds, recurring aggregation

1 participant