Documentation
¶
Overview ¶
Package audit is the forensic sink for remote-permission decisions: it writes exactly one structured record per decision the modal control loop (#703) resolves — which device, which modal, what outcome, from where.
SECURITY: an Entry carries ONLY non-secret identity. It has no field that can hold a plain device token or any other secret (honoring the internal/devices SECURITY contract): the device is identified by its SHA-256 hash and/or label, never the plain token. The package imports only log/slog — it never imports internal/devices, so it cannot reach a plain token. The writer emits a fixed attribute set; a future edit that adds a secret-bearing field is caught by the no-leak test in audit_test.go.
The sink is write-only and local (ADR 025 §6 "Audit"): it reads nothing from the network and never emits to the wire. It is decoupled from the authorization gate (#702) — Log records the already-decided Outcome and never consults the gate or re-derives the decision.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Log ¶
Log writes exactly one structured audit record for a resolved remote-permission decision. It records the already-decided Entry verbatim — it does NOT consult the gate, re-derive the outcome, or touch any token. A nil logger defaults to slog.Default() (matching the repo's optional-logger convention); the write never panics. Emitted at slog.Info; the slog record's automatic timestamp satisfies ADR 025 §6's "time" requirement.
Types ¶
type Entry ¶
type Entry struct {
DeviceHash string // device.TokenHash (SHA-256 hex); "" for a no-device timeout
DeviceLabel string // device.Name
ModalID string // protocol.ModalShownPayload.ModalID — the one-time nonce (#701)
ModalClass string // protocol.ModalShownPayload.Class — e.g. "permission" (ADR 025 §6 "class")
// ConversationID and Target scope a decision that is ABOUT SOMETHING rather
// than about a one-time prompt, and they arrived together in #2420 with the
// per-device MCP actuation gate — the first decision family that has to name
// three things (which conversation, which server, what kind) where ModalID and
// ModalClass offer two slots.
//
// Adding them departs from the precedent #1986 and #2127 set, and deliberately:
// that precedent's own reasoning is that the id/class pair "already says which
// batch and what kind", which is exactly what stops being true here. The
// alternative it forbids is the one not taken — pairingMinterV2.auditMint
// records that filling ModalID with a different KIND of value puts a value in a
// field an operator reads as one thing, and a conversation id is not a one-time
// nonce. Both fields are empty at every caller that has nothing for them, which
// is that same precedent honored rather than broken.
//
// ConversationID is DAEMON-OWNED: it comes from the registry record the decision
// resolved, never from the asking frame.
ConversationID string
// Target is the object the decision was about, AS THE ASKING DEVICE NAMED IT —
// so unlike every other field here it is REMOTE-AUTHORED, validated only by
// whatever decision recorded it, and a caller MUST bound it before it arrives
// (cmd/pyry's truncateForLog is the in-tree helper; its own block carries the
// padding threat). It is not identity, it is never a secret, and it must never
// have been used as a path component to get here.
//
// It is recorded as asked rather than as resolved on purpose: a record saying a
// device was refused "something" is not forensically useful, and on a refusal
// there IS no resolved value to substitute.
Target string
Outcome Outcome // the self-contained decision classification (below)
Source Source // where the decision originated (mirrors the wire set)
}
Entry is one resolved remote-permission decision to be recorded. It carries ONLY non-secret identity: the device's TokenHash / Name (NEVER the plain token — the struct has no field that could hold one), the one-time modal nonce, the modal class, the resolved outcome, and where the decision originated. It is constructed in-process by #703 and never decoded from the network.
type Outcome ¶
type Outcome string
Outcome is the security classification of a resolved remote-permission decision. Self-contained per this ticket (#712); #703 maps devices.RemotePermissionOutcome + eligibility onto it. String-backed so the serialized audit record is stable and human-readable regardless of constant order.
const ( OutcomeAllowed Outcome = "allowed" // eligible device + explicit allow (the sole grant) OutcomeDeniedTimeout Outcome = "denied_timeout" // denied: deny-on-timeout window elapsed OutcomeCancelled Outcome = "cancelled" // phone cancelled / dismissed (ESC) OutcomeDenied Outcome = "denied" // authorized phone explicitly chose a deny option OutcomeDismissedLocal Outcome = "dismissed_local" // resolved at the desktop TTY; the picked choice is not observable by the daemon (#706) )
type Source ¶
type Source string
Source is where the decision originated. The value set deliberately mirrors protocol.ModalDismissedPayload.Source's documented closed set {remote, local, timeout}, so #703 passes ONE source value to both the wire dismissal and this audit entry — no second, divergent source vocabulary.