runtimeadmission

package
v0.0.0-...-804b954 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package runtimeadmission owns the content-reference and durable SendInput admission seam.

Index

Constants

View Source
const (
	// InputMediaTypeV1 identifies the versioned canonical input envelope.
	InputMediaTypeV1 = "application/vnd.agent-runtime.input+cbor;version=1"
)

Variables

View Source
var (
	// ErrNotFoundOrDenied prevents artifact/content existence disclosure.
	ErrNotFoundOrDenied = errors.New("runtime admission resource not found or denied")
	// ErrConflict reports a durable idempotency or lifecycle conflict.
	ErrConflict = errors.New("runtime admission conflict")
	// ErrUnavailable reports an object-store or PostgreSQL failure safe to retry.
	ErrUnavailable = errors.New("runtime admission unavailable")
	// ErrIntegrity reports content that no longer matches its durable reference.
	ErrIntegrity = errors.New("runtime admission content integrity failure")
)

Functions

This section is empty.

Types

type AdmissionResult

type AdmissionResult struct {
	InputID    agentruntime.InputID
	AcceptedAt time.Time
	Turn       agentruntime.Turn
}

AdmissionResult is the durable result before input content is hydrated.

type ArtifactCatalog

type ArtifactCatalog interface {
	AuthorizeInputReferences(context.Context, Owner, []agentruntime.ArtifactReference) error
}

ArtifactCatalog authorizes immutable artifact metadata before input staging.

type Clock

type Clock interface{ Now() time.Time }

Clock supplies admission timestamps.

type ContentReference

type ContentReference struct {
	Digest    string
	MediaType string
	SizeBytes int64
}

ContentReference is immutable metadata; it never contains an object key.

type ContentStore

type ContentStore interface {
	PutInput(context.Context, Owner, []agentruntime.ContentPart) (ContentReference, error)
	GetInput(context.Context, authorizedInputLocator) ([]agentruntime.ContentPart, error)
}

ContentStore owns immutable canonical input bytes.

type IDSource

type IDSource interface{ Next() (string, error) }

IDSource supplies the sixteen-character opaque ID payload used by runtime IDs.

type MemoryArtifactCatalog

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

MemoryArtifactCatalog is a deterministic owner-scoped immutable catalog.

func NewMemoryArtifactCatalog

func NewMemoryArtifactCatalog() *MemoryArtifactCatalog

NewMemoryArtifactCatalog creates an empty catalog.

func (*MemoryArtifactCatalog) AuthorizeInputReferences

func (catalog *MemoryArtifactCatalog) AuthorizeInputReferences(ctx context.Context, owner Owner, references []agentruntime.ArtifactReference) error

AuthorizeInputReferences verifies every exact immutable reference for owner.

func (*MemoryArtifactCatalog) Seed

func (catalog *MemoryArtifactCatalog) Seed(owner Owner, reference agentruntime.ArtifactReference)

Seed registers one immutable artifact for focused tests.

type MemoryContentStore

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

MemoryContentStore is a deterministic immutable ContentStore for focused tests.

func NewMemoryContentStore

func NewMemoryContentStore() *MemoryContentStore

NewMemoryContentStore creates an empty tenant-namespaced immutable store.

func (*MemoryContentStore) Count

func (store *MemoryContentStore) Count() int

Count returns staged immutable objects for deterministic orphan tests.

func (*MemoryContentStore) GetInput

func (store *MemoryContentStore) GetInput(ctx context.Context, locator authorizedInputLocator) ([]agentruntime.ContentPart, error)

GetInput verifies and decodes content addressed by a repository-issued locator.

func (*MemoryContentStore) PutInput

func (store *MemoryContentStore) PutInput(ctx context.Context, owner Owner, parts []agentruntime.ContentPart) (ContentReference, error)

PutInput canonicalizes and conditionally stores one valid public input.

type Owner

type Owner struct {
	TenantID    string
	PrincipalID string
}

Owner is the exact authenticated tenant/principal authorization boundary.

type PostgresRepository

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

PostgresRepository is the normalized runtime-v3 durable SendInput authority.

func NewPostgresRepository

func NewPostgresRepository(pool *pgxpool.Pool) (*PostgresRepository, error)

NewPostgresRepository constructs the existing-session admission repository.

func (*PostgresRepository) Admit

func (repository *PostgresRepository) Admit(ctx context.Context, owner Owner, prepared PreparedInput, ids IDSource) (result AdmissionResult, resultErr error)

Admit serializes distinct sends at the scoped session row and replays an exact idempotent result.

func (*PostgresRepository) AuthorizeInputRead

func (repository *PostgresRepository) AuthorizeInputRead(ctx context.Context, owner Owner, sessionID agentruntime.SessionID, inputID agentruntime.InputID) (authorizedInputLocator, error)

AuthorizeInputRead returns an unexported locator only after exact owner/session/input lookup.

type PreparedInput

type PreparedInput struct {
	ID             agentruntime.InputID
	SessionID      agentruntime.SessionID
	IdempotencyKey string
	RequestDigest  string
	Content        ContentReference
	AcceptedAt     time.Time
}

PreparedInput contains only a content reference and bounded command metadata.

type Repository

type Repository interface {
	Admit(context.Context, Owner, PreparedInput, IDSource) (AdmissionResult, error)
	AuthorizeInputRead(context.Context, Owner, agentruntime.SessionID, agentruntime.InputID) (authorizedInputLocator, error)
}

Repository commits only one prepared SendInput against an existing Session.

type Service

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

Service composes content ingress, artifact admission, and durable SendInput.

func NewService

func NewService(content ContentStore, artifacts ArtifactCatalog, repository Repository, clock Clock, ids IDSource) (*Service, error)

NewService constructs a fail-closed durable SendInput composition.

func (*Service) SendInput

func (service *Service) SendInput(ctx context.Context, owner Owner, request agentruntime.SendInputRequest) (agentruntime.SendInputResult, error)

SendInput validates artifacts before staging content, commits a prepared reference, then hydrates from the authorized locator.

Jump to

Keyboard shortcuts

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