install

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package install implements trust resolution and TOFU (Trust On First Use) consent for the AgentPaaS verified install flow (Block 23).

After bundle verification passes, the caller invokes ResolveTrust to resolve the publisher's fingerprint against the trust store, handling pinned, unknown (TOFU), and key-conflict paths.

Index

Constants

View Source
const AgentRefLabel = "agentpaas.agent-ref"

AgentRefLabel is the Docker label key for installed agent references.

Variables

View Source
var ErrConfirmMismatch = errors.New("--confirm-fingerprint does not match the publisher fingerprint")

ErrConfirmMismatch is returned when --confirm-fingerprint is provided but does not match the publisher's fingerprint. The CLI layer must use exit code 2 for this error.

View Source
var ErrCredentialMapInvalid = errors.New("invalid credential mapping")

ErrCredentialMapInvalid is returned for invalid non-interactive mapping input.

View Source
var ErrCredentialMapRefused = errors.New("credential mapping refused")

ErrCredentialMapRefused is returned when interactive credential mapping is aborted.

View Source
var ErrDepsUnlockedRefused = errors.New("missing uv.lock requires --allow-unlocked-deps in non-interactive mode")

ErrDepsUnlockedRefused is returned when uv.lock is missing and operator did not allow unlocked deps.

View Source
var ErrDowngradeRefused = errors.New("install refused: version downgrade requires --allow-downgrade")

ErrDowngradeRefused is returned when agent version decreases without --allow-downgrade (A6).

View Source
var ErrForkRefused = errors.New("fork refused")

ErrForkRefused is returned when fork preconditions fail before materialization.

View Source
var ErrImageDigestMismatch = errors.New("image digest mismatch")

ErrImageDigestMismatch is returned when a loaded/built image digest does not match expectation.

View Source
var ErrInstallVerifyFailed = errors.New("post-install verification failed")

ErrInstallVerifyFailed is returned when post-install verification fails (rollback required).

View Source
var ErrKeyConflict = errors.New("publisher key conflict: different key already trusted for this publisher name")

ErrKeyConflict is returned when a publisher name is already pinned with a different key in the trust store (SSH-style hostile-key warning).

View Source
var ErrMaterializeFailed = errors.New("install materialization failed")

ErrMaterializeFailed is returned when install materialization fails (state rolled back).

View Source
var ErrPolicyMismatch = errors.New("--accept-policy does not match the bundle policy digest")

ErrPolicyMismatch is returned when --accept-policy does not match lock.policy_digest (exit 2).

View Source
var ErrPolicyRefused = errors.New("policy approval refused")

ErrPolicyRefused is returned when the operator declines policy approval.

View Source
var ErrPrebuiltPlatformMismatch = errors.New("prebuilt image platform mismatch")

ErrPrebuiltPlatformMismatch is returned when bundle image platform does not match the host.

View Source
var ErrTrustRefused = errors.New("trust refused: fingerprint verification not completed")

ErrTrustRefused is returned when the user declines to trust the publisher fingerprint (TTY abort after failed prompts, or non-TTY with no flag).

Functions

func ApplyMapCredential

func ApplyMapCredential(opts MapCredentialOpts) error

ApplyMapCredential adds or updates one mapping on a saved install manifest.

func CheckAliasUnique

func CheckAliasUnique(stateRoot, alias, excludeRef string) error

CheckAliasUnique ensures no other installed agent uses alias (excluding excludeRef).

func CheckPrebuiltPlatform

func CheckPrebuiltPlatform(bundlePlatform string) error

CheckPrebuiltPlatform refuses amd64 bundles on arm64 hosts (and vice versa) per spec.

func ComputeLocallyVerifiedHops

func ComputeLocallyVerifiedHops(report *bundle.InspectReport, state InstallStateStore) map[int]bool

ComputeLocallyVerifiedHops marks fork hops whose parent lock digest matches a local install.

func DisplayForDaemonKey

func DisplayForDaemonKey(stateRoot, daemonKey string) string

DisplayForDaemonKey returns the D7 display string for a daemon agent key.

func ForkAgentNameFromRef

func ForkAgentNameFromRef(ref string) (string, error)

ForkAgentNameFromRef extracts the agent name from an installed ref for display.

func ForkInstalled

func ForkInstalled(stateRoot, ref, targetDir string, auditAppender audit.AuditAppender) error

ForkInstalled materializes an installed agent into an editable project directory.

func ForkPublisherWarning

func ForkPublisherWarning(stateRoot, ref string) string

