scheduler

package
v0.1.0-alpha.1 Latest Latest
Warning

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

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

Documentation

Overview

Package scheduler turns durable intake evidence into frozen consolidation windows. It owns retry mechanics only; semantic eligibility and every Seed transition remain inside the consolidation engine.

Index

Constants

This section is empty.

Variables

View Source
var ErrLeaseLost = errors.New("consolidation Job lease lost")

ErrLeaseLost means another process no longer recognizes the caller's lease.

Functions

This section is empty.

Types

type Config

type Config struct {
	QuietPeriod   time.Duration
	LeaseDuration time.Duration
	WorkerTimeout time.Duration
	RetryDelay    time.Duration
	PollInterval  time.Duration
	MaxEpisodes   int
	Overlap       int
	OnError       func(error)
}

Config controls batching and retry frequency, not learning meaning.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig waits for a short quiet period, while a full window is ready immediately. One complete Episode is enough after the quiet period.

type Engine

type Engine interface {
	ConsolidateWindow(context.Context, consolidation.Window, consolidation.Worker) (consolidation.Receipt, error)
}

Engine is the single semantic commit entry. Scheduler never branches on FORM, REENACT, INHIBIT, or REVISE.

type Job

type Job struct {
	Ref              string
	EpisodeRefs      []string
	OutcomeEventRefs []string
	LeaseToken       string
}

Job is one immutable leased window. Stable refs remain Core-owned and are never generated or rewritten by the inference Worker.

type LeaseRequest

type LeaseRequest struct {
	QuietBefore time.Time
	LeaseUntil  time.Time
	MaxEpisodes int
	Overlap     int
}

LeaseRequest carries only runtime timing and bounded-window policy.

type Processor

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

Processor leases, consolidates, and acknowledges one durable Job at a time.

func New

func New(queue Queue, engine Engine, worker consolidation.Worker, config Config) *Processor

New constructs a background processor. Non-positive timing values fall back to safe defaults so environment parsing cannot create a busy loop.

func (*Processor) ProcessOne

func (processor *Processor) ProcessOne(ctx context.Context) (bool, error)

ProcessOne runs exactly one frozen Job. A failed semantic call releases the same window for retry; a commit followed by a lost ack is safe because the engine freezes its own receipt by Job ref and window hash.

func (*Processor) Run

func (processor *Processor) Run(ctx context.Context) error

Run drains available Jobs and then polls. Individual failures are reported and retried without taking down public intake.

type Queue

type Queue interface {
	LeaseConsolidationJob(context.Context, LeaseRequest) (Job, bool, error)
	CompleteConsolidationJob(context.Context, string, string) error
	RetryConsolidationJob(context.Context, string, string, time.Time) error
}

Queue is the minimal durable work boundary implemented by PostgreSQL.

Jump to

Keyboard shortcuts

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