fixture

package
v1.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 12 Imported by: 0

Documentation

Overview

Package fixture builds realistic on-disk fixtures for TCP-01 tests: a primary worktree with its `.git` common directory, a `.taskman/` intent store and a `<git-common-dir>/taskman/` state dir with a valid receipt chain. It is test support only (imported by `_test.go` files); it never touches a real repository and every path it writes is under a temp directory the caller owns. It also provides the byte/mode/mtime tree snapshot used to prove that read commands modify nothing (AS-07).

Index

Constants

View Source
const (
	QueueID   = "queue:acme:main"
	RepoID    = "repo:acme"
	Prefix    = "AT"
	Actor     = "russell"
	Timestamp = "2026-09-06T12:00:00Z"
)

Queue identity shared by every fixture.

Variables

This section is empty.

Functions

func ApplyReceipt

func ApplyReceipt(t *testing.T, r *Repo, seq uint64)

ApplyReceipt is the writer's last §5.2 effect for a receipt PlantReceipt left pending: it renames the head to name receipt seq, which must be lastSeq+1. Together the two simulate a writer caught inside, then leaving, the REDO_PENDING window (CTS-V0-006).

func AssertUntouched

func AssertUntouched(t *testing.T, r *Repo, stateBefore, intentBefore []Entry, what string)

AssertUntouched fails the test when the state dir, the intent dir or the lock path changed relative to the snapshots taken before a read, or when a lock file appeared.

func Commit

func Commit(t *testing.T, r *Repo, kind string)

Commit appends one receipt of the given kind to the chain and advances head.json, simulating a committed transaction (test-only; the real commit protocol is TCP-02's).

func CommitPosts

func CommitPosts(t *testing.T, r *Repo, kind, requestID string, posts map[string][]byte)

CommitPosts is test-only fixture assembly: receipt bytes and projections are written directly, without simulating durability or granting writer authority.

func Dep

func Dep(local string) ticket.Dependency

Dep builds a COMPLETED dependency edge on a local token.

func GateDep

func GateDep(local, gate string) ticket.Dependency

GateDep builds a GATE_PASSED dependency edge.

func GenesisValue

func GenesisValue(t *testing.T, r *Repo) wire.Value

GenesisValue builds the minimal experimental J1 genesis, supplying actual retained VERSION blob bytes. Existing intent fixtures remain projections; callers needing a full ledger must post tickets in later receipts.

func HeadValue

func HeadValue(primary string, lastSeq uint64, last wire.Digest, generation uint64, initSha wire.Digest) wire.Value

HeadValue builds head.json for the fixture queue.

func PlantReceipt

func PlantReceipt(t *testing.T, r *Repo, seq uint64)

PlantReceipt writes a receipt file at seq without touching head.json (a pending redo at lastSeq+1, or a fork at lastSeq+2).

func PolicyBytes

func PolicyBytes() []byte

PolicyBytes is PolicyValue on disk.

func PolicyValue

func PolicyValue() wire.Value

PolicyValue is a valid taskman-policy/0 with one required COMMAND gate `verify` and serialFallback BLOCK.

func QueueBytes

func QueueBytes() []byte

QueueBytes is QueueValue on disk.

func QueueValue

func QueueValue() wire.Value

QueueValue is a valid taskman-queue/0 for the fixture queue.

func ReceiptValue

func ReceiptValue(seq uint64, prev *wire.Digest, kind string, headGeneration uint64) wire.Value

ReceiptValue builds a receipt of the given kind at seq with prev.

func SameTree

func SameTree(a, b []Entry) bool

SameTree reports whether two snapshots are identical.

func TempDirOutside

func TempDirOutside(t *testing.T) string

TempDirOutside returns a resolved temp directory that is neither inside the repository nor inside the state dir (a legal `--staging`).

func Ticket

func Ticket(local string) *ticket.Record

Ticket returns a minimal valid OPEN, AUTONOMOUS, QUALIFIED record for the local token, at revision 1. Callers mutate the struct before encoding.

func TicketID

func TicketID(local string) string

TicketID renders the fixture queue's ticket ID for a local token.

func Write

func Write(t *testing.T, path string, data []byte)

Write writes a file, creating parents, with mode 0644.

func WriteIntent

func WriteIntent(t *testing.T, r *Repo, tickets ...*ticket.Record)

WriteIntent writes queue.json, policy.json and the given tickets.

func WriteState

func WriteState(t *testing.T, r *Repo)

WriteState initialises the state dir with VERSION, an INIT receipt at seq 1 and a matching head.json. This is fixture construction, not a writer.

Types

type Entry

type Entry struct {
	Path  string
	Mode  fs.FileMode
	Size  int64
	MTime int64
	Sha   string
}

Entry is one row of a tree snapshot.

func TreeSnapshot

func TreeSnapshot(t *testing.T, root string) []Entry

TreeSnapshot records every entry under root (path, mode, size, mtime and content digest for regular files). A missing root yields an empty snapshot, so "still absent" compares equal.

type Repo

type Repo struct {
	Root      string // resolved absolute path of the primary worktree
	CommonDir string // <Root>/.git
	StateDir  string // <Root>/.git/taskman
	IntentDir string // <Root>/.taskman
}

Repo is a fixture repository on disk.

func TempRepo

func TempRepo(t *testing.T) *Repo

TempRepo creates a primary worktree with a `.git` directory under a symlink-resolved temp path (macOS's /var is a symlink; the §3.4 resolver records the canonical path, so Root equals it). `head.primaryWorktree` is a PathText bounded to 4096 bytes (§2). It removes everything at test cleanup.

Jump to

Keyboard shortcuts

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