ForkPublisherWarning returns a stderr hint when the parent lock has no publisher block.

func FormatAgentDisplay

func FormatAgentDisplay(ref, alias string) string

FormatAgentDisplay renders D7 text: name@pub8 (alias) or name@pub8.

func FormatInstallRef

func FormatInstallRef(agentName, publisherFingerprint string) string

FormatInstallRef builds name@pub8 for warnings and broker errors.

func FormatPolicyStructuralDiff

func FormatPolicyStructuralDiff(d *PolicyStructuralDiff) []string

FormatPolicyStructuralDiff renders human-readable diff lines for the consent card.

func InstalledAgentPath

func InstalledAgentPath(stateRoot, agentName, publisherFingerprint string) (string, error)

InstalledAgentPath returns StateRoot/agents/<name>@<pub8>/.

func InstalledAgentRefDirName

func InstalledAgentRefDirName(agentName, publisherFingerprint string) (string, error)

InstalledAgentRefDirName returns the state directory segment name@pub8.

func IsBundleFileArg

func IsBundleFileArg(arg string) bool

IsBundleFileArg reports whether arg names an existing regular bundle file path.

func IsPhase1LocalAgentDir

func IsPhase1LocalAgentDir(dirName string) bool

IsPhase1LocalAgentDir reports whether dirName is a Phase-1 local agent path (no @pub8).

func MatchPublisherPub8

func MatchPublisherPub8(fingerprint, pub8 string) bool

MatchPublisherPub8 reports whether the full fingerprint matches a pub8 suffix.

func MergeCredentialMapIntoManifest

func MergeCredentialMapIntoManifest(m *InstallManifest, credMap map[string]string)

MergeCredentialMapIntoManifest copies a resolved map onto the manifest (names only).

func ParseInstalledAgentDir

func ParseInstalledAgentDir(dirName string) (name, pub8 string, ok bool)

ParseInstalledAgentDir reports whether a directory name under state/agents is an installed ref (name@pub8).

func ProvenanceReportFromLock

func ProvenanceReportFromLock(lock *pack.AgentLock) (*pack.ProvenanceReport, error)

ProvenanceReportFromLock validates signatures and provenance, returning a report or error.

func ReadInstalledProvenanceReport

func ReadInstalledProvenanceReport(stateRoot, ref string) (*pack.ProvenanceReport, error)

ReadInstalledProvenanceReport loads agent.lock from an installed ref and validates provenance.

func RemoveInstalledAgent

func RemoveInstalledAgent(ctx context.Context, stateRoot, ref string, stopper ContainerStopper, emitAudit func(eventType string, payload map[string]string)) error

RemoveInstalledAgent removes materialized state for ref (name@pub8 or alias). Trust pin is retained.

func ResolveInstalledAgentDir

func ResolveInstalledAgentDir(stateRoot, ref string) (string, error)

ResolveInstalledAgentDir returns the directory for a materialized install or Phase-1 local agent.

func SetInstalledAlias

func SetInstalledAlias(stateRoot, ref, newAlias string, emitAudit func(eventType string, payload map[string]string)) error

SetInstalledAlias updates manifest alias for ref (name@pub8 or alias), with uniqueness check.

func SignedLLMCredentialID

func SignedLLMCredentialID(stateRoot, ref string) (string, error)

SignedLLMCredentialID reads the installed lock for ref (name@pub8) and returns the signed agent_yaml.llm.credential ID, or "" if absent.

func SourceHasUVLock

func SourceHasUVLock(sourceDir string) bool

SourceHasUVLock reports whether uv.lock exists under sourceDir.

func ValidateAlias

func ValidateAlias(alias string) error

ValidateAlias checks install alias strings (publisher display names).

func ValidateReferenceInput

func ValidateReferenceInput(s string) error

ValidateReferenceInput rejects hostile reference strings before resolution.

func VerifyInstalledAgent

func VerifyInstalledAgent(stateRoot, agentRef string, auditAppender audit.AuditAppender) error

VerifyInstalledAgent runs the B20 T03-equivalent checks for materialized installs. Image digest is checked against manifest.LocalImageDigest; source/policy against the signed lock.

Types

type ConfirmMismatchError

type ConfirmMismatchError struct {
	Provided string // display-form fingerprint the user provided
	Expected string // display-form fingerprint from the bundle
}

ConfirmMismatchError wraps ErrConfirmMismatch with the provided vs expected values.

func (*ConfirmMismatchError) DisplayMessage

func (e *ConfirmMismatchError) DisplayMessage() string

