state

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package state persists the per-task watermark sidecars that give the `da service` background tasks restart safety (R3 design decision D3).

Each task owns exactly one human-readable YAML sidecar at .agents/active/service-state/<task-name>.watermark.yaml. On startup a task reads its watermark; absent means "start from scratch". Writes are atomic (temp+rename via fsops.WriteFileAtomic, the same primitive the scoring sidecar writers use) so a crash never leaves a partial watermark behind.

The package is deliberately shape-agnostic: each task defines its own watermark struct (e.g. the iter-log ingester's {last_iter_processed, last_mtime, rubric_version}) and hands it to Load/Save as an opaque value.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(path string, v any) (bool, error)

Load reads the watermark at path into v. A missing file is not an error: it returns found=false with a nil error, leaving v untouched, which is the D3 "absent means start from scratch" contract. A blocked parent (ENOTDIR: a path component is a regular file) is also treated as absent — Windows already reports that case as not-exist, and the subsequent Save surfaces the broken hierarchy loudly. Read or parse failures are returned as errors so a corrupt watermark is surfaced instead of silently reprocessing from zero.

func Path

func Path(repoDir, taskName string) string

Path returns the canonical watermark sidecar path for taskName in the repository rooted at repoDir: .agents/active/service-state/<task>.watermark.yaml.

func Save

func Save(path string, v any) error

Save atomically persists v as YAML at path, creating the parent directory when missing. The temp+rename write guarantees a concurrent reader (or a crash) never observes a partial watermark.

Types

This section is empty.

Jump to

Keyboard shortcuts

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