tracking

package
v1.29.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 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 tracking records which initial Markdown sources the CLI has read, applied and validated. Identity is by content hash, never by file name. The record is derived operational state under .gtt/cli/: it can be rebuilt and is never a source of truth about the project.

Index

Constants

View Source
const (
	Discovered = "DISCOVERED"
	Read       = "READ"
	Applied    = "APPLIED"
	Validated  = "VALIDATED"
	Failed     = "FAILED"
)

States of an initial MD.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Path         string    `json:"path"`
	SHA256       string    `json:"sha256"`
	State        string    `json:"state"`
	DiscoveredAt string    `json:"discovered_at"`
	ReadAt       string    `json:"read_at,omitempty"`
	AppliedAt    string    `json:"applied_at,omitempty"`
	ValidatedAt  string    `json:"validated_at,omitempty"`
	Error        string    `json:"error,omitempty"`
	Changed      bool      `json:"changed,omitempty"` // content differs from the last processed version
	Previous     []Version `json:"previous,omitempty"`
}

Entry is the tracking record of one document.

func (Entry) Done

func (e Entry) Done() bool

Done reports whether this exact content was applied and validated.

func (*Entry) MarkApplied

func (e *Entry) MarkApplied() error

MarkApplied records a successful application. It is refused unless the content was read first.

func (*Entry) MarkFailed

func (e *Entry) MarkFailed(reason string)

MarkFailed records a failure. A failed document is never APPLIED.

func (*Entry) MarkRead

func (e *Entry) MarkRead()

MarkRead records that the content was read.

func (*Entry) MarkValidated

func (e *Entry) MarkValidated() error

MarkValidated records a successful validation. It is refused unless the content was applied: READ + APPLIED is recorded only after both happened.

type Ledger

type Ledger struct {
	Schema  int               `json:"schema"`
	Notice  string            `json:"notice"`
	Entries map[string]*Entry `json:"entries"`
}

Ledger is .gtt/cli/tracking.json.

func (*Ledger) Observe

func (l *Ledger) Observe(root, rel string) (*Entry, error)

Observe registers the current content of a document. A new document is DISCOVERED. A document whose content changed since it was processed goes back to DISCOVERED, keeping the processed version as history. Unchanged content keeps its state.

func (*Ledger) Sorted

func (l *Ledger) Sorted() []*Entry

Sorted returns the entries ordered by path.

type Store

type Store struct {
	Root string
	// Path is the record the Bootstrap declares, relative to Root. Empty
	// means the CLI's own location under .gtt/cli/, which is also read as a
	// fallback until the declared record holds entries.
	Path string
}

Store persists the ledger of one project.

func (Store) Load

func (s Store) Load() (*Ledger, error)

Load returns the ledger; a project without one yields an empty ledger. Entries recorded at the legacy location are carried over to a declared record that has none yet, and saved there on the next write.

func (Store) Save

func (s Store) Save(l *Ledger) error

Save writes the ledger.

type Version

type Version struct {
	SHA256      string `json:"sha256"`
	State       string `json:"state"`
	ValidatedAt string `json:"validated_at,omitempty"`
}

Version is one processed content of a document.

Jump to

Keyboard shortcuts

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