DEFAULT_POLICY#
- scikitplot.cleanprompt.DEFAULT_POLICY = RedactionPolicy(kinds=None, allow=(), tag_style=TagStyle(prefix='[', suffix=']', separator='-', uppercase_kind=True, style='placeholder', surrogates=None), overlap=<OverlapStrategy.LONGEST_WINS: 'LONGEST_WINS'>, limits=Limits(max_input_chars=1000000, max_spans=100000, max_entries=50000, max_literal_terms=10000, max_literal_length=4096), case_insensitive=False, min_confidence=0.0, preserve_placeholders=True)[source]#
Complete, declarative configuration for a redaction pass.
- Parameters:
- kindstuple of str, optional
Categories to detect, naming entries of the pattern library.
Nonemeans “every pattern enabled by default”.- tag_styleTagStyle, optional
Placeholder grammar. Defaults to
DEFAULT_TAG_STYLE.- overlapOverlapStrategy, default=OverlapStrategy.LONGEST_WINS
Arbitration rule for overlapping detections.
- limitsLimits, optional
Hard bounds. Defaults to
DEFAULT_LIMITS.- case_insensitivebool, default=False
Whether two surfaces that differ only in case share one label.
- min_confidencefloat, default=0.0
Detections below this confidence are discarded before resolution.
- allowtuple of str, default=()
Surfaces that must never be redacted, compared exactly against a detection’s own text. An allowlist is the necessary complement to a denylist: without it the only way to stop a false positive is to disable the whole pattern, which silently removes cover for everything else that pattern would have caught.
- preserve_placeholdersbool, default=True
Whether text already matching the placeholder grammar is protected from re-detection, making redaction idempotent.
- Raises:
- PolicyError
If
kindsis empty, contains a non-string or a duplicate, or ifmin_confidenceis outside[0.0, 1.0].
Notes
User notes.
case_insensitive=Trueis the right choice for names that appear in mixed case (“Acme” and “ACME” become one label). Leave it off for identifiers where case is meaningful, such as API keys.Developer notes.
preserve_placeholdersis what gives invariant I7. Before detection runs, the engine finds every substring matching the active placeholder grammar and treats those ranges as reserved; detectors may still report spans there, but resolution drops them. Without this, feeding an already-redacted text back through the pipeline lets a detector tag the inside of a placeholder and destroy it — which is the reproduced upstream defectCP-006.Examples
>>> policy = DEFAULT_POLICY.evolve(case_insensitive=True) >>> policy.case_insensitive True >>> policy is DEFAULT_POLICY False >>> len(policy.fingerprint) 16
Gallery examples#
Cleanprompt Advanced: Invariants, Encryption, and the Lossy Model Hop
Cleanprompt Moderate: Policies, Entities, and the Vault’s Lifecycle
Cleanprompt from Python: Single Calls and Edge Cases