DisplayMessage returns the mismatch details for the operator.

func (*ConfirmMismatchError) Error

func (e *ConfirmMismatchError) Error() string

func (*ConfirmMismatchError) Unwrap

func (e *ConfirmMismatchError) Unwrap() error

type ContainerStopper

type ContainerStopper interface {
	StopByAgentRef(ctx context.Context, agentRef string) error
}

ContainerStopper stops running containers for an installed agent ref.

type CredentialMapOpts

type CredentialMapOpts struct {
	Policy     *policy.Policy
	Store      secrets.SecretStore
	InstallRef string
	// Lock is the signed agent lock (for extracting the LLM credential requirement).
	Lock *pack.AgentLock

	IsTTY bool
	// MapCredentials holds non-TTY mappings as "<declared>=<local>" strings.
	MapCredentials []string

	Prompt    func(prompt string) (string, error)
	PrintWarn func(msg string)
	EmitAudit func(eventType string, payload map[string]string)
}

CredentialMapOpts carries explicit inputs for install-time credential mapping.

type CredentialMapResult

type CredentialMapResult struct {
	Map          map[string]string
	Warnings     []string
	DisplayLines []string
}

CredentialMapResult holds mapping output for the install orchestrator.

func ResolveCredentialMapping

func ResolveCredentialMapping(opts CredentialMapOpts) (*CredentialMapResult, error)

ResolveCredentialMapping collects declared→local credential renames for brokered credentials.

type DockerContainerStopper

type DockerContainerStopper struct{}

DockerContainerStopper stops containers labeled agentpaas.agent-ref=<ref>.

func (DockerContainerStopper) StopByAgentRef

func (DockerContainerStopper) StopByAgentRef(ctx context.Context, agentRef string) error

StopByAgentRef implements ContainerStopper.

type DowngradeRefusedError

type DowngradeRefusedError struct {
	PriorVersion string
	NewVersion   string
}

DowngradeRefusedError wraps ErrDowngradeRefused with version context.

func (*DowngradeRefusedError) DisplayMessage

func (e *DowngradeRefusedError) DisplayMessage() string

func (*DowngradeRefusedError) Error

func (e *DowngradeRefusedError) Error() string

func (*DowngradeRefusedError) Unwrap

func (e *DowngradeRefusedError) Unwrap() error

type FakeContainerStopper

type FakeContainerStopper struct {
	Stopped []string
}

FakeContainerStopper records stop calls for tests.

func (*FakeContainerStopper) StopByAgentRef

func (f *FakeContainerStopper) StopByAgentRef(ctx context.Context, agentRef string) error

StopByAgentRef implements ContainerStopper.

type FileInstallState

type FileInstallState struct {
	StateRoot string
}

FileInstallState stores install manifests under StateRoot/installs/<fp>/<agent>/.

func (*FileInstallState) GetInstallByRef

func (s *FileInstallState) GetInstallByRef(ref string) (*PriorInstallRecord, error)

GetInstallByRef loads an install record by agent reference name@pub8.

func (*FileInstallState) GetPriorInstall

func (s *FileInstallState) GetPriorInstall(publisherFingerprint, agentName string) (*PriorInstallRecord, error)

GetPriorInstall loads the prior manifest and policy bytes if present.

func (*FileInstallState) SaveApprovedInstall

func (s *FileInstallState) SaveApprovedInstall(manifest InstallManifest, policyYAML []byte) error

SaveApprovedInstall writes manifest and policy after successful policy approval.

type ForkLineage

type ForkLineage struct {
	Version  int               `json:"version"`
	Parent   ForkLineageParent `json:"parent"`
	ForkedAt string            `json:"forked_at"`
}

ForkLineage is the advisory fork lineage record written beside the project.

func ReadForkLineage

func ReadForkLineage(projectDir string) (*ForkLineage, error)

ReadForkLineage parses lineage.json from a project directory.

type ForkLineageParent

type ForkLineageParent struct {
	AgentName            string                 `json:"agent_name"`
	AgentVersion         string                 `json:"agent_version"`
	PublisherFingerprint string                 `json:"publisher_fingerprint"`
	PublisherName        string                 `json:"publisher_name"`
	LockDigest           string                 `json:"lock_digest"`
	BundleDigest         string                 `json:"bundle_digest"`
	PolicyDigest         string                 `json:"policy_digest"`
	PolicyYAMLB64        string                 `json:"policy_yaml_b64"`
	Provenance           []pack.ProvenanceEntry `json:"provenance"`
}

