Documentation
¶
Overview ¶
Package object defines the vx object model: trees, manifests and changesets.
A tree is one directory: a sorted list of named entries, each pointing to a blob (file content) or another tree. Trees are stored in the blob store, so identical directories are stored once and two snapshots can be compared by skipping every subtree whose hash did not change.
Index ¶
- Constants
- Variables
- func ApplyChanges(ctx context.Context, s blob.Store, root hash.Hash, changes []Change) (hash.Hash, error)
- func ChangeIDFrom(b []byte) string
- func ChangedDirs(changes []Change) []string
- func EmptyTree(ctx context.Context, s blob.Store) (hash.Hash, error)
- func HasPrefixPath(path, dir string) bool
- func NewChangeID() string
- func NewObjects(ctx context.Context, s blob.Store, a, b hash.Hash) (trees, blobs []hash.Hash, err error)
- func PutTree(ctx context.Context, s blob.Store, t *Tree) (hash.Hash, error)
- func SplitPath(p string) ([]string, error)
- func ValidChangeID(s string) bool
- func ValidName(name string) error
- func WriteManifest(ctx context.Context, s blob.Store, m Manifest) (hash.Hash, error)
- type Author
- type Change
- type Changeset
- type Check
- type Entry
- type Evidence
- type File
- type Manifest
- type Mode
- type Op
- type Origin
- type Tree
Constants ¶
const CurrentVersion = 1
CurrentVersion is the changeset encoding version.
Variables ¶
var ErrBadPath = errors.New("invalid path")
ErrBadPath is returned for paths or names vx cannot store.
Functions ¶
func ApplyChanges ¶
func ApplyChanges(ctx context.Context, s blob.Store, root hash.Hash, changes []Change) (hash.Hash, error)
ApplyChanges returns the tree that results from applying changes to root. Only the directories on the changed paths are read and rewritten, so the cost depends on the size of the change, not of the repository. Directories left empty are removed. Adds and modifies set the file; deletes remove it.
func ChangeIDFrom ¶
ChangeIDFrom derives a change ID from bytes, such as a git commit hash, so importing the same commit twice gives the same change ID.
func ChangedDirs ¶
ChangedDirs returns the set of directories touched by changes, useful for display ("internal/http").
func HasPrefixPath ¶
HasPrefixPath reports whether path is dir or inside dir.
func NewObjects ¶
func NewObjects(ctx context.Context, s blob.Store, a, b hash.Hash) (trees, blobs []hash.Hash, err error)
NewObjects lists the trees and blobs reachable from tree b that are not reachable through the same path in tree a. These are the objects a client must upload when the server already has a. Subtrees with equal hashes are skipped, so the cost depends on the size of the change.
func ValidChangeID ¶
ValidChangeID reports whether s has the change ID format.
Types ¶
type Author ¶
type Author struct {
Principal string `json:"principal,omitempty"` // e.g. "agent:alice/claude-backend"
Name string `json:"name,omitempty"` // display name for git
Email string `json:"email,omitempty"` // email for git
OnBehalfOf string `json:"on_behalf_of,omitempty"` // e.g. "user:alice"
Model string `json:"model,omitempty"`
Session string `json:"session,omitempty"`
}
Author records who made a change and, for agents, on whose behalf.
type Change ¶
Change is one file that differs between two snapshots.
func DiffManifests ¶
DiffManifests lists file changes from a to b.
type Changeset ¶
type Changeset struct {
Version int `json:"v"`
ChangeID string `json:"change_id"`
Parents []hash.Hash `json:"parents,omitempty"`
Tree hash.Hash `json:"tree"`
Origin Origin `json:"origin"`
GitSHA string `json:"git_sha,omitempty"`
Author Author `json:"author"`
Intent string `json:"intent"`
DependsOn []string `json:"depends_on,omitempty"`
Evidence *Evidence `json:"evidence,omitempty"`
CreatedAt time.Time `json:"created_at"`
// SnapshotTree is the tree the author actually had, set when the server
// merged it onto newer work so Tree differs. Evidence describes this
// tree, not Tree.
SnapshotTree hash.Hash `json:"snapshot_tree,omitempty"`
}
Changeset is one change: a snapshot (tree) on top of its parents, with the intent and provenance that git has no place for. Its hash covers every field, so provenance cannot be altered after the fact.
func DecodeChangeset ¶
DecodeChangeset parses canonical changeset bytes.
func (*Changeset) FirstParent ¶
FirstParent returns the first parent or Zero.
func (*Changeset) Merged ¶
Merged reports whether the server merged the author's snapshot onto newer work, so the evidence was gathered on a different tree than the one landed.
func (*Changeset) Normalize ¶
func (c *Changeset) Normalize()
Normalize applies the same normalization as Encode, so a changeset read back from the database hashes to the same value.
type Check ¶
type Check struct {
Name string `json:"name"`
Result string `json:"result"` // "pass" or "fail"
Passed int `json:"passed,omitempty"`
Failed int `json:"failed,omitempty"`
// RanByVX is true when vx ran the command itself (vx land --run),
// false when the author reported the result (vx land --check).
RanByVX bool `json:"ran_by_vx,omitempty"`
DurationMs int64 `json:"duration_ms,omitempty"`
}
Check is one piece of evidence: a command that was run and its result.
type Evidence ¶
type Evidence struct {
Checks []Check `json:"checks,omitempty"`
NewTests []string `json:"new_tests,omitempty"`
}
Evidence is what an author offers as proof that a change works.
type Manifest ¶
Manifest is a flat view of a snapshot: every file path and its content.
func ReadManifest ¶
ReadManifest flattens the tree at root into a manifest.
type Tree ¶
type Tree struct {
Entries []Entry // sorted by Name
}
Tree is one directory.
func DecodeTree ¶
DecodeTree parses canonical tree bytes.