evidence

package
v1.10.4 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package evidence defines immutable, scoped artifacts used by result checks.

Index

Constants

View Source
const PrefixArtifact id.Prefix = "evi"

PrefixArtifact identifies immutable evidence objects.

Variables

Error aliases preserve the shared Cortex sentinel identities.

Functions

func DeletionActor

func DeletionActor(ctx context.Context) string

DeletionActor returns the host-supplied actor, or empty when absent.

func Digest

func Digest(data []byte) string

Digest returns the lowercase SHA-256 encoding of exact content bytes.

func ValidDigest

func ValidDigest(value string) bool

ValidDigest accepts only canonical lowercase SHA-256 encodings.

func WithDeletionActor

func WithDeletionActor(ctx context.Context, actor string) context.Context

WithDeletionActor supplies the authenticated actor for a deletion. Hosts derive this reference from their principal rather than request content.

Types

type Action

type Action string

Action identifies the resource operation checked by the host.

const (
	ActionPut    Action = "put"
	ActionRead   Action = "read"
	ActionDelete Action = "delete"
)

type Artifact

type Artifact struct {
	Ref  Ref    `json:"ref"`
	Data []byte `json:"data"`
}

Artifact is the bounded content supplied by a trusted capture adapter.

func Seal

func Seal(a Artifact) (Artifact, error)

Seal detaches content and assigns its digest and byte count. The host supplies identity, scope and timestamps; model output must not supply those fields.

func (Artifact) Validate

func (a Artifact) Validate() error

Validate rejects content that no longer matches its immutable reference.

type Authorizer

type Authorizer interface {
	AuthorizeEvidence(context.Context, Action, Ref) error
}

Authorizer rechecks the current principal, source grants, sensitivity and retention policy. Delete policy may allow an explicit privacy revocation before retention expires. A nil authorizer never grants access.

type Ref

type Ref struct {
	SchemaVersion int          `json:"schema_version"`
	ID            id.ID        `json:"id"`
	SHA256        string       `json:"sha256"`
	MediaType     string       `json:"media_type"`
	Bytes         int64        `json:"bytes"`
	Scope         cortex.Scope `json:"scope"`
	Version       string       `json:"version"`
	Producer      string       `json:"producer"`
	SourceURI     string       `json:"source_uri,omitempty"`
	Sensitivity   Sensitivity  `json:"sensitivity"`
	CreatedAt     time.Time    `json:"created_at"`
	RetainUntil   time.Time    `json:"retain_until"`
}

Ref binds content and its identity. SourceURI is an opaque host resource reference, not a download URL. It must not contain credentials.

func (Ref) BindingDigest

func (r Ref) BindingDigest() (string, error)

BindingDigest hashes the complete versioned reference, including scope, retention and producer. Content hashes alone do not identify authority.

func (Ref) Validate

func (r Ref) Validate() error

Validate checks reference structure without granting access to its content.

type Repository

type Repository interface {
	Put(context.Context, Artifact) (Ref, error)
	Open(context.Context, Ref) (io.ReadCloser, error)
	Delete(context.Context, Ref, string) error
}

Repository provides authorized evidence access. Delete retains a tombstone.

func NewRepository

func NewRepository(storage Storage, authorizer Authorizer, maxBytes int64) (Repository, error)

NewRepository wraps an injected backend with bounded, digest-checked access. Large artifacts need a separately configured repository. No fallback exists.

type Sensitivity

type Sensitivity string

Sensitivity is a host-enforced classification, never an access grant.

const (
	SensitivityPublic     Sensitivity = "public"
	SensitivityInternal   Sensitivity = "internal"
	SensitivityRestricted Sensitivity = "restricted"
)

type Storage

type Storage interface {
	SaveEvidence(context.Context, Artifact) error
	LoadEvidence(context.Context, Ref) (Artifact, error)
	TombstoneEvidence(context.Context, Ref, string) error
}

Storage is an optional persistence capability, not an authorization boundary. SaveEvidence is immutable and idempotent only for identical artifacts. LoadEvidence returns ErrDeleted for tombstones. TombstoneEvidence atomically removes bytes and retains the original reference, actor, time and reason. For an absent identity it records the tombstone before any bytes arrive, so delayed uploads cannot resurrect content. All saves must honor that fence. Every operation must match the exact context scope, including reads.

type Tombstone

type Tombstone struct {
	Ref       Ref       `json:"ref"`
	Actor     string    `json:"actor"`
	Reason    string    `json:"reason"`
	DeletedAt time.Time `json:"deleted_at"`
}

Tombstone retains immutable identity after content removal. Deletion reasons are audit data, not public output. The host supplies a stable actor reference.

type TombstoneReader

type TombstoneReader interface {
	GetEvidenceTombstone(context.Context, Ref) (Tombstone, error)
}

TombstoneReader is an optional audit capability. Reads require exact scope and host audit authorization; Repository never exposes raw tombstones.

Jump to

Keyboard shortcuts

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