checkpoint

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package checkpoint persists a single worker's resumable state to SQLite.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Disposition

type Disposition int

Disposition is the reconciliation outcome.

const (
	// Resume means saved intent can be safely continued.
	Resume Disposition = iota
	// Diverged means live state contradicts the checkpoint; re-plan instead.
	Diverged
)

func (Disposition) String

func (d Disposition) String() string

String renders a Disposition for logs.

type Intent

type Intent struct {
	StandingBehavior string
	ActiveTaskID     string
	StepIndex        int
}

Intent is the worker's current standing behavior and active task position.

type JournalEntry

type JournalEntry struct {
	TaskID  string
	Outcome string
	At      time.Time
}

JournalEntry is one assigned-task outcome.

type KnownState

type KnownState struct {
	System    string
	POI       string
	Docked    bool
	Credits   float64
	CargoJSON string
	Tick      int
}

KnownState is the last game-state snapshot used for restart reconciliation.

type Reconciliation

type Reconciliation struct {
	Disposition Disposition
	Reasons     []string
}

Reconciliation is the result of comparing a checkpoint against live state.

func Reconcile

func Reconcile(saved, live KnownState, creditDropFraction float64) Reconciliation

Reconcile compares saved checkpoint state to freshly-fetched live state. A zero-value saved state (fresh worker, no checkpoint) always returns Resume. creditDropFraction is the fraction of saved credits whose loss flags divergence.

type Store

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

Store is a per-worker SQLite checkpoint.

func Open

func Open(dbPath string) (*Store, error)

Open opens (or creates) the checkpoint DB, enables WAL, and migrates.

func (*Store) AppendJournal

func (s *Store) AppendJournal(taskID, outcome string, at time.Time) error

AppendJournal records one task outcome.

func (*Store) Close

func (s *Store) Close() error

Close releases the database connection.

func (*Store) Cursor

func (s *Store) Cursor(key string) (string, bool, error)

Cursor returns a named cursor and whether it exists.

func (*Store) Journal

func (s *Store) Journal(limit int) ([]JournalEntry, error)

Journal returns up to limit entries, newest first.

func (*Store) LoadIntent

func (s *Store) LoadIntent() (Intent, bool, error)

LoadIntent returns the intent row and whether one exists.

func (*Store) LoadKnownState

func (s *Store) LoadKnownState() (KnownState, bool, error)

LoadKnownState returns the known-state row and whether one exists.

func (*Store) SaveIntent

func (s *Store) SaveIntent(i Intent) error

SaveIntent upserts the single intent row.

func (*Store) SaveKnownState

func (s *Store) SaveKnownState(k KnownState) error

SaveKnownState upserts the single known-state row.

func (*Store) SetCursor

func (s *Store) SetCursor(key, value string) error

SetCursor upserts a named progress cursor.

Jump to

Keyboard shortcuts

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