extractor

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package extractor builds the one canonical child call used for semantic continuity extraction and validates its bounded result. It intentionally depends only on canonical lipapi contracts and the auxiliary SDK seam.

Index

Constants

View Source
const (
	// Role and Visibility are content-free auxiliary lineage labels.
	Role       = "compaction_continuity_extractor"
	Visibility = "private"
	PluginID   = "compaction-continuity"

	DefaultMaxOutputToken = 2_000
	DefaultTimeout        = 8 * time.Second
)
View Source
const (
	// DefaultMaxInputTokens mirrors the validated extractor.max_input_tokens
	// policy captured by the feature composition layer.
	DefaultMaxInputTokens = 12_000
)
View Source
const OutputSchema = `` /* 624-byte string literal not displayed */

OutputSchema is the fixed result shape shown to the child. It is kept as a literal so the prompt cannot drift into a second, implicit output contract.

View Source
const SystemPrompt = `` /* 695-byte string literal not displayed */

SystemPrompt is fixed extractor policy. Source text is always supplied in a separately delimited user payload and is data, never an instruction.

Variables

View Source
var (
	ErrInvalidResult = errors.New("extractor: invalid result")
)

Functions

func BuildRequest

func BuildRequest(in Input) (auxiliary.Request, error)

BuildRequest constructs exactly one detached, no-tools auxiliary request. It does not call routing, a provider, billing, or another plugin.

func Submit

func Submit(ctx context.Context, client auxiliary.BackgroundClient, in Input, coalesceKey string) (auxiliary.JobID, error)

Submit queues one detached extraction through the SDK background seam.

Types

type DecisionUpdate

type DecisionUpdate struct {
	ID          string
	ConflictKey string
	Supersedes  []string
	Statement   string
	Status      capsule.DecisionStatus
	Rationale   string
	SourceRef   string
	Authority   capsule.Authority
	Source      capsule.Source
}

type FactKind

type FactKind string
const (
	FactConstraint          FactKind = "constraint"
	FactRejectedAlternative FactKind = "rejected_alternative"
	FactOpenQuestion        FactKind = "open_question"
)

type FactUpdate

type FactUpdate struct {
	Kind      FactKind
	ID        string
	Statement string
	Status    capsule.FactStatus
	Rationale string
	SourceRef string
}

type Input

type Input struct {
	Route          string
	Inherit        bool
	InheritedRoute string

	ParentBranchBinding string
	ParentTraceID       string
	ParentALegID        string
	ParentBLegID        string

	Previous            capsule.Envelope
	DeterministicPlan   *capsule.Plan
	DeterministicFacts  []capsule.Fact
	SanitizedDelta      []source.Entry
	SourceHighWatermark string

	// MaxInputTokens is copied from the immutable extractor.max_input_tokens
	// configuration captured for this job. BuildRequest enforces it without a
	// provider tokenizer by counting each UTF-8 byte as one token-equivalent
	// unit, a conservative upper bound on token count.
	MaxInputTokens    int
	MaxOutputTokens   int
	Timeout           time.Duration
	AllowedSourceRefs []string
}

Input is the bounded, already-sanitized source for one child call. The parent branch binding is trusted lineage only; it is never copied into the canonical prompt or Call.Session.

type Limits

type Limits struct {
	MaxBytes          int
	MaxDepth          int
	MaxItems          int
	MaxStringBytes    int
	MaxSourceRefBytes int
	MaxConflictBytes  int
	MaxSupersedes     int
}

Limits bounds the untrusted child result before it can become capsule state. Zero values use DefaultLimits.

func DefaultLimits

func DefaultLimits() Limits

type ParseOptions

type ParseOptions struct {
	Previous            capsule.Envelope
	ExpectedBranch      string
	AllowedSourceRefs   []string
	SourceHighWatermark string
	Limits              Limits
}

ParseOptions supplies the locally validated parent capsule and source authority. The result schema has no branch field: cross-branch output is rejected by checking the parent binding and supersede references here.

type PlanUpdate

type PlanUpdate struct {
	ID        string
	Text      string
	Status    capsule.StepStatus
	SourceRef string
}

type Removal

type Removal struct {
	ID        string
	Status    capsule.DecisionStatus
	SourceRef string
}

type Result

type Result struct {
	SchemaVersion uint8
	BaseRevision  uint64
	Facts         []FactUpdate
	PlanUpdates   []PlanUpdate
	Decisions     []DecisionUpdate
	Removals      []Removal
}

func Await

Await parses one previously submitted child result through the SDK seam.

func Collect

func Collect(ctx context.Context, client auxiliary.Client, in Input) (Result, error)

Collect performs one and only one auxiliary collection and parses its text. There is deliberately no summary rewrite or provider-specific fallback.

func ParseResult

func ParseResult(data []byte, opts ParseOptions) (Result, error)

ParseResult accepts exactly one strict JSON object and validates it against the locally verified parent capsule. It never trusts child authority fields.

func (Result) Delta

func (r Result) Delta(branchBinding, sourceHighWatermark string) capsule.Delta

Delta converts validated semantic additions and terminal decision changes into the capsule's authority-safe delta. The parser has already established that every transition targets an active semantic parent decision.

Jump to

Keyboard shortcuts

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