feat(sensitivity): add sensitivity tagging with pattern-based auto-classification#85
Merged
Merged
Conversation
…assification - New pkg/sensitivity with Classifier, Level enum (None/PII/InternalIP/Credentials) - Built-in patterns: email, phone, credit card, SSN, AWS keys, OpenAI keys, GitHub tokens, Slack tokens, generic secrets - Configurable internal domain detection (.internal, .corp, .local) - StoreEntry accepts Sensitivity (explicit) and AutoClassify (pattern-based) - RecallResult includes MaxSensitivity and SensitiveChunks metadata - Sensitivity stored in SQLite, does not affect dedup or ranking - 17 classifier tests + 4 benchmarks (all <1ms) - 7 memory integration tests for sensitivity propagation Closes #82 Co-authored-by: Ona <[email protected]>
0ad00dd to
21b850b
Compare
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
Adds a sensitivity classification layer to Distill's memory store. When context is stored or retrieved, Distill classifies it and returns sensitivity metadata alongside the content.
Why
Distill sits at the right point in the pipeline to detect sensitive content before it reaches the model. When an agent retrieves memory and then calls an external tool, there's no signal about what the context contains. This PR adds that signal — callers can use
max_sensitivityto make authorization decisions before dispatching tool calls.Changes
New package:
pkg/sensitivityLevelenum:None(0),PII(1),InternalIP(2),Credentials(3)Classifierwith built-in detection for:AKIA...), OpenAI keys (sk-...), GitHub tokens (ghp_...), Slack tokens (xox...), genericpassword=/secret=patterns.internal,.corp,.local)Classify(text)andClassifyBatch(texts)methodsMemory integration
StoreEntry.Sensitivity— explicit tag at write timeStoreEntry.AutoClassify— triggers pattern-based classification on writeRecallResult.MaxSensitivity— highest level across all returned memoriesRecallResult.SensitiveChunks— which memories triggered itRecalledMemory.Sensitivity— per-entry sensitivity levelTests
Usage
Closes #82