docs(connectors): clarify catalogue and guard comments (#2119)

This commit is contained in:
sam committed 2026-11-27 02:21:13 +11:00
1 parent c538017523
commit bc4ac4436d
10 files changed
+30 -34

No files matched your search

+3 -4
View File
@@ -295,10 +295,9 @@ func checkAccepted(a store.Installed, req installationRequest) error {
return nil
}
// checkGrants bounds what an organisation or a person may grant an extension.
// The instance's installations of a package are what an administrator
// accepted, so an installation below them may see only the environment
// variables those pass on. Each installation names its own egress hosts.
// checkGrants limits organisation and personal installations to environment
// variables granted to the package at instance scope. Only an instance
// installation can request unrestricted egress.
func checkGrants(a store.Installed, req installationRequest, installed []store.Installed) error {
if a.Scope == store.ScopeInstance {
return nil
@@ -42,7 +42,7 @@ func NewFetcher(dir string) *Fetcher {
return &Fetcher{Dir: dir, Client: &http.Client{Timeout: 5 * time.Minute}}
}
// CheckSource validates a catalogue source, which can also be an OCI repository.
// CheckSource accepts OCI repositories, HTTPS URLs, loopback HTTP URLs and absolute paths.
func CheckSource(loc string) error {
if isOCI(loc) || checkLocation(loc) == nil {
return nil
@@ -150,9 +150,9 @@ func (f *Fetcher) readAll(ctx context.Context, loc string) ([]byte, error) {
return data, nil
}
// FetchVersion keeps the verified binary and returns its path and SHA-256.
// An OCI version pins the manifest, not the binary, so its binary has a
// separate digest for the host to check at launch.
// FetchVersion saves the verified binary and returns its path and SHA-256.
// OCI catalogue entries pin the manifest. The host checks the binary's own
// digest before starting it.
func (f *Fetcher) FetchVersion(ctx context.Context, name, location string, v Version) (path, digest string, err error) {
if b := v.binary; b != nil {
layer, err := fetchLayer(ctx, b.repository, b.layer, 64<<20)
@@ -37,7 +37,7 @@ func tidy(in []string) []string {
return slices.Compact(out)
}
// Covers reports whether every grant in want is one g holds.
// Covers reports whether g includes every requested grant.
func (g Grants) Covers(want Grants) bool {
return subset(want.Egress, g.Egress) && subset(want.Env, g.Env) && subset(want.Credentials, g.Credentials)
}
@@ -51,7 +51,7 @@ func subset(want, have []string) bool {
return true
}
// Added returns what want asks for beyond g.
// Added returns the requested grants that g doesn't include.
func (g Grants) Added(want Grants) Grants {
return Grants{
Egress: missing(want.Egress, g.Egress),
+2 -4
View File
@@ -88,8 +88,8 @@ func (f *Fetcher) repository(loc string) (*remote.Repository, error) {
return r, nil
}
// ReadOCI verifies the catalogue before fetching any package metadata. Every
// descriptor is then verified against the catalogue's immutable manifest pin.
// ReadOCI verifies the catalogue signature, then checks each package manifest
// against the digest in the signed catalogue.
func (f *Fetcher) ReadOCI(ctx context.Context, loc string, key ed25519.PublicKey) (Document, error) {
r, err := f.repository(loc)
if err != nil {
@@ -191,8 +191,6 @@ func packageEntry(p publishedPackage, meta packageMetadata, binary *ociBinary) E
}
}
// fetchManifest and fetchLayer carry the bounded, digest-checked OCI reads
// used by the signed catalogue and its pinned packages.
func fetchManifest(ctx context.Context, r *remote.Repository, ref, pin string) (ocispec.Manifest, error) {
_, stream, err := r.FetchReference(ctx, ref)
if err != nil {
@@ -16,8 +16,8 @@ import (
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
// TestReadOCIChecksSignatureAndPackagePin ensures a registry can't substitute
// a different grants or settings descriptor for a signed catalogue entry.
// TestReadOCIChecksSignatureAndPackagePin checks that a registry can't replace
// the package manifest that declares settings and grants.
func TestReadOCIChecksSignatureAndPackagePin(t *testing.T) {
key, signer, err := ed25519.GenerateKey(nil)
if err != nil {
+1 -2
View File
@@ -43,8 +43,7 @@ type Spec struct {
// Env names the host environment variables the extension may see. PATH and
// HOME are always passed so a plugin can find the CLI it wraps.
Env []string
// Egress is the accepted host list. The extension can reach only these
// hosts through its proxy.
// Egress lists the hosts the extension may reach through its proxy.
Egress []string
}
+5 -5
View File
@@ -27,8 +27,8 @@ type Source struct {
Generation int64 `db:"generation"`
}
// CatalogueSource returns the override and the active source's freshness mark.
// An empty location selects the built-in source.
// CatalogueSource returns the configured override and the newest issue time
// accepted from the active source. An empty location means there's no override.
func (s *Store) CatalogueSource(ctx context.Context) (Source, error) {
var out Source
err := s.db.GetContext(ctx, &out, `
@@ -62,8 +62,8 @@ func (s *Store) PutCatalogueSource(ctx context.Context, src Source) error {
return nil
}
// AdvanceCatalogue records freshness only for the source that was read. The
// built-in source keeps its own mark when the operator selects an override.
// AdvanceCatalogue rejects reads from an earlier source generation and never
// lowers the issue time. An override doesn't reset Archipelago's issue time.
func (s *Store) AdvanceCatalogue(ctx context.Context, generation int64, issuedAt time.Time) (bool, error) {
if generation == 0 {
if _, err := s.db.ExecContext(ctx, `INSERT INTO connectors.catalogue_source (location, public_key)
@@ -325,7 +325,7 @@ var (
ErrDefaultVersion = errors.New("the version is the package's default")
// ErrVersionPinned means an installation pins the version.
ErrVersionPinned = errors.New("an installation pins the version")
// ErrCatalogueChanged means a different source or newer catalogue superseded the fetch.
// ErrCatalogueChanged means the source changed or a newer catalogue was accepted during the fetch.
ErrCatalogueChanged = errors.New("the catalogue changed while the package was being fetched")
)
+3 -2
View File
@@ -293,8 +293,9 @@ func (m *Module) connectorsFor(ctx context.Context) []*Connector {
return out
}
// Guards lists every enabled guard in scope. A narrower installation can't
// shadow a guard, and an unavailable guard must still contribute a verdict.
// Guards returns the enabled guards that apply to the caller. A same-named
// installation can't replace an inherited guard. An unavailable guard still
// participates so an action can't proceed without review.
func (m *Module) Guards(ctx context.Context) []*Guard {
scope := ScopeFromContext(ctx)
owners := scope.owners()
+6 -7
View File
@@ -205,9 +205,9 @@ func (m *Module) relaunchFollowers(ctx context.Context, packageID uuid.UUID, ski
return errors.Join(errs...)
}
// promote launches followers before changing the durable default. A restart
// during promotion still loads the old version. On failure, restore each
// installation that was touched, including the one that failed to start.
// promote leaves the saved default unchanged until every enabled follower starts
// on the new version. If promotion fails, it restarts each affected installation
// on its previous version.
func (m *Module) promote(ctx context.Context, pkg store.Package, v store.Version) error {
installed, err := m.store.List(ctx)
if err != nil {
@@ -592,10 +592,9 @@ func errNoVersion(name, version string) error {
return huma.NewError(http.StatusNotFound, fmt.Sprintf("%s has no version %s", name, version))
}
// UpdateAuto fetches the newest catalogue version of every package whose
// policy is auto. One whose grants the default version's cover becomes the
// default; one that asks for more waits for an operator. One package that
// fails doesn't stop the rest.
// UpdateAuto updates packages set to update automatically. A version that
// requests additional grants waits for operator acceptance. A failed update
// doesn't stop other updates.
func (m *Module) UpdateAuto(ctx context.Context) error {
pkgs, err := m.store.Packages(ctx)
if err != nil {
+2 -2
View File
@@ -108,8 +108,8 @@ func TestOverridesNameTheScopeThatSetThem(t *testing.T) {
}
}
// TestInheritedGuardStillJudges guards against a saved override or a
// narrower installation masking an unavailable enforcing guard.
// TestInheritedGuardStillJudges checks that an unavailable enforcing guard
// still applies despite a saved override and a same-named personal guard.
func TestInheritedGuardStillJudges(t *testing.T) {
instance := store.Installed{ID: uuid.New(), Scope: store.ScopeInstance, Name: "hours", Contract: store.ContractGuard, Enabled: true}
personal := store.Installed{ID: uuid.New(), Scope: store.ScopePerson, PersonID: "me", Name: "hours", Contract: store.ContractGuard, Enabled: true}