Help us shape the future of Go! Take the 2026 Go Developer Survey

model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package model defines the engine's transport-independent contracts.

Index

Constants

View Source
const AuditExportLease = 3 * time.Minute

AuditExportLease outlasts the bounded export attempt. Delivery retries must wait at least this long after an attempt that may have claimed the job.

View Source
const MaxProjectionPageBytes = 8 << 20
View Source
const MaxProjectionPageDocuments = 256
View Source
const ProjectionInventoryV2 = "projection-inventory-v2"

Variables

View Source
var (
	ErrInvalid      = errors.New("invalid input")
	ErrDenied       = errors.New("permission denied")
	ErrNotFound     = errors.New("not found")
	ErrConflict     = errors.New("command identity conflict")
	ErrRevision     = errors.New("stream revision conflict")
	ErrPrecondition = errors.New("precondition failed")
	ErrQuota        = errors.New("quota exhausted")
	ErrUnavailable  = errors.New("dependency unavailable")
)
View Source
var ErrRefreshNotNeeded = fmt.Errorf("memory refresh is no longer needed: %w", ErrPrecondition)

ErrRefreshNotNeeded is distinct from configuration, evidence and schema failures so event consumers may skip only an obsolete or restored target.

Functions

func ArchiveConsumer

func ArchiveConsumer(stream string) string

func AttestationEvidence

func AttestationEvidence(a Attestation) []string

func AttestationIdentityDigest

func AttestationIdentityDigest(r AttestationIdentityRequest) string

func AuditExportConsumer

func AuditExportConsumer(stream string) string

func BytesDigest

func BytesDigest(b []byte) string

func CalculationDigest

func CalculationDigest(r CalculationReceipt) string

func ChangesMemoryDependency

func ChangesMemoryDependency(e Event) bool

func ContextDigest

func ContextDigest(m ContextManifest) string

func ContextScopes

func ContextScopes(m ContextManifest) []string

ContextScopes includes every scope whose content is retained in the manifest.

func ConversationDigest

func ConversationDigest(r ConversationRequest) string

func ConversationRecordID

func ConversationRecordID(tenant string, r ConversationRequest) string

func DecisionArtifacts

func DecisionArtifacts(r DecisionReceipt) map[string]ArtifactReference

func DecisionDigest

func DecisionDigest(r DecisionReceipt) string

func Digest

func Digest(v any) string

func EvidenceDisposalConsumer

func EvidenceDisposalConsumer() string

EvidenceDisposalConsumer identifies the trusted consumer that performs post-commit deletion from external immutable evidence stores.

func ExtractionConsumer

func ExtractionConsumer(stream string) string

func ExtractionProfileDigest

func ExtractionProfileDigest(p ExtractionProfile) string

func FactDigest

func FactDigest(p FactProposal) string

FactDigest is the canonical content digest used by fact proposals. Command metadata and disposal state do not participate in the content identity.

func IsMemoryRefreshSweep

func IsMemoryRefreshSweep(e Event) bool

func MemoryDigest

func MemoryDigest(p MemoryProposal) string

func MemoryRecordID

func MemoryRecordID(k MemoryKey) string

func MemoryRefreshConsumer

func MemoryRefreshConsumer(stream string) string

func ProjectionConsumer

func ProjectionConsumer(generation string) string

func ProjectionID

func ProjectionID(d ProjectionDocument) string

func SnapshotDigest

func SnapshotDigest(s FactSnapshot) string

SnapshotDigest covers the immutable selection payload. Creation revision and authorization receipts are retained separately from this canonical content digest.

func SortTimeline

func SortTimeline(entries []Acceptance)

func ValidAttestationTombstone

func ValidAttestationTombstone(a Attestation, tenant, id string) bool

func ValidCalculationTombstone

func ValidCalculationTombstone(r CalculationRecord, tenant, id string) bool

ValidCalculationTombstone rejects content smuggled into a marked envelope.

func ValidConversationTombstone

func ValidConversationTombstone(r ConversationRecord, tenant, id string) bool

func ValidDecisionTombstone

func ValidDecisionTombstone(r DecisionRecord, tenant, id string) bool

ValidDecisionTombstone rejects content smuggled into a marked envelope.

func ValidExtractionTombstoneJSON

func ValidExtractionTombstoneJSON(kind string, raw []byte) bool

ValidExtractionTombstoneJSON checks the shape of content-free retained metadata. It is not authorization or validation of the original unavailable content.

func ValidID

func ValidID(s string) bool

func ValidateProjectionPage

func ValidateProjectionPage(page ProjectionPage, after ProjectionCursor) error

ValidateProjectionPage checks scan progress independently of the retained document inventory. Skipped tombstones may advance the cursor past the last document, but no returned document may fall behind a previously scanned row.

Types

type Acceptance

type Acceptance struct {
	DependencyAuthorization []AuthorizationDecision `json:",omitempty"`
	State                   string
	VersionID               string
	Valid                   Interval
	PolicyID                string
	AttestationIDs          []string
	LedgerRevision          int64
}

type AcceptancePolicy

type AcceptancePolicy struct {
	Scope, ID                        string
	Mode                             string
	AcceptingServices, SourceClasses []string
	Required                         []AttestationRequirement
}

type ActiveProjection

type ActiveProjection struct {
	Generation string
	Epoch      int64
}

type Approval

type Approval struct {
	Command
	Scope, RecordID, VersionID string
	ExpectedRevision           int64
}

type ApprovedExtractor

type ApprovedExtractor struct {
	Profile  ExtractionProfile
	Provider ExtractionProvider
}

type ArchiveBatch

type ArchiveBatch struct {
	Manifest  ArchiveManifest
	Signature AuditSignature
}

type ArchiveCoverageReceipt

type ArchiveCoverageReceipt struct {
	Tenant, Scope, Stream, HeadDigest, KeyID string
	ThroughRevision                          int64
	VerifiedAt                               time.Time
}

ArchiveCoverageReceipt records a chain verification anchored to the export's tenant revision. It carries no archived event or other-scope metadata.

type ArchiveCoverageVerifier

type ArchiveCoverageVerifier interface {
	VerifyAuditCoverage(context.Context, string, string, int64) (ArchiveCoverageReceipt, error)
}

type ArchiveManifest

type ArchiveManifest struct {
	Authorization                    []AuthorizationDecision
	Schema, Encoding, Tenant, Stream string
	FromRevision, ThroughRevision    int64
	EventCount                       int
	Payload                          ObjectRef
	Previous                         *ObjectRef
}

type ArchivePayload

type ArchivePayload struct {
	Scopes  []string
	Event   Event
	Entries []AuditEntry
	Gaps    []AuditGap
}

type ArchiveSource

type ArchiveSource interface {
	ArchivePayload(context.Context, Delivery) (ArchivePayload, error)
}

type ArchiveStore

type ArchiveStore interface {
	Put(context.Context, string, string, []byte) (ObjectRef, error)
	Load(context.Context, string, string) (ObjectRef, []byte, error)
	Read(context.Context, string, ObjectRef) ([]byte, error)
}

ArchiveStore is separately administered immutable object storage. Put is create-once by logical key, returning the same version on identical retries. Digest covers plaintext; Version identifies immutable encrypted stored bytes.

type ArtifactReference

type ArtifactReference struct{ EvidenceID, Digest string }

type Attestation

type Attestation struct {
	PayloadDisposed                                                 bool                   `json:",omitempty"`
	DisposedPayloadDigest                                           string                 `json:",omitempty"`
	RecordedAt                                                      *time.Time             `json:",omitempty"`
	ReviewAuthorization                                             *AuthorizationDecision `json:",omitempty"`
	Recorder                                                        *Caller                `json:",omitempty"`
	Delegation                                                      *AttestationDelegation `json:",omitempty"`
	EvidenceAuthorization                                           *AuthorizationDecision `json:",omitempty"`
	Confirmation                                                    *ClientConfirmation    `json:",omitempty"`
	ID, Scope, RecordID, VersionID, ContentDigest, Kind, EvidenceID string
	Attestor                                                        Caller
	ExpiresAt                                                       *time.Time
}

func AttestationTombstone

func AttestationTombstone(a Attestation) Attestation

AttestationTombstone retains exact version/evidence binding and provenance while omitting confirmation presentation details and delegated proof content.

type AttestationDelegation

type AttestationDelegation struct {
	Receipt       AttestationIdentityReceipt
	Authorization []AuthorizationDecision
}

type AttestationDisposalRequest

type AttestationDisposalRequest struct {
	Command
	Kind, Scope, RecordID, VersionID, AttestationID, PolicyID, Jurisdiction, Purpose, Reason string
}

AttestationDisposalRequest selects one fact or memory attestation payload. Structural identity and the tombstone remain after disposal.

type AttestationDisposalTx

type AttestationDisposalTx interface {
	DisposeAttestation(context.Context, AttestationDisposalRequest) (int64, error)
}

type AttestationIdentityOptions

type AttestationIdentityOptions struct {
	Verifier                      AttestationIdentityVerifier
	Authority                     string
	Timeout, MaxAuthenticationAge time.Duration
}

type AttestationIdentityReceipt

type AttestationIdentityReceipt struct {
	Authority, BindingID, RequestDigest    string
	Attestor                               Caller
	AuthenticatedAt, VerifiedAt, ExpiresAt time.Time
}

type AttestationIdentityRequest

type AttestationIdentityRequest struct {
	Recorder Caller
	Request  DelegatedAttestationRequest
}

The verifier must authenticate the grant and bind ALL request fields, including actor, tenant, scope, command, exact version/digest, artifacts and timestamps. Returning the request's claimed identity without independent verification is unsafe.

type AttestationIdentityVerifier

type AttestationIdentityVerifier interface {
	VerifyAttestationIdentity(context.Context, AttestationIdentityRequest) (AttestationIdentityReceipt, error)
}

type AttestationRequest

type AttestationRequest struct {
	Command
	Attestation Attestation
}

type AttestationRequirement

type AttestationRequirement struct {
	RequireExpiry bool  `json:",omitempty"`
	MaxAgeSeconds int64 `json:",omitempty"`
	Kind          string
	Principals    []string
}

type AuditBundle

type AuditBundle struct {
	Manifest  AuditManifest
	Entries   []AuditEntry
	Signature AuditSignature
}

type AuditEntry

type AuditEntry struct {
	Kind, ID string
	Payload  json.RawMessage
}

type AuditExportJob

type AuditExportJob struct {
	ID              string
	Caller          Caller
	Request         AuditExportRequest
	CreatedRevision int64
	State           string
	Fence           int64
	LeaseUntil      *time.Time
}

type AuditExportQuery

type AuditExportQuery struct{ ID, Scope, Purpose string }

type AuditExportRequest

type AuditExportRequest struct {
	Command
	Scope           string
	IncludeEvidence bool
}

type AuditExportResult

type AuditExportResult struct {
	ID, State                          string
	CreatedRevision, CompletedRevision int64
	Artifact                           ObjectRef
	Bundle                             *AuditBundle
}

type AuditExportRunner

type AuditExportRunner interface {
	RunAuditExport(context.Context, Caller, AuditExportQuery) (AuditExportResult, error)
}

type AuditGap

type AuditGap struct{ Kind, ID, Reason string }

type AuditManifest

type AuditManifest struct {
	SchemaVersion, Encoding, Tenant, Scope, ExportID string
	ThroughRevision                                  int64
	EntryCount                                       int
	Entries                                          []AuditManifestEntry
	Gaps                                             []AuditGap
	Authorization                                    []AuthorizationDecision
	ArchiveCoverage                                  *ArchiveCoverageReceipt `json:",omitempty"`
}

type AuditManifestEntry

type AuditManifestEntry struct{ Kind, ID, Digest string }

type AuditOptions

type AuditOptions struct {
	Signer          AuditSigner
	ArchiveCoverage ArchiveCoverageVerifier
}

type AuditSignature

type AuditSignature struct {
	Algorithm, KeyID string
	Bytes            []byte
}

type AuditSigner

type AuditSigner interface {
	Sign(context.Context, []byte) (AuditSignature, error)
}

type AuditTx

AuditTx keeps business receipts and export completion in the same append transaction.

type AuthorizationDecision

type AuthorizationDecision struct {
	Allowed                             bool
	ModelID, ContextDigest, Consistency string
	CheckedAt                           time.Time
	Request                             AuthorizationRequest
}

type AuthorizationRequest

type AuthorizationRequest struct {
	Caller                                    Caller
	Scope, Permission, Purpose, CorrelationID string
}

type Authorizer

type Authorizer interface {
	Check(context.Context, AuthorizationRequest) (AuthorizationDecision, error)
}

type CalculationDisposalRequest

type CalculationDisposalRequest struct {
	Command
	CalculationID, Reason string
	Bindings              []CalculationRetentionBinding
}

CalculationDisposalRequest selects independently governed scope policies.

type CalculationQuery

type CalculationQuery struct{ ID, Purpose string }

type CalculationReceipt

type CalculationReceipt struct {
	Command
	Scope, SnapshotID, ApplicationID, ExternalRunID                                      string
	MethodID, MethodVersion, ExecutableDigest, ConfigurationDigest, NormalizationVersion string
	ReferenceSnapshotIDs                                                                 []string
	Input, Output                                                                        ArtifactReference
	StartedAt, CompletedAt                                                               time.Time
	Outcome                                                                              string
}

CalculationReceipt reports an externally executed run; the engine never executes it.

type CalculationRecord

type CalculationRecord struct {
	PayloadDisposed                    bool `json:",omitempty"`
	Authorization                      []AuthorizationDecision
	ID, Tenant, Digest, SnapshotDigest string
	Caller                             Caller
	Receipt                            CalculationReceipt
	LedgerRevision                     int64
}

func CalculationTombstone

func CalculationTombstone(r CalculationRecord) CalculationRecord

CalculationTombstone retains identity, lineage and integrity digests without method metadata, runtime configuration identity or execution details.

type CalculationRetentionBinding

type CalculationRetentionBinding struct{ Scope, PolicyID, Jurisdiction string }

type Caller

type Caller struct {
	Tenant, Principal, Initiator string
	Service                      bool
}

func (Caller) Human

func (c Caller) Human() string

type ChangesQuery

type ChangesQuery struct {
	Scope, Purpose string
	AfterRevision  int64
	Limit          int
}

type ChangesResult

type ChangesResult struct {
	Events                        []Event
	ThroughRevision, NextRevision int64
}

type ChangesTx

type ChangesTx interface {
	Tx
	Changes(context.Context, string, int64, int64, int) ([]Event, error)
}

type ClientConfirmation

type ClientConfirmation struct {
	Presentation, Response   ArtifactReference
	PresentationVersion      string
	PresentedAt, RespondedAt time.Time
}

ClientConfirmation retains the application's presentation and affirmative response for the attestation's exact record/version/content digest. The trusted attestor binds their meaning; the engine does not interpret PDFs, images, or natural language as consent.

type Command

type Command struct{ Key, Purpose, CorrelationID string }

type CommitResult

type CommitResult struct {
	RecordKind                     string `json:",omitempty"`
	ContentDigest                  string
	ID, RecordID, VersionID        string
	StreamRevision, LedgerRevision int64
}

type ConsumerKey

type ConsumerKey struct{ Tenant, Consumer string }

ConsumerKey is trusted host configuration, never unchecked client input. Each consumer receives the complete tenant stream from revision one.

type ConsumerStatus

type ConsumerStatus struct {
	Key                   ConsumerKey
	AcknowledgedRevision  int64
	State                 string
	Fence                 int64
	Attempts, MaxAttempts int
	LeaseUntil            *time.Time
	AvailableAt           time.Time
	LastFailureCode       string
}

type ContextArchiveOptions

type ContextArchiveOptions struct {
	Stream              string
	MaxPendingRevisions int64
	Progress            OutboxProgressReader
}

ContextArchiveOptions is trusted host policy for all context deliveries on an engine. Progress must read the configured archive consumer's ledger domain.

type ContextArchiveReceipt

type ContextArchiveReceipt struct {
	Stream                                                    string
	MaxPendingRevisions, LedgerRevision, AcknowledgedRevision int64
	CheckedAt                                                 time.Time
}

ContextArchiveReceipt records the preparation-time policy check. It is not a signed archive-head proof; current delivery is rechecked independently.

type ContextDisposalRequest

type ContextDisposalRequest struct {
	Command
	ContextID, Reason string
	Bindings          []ContextRetentionBinding
}

type ContextDisposalTx

type ContextDisposalTx interface {
	DisposeContext(context.Context, ContextDisposalRequest) error
}

ContextDisposalTx adapters must serialize disposal with new references, scope holds, exports and archive reads, and retain an immutable tombstone.

type ContextManifest

type ContextManifest struct {
	PayloadDisposed                                      bool                   `json:",omitempty"`
	Archive                                              *ContextArchiveReceipt `json:",omitempty"`
	ID, Tenant, Scope                                    string
	Caller                                               Caller
	Request                                              ContextRequest
	CanonicalVersion, RedactionVersion, QueryReference   string
	Retrieval                                            RetrievalIdentity
	Items                                                []RecallItem
	Memories                                             []MemoryRecallItem `json:",omitempty"`
	Order                                                []VersionReference `json:",omitempty"`
	Rendered                                             []byte
	RenderedDigest, Digest                               string
	SelectionRevision, IndexedRevision, CreationRevision int64
	Incomplete                                           bool
	Authorization                                        []AuthorizationDecision
}

func ContextTombstone

func ContextTombstone(m ContextManifest) ContextManifest

ContextTombstone removes copied content while retaining the original digests, version inventory, scope boundaries and authorization provenance. It does not authorize disposal or validate its input. The returned metadata cannot be used to reconstruct or verify the original context content. Input is not mutated.

type ContextQuery

type ContextQuery struct{ ID, Purpose string }

type ContextRequest

type ContextRequest struct {
	Command
	Scope           string
	Query           RecallRequest
	IncludeMemories bool `json:",omitempty"`
}

type ContextRetentionBinding

type ContextRetentionBinding struct{ Scope, PolicyID, Jurisdiction string }

type ConversationDisposalRequest

type ConversationDisposalRequest struct {
	Command
	Scope, ConversationID, PolicyID, Jurisdiction, Purpose, Reason string
}

type ConversationDisposalTx

type ConversationDisposalTx interface {
	DisposeConversation(context.Context, ConversationDisposalRequest) error
}

type ConversationMessage

type ConversationMessage struct {
	ID, Revision, Speaker, SpeakerRole, SourceClass string
	SourceTime                                      time.Time
	MediaType, Classification, RetentionPolicy      string
	Object                                          ObjectRef
}

ConversationMessage points at already finalized immutable UTF-8 source bytes. SpeakerRole and SourceClass preserve source authority; neither proves truth.

type ConversationQuery

type ConversationQuery struct{ ID, Scope, Purpose string }

type ConversationRecord

type ConversationRecord struct {
	ID, Tenant, Digest string
	Caller             Caller
	Request            ConversationRequest
	EvidenceIDs        []string
	Authorization      []AuthorizationDecision
	LedgerRevision     int64
	PayloadDisposed    bool `json:",omitempty"`
}

func ConversationTombstone

func ConversationTombstone(r ConversationRecord) ConversationRecord

ConversationTombstone removes message references and object locators while retaining the conversation identity, original digest and source inventory.

type ConversationRequest

type ConversationRequest struct {
	Command
	Scope, SourceSystem, ConversationID, Revision, Timezone string
	Messages                                                []ConversationMessage
}

type ConversationTx

type ConversationTx interface {
	Tx
	Conversation(context.Context, string) (ConversationRecord, error)
	StageConversation(context.Context, ConversationRecord) error
}

type DecisionDisposalRequest

type DecisionDisposalRequest struct {
	Command
	DecisionID, Reason string
	Bindings           []DecisionRetentionBinding
}

DecisionDisposalRequest selects independently governed scope policies.

type DecisionQuery

type DecisionQuery struct{ ID, Purpose string }

type DecisionReceipt

type DecisionReceipt struct {
	Command
	Scope, ApplicationID, ExternalDecisionID                   string
	ContextID, SnapshotID, CalculationID                       string
	SelectedItems, UsedItems                                   []VersionReference
	MethodKind, MethodID, MethodVersion, TransformationVersion string
	Input, Output                                              ArtifactReference
	ModelRequest, ModelResponse, ActionReceipt                 *ArtifactReference
	DecidedAt                                                  time.Time
	Outcome                                                    string
}

type DecisionRecord

type DecisionRecord struct {
	PayloadDisposed                                     bool `json:",omitempty"`
	ID, Tenant, Digest, SourceDigest, CalculationDigest string
	Caller                                              Caller
	Receipt                                             DecisionReceipt
	Scopes                                              []string
	LedgerRevision                                      int64
	Authorization                                       []AuthorizationDecision
}

func DecisionTombstone

func DecisionTombstone(r DecisionRecord) DecisionRecord

DecisionTombstone retains identity, declared-use lineage and integrity digests while removing method, transformation, execution-time and outcome metadata.

type DecisionRetentionBinding

type DecisionRetentionBinding struct{ Scope, PolicyID, Jurisdiction string }

type DelegatedAttestationRequest

type DelegatedAttestationRequest struct {
	AttestationRequest
	GrantID string
}

GrantID is an opaque reference, never a bearer token or raw identity assertion.

type Delivery

type Delivery struct {
	Key        ConsumerKey
	Event      Event
	Fence      int64
	Attempt    int
	LeaseUntil time.Time
}

type DisposalBatchRequest

type DisposalBatchRequest struct {
	Command
	Scope, Reason string
	Evidence      []EvidenceDisposalRequest     `json:",omitempty"`
	Conversations []ConversationDisposalRequest `json:",omitempty"`
	Attestations  []AttestationDisposalRequest  `json:",omitempty"`
	Decisions     []DecisionDisposalRequest     `json:",omitempty"`
	Calculations  []CalculationDisposalRequest  `json:",omitempty"`
	Snapshots     []SnapshotDisposalRequest     `json:",omitempty"`
	Contexts      []ContextDisposalRequest      `json:",omitempty"`
	Versions      []VersionDisposalRequest
	Extractions   []ExtractionDisposalRequest
}

DisposalBatchRequest explicitly selects related evidence lineages, versions, extraction artifacts and other retained payloads. Child commands/reasons may be empty or equal to the parent; the service normalizes them to the parent before authorization and replay checks. Other retained copies remain blockers. Index removal remains asynchronous.

func (DisposalBatchRequest) Scopes

func (r DisposalBatchRequest) Scopes() []string

Scopes includes every scope carried by a batch for audit/archive disclosure.

func (DisposalBatchRequest) SelectionCount

func (r DisposalBatchRequest) SelectionCount() int

SelectionCount bounds the complete transaction across all artifact classes.

type DisposalBatchResult

type DisposalBatchResult struct {
	VersionRevisions     []int64
	AttestationRevisions []int64
}

type DisposalBatchTx

type DisposalBatchTx interface {
	DisposeBatch(context.Context, DisposalBatchRequest) (DisposalBatchResult, error)
}

DisposalBatchTx must remove the complete authorized selection atomically, including all individual policy/age/hold/reference checks. Returned version and attestation revisions correspond to their selections in input order. Any error must abort the transaction.

type Embedder

type Embedder interface {
	Embed(context.Context, string) ([]float32, error)
}

type EngineOptions

type EngineOptions struct {
	ProjectionCleanup       ProjectionCleanupOptions
	ContextArchive          *ContextArchiveOptions
	Telemetry               TelemetryOptions
	Operations              OperationsOptions
	RedactionPolicyVersions []string
	AttestationIdentity     AttestationIdentityOptions
	Extraction              ExtractionOptions
	Audit                   AuditOptions
	Retrieval               RetrievalOptions
	Reads                   ReadOptions
}

EngineOptions composes optional capabilities without global configuration. Hosts own every injected connection, provider, signing key and worker lifecycle.

type Event

type Event struct {
	RefreshSweep                         *MemoryRefreshSweep `json:",omitempty"`
	RecordKind                           string              `json:",omitempty"`
	DefinitionPredicate                  string              `json:",omitempty"`
	EntityID, Reason                     string
	Affected                             *Interval
	ReplacedVersionIDs                   []string
	ID, Type, Scope, RecordID, VersionID string
	StreamRevision, LedgerRevision       int64
	Caller                               Caller
	Command                              Command
	Authorization                        AuthorizationDecision
	RecordedAt                           time.Time
}

type Evidence

type Evidence struct {
	Derivation                                                                                                              *EvidenceDerivation `json:",omitempty"`
	ID, Scope, SourceSystem, SourceObject, SourceRevision, Speaker, SourceClass, MediaType, Classification, RetentionPolicy string
	SourceTime                                                                                                              time.Time
	Object                                                                                                                  ObjectRef
}

func MessageEvidence

func MessageEvidence(tenant string, r ConversationRequest, m ConversationMessage) Evidence

type EvidenceContent

type EvidenceContent struct {
	Metadata Evidence
	Bytes    []byte
}

type EvidenceCopyRange

type EvidenceCopyRange struct {
	OriginalStart, OriginalEnd, DerivedStart int
}

EvidenceCopyRange maps an unchanged derivative segment to original bytes.

type EvidenceDerivation

type EvidenceDerivation struct {
	ParentEvidenceID, TransformationVersion, PolicyVersion string
	Ranges                                                 []EvidenceCopyRange
}

EvidenceDerivation is server-validated omission provenance. Classification, source authority and retention policy are inherited from the original.

func (EvidenceDerivation) OriginalSpan

func (d EvidenceDerivation) OriginalSpan(span SourceSpan) (SourceSpan, error)

OriginalSpan translates a citation only when it fits within one unchanged segment. It never joins text across an omission or cites inserted text.

type EvidenceDisposalRequest

type EvidenceDisposalRequest struct {
	// DerivativeEvidenceIDs explicitly selects the complete direct derivative set.
	// Empty preserves single-object disposal; custom adapters must implement EvidenceLineageDisposalTx.
	DerivativeEvidenceIDs []string `json:",omitempty"`
	// DeferObjectDeletion is service-owned and excluded from command identity.
	// External stores are deleted by a retryable outbox worker after the ledger tombstone commits.
	DeferObjectDeletion bool `json:"-"`
	Command
	Scope, EvidenceID, PolicyID, Jurisdiction, Reason string
}

type EvidenceLineageDisposalTx

type EvidenceLineageDisposalTx interface {
	DisposeEvidenceLineage(context.Context, EvidenceDisposalRequest) error
}

EvidenceLineageDisposalTx atomically disposes an original and its explicitly enumerated derivatives under the same retention policy and scope.

type EvidenceQuery

type EvidenceQuery struct{ ID, Scope, Purpose string }

EvidenceQuery includes the claimed scope so authorization can precede lookup. Object-store credentials are never returned by evidence access operations.

type EvidenceRequest

type EvidenceRequest struct {
	Command
	Evidence Evidence
}

type EvidenceStore

type EvidenceStore interface {
	Read(context.Context, string, ObjectRef) ([]byte, error)
}

EvidenceStore reads only immutable references. Implementations must enforce tenant isolation. Temporary dependency outages should wrap ErrUnavailable; missing or corrupt content must not use that classification. Reads must honor context cancellation.

type EvidenceVersionDeleter

type EvidenceVersionDeleter interface {
	DeleteEvidenceVersion(context.Context, string, ObjectRef) error
}

EvidenceVersionDeleter removes one exact immutable object version. It must be tenant-isolated, idempotent, and treat an already missing version as success. The engine invokes it only from a post-commit disposal worker.

type ExtractedProposal

type ExtractedProposal struct {
	RecordKind          string `json:",omitempty"`
	Candidate           int
	RecordID, VersionID string
}

type ExtractionAdmission

type ExtractionAdmission struct {
	JobStatus
	Reservation ExtractionReservation
}

type ExtractionAttempt

type ExtractionAttempt struct {
	PayloadDisposed                                                    bool                   `json:",omitempty"`
	Reservation                                                        *ExtractionReservation `json:",omitempty"`
	ContentScopes                                                      []string               `json:",omitempty"`
	RefreshScopes                                                      []string               `json:",omitempty"`
	ID, Tenant, Scope, JobID, OwnerNonce, ProfileDigest, RequestDigest string
	Caller                                                             Caller
	Fence, LedgerRevision                                              int64
	LeaseUntil                                                         time.Time
	Number                                                             int
	StartedAt                                                          time.Time
	RequestBytes                                                       []byte
	Authorization                                                      []AuthorizationDecision
}

func ExtractionAttemptTombstone

func ExtractionAttemptTombstone(a ExtractionAttempt) ExtractionAttempt

ExtractionAttemptTombstone removes the provider request. Original request digests, admission reservations, authorization and attempt identity remain.

type ExtractionCandidate

type ExtractionCandidate struct {
	Subject, Predicate, Discriminator, SchemaVersion string
	Value                                            Value
	Valid                                            Interval
	Sources                                          []SourceSpan
	Uncertainty, Rationale                           string
	Confidence                                       float64
}

type ExtractionChunk

type ExtractionChunk struct {
	InputRanges []ExtractionInputRange
	SourceBytes int
}

type ExtractionChunkPlan

type ExtractionChunkPlan struct {
	RedactedEvidenceIDs                                        []string `json:",omitempty"`
	Version, Tenant, Scope, ConversationID, ConversationDigest string
	ProfileID, ProfileDigest                                   string
	MaxSourceBytes                                             int
	Chunks                                                     []ExtractionChunk
	ExcludedRanges                                             []ExtractionInputRange
}

ExtractionChunkPlan is an authorized preview, not a persisted job or a quota reservation. StartExtraction rechecks authorization and current profile approval.

type ExtractionChunkQuery

type ExtractionChunkQuery struct {
	RedactedEvidenceIDs                       []string
	Scope, ConversationID, ProfileID, Purpose string
	InputRanges                               []ExtractionInputRange
	MaxSourceBytes                            int
}

ExtractionChunkQuery plans original evidence ranges without creating jobs or consuming provider quota. MaxSourceBytes excludes the serialized envelope.

type ExtractionCostBudget

type ExtractionCostBudget struct {
	Unit                   string
	DailyLimit, PerAttempt int64
}

Cost units are host-approved integer accounting units, e.g. USD micro-units. Amounts are conservative reservations, not provider billing measurements.

type ExtractionDisposalRequest

type ExtractionDisposalRequest struct {
	Command
	JobID, Reason string
	Bindings      []ExtractionRetentionBinding
}

ExtractionDisposalRequest selects a terminal job and all of its retained attempts/results, including attempts from earlier retries.

type ExtractionDisposalTx

type ExtractionDisposalTx interface {
	DisposeExtraction(context.Context, ExtractionDisposalRequest) error
}

ExtractionDisposalTx must atomically verify terminal state, complete content scope/input inventories, class-specific policy ages, holds, live derivatives, exports and archive progress before retaining tombstones and deleting payloads. Implementations must serialize with execution, retries and new references. This interface grants no authority to dispose source facts, memories or evidence.

type ExtractionInput

type ExtractionInput struct {
	PayloadRedactionVersion string                   `json:",omitempty"`
	PayloadOmittedPaths     []string                 `json:",omitempty"`
	PayloadRanges           []ExtractionPayloadRange `json:",omitempty"`

	InputSelectionVersion                                                          string                 `json:",omitempty"`
	ExcludedRanges                                                                 []ExtractionInputRange `json:",omitempty"`
	Schema, Tenant, JobID, AttemptID, ConversationID, ConversationDigest, Timezone string
	Profile                                                                        ExtractionProfile
	Subjects                                                                       []string
	Predicates                                                                     []PredicateVersion
	Messages                                                                       []ExtractionInputMessage
	OmittedRanges                                                                  []string
	RedactionVersion                                                               string
	Refresh                                                                        *MemoryRefreshInput      `json:",omitempty"`
	MemoryTargets                                                                  []MemoryExtractionTarget `json:",omitempty"`
	MemoryTypes                                                                    []MemoryType             `json:",omitempty"`
	DependencyVersions                                                             []Version                `json:",omitempty"`
}

type ExtractionInputMessage

type ExtractionInputMessage struct {
	DerivativeEvidenceID, DerivativeDigest        string `json:",omitempty"`
	DerivativeStart                               int    `json:",omitempty"`
	SourceStart                                   int    `json:",omitempty"`
	EvidenceID, Speaker, SpeakerRole, SourceClass string
	SourceTime                                    time.Time
	Content                                       string
}

type ExtractionInputRange

type ExtractionInputRange struct {
	EvidenceID string
	Start, End int
}

ExtractionInputRange uses half-open UTF-8 byte offsets in original evidence.

type ExtractionIssue

type ExtractionIssue struct {
	Candidate int
	Code      string
}

type ExtractionJob

type ExtractionJob struct {
	PayloadDisposed           bool `json:",omitempty"`
	ID, Tenant, ProfileDigest string
	Caller                    Caller
	Request                   ExtractionRequest
	Profile                   ExtractionProfile
	Predicates                []PredicateVersion
	RefreshScopes             []string `json:",omitempty"`
	Authorization             []AuthorizationDecision
	CreatedRevision           int64
	MemoryTypes               []MemoryType `json:",omitempty"`
	DependencyVersions        []Version    `json:",omitempty"`
	ContentScopes             []string     `json:",omitempty"`
}

func ExtractionJobTombstone

func ExtractionJobTombstone(j ExtractionJob) ExtractionJob

ExtractionJobTombstone removes copied content from a scheduling artifact while preserving IDs, scopes, profile/schema bindings and original digests. It does not authorize disposal or validate the input. The input is not mutated.

type ExtractionOptions

type ExtractionOptions struct {
	// ScheduleOnly allows profile validation and durable job creation without a
	// provider. Profiles must omit Provider; RunExtraction is disabled in this host.
	// A separate execution host must configure the same profile digest and budgets.
	ScheduleOnly           bool
	CostUnit               string
	DailyCostBudgetUnits   int64
	Profiles               []ApprovedExtractor
	MaxConcurrentPerTenant int
	DailyTokenBudget       int64
}

type ExtractionOutput

type ExtractionOutput struct {
	Candidates []ExtractionCandidate `json:"candidates"`
}

type ExtractionPayloadRange

type ExtractionPayloadRange struct {
	Path       string
	Start, End int
}

ExtractionPayloadRange selects a half-open UTF-8 byte range in a specific provider-input string, addressed by its canonical JSON pointer.

type ExtractionPayloadRedaction

type ExtractionPayloadRedaction struct {
	PolicyVersion               string
	DependencyPayloads          bool
	OriginalMemoryPayload       bool
	RefreshEvidence             bool
	DependencyPayloadRanges     bool `json:",omitempty"`
	OriginalMemoryPayloadRanges bool `json:",omitempty"`
	RefreshEvidenceRanges       bool `json:",omitempty"`
}

ExtractionPayloadRedaction applies field-omit-v1 to provider input only. The policy and selected fields are included in the approved profile digest.

type ExtractionProfile

type ExtractionProfile struct {
	PayloadRedaction *ExtractionPayloadRedaction `json:",omitempty"`

	RedactionPolicyVersion                                                                       string `json:",omitempty"`
	InputSelectionVersion                                                                        string `json:",omitempty"`
	CostUnit                                                                                     string `json:",omitempty"`
	MaxCostUnitsPerAttempt                                                                       int64  `json:",omitempty"`
	ID, ProviderID, RequestedModel, PromptVersion, PromptDigest, ParserVersion, ApplicationBuild string
	Prompt                                                                                       []byte
	Parameters                                                                                   json.RawMessage
	Timeout                                                                                      time.Duration
	MaxInputBytes, MaxOutputBytes, MaxCandidates, MaxAttempts                                    int
	MaxTokensPerAttempt                                                                          int64
	RetryDelay                                                                                   time.Duration
}

type ExtractionProvider

type ExtractionProvider interface {
	Extract(context.Context, []byte) (ExtractionResponse, error)
}

ExtractionProvider receives the exact retained request bytes. Implementations must honor cancellation and enforce transport response limits. It has no tools or ledger mutation capability through this interface.

type ExtractionRelation

type ExtractionRelation struct {
	Candidate                 int
	RecordID, VersionID, Kind string
}

type ExtractionRequest

type ExtractionRequest struct {
	RedactedEvidenceIDs   []string                 `json:",omitempty"`
	ExpectedProfileDigest string                   `json:",omitempty"`
	InputRanges           []ExtractionInputRange   `json:",omitempty"`
	PayloadRanges         []ExtractionPayloadRange `json:",omitempty"`
	Command
	Scope, ConversationID, ProfileID string
	Subjects                         []string
	Predicates                       []PredicateBinding
	Refresh                          *VersionReference        `json:",omitempty"`
	RefreshTrigger                   *MemoryRefreshTrigger    `json:",omitempty"`
	MemoryTargets                    []MemoryExtractionTarget `json:",omitempty"`
}

type ExtractionReservation

type ExtractionReservation struct {
	Day                       string
	Tokens, DailyTokenLimit   int64
	ConcurrentLimit           int
	CostUnit                  string `json:",omitempty"`
	CostUnits, DailyCostLimit int64  `json:",omitempty"`
}

type ExtractionResponse

type ExtractionResponse struct {
	ModelIdentity             string
	Body                      []byte
	InputTokens, OutputTokens int64
}

type ExtractionResult

type ExtractionResult struct {
	PayloadDisposed                                                                        bool     `json:",omitempty"`
	ContentScopes                                                                          []string `json:",omitempty"`
	RefreshScopes                                                                          []string `json:",omitempty"`
	AttemptID, JobID, Tenant, Scope, Outcome, ModelIdentity, RequestDigest, ResponseDigest string
	ResponseBytes                                                                          []byte
	ResponseComplete                                                                       bool
	InputTokens, OutputTokens                                                              int64
	Issues                                                                                 []ExtractionIssue
	Relations                                                                              []ExtractionRelation
	Proposals                                                                              []ExtractedProposal
	Authorization                                                                          []AuthorizationDecision
	CompletedAt                                                                            time.Time
	LedgerRevision                                                                         int64
}

func ExtractionResultTombstone

func ExtractionResultTombstone(r ExtractionResult) ExtractionResult

ExtractionResultTombstone removes retained response bytes, including truncated responses. ResponseComplete describes the original capture; PayloadDisposed states that those bytes are no longer available. Proposals and issue codes remain structural provenance. Digests are not anonymization.

type ExtractionRetentionBinding

type ExtractionRetentionBinding struct {
	Scope, JobPolicyID, RequestPolicyID, ResponsePolicyID, Jurisdiction string
}

ExtractionRetentionBinding selects independently governed scheduling, request, and response payload policies for one content scope.

type ExtractionRun

type ExtractionRun struct {
	Attempt ExtractionAttempt
	Result  *ExtractionResult
}

type ExtractionRunQuery

type ExtractionRunQuery struct{ ID, Scope, Purpose string }

type ExtractionRunRequest

type ExtractionRunRequest struct {
	Command
	ID, Scope string
}

type ExtractionRunTx

type ExtractionRunTx interface {
	ExtractionTx
	TemporalTx
	BeginExtraction(context.Context, string, string, int, int64, int64, time.Duration, ExtractionCostBudget) (ExtractionAdmission, error)
	FailExpiredExtraction(context.Context, string, int64) error
	RejectExtractionInput(context.Context, string) error
	StageExtractionAttempt(context.Context, ExtractionAttempt) error
	ExtractionAttempt(context.Context, string) (ExtractionAttempt, error)
	ExtractionResult(context.Context, string) (ExtractionResult, error)
	FinishExtraction(context.Context, string, string, int64, string, string, time.Duration) error
	StageExtractionResult(context.Context, ExtractionResult) error
}

type ExtractionRunner

type ExtractionRunner interface {
	GetJob(context.Context, Caller, JobQuery) (JobStatus, error)
	RunExtraction(context.Context, Caller, ExtractionRunRequest) (JobStatus, error)
}

ExtractionRunner is the authorized engine boundary used by explicit workers.

type ExtractionTx

type ExtractionTx interface {
	Tx
	StageExtractionJob(context.Context, ExtractionJob) error
	ExtractionJob(context.Context, string) (ExtractionJob, error)
	ExtractionJobStatus(context.Context, string) (JobStatus, error)
	RetryExtractionJob(context.Context, string, int64) error
}

type FactKey

type FactKey struct{ Scope, Subject, Predicate, Discriminator string }

type FactProposal

type FactProposal struct {
	Command
	Key              FactKey
	SchemaVersion    string
	Value            Value
	Valid            Interval
	Sources          []SourceSpan
	ExpectedRevision int64
}

type FactQuery

type FactQuery struct {
	KnownAt           *time.Time
	Purpose           string
	Key               FactKey
	ValidAt           time.Time
	KnowledgeRevision int64
}

type FactResult

type FactResult struct {
	State                          string
	RecordID, VersionID            string
	Value                          *Value
	LedgerRevision, StreamRevision int64
}

type FactSnapshot

type FactSnapshot struct {
	PayloadDisposed                     bool `json:",omitempty"`
	ID                                  string
	Tenant                              string
	Caller                              Caller
	Purpose                             string
	ValidAt, EvaluatedAt                time.Time
	SelectionRevision, CreationRevision int64
	Items                               []SnapshotItem
	CanonicalVersion, Digest            string
	Authorization                       []AuthorizationDecision
}

type FactSnapshotRequest

type FactSnapshotRequest struct {
	Command
	Selectors         []FactKey
	ValidAt           time.Time
	KnowledgeRevision int64
}

type FactsPage

type FactsPage struct {
	Items          []SnapshotItem
	LedgerRevision int64
	EvaluatedAt    time.Time
	NextPageToken  string
}

type FactsQuery

type FactsQuery struct {
	Scope, Subject, Predicate, Purpose string
	ValidAt                            time.Time
	KnowledgeRevision                  int64
	KnownAt                            *time.Time
	Limit                              int
	PageToken                          string
}

type GenerationKey

type GenerationKey struct{ Tenant, Generation string }

type HistoryPage

type HistoryPage struct {
	Events                         []Event
	LedgerRevision, StreamRevision int64
	NextPageToken                  string
}

type HistoryPageQuery

type HistoryPageQuery struct {
	HistoryQuery
	Limit     int
	PageToken string
}

HistoryPageQuery orders one record's immutable events by stream revision.

type HistoryPageTx

type HistoryPageTx interface {
	Tx
	HistoryPage(context.Context, string, int64, int64, int) ([]Event, error)
}

type HistoryQuery

type HistoryQuery struct{ Scope, RecordID, Purpose string }

type HistoryResult

type HistoryResult struct {
	LedgerRevision int64
	Events         []Event
}

type IdentityQuery

type IdentityQuery struct {
	Scope, ID, Purpose string
	Revision           int64
}

Revision zero selects current metadata; positive revisions select immutable history.

type IdentityTx

type IdentityTx interface {
	Tx
	StageScope(context.Context, ScopeVersion, int64) error
	StageSubject(context.Context, SubjectVersion, int64) error
	ScopeIdentity(context.Context, string, int64) (ScopeVersion, error)
	SubjectIdentity(context.Context, string, string, int64) (SubjectVersion, error)
	LookupSubject(context.Context, string, string, string) (SubjectVersion, error)
}

type Interval

type Interval struct {
	From *time.Time
	To   *time.Time
}

func Intersect

func Intersect(a, b Interval) Interval

func Subtract

func Subtract(original, cut Interval) []Interval

Subtract returns the unaffected pieces of a known-start interval.

func (Interval) Contains

func (i Interval) Contains(t time.Time) bool

func (Interval) Overlaps

func (i Interval) Overlaps(j Interval) bool

func (Interval) Validate

func (i Interval) Validate() error

type JobQuery

type JobQuery struct{ ID, Scope, Purpose string }

type JobRetryRequest

type JobRetryRequest struct {
	Command
	ID, Scope     string
	ExpectedFence int64
}

type JobStatus

type JobStatus struct {
	ID, Scope, Kind, State, AttemptID, LastFailureCode, Purpose string
	Attempts, MaxAttempts                                       int
	Fence, CreatedRevision                                      int64
	AvailableAt                                                 time.Time
	LeaseUntil                                                  *time.Time
}

type Ledger

type Ledger interface {
	Transact(context.Context, string, func(Tx) error) error
}

Ledger owns transaction boundaries. Callbacks must not perform network calls.

type LegalHoldRequest

type LegalHoldRequest struct {
	Command
	ID, Scope, Reason string
}

type LifecycleChange

type LifecycleChange struct {
	Approval
	Valid  Interval
	Reason string
}

LifecycleChange applies to an exact accepted version over a bounded interval. RejectFact ignores Valid and only allows versions still in proposal state.

type MemoriesPage

type MemoriesPage struct {
	Items          []MemoryListItem
	LedgerRevision int64
	EvaluatedAt    time.Time
	NextPageToken  string
}

type MemoriesQuery

type MemoriesQuery struct {
	Scope, Subtype, Purpose string
	ValidAt                 time.Time
	KnowledgeRevision       int64
	KnownAt                 *time.Time
	Limit                   int
	PageToken               string
}

MemoriesQuery lists one scope's memories as GetMemory would resolve each at ValidAt and the selected knowledge revision. Subtype is an optional filter.

type MemoryDependency

type MemoryDependency struct {
	Scope, RecordID, VersionID, ContentDigest string
	// Label preserves the application's distinction between assertions and uncertainty.
	Label string
}

type MemoryExtractionCandidate

type MemoryExtractionCandidate struct {
	ID, Subtype, SchemaVersion, Body string
	Valid                            Interval
	Sources                          []SourceSpan
	Uncertainty, Rationale           string
	Confidence                       float64
}

type MemoryExtractionOutput

type MemoryExtractionOutput struct {
	Candidates []MemoryExtractionCandidate `json:"candidates"`
}

type MemoryExtractionTarget

type MemoryExtractionTarget struct {
	ID, Subtype, SchemaVersion string
	Dependencies               []MemoryDependency
}

type MemoryExtractionTx

type MemoryExtractionTx interface {
	MemoryLifecycleTx
	MemoryVersions(context.Context, string, int64) ([]MemoryVersion, error)
}

type MemoryHistoryPageTx

type MemoryHistoryPageTx interface {
	Tx
	MemoryHistoryPage(context.Context, string, int64, int64, int) ([]Event, error)
}

type MemoryKey

type MemoryKey struct{ Scope, ID string }

MemoryKey is an explicit application-issued identity, independent of fact keys.

type MemoryLifecycleTx

type MemoryLifecycleTx interface {
	MemoryTx
	TemporalTx
	MemoryTimeline(context.Context, string, int64) ([]Acceptance, error)
	StageMemoryTimeline(context.Context, string, []Acceptance) error
	MemoryRejected(context.Context, string, string, int64) (bool, error)
	MemoryHasAcceptance(context.Context, string, string) (bool, error)
	StageMemoryRejection(context.Context, string, string) error
	MemoryStreamRevisionAt(context.Context, string, int64) (int64, error)
	MemoryAttestations(context.Context, string, int64) ([]Attestation, error)
	StageMemoryAttestation(context.Context, Attestation) error
}

type MemoryListItem

type MemoryListItem struct {
	Key    MemoryKey
	Memory MemoryResult
}

type MemoryProjection

type MemoryProjection struct {
	Key                          MemoryKey
	Subtype, SchemaVersion, Body string
	Dependencies                 []MemoryDependency
}

type MemoryProposal

type MemoryProposal struct {
	Command
	Key                          MemoryKey
	Subtype, SchemaVersion, Body string
	Valid                        Interval
	Sources                      []SourceSpan
	Dependencies                 []MemoryDependency
	ExpectedRevision             int64
}

type MemoryQuery

type MemoryQuery struct {
	Key               MemoryKey
	Purpose           string
	ValidAt           time.Time
	KnowledgeRevision int64
	KnownAt           *time.Time
}

type MemoryRecallItem

type MemoryRecallItem struct {
	Key    MemoryKey
	Memory MemoryResult
	Score  float64
}

type MemoryRecallResult

type MemoryRecallResult struct {
	Items                           []MemoryRecallItem
	Generation                      string
	LedgerRevision, IndexedRevision int64
	Incomplete                      bool
}

type MemoryRefreshBinding

type MemoryRefreshBinding struct{ Scope, ProfileID string }

type MemoryRefreshDependency

type MemoryRefreshDependency struct {
	Scope, RecordID string
	Timeline        []Acceptance
	Versions        []Version
}

type MemoryRefreshInput

type MemoryRefreshInput struct {
	Schema                         string
	Original                       MemoryVersion
	Definition                     MemoryType
	LedgerRevision, StreamRevision int64
	Dependencies                   []MemoryRefreshDependency
	Evidence                       []ExtractionInputMessage
}

type MemoryRefreshOutput

type MemoryRefreshOutput struct {
	Body          string
	Dependencies  []MemoryDependency
	DeclineReason string
}

type MemoryRefreshRequest

type MemoryRefreshRequest struct {
	Trigger       *MemoryRefreshTrigger    `json:",omitempty"`
	PayloadRanges []ExtractionPayloadRange `json:",omitempty"`
	Command
	Scope, RecordID, VersionID, ProfileID string
}

MemoryRefreshRequest binds an asynchronous replacement proposal to an exact accepted memory version. The job never accepts or supersedes it automatically.

type MemoryRefreshScan

type MemoryRefreshScan struct {
	Scope, Purpose string
	Trigger        MemoryRefreshTrigger
	AfterVersionID string
	Limit          int
}

type MemoryRefreshScanResult

type MemoryRefreshScanResult struct{ Versions []VersionReference }

type MemoryRefreshScanTx

type MemoryRefreshScanTx interface {
	Tx
	MemoryRefreshEvent(context.Context, MemoryRefreshTrigger) (Event, error)
	MemoryRefreshDependents(context.Context, string, string, int64, string, int) ([]VersionReference, error)
}

type MemoryRefreshScheduler

type MemoryRefreshScheduler interface {
	ScanMemoryRefresh(context.Context, Caller, MemoryRefreshScan) (MemoryRefreshScanResult, error)
	StartMemoryRefresh(context.Context, Caller, MemoryRefreshRequest) (JobStatus, error)
}

type MemoryRefreshSweep

type MemoryRefreshSweep struct {
	Stream, ProfileID, ProfileDigest string
	ScheduledFor                     time.Time
	Interval                         time.Duration
}

type MemoryRefreshSweepRequest

type MemoryRefreshSweepRequest struct {
	Command
	Scope, Stream, ProfileID string
	ScheduledFor             time.Time
	Interval                 time.Duration
}

type MemoryRefreshSweepStarter

type MemoryRefreshSweepStarter interface {
	StartMemoryRefreshSweep(context.Context, Caller, MemoryRefreshSweepRequest) (CommitResult, error)
}

type MemoryRefreshTrigger

type MemoryRefreshTrigger struct {
	EventID        string
	LedgerRevision int64
}

type MemoryResult

type MemoryResult struct {
	State, RecordID, VersionID, Body string
	StreamRevision, LedgerRevision   int64
	Dependencies                     []MemoryDependency
}

type MemoryTx

type MemoryTx interface {
	Tx
	MemoryType(context.Context, string, string, string) (MemoryType, error)
	ActiveMemoryType(context.Context, string, string) (string, error)
	StageMemoryType(context.Context, MemoryType) error
	LockMemory(context.Context, MemoryKey) (Record, error)
	StageMemoryVersion(context.Context, MemoryVersion) error
	MemoryVersion(context.Context, string, string) (MemoryVersion, error)
}

type MemoryType

type MemoryType struct {
	Scope, Subtype, Version, PolicyID, Classification string
	Migration                                         *PredicateMigration `json:",omitempty"`
}

type MemoryTypeRequest

type MemoryTypeRequest struct {
	Command
	Definition MemoryType
}

type MemoryVersion

type MemoryVersion struct {
	PayloadDisposed                bool `json:",omitempty"`
	Authorization                  []AuthorizationDecision
	ID, RecordID, Digest, PolicyID string
	Proposal                       MemoryProposal
	Proposer                       Caller
	LedgerRevision                 int64
}

func MemoryVersionTombstone

func MemoryVersionTombstone(v MemoryVersion) MemoryVersion

MemoryVersionTombstone removes the body and source quotes while preserving dependency identities and their assertion/uncertainty labels. As with VersionTombstone, the original digest is provenance, not a digest of metadata.

type MemoryVersionQuery

type MemoryVersionQuery struct{ Scope, RecordID, VersionID, Purpose string }

type ObjectRef

type ObjectRef struct {
	Locator, Version, Digest string
	Size                     int64
}

type OperationsOptions

type OperationsOptions struct {
	Scope    string
	Store    RebuildStore
	Index    RebuildIndex
	Progress Outbox
}

OperationsOptions uses separately provisioned administrative ports. Scope is host-owned and grants tenant-wide projection operations through can_operate.

type OrphanEvidenceDisposalRequest

type OrphanEvidenceDisposalRequest struct {
	Command
	Scope, PolicyID, Jurisdiction, Reason string
	Object                                ObjectRef
}

OrphanEvidenceDisposalRequest selects exactly one immutable upload version. It can only delete an object that has never been registered as evidence.

type OrphanEvidenceDisposalTx

type OrphanEvidenceDisposalTx interface {
	DisposeOrphanEvidence(context.Context, OrphanEvidenceDisposalRequest) error
}

type OrphanEvidenceEngine

type OrphanEvidenceEngine interface {
	ScanOrphanEvidence(context.Context, Caller, OrphanEvidenceQuery) ([]ObjectRef, error)
	DisposeOrphanEvidence(context.Context, Caller, OrphanEvidenceDisposalRequest) (CommitResult, error)
}

type OrphanEvidenceQuery

type OrphanEvidenceQuery struct {
	Scope, PolicyID, Jurisdiction, Purpose string
	AfterLocator, AfterVersion             string
	Limit                                  int
}

OrphanEvidenceQuery is a bounded, live scan, not a deletion authorization. The optional cursor is the last locator/version pair returned by a prior page.

type OrphanEvidenceScannerTx

type OrphanEvidenceScannerTx interface {
	ScanOrphanEvidence(context.Context, OrphanEvidenceQuery) ([]ObjectRef, error)
}

type Outbox

type Outbox interface {
	RegisterConsumer(context.Context, ConsumerKey, int) error
	ClaimDelivery(context.Context, ConsumerKey, time.Duration) (Delivery, error)
	RenewDelivery(context.Context, Delivery, time.Duration) error
	AcknowledgeDelivery(context.Context, Delivery) error
	FailDelivery(context.Context, Delivery, time.Duration) error
	ConsumerStatus(context.Context, ConsumerKey) (ConsumerStatus, error)
	RetryConsumer(context.Context, ConsumerKey, int64) error
}

Outbox is an operational port for trusted workers. External effects must be idempotent by (tenant,event ID); lease fencing cannot undo external effects.

type OutboxProgress

type OutboxProgress struct {
	LedgerRevision, AcknowledgedRevision int64
	OldestRecordedAt                     *time.Time
	State                                string
}

OutboxProgress is a consistent snapshot for operational monitoring. Pending includes leased, delayed and failed work, not only immediately claimable work.

type OutboxProgressReader

type OutboxProgressReader interface {
	ReadOutboxProgress(context.Context, ConsumerKey) (OutboxProgress, error)
}

type PagedRebuildIndex

type PagedRebuildIndex interface {
	VerifyProjectionPages(context.Context, GenerationKey, int64, ProjectionPageLoader) (ProjectionCheck, error)
}

type PagedRebuildStore

type PagedRebuildStore interface {
	ProjectionDocumentPage(context.Context, GenerationKey, int64, int64, ProjectionCursor, int) (ProjectionPage, error)
}

PagedRebuildStore pins every page to one frozen source revision and fence. These are trusted administrative ports, not user-facing cursor APIs.

type PendingEvidenceUpload

type PendingEvidenceUpload struct{ ID, Scope, PolicyID string }

PendingEvidenceUpload binds a new development-store object to its intended scope and orphan cleanup policy before ledger registration. It grants no permission to disclose content or to register evidence.

type PolicyRequest

type PolicyRequest struct {
	Command
	Policy AcceptancePolicy
}

type PredicateBinding

type PredicateBinding struct{ Predicate, SchemaVersion string }

type PredicateMigration

type PredicateMigration struct {
	FromVersion, Mode, Reason string
}

PredicateMigration declares a reviewed schema transition. Existing versions are never rewritten; replacement values require new proposals and acceptance.

type PredicateRequest

type PredicateRequest struct {
	Command
	Definition PredicateVersion
}

type PredicateVersion

type PredicateVersion struct {
	Scope, Predicate, Version, PolicyID string
	Kind                                ValueKind
	Classification                      string
	Migration                           *PredicateMigration `json:",omitempty"`
	Constraints                         *ValueConstraints   `json:",omitempty"`
	Cardinality                         string              `json:",omitempty"`
	TemporalPrecision                   string              `json:",omitempty"`
}

func (PredicateVersion) ValidateFact

func (p PredicateVersion) ValidateFact(v Value, interval Interval) error

ValidateFact applies the same deterministic schema to manual and model proposals.

func (PredicateVersion) ValidateSchema

func (p PredicateVersion) ValidateSchema() error

type ProjectionCheck

type ProjectionCheck struct {
	Version string `json:",omitempty"`
	Count   int
	Digest  string
}

type ProjectionCleanupCursor

type ProjectionCleanupCursor struct{ Kind, VersionID, Generation string }

ProjectionCleanupCursor orders captured targets within one tenant.

func (ProjectionCleanupCursor) Compare

func (ProjectionCleanupCursor) Valid

func (c ProjectionCleanupCursor) Valid() bool

type ProjectionCleanupEngine

type ProjectionCleanupEngine interface {
	CleanupProjection(context.Context, Caller, ProjectionCleanupRequest) (CommitResult, error)
}

type ProjectionCleanupGate

type ProjectionCleanupGate interface {
	ProjectionDisposalSealer
	SetProjectionGate(context.Context, GenerationKey, int64, bool) error
}

type ProjectionCleanupKey

type ProjectionCleanupKey struct{ Tenant, Kind, VersionID string }

ProjectionCleanupKey identifies index cleanup for one disposed version.

type ProjectionCleanupOptions

type ProjectionCleanupOptions struct{ Destination ProjectionDisposer }

ProjectionCleanupOptions uses separately provisioned retention credentials. Destinations must implement idempotent atomic deletion with durable write fences, and honor context cancellation. Terminal generations also require ProjectionCleanupGate. No connections or workers are started by the engine.

type ProjectionCleanupPlan

type ProjectionCleanupPlan struct {
	Target        ProjectionDisposal
	TerminalFence int64
}

ProjectionCleanupPlan is prepared while the transaction holds scope and generation guards. A positive TerminalFence requires permanent destination sealing before cleanup; only retired/abandoned generations may receive it.

type ProjectionCleanupQuery

type ProjectionCleanupQuery struct {
	Tenant string
	After  ProjectionCleanupCursor
	Limit  int
}

type ProjectionCleanupReader

type ProjectionCleanupReader interface {
	ProjectionCleanupStatus(context.Context, ProjectionCleanupKey) (ProjectionCleanupStatus, error)
}

ProjectionCleanupReader is a trusted maintenance port, not an end-user API.

type ProjectionCleanupRequest

type ProjectionCleanupRequest struct {
	Command
	Kind, Scope, RecordID, VersionID, DisposalEventID, Generation, Reason string
	Bindings                                                              []VersionRetentionBinding
}

ProjectionCleanupRequest selects one captured destination and binds it to the original policy-authorized version disposal. Bindings must match that event.

type ProjectionCleanupScanner

type ProjectionCleanupScanner interface {
	ScanProjectionCleanup(context.Context, ProjectionCleanupQuery) ([]ProjectionCleanupRequest, error)
}

ProjectionCleanupScanner is a trusted maintenance reader. Returned requests have the original policy purpose/bindings but no command key or cleanup reason. Execution must still pass the engine's fresh authorization and hold checks.

type ProjectionCleanupStatus

type ProjectionCleanupStatus struct {
	Key            ProjectionCleanupKey
	InventoryEpoch int64
	CreatedAt      time.Time
	Targets        []ProjectionCleanupTarget
	Complete       bool
}

ProjectionCleanupStatus reports acknowledgements for the destinations captured atomically with a version tombstone. Complete means every captured target has an acknowledgement; it does not prove independent destination state, authorize disposal, or claim that evidence, derivatives, backups or archives were erased.

type ProjectionCleanupTarget

type ProjectionCleanupTarget struct {
	Generation, AcknowledgementID string
	CompletedAt                   *time.Time
}

type ProjectionCleanupTx

type ProjectionCleanupTx interface {
	PrepareProjectionCleanup(context.Context, ProjectionCleanupRequest) (ProjectionCleanupPlan, error)
}

type ProjectionCursor

type ProjectionCursor struct{ Kind, VersionID string }

func ProjectionDocumentCursor

func ProjectionDocumentCursor(d ProjectionDocument) ProjectionCursor

func (ProjectionCursor) Before

func (c ProjectionCursor) Before(next ProjectionCursor) bool

func (ProjectionCursor) Valid

func (c ProjectionCursor) Valid() bool

type ProjectionDestinationInventory

type ProjectionDestinationInventory struct {
	Destinations     []GenerationKey
	MissingConsumers []string
	Epoch            int64
}

ProjectionDestinationInventory is a point-in-time inventory of ledger-known destinations, including retired and abandoned generations. MissingConsumers lists projection consumers without a generation binding; it is not safe to infer their destination names from hashes. This is not disposal authorization or proof that a host has registered all externally provisioned indexes.

type ProjectionDestinationRegistry

type ProjectionDestinationRegistry interface {
	RegisterProjectionDestination(context.Context, GenerationKey) error
	ProjectionDestinationInventory(context.Context, string) (ProjectionDestinationInventory, error)
}

ProjectionDestinationRegistry is a trusted host maintenance port. Register a destination before writing to it; its ProjectionConsumer must already exist. Registration never resets consumer progress or removes old destinations.

type ProjectionDisposal

type ProjectionDisposal struct{ Tenant, Generation, Kind, VersionID string }

ProjectionDisposal identifies one immutable version in one destination. Kind is explicitly "fact" or "memory". This adapter contract is not disposal authorization: the host must coordinate ledger policy, holds and every copy.

type ProjectionDisposalSealer

type ProjectionDisposalSealer interface {
	SealProjectionForDisposal(context.Context, GenerationKey, int64) error
}

ProjectionDisposalSealer permanently excludes a generation from verification and activation, while allowing individual projection cleanup. The host must authorize disposal and establish a retired/abandoned ledger state first. fence is the exact sealed generation fence. An exact retry is idempotent; the transition must reject stale fences and prevent any future reopening.

type ProjectionDisposer

type ProjectionDisposer interface {
	DisposeProjection(context.Context, ProjectionDisposal) error
}

ProjectionDisposer atomically removes content and leaves a durable fence against delayed writes. A sealed generation must first enter the permanent disposal state through ProjectionDisposalSealer before accepting new cleanup.

type ProjectionDocument

type ProjectionDocument struct {
	Memory                                                                           *MemoryProjection `json:",omitempty"`
	Tenant, Generation, RecordID, VersionID, VersionDigest, PolicyID, Classification string
	Key                                                                              FactKey
	Value                                                                            Value
	Valid                                                                            Interval
	SourceClasses                                                                    []string
}

ProjectionDocument contains canonical accepted fact or memory content, never source-span quotes.

func (ProjectionDocument) Scope

func (d ProjectionDocument) Scope() string

type ProjectionInventory

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

ProjectionInventory hashes an ordered, length-delimited canonical transcript without retaining the whole inventory. Order is kind then version ID, using bytewise string comparison. The algorithm version is retained with the check.

func NewProjectionInventory

func NewProjectionInventory() *ProjectionInventory

func (*ProjectionInventory) Add

func (*ProjectionInventory) Check

type ProjectionPage

type ProjectionPage struct {
	Documents []ProjectionDocument
	// Next is the last scanned acceptance, including disposed versions. A page
	// may contain no documents and still advance. Nil means the scan is complete.
	Next *ProjectionCursor
}

type ProjectionPageLoader

type ProjectionPageLoader func(context.Context, ProjectionCursor) (ProjectionPage, error)

type ProjectionReceipt

type ProjectionReceipt struct {
	Generation      string
	IndexedRevision int64
}

type ProjectionRegistry

type ProjectionRegistry interface {
	ActiveProjection(context.Context, string) (ActiveProjection, error)
}

type ProjectionSource

type ProjectionSource interface {
	ProjectionDocument(context.Context, Delivery, string) (*ProjectionDocument, error)
}

ProjectionSource returns nil for an event with no projectable content, including a version whose durable disposal tombstone has been validated. Missing or malformed retained content must return an error, not nil.

type ProjectionStatus

type ProjectionStatus struct {
	Active         ActiveProjection
	Rebuild        RebuildStatus
	Consumer       ConsumerStatus
	LedgerRevision int64
	Incomplete     bool
}

type ProjectionStatusQuery

type ProjectionStatusQuery struct{ Generation, Purpose string }

type ProjectionWaitRequest

type ProjectionWaitRequest struct {
	Scopes              []string
	Generation, Purpose string
	Revision            int64
}

ProjectionWaitRequest binds a wait to one generation and committed revision. Callers must provide a context deadline; waits are additionally capped at two minutes.

type ReadOptions

type ReadOptions struct {
	PaginationKey []byte
	TokenLifetime time.Duration
}

type ReadTx

type ReadTx interface {
	TemporalTx
	RevisionAt(context.Context, time.Time) (int64, error)
	FactRecords(context.Context, FactsQuery, int64, string, int) ([]Record, error)
	// MemoryRecords returns memory records in the scope, ordered by record ID,
	// whose key is carried as Record.Key.Scope and Record.Key.Discriminator.
	MemoryRecords(context.Context, MemoriesQuery, int64, string, int) ([]Record, error)
}

type RebuildActor

type RebuildActor struct {
	Principal, Purpose string
	// Present for application-authorized operations; legacy trusted worker callers
	// retain their host-supplied principal and purpose contract.
	Caller        *Caller                `json:",omitempty"`
	Authorization *AuthorizationDecision `json:",omitempty"`
}

RebuildActor is a trusted operator identity supplied by the host. The administrative port must not be exposed as an unchecked end-user API.

type RebuildIndex

type RebuildIndex interface {
	RetrievalIndex
	SetProjectionGate(context.Context, GenerationKey, int64, bool) error
	VerifyProjection(context.Context, GenerationKey, int64, []ProjectionDocument) (ProjectionCheck, error)
}

type RebuildRequest

type RebuildRequest struct {
	Generation, Action, Purpose string
	MaxAttempts                 int
	ExpectedFence               int64
}

RebuildRequest selects an explicit administrative transition. Generation is also the start identity; retries cannot change its configured attempt budget.

type RebuildStatus

type RebuildStatus struct {
	VerificationVersion               string `json:",omitempty"`
	Key                               GenerationKey
	State                             string
	Fence, ThroughRevision, BaseEpoch int64
	PreviousGeneration                string
	Count                             int
	Digest                            string
}

type RecallItem

type RecallItem struct {
	Key   FactKey
	Fact  FactResult
	Score float64
}

type RecallRequest

type RecallRequest struct {
	Scopes                             []string
	Query, Purpose                     string
	RequireGeneration                  string `json:",omitempty"`
	ValidAt                            time.Time
	KnowledgeRevision, RequireRevision int64
	Limit                              int
}

type RecallResult

type RecallResult struct {
	Items                           []RecallItem
	Generation                      string
	LedgerRevision, IndexedRevision int64
	Incomplete                      bool
}

type Record

type Record struct {
	Kind     string `json:",omitempty"`
	ID       string
	Key      FactKey
	Revision int64
}

type RedactedEvidenceRequest

type RedactedEvidenceRequest struct {
	Command
	ID, Scope, ParentEvidenceID, PolicyVersion string
	Object                                     ObjectRef
	Ranges                                     []EvidenceCopyRange
}

type ReleaseLegalHoldRequest

type ReleaseLegalHoldRequest struct {
	Command
	ID, Scope, Reason string
}

type RetentionDomain

type RetentionDomain interface {
	RetentionDomain(context.Context) (string, error)
}

RetentionDomain binds synchronous object deletion to the ledger database. External stores use EvidenceVersionDeleter and post-commit outbox delivery.

type RetentionEvent

type RetentionEvent struct {
	DecisionDisposal        *DecisionDisposalRequest     `json:",omitempty"`
	CalculationDisposal     *CalculationDisposalRequest  `json:",omitempty"`
	BatchID                 string                       `json:",omitempty"`
	DisposalBatch           *DisposalBatchRequest        `json:",omitempty"`
	ProjectionCleanup       *ProjectionCleanupRequest    `json:",omitempty"`
	VersionDisposal         *VersionDisposalRequest      `json:",omitempty"`
	AttestationDisposal     *AttestationDisposalRequest  `json:",omitempty"`
	ConversationDisposal    *ConversationDisposalRequest `json:",omitempty"`
	ExtractionDisposal      *ExtractionDisposalRequest   `json:",omitempty"`
	ContextDisposal         *ContextDisposalRequest      `json:",omitempty"`
	SnapshotDisposal        *SnapshotDisposalRequest     `json:",omitempty"`
	AdditionalAuthorization []AuthorizationDecision      `json:",omitempty"`

	ID, Tenant, Scope, Kind, TargetID string
	Caller                            Caller
	Command                           Command
	Policy                            *RetentionPolicy
	Hold                              *LegalHoldRequest
	Release                           *ReleaseLegalHoldRequest
	Disposal                          *EvidenceDisposalRequest
	OrphanDisposal                    *OrphanEvidenceDisposalRequest `json:",omitempty"`
	LedgerRevision                    int64
	Limitations                       []string
}

type RetentionPolicy

type RetentionPolicy struct {
	ID, Scope, RecordClass, Purpose, Jurisdiction string
	MinimumAgeSeconds                             int64
}

RetentionPolicy is immutable and application-owned. Evidence-byte durations start at registration; orphan-evidence durations start at recorded upload time. Snapshot/context and extraction artifact durations start at their database creation event times; each extraction payload class has its own policy. None uses a caller-supplied historical source timestamp.

type RetentionPolicyRequest

type RetentionPolicyRequest struct {
	Command
	Policy RetentionPolicy
}

type RetentionStatus

type RetentionStatus struct {
	EvidenceID, PolicyID string
	RegisteredAt         time.Time
	Disposed             bool
	ActiveHolds          []string
	Blockers             []string
}

type RetentionStatusQuery

type RetentionStatusQuery struct{ Scope, EvidenceID, Purpose string }

type RetentionTx

type RetentionTx interface {
	Tx
	RetentionPolicy(context.Context, string, string) (RetentionPolicy, error)
	StageRetention(context.Context, RetentionEvent) error
	RetentionStatus(context.Context, string, string) (RetentionStatus, error)
	DisposeEvidence(context.Context, EvidenceDisposalRequest) error
}

type RetrievalDescriber

type RetrievalDescriber interface {
	DescribeRetrieval(context.Context, string, string) (RetrievalIdentity, error)
}

type RetrievalIdentity

type RetrievalIdentity struct {
	Generation, EmbeddingID, SearchVersion, RerankerID string
	Dimensions                                         int
}

type RetrievalIndex

type RetrievalIndex interface {
	Put(context.Context, ProjectionDocument) error
	Candidates(context.Context, string, string, string, string, int) ([]SearchCandidate, error)
}

type RetrievalOptions

type RetrievalOptions struct {
	Registry   ProjectionRegistry
	Index      RetrievalIndex
	Progress   Outbox
	Generation string
}

type RevisionConflict

type RevisionConflict struct {
	RecordID                          string
	ExpectedRevision, CurrentRevision int64
}

RevisionConflict describes the record state observed under the mutation's record lock. It is a refresh hint, not a reservation or permission to overwrite. Error deliberately contains no record identifiers or revision values.

func (*RevisionConflict) Error

func (e *RevisionConflict) Error() string

func (*RevisionConflict) Unwrap

func (e *RevisionConflict) Unwrap() error

type ScopeDefinition

type ScopeDefinition struct{ ID, Label string }

IDs are application-issued opaque identifiers. Labels never resolve identities.

type ScopeRequest

type ScopeRequest struct {
	Command
	Definition       ScopeDefinition
	ExpectedRevision int64
	Reason           string
}

type ScopeVersion

type ScopeVersion struct {
	Definition               ScopeDefinition
	Revision, LedgerRevision int64
	Caller                   Caller
	Reason                   string
}

type SearchCandidate

type SearchCandidate struct {
	Kind                string `json:",omitempty"`
	RecordID, VersionID string
	Score               float64
}

type SnapshotDisposalRequest

type SnapshotDisposalRequest struct {
	Command
	SnapshotID, Reason string
	Bindings           []SnapshotRetentionBinding
}

type SnapshotDisposalTx

type SnapshotDisposalTx interface {
	DisposeSnapshot(context.Context, SnapshotDisposalRequest) error
}

SnapshotDisposalTx adapters must serialize disposal with new references, scope holds, exports and archive reads, and retain an immutable tombstone.

type SnapshotItem

type SnapshotItem struct {
	Selector                    FactKey
	Resolution                  FactResult
	SchemaVersion, PolicyID     string
	Valid                       Interval
	SourceClasses               []string
	EvidenceIDs, AttestationIDs []string
}

type SnapshotQuery

type SnapshotQuery struct {
	ID      string
	Purpose string
}

type SnapshotRetentionBinding

type SnapshotRetentionBinding struct{ Scope, PolicyID, Jurisdiction string }

type SourceSpan

type SourceSpan struct {
	EvidenceID string
	Start, End int
	Quote      string
}

type SubjectDefinition

type SubjectDefinition struct {
	Scope, ID, Kind, Label string
	// Lookup contains qualified, exact external identifiers, not search terms.
	Lookup map[string]string
}

type SubjectLookupQuery

type SubjectLookupQuery struct{ Scope, Namespace, Value, Purpose string }

type SubjectRequest

type SubjectRequest struct {
	Command
	Definition       SubjectDefinition
	ExpectedRevision int64
	Reason           string
}

type SubjectVersion

type SubjectVersion struct {
	Definition               SubjectDefinition
	Revision, LedgerRevision int64
	Caller                   Caller
	Reason                   string
}

type Supersession

type Supersession struct {
	Approval
	ReplacedVersionIDs []string
	Valid              Interval
	Reason             string
	Automated          bool
}

type TelemetryOptions

type TelemetryOptions struct {
	TracerProvider trace.TracerProvider
	MeterProvider  metric.MeterProvider
	Logger         *slog.Logger
}

TelemetryOptions injects host-owned providers. Nil providers are local no-ops, never global defaults. The host owns exporters, sampling, flush and shutdown.

type TemporalTx

type TemporalTx interface {
	Tx
	StageTimeline(context.Context, string, []Acceptance) error
	StageRejection(context.Context, string, string) error
	Rejected(context.Context, string, string, int64) (bool, error)
	HasAcceptance(context.Context, string, string) (bool, error)
	Versions(context.Context, string, int64) ([]Version, error)
	HistoricalAttestations(context.Context, string, int64) ([]Attestation, error)
	RevisionTime(context.Context, int64) (time.Time, error)
	StreamRevisionAt(context.Context, string, int64) (int64, error)
	StageSnapshot(context.Context, FactSnapshot) error
	Snapshot(context.Context, string) (FactSnapshot, error)
	History(context.Context, string) ([]Event, error)
}

TemporalTx is implemented by ledgers supporting the second delivery slice.

type Tx

type Tx interface {
	// RequireScope and RequireSubject reject unregistered write identities.
	RequireScope(context.Context, string) error
	RequireSubject(context.Context, string, string) error
	Receipt(context.Context, Caller, string, string, string) (*CommitResult, error)
	SaveReceipt(context.Context, Caller, string, string, string, CommitResult) error
	Policy(context.Context, string, string) (AcceptancePolicy, error)
	InsertPolicy(context.Context, AcceptancePolicy) error
	Predicate(context.Context, string, string, string) (PredicateVersion, error)
	InsertPredicate(context.Context, PredicateVersion) error
	ActivePredicate(context.Context, string, string) (string, error)
	Evidence(context.Context, string) (Evidence, error)
	InsertEvidence(context.Context, Evidence) (string, error)
	// LockRecord must require a registered subject before locking or creating a record.
	LockRecord(context.Context, FactKey) (Record, error)
	Record(context.Context, string) (Record, error)
	SetRevision(context.Context, string, int64) error
	Version(context.Context, string, string) (Version, error)
	InsertVersion(context.Context, Version) error
	Attestations(context.Context, string) ([]Attestation, error)
	InsertAttestation(context.Context, Attestation) error
	WithdrawAttestation(context.Context, string, string, Caller) (CommitResult, error)
	Acceptances(context.Context, string, int64) ([]Acceptance, error)
	InsertAcceptance(context.Context, string, Acceptance) error
	Append(context.Context, Event) (Event, error)
	Revision(context.Context) (int64, error)
}

type Value

type Value struct {
	Kind    ValueKind
	Text    *string
	Boolean *bool
	Integer *int64
	Decimal *string
	Unit    string
	Date    *string
	Instant *time.Time
	Entity  *string
}

Value has exactly one payload. Unknown has no payload. Decimal strings are canonical.

func (Value) Validate

func (v Value) Validate() error

type ValueConstraints

type ValueConstraints struct {
	AllowUnknown               *bool    `json:",omitempty"`
	AllowedValues              []Value  `json:",omitempty"`
	MinTextRunes, MaxTextRunes *int     `json:",omitempty"`
	MinInteger, MaxInteger     *int64   `json:",omitempty"`
	MinDecimal, MaxDecimal     *string  `json:",omitempty"`
	DecimalPlaces              *int     `json:",omitempty"`
	Units                      []string `json:",omitempty"`
}

ValueConstraints are immutable, application-owned restrictions. Nil fields preserve the base value contract. Bounds are inclusive; text length is runes.

type ValueKind

type ValueKind string
const (
	Text    ValueKind = "text"
	Boolean ValueKind = "boolean"
	Integer ValueKind = "integer"
	Decimal ValueKind = "decimal"
	Date    ValueKind = "date"
	Instant ValueKind = "instant"
	Entity  ValueKind = "entity"
	Unknown ValueKind = "unknown"
)

type Version

type Version struct {
	PayloadDisposed      bool   `json:",omitempty"`
	ExtractionAttemptID  string `json:",omitempty"`
	ID, RecordID, Digest string
	Proposal             FactProposal
	Proposer             Caller
	PolicyID             string
}

func VersionTombstone

func VersionTombstone(v Version) Version

VersionTombstone removes the typed value and source quotes, preserving the original digest, identities, locators and governance provenance. This is not disposal authorization, and the metadata cannot reconstruct original content. It does not mutate the input.

type VersionDisposalRequest

type VersionDisposalRequest struct {
	Command
	Kind, Scope, RecordID, VersionID, Reason string
	Bindings                                 []VersionRetentionBinding
}

VersionDisposalRequest selects one immutable fact or memory payload. Its index cleanup obligations are durable but may remain pending after commit.

type VersionDisposalTx

type VersionDisposalTx interface {
	DisposeVersion(context.Context, VersionDisposalRequest) (int64, error)
}

VersionDisposalTx atomically validates retention policy and retained copies, fences references/lifecycle writes, retains a tombstone, captures index cleanup obligations and increments the owning record revision. It returns that revision.

type VersionReference

type VersionReference struct{ RecordID, VersionID string }

type VersionRetentionBinding

type VersionRetentionBinding struct{ Scope, PolicyID, Jurisdiction string }

type Withdrawal

type Withdrawal struct {
	Command
	Scope, AttestationID string
}

Jump to

Keyboard shortcuts

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