Expand description
Per-item sensitivity model with a uniform policy floor (#212).
Assigns a SensitivityLevel to context items (tool outputs, knowledge
facts, file paths) from path + content signals, and lets a configurable
policy_floor drop or redact anything at/above the floor before it reaches
the model.
Design goals:
- No-op by default. Disabled until
sensitivity.enabled = true(or theLEAN_CTX_SENSITIVITYenv override). Nothing changes for existing users. - Honest classification. Only high-precision signals raise a level:
secret-like paths and detected secrets →
Secret; Luhn-validated card numbers and IBANs →Confidential. No speculative heuristics. - Uniform enforcement. One
enforce_textentry point used at the pre-prompt choke points (tool output, knowledge injection).
Structs§
- Sensitivity
Config - Configuration for the sensitivity policy floor.
Enums§
- Enforced
- Outcome of enforcing the floor on a single text item.
- Floor
Action - What to do when an item meets or exceeds the floor.
- Sensitivity
Level - Ordered sensitivity classification.
Functions§
- classify
- Combined classification: the maximum of path- and content-derived levels.
- classify_
content - Classify free text by content.
- classify_
path - Classify a source path. Secret-like paths (keys,
.env,.ssh/…) →Secret. Everything else staysPublic— path alone is not enough to infer lower confidential levels without guessing. - enforce_
text - Apply the configured floor to a text item (e.g. a tool output).
- floor_
blocks - Decide whether
fact_levelis blocked by the floor. Used for structured items (knowledge facts) where the level is known/stored rather than derived from free text. No-op (never blocked) when disabled.