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
- Variables
- func ApplyMapCredential(opts MapCredentialOpts) error
- func CheckAliasUnique(stateRoot, alias, excludeRef string) error
- func CheckPrebuiltPlatform(bundlePlatform string) error
- func ComputeLocallyVerifiedHops(report *bundle.InspectReport, state InstallStateStore) map[int]bool
- func DisplayForDaemonKey(stateRoot, daemonKey string) string
- func ForkAgentNameFromRef(ref string) (string, error)
- func ForkInstalled(stateRoot, ref, targetDir string, auditAppender audit.AuditAppender) error
- func ForkPublisherWarning(stateRoot, ref string) string
- func FormatAgentDisplay(ref, alias string) string
- func FormatInstallRef(agentName, publisherFingerprint string) string
- func FormatPolicyStructuralDiff(d *PolicyStructuralDiff) []string
- func InstalledAgentPath(stateRoot, agentName, publisherFingerprint string) (string, error)
- func InstalledAgentRefDirName(agentName, publisherFingerprint string) (string, error)
- func IsBundleFileArg(arg string) bool
- func IsPhase1LocalAgentDir(dirName string) bool
- func MatchPublisherPub8(fingerprint, pub8 string) bool
- func MergeCredentialMapIntoManifest(m *InstallManifest, credMap map[string]string)
- func ParseInstalledAgentDir(dirName string) (name, pub8 string, ok bool)
- func ProvenanceReportFromLock(lock *pack.AgentLock) (*pack.ProvenanceReport, error)
- func ReadInstalledProvenanceReport(stateRoot, ref string) (*pack.ProvenanceReport, error)
- func RemoveInstalledAgent(ctx context.Context, stateRoot, ref string, stopper ContainerStopper, ...) error
- func ResolveInstalledAgentDir(stateRoot, ref string) (string, error)
- func SetInstalledAlias(stateRoot, ref, newAlias string, ...) error
- func SignedLLMCredentialID(stateRoot, ref string) (string, error)
- func SourceHasUVLock(sourceDir string) bool
- func ValidateAlias(alias string) error
- func ValidateReferenceInput(s string) error
- func VerifyInstalledAgent(stateRoot, agentRef string, auditAppender audit.AuditAppender) error
- type ConfirmMismatchError
- type ContainerStopper
- type CredentialMapOpts
- type CredentialMapResult
- type DockerContainerStopper
- type DowngradeRefusedError
- type FakeContainerStopper
- type FileInstallState
- type ForkLineage
- type ForkLineageParent
- type ImageBuilder
- type ImageLoader
- type InstallManifest
- type InstallStateStore
- type InstalledAgentEntry
- type KeyConflictError
- type MapCredentialOpts
- type MaterializeOpts
- type MaterializeResult
- type PackImageBuilder
- type ParentBundleRef
- type PolicyConsentOpts
- type PolicyConsentResult
- type PolicyMismatchError
- type PolicyRefusedError
- type PolicyStructuralDiff
- type PriorInstallRecord
- type ResolveRefOpts
- type ResolvedAgent
- type SkopeoImageLoader
- type TrustRefusedError
- type TrustResolveOpts
- type TrustResult
Constants ¶
const AgentRefLabel = "agentpaas.agent-ref"
AgentRefLabel is the Docker label key for installed agent references.
Variables ¶
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.
var ErrCredentialMapInvalid = errors.New("invalid credential mapping")
ErrCredentialMapInvalid is returned for invalid non-interactive mapping input.
var ErrCredentialMapRefused = errors.New("credential mapping refused")
ErrCredentialMapRefused is returned when interactive credential mapping is aborted.
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.
var ErrDowngradeRefused = errors.New("install refused: version downgrade requires --allow-downgrade")
ErrDowngradeRefused is returned when agent version decreases without --allow-downgrade (A6).
var ErrForkRefused = errors.New("fork refused")
ErrForkRefused is returned when fork preconditions fail before materialization.
var ErrImageDigestMismatch = errors.New("image digest mismatch")
ErrImageDigestMismatch is returned when a loaded/built image digest does not match expectation.
var ErrInstallVerifyFailed = errors.New("post-install verification failed")
ErrInstallVerifyFailed is returned when post-install verification fails (rollback required).
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).
var ErrMaterializeFailed = errors.New("install materialization failed")
ErrMaterializeFailed is returned when install materialization fails (state rolled back).
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).
var ErrPolicyRefused = errors.New("policy approval refused")
ErrPolicyRefused is returned when the operator declines policy approval.
var ErrPrebuiltPlatformMismatch = errors.New("prebuilt image platform mismatch")
ErrPrebuiltPlatformMismatch is returned when bundle image platform does not match the host.
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 ¶
CheckAliasUnique ensures no other installed agent uses alias (excluding excludeRef).
func CheckPrebuiltPlatform ¶
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 ¶
DisplayForDaemonKey returns the D7 display string for a daemon agent key.
func ForkAgentNameFromRef ¶
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 ¶
ForkPublisherWarning returns a stderr hint when the parent lock has no publisher block.
func FormatAgentDisplay ¶
FormatAgentDisplay renders D7 text: name@pub8 (alias) or name@pub8.
func FormatInstallRef ¶
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 ¶
InstalledAgentPath returns StateRoot/agents/<name>@<pub8>/.
func InstalledAgentRefDirName ¶
InstalledAgentRefDirName returns the state directory segment name@pub8.
func IsBundleFileArg ¶
IsBundleFileArg reports whether arg names an existing regular bundle file path.
func IsPhase1LocalAgentDir ¶
IsPhase1LocalAgentDir reports whether dirName is a Phase-1 local agent path (no @pub8).
func MatchPublisherPub8 ¶
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 ¶
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 ¶
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 ¶
SignedLLMCredentialID reads the installed lock for ref (name@pub8) and returns the signed agent_yaml.llm.credential ID, or "" if absent.
func SourceHasUVLock ¶
SourceHasUVLock reports whether uv.lock exists under sourceDir.
func ValidateAlias ¶
ValidateAlias checks install alias strings (publisher display names).
func ValidateReferenceInput ¶
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 ¶
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 ¶
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 ¶
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 ¶
PackImageBuilder wraps pack.BuildImage.
type ParentBundleRef ¶
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 ¶
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 ¶
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.
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:
Pinned + same key: returns the existing publisher with no mutation.
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.
Alias/name match, different fingerprint: returns ErrKeyConflict with an SSH-style hard warning. No store mutation occurs.
Non-TTY without --confirm-fingerprint: returns an error instructing the operator to run inspect first or pass the flag.
--confirm-fingerprint with a non-matching value: returns ErrConfirmMismatch (exit code 2) with no store mutation.