feat(guard): minimum term overlap before preflight injects a memory - #255
Merged
Conversation
…a memory The turn preflight injected the top-ranked note on ANY score > 0, so a one-word prompt like 'retry' pulled an entirely unrelated note into every session (observed fleet-wide; ranked 'best' is not the same as relevant). - retrieve.matched_terms(): distinct stemmed task-term overlap, sharing _tokens with overlap_score so 'matched' means the same thing everywhere - retrieve.preflight_min_terms(): threshold, default 2, env-overridable via OMIND_PREFLIGHT_MIN_TERMS (0 disables the filter) - guard.preflight_turn(): a weak match is treated like a miss — no injection, gate auto-clears (honors OMI_GATE_MISS_STRICT), logged as omi-gate-weak-match Ratio scores cannot gate this (a one-term task trivially scores 1.0), hence an absolute match count. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XRHMqf9JLj1P6Gbb9XpFsh
|
Important Review available on request
Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 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 |
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.
Problem
The proactive turn preflight injects the top-ranked vault note on any score > 0. A one-word prompt ("retry") reliably pulled an unrelated note (the Ghidra retry-budget memory) into every session, fleet-wide — top-ranked is not the same as relevant.
Fix
retrieve.matched_terms(task, text)— distinct stemmed task-term overlap; shares_tokenswithoverlap_scoreso relevance vocabulary stays unified.retrieve.preflight_min_terms()— injection threshold, default 2, overridable viaOMIND_PREFLIGHT_MIN_TERMS(0restores legacy always-inject).guard.preflight_turn()— a weak match now behaves exactly like a miss: nothing injected, consult gate auto-clears (honorsOMI_GATE_MISS_STRICT=1), compliance-logged underomi-gate-weak-match.An absolute count is used deliberately: recall-ratio scores can't gate this (a one-term task trivially scores 1.0 against any note containing the word).
Gate-deny suggestions are unchanged — naming the best candidate on a block is still right even at one shared word; this only stops unsolicited per-turn injection.
Validation
ruff check+ruff formatclean,mypy --strictclean on touched sourcesProudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/
🤖 Generated with Claude Code
https://claude.ai/code/session_01XRHMqf9JLj1P6Gbb9XpFsh