secret

package
v0.5.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

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

View Source
const Marker = "[REDACTED]"

Marker replaces what was masked.

View Source
const PrivateMarker = "[private]"

PrivateMarker replaces a <private>…</private> span.

Variables

This section is empty.

Functions

func NothingLeft added in v0.5.3

func NothingLeft(s string) bool

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.

func Summary

func Summary(found []Redaction) string

Summary is the sentence a receipt carries when something was masked, or "" when nothing was. It names where and why, never the value: an agent that pasted a key and is told only "saved" goes on believing the key is in the vault, or never learns it pasted one at all.

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

func KeptPrivate(field string, n int) []Redaction

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

func Mask(field, s string) (string, []Redaction)

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

func MaskAll(field, s string) (string, []Redaction)

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

func StripPrivate(field, s string) (string, []Redaction)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL