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

checkpoint

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: EUPL-1.2 Imports: 11 Imported by: 0

Documentation

Overview

Package checkpoint conserve le contenu des fichiers avant que l'agent les écrase, pour /rewind. Le stockage est adressé par le contenu : un fichier <2 premiers hex>/<sha256 hex>, écrit une seule fois.

Index

Constants

View Source
const (
	ActionRestore = "restore"
	ActionDelete  = "delete"

	StatusOK           = "ok"
	StatusConflict     = "conflict"
	StatusUnrestorable = "unrestorable"
	StatusNoop         = "noop"
)

Actions et états d'un fichier du plan.

View Source
const MaxBytes = 10 << 20

MaxBytes : taille maximale d'une copie (10 Mio).

View Source
const Unreadable = "unreadable"

Unreadable : empreinte d'un chemin illisible ou non ordinaire, qui ne correspond à aucune empreinte réelle (conflit assuré).

Variables

View Source
var (
	ErrCorrupted = errors.New("corrupted checkpoint")
	ErrMissing   = errors.New("missing checkpoint")
)
View Source
var ErrUnknownPoint = errors.New("unknown checkpoint")

ErrUnknownPoint : aucun point de contrôle pour ce seq.

Functions

func Dir

func Dir(getenv func(string) string) string

Dir : <répertoire de données>/checkpoints.

Types

type FilePlan

type FilePlan struct {
	Path     string
	Action   string
	Status   string
	Target   string
	Expected string
	// Current : état observé au calcul du plan (FileState.Key) ; Rewind
	// refuse d'agir si le fichier a changé depuis l'aperçu.
	Current string
}

FilePlan : ce que /rewind ferait pour un fichier.

type FileState

type FileState struct {
	Exists  bool
	Symlink bool
	Hash    string
}

FileState : l'état courant d'un chemin sur le disque.

func (FileState) Key

func (s FileState) Key() string

Key résume l'état : "" absent, "symlink" pour un lien symbolique, "unreadable" pour un chemin illisible, sinon l'empreinte "sha256:<hex>".

type Plan

type Plan struct {
	Point                 Point
	Files                 []FilePlan
	UntrackedCalls        int
	ConversationAvailable bool
}

Plan : résultat de BuildPlan.

func BuildPlan

func BuildPlan(st State, toSeq uint64, current func(path string) FileState, has func(hash string) bool) (Plan, error)

BuildPlan calcule, sans rien modifier, les actions pour revenir au point toSeq. current et has sont injectés : aucune lecture disque ici.

type Point

type Point struct {
	Seq          uint64
	Excerpt      string
	HistoryLen   int
	Conversation bool
}

Point : un message utilisateur auquel on peut revenir.

type State

type State struct {
	Points    []Point
	Writes    []Write
	Untracked []Untracked
}

State : l'état en mémoire d'une session, dans l'ordre des seq.

type Store

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

Store est un magasin de copies adressées par le contenu.

func Open

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

Open crée le répertoire (0700) s'il n'existe pas.

func (*Store) Has

func (s *Store) Has(h string) bool

Has indique si la copie existe et est intacte.

func (*Store) Load

func (s *Store) Load(h string) ([]byte, error)

Load relit la copie et vérifie son empreinte.

func (*Store) Prune

func (s *Store) Prune(maxAge time.Duration, keep map[string]bool, now time.Time) (int, error)

Prune supprime les fichiers plus vieux que maxAge (mtime) dont l'empreinte n'est pas dans keep, et les temporaires .tmp-* périmés.

func (*Store) Save

func (s *Store) Save(data []byte) (string, error)

Save écrit data (s'il n'existe pas déjà intact, sinon rafraîchit son mtime) et renvoie son sha256 hex.

type Untracked

type Untracked struct {
	Seq  uint64
	Tool string
}

Untracked : un appel non annulable (shell, MCP...).

type Write

type Write struct {
	Seq          uint64
	Path         string
	Before       string
	After        string
	NoCheckpoint bool
}

Write : une écriture de fichier enregistrée. After vide = fichier absent après l'événement (suppression par un rewind enregistré).

Jump to

Keyboard shortcuts

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