cayu.vaults.redaction
Public Cayu API. Definitions are grouped by their public source module, and definitions from private implementation modules appear on their package’s page; adding a symbol does not move existing links. The import shown at each entry is a supported public namespace. Read the Python API overview and install the required extra.
contains_redacted_secret
Section titled “contains_redacted_secret”from cayu.vaults import contains_redacted_secretReturn whether JSON-compatible data contains the durable redaction marker.
contains_redacted_secret(value: Any) -> boolRelease source · Runtime guarantees · Capability guides
REDACTED_SECRET
Section titled “REDACTED_SECRET”from cayu.vaults import REDACTED_SECRETREDACTED_SECRET = '[REDACTED_SECRET]'Release source · Runtime guarantees · Capability guides
SecretRedactionCapacityError
Section titled “SecretRedactionCapacityError”from cayu.vaults import SecretRedactionCapacityErrorRaised before unresolved streaming-redaction state exceeds its bound.
Bases: RuntimeError.
init (method)
Section titled “init (method)”SecretRedactionCapacityError.__init__(*, released: bytes=b'') -> NoneRelease source · Runtime guarantees · Capability guides
SecretRedactionStream
Section titled “SecretRedactionStream”from cayu.vaults import SecretRedactionStreamRedact registered secrets before releasing ordered byte fragments.
A suffix that may begin either a secret or the public marker remains
private until a later fragment makes it decidable. Callers must distinguish
a proven normal EOF from uncertain abandonment: finish_complete may
release an unmatched suffix, while abort discards it.
init (method)
Section titled “init (method)”SecretRedactionStream.__init__(redactor: SecretRedactor, *, max_retained_bytes: int | None=None) -> Nonefeed (method)
Section titled “feed (method)”SecretRedactionStream.feed(chunk: bytes) -> bytesfinish_complete (method)
Section titled “finish_complete (method)”SecretRedactionStream.finish_complete() -> bytesFinish after proven EOF and release the final unmatched suffix.
abort (method)
Section titled “abort (method)”SecretRedactionStream.abort() -> boolSeal an incomplete stream and report whether raw bytes were discarded.
Release source · Runtime guarantees · Capability guides
SecretRedactionTail
Section titled “SecretRedactionTail”from cayu.vaults import SecretRedactionTailRetain a marker-safe bounded tail from an incrementally redacted source.
init (method)
Section titled “init (method)”SecretRedactionTail.__init__(redactor: SecretRedactor, *, max_bytes: int) -> Nonefeed (method)
Section titled “feed (method)”SecretRedactionTail.feed(chunk: bytes) -> Nonefinish_complete (method)
Section titled “finish_complete (method)”SecretRedactionTail.finish_complete() -> Noneabort (method)
Section titled “abort (method)”SecretRedactionTail.abort() -> Nonetext (method)
Section titled “text (method)”SecretRedactionTail.text() -> strRelease source · Runtime guarantees · Capability guides
SecretRedactor
Section titled “SecretRedactor”from cayu.vaults import SecretRedactorRedacts known resolved secret values from strings and JSON-like data.
init (method)
Section titled “init (method)”SecretRedactor.__init__(secrets: str | SecretStr | ResolvedSecret | Sequence[str | SecretStr | ResolvedSecret] | None=None) -> Nonehas_values (property)
Section titled “has_values (property)”SecretRedactor.has_values() -> boolmax_secret_utf8_bytes (property)
Section titled “max_secret_utf8_bytes (property)”SecretRedactor.max_secret_utf8_bytes() -> intReturn the bounded overlap needed to redact across a byte boundary.
pagination_overlap_utf8_bytes (property)
Section titled “pagination_overlap_utf8_bytes (property)”SecretRedactor.pagination_overlap_utf8_bytes() -> intReturn source overlap needed for source-position-aware page redaction.
with_secret (method)
Section titled “with_secret (method)”SecretRedactor.with_secret(secret: str | SecretStr | ResolvedSecret) -> SecretRedactormerged_with (method)
Section titled “merged_with (method)”SecretRedactor.merged_with(other: SecretRedactor) -> SecretRedactorCombine two registries without exposing either registry’s values.
with_python_repr_forms (method)
Section titled “with_python_repr_forms (method)”SecretRedactor.with_python_repr_forms() -> SecretRedactorAlso match each secret in the escaped forms Python text commonly uses.
Exception messages quote values with repr (an OSError filename,
a KeyError key, f"{path!r}" inside another repr), ascii,
repr of the UTF-8 bytes, or json.dumps. Each form turns a
newline into \n, a backslash into \\ and so on. Forms equal
to the secret itself are not added.
redact_cut_text (method)
Section titled “redact_cut_text (method)”SecretRedactor.redact_cut_text(value: str, *, cut_head: bool=False, cut_tail: bool=False) -> strRedact text cut from a longer source, dropping what a cut may have split.
Everything that starts within the longest secret’s length of a cut edge is discarded, redactions included, by position in value. A secret split by the cut, and any shorter secret nested inside it, therefore leave no visible remainder.
has_same_registry (method)
Section titled “has_same_registry (method)”SecretRedactor.has_same_registry(other: SecretRedactor) -> boolCompare registries without exposing their secret values.
is_exact_secret (method)
Section titled “is_exact_secret (method)”SecretRedactor.is_exact_secret(value: str) -> boolReturn whether value exactly equals one registered secret.
contains_secret_bytes (method)
Section titled “contains_secret_bytes (method)”SecretRedactor.contains_secret_bytes(value: bytes) -> boolReturn whether raw bytes contain any registered non-marker secret.
redact_uppercase_text (method)
Section titled “redact_uppercase_text (method)”SecretRedactor.redact_uppercase_text(value: str) -> strRedact text against uppercase-normalized registered secret values.
redact_stripped_text (method)
Section titled “redact_stripped_text (method)”SecretRedactor.redact_stripped_text(value: str) -> strRedact text against whitespace-trimmed registered secret values.
redact_text (method)
Section titled “redact_text (method)”SecretRedactor.redact_text(value: str) -> strredact_text_bounded (method)
Section titled “redact_text_bounded (method)”SecretRedactor.redact_text_bounded(value: str, *, max_bytes: int) -> strRedact a diagnostic string before applying its UTF-8 byte bound.
redact_text_bounded_with_marker (method)
Section titled “redact_text_bounded_with_marker (method)”SecretRedactor.redact_text_bounded_with_marker(value: str, *, max_bytes: int, truncation_marker: str) -> tuple[str, bool]Redact complete text, then append an atomic marker when it is shortened.
redact_text_head (method)
Section titled “redact_text_head (method)”SecretRedactor.redact_text_head(value: str, *, max_bytes: int) -> tuple[str, bool]Redact a complete string, then return its marker-safe bounded head.
redact_utf8_head (method)
Section titled “redact_utf8_head (method)”SecretRedactor.redact_utf8_head(value: bytes, *, max_bytes: int, source_complete: bool) -> tuple[str, bool]Project a possibly incomplete UTF-8 source prefix without exposing its suffix.
source_complete=False means the caller did not observe authoritative
EOF. The streaming redactor therefore discards every suffix whose safety
could depend on unavailable bytes instead of treating the captured prefix
as a complete value. Bytes buffered by the incremental UTF-8 decoder are
likewise withheld and reported as truncation.
redact_bytes_head (method)
Section titled “redact_bytes_head (method)”SecretRedactor.redact_bytes_head(value: bytes, *, max_bytes: int, source_complete: bool) -> tuple[bytes, bool]Project a possibly incomplete binary prefix without exposing its suffix.
redact_utf8_page (method)
Section titled “redact_utf8_page (method)”SecretRedactor.redact_utf8_page(value: bytes, *, window_offset: int, page_offset: int, page_end: int, max_bytes: int, source_complete: bool) -> tuple[str, bool]Project one raw-source page without exposing cross-page secret fragments.
redact_utf8_page_with_progress (method)
Section titled “redact_utf8_page_with_progress (method)”SecretRedactor.redact_utf8_page_with_progress(value: bytes, *, window_offset: int, page_offset: int, page_end: int, total_bytes: int, max_bytes: int) -> tuple[str, int]Return a framed text page and the exact next stored-byte position.
Unlike prefix capture, this operation requires lookbehind and lookahead proving the page’s redaction context. It never splits an atomic redaction span or advances past output omitted by the byte bound. A source span or replacement that cannot fit raises ValueError rather than losing text.
redact_bytes_page (method)
Section titled “redact_bytes_page (method)”SecretRedactor.redact_bytes_page(value: bytes, *, window_offset: int, page_offset: int, page_end: int, max_bytes: int, source_complete: bool) -> tuple[bytes, bool]Project one raw-source byte page without exposing cross-page fragments.
stream_bytes (method)
Section titled “stream_bytes (method)”SecretRedactor.stream_bytes(*, max_retained_bytes: int | None=None) -> SecretRedactionStreamCreate an ordered byte-stream redactor for this registry.
max_retained_bytes bounds source bytes whose final redaction is
still dependent on future input. Exceeding the bound fails closed
before the unresolved source is published.
redact_json (method)
Section titled “redact_json (method)”SecretRedactor.redact_json(value: Any) -> Anyredact_json_values (method)
Section titled “redact_json_values (method)”SecretRedactor.redact_json_values(value: Any, *, preserve_string_fields: Collection[str]=()) -> AnyRedact JSON string values without rewriting protocol object keys.
require_no_secret_keys (method)
Section titled “require_no_secret_keys (method)”SecretRedactor.require_no_secret_keys(value: Any, *, field_name: str='value', preserve_keys: Collection[str]=(), untrusted_container_keys: Collection[str]=(), match_short_substrings: bool=False) -> NoneFail closed when a known secret occurs in an untyped JSON object key.