compactioncontinuity

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: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FailureModeFailOpen   = "fail_open"
	FailureModeFailClosed = "fail_closed"

	DefaultExtractorTimeout = 8 * time.Second
	DefaultMaxInputTokens   = 12_000
	DefaultMaxOutputTokens  = 2_000
	DefaultMaxConcurrency   = 2
	DefaultQueueCapacity    = 16
	DefaultBarrierTimeout   = 2 * time.Second
	DefaultPendingResultTTL = 2 * time.Hour
	DefaultMaxCapsuleTokens = 2_500
	DefaultMaxCapsuleBytes  = 1 << 20
	DefaultSourceTTL        = 2 * time.Hour
	DefaultMaxSourceBytes   = 4 << 20
	DefaultResultMaxBytes   = 4 << 20
	DefaultResultMaxCount   = 16
	DefaultMaxBranchEntries = 1024
	DefaultBranchTTL        = 2 * time.Hour
	MaxExtractorTimeout     = 24 * time.Hour
	MaxInputTokens          = 1_000_000
	MaxOutputTokens         = 1_000_000
	MaxConcurrency          = 128
	MaxQueueCapacity        = 4_096
	MaxBarrierTimeout       = 24 * time.Hour
	MaxRetention            = 30 * 24 * time.Hour
	MaxCapsuleTokens        = 100_000
	MaxCapsuleBytes         = 64 << 20
	MaxSourceBytes          = 64 << 20
	MaxResultBytes          = 64 << 20
	MaxResultCount          = 4_096
	MaxBranchEntries        = 65_536
)
View Source
const ID = "compaction-continuity"

ID is the official standard-distribution feature factory id.

Variables

This section is empty.

Functions

func FeatureBundle

func FeatureBundle(_ Config) lipfeature.FeatureBundle

FeatureBundle retains the registry's configuration-only compatibility surface. Runtime composition must use FeatureBundleWithPort to enable work.

func FeatureBundleWithPort

func FeatureBundleWithPort(cfg Config, parent ParentPort) (lipfeature.FeatureBundle, error)

FeatureBundleWithPort contributes the feature callback after runtime composition has supplied the process-owned parent authority port.

func FeatureBundleWithPortAndObservability

func FeatureBundleWithPortAndObservability(cfg Config, parent ParentPort, sink observability.Sink) (lipfeature.FeatureBundle, error)

FeatureBundleWithPortAndObservability is the explicit composition seam for a host that has a content-free feature diagnostics sink. A nil sink keeps the existing no-observability behavior.

func ValidatePrerequisites

func ValidatePrerequisites(c Config, p Prerequisites) error

ValidatePrerequisites applies the enabled-feature dependency gate. Disabled registrations never call this function, so they remain a no-op even with missing extractor configuration or process capabilities.

Types

type BarrierConfig

type BarrierConfig struct {
	Timeout time.Duration
}

BarrierConfig controls the bounded wait for an already-submitted result.

type CapsuleConfig

type CapsuleConfig struct {
	MaxTokens int
	MaxBytes  int
}

CapsuleConfig bounds serialized continuity state.

type Config

type Config struct {
	Preserve  PreserveConfig
	Extractor ExtractorConfig
	Worker    WorkerConfig
	Barrier   BarrierConfig
	Capsule   CapsuleConfig
	Source    SourceConfig
	Result    ResultConfig
	Failure   FailureConfig

	// Flattened aliases retain the D18 operator-facing names and make retention
	// policy explicit to callers. Normalize keeps aliases equal to their group.
	BarrierTimeout   time.Duration
	PendingResultTTL time.Duration
	MaxCapsuleTokens int
	SourceTTL        time.Duration
	FailureMode      string
	BranchTTL        time.Duration
	MaxBranchEntries int
}

Config is the validated, generation-local compaction-continuity policy. All fields are values (no maps, slices, or mutable service handles), so a Snapshot is safe to retain for an in-flight submission across reload.

func DecodeConfig

func DecodeConfig(n yaml.Node) (Config, error)

DecodeConfig decodes one feature-private YAML subtree. Empty/null config receives safe bounded defaults; unknown nested keys are rejected before decoding so typos cannot silently widen a billable egress policy.

func (Config) Normalize

func (c Config) Normalize() (Config, error)

Normalize returns a complete bounded value copy. It is useful to callers constructing config in tests or composition code without YAML.

func (Config) Snapshot

func (c Config) Snapshot() Config

Snapshot returns the immutable per-generation/submission value copy.

func (Config) Validate

func (c Config) Validate() error

Validate returns an error for an already materialized Config. DecodeConfig should be preferred for YAML because it distinguishes omitted from explicit zero bounds.

type ExtractorConfig

type ExtractorConfig struct {
	Enabled         bool
	Route           string
	Inherit         bool
	Timeout         time.Duration
	MaxInputTokens  int
	MaxOutputTokens int
	// These aliases mirror the original D18 shape. Worker is the canonical
	// composition group; both views are kept equal after normalization.
	MaxConcurrency int
	QueueCapacity  int
}

ExtractorConfig is the immutable semantic-extractor policy captured by a generation and copied into each submitted background job.

type FailureConfig

type FailureConfig struct {
	Mode string
}

FailureConfig selects request-time preservation failure behavior.

type InjectionTarget

type InjectionTarget struct {
	BoundaryKey     string
	CapsuleRevision uint64
}

InjectionTarget identifies one boundary/revision that still needs a canonical continuity projection on a later eligible request.

type InjectionWatermark

type InjectionWatermark struct {
	BranchBinding   string
	BoundaryKey     string
	CapsuleRevision uint64
}

InjectionWatermark records one successfully released projection.

type ParentBranch

type ParentBranch struct {
	Binding string
	TraceID string
	ALegID  string
	BLegID  string
}

ParentBranch is the bounded authority captured before any detached child is created. Binding is the only value used as a continuity lookup key. The remaining fields are correlation metadata for the detached request and are never included in its prompt.

type ParentPort

ParentPort is the smallest authority/state seam consumed by this feature. Capture must derive the parent from trusted scope in ctx plus PreservationMeta; it must not select a branch from child A-leg or untrusted call hints. ValidatePendingJob is the per-parent late-result access guard used by later response-boundary work; RequestOpened itself never awaits a result.

type ParentState

type ParentState struct {
	Revision                  uint64
	CapsuleJSON               []byte
	CapsuleDigest             [32]byte
	SourceJSON                []byte
	SourceHighWatermark       string
	PendingJobID              auxiliary.JobID
	PendingJobTargetRevision  uint64
	PendingJobBranchBinding   string
	PendingPreviewIntent      *PreviewIntent
	PendingInjection          *InjectionTarget
	LastReleasedInjection     *InjectionWatermark
	LastCompactionTransaction string
}

ParentState is an opaque defensive snapshot of one authoritative parent. CapsuleJSON and SourceJSON are feature-owned serialized values; a runtime adapter remains responsible for persistence, bounds, and compare-and-swap.

type Plugin

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

Plugin is the feature-owned successful-Open preserver. It has no global state; config is normalized once and the parent port is explicitly bound.

func New

func New(cfg Config, parent ParentPort) (*Plugin, error)

New constructs one immutable-generation feature instance.

func NewWithObservability

func NewWithObservability(cfg Config, parent ParentPort, sink observability.Sink) (*Plugin, error)

NewWithObservability constructs one immutable-generation feature instance with an optional content-free diagnostics sink. The sink is deliberately a feature-local seam; scheduler queue, token, cost and accounting truth stays in the existing auxiliary/billing surfaces.

func (*Plugin) AfterResponseRelease

func (p *Plugin) AfterResponseRelease(ctx context.Context, ev lipapi.Event, meta compaction.PreservationMeta, _ compaction.Services) (err error)

AfterResponseRelease is the only release-side watermark commit point. Core invokes it after detector finalization and before returning the event.

func (*Plugin) BeforeRequest

func (p *Plugin) BeforeRequest(ctx context.Context, call *lipapi.Call, preview compaction.RequestPreview, meta compaction.PreservationMeta, services compaction.Services) (err error)

BeforeRequest consumes only pure detector metadata. It may prepare a non-billable intent and inject an already available capsule, but it never submits fresh auxiliary work before the primary request opens. Pre-open staging is authorized by requirement 7.12; §571 holds operatively: failed opens never bind preview intents, submit billable jobs, or commit release watermarks (see RequestOpenFailed).

func (*Plugin) BeforeResponseRelease

func (p *Plugin) BeforeResponseRelease(ctx context.Context, ev *lipapi.Event, preview compaction.ResponsePreview, meta compaction.PreservationMeta, services compaction.Services) (err error)

BeforeResponseRelease consumes only an existing pending result. The augmentation matcher is an explicit empty allowlist for today's canonical compaction contract, so it records the capsule for the next eligible request and leaves the canonical event byte-for-byte intact.

func (*Plugin) ID

func (p *Plugin) ID() string

func (*Plugin) RequestOpenFailed

func (p *Plugin) RequestOpenFailed(_ context.Context, meta compaction.PreservationMeta, _ compaction.Services) (err error)

RequestOpenFailed lets the coordinator's bounded TTL cleanup expire the non-billable preview intent while preserving any pending injection target.

func (*Plugin) RequestOpened

func (p *Plugin) RequestOpened(ctx context.Context, call lipapi.Call, events []compaction.Event, meta compaction.PreservationMeta, services compaction.Services) (err error)

RequestOpened schedules at most one detached extraction for one committed detector transaction. All failures are deliberately feature-local and fail-open because the primary request is already open.

type Prerequisites

type Prerequisites struct {
	DetectorPreview   bool
	DetectorCommit    bool
	BranchCoordinator bool
	BackgroundAux     bool
}

Prerequisites describes the capabilities available at generation composition. The feature package deliberately receives capabilities as booleans rather than importing runtime or process-owned service types.

type PreserveConfig

type PreserveConfig struct {
	Plan                 bool `yaml:"plan"`
	UserDecisions        bool `yaml:"user_decisions"`
	Constraints          bool `yaml:"constraints"`
	Rationale            bool `yaml:"rationale"`
	RejectedAlternatives bool `yaml:"rejected_alternatives"`
}

PreserveConfig selects deterministic categories retained in a capsule.

type PreviewIntent

type PreviewIntent struct {
	Key                  string
	TargetSourceRevision uint64
}

PreviewIntent is a non-billable completion-only boundary prepared before the primary request opens.

type ResultConfig

type ResultConfig struct {
	TTL      time.Duration
	MaxBytes int
	MaxCount int
}

ResultConfig bounds raw background results before validation and merge.

type SourceConfig

type SourceConfig struct {
	TTL      time.Duration
	MaxBytes int
}

SourceConfig bounds the sanitized source window retained for later turns.

type WorkerConfig

type WorkerConfig struct {
	MaxConcurrency int
	QueueCapacity  int
}

WorkerConfig bounds process-owned background admission.

Directories

Path Synopsis
Package augmentation owns the deliberately narrow response-side continuation-carrier allowlist.
Package augmentation owns the deliberately narrow response-side continuation-carrier allowlist.
Package capsule contains the provider-neutral, bounded continuity capsule.
Package capsule contains the provider-neutral, bounded continuity capsule.
Package carriers recognizes a small, versioned catalog of canonical structured plan shapes.
Package carriers recognizes a small, versioned catalog of canonical structured plan shapes.
Package extractor builds the one canonical child call used for semantic continuity extraction and validates its bounded result.
Package extractor builds the one canonical child call used for semantic continuity extraction and validates its bounded result.
Package injection applies a bounded, provider-neutral continuity projection to a canonical call.
Package injection applies a bounded, provider-neutral continuity projection to a canonical call.
Package observability provides the content-free diagnostics seam for the compaction-continuity feature.
Package observability provides the content-free diagnostics seam for the compaction-continuity feature.
Package policy resolves the continuity egress policy at request time.
Package policy resolves the continuity egress policy at request time.
Package resultmerge consumes one bounded background result and applies it to the authoritative parent continuity branch.
Package resultmerge consumes one bounded background result and applies it to the authoritative parent continuity branch.
Package source prepares a small, canonical and privacy-bounded source window for continuity extraction.
Package source prepares a small, canonical and privacy-bounded source window for continuity extraction.
Package state contains the process-owned state coordination used by compaction preservation.
Package state contains the process-owned state coordination used by compaction preservation.

Jump to

Keyboard shortcuts

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