assembler

package
v0.0.0-...-553e076 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	StatusSuccess = "success"
	StatusFailed  = "failed"
	StatusBypass  = "bypass"
)
View Source
const ThresholdTuningSchemaVersion = "v1"

Variables

This section is empty.

Functions

func RenderThresholdTuningMarkdown

func RenderThresholdTuningMarkdown(report ThresholdTuningReport) string

Types

type AgenticRouter

type AgenticRouter interface {
	DecideStage2(ctx context.Context, req AgenticRoutingRequest) (AgenticRoutingDecision, error)
}

AgenticRouter decides whether Stage2 should run for a context stage2 assemble cycle.

type AgenticRouterFunc

type AgenticRouterFunc func(ctx context.Context, req AgenticRoutingRequest) (AgenticRoutingDecision, error)

AgenticRouterFunc adapts a function to AgenticRouter.

func (AgenticRouterFunc) DecideStage2

DecideStage2 invokes wrapped function.

type AgenticRoutingDecision

type AgenticRoutingDecision struct {
	RunStage2 bool
	Reason    string
}

AgenticRoutingDecision is the callback output for context stage2 routing.

type AgenticRoutingRequest

type AgenticRoutingRequest struct {
	RunID         string
	SessionID     string
	ModelProvider string
	Model         string
	Input         string
	Messages      []types.Message
	Capabilities  []types.ModelCapability
}

AgenticRoutingRequest is the normalized callback input for context stage2 agentic routing.

type Assembler

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

Assembler composes context before model execution using prefix-baseline, stage2-routing, and pressure-compaction policies.

func New

func New(cfgProvider func() runtimeconfig.ContextAssemblerConfig, opts ...Option) *Assembler

New creates a context assembler with runtime config provider and optional extensions.

func (*Assembler) Assemble

Assemble builds model-ready context with prefix-baseline, stage2-routing, and pressure-compaction policies.

func (*Assembler) AssembleWithHandoff

AssembleWithHandoff preserves the existing Assemble result and optionally emits a bounded handoff when the runtime handoff switch is enabled.

func (*Assembler) BuildHandoff

BuildHandoff projects an assembled model request into the bounded handoff contract. It is deliberately side-effect-free; source history and checkpoint owners remain authoritative for bodies and lineage.

func (*Assembler) OnRunFinished

func (a *Assembler) OnRunFinished(runID string)

OnRunFinished compacts run-scoped context assembler caches without changing external semantics.

func (*Assembler) RestoreHandoff

func (a *Assembler) RestoreHandoff(h handoff.Handoff, resolver handoff.Resolver) (handoff.RestoreResult, error)

RestoreHandoff validates and resolves a handoff before any caller-owned context mutation. The assembler remains stateless with respect to source history; callers decide how to inject the returned restore projection.

func (*Assembler) RestoreHandoffWithStore

func (a *Assembler) RestoreHandoffWithStore(h handoff.Handoff, resolver handoff.Resolver, store handoff.RestoreOperationStore) (handoff.RestoreResult, error)

RestoreHandoffWithStore performs reference validation and uses the injected durable operation store when available. The store is consulted only after schema validation and before any source-owner mutation.

func (*Assembler) SetAgenticRouter

func (a *Assembler) SetAgenticRouter(router AgenticRouter)

SetAgenticRouter updates agentic router callback at runtime.

type DBSpillBackend

type DBSpillBackend interface {
	SpillBackend
}

DBSpillBackend is a placeholder SPI for future DB implementations.

type ObjectSpillBackend

type ObjectSpillBackend interface {
	SpillBackend
}

ObjectSpillBackend is a placeholder SPI for future object-storage implementations.

type Option

type Option func(*Assembler)

Option customizes assembler behavior for embedding/reranker/redaction integrations.

func WithAgenticRouter

func WithAgenticRouter(router AgenticRouter) Option

WithAgenticRouter registers a host callback for context stage2 agentic routing decisions.

