Removes the Kit task-tool result shim (and with it the MCP go-sdk dependency), the messaging enable/disable/restart helpers and channel rebuild closures nothing calls since channels became extensions, the unused messaging capability, ephemeral and text-fallback types, and single stragglers in telemetry, releaseupdate, skill, storepkg and webui. The egress sandbox relay stays for #1867.
64 lines
2.1 KiB
Go
64 lines
2.1 KiB
Go
package storepkg
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"github.com/samcharles93/archie-core/internal/domain/distribution"
|
|
domain "github.com/samcharles93/archie-core/internal/domain/storepkg"
|
|
"github.com/samcharles93/archie-core/internal/infrastructure/signedoci"
|
|
)
|
|
|
|
// SignatureAnnotation carries the base64 ed25519 signature over the
|
|
// catalogue's layer bytes.
|
|
const SignatureAnnotation = "dev.archie.catalogue.signature.v1"
|
|
|
|
const maxCatalogueBytes = 1 << 20
|
|
|
|
// catalogueTag is the tag a catalogue source publishes its current catalogue
|
|
// under.
|
|
const catalogueTag = "latest"
|
|
|
|
// Catalogue fetches the catalogue a source publishes and refuses a replayed
|
|
// older one, keeping the freshness mark per source.
|
|
func Catalogue(source distribution.Source) domain.CatalogueSource {
|
|
return domain.FreshCatalogueSource{
|
|
Source: OCICatalogue{Source: source},
|
|
Freshness: &signedoci.FileFreshness{Path: signedoci.MarkPath("catalogue", source.Reference)},
|
|
}
|
|
}
|
|
|
|
// OCICatalogue fetches a catalogue artifact and verifies it against the
|
|
// source's key: an OCI manifest whose first layer is the catalogue JSON and
|
|
// whose annotation signs that layer. The tag is mutable; the signature is
|
|
// what makes the list trustworthy.
|
|
type OCICatalogue struct {
|
|
Source distribution.Source
|
|
}
|
|
|
|
var _ domain.CatalogueSource = OCICatalogue{}
|
|
|
|
func (c OCICatalogue) Fetch(ctx context.Context) (domain.Catalogue, error) {
|
|
artifact, err := signedoci.Fetch(ctx, c.Source, catalogueTag, SignatureAnnotation, maxCatalogueBytes)
|
|
if err != nil {
|
|
return domain.Catalogue{}, fmt.Errorf("catalogue: %w", err)
|
|
}
|
|
return decodeCatalogue(artifact.Statement)
|
|
}
|
|
|
|
// decodeCatalogue decodes a verified catalogue layer.
|
|
func decodeCatalogue(layer []byte) (domain.Catalogue, error) {
|
|
decoder := json.NewDecoder(bytes.NewReader(layer))
|
|
decoder.DisallowUnknownFields()
|
|
var catalogue domain.Catalogue
|
|
if err := decoder.Decode(&catalogue); err != nil {
|
|
return domain.Catalogue{}, fmt.Errorf("catalogue: %w", err)
|
|
}
|
|
if err := catalogue.Validate(); err != nil {
|
|
return domain.Catalogue{}, err
|
|
}
|
|
return catalogue, nil
|
|
}
|