auto

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package auto is what Logos does without being asked, in one place.

Each automatic behaviour grew its own switch or none — the session-end checkpoint, the distil offer, the edit hook — so nobody could see or change "what Logos does without me" without reading the code. Here every one of them is a named switch, and the answer lives in auto.md at the vault's root: a file the user can read and edit by hand, which a deleted index cannot reset (invariant 1).

Three states per switch, as with the activity log, because there are three different users. One who turned a switch off by hand meant it, and `logos auto on` must not undo that. One who said `auto on` or `auto off` meant all of it. One who never answered gets exactly what Logos did before the switch existed, so upgrading changes nothing anybody relied on.

Index

Constants

View Source
const DreamEvery = 24 * time.Hour

DreamEvery is how long a dream run counts as recent. A started run counts as much as a finished one: a dream that is still going, or died, must not be launched again by every session start until somebody notices.

View Source
const File = "auto.md"

File is the switch file, at the vault's root.

View Source
const LogFile = "auto-log.md"

LogFile is what auto did, one line per action, at the vault's root beside auto.md. Only what happened out of the user's sight is logged — a session end, a server shutting down, a background pass. What a command does while they watch it says so on the spot and needs no second telling.

Markdown, append-only, in the vault: the next resume reads it, and a log in the index would be emptied by the very rebuild it might be reporting.

Variables

View Source
var Fixed = []struct{ Name, Why string }{
	{"verify", "a procedure's verify command is vault text, and vault text is never run as an instruction"},
	{"forget", "forgetting or retiring a memory loses something only the user can judge"},
	{"retire", "forgetting or retiring a memory loses something only the user can judge"},
	{"push", "nothing pushes or syncs without the user"},
	{"sync", "nothing pushes or syncs without the user"},
	{"network", "nothing leaves the machine"},
}

Fixed is what is never automatic, whatever auto.md says, with the reason. Listed so nobody has to wonder, and refused by name so a hand-written `- verify: on` is answered rather than silently ignored.

View Source
var Launch = launch

Launch starts a logos command for a vault as a process of its own. A var so tests run the work in-process instead of spawning the test binary.

Functions

func Describe

func Describe(s Switch) string

Describe says what a switch does, in a phrase.

func LogPath

func LogPath(vault string) string

LogPath is where a vault's auto log is written.

func On

func On(vault string, s Switch) bool

On is whether a switch is on in this vault. A file that exists and cannot be read is somebody's answer that cannot be seen, so every switch reads as off until it can: guessing the defaults is how a user who turned everything off finds it running. Status reports the read failure.

func Path

func Path(vault string) string

Path is where a vault's switches are written down.

func Record

func Record(vault string, e Entry) error

Record appends one entry to the log. The caller still reports a failure where it happened; this is so the next resume can say it too, since the place it happened — a hook, a server going away — had nobody watching.

func Set

func Set(vault, name string, on bool) error

Set records one switch by hand.

func SetMaster

func SetMaster(vault string, on bool) error

SetMaster records `auto on` or `auto off`. A switch set by hand keeps its value: the user who turned one off meant that one, whatever they say about the rest later.

func StartDream

func StartDream(vault string, now time.Time) (bool, error)

StartDream launches the day's dream when the switch is on and none has started in the last DreamEvery, and says whether it did. Session start is the trigger because it is the one moment Logos reliably runs; the dream is its own process so the session never waits on a model. Under a lock, so two hosts starting at once launch one dream between them.

func StartImport

func StartImport(vault string, changed, now time.Time) (bool, error)

StartImport launches `logos import --from claude-mem --auto` when the switch is on and claude-mem's store changed after the last automatic import began, and says whether it did. changed is the store's last write, zero when there is no store.

Measured from when the last run began, not ended: whatever claude-mem wrote while it ran may have been missed, and the price of a second look is only the skipped count. The log is the record, so deleting the index does not set off a run, and under a lock, so two hosts starting at once launch one.

func Summary

func Summary(entries []Entry) string

Summary is the one line resume opens with: what auto did since, by switch, then each failure, or "" when it did nothing. Failures are said one by one and never summed — two different reasons are two things to fix.

Types

type Config

type Config struct {
	Master   *bool
	Hand     map[Switch]bool
	Problems []string
}

Config is auto.md read. Master is nil when nobody has said `auto on` or `auto off`; Hand holds the switches set one at a time. Problems are lines the file holds that mean nothing, each one said by status rather than dropped.

func Load

func Load(vault string) (Config, error)

Load reads a vault's switches. A missing file is a vault nobody has asked, not an error. An unreadable one is an error, which status reports.

func (Config) On

func (c Config) On(s Switch) bool

On is whether a switch is on under this config.

func (Config) Why

func (c Config) Why(s Switch) string

Why says what decided a switch, for status.

type Count

type Count struct {
	Name string
	N    int
}

Count is one named number a run reports, such as dream's merged.

type Entry

type Entry struct {
	At      time.Time
	Switch  Switch
	Project string
	Started bool
	N       int
	Counts  []Count
	Skipped string
	Failed  string
}

Entry is one thing auto did, or failed to do. A run is Started, Failed, or done: N, or Counts for a switch whose run does several things, and Skipped when it could not do all of it for a reason that is not a fault.

func Entries

func Entries(vault, project string, since time.Time) ([]Entry, error)

Entries reads the log for one project, and the vault-wide entries with none, from since on; project "" reads every project's. A line it cannot read is skipped: the log is Logos's own account, and one mangled line must not hide the rest of it.

type Switch

type Switch string

Switch names one automatic behaviour.

const (
	Checkpoint    Switch = "checkpoint"
	Distil        Switch = "distil"
	RulingsAtEdit Switch = "rulings-at-edit"
	Dream         Switch = "dream"
	Index         Switch = "index"
	Review        Switch = "review"
	Import        Switch = "import"
)

func Switches

func Switches() []Switch

Switches lists every switch, in the order status prints them.

Jump to

Keyboard shortcuts

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