Documentation
¶
Overview ¶
Package secret masks credentials in text before it is written to the vault.
It started in internal/ingest, where a transcript is someone else's agent talking to a shell and routinely carries a pasted API key. But an agent writing a checkpoint, a working note or a memory pastes the same keys — "verified: the upload works with GITHUB_TOKEN=ghp_…" — and those paths went to the vault verbatim (#209). It is a leaf package so session and memory can use it without importing ingest, which imports them.
Two strengths, because the two kinds of text differ. A transcript is mostly machine output nobody chose to keep, so ingest also masks anything that merely looks random (MaskAll). An agent's own write is prose it chose, full of long mixed-case words — test names, module paths, identifiers with digits in them — that the entropy check can take for a key (#210 spares the plainest of them, not all) and that are the whole content of a verified line; there only a known credential shape is masked (Mask).
Index ¶
Constants ¶
const Marker = "[REDACTED]"
Marker replaces what was masked.
const PrivateMarker = "[private]"
PrivateMarker replaces a <private>…</private> span.
Variables ¶
This section is empty.
Functions ¶
func NothingLeft ¶ added in v0.5.3
NothingLeft says whether text once masked says nothing at all: only markers and punctuation. A memory or a note that was a pasted key or a span the person marked private is refused, not kept as "[REDACTED]" or "[private]" — a record that says nothing, ranked and recalled like one that does.
Types ¶
type Redaction ¶
type Redaction struct {
Field string // field the token was found in ("Commands", "Verified", ...)
Reason string // why it matched
}
Redaction records one secret-shaped token that was masked, so the caller can announce it instead of leaving the fix invisible.
func KeptPrivate ¶ added in v0.5.3
KeptPrivate is n spans' Redactions, for a caller that stripped them where the text was read and reports them where it is written: a transcript loses its spans as it is parsed, long before the record built from it has a receipt.
func Mask ¶
Mask masks every substring of s that has a known credential shape. For text an agent chose to write: see the package comment for why it leaves high-entropy words alone. field is carried through only for the report.
func MaskAll ¶
MaskAll is Mask plus any token that looks random enough to be a credential with no recognisable shape. For transcript text.
func StripPrivate ¶ added in v0.5.3
StripPrivate replaces every <private> span in s with PrivateMarker and reports one Redaction per span.
The person marks what they never want kept; that is a promise about every path text takes into Logos — a hook's prompt, a transcript read for harvest or distil, an import, a note — so this is applied where text enters, not where one writer happens to remember it.
Spans nest: a lazy match closed the outer span at the inner one's end and kept what the person wrote after it. One that is never closed runs to the end: a hook keeps a prompt cut to 160 characters, and the text after an opened span is the person's private text until it is shown not to be.