audit

package
v0.40.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func Log(logger *slog.Logger, e Entry)

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)
	OutcomeDeniedUnauthorized Outcome = "denied_unauthorized" // denied: no authorization bit
	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.

const (
	SourceRemote  Source = "remote"  // a remote inbound answer (the answering device/connection)
	SourceTimeout Source = "timeout" // the daemon's own internal safe-deny on timeout
	SourceLocal   Source = "local"   // resolved at the desktop TTY (ADR 025 §4 first-answer-wins; #706)
)

Jump to

Keyboard shortcuts

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