state

package
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Apply

type Apply struct {
	ID         int64
	VersionID  int64
	Agent      string
	StartedAt  time.Time
	FinishedAt *time.Time
	ExitCode   *int
	Outcome    string
	// FeaturePath is the repository-relative spec file being implemented; empty
	// for a whole-version apply.
	FeaturePath string
	LogPath     string
}

Apply is one agent run against a committed version. FinishedAt and ExitCode are nil while the run is active or after an unexpected exit.

type Baseline added in v0.1.4

type Baseline struct {
	ID            int64
	Agent         string
	StartedAt     time.Time
	FinishedAt    time.Time
	Outcome       string
	BeforeHash    string
	AfterHash     string
	BeforeContent []byte
	AfterContent  []byte
	// Proposal holds a JSON-encoded split proposal (before/after file maps)
	// for `baseline --split` rows; empty for ordinary baselines.
	Proposal []byte
	LogPath  string
}

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB wraps the SQLite handle and owns migrations.

func Open

func Open(path string) (*DB, error)

Open opens (creating if needed) the state database and applies pending migrations.

func (*DB) Close

func (s *DB) Close() error

func (*DB) FinishApply

func (s *DB) FinishApply(id int64, exitCode int, now time.Time) error

FinishApply stamps the outcome of an apply run.

func (*DB) FinishApplyWithOutcome added in v0.0.6

func (s *DB) FinishApplyWithOutcome(id int64, exitCode int, outcome string, now time.Time) error

func (*DB) GetBaseline added in v0.1.4

func (s *DB) GetBaseline(id int64) (*Baseline, error)

func (*DB) GetRefine added in v0.0.6

func (s *DB) GetRefine(id int64) (*Refine, error)

func (*DB) GetVersion

func (s *DB) GetVersion(id int64) (*SpecVersion, error)

GetVersion loads one stored snapshot by id.

func (*DB) HasUnfinishedApply

func (s *DB) HasUnfinishedApply() (bool, error)

HasUnfinishedApply reports whether any apply row lacks an outcome.

func (*DB) InsertApply

func (s *DB) InsertApply(versionID int64, agent, featurePath string, now time.Time) (int64, error)

InsertApply records the start of an apply run; log_path starts empty and is filled by SetApplyLogPath once the row id has named the file. featurePath is empty for a whole-version apply.

func (*DB) InsertBaseline added in v0.1.4

func (s *DB) InsertBaseline(agent, outcome, beforeHash, afterHash string, beforeContent, afterContent, proposal []byte, logPath string, started, finished time.Time) (int64, error)

func (*DB) InsertRefine added in v0.0.6

func (s *DB) InsertRefine(agent, outcome, beforeHash, afterHash string, beforeContent, afterContent []byte, targetPath, inputFingerprint, logPath string, started, finished time.Time) (int64, error)

func (*DB) InsertVersion

func (s *DB) InsertVersion(hash string, content []byte, message string, now time.Time) (int64, error)

InsertVersion stores a full spec snapshot and returns its id (displayed as vN).

func (*DB) IsApplied

func (s *DB) IsApplied(versionID int64) (bool, error)

IsApplied reports whether versionID has a whole-version apply row with exit_code = 0.

func (*DB) IsFeatureApplied added in v0.1.14

func (s *DB) IsFeatureApplied(versionID int64, featurePath string) (bool, error)

IsFeatureApplied reports whether versionID has a successful apply row for the given feature path.

func (*DB) LatestBaseline added in v0.1.4

func (s *DB) LatestBaseline() (*Baseline, error)

func (*DB) LatestRefine added in v0.0.6

func (s *DB) LatestRefine() (*Refine, error)

func (*DB) LatestRefineByTarget added in v0.1.14

func (s *DB) LatestRefineByTarget(targetPath string) (*Refine, error)

LatestRefineByTarget returns the most recent refinement for a given target path (empty for the master spec).

func (*DB) LatestVersion

func (s *DB) LatestVersion() (*SpecVersion, error)

LatestVersion returns the newest committed version, or nil when none exist.

func (*DB) ListApplies

func (s *DB) ListApplies() ([]Apply, error)

ListApplies returns all apply rows, newest first.

func (*DB) ListBaselines added in v0.1.4

func (s *DB) ListBaselines() ([]Baseline, error)

func (*DB) ListRefines added in v0.0.6

func (s *DB) ListRefines() ([]Refine, error)

func (*DB) ListVersions

func (s *DB) ListVersions() ([]SpecVersion, error)

ListVersions returns all versions, newest first.

func (*DB) MarkUnfinishedAppliesStale added in v0.0.6

func (s *DB) MarkUnfinishedAppliesStale() error

func (*DB) SchemaVersion

func (s *DB) SchemaVersion() (int, error)

SchemaVersion returns the current schema version.

func (*DB) SetApplyLogPath

func (s *DB) SetApplyLogPath(id int64, logPath string) error

SetApplyLogPath records the (repo-relative) log path for an apply row.

func (*DB) SetBaselineOutcome added in v0.1.6

func (s *DB) SetBaselineOutcome(id int64, outcome string) error

SetBaselineOutcome updates the outcome of a baseline row — used when a pending split proposal is accepted or discarded.

type Refine added in v0.0.6

type Refine struct {
	ID            int64
	Agent         string
	StartedAt     time.Time
	FinishedAt    time.Time
	Outcome       string
	BeforeHash    string
	AfterHash     string
	BeforeContent []byte
	AfterContent  []byte
	// TargetPath is the repository-relative spec file being refined; empty for
	// the master spec.
	TargetPath       string
	InputFingerprint string
	LogPath          string
}

type SpecVersion

type SpecVersion struct {
	ID          int64
	Hash        string
	Content     []byte
	CommittedAt time.Time
	Message     string
}

SpecVersion is one committed snapshot of the spec file.

Jump to

Keyboard shortcuts

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