RedactionRegistry

Struct RedactionRegistry 

Source
pub struct RedactionRegistry {
    confidence_threshold: f32,
}
Expand description

Server-side PII verification registry and egress guard.

Under Option A, the client performs primary scrubbing. The registry’s role:

  1. Verify: Check that text claimed to be scrubbed has no surviving PII.
  2. Verify manifest: Check consistency between manifest and payload.
  3. Scrub (redact-only): Fallback for server-originated text where client-side scrubbing wasn’t possible. No vault inserts — permanent redaction.

Fields§

§confidence_threshold: f32

Implementations§

Source§

impl RedactionRegistry

Source

pub fn with_defaults(confidence_threshold: f32) -> Self

Create a registry with default detectors and the given confidence threshold.

Source

pub fn default_threshold() -> f32

Default confidence threshold (0.8).

Source

pub fn verify(&self, text: &str, confidence_threshold: f32) -> Vec<PiiViolation>

VERIFY: Check that text claimed to be scrubbed has no surviving PII.

Returns a list of violations (empty = text is clean).

Source

pub fn verify_manifest( &self, payload: &Value, manifest: &RedactionManifest, ) -> Result<(), Vec<ManifestViolation>>

VERIFY MANIFEST: Check that a manifest is consistent with a JSON payload.

Checks:

  • Every span’s placeholder string exists in the serialized payload.
  • Every span whose PII type requires encryption has a matching vault_insert.
Source

pub fn scrub_redact_only(&self, text: &str, threshold: f32) -> ScrubbedText

SCRUB (server-side, redact-only): For server-originated text where client-side scrubbing wasn’t possible.

No vault inserts are produced — these redactions are permanent (no reveal possible). Use this only for server-generated content.

Source

pub fn mark_verified( &self, text: String, manifest: RedactionManifest, ) -> ScrubbedText

Wrap text that has been externally verified as PII-clean into a ScrubbedText.

Use this for text that arrived pre-scrubbed from the client SDK and passed server-side verification (verify + verify_manifest). The registry reference acts as a capability token — you can only produce ScrubbedText if you have access to a registry.

Source

pub fn mark_static_clean(&self, text: String) -> ScrubbedText

Wrap text known to be Cellstate-generated (no user data) as clean.

Use for server-originated text that cannot contain user PII by construction (e.g. error messages, system prompt templates assembled from static strings).

Source

pub fn scrub_payload_redact_only( &self, value: Value, threshold: f32, ) -> ScrubbedPayload

Scrub all string values in a JSON payload (redact-only, no vault inserts).

Source

fn scrub_json_value( &self, value: Value, threshold: f32, spans: &mut Vec<RedactionSpan>, ) -> Value

Recursively scrub string values in a JSON value.

Trait Implementations§

Source§

impl Debug for RedactionRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.