doctorcli

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package doctorcli implements the `agent-receipts doctor` subcommand: an end-to-end health check of the receipts pipeline (emitter → socket → daemon → SQLite → verify) described by ADR-0010. It exists because the failure modes the pipeline can drift into are subtle — tool calls succeed, individual signatures verify, yet the documented path is silently broken. `doctor` makes "agent-receipts is working on this host" an actively-checkable property rather than an assumption (issue #539).

Logic lives here, away from cmd/agent-receipts/main.go, so tests can drive the subcommand directly with arbitrary args / captured I/O without shelling out to a built binary, and so individual checks can be unit-tested against fixtures.

Index

Constants

View Source
const (
	ExitOK         = 0 // all checks ok (or only warnings without --warn-as-error)
	ExitUnhealthy  = 1 // at least one check failed (or warned under --warn-as-error)
	ExitUsageError = 2 // bad flags
)

Exit codes are part of the CLI contract — CI healthchecks pivot on them. Keep these stable.

Variables

This section is empty.

Functions

func Run

func Run(args []string, stdout, stderr io.Writer, envLookup func(string) string) int

Run executes the doctor subcommand. Returns one of the Exit* constants; cmd/agent-receipts/main.go forwards it to os.Exit.

envLookup is split out so tests can inject a deterministic environment. Pass os.Getenv for the production caller.

Types

type Report

type Report struct {
	OK     bool     `json:"ok"`
	Checks []Result `json:"checks"`
}

Report is the full doctor run, emitted verbatim under --json.

type Result

type Result struct {
	Check  string `json:"check"`
	Status Status `json:"status"`
	Reason string `json:"reason"`
	Fix    string `json:"fix,omitempty"`
}

Result is one check's structured outcome. Reason is always present; Fix is a suggested remediation command/hint, omitted when there is nothing actionable.

type Status

type Status string

Status is the outcome of a single check.

const (
	StatusOK   Status = "ok"
	StatusWarn Status = "warn"
	StatusFail Status = "fail"
)

Jump to

Keyboard shortcuts

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