undo

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package undo implements the append-only transaction journal from SPEC §6.3. Each forward mutation records one transaction capturing the before-images of every task line it touched (added, changed, or removed), keyed by ULID. Undo pops the last transaction and restores those before-images. The journal is written under the tasks.txt lock, in the same critical section as the mutation, so "last" is well-defined across processes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(s *store.Store, t Txn) error

Append writes a transaction to the journal. Caller holds the lock.

Types

type Change

type Change struct {
	ID     string `json:"id"`
	Before string `json:"before,omitempty"`
	After  string `json:"after,omitempty"`
}

Change records one task's before/after raw lines. An empty Before means the task was newly added (undo deletes it); an empty After means it was removed (undo re-adds it).

type Txn

type Txn struct {
	Op      string   `json:"op"`      // human label, e.g. "add", "done", "archive"
	TS      string   `json:"ts"`      // RFC3339 timestamp
	Changes []Change `json:"changes"` // ULID-keyed before/after lines
}

Txn is a single undoable transaction.

func Pop

func Pop(s *store.Store) (Txn, bool, error)

Pop removes and returns the most recent transaction, or ok=false if the journal is empty. Caller holds the lock. It rewrites the journal without the popped line (atomic write).

Jump to

Keyboard shortcuts

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