feat(claims): bulk clear for auto-approved claims (#433)#434
Conversation
|
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 |
303ef12 to
fae7d0d
Compare
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
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.
fae7d0d to
0321c13
Compare
the bulk-clear feature landed with three ruff violations in the `claims-clear` cli handler (B904 missing `raise ... from`, E501 long line, SIM102 nested `if`) and an unused `claim2` binding in the test (F841), plus stale committed schemas — the additive `auto_approved` / `proposed_by` claim fields and the `delete` proposal kind weren't reflected in `schemas/`. regenerate via `scripts/gen_schemas.py` and clear the lint errors so the ci lint/type/drift gates pass.
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.