Documentation
¶
Overview ¶
Package tasks contains the concrete background tasks hosted by the `da service` scheduler (R3 design D2). Each task binds a trigger to a unit of work, keeps its restart watermark via internal/service/state (D3), and publishes notifications through the events.EventBus interface seam (D4.1) — never a concrete bus — assuming only the D4.2 G1–G4 delivery floor: a missed event is recovered from the on-disk sidecars, never from the bus.
Index ¶
Constants ¶
const IterLogIngesterName = "iterlog-ingester"
IterLogIngesterName is the scheduler task name and the watermark key of the iter-log ingester (sidecar: iterlog-ingester.watermark.yaml).
const RescoreName = "rescore"
RescoreName is the scheduler task name and the watermark key of the rubric-bump rescorer (sidecar: rescore.watermark.yaml).
Variables ¶
var ( ErrNoIterLogDir = errors.New("tasks: iter-log dir is required") ErrNoRepoDir = errors.New("tasks: repo dir is required") ErrNoBus = errors.New("tasks: event bus is required") )
Configuration errors returned by NewIterLogIngester.
Functions ¶
func NewIterLogIngester ¶
func NewIterLogIngester(cfg IterLogIngesterConfig) (scheduler.Task, error)
NewIterLogIngester builds the scheduler task that watches IterLogDir via fsnotify (bursts are coalesced by the trigger's debounce) and, on each fire, ingests every new or modified iter-N.yaml: score via internal/ scoring, write the score sidecar, persist the watermark, then publish IterationScored on the bus. The watermark is persisted before the publish so the bus stays eventually consistent with disk.
func NewRescore ¶
func NewRescore(cfg RescoreConfig) (scheduler.Task, error)
NewRescore builds the scheduler task that ticks on an interval (default 60s) and rescores the whole iteration log when scoring.RubricVersion has moved past the version recorded in the rescore watermark: score every record, rewrite the per-iteration + per-session sidecars, persist the watermark, then publish RescoreDone on the bus. The watermark is persisted before the publish so the bus stays eventually consistent with disk (G1: a missed event is recovered from the sidecars, never the bus).
Types ¶
type IterLogIngesterConfig ¶
type IterLogIngesterConfig struct {
// IterLogDir is the iteration-log directory to watch and ingest,
// conventionally .agents/active/iteration-log under RepoDir.
IterLogDir string
// RepoDir is the repository root scoring resolves commits against; it
// also anchors the watermark sidecar under .agents/active/service-state.
RepoDir string
// Bus receives IterationScored notifications. This is the D4.1
// interface seam; any conformant backend works.
Bus events.EventBus
// Timeout bounds one ingest pass. Zero applies defaultIngestTimeout.
Timeout time.Duration
}
IterLogIngesterConfig configures NewIterLogIngester.
type IterLogWatermark ¶
type IterLogWatermark struct {
LastIterProcessed int `yaml:"last_iter_processed"`
LastMTime time.Time `yaml:"last_mtime"`
RubricVersion string `yaml:"rubric_version"`
}
IterLogWatermark is the ingester's D3 restart watermark: the highest iteration already ingested, the newest file mtime seen when it was processed, and the rubric version the sidecars were written under.
type RescoreConfig ¶
type RescoreConfig struct {
// IterLogDir is the iteration-log directory whose score sidecars are
// refreshed, conventionally .agents/active/iteration-log under RepoDir.
IterLogDir string
// RepoDir is the repository root scoring resolves commits against; it
// also anchors the watermark sidecar under .agents/active/service-state.
RepoDir string
// Bus receives RescoreDone notifications. This is the D4.1 interface
// seam; any conformant backend works.
Bus events.EventBus
// Interval is the version-check cadence. Zero applies
// defaultRescoreInterval.
Interval time.Duration
// Timeout bounds one rescore pass. Zero applies defaultRescoreTimeout.
Timeout time.Duration
}
RescoreConfig configures NewRescore.
type RescoreWatermark ¶
type RescoreWatermark struct {
RubricVersion string `yaml:"rubric_version"`
}
RescoreWatermark is the rescorer's D3 restart watermark: the rubric version the on-disk score sidecars were last written under. A delta between it and scoring.RubricVersion is the sole rescore trigger — never the mere absence of sidecars (the ingester scores those on ingest).