Skip to content

feat: KB quality management — reinforce, prune, quality report - #26

Merged
ShadowSlayer08 merged 1 commit into
masterfrom
feat/kb-quality
Sep 25, 2026
Merged

ShadowSlayer08 merged 1 commit into
masterfrom
feat/kb-quality

Conversation

@ShadowSlayer08

Copy link
Copy Markdown
Owner

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

  • RedTeamKB gains:
    • get(collection, doc_id) — fetch one doc.
    • record_success(doc_id) — bump success_count + stamp last_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 missing created_at is 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.
  • The dynamic grow loop now reinforces a repeat win (record_success on the near-duplicate) instead of dropping it on the floor; new wins are stamped success_count=1 + created_at/last_used; DynamicRedTeamer tracks grown vs reinforced (both 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).

Tests

tests/test_kb_quality.py (+9, offline lexical mode, injected timestamps): get, record_success bump+stamp, prune targets only dynamic-wins / keeps proven / by-age / requires-both / missing-created_at safe / no-criteria no-op, and quality_report. A falsy-zero timestamp bug (if created treating created_at==0.0 as missing) was caught by these tests and fixed (is not None).

Full suite: 1947 passed, 1 skipped.

🤖 Generated with Claude Code

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>
@ShadowSlayer08
ShadowSlayer08 merged commit 10fbe81 into master Sep 25, 2026
6 checks passed
@ShadowSlayer08
ShadowSlayer08 deleted the feat/kb-quality branch September 25, 2026 01:40
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.

1 participant