state

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package state reads the run state bin/f10-state.sh writes: one small `key value` file per session under ~/.claude/f10/state, keyed by session rather than by repo because two sessions over one checkout are two runs.

The script is the writer and the semantics oracle. This package only reads, with the script's own tolerances - unknown keys ignored, a non-numeric timestamp read as stale - so `f10 status` and `f10-state.sh show` describe one run the same way. The parity test pins that.

Index

Constants

View Source
const DefaultTTL = 24 * time.Hour

DefaultTTL is how long a run counts as live with nothing reporting: the script's default, and the point past which the badge stops rendering.

Variables

View Source
var Phases = []string{"capture", "plan", "ship"}

Phases in the order the badge draws them.

Functions

func Dir

func Dir() string

Dir is where state files live: the script's variable, else its default.

func Path

func Path(dir, session string) string

Path is the state file for a session: the id sanitized the way the script sanitizes it, since it names a file.

func Session

func Session() string

Session is the session this process runs in, in the order the script finds it: the explicit override, then the id Claude Code exports into every Bash tool call. Empty from a plain terminal.

func Stopped

func Stopped(status string) bool

Stopped reports whether the phase status is one a run halts on.

func TTL

func TTL() time.Duration

TTL is how long a run counts as live, from the script's variable.

Types

type Run

type Run struct {
	Session string    `json:"session"`
	Task    string    `json:"task,omitempty"`
	URL     string    `json:"url,omitempty"`
	Root    string    `json:"root,omitempty"` // checkout root the run is about
	Capture string    `json:"capture"`
	Plan    string    `json:"plan"`
	Ship    string    `json:"ship"`
	Leaf    string    `json:"leaf,omitempty"`  // the pipeline step running, or stopped on
	Final   string    `json:"final,omitempty"` // the ship pipeline's declared last step
	Note    string    `json:"note,omitempty"`  // why the run stopped
	Next    string    `json:"next,omitempty"`  // what unblocks it
	Ask     string    `json:"ask,omitempty"`   // the question a driven run stopped on, options included
	Updated time.Time `json:"updated"`
}

A Run is one session's state file, read back. Every phase holds one of the script's statuses: pending, running, done, failed, partial, skipped, prior, blocked.

func List

func List(dir string, now time.Time, ttl time.Duration) ([]*Run, error)

List reads every live run in dir, newest first. A missing directory is an empty list: no run has ever reported on this machine.

func Load

func Load(path string) (*Run, error)

Load reads one state file. A missing file is os.ErrNotExist, unwrapped enough for errors.Is.

func (*Run) Live

func (r *Run) Live(now time.Time, ttl time.Duration) bool

Live reports whether the run was updated within ttl of now.

func (*Run) PhaseText

func (r *Run) PhaseText(phase string) string

PhaseText is the status with its step attached where one is known and belongs to that status: `running: implement`, `blocked at judge`. The leaf is a pipeline step, so only ship ever carries one. The script's show prints the same words.

func (*Run) Status

func (r *Run) Status(phase string) string

Status is the phase's status as recorded.

Jump to

Keyboard shortcuts

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