Repository navigation
feat: KB quality management — reinforce, prune, quality report - #26
Merged
Merged
Conversation
Make the self-growing KB (--evolve) curate itself instead of only appending. - RedTeamKB gains get(), record_success() (bump success_count + stamp last_used), prune() (remove grown 'dynamic-win' patterns that are stale and/or weak — static seeds and proven/undated patterns are never pruned), and quality_report() (origin mix, reinforcement count, staleness, top wins). - The dynamic grow loop now REINFORCES a repeat win (record_success on the near-duplicate) instead of dropping it; new wins are stamped success_count=1 + created_at/last_used; DynamicRedTeamer tracks grown vs reinforced (shown in the "KB grew" line). - CLI: --kb-prune [--kb-prune-max-age-days N] [--kb-prune-min-success K]; --kb-stats now prints a quality snapshot (grown wins / reinforced / avg success / stale >30d). Recovers the second feature lost with the deleted background-task branch (see #24/#25). +9 tests (tests/test_kb_quality.py). Full suite: 1947 passed, 1 skipped. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Make the self-growing knowledge base (
--evolve) curate itself instead of only appending. This recovers the second feature lost with the deleted background-task branch (the first, the reporter fix, was #24; ArtPrompt was #25).How
RedTeamKBgains:get(collection, doc_id)— fetch one doc.record_success(doc_id)— bumpsuccess_count+ stamplast_used.prune(collection, max_age_days=, min_success=)— remove grown (origin == 'dynamic-win') patterns that are stale and/or weak. Static seeds are never pruned; a grown doc missingcreated_atis never age-pruned; with both criteria a doc must be both stale AND weak; with neither, it's a no-op.quality_report(collection)— origin mix, reinforcement count, avg success, stale-over-30d, top wins.record_successon the near-duplicate) instead of dropping it on the floor; new wins are stampedsuccess_count=1+created_at/last_used;DynamicRedTeamertracksgrownvsreinforced(both shown in the "KB grew" line).--kb-prune [--kb-prune-max-age-days N] [--kb-prune-min-success K];--kb-statsnow prints a quality snapshot (grown wins / reinforced / avg success / stale >30d).Tests
tests/test_kb_quality.py(+9, offline lexical mode, injected timestamps):get,record_successbump+stamp, prune targets only dynamic-wins / keeps proven / by-age / requires-both / missing-created_atsafe / no-criteria no-op, andquality_report. A falsy-zero timestamp bug (if createdtreatingcreated_at==0.0as missing) was caught by these tests and fixed (is not None).Full suite: 1947 passed, 1 skipped.
🤖 Generated with Claude Code