ForkLineageParent captures the installed parent lock metadata for pack (B24-T02).

type ImageBuilder

type ImageBuilder interface {
	Build(ctx context.Context, sourceDir, agentName string) (digest string, err error)
}

ImageBuilder builds an OCI image from an extracted source tree.

type ImageLoader

type ImageLoader interface {
	Load(ctx context.Context, ociLayoutDir, expectedDigest string) (digest string, err error)
}

ImageLoader loads an OCI layout directory into the local Docker engine.

type InstallManifest

type InstallManifest struct {
	PublisherFingerprint string `json:"publisher_fingerprint"`
	PublisherName        string `json:"publisher_name"`
	AgentName            string `json:"agent_name"`
	AgentVersion         string `json:"agent_version"`
	AcceptedPolicyDigest string `json:"accepted_policy_digest"`
	// CredentialMap maps declared policy credential IDs to local secret store names
	// (renames only; scope remains governed by the signed policy).
	CredentialMap map[string]string `json:"credential_map,omitempty"`

	// B23-T04 materialization fields (install-manifest.json under state/agents/<name>@<pub8>/).
	InstallMode         string           `json:"install_mode,omitempty"`
	LocalImageDigest    string           `json:"local_image_digest,omitempty"`
	DepsUnlockedRebuild bool             `json:"deps_unlocked_rebuild,omitempty"`
	ParentBundleRef     *ParentBundleRef `json:"parent_bundle_ref,omitempty"`
	InstalledAt         time.Time        `json:"installed_at,omitempty"`
	Alias               string           `json:"alias,omitempty"`
}

InstallManifest records receiver-side install metadata (extended by B23-T04).

func LoadManifestByRef

func LoadManifestByRef(stateRoot, ref string) (*InstallManifest, error)

LoadManifestByRef loads the install manifest for an installed agent ref (name@pub8).

type InstallStateStore

type InstallStateStore interface {
	GetPriorInstall(publisherFingerprint, agentName string) (*PriorInstallRecord, error)
	SaveApprovedInstall(manifest InstallManifest, policyYAML []byte) error
	GetInstallByRef(ref string) (*PriorInstallRecord, error)
}

InstallStateStore persists per-(publisher fingerprint, agent name) install records.

type InstalledAgentEntry

type InstalledAgentEntry struct {
	Ref         string    `json:"ref"`
	Alias       string    `json:"alias,omitempty"`
	Version     string    `json:"version"`
	Publisher   string    `json:"publisher"`
	InstalledAt time.Time `json:"installed_at"`
	Mode        string    `json:"mode"`
}

InstalledAgentEntry is one row for `installed list`.

func ListInstalledAgents

func ListInstalledAgents(stateRoot string) ([]InstalledAgentEntry, error)

ListInstalledAgents scans StateRoot/agents/<name>@<pub8>/ only (not Phase-1 bare names).

type KeyConflictError

type KeyConflictError struct {
	PublisherName string // name from the bundle that triggered the conflict
	ExpectedFP    string // fingerprint already trusted for this name
	ReceivedFP    string // fingerprint from the incoming bundle
}

KeyConflictError wraps ErrKeyConflict with an SSH-style user-facing message.

func (*KeyConflictError) DisplayMessage

func (e *KeyConflictError) DisplayMessage() string

DisplayMessage returns the SSH-style hard warning for the operator.

func (*KeyConflictError) Error

func (e *KeyConflictError) Error() string

func (*KeyConflictError) Unwrap

func (e *KeyConflictError) Unwrap() error

type MapCredentialOpts

type MapCredentialOpts struct {
	State   InstallStateStore
	Store   secrets.SecretStore
	Ref     string
	Mapping string // declared=local
	// StateRoot is the installed agent state root (for reading the signed lock).
	StateRoot string
	EmitAudit func(eventType string, payload map[string]string)
}

MapCredentialOpts updates a single mapping on an installed agent (CLI subcommand).

type MaterializeOpts

type MaterializeOpts struct {
	StateRoot    string
	Bundle       *bundle.Bundle
	BundlePath   string
	BundleDigest string
	Manifest     InstallManifest

	PreferImage       bool
	AllowUnlockedDeps bool
	IsTTY             bool
	PrintWarn         func(msg string)
	PromptUnlocked    func(prompt string) (string, error)

	Builder ImageBuilder
	Loader  ImageLoader

	// PostVerifyHook runs after files are written but before atomic rename (tests).
	PostWriteHook func(stagingDir string) error

	Audit audit.AuditAppender
}

