Repository navigation
feat(quality): pre-write memory quality gate foundation - #748
Open
andreyt2002-droid wants to merge 1 commit into
Open
andreyt2002-droid wants to merge 1 commit into
andreyt2002-droid wants to merge 1 commit into
Conversation
Deterministic, side-effect-free scoring for captured memory sections: - src/memsearch/quality.py: pure UTF-8-safe score_section() with meta-memory, boilerplate, length, repetition, and near-duplicate (shingle Jaccard) penalties returning write/degrade/reject. - [quality_filter] global-only config section (project .memsearch.toml cannot change capture automation policy). - `memsearch quality` CLI: reads a candidate from stdin plus repeatable --recent-file journals, emits a stable JSON verdict, never touches journals or Milvus. - Focused unit/CLI/config tests; docs for the command and config. Foundation for Proposal 002; DSH wiring follows separately after zilliztech#721.
This branch has not been deployed
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.
Summary
Foundation for the pre-write memory quality filter (Proposal 002): a deterministic, fail-open way for capture integrations to score a pending journal section before appending it, so meta-memory noise, ultra-short notes, and near-duplicates stop diluting recall.
src/memsearch/quality.py— purescore_section()(no I/O, no LLM, no shared state). Penalties: meta-memory vocabulary (−25), agent-verbosity boilerplate (−10), belowmin_content_lengthafter normalization (−30), token repetition ratio > 0.6 (−20), near-duplicate of a recent section (shingle Jaccard > 0.8, −40). Returnswrite/degrade/rejectwith score and reasons. Normalization is UTF-8 replacement-safe for lone surrogates so verdicts never crash on console-captured text.[quality_filter]config section (enabled,min_content_length,degrade_threshold,reject_threshold) — global-only by design: project.memsearch.tomlstays restricted to low-risk indexing keys and cannot change capture automation policy.memsearch qualityCLI — side-effect free: reads the candidate from stdin plus repeatable--recent-filejournals (current + prior day covers the 48h duplicate window), emits a stable JSON verdict; never writes a journal or opens Milvus. Designed so plugins call it via direct argv/stdin without a shell.docs/cli.md(command + config keys),docs/home/configuration.md(section explaining thresholds and global-only placement).Testing
tests/test_quality.py— each penalty rule, exact threshold boundaries, Jaccard strictly > 0.8, disabled filter preserves writes, surrogate/anchor normalization, invalid threshold order rejected.tests/test_cli_quality.py— JSON verdict stability,--recent-fileduplicate detection, empty-stdin error goes to stderr with nonzero exit.tests/test_config.py— defaults and project-config cannot alter quality policy.mkdocs build --strictpasses.Scope / follow-up
Core + CLI only — deliberately no
plugins/wiring in this PR to keep it independent of the open Windows-runtime PR #721. DSH integration (post-summary gate beforewriteCapture(),quality:<score>anchor tag for degraded writes) follows as a small separate PR on top of merged #721.