func WithHandoffRestoreStore

func WithHandoffRestoreStore(store handoff.RestoreOperationStore) Option

WithHandoffRestoreStore injects a durable operation identity store for crash/restart-safe handoff restores.

func WithMemoryConfigProvider

func WithMemoryConfigProvider(provider func() runtimeconfig.RuntimeMemoryConfig) Option

WithMemoryConfigProvider injects runtime memory config provider for stage2 memory facade mode.

func WithRedactionConfigProvider

func WithRedactionConfigProvider(provider func() runtimeconfig.SecurityRedactionConfig) Option

WithRedactionConfigProvider injects runtime redaction config provider for recap/stage2 sanitization.

func WithRuntimeContextConfigProvider

func WithRuntimeContextConfigProvider(provider func() runtimeconfig.RuntimeContextConfig) Option

WithRuntimeContextConfigProvider injects runtime context-domain config provider for JIT controls.

func WithSemanticEmbeddingScorer

func WithSemanticEmbeddingScorer(key string, scorer SemanticEmbeddingScorer) Option

WithSemanticEmbeddingScorer registers semantic embedding scorer extension.

func WithSemanticReranker

func WithSemanticReranker(provider string, reranker SemanticReranker) Option

WithSemanticReranker registers provider-specific semantic reranker extension.

type SemanticEmbeddingScoreRequest

type SemanticEmbeddingScoreRequest struct {
	Selector string
	Provider string
	Model    string
	Source   string
	Summary  string
}

type SemanticEmbeddingScorer

type SemanticEmbeddingScorer interface {
	Score(ctx context.Context, req SemanticEmbeddingScoreRequest) (float64, error)
}

SemanticEmbeddingScorer is a provider-agnostic SPI hook for semantic quality scoring. Provider adapter binding is intentionally deferred to keep the SPI boundary stable.

type SemanticRerankRequest

type SemanticRerankRequest struct {
	Provider      string
	Model         string
	Source        string
	Summary       string
	RuleScore     float64
	Embedding     float64
	CurrentScore  float64
	BaseThreshold float64
}

type SemanticRerankResult

type SemanticRerankResult struct {
	Score float64
}

type SemanticReranker

type SemanticReranker interface {
	Rerank(ctx context.Context, req SemanticRerankRequest) (SemanticRerankResult, error)
}

SemanticReranker is an extension hook for provider-specific score reranking.

type SpillBackend

type SpillBackend interface {
	Append(ctx context.Context, rec spillRecord) error
	LoadByRun(ctx context.Context, runID string, limit int) ([]spillRecord, error)
}

type ThresholdRecommendation

type ThresholdRecommendation struct {
	Threshold  float64 `json:"threshold"`
	Precision  float64 `json:"precision"`
	Recall     float64 `json:"recall"`
	F1         float64 `json:"f1"`
	Accepting  bool    `json:"accepting"`
	ReasonCode string  `json:"reason_code,omitempty"`
	Confidence string  `json:"confidence"`
}

type ThresholdTuningReport

type ThresholdTuningReport struct {
	SchemaVersion      string                  `json:"schema_version"`
	Recommendation     ThresholdRecommendation `json:"recommendation"`
	CorpusReadiness    string                  `json:"corpus_readiness"`
	CorpusReadinessMsg string                  `json:"corpus_readiness_message"`
}

type ThresholdTuningRequest

type ThresholdTuningRequest struct {
	SchemaVersion string                  `json:"schema_version"`
	Samples       []ThresholdTuningSample `json:"samples"`
	MinPrecision  float64                 `json:"min_precision"`
	MinRecall     float64                 `json:"min_recall"`
}

type ThresholdTuningSample

type ThresholdTuningSample struct {
	ID       string  `json:"id"`
	Provider string  `json:"provider"`
	Model    string  `json:"model"`
	Score    float64 `json:"score"`
	Label    bool    `json:"label"`
}

Jump to

Keyboard shortcuts

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