MaterializeOpts configures state materialization + image acquisition.

type MaterializeResult

type MaterializeResult struct {
	AgentRef      string
	InstalledPath string
	Manifest      InstallManifest
}

MaterializeResult holds the final installed path and manifest written on disk.

func MaterializeInstall

func MaterializeInstall(ctx context.Context, opts MaterializeOpts) (*MaterializeResult, error)

MaterializeInstall writes ~/.agentpaas/state/agents/<name>@<pub8>/ atomically.

type PackImageBuilder

type PackImageBuilder struct {
	HarnessPath string
	SDKDir      string
	ImageTag    string
}

PackImageBuilder wraps pack.BuildImage.

func (*PackImageBuilder) Build

func (b *PackImageBuilder) Build(ctx context.Context, sourceDir, agentName string) (string, error)

Build implements ImageBuilder using pack.BuildImage.

type ParentBundleRef

type ParentBundleRef struct {
	Digest string `json:"digest"`
	Path   string `json:"path"`
}

ParentBundleRef records the originating bundle for fork lineage (B24).

type PolicyConsentOpts

type PolicyConsentOpts struct {
	Report *bundle.InspectReport

	PolicyDigest string
	PolicyYAML   []byte

	PublisherFingerprint string
	PublisherName        string
	AgentName            string
	AgentVersion         string

	State InstallStateStore

	IsTTY bool
	// AcceptPolicyDigest is the caller-provided --accept-policy value (non-TTY).
	AcceptPolicyDigest string
	AllowDowngrade     bool

	Prompt    func(prompt string) (string, error)
	EmitAudit func(eventType string, payload map[string]string)
}

PolicyConsentOpts carries explicit inputs for policy consent (no os.Args reads).

type PolicyConsentResult

type PolicyConsentResult struct {
	Manifest     InstallManifest
	CardText     string
	DisplayLines []string
}

PolicyConsentResult holds a successful policy approval outcome.

func ResolvePolicyConsent

func ResolvePolicyConsent(opts PolicyConsentOpts) (*PolicyConsentResult, error)

ResolvePolicyConsent renders the consent card and enforces policy digest binding.

If the operator approved the publisher fingerprint (T01) but declines policy here, the trust pin intentionally remains — do not remove trust store entries on decline.

type PolicyMismatchError

type PolicyMismatchError struct {
	Provided string
	Expected string
}

PolicyMismatchError wraps ErrPolicyMismatch with provided vs expected digests.

func (*PolicyMismatchError) DisplayMessage

func (e *PolicyMismatchError) DisplayMessage() string

DisplayMessage returns mismatch details for the operator.

func (*PolicyMismatchError) Error

func (e *PolicyMismatchError) Error() string

func (*PolicyMismatchError) Unwrap

func (e *PolicyMismatchError) Unwrap() error

type PolicyRefusedError

type PolicyRefusedError struct {
	Reason string
	Digest string
}

PolicyRefusedError wraps ErrPolicyRefused with operator-facing context.

func (*PolicyRefusedError) DisplayMessage

func (e *PolicyRefusedError) DisplayMessage() string

DisplayMessage returns instructions for the operator.

func (*PolicyRefusedError) Error

func (e *PolicyRefusedError) Error() string

func (*PolicyRefusedError) Unwrap

func (e *PolicyRefusedError) Unwrap() error

type PolicyStructuralDiff

type PolicyStructuralDiff struct {
	EgressAdded        []string
	EgressRemoved      []string
	CredentialsAdded   []string
	CredentialsRemoved []string
	MCPAdded           []string
	MCPRemoved         []string
	IngressAdded       []string
	IngressRemoved     []string
}

PolicyStructuralDiff is a locally computed diff between two policy YAML blobs.

func ComputeStructuralPolicyDiff

func ComputeStructuralPolicyDiff(oldYAML, newYAML []byte) (*PolicyStructuralDiff, error)

ComputeStructuralPolicyDiff parses old and new policy bytes and diffs egress, credentials, MCP, and ingress sections (not signer-claimed deltas).

type PriorInstallRecord

type PriorInstallRecord struct {
	Manifest   InstallManifest
	PolicyYAML []byte
}

PriorInstallRecord is the stored install state for update/downgrade/diff logic.

type ResolveRefOpts

type ResolveRefOpts struct {
	StateRoot string
	Input     string
	// Infof prints non-fatal resolution hints (e.g. ambiguous-soon) to stderr.
	Infof func(format string, args ...any)
}

ResolveRefOpts configures shared agent reference resolution.

