Documentation
¶
Overview ¶
Package daemon assembles the agent-receipts-daemon's components — chain state, key source, receipt store, frame socket — into a single Run entrypoint. cmd/agent-receipts-daemon/main.go wraps Run with flag/env parsing and signal handling.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultDBPath ¶
func DefaultDBPath() string
DefaultDBPath returns the per-user SQLite path used when AGENTRECEIPTS_DB is not set. Uses XDG_DATA_HOME (defaults to ~/.local/share on Linux/macOS).
func DefaultKeyPath ¶
func DefaultKeyPath() string
DefaultKeyPath returns the per-user signing-key path used when AGENTRECEIPTS_KEY is not set. Uses XDG_DATA_HOME (defaults to ~/.local/share on Linux/macOS).
func DefaultPublicKeyPath ¶
DefaultPublicKeyPath returns the default published public-key path: the same directory as keyPath with the suffix ".pub". Empty when keyPath is empty so cmd/main.go can surface a clearer "Config.KeyPath is required" error from validateConfig instead of a less-helpful PublicKeyPath one.
func DefaultSocketPath ¶
func DefaultSocketPath() string
DefaultSocketPath returns the per-OS default socket path. Phase 1 resolves Q1 of issue #236:
- macOS: $TMPDIR/agentreceipts/events.sock — per-user, unprivileged.
- Linux with $XDG_RUNTIME_DIR set: $XDG_RUNTIME_DIR/agentreceipts/ events.sock — per-user, unprivileged.
- Linux fallback (no $XDG_RUNTIME_DIR): /run/agentreceipts/events.sock — this is the system-install path and requires privileged directory creation/write. Unprivileged users on systems without $XDG_RUNTIME_DIR should set AGENTRECEIPTS_SOCKET explicitly.
- Other platforms: empty string (the daemon refuses to start outside Linux/macOS, see Run).
func GenerateKey ¶
GenerateKey creates a new Ed25519 key pair and saves the private key to keyPath (mode 0600) and public key to publicKeyPath (mode 0644). Refuses to overwrite an existing file at either path, and refuses to follow a symlink at either path. Use this explicitly via --init; never call it as a side-effect of starting the daemon — silently regenerating a missing key would invalidate every receipt previously signed by the operator's real key.
Atomicity: both files are created with O_CREATE|O_EXCL|O_NOFOLLOW so an attacker who plants a symlink (or any other dirent) at either path between the directory creation and the file open trips O_EXCL — we never write through the symlink target. If the public-key write fails after the private-key write succeeded, the private-key file is removed so the caller doesn't end up with a half-initialised on-disk state.
The mode passed to OpenFile may be narrowed by the process umask; an explicit fchmod after open ensures the on-disk mode matches what the caller asked for.
Types ¶
type Config ¶
type Config struct {
// SocketPath is the Unix-domain socket the daemon listens on.
SocketPath string
// DBPath is the SQLite receipt-store path.
DBPath string
// KeyPath is the PEM-encoded Ed25519 private key path. Mode must be 0600.
KeyPath string
// PublicKeyPath is where the daemon publishes the matching SPKI public
// key in PEM form, mode 0644, on every startup. Read-side tools
// (`agent-receipts verify`) load it without needing access to KeyPath or
// the daemon's signing surface. Defaults to KeyPath + ".pub" when empty.
PublicKeyPath string
// ChainID is the chain id all incoming frames are written under. Phase 1
// supports one chain per daemon process.
ChainID string
// IssuerID is embedded in receipts as issuer.id, e.g.
// "did:agent-receipts-daemon:<host>".
IssuerID string
// VerificationMethodID goes into proof.verificationMethod.
VerificationMethodID string
// Logger receives daemon log lines. Defaults to log.Default().
Logger *log.Logger
// TraceLog optionally receives daemon trace lines for test debugging.
// When nil, tracing is silent. Tests can pass a buffer to inspect
// what frames were received, receipts signed, etc.
TraceLog io.Writer
// ParameterDisclosure controls whether plaintext tool input and output are
// included in the parameters_disclosure receipt field. Disabled by default.
// WARNING: stores unredacted payloads — see issue #280 for the encrypted
// design that supersedes this flag.
ParameterDisclosure bool
// RedactPatternsPath is an optional path to a YAML file of additional
// redaction patterns applied to receipt body fields after hashing. When
// empty, only the built-in patterns are used. File format:
//
// patterns:
// - name: my-secret
// pattern: 'MY_SECRET_[A-Z0-9]+'
RedactPatternsPath string
}
Config is the daemon's startup configuration. Resolve from flags/env in cmd/agent-receipts-daemon/main.go and pass to Run.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
agent-receipts
command
Command agent-receipts is the daemon's read-side companion CLI.
|
Command agent-receipts is the daemon's read-side companion CLI. |
|
agent-receipts-daemon
command
Command agent-receipts-daemon runs the receipts daemon: a single OS-user process that owns the Ed25519 signing key and the SQLite receipt store, and receives fire-and-forget event frames from emitters over a Unix-domain socket.
|
Command agent-receipts-daemon runs the receipts daemon: a single OS-user process that owns the Ed25519 signing key and the SQLite receipt store, and receives fire-and-forget event frames from emitters over a Unix-domain socket. |
|
internal
|
|
|
chain
Package chain owns the daemon's in-memory chain state — the next sequence number and the previous-receipt-hash for each chain id.
|
Package chain owns the daemon's in-memory chain state — the next sequence number and the previous-receipt-hash for each chain id. |
|
keysource
Package keysource defines the interface the daemon uses to sign receipts.
|
Package keysource defines the interface the daemon uses to sign receipts. |
|
listcli
Package listcli implements the `agent-receipts list` subcommand: query recent receipts from a daemon-written SQLite store and print them in tabular or JSON form.
|
Package listcli implements the `agent-receipts list` subcommand: query recent receipts from a daemon-written SQLite store and print them in tabular or JSON form. |
|
pipeline
Package pipeline maps an emitter frame plus an OS-attested peer credential into a signed AgentReceipt and persists it to the store.
|
Package pipeline maps an emitter frame plus an OS-attested peer credential into a signed AgentReceipt and persists it to the store. |
|
socket
Package socket owns the daemon's Unix-domain-socket listener, the per-OS peer-credential capture, and the length-prefix message framing.
|
Package socket owns the daemon's Unix-domain-socket listener, the per-OS peer-credential capture, and the length-prefix message framing. |
|
sockettest
Package sockettest provides shared helpers for AF_UNIX socket tests.
|
Package sockettest provides shared helpers for AF_UNIX socket tests. |
|
verifycli
Package verifycli implements the `agent-receipts verify` subcommand: validate a stored chain's signatures and hash links using a daemon-written SQLite store and the daemon-published public key.
|
Package verifycli implements the `agent-receipts verify` subcommand: validate a stored chain's signatures and hash links using a daemon-written SQLite store and the daemon-published public key. |