Skip to main content

Module sensitivity

Module sensitivity 

Source
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 the LEAN_CTX_SENSITIVITY env 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_text entry point used at the pre-prompt choke points (tool output, knowledge injection).

Structs§

SensitivityConfig
Configuration for the sensitivity policy floor.

Enums§

Enforced
Outcome of enforcing the floor on a single text item.
FloorAction
What to do when an item meets or exceeds the floor.
SensitivityLevel
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 stays Public — 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_level is 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.