type ResolvedAgent

type ResolvedAgent struct {
	// DaemonKey is the agent identity passed to the daemon Run/Cron/Trigger APIs.
	DaemonKey string
	// Ref is the canonical installed ref (name@pub8) when installed; otherwise DaemonKey.
	Ref string
	// Display is the D7 publisher string: name@pub8 (alias) or name@pub8.
	Display string
	// Installed is true when resolution targeted materialized shared install state.
	Installed bool
}

ResolvedAgent is the outcome of ResolveAgentRef.

func ResolveAgentRef

func ResolveAgentRef(opts ResolveRefOpts) (*ResolvedAgent, error)

ResolveAgentRef resolves a user reference (name@pub8, alias, or bare name).

type SkopeoImageLoader

type SkopeoImageLoader struct{}

SkopeoImageLoader loads OCI layouts via skopeo copy into docker-daemon.

func (SkopeoImageLoader) Load

func (SkopeoImageLoader) Load(ctx context.Context, ociLayoutDir, expectedDigest string) (string, error)

Load implements ImageLoader.

type TrustRefusedError

type TrustRefusedError struct {
	Reason      string // explanation for non-TTY missing-flag case
	Fingerprint string // display-form fingerprint (non-TTY missing-flag)
}

TrustRefusedError wraps ErrTrustRefused with operator-facing context.

func (*TrustRefusedError) DisplayMessage

func (e *TrustRefusedError) DisplayMessage() string

DisplayMessage returns instructions for the operator.

func (*TrustRefusedError) Error

func (e *TrustRefusedError) Error() string

func (*TrustRefusedError) Unwrap

func (e *TrustRefusedError) Unwrap() error

type TrustResolveOpts

type TrustResolveOpts struct {
	// PublisherName is the human-readable slug from the bundle lock's publisher block.
	PublisherName string

	// PublisherFingerprint is the hex-encoded SHA-256 of the publisher's public key.
	PublisherFingerprint string

	// PublisherPublicKeyPEM is the PEM-encoded ECDSA P-256 public key.
	PublisherPublicKeyPEM string

	// Store is a pre-loaded trust store. ResolveTrust only mutates the store
	// (via Pin + Save) on the TOFU approval path. On every non-approval path
	// the store is left unchanged.
	Store *trust.Store

	// IsTTY indicates whether the caller is attached to an interactive terminal.
	IsTTY bool

	// ConfirmedFingerprint is the value of the --confirm-fingerprint CLI flag
	// (non-TTY mode). Empty string means the flag was not provided.
	ConfirmedFingerprint string

	// Prompt is a callback for TTY interactive input. It receives a prompt
	// message and must return the user's typed line. Tests inject this to
	// simulate user input without reading os.Stdin directly.
	Prompt func(prompt string) (string, error)

	// EmitAudit is a best-effort audit event emitter. It receives an event
	// type string and a string→string payload. Never called with secret material.
	EmitAudit func(eventType string, payload map[string]string)
}

TrustResolveOpts carries all inputs needed for trust resolution.

type TrustResult

type TrustResult struct {
	// Publisher is the resolved publisher record (from the store or newly pinned).
	Publisher *trust.Publisher

	// WasPinned is true when a new publisher was added to the trust store (TOFU path).
	WasPinned bool

	// DisplayLines contains the exact user-facing strings to print to the
	// operator, one per line. These are computed by ResolveTrust so the CLI
	// layer does not need to derive display messages.
	DisplayLines []string
}

TrustResult holds the outcome of trust resolution.

func ResolveTrust

func ResolveTrust(opts TrustResolveOpts) (*TrustResult, error)

ResolveTrust resolves a verified publisher against the trust store and handles the TOFU consent flow.

Resolution paths:

  1. Pinned + same key: returns the existing publisher with no mutation.

  2. Unknown (TOFU): displays the full fingerprint and requires explicit operator confirmation. TTY mode prompts for the last 8 hex characters (up to 3 attempts). Non-TTY mode requires --confirm-fingerprint with the full normalized fingerprint. On approval, the publisher is pinned with source=tofu and the store is saved.

  3. Alias/name match, different fingerprint: returns ErrKeyConflict with an SSH-style hard warning. No store mutation occurs.

  4. Non-TTY without --confirm-fingerprint: returns an error instructing the operator to run inspect first or pass the flag.

  5. --confirm-fingerprint with a non-matching value: returns ErrConfirmMismatch (exit code 2) with no store mutation.

Jump to

Keyboard shortcuts

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