Skip to content

feat(scripts): audit-bd-memories — near-duplicate + retired-surface scanner (soc-lgq4 #memory-audit)#377

Open
boshu2 wants to merge 2 commits into
mainfrom
feat/bd-memories-audit-soc-lgq4
Open

feat(scripts): audit-bd-memories — near-duplicate + retired-surface scanner (soc-lgq4 #memory-audit)#377
boshu2 wants to merge 2 commits into
mainfrom
feat/bd-memories-audit-soc-lgq4

Conversation

@boshu2
Copy link
Copy Markdown
Owner

@boshu2 boshu2 commented May 20, 2026

Why

154+ bd memories as of 2026-05-20. Without curation, recall quality degrades — same lesson stored multiple ways, and old lessons reference surfaces that have been retired (Ollama, shepherd-cron, gemma pipelines, etc.). No existing tool surfaces these candidates.

What

scripts/audit-bd-memories.sh — pure-shell audit that:

  1. Parses bd memories output (text, not JSON — bd memories doesn't support --json today).
  2. For each pair of memories, computes Jaccard similarity on lowercase word-token sets. Pairs >= threshold (default 0.65) flagged as near-duplicates.
  3. Scans each memory body for retired-surface keywords (default: ollama,shepherd-cron,openclaw,gemma,morai-codex,d:\\dream,dreamworker; override with --retired <csv>).
  4. Emits a markdown report at .agents/audits/bd-memories-<date>.md with Summary, Near-duplicates, and Retired-surface-candidates sections.

Does NOT auto-delete. Operator reviews and selectively runs bd forget <key>.

Flags: --threshold <0..1> --out <path> --stdout --retired <csv> --no-retired --no-dups --json

Test

11 bats tests, all passing. Cover: empty corpus, count parsing on 4-memory fixture, default file-write path, --stdout, near-dup detection, threshold sensitivity (0.99 rejects 0.75 jaccard), --no-dups / --no-retired suppression, --retired override, unknown-flag error, missing-bd-binary error. Stubs bd via PATH for deterministic test input.

Live signal

Smoke-run against this repo's real bd memories (154 memories) detected 3 near-duplicate pairs and 23 retired-surface mentions — actionable backlog for the next memory-curation pass.

Performance

154 memories × pairwise = ~12k Jaccard computations. Wall-clock ~3 min on this box. Acceptable for an audit; not in any hot path.

Closes-scenario: soc-lgq4#memory-audit
Bounded-context: BC1-Corpus
Evidence: scripts/audit-bd-memories.sh
Evidence: tests/scripts/audit-bd-memories.bats

@github-actions github-actions Bot added the tests label May 20, 2026
@boshu2 boshu2 enabled auto-merge (squash) May 20, 2026 22:10
@boshu2 boshu2 force-pushed the feat/bd-memories-audit-soc-lgq4 branch 2 times, most recently from fbf987a to 086329e Compare May 20, 2026 22:23
…canner (soc-lgq4 #memory-audit)

154+ bd memories accumulating. This script computes pairwise Jaccard on content tokens (default threshold 0.65) and scans for retired-surface keywords. Emits markdown report at .agents/audits/bd-memories-<date>.md; does not auto-delete (operator runs bd forget selectively).

Flags: --threshold --out --stdout --retired --no-retired --no-dups --json. Pure shell + awk; bd stubbed in tests for determinism.

Smoke against real memories surfaced 3 near-dup pairs + 23 retired-surface mentions.

Closes-scenario: soc-lgq4#memory-audit
Bounded-context: BC1-Corpus
Evidence: scripts/audit-bd-memories.sh
Evidence: tests/scripts/audit-bd-memories.bats
@boshu2 boshu2 force-pushed the feat/bd-memories-audit-soc-lgq4 branch from 086329e to 290a0ea Compare May 20, 2026 22:48
@boshu2 boshu2 added the parked Parked PR — actively deferred, will return after upstream work lands label May 21, 2026
@boshu2
Copy link
Copy Markdown
Owner Author

boshu2 commented May 21, 2026

Parking pending soc-g2qd (/evolve --mode=loop epic). Both this PR's surface and the epic touch overlapping infrastructure; resolving the upstream contract first avoids rebase churn. Will rebase + resume after epic ships.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parked Parked PR — actively deferred, will return after upstream work lands tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant