runtime

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation ¶

Overview ¶

Package runtime composes built-in domain services and owns scope, operation, scheduler, readiness, and resource lifecycles.

Index ¶

Constants ¶

View Source
const (
	DefaultMemoryArtifactID  = "memory"
	DefaultSourceWindowLimit = int64(100)
)
View Source
const (
	DefaultReadinessProbeTimeout = 2 * time.Second
	DefaultReadinessCacheTTL     = 5 * time.Minute
	TransientReadinessCacheTTL   = 30 * time.Second
)
View Source
const (
	ProcessSourceWindowOperation = "process_source_window"
	IncubateExperienceOperation  = "incubate_experience_candidates"
	ScheduledProcessingSuccess   = "success"
	ScheduledProcessingNoop      = "noop"
	ScheduledProcessingFailure   = "failure"
	ScheduledProcessingCancelled = "cancelled"
)
View Source
const DefaultHandoffArtifactID = "handoff"
View Source
const DefaultScopeCacheSize = 128
View Source
const MaxScopeIDLength = 256
View Source
const PreparedContextV1 = "powercontext.prepared-context.v1"

Variables ¶

This section is empty.

Functions ¶

func ReportEmbeddingUsage ¶

func ReportEmbeddingUsage(delegate inference.EmbeddingModel) inference.EmbeddingModel

ReportEmbeddingUsage decorates an embedding model while preserving its immutable profile. Empty and failed calls retain the delegate's behavior.

func ReportStructuredUsage ¶

func ReportStructuredUsage[I, O any](
	delegate inference.StructuredGenerator[I, O],
) inference.StructuredGenerator[I, O]

ReportStructuredUsage decorates a structured generator without changing its provider contract. Only successful results are reported, and attribution is resolved from the admitted Runtime operation's context.

func TraceMemoryReranker ¶

func TraceMemoryReranker(runtime *Runtime, delegate memory.Reranker) memory.Reranker

TraceMemoryReranker records the bounded rerank stage around the actual model call, so provider spans remain children of memory.rerank and no query or candidate text becomes an attribute.

func ValidateScopeID ¶

func ValidateScopeID(scopeID string) (string, error)

ValidateScopeID validates the opaque runtime partition. Like the frozen Python runtime it accepts nonblank leading/trailing whitespace; individual persistence adapters may impose their stricter storage identity contract.

Types ¶

type BackgroundTracing ¶

type BackgroundTracing interface {
	StartBackground(context.Context, string, map[string]TraceAttribute) (context.Context, StageSpan)
}

BackgroundTracing is an optional consumer-owned boundary for work that has no request parent. Runtime remains transport-agnostic while a consumer such as the server can export an independent operation root.

type CachedProbe ¶

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

CachedProbe caches stable and transient outcomes with separate TTLs and collapses concurrent refreshes without holding a mutex during I/O.

func NewCachedProbe ¶

func NewCachedProbe(probe Probe, ttl, transientTTL time.Duration, clock Clock) (*CachedProbe, error)

func (*CachedProbe) Probe ¶

func (p *CachedProbe) Probe(ctx context.Context) (CheckStatus, error)

type Capabilities ¶

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

func EmptyCapabilities ¶

func EmptyCapabilities() Capabilities

func NewCapabilities ¶

func NewCapabilities(options CapabilityOptions) (Capabilities, error)

func (Capabilities) ArtifactFamilies ¶

func (c Capabilities) ArtifactFamilies() []string

func (Capabilities) ContextVersions ¶

func (c Capabilities) ContextVersions() []string

func (Capabilities) ExperienceGeneration ¶

func (c Capabilities) ExperienceGeneration() bool

func (Capabilities) ExternalSkillRegistry ¶

func (c Capabilities) ExternalSkillRegistry() bool

func (Capabilities) HandoffGeneration ¶

func (c Capabilities) HandoffGeneration() bool

func (Capabilities) ManagedSkillGeneration ¶

func (c Capabilities) ManagedSkillGeneration() bool

func (Capabilities) MemoryExtraction ¶

func (c Capabilities) MemoryExtraction() bool

func (Capabilities) SearchModes ¶

func (c Capabilities) SearchModes() []memory.SearchMode

func (Capabilities) SourceTypes ¶

func (c Capabilities) SourceTypes() []string

type CapabilityOptions ¶

type CapabilityOptions struct {
	SourceTypes            []string
	ArtifactFamilies       []string
	MemoryExtraction       bool
	ExperienceGeneration   bool
	ManagedSkillGeneration bool
	ExternalSkillRegistry  bool
	HandoffGeneration      bool
	SearchModes            []memory.SearchMode
	ContextVersions        []string
}

type CheckStatus ¶

type CheckStatus string
const (
	CheckReady         CheckStatus = "ready"
	CheckUnavailable   CheckStatus = "unavailable"
	CheckTimeout       CheckStatus = "timeout"
	CheckMisconfigured CheckStatus = "misconfigured"
)

type Clock ¶

type Clock func() time.Time

type ContextApplication ¶

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

ContextApplication owns the composite preparation use case. Memory and Experience candidates are selected under one admitted per-scope gate, then the pure Builder owns final selection, trust labeling, and the byte budget.

func NewContextApplication ¶

func NewContextApplication(
	runtime *Runtime,
	memoryApplication *MemoryApplication,
	experiences ExperienceRecall,
) (*ContextApplication, error)

func NewContextApplicationWithRecall ¶

func NewContextApplicationWithRecall(
	runtime *Runtime,
	memoryApplication *MemoryApplication,
	experiences ExperienceRecall,
	recall RecallStatistics,
) (*ContextApplication, error)

func (*ContextApplication) Prepare ¶

func (a *ContextApplication) Prepare(
	ctx context.Context,
	scopeID string,
	request contextpack.Request,
) (contextpack.Prepared, error)

type CreateHandoffReportProject ¶

type CreateHandoffReportProject struct {
	ProjectKey, Title string
	Description       *string
	DefaultLocale     handoffreport.Locale
	Timezone          string
}

type DependencyOperation ¶

type DependencyOperation func(context.Context) error

type ExperienceIncubationApplication ¶

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

func (*ExperienceIncubationApplication) Incubate ¶

type ExperienceIncubationBackend ¶

type ExperienceIncubationBackend interface {
	ObserveWindow(context.Context, string, int64) (
		previous source.Cursor,
		next source.Cursor,
		generation *int64,
		highWatermark int64,
		values []source.Value,
		available []source.Ref,
		err error,
	)
	ApplyWindow(
		context.Context,
		string,
		[]string,
		[]experience.CandidateInput,
		source.Cursor,
		*int64,
	) error
}

ExperienceIncubationBackend is the use-case-shaped two-transaction port. ObserveWindow commits before model inference; ApplyWindow atomically creates every Candidate and advances the independent Source cursor.

type ExperienceIncubationBackendFactory ¶

type ExperienceIncubationBackendFactory func(string) (ExperienceIncubationBackend, error)

type ExperienceIncubationResult ¶

type ExperienceIncubationResult struct {
	PreviousCursor       int64
	HighWatermark        int64
	CurrentCursor        int64
	ProcessedSourceCount int
	CandidateCount       int
}

func (ExperienceIncubationResult) Processed ¶

func (r ExperienceIncubationResult) Processed() bool

type ExperienceRecall ¶

type ExperienceRecall interface {
	Search(context.Context, string, string, int) ([]experience.SearchHit, error)
}

ExperienceRecall is the narrow read surface Context preparation consumes. Persistence implementations remain free to use SQLite FTS, OceanBase FULLTEXT, or a deterministic fake without leaking those details here.

type ExperienceRecallFunc ¶

type ExperienceRecallFunc func(context.Context, string, string, int) ([]experience.SearchHit, error)

func (ExperienceRecallFunc) Search ¶

func (f ExperienceRecallFunc) Search(
	ctx context.Context,
	scopeID, query string,
	limit int,
) ([]experience.SearchHit, error)

type ExternalSkillApplication ¶

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

func NewExternalSkillApplication ¶

func NewExternalSkillApplication(
	runtime *Runtime,
	registries ExternalSkillRegistryFactory,
	generations GenerationServiceFactory,
	snapshots ExternalSkillSnapshotStore,
) (*ExternalSkillApplication, error)

func (*ExternalSkillApplication) Import ¶

func (a *ExternalSkillApplication) Import(
	ctx context.Context,
	scopeID, externalSkillID, fingerprint string,
	mode skill.ImportMode,
	reason *string,
) (review.GeneratedCandidateResult, error)

func (*ExternalSkillApplication) List ¶

func (a *ExternalSkillApplication) List(
	ctx context.Context,
	scopeID string,
	includeUnavailable bool,
) ([]skill.Resolution, error)

func (*ExternalSkillApplication) Resolve ¶

func (a *ExternalSkillApplication) Resolve(
	ctx context.Context,
	scopeID, externalSkillID, fingerprint string,
) (skill.Resolution, error)

func (*ExternalSkillApplication) Scan ¶

type ExternalSkillRegistryFactory ¶

type ExternalSkillRegistryFactory func(string) (*skill.RegistryService, error)

type ExternalSkillSnapshotStore ¶

type ExternalSkillSnapshotStore interface {
	Store(context.Context, string, skill.SnapshotCapture) (source.Ref, error)
}

type GenerationApplication ¶

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

func NewGenerationApplication ¶

func NewGenerationApplication(runtime *Runtime, services GenerationServiceFactory) (*GenerationApplication, error)

func (*GenerationApplication) GenerateExperience ¶

func (a *GenerationApplication) GenerateExperience(
	ctx context.Context,
	scopeID string,
	sources []source.Ref,
	artifacts []artifact.Ref,
	target *artifact.Ref,
	reason *string,
) (review.GeneratedCandidateResult, error)

func (*GenerationApplication) GenerateSkill ¶

func (a *GenerationApplication) GenerateSkill(
	ctx context.Context,
	scopeID string,
	origin review.SkillGenerationOrigin,
	sources []source.Ref,
	artifacts []artifact.Ref,
	target *artifact.Ref,
	reason *string,
) (review.GeneratedCandidateResult, error)

type GenerationServiceFactory ¶

type GenerationServiceFactory func(string) (*review.GenerationService, error)

type GetHandoffReport ¶

type GetHandoffReport struct {
	ScopeID               string
	Locale                *handoffreport.Locale
	IncludeEvidenceChecks bool
	Format                handoffreport.Format
	IncludeArchived       bool
	Period                *HandoffReportPeriod
}

type HandoffActivationBackend ¶

type HandoffActivationBackend interface {
	LoadBoundary(context.Context, string, source.Ref, string) (int64, source.Cursor, *int64, error)
	SaveBoundary(context.Context, string, string, source.Cursor, *int64) error
}

HandoffActivationBackend brackets generation with short transactional boundary reads and cursor CAS writes.

type HandoffActivationResult ¶

type HandoffActivationResult = handoff.Activation

type HandoffApplication ¶

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

func NewHandoffApplication ¶

func NewHandoffApplication(
	runtime *Runtime,
	services HandoffServiceFactory,
	activation HandoffActivationBackend,
) (*HandoffApplication, error)

func (*HandoffApplication) Activate ¶

func (a *HandoffApplication) Activate(
	ctx context.Context,
	scopeID string,
	activation handoff.Activate,
) (HandoffActivationResult, error)

func (*HandoffApplication) Commit ¶

func (a *HandoffApplication) Commit(
	ctx context.Context,
	scopeID string,
	prepared handoff.Prepared,
) (handoff.Handoff, error)

func (*HandoffApplication) ContinueLatest ¶

func (a *HandoffApplication) ContinueLatest(
	ctx context.Context,
	scopeID string,
) (handoff.Resolution, error)

func (*HandoffApplication) ContinuePrepared ¶

func (a *HandoffApplication) ContinuePrepared(
	ctx context.Context,
	scopeID string,
	prepared handoff.Prepared,
) (handoff.Resolution, error)

func (*HandoffApplication) ContinueRevision ¶

func (a *HandoffApplication) ContinueRevision(
	ctx context.Context,
	scopeID string,
	ref artifact.Ref,
) (handoff.Resolution, error)

func (*HandoffApplication) Finalize ¶

func (a *HandoffApplication) Finalize(
	ctx context.Context,
	scopeID string,
	draft handoff.Draft,
) (handoff.Prepared, error)

func (*HandoffApplication) Prepare ¶

func (a *HandoffApplication) Prepare(
	ctx context.Context,
	scopeID string,
	action handoff.Prepare,
) (handoff.Draft, error)

type HandoffReportActivityList ¶

type HandoffReportActivityList struct {
	ProjectID              string
	PeriodStart, PeriodEnd *time.Time
	Sources                []handoffreport.ActivitySource
	AfterCursor            int64
	ThroughCursor          *int64
	Limit                  int
}

type HandoffReportApplication ¶

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

func NewHandoffReportApplication ¶

func NewHandoffReportApplication(
	runtime *Runtime,
	backend HandoffReportBackend,
	reader handoffreport.HandoffReader,
	continuity handoffreport.WorkContinuityReader,
	clock Clock,
	ids HandoffReportIDFactory,
	scopeProviders ...HandoffScopeIDs,
) (*HandoffReportApplication, error)

func (*HandoffReportApplication) AttachWorkspaceBinding ¶

func (a *HandoffReportApplication) AttachWorkspaceBinding(ctx context.Context, id, project string, repository handoffreport.RepositoryRef, expected *int) (handoffreport.WorkspaceBinding, error)

func (*HandoffReportApplication) CreateProject ¶

func (*HandoffReportApplication) DetachWorkspaceBinding ¶

func (a *HandoffReportApplication) DetachWorkspaceBinding(ctx context.Context, id string, expected int) (handoffreport.WorkspaceBinding, error)

func (*HandoffReportApplication) GetProject ¶

func (*HandoffReportApplication) GetReport ¶

func (*HandoffReportApplication) GetWorkspaceBinding ¶

func (*HandoffReportApplication) ListActivities ¶

func (*HandoffReportApplication) ListKnownScopes ¶

func (a *HandoffReportApplication) ListKnownScopes(ctx context.Context, cursor *string, limit int) (KnownHandoffScopePage, error)

func (*HandoffReportApplication) ListProjects ¶

func (a *HandoffReportApplication) ListProjects(ctx context.Context, cursor *string, limit int, archived bool) (handoffreport.Page[handoffreport.ProjectDescriptor], error)

func (*HandoffReportApplication) ListWorkstreams ¶

func (a *HandoffReportApplication) ListWorkstreams(ctx context.Context, project string, cursor *string, limit int, archived bool) (handoffreport.Page[handoffreport.WorkstreamDescriptor], error)

func (*HandoffReportApplication) PurgeActivities ¶

func (a *HandoffReportApplication) PurgeActivities(ctx context.Context, project string, before time.Time) (int64, error)

func (*HandoffReportApplication) RecordActivity ¶

func (*HandoffReportApplication) RegisterWorkstream ¶

func (*HandoffReportApplication) UpdateProject ¶

func (*HandoffReportApplication) UpdateWorkstream ¶

type HandoffReportBackend ¶

type HandoffReportBackend interface {
	CreateProject(context.Context, handoffreport.ProjectDescriptor, time.Time) (handoffreport.ProjectDescriptor, error)
	GetProject(context.Context, string) (handoffreport.ProjectDescriptor, error)
	UpdateProject(context.Context, handoffreport.ProjectDescriptor, int, time.Time) (handoffreport.ProjectDescriptor, error)
	ListProjects(context.Context, *string, int, bool) (handoffreport.Page[handoffreport.ProjectDescriptor], error)
	RegisterWorkstream(context.Context, handoffreport.WorkstreamDescriptor, time.Time) (handoffreport.WorkstreamDescriptor, error)
	UpdateWorkstream(context.Context, handoffreport.WorkstreamDescriptor, int, time.Time) (handoffreport.WorkstreamDescriptor, error)
	ListWorkstreams(context.Context, string, *string, int, bool) (handoffreport.Page[handoffreport.WorkstreamDescriptor], error)
	RecordActivity(context.Context, handoffreport.ActivityEvent) (handoffreport.StoredActivity, error)
	ListActivities(context.Context, string, *time.Time, *time.Time, []handoffreport.ActivitySource, int64, *int64, int) (handoffreport.ActivityPage, error)
	PurgeActivities(context.Context, string, time.Time) (int64, error)
	GetWorkspaceBinding(context.Context, string) (handoffreport.WorkspaceBinding, error)
	AttachWorkspaceBinding(context.Context, string, string, handoffreport.RepositoryRef, *int, time.Time) (handoffreport.WorkspaceBinding, error)
	DetachWorkspaceBinding(context.Context, string, int) (handoffreport.WorkspaceBinding, error)
	ReadHandoffReportInputs(context.Context, string, bool, *time.Time, *time.Time, *time.Time, *time.Time) (handoffreport.ProjectDescriptor, []handoffreport.WorkstreamDescriptor, []handoffreport.ActivityEvent, int64, int, error)
}

type HandoffReportIDFactory ¶

type HandoffReportIDFactory func(prefix string) (string, error)

type HandoffReportPeriod ¶

type HandoffReportPeriod struct {
	Start, End              time.Time
	Timezone                *string
	CompareToPreviousPeriod bool
}

type HandoffReportReader ¶

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

HandoffReportReader exposes only committed exact reads. Evidence checking is explicitly unavailable because reusing Continue would cross its trust and telemetry boundary.

func NewHandoffReportReader ¶

func NewHandoffReportReader(services HandoffServiceFactory) (*HandoffReportReader, error)

func (*HandoffReportReader) CheckEvidence ¶

func (*HandoffReportReader) Get ¶

func (*HandoffReportReader) Latest ¶

func (r *HandoffReportReader) Latest(ctx context.Context, scope string) (handoff.Handoff, bool, error)

func (*HandoffReportReader) Revisions ¶

func (r *HandoffReportReader) Revisions(ctx context.Context, scope string) ([]handoff.Handoff, error)

type HandoffScopeIDs ¶

type HandoffScopeIDs func(context.Context) ([]string, error)

type HandoffServiceFactory ¶

type HandoffServiceFactory func(string) (*handoff.Service, error)

type InvalidScopeError ¶

type InvalidScopeError struct{ Detail string }

func (*InvalidScopeError) Error ¶

func (e *InvalidScopeError) Error() string

type KnownHandoffScopePage ¶

type KnownHandoffScopePage struct {
	Items      []string
	NextCursor *string
}

type MemoryApplication ¶

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

func NewMemoryApplication ¶

func NewMemoryApplication(runtime *Runtime, services MemoryServiceFactory, memoryArtifactID string) (*MemoryApplication, error)

func NewMemoryApplicationWithFlush ¶

func NewMemoryApplicationWithFlush(
	runtime *Runtime,
	services MemoryServiceFactory,
	flushes MemoryFlushBackendFactory,
	memoryArtifactID string,
	sourceWindowLimit int64,
) (*MemoryApplication, error)

NewMemoryApplicationWithFlush constructs the complete Memory application. The simpler constructor remains useful for deployments that intentionally expose only explicit Memory operations.

func (*MemoryApplication) Changes ¶

func (a *MemoryApplication) Changes(
	ctx context.Context,
	scopeID string,
	sinceRevision *int64,
) (MemoryChangesPage, error)

func (*MemoryApplication) Flush ¶

func (a *MemoryApplication) Flush(ctx context.Context, scopeID string) (MemoryFlushResult, error)

Flush advances the stable Memory Source window. Planning may invoke models and is intentionally performed after ObserveWindow has committed and before ApplyWindow opens the final transaction.

func (*MemoryApplication) Get ¶

func (a *MemoryApplication) Get(
	ctx context.Context,
	scopeID string,
	citation memory.Citation,
) (MemoryEntryRecord, error)

func (*MemoryApplication) List ¶

func (a *MemoryApplication) List(
	ctx context.Context,
	scopeID string,
	includeInactive bool,
) (MemoryEntriesPage, error)

func (*MemoryApplication) Remember ¶

func (a *MemoryApplication) Remember(
	ctx context.Context,
	scopeID string,
	request RememberMemoryRequest,
) (MemoryMutationResult, error)

func (*MemoryApplication) Retire ¶

func (a *MemoryApplication) Retire(
	ctx context.Context,
	scopeID string,
	citation memory.Citation,
	reason *string,
) (MemoryMutationResult, error)

func (*MemoryApplication) Revise ¶

func (a *MemoryApplication) Revise(
	ctx context.Context,
	scopeID string,
	citation memory.Citation,
	kind, text string,
	reason *string,
) (MemoryMutationResult, error)

func (*MemoryApplication) Search ¶

func (a *MemoryApplication) Search(
	ctx context.Context,
	scopeID, query string,
	limit int,
	mode memory.SearchMode,
) (MemorySearchPage, error)

type MemoryChangesPage ¶

type MemoryChangesPage struct {
	MemoryRef *artifact.Ref
	Revisions []memory.RevisionChanges
}

type MemoryEntriesPage ¶

type MemoryEntriesPage struct {
	MemoryRef *artifact.Ref
	Entries   []MemoryEntryRecord
}

type MemoryEntryRecord ¶

type MemoryEntryRecord struct {
	MemoryRef artifact.Ref
	State     memory.EntryState
	Entry     memory.EntryVersion
}

func (MemoryEntryRecord) Clone ¶

type MemoryFlushBackend ¶

type MemoryFlushBackend interface {
	ObserveWindow(context.Context, string, int64) (
		previous source.Cursor,
		next source.Cursor,
		generation *int64,
		highWatermark int64,
		values []source.Value,
		err error,
	)
	ApplyWindow(context.Context, string, memory.WritePlan, source.Cursor, *int64) (*memory.Memory, error)
}

MemoryFlushBackend is the use-case-shaped persistence port for the two transaction boundaries surrounding extraction. ObserveWindow returns one relational snapshot; ApplyWindow must atomically apply the Memory plan and cursor CAS.

type MemoryFlushBackendFactory ¶

type MemoryFlushBackendFactory func(string) (MemoryFlushBackend, error)

type MemoryFlushResult ¶

type MemoryFlushResult struct {
	PreviousCursor       int64
	CurrentCursor        int64
	HighWatermark        int64
	ProcessedSourceCount int
	MemoryRef            *artifact.Ref
}

func (MemoryFlushResult) Processed ¶

func (r MemoryFlushResult) Processed() bool

type MemoryMutationResult ¶

type MemoryMutationResult struct {
	PreviousRevision *int64
	MemoryRef        artifact.Ref
	Entry            *MemoryEntryRecord
}

type MemorySearchPage ¶

type MemorySearchPage struct {
	MemoryRef *artifact.Ref
	Mode      *memory.SearchMode
	Hits      []memory.Hit
	Rerank    *memory.RerankTrace
}

type MemoryServiceFactory ¶

type MemoryServiceFactory func(string) (*memory.Service, error)

type ModelUsageRecorder ¶

type ModelUsageRecorder interface {
	RecordModelUsage(
		context.Context,
		string,
		stats.ModelPurpose,
		stats.ModelOperation,
		inference.Usage,
	)
}

ModelUsageRecorder is the best-effort application-side sink used by inference decorators. Implementations own persistence failure handling so a statistics outage can never turn a successful model call into a failed business operation.

type ModelUsageRecorderFunc ¶

type ModelUsageRecorderFunc func(
	context.Context,
	string,
	stats.ModelPurpose,
	stats.ModelOperation,
	inference.Usage,
)

func (ModelUsageRecorderFunc) RecordModelUsage ¶

func (f ModelUsageRecorderFunc) RecordModelUsage(
	ctx context.Context,
	scopeID string,
	purpose stats.ModelPurpose,
	operation stats.ModelOperation,
	usage inference.Usage,
)

type Probe ¶

type Probe func(context.Context) (CheckStatus, error)

func DependencyProbe ¶

func DependencyProbe(operation DependencyOperation, timeout time.Duration) Probe

DependencyProbe bounds one dependency call and maps only safe readiness categories; provider messages and credentials never escape into checks.

type ProbeDefinition ¶

type ProbeDefinition struct {
	Name     string
	Probe    Probe
	Blocking bool
}

type Readiness ¶

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

func (Readiness) CheckOrder ¶

func (r Readiness) CheckOrder() []string

func (Readiness) Checks ¶

func (r Readiness) Checks() map[string]CheckStatus

func (Readiness) Ready ¶

func (r Readiness) Ready() bool

func (Readiness) Status ¶

func (r Readiness) Status() ReadinessStatus

type ReadinessChecks ¶

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

func NewReadinessChecks ¶

func NewReadinessChecks(definitions []ProbeDefinition) (*ReadinessChecks, error)

func (*ReadinessChecks) Run ¶

Run evaluates independent dependencies concurrently. A dependency panic or ordinary error is isolated as unavailable; caller cancellation still aborts the aggregate operation.

type ReadinessStatus ¶

type ReadinessStatus string
const (
	Ready    ReadinessStatus = "ready"
	Degraded ReadinessStatus = "degraded"
	NotReady ReadinessStatus = "not_ready"
)

type RecallStatistics ¶

type RecallStatistics interface {
	ObservePreparedContext(context.Context, string, contextpack.Build)
}

RecallStatistics observes one final Context Pack after the per-scope gate is released but before lifecycle admission ends. Implementations are best-effort: persistence or estimation failures must be handled internally.

type RecallStatisticsFunc ¶

type RecallStatisticsFunc func(context.Context, string, contextpack.Build)

func (RecallStatisticsFunc) ObservePreparedContext ¶

func (f RecallStatisticsFunc) ObservePreparedContext(
	ctx context.Context,
	scopeID string,
	build contextpack.Build,
)

type RecordHandoffReportActivity ¶

type RecordHandoffReportActivity struct {
	ProjectID      string
	ScopeID        *string
	Source         handoffreport.ActivitySource
	SourceEventID  string
	SourceRef      *handoffreport.ExternalReference
	OccurredAt     *time.Time
	TimeBasis      handoffreport.TimeBasis
	Title, Summary *string
	Agent          *handoffreport.ActivityAgent
	SessionID      *string
	VCSContext     *handoffreport.ActivityVCSContext
	EvidenceRefs   []handoffreport.ExternalReference
}

type RegisterHandoffReportWorkstream ¶

type RegisterHandoffReportWorkstream struct {
	ProjectID, ScopeID string
	Key                *string
	Title              string
	Kind               handoffreport.WorkstreamKind
	CatalogState       handoffreport.CatalogState
	ExternalRefs       []handoffreport.ExternalReference
	Labels             []string
}

type RememberMemoryRequest ¶

type RememberMemoryRequest struct {
	Kind             string
	Text             string
	Reason           *string
	ExpectedRevision *int64
}

type Resource ¶

type Resource interface {
	Close(context.Context) error
}

Resource is an explicitly owned Runtime dependency closed after scheduled work and admitted operations have drained.

type ReviewApplication ¶

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

func NewReviewApplication ¶

func NewReviewApplication(runtime *Runtime, services ReviewServiceFactory) (*ReviewApplication, error)

func (*ReviewApplication) Approve ¶

func (a *ReviewApplication) Approve(
	ctx context.Context,
	scopeID, candidateID string,
	expectedVersion int64,
) (review.Snapshot, error)

func (*ReviewApplication) GetCandidate ¶

func (a *ReviewApplication) GetCandidate(ctx context.Context, scopeID, candidateID string) (review.Snapshot, error)

func (*ReviewApplication) GetExperience ¶

func (a *ReviewApplication) GetExperience(
	ctx context.Context,
	scopeID string,
	ref artifact.Ref,
) (experience.Experience, error)

func (*ReviewApplication) GetSkill ¶

func (a *ReviewApplication) GetSkill(
	ctx context.Context,
	scopeID string,
	ref artifact.Ref,
) (skill.Skill, error)

func (*ReviewApplication) ListCandidates ¶

func (a *ReviewApplication) ListCandidates(
	ctx context.Context,
	scopeID string,
	status review.Status,
	family, cursor *string,
	limit int,
) (review.Page, error)

func (*ReviewApplication) ProposeExperience ¶

func (a *ReviewApplication) ProposeExperience(
	ctx context.Context,
	scopeID string,
	proposal experience.Content,
	sources []source.Ref,
	artifacts []artifact.Ref,
	target *artifact.Ref,
	reason *string,
) (review.Snapshot, error)

func (*ReviewApplication) ProposeSkill ¶

func (a *ReviewApplication) ProposeSkill(
	ctx context.Context,
	scopeID string,
	proposal skill.Content,
	sources []source.Ref,
	artifacts []artifact.Ref,
	target *artifact.Ref,
	reason *string,
) (review.Snapshot, error)

func (*ReviewApplication) Reject ¶

func (a *ReviewApplication) Reject(
	ctx context.Context,
	scopeID, candidateID string,
	expectedVersion int64,
	reason string,
) (review.Snapshot, error)

func (*ReviewApplication) Revise ¶

func (a *ReviewApplication) Revise(
	ctx context.Context,
	scopeID, candidateID string,
	expectedVersion int64,
	proposal any,
	sources []source.Ref,
	artifacts []artifact.Ref,
	target *artifact.Ref,
	reason *string,
) (review.Snapshot, error)

type ReviewServiceFactory ¶

type ReviewServiceFactory func(string) (*review.Service, error)

type Runtime ¶

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

Runtime owns operation admission and per-scope write serialization. Domain services remain lifecycle-free and are invoked inside these boundaries by endpoint-facing application methods.

func New ¶

func New(resources ...Resource) *Runtime

func NewConfigured ¶

func NewConfigured(
	options RuntimeOptions,
	recorder ModelUsageRecorder,
	resources ...Resource,
) (*Runtime, error)

NewConfigured constructs a Runtime with bounded Scope retention and optional low-cardinality observation. A zero ScopeCacheSize selects the current compatibility default.

func NewWithModelUsageRecorder ¶

func NewWithModelUsageRecorder(recorder ModelUsageRecorder, resources ...Resource) *Runtime

NewWithModelUsageRecorder constructs a Runtime whose admitted operations can attribute successful inference calls. The recorder is deliberately best-effort and does not participate in Runtime resource ownership.

func (*Runtime) AttachScheduler ¶

func (r *Runtime) AttachScheduler(scheduler SchedulerLifecycle) error

AttachScheduler transfers lifecycle ownership after a scheduler has been opened with handlers that dispatch through this Runtime.

func (*Runtime) Background ¶

func (r *Runtime) Background(ctx context.Context, fn func(context.Context) error) error

Background serializes scheduled processors across all Scopes while keeping their execution visible to lifecycle admission.

func (*Runtime) BackgroundOperation ¶

func (r *Runtime) BackgroundOperation(
	ctx context.Context,
	name string,
	fn func(context.Context) (string, error),
) (err error)

BackgroundOperation serializes one named background operation and lets the owning transport trace it as a root. The callback returns its observable outcome separately because scheduled scope failures may be isolated rather than returned as the dispatch error.

func (*Runtime) Close ¶

func (r *Runtime) Close(ctx context.Context) error

Close atomically rejects new operations and waits for every admitted read, writer, lock waiter, and background processor. If ctx is canceled before the drain completes, admission is restored so the owner can retry shutdown.

func (*Runtime) Operation ¶

func (r *Runtime) Operation(ctx context.Context, fn func(context.Context) error) error

Operation admits one unscoped read/use case and tracks it through close.

func (*Runtime) ScopedRead ¶

func (r *Runtime) ScopedRead(ctx context.Context, scopeID string, fn func(context.Context, string) error) error

ScopedRead admits one scoped operation without serializing it against other reads. It is still drained during shutdown.

func (*Runtime) ScopedWrite ¶

func (r *Runtime) ScopedWrite(ctx context.Context, scopeID string, fn func(context.Context, string) error) error

ScopedWrite admits one operation then acquires the reference-counted lock for its exact Scope. Waiting writers are active operations, so Close waits until each either runs or observes cancellation.

type RuntimeOptions ¶

type RuntimeOptions struct {
	ScopeCacheSize int
	ScopeEvictor   ScopeEvictor
	ScopeObserver  ScopeCacheObserver
	Tracing        StageTracing
}

type ScheduledObservation ¶

type ScheduledObservation struct {
	Operation      string
	Outcome        string
	Duration       time.Duration
	SourceCount    int
	CandidateCount *int
	Err            error
}

type ScheduledObserver ¶

type ScheduledObserver func(context.Context, ScheduledObservation)

type ScheduledProcessor ¶

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

ScheduledProcessor serializes both persisted jobs globally, then visits Source-backed Scopes deterministically. Each Scope keeps its normal write gate, while one failure is observed and isolated from later Scopes.

func NewScheduledProcessor ¶

func NewScheduledProcessor(
	runtime *Runtime,
	scopes ScheduledScopeLister,
	memory *MemoryApplication,
	experience *ExperienceIncubationApplication,
	observer ScheduledObserver,
	clock func() time.Time,
) (*ScheduledProcessor, error)

func (*ScheduledProcessor) IncubateExperiences ¶

func (p *ScheduledProcessor) IncubateExperiences(ctx context.Context) error

func (*ScheduledProcessor) ProcessSourceWindows ¶

func (p *ScheduledProcessor) ProcessSourceWindows(ctx context.Context) error

type ScheduledScopeLister ¶

type ScheduledScopeLister interface {
	ScopeIDs(context.Context) ([]string, error)
}

type SchedulerLifecycle ¶

type SchedulerLifecycle interface {
	Pause()
	Close(context.Context) error
}

SchedulerLifecycle is the consumer-shaped shutdown surface required by the Runtime. Pause prevents new scheduled dispatch; Close drains its loop.

type ScopeCacheObserver ¶

type ScopeCacheObserver func(cached, active int)

type ScopeEvictor ¶

type ScopeEvictor func(scopeID string)

type SourceApplication ¶

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

func NewSourceApplication ¶

func NewSourceApplication(runtime *Runtime, backend SourceCaptureBackend) (*SourceApplication, error)

func (*SourceApplication) CaptureContent ¶

func (a *SourceApplication) CaptureContent(
	ctx context.Context,
	scopeID, sourceID, content string,
	metadata map[string]any,
) (SourceReceipt, error)

type SourceCaptureBackend ¶

type SourceCaptureBackend interface {
	Capture(context.Context, string, source.ContentCapture) (source.Ref, int64, error)
}

type SourceReceipt ¶

type SourceReceipt struct {
	Ref      source.Ref
	Sequence int64
}

type StageSpan ¶

type StageSpan interface {
	SetAttributes(map[string]TraceAttribute)
	Finish(outcome string, err error)
}

StageSpan is the minimal tracing surface consumed by Runtime operations. Implementations must treat attributes as operational metadata only.

type StageTracing ¶

type StageTracing interface {
	StartStage(context.Context, string, map[string]TraceAttribute) (context.Context, StageSpan)
}

type StageTracingFunc ¶

type StageTracingFunc func(context.Context, string, map[string]TraceAttribute) (context.Context, StageSpan)

func (StageTracingFunc) StartStage ¶

func (f StageTracingFunc) StartStage(
	ctx context.Context,
	name string,
	attributes map[string]TraceAttribute,
) (context.Context, StageSpan)

type StateError ¶

type StateError struct{ Code string }

func (*StateError) Error ¶

func (e *StateError) Error() string

type StatisticsApplication ¶

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

func NewStatisticsApplication ¶

func NewStatisticsApplication(
	runtime *Runtime,
	readers StatisticsReaderFactory,
	clock Clock,
) (*StatisticsApplication, error)

func (*StatisticsApplication) Overview ¶

func (a *StatisticsApplication) Overview(
	ctx context.Context,
	scopeID string,
	period stats.Period,
) (stats.Statistics, error)

type StatisticsReader ¶

type StatisticsReader interface {
	Overview(context.Context, stats.Period, time.Time) (stats.Statistics, error)
}

StatisticsReader is the exact read surface needed by the product-facing application. Persistence implementations may additionally record usage, but the HTTP operation does not depend on those mutation methods.

type StatisticsReaderFactory ¶

type StatisticsReaderFactory func(string) (StatisticsReader, error)

type TraceAttribute ¶

type TraceAttribute = any

TraceAttribute values are validated by the tracing adapter before export. Runtime call sites use only string, bool, int, int64, and float64 values.

type WorkApplication ¶

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

WorkApplication orchestrates the delegation, Handoff, acknowledgement, and outcome loop over the existing Source journal and Handoff authority.

func NewWorkApplication ¶

func NewWorkApplication(runtime *Runtime, sources WorkSourceBackend, handoffs HandoffServiceFactory) (*WorkApplication, error)

func (*WorkApplication) Acknowledge ¶

func (a *WorkApplication) Acknowledge(ctx context.Context, scopeID string, request work.Acknowledge) (work.Acknowledgement, error)

func (*WorkApplication) Continuity ¶

func (a *WorkApplication) Continuity(ctx context.Context, scopeID string, selected *artifact.Ref) (work.Continuity, error)

func (*WorkApplication) CreateContract ¶

func (a *WorkApplication) CreateContract(ctx context.Context, scopeID string, request work.CreateContract) (work.SourceReceipt, error)

func (*WorkApplication) HandoffCurrent ¶

func (a *WorkApplication) HandoffCurrent(ctx context.Context, scopeID string, request work.HandoffCurrent) (work.PreparedHandoff, error)

func (*WorkApplication) RecordOutcome ¶

func (a *WorkApplication) RecordOutcome(ctx context.Context, scopeID string, request work.RecordOutcome) (work.SourceReceipt, error)

type WorkSourceBackend ¶

type WorkSourceBackend interface {
	Capture(context.Context, string, source.ContentCapture) (source.Ref, int64, error)
	Entries(context.Context, string) ([]source.JournalEntry, error)
}

Jump to

Keyboard shortcuts

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