api

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package api contains transport-neutral public Registry contracts.

The package intentionally does not perform network I/O or persistence. In particular, an attestation URI is data only; consumers must not fetch it without applying their own allowlist and network policy.

Index

Constants

View Source
const ObservationSchemaV1 = "urn:agentapi-doctor:observation:v1"

Variables

This section is empty.

Functions

This section is empty.

Types

type AttestationReference

type AttestationReference struct {
	Digest schema.Digest `json:"digest"`
	URI    string        `json:"uri,omitempty"`
}

type CanonicalObject

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

CanonicalObject is an RFC 8785 JSON object. Its byte slice is private so a caller cannot mutate an Observation's signed projection through an alias.

func ParseCanonicalObject

func ParseCanonicalObject(raw []byte) (CanonicalObject, error)

ParseCanonicalObject rejects ambiguous JSON before retaining canonical bytes. Observation sections are objects, not arbitrary JSON values.

func (CanonicalObject) Bytes

func (object CanonicalObject) Bytes() []byte

Bytes returns a defensive copy of the canonical representation.

func (CanonicalObject) Equal

func (object CanonicalObject) Equal(other CanonicalObject) bool

func (CanonicalObject) IsZero

func (object CanonicalObject) IsZero() bool

func (CanonicalObject) MarshalJSON

func (object CanonicalObject) MarshalJSON() ([]byte, error)

func (*CanonicalObject) UnmarshalJSON

func (object *CanonicalObject) UnmarshalJSON(raw []byte) error

type Freshness

type Freshness string
const (
	FreshnessUnknown Freshness = "unknown"
	FreshnessFresh   Freshness = "fresh"
	FreshnessStale   Freshness = "stale"
)

type Observation

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

Observation binds an immutable projection to its content-derived ID while permitting append-only provenance and recomputable Registry metadata to evolve independently.

func NewObservation

func NewObservation(
	projection ObservationProjection,
	classID schema.Digest,
	attestations []AttestationReference,
	derived RegistryDerived,
) (Observation, error)

func (Observation) Attestations

func (observation Observation) Attestations() []AttestationReference

func (Observation) ClassID

func (observation Observation) ClassID() schema.Digest

func (Observation) ID

func (observation Observation) ID() schema.Digest

func (Observation) MarshalJSON

func (observation Observation) MarshalJSON() ([]byte, error)

func (Observation) Projection

func (observation Observation) Projection() ObservationProjection

func (Observation) RegistryDerived

func (observation Observation) RegistryDerived() RegistryDerived

func (*Observation) UnmarshalJSON

func (observation *Observation) UnmarshalJSON(raw []byte) error

func (Observation) Validate

func (observation Observation) Validate() error

func (Observation) WithAttestation

func (observation Observation) WithAttestation(reference AttestationReference) (Observation, error)

WithAttestation appends provenance without replacing previously recorded attestations. Exact duplicates are rejected by Validate.

func (Observation) WithRegistryDerived

func (observation Observation) WithRegistryDerived(derived RegistryDerived) (Observation, error)

WithRegistryDerived returns a new derived view while preserving immutable content and all append-only provenance.

type ObservationProjection

type ObservationProjection struct {
	SchemaVersion  string          `json:"schema_version"`
	Subject        CanonicalObject `json:"subject"`
	Test           CanonicalObject `json:"test"`
	Environment    CanonicalObject `json:"environment"`
	Result         CanonicalObject `json:"result"`
	ManifestDigest schema.Digest   `json:"manifest_digest"`
}

ObservationProjection is the complete v1 observation_id input. IDs, signatures, attestations, trust/freshness, publication time, disputes and correction relations deliberately live outside this structure.

func (ObservationProjection) Digest

func (projection ObservationProjection) Digest() (schema.Digest, error)

Digest computes observation_id over the immutable projection only.

func (ObservationProjection) Validate

func (projection ObservationProjection) Validate() error

type RegistryDerived

type RegistryDerived struct {
	TrustLabels  []string        `json:"trust_labels,omitempty"`
	Freshness    Freshness       `json:"freshness,omitempty"`
	PublishedAt  *schema.UTCTime `json:"published_at,omitempty"`
	DisputeIDs   []string        `json:"dispute_ids,omitempty"`
	SupersededBy schema.Digest   `json:"superseded_by,omitempty"`
	Tombstoned   bool            `json:"tombstoned,omitempty"`
}

RegistryDerived contains mutable interpretations and publication metadata. None of these fields participate in observation_id.

Jump to

Keyboard shortcuts

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