Help us shape the future of Go! Take the 2026 Go Developer Survey

loop

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package loop models maintenance loops (SPEC-ADDITIONS §15): a named invariant kept true by a sensor and an authorized action, with an explicit retirement condition. The registry and its validation are pure; running a sensor is a command-level seam.

Index

Constants

View Source
const DefaultRegistryFile = ".adh/loops.json"

DefaultRegistryFile is the conventional repo path the loop registry lives under (SPEC-ADDITIONS §15). It is the single owner of that path across the CLI.

Variables

This section is empty.

Functions

func Marshal

func Marshal(r Registry) ([]byte, error)

Marshal encodes the registry as indented JSON with a trailing newline — the on-disk form Load reads back, so the write and read sides agree in one place.

Types

type Loop

type Loop struct {
	ID         string `json:"id"`
	Goal       string `json:"goal"`
	Sensor     string `json:"sensor"`
	OnFinding  string `json:"on_finding,omitempty"`
	RetireWhen string `json:"retire_when"`
	Owner      string `json:"owner,omitempty"`
}

Loop is one maintenance loop: the invariant it keeps, how it senses a departure, the authorized action on a finding, when it retires, and its owner.

type Registry

type Registry struct {
	Loops []Loop `json:"loops"`
}

Registry is the set of registered maintenance loops.

func Load

func Load(path string) (Registry, error)

Load reads a loop registry from a JSON file. An absent file is an empty registry, not an error.

func StarterRegistry

func StarterRegistry() Registry

StarterRegistry is the set of standing maintenance loops that make accretion automatic instead of prompted (SPEC-ADDITIONS §15): each names an invariant the harness keeps true, a deterministic sensor (`adh` itself), and "open arc" as the authorized action, so a sensed departure becomes work an agent drives. `adh init` seeds it and then the operator tailors it. The sensors compose the other levers — context-integrity (Loop F, `context verify`), the tool registry (`tool doctor`), and the lesson backlog — so a correction is inherited by the next arc, not lost.

func (Registry) Find

func (r Registry) Find(id string) (Loop, bool)

Find returns the loop with the given ID.

func (Registry) Validate

func (r Registry) Validate() error

Validate checks that every loop names an invariant, a sensor, and a retirement condition, and that IDs are unique. A loop without a retirement condition can never be garbage-collected, so it is rejected (§15).

Jump to

Keyboard shortcuts

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