resolve

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package resolve turns a Source declaration into concrete, pinned, content-addressable code (or an integrity anchor for sources that cannot be hashed locally). A Router dispatches by source kind to per-kind resolvers: local, inline, npm, git, and url.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertFetcher

type CertFetcher interface {
	SPKIPin(ctx context.Context, rawURL string) (string, error)
}

CertFetcher returns the SPKI pin (base64 SHA-256 of the leaf certificate's SubjectPublicKeyInfo) for the host of a URL.

type Container

type Container struct {
	Runner run.Runner
}

Container resolves container-image MCP sources. The image reference is the integrity anchor (ideally pinned to an @sha256: digest); a cosign signature, when present and verifiable, satisfies the top provenance rung. Like git, the tree is not hashed locally — the pinned ref makes drift detectable.

func NewContainer

func NewContainer(r run.Runner) Container

NewContainer builds a Container resolver.

func (Container) Resolve

func (c Container) Resolve(ctx context.Context, src artifact.Source) (ports.Resolution, error)

Resolve satisfies ports.Resolver.

type Git

type Git struct {
	Runner run.Runner
}

Git resolves git sources by pinning the requested ref to a concrete commit SHA — the SHA is the integrity anchor. Content hashing of cloned trees is a follow-up; the SHA alone makes drift detectable.

func NewGit

func NewGit(r run.Runner) Git

NewGit builds a Git resolver.

func (Git) Resolve

func (g Git) Resolve(ctx context.Context, src artifact.Source) (ports.Resolution, error)

Resolve satisfies ports.Resolver.

type Inline

type Inline struct{}

Inline content-addresses literal text (hooks, rules, context). By convention the literal content is carried in Source.Ref.

func (Inline) Resolve

Resolve satisfies ports.Resolver.

type Local

type Local struct{}

Local resolves a filesystem path to an absolute, hashable location.

func (Local) Resolve

Resolve satisfies ports.Resolver.

type NPM

type NPM struct {
	Runner  run.Runner
	Fetcher npmFetcher
}

NPM resolves npm/npx sources: it pins the exact version and npm integrity, and fetches the package code into a temp directory for hashing/analysis.

func NewNPM

func NewNPM(r run.Runner) NPM

NewNPM builds an NPM resolver with the real pack-based fetcher.

func (NPM) Resolve

func (n NPM) Resolve(ctx context.Context, src artifact.Source) (ports.Resolution, error)

Resolve satisfies ports.Resolver.

type Registry added in v0.4.1

type Registry struct {
	Client  *http.Client
	Fetcher CertFetcher
}

Registry resolves a remote catalog entry (an app store listing).

Unlike npm or git, there is nothing to download: the listing points at a hosted application whose code the registry never exposes. The integrity anchor is therefore twofold — the canonical digest of the published manifest, and the TLS SPKI pin of the distribution host. Together they detect a silent manifest edit or a swapped backing deployment, which is the most that can be established without the bytes.

Schema coverage: this resolver reads the AgentOS `agentos.app.v1` record shape — a manifest object carrying entrypoint, permissions, requiredSecrets, commands and distribution.webUrl. It is named for the generic SourceRegistry kind because the *anchoring strategy* generalizes, but the field mapping does not. A record it cannot read is rejected outright rather than partially parsed: guessing would emit an anchor that pins nothing and findings drawn from fields that were never present. Supporting a second registry means adding a mapper here, not relying on the current one to cope.

func NewRegistry added in v0.4.1

func NewRegistry() Registry

NewRegistry builds a Registry resolver with the real TLS fetcher.

func (Registry) Resolve added in v0.4.1

func (r Registry) Resolve(ctx context.Context, src artifact.Source) (ports.Resolution, error)

Resolve satisfies ports.Resolver. Source.Ref is the app record URL.

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router dispatches resolution by Source.Kind.

func NewRouter

func NewRouter() *Router

NewRouter wires the default per-kind resolvers.

func (*Router) Resolve

func (r *Router) Resolve(ctx context.Context, src artifact.Source) (ports.Resolution, error)

Resolve satisfies ports.Resolver by delegating to the per-kind resolver.

type TLSCertFetcher

type TLSCertFetcher struct {
	// InsecureSkipVerify disables chain verification (used only in tests against
	// httptest servers). Production leaves this false.
	InsecureSkipVerify bool
}

TLSCertFetcher dials the host over TLS and pins the leaf certificate's SPKI.

func (TLSCertFetcher) SPKIPin

func (f TLSCertFetcher) SPKIPin(ctx context.Context, rawURL string) (string, error)

SPKIPin satisfies CertFetcher.

type URL

type URL struct {
	Fetcher CertFetcher
}

URL resolves remote (SSE/HTTP) MCP sources. Remote code cannot be hashed, so the integrity anchor is the TLS certificate's SPKI pin; any change is drift.

func NewURL

func NewURL(f CertFetcher) URL

NewURL builds a URL resolver with the real TLS fetcher.

func (URL) Resolve

func (u URL) Resolve(ctx context.Context, src artifact.Source) (ports.Resolution, error)

Resolve satisfies ports.Resolver.

Jump to

Keyboard shortcuts

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