resultmerge

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

Documentation

Overview

Package resultmerge consumes one bounded background result and applies it to the authoritative parent continuity branch. It owns no branch store or scheduler; both are deliberately consumed through the small interfaces below.

Index

Constants

View Source
const (
	DefaultMaxCapsuleBytes  = 1 << 20
	DefaultMaxCapsuleTokens = 2_500
)
View Source
const DefaultCommitTimeout = time.Second

Variables

View Source
var (
	ErrInvalidJob         = errors.New("resultmerge: invalid pending job")
	ErrInvalidParentState = errors.New("resultmerge: invalid parent state")
	ErrInvalidResult      = errors.New("resultmerge: invalid collected result")
	ErrAwaitTimeout       = errors.New("resultmerge: result await timed out")
	ErrStaleResult        = errors.New("resultmerge: stale result")
	ErrRejected           = errors.New("resultmerge: result rejected")
)

Functions

This section is empty.

Types

type BackgroundClient

type BackgroundClient interface {
	Await(context.Context, auxiliary.JobID) (lipapi.Collected, error)
	Forget(auxiliary.JobID)
}

BackgroundClient is intentionally smaller than auxiliary.BackgroundClient: late-result consumption cannot submit work and therefore cannot accidentally create a new billable job.

type Config

type Config struct {
	MaxCapsuleBytes  int
	MaxCapsuleTokens int
}

Config bounds the next serialized capsule. Both dimensions are enforced independently by capsule.PruneWithLimits before parent commit.

type DecodeInput

type DecodeInput struct {
	Previous            capsule.Envelope
	ExpectedBranch      string
	SourceHighWatermark string
}

DecodeInput is built only after the parent capsule has been verified. It is the complete authority context required by a strict result parser.

type DeltaDecoder

type DeltaDecoder interface {
	Decode(lipapi.Collected, DecodeInput) (capsule.Delta, error)
}

DeltaDecoder is implemented by the strict extractor-result parser. A successful return promises that the JSON/schema and semantic bounds have already been checked; Service still rechecks branch and revision bindings.

type ExtractorDecoder

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

ExtractorDecoder adapts the strict feature extractor parser to the late result seam. It deliberately parses against the verified parent supplied by Service rather than trusting child-provided branch or revision metadata.

func NewExtractorDecoder

func NewExtractorDecoder(cfg ExtractorDecoderConfig) *ExtractorDecoder

func (*ExtractorDecoder) Decode

func (d *ExtractorDecoder) Decode(collected lipapi.Collected, input DecodeInput) (capsule.Delta, error)

type ExtractorDecoderConfig

type ExtractorDecoderConfig struct {
	AllowedSourceRefs []string
	Limits            extractor.Limits
}

ExtractorDecoderConfig captures only immutable parser policy for one generation/job. Source references are bounded sanitized-source handles, never transcript or branch identifiers.

type Job

type Job struct {
	ID                  auxiliary.JobID
	ParentBranchBinding string
}

Job identifies a pending result owned by one authoritative parent branch.

type Outcome

type Outcome struct {
	Status Status
	State  ParentState
}

type ParentCoordinator

type ParentCoordinator interface {
	ValidatePendingJob(context.Context, string, auxiliary.JobID) (ParentState, error)
	CommitCapsuleForJob(context.Context, string, auxiliary.JobID, string, uint64, []byte, [32]byte, string) (ParentState, error)
}

ParentCoordinator is an adapter seam for the process-owned coordinator. The branch binding is the only branch identity visible here; a child A-leg is never a lookup key. CommitCapsuleForJob must perform its own job-bound CAS.

type ParentState

type ParentState struct {
	BranchBinding            string
	Revision                 uint64
	CapsuleJSON              []byte
	CapsuleDigest            [32]byte
	SourceHighWatermark      string
	PendingJobID             auxiliary.JobID
	PendingJobTargetRevision uint64
	PendingJobBranchBinding  string
}

ParentState is the opaque state needed by this feature-owned merger. The coordinator returns defensive copies, so this package never mutates a store snapshot in place.

type Service

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

func New

func New(background BackgroundClient, parent ParentCoordinator, decoder DeltaDecoder, cfg Config) (*Service, error)

func (*Service) Consume

func (s *Service) Consume(ctx context.Context, job Job) (Outcome, error)

Consume awaits and, if ready, atomically merges exactly one result. A timeout is intentionally returned as StatusPending without Forget: the parent branch may consume that raw result on a later eligible turn.

type Status

type Status string

Status describes the fail-open result of one consumption attempt.

const (
	StatusMerged   Status = "merged"
	StatusPending  Status = "pending"
	StatusRejected Status = "rejected"
)

Jump to

Keyboard shortcuts

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