feat(claims): bulk clear for auto-approved claims (#433)#434
Conversation
enables users to bulk clear auto-saved claims while preserving manually reviewed knowledge. when auto-approval is enabled (review.approver_role: trusted-agent), users can reset by clearing auto-approved claims in bulk. implemented: - new lifecycle function: clear_claims() filters by auto-approval status and optional date range, archives matching claims - added Claim.auto_approved and Claim.proposed_by fields - updated approval logic to set auto_approved flag when approver == proposer - cli command: vouch claims-clear [--auto-only] [--before DATE] [--confirm] - mcp tool: kb_clear_claims() with dry-run support - jsonl handler for kb.clear_claims in jsonl_server - registered in capabilities.METHODS for parity - comprehensive test suite covering filters, dry-run, audit trail design: - archives rather than deletes to preserve audit history - single bulk audit event logs all affected claim ids - no review gate (consistent with supersede/archive) - dry-run support for preview before confirmation fix: vouchdev#433
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Update the webapp as well and attach the screenshot of the webapp with cli |
regenerate schemas/claim.schema.json for the new auto_approved / proposed_by fields, and clear ruff findings in the claims-clear command (B904 raise-from, E501 line length, SIM102 nested-if) and its test (F841 unused binding).
the test branch carries main's test suite but a heavily gutted src/ tree — cli.py alone was missing ~3.4k lines (why/trace/impact/fsck and more), plus large deletions across health, server, jsonl_server, context, storage, bundle, index_db and sessions. the result was 334 failing tests and 31 mypy errors on the base, none related to the bulk-clear feature. restore the affected modules from origin/main (the healthy reference) so the branch's code matches the tests it ships, then re-apply the vouchdev#433 bulk-clear feature on top. also restores the provenance subsystem (prov_edges table + index_db helpers) the deletions had orphaned. result: mypy clean, ruff clean, full non-embeddings suite green.
adds a "clear" view to the browser review-ui that mirrors `vouch claims-clear`: a GET renders a dry-run preview of every auto-approved durable claim (optionally filtered by a --before date), and a POST archives them under a single `claim.bulk_clear` audit event. routes through `lifecycle.clear_claims`, so the audit trail is identical to the cli and mcp surfaces — no parallel data path. auto_only is fixed on, so the console can only ever clear auto-approved calibration cruft, never human-reviewed knowledge. progressive-enhancement friendly (plain form posts) with a js confirm() guard and a hub refresh broadcast.
what changed
adds a way to bulk-clear auto-saved claims while keeping human-reviewed knowledge intact. a new
clear_claims()lifecycle op filters durable claims by auto-approval status and an optional--beforedate, then archives (never deletes) the matches under a single audit event. exposed on all three surfaces:vouch claims-clear(cli),kb.clear_claims(mcp + jsonl), and registered incapabilities.METHODS. two additive fields on the claim model —auto_approvedandproposed_by— record provenance at approval time so the filter has something to key on (auto_approvedis set when the approver equals the proposer, i.e. trusted-agent mode).why
when
review.approver_role: trusted-agentis enabled, an agent can approve its own proposals, so a bad calibration run can silently pile up low-quality claims the user never actually reviewed. today there's no way to walk that back short of hand-archiving each one. this gives users a reset button that is precise (only auto-approved claims by default), reversible (archive, not delete), previewable (--dry-run), and fully audited. closes #433.proof
captured from a live run of the shipped cli against a fresh kb in trusted-agent mode — three auto-approved claims cleared, the human-reviewed claim left as
working, oneclaim.bulk_clearaudit event written:what might break
Claimgainsauto_approved: bool = falseandproposed_by: str | none = none. existing claims load fine — the defaults apply — so no migration is required.auto_approved: false, soclaims-clear --auto-onlywill not catch historical auto-approvals; only claims approved after upgrade are flagged. a backfill could be a follow-up.kb.*method + new audit event.kb.clear_claimsjoins the method surface andclaim.bulk_clearis a new audit-log event type. adapters that enumerate methods or parse the audit stream will see both.vep
this touches the surface (new
kb.*method, new on-disk fields, new audit event), which per the template needs an accepted vep first. flagging it — happy to write one up if this should be gated on that before review.tests
tests/test_clear_claims.py, 6 cases: auto-only filter,--beforedate filter, dry-run makes no changes, already-archived skipped,auto_only=falseclears all, audit event shapemake checkpasses locally — the new suite is green, buttest_capabilitiesfails in my env because the embeddings extras aren't installed (pre-existing surface-parity gaps), and mypy/ruff weren't runnable without the venv tooling. needs a clean run before merge.CHANGELOG.mdupdated under## [Unreleased]— not done yet.