lineage

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 16 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 lineage stores portable causal history beside native agent transcripts. Native files stay vendor-owned; receipts describe their exact logical coverage.

Index

Constants

View Source
const (
	HopMove     = "move"
	HopContinue = "continue"
	HopHandoff  = "handoff"
	HopFetch    = "fetch"
)
View Source
const FileFormat = "lineage/6"

FileFormat is how a lineage file holds a Format manifest: its records with each value written once. A revision is [replica, anchor, hash] or [replica, anchor, hash, parents]: the replica's and the parents' places in their lists, the parents only when they are not just the revision before, and no id (it is the hash of the rest, worked out again on read). A native projection, the anchor and hash of its one revision, is that revision's place. Everything else is as in Format. In memory, and between machines, a manifest is always Format; a manifest that cannot be packed is written as Format.

Most of a long session's lineage was these repeats: its ids are 64 hex digits, each revision's written three times and its anchor and hash twice.

View Source
const FirstFileFormatVersion = "0.6.0"

FirstFileFormatVersion is the first hopsesh that reads FileFormat: an older one shows such a session's lineage as unsupported (and cannot block a moved session's original).

View Source
const Format = "lineage/5"
View Source
const Suffix = ".hopsesh.json"

Variables

View Source
var ErrTooLarge = errors.New("movement ledger exceeds its size limit")

ErrTooLarge is a lineage that cannot be written (Read refuses more than maxSize).

Functions

func PathFor

func PathFor(main string) string

func Subset added in v0.4.0

func Subset(a, b map[ir.NodeID]bool) bool

Types

type Branch added in v0.4.0

type Branch struct {
	ID        string      `json:"id"`
	Parent    string      `json:"parent,omitempty"`
	ForkHeads []ir.NodeID `json:"forkHeads,omitempty"`
	Origin    ReplicaID   `json:"origin,omitempty"`
}

type CodeHop added in v0.4.0

type CodeHop struct {
	Way        agent.CodeWay `json:"way"`
	Remote     string        `json:"remote,omitempty"`
	Branch     string        `json:"branch,omitempty"`
	Base       string        `json:"base,omitempty"`
	Snapshot   string        `json:"snapshot,omitempty"`
	Withheld   []string      `json:"withheld,omitempty"`
	Redactions int           `json:"redactions,omitempty"`
}

type Compensation added in v0.4.0

type Compensation struct {
	ID        string `json:"id"`
	Operation string `json:"operation"`
}

type Hop

type Hop struct {
	Notify   bool      `json:"notify,omitempty"` // optional source notice; never conversation work
	Rollover *Rollover `json:"rollover,omitempty"`
	ID       string    `json:"id"`
	Parents  []string  `json:"parents,omitempty"`
	Line     string    `json:"line"`
	Time     time.Time `json:"time"`
	From     ReplicaID `json:"from"`
	To       ReplicaID `json:"to"`
	Source   StateID   `json:"source,omitempty"`
	Target   StateID   `json:"target,omitempty"`
	Kind     string    `json:"kind"`
	Fork     bool      `json:"fork,omitempty"`
	Backup   bool      `json:"backup,omitempty"`
	Fidelity string    `json:"fidelity,omitempty"`
	Written  *Range    `json:"written,omitempty"`
	Code     *CodeHop  `json:"code,omitempty"`
}

type Journey added in v0.4.0

type Journey struct {
	MachineTransfers  int    `json:"machineTransfers"`
	MachineRoundTrips int    `json:"machineRoundTrips"`
	MachineReturns    int    `json:"machineReturns"`
	OriginProfile     string `json:"originProfile,omitempty"`
	ParentBranch      string `json:"parentBranch,omitempty"`
	Origin            string `json:"origin,omitempty"`
	Transfers         int    `json:"transfers"`
	RoundTrips        int    `json:"roundTrips"`
	Returns           int    `json:"returns"`
	Fork              bool   `json:"fork"`
	Branch            string `json:"branch"`
	Family            string `json:"family"`
}

type Manifest

type Manifest struct {
	Format        string         `json:"hopsesh"`
	Family        string         `json:"family"`
	Branch        string         `json:"branch"` // branch of the native session beside this manifest
	Branches      []Branch       `json:"branches"`
	Replicas      []Replica      `json:"replicas"`
	Revisions     []Revision     `json:"revisions"`
	States        []State        `json:"states"`
	Hops          []Hop          `json:"hops"`
	Compensations []Compensation `json:"compensations,omitempty"`
	// contains filtered or unexported fields
}

func New

func New(family string) *Manifest

func NewNative added in v0.4.0

func NewNative(endpoint string, key agent.SessionKey) *Manifest

func Parse

func Parse(b []byte, limits ...ir.Limits) (*Manifest, error)

func Read

func Read(fsys agent.FS, main string, limits ...ir.Limits) (*Manifest, error)

func (*Manifest) ActiveHops added in v0.4.0

func (m *Manifest) ActiveHops() []Hop

ActiveHops excludes undone operations and implementation-only native backups. OrderedHops supplies causal ordering; wall-clock timestamps are not authorities.

func (*Manifest) AdoptNativeFork added in v0.4.0

func (m *Manifest) AdoptNativeFork(parent ReplicaID, child Replica, proof []agent.NativeInheritance, seg *ir.Segment) (*Manifest, error)

AdoptNativeFork requires module-verified native inheritance. It returns a new branch view without modifying the parent's manifest or its native session.

func (*Manifest) AppendHop added in v0.4.0

func (m *Manifest) AppendHop(h Hop) error

func (*Manifest) Clone added in v0.4.0

func (m *Manifest) Clone() *Manifest

func (*Manifest) Covered added in v0.4.0

func (m *Manifest) Covered(heads []ir.NodeID) map[ir.NodeID]bool

func (*Manifest) Deliver added in v0.4.0

func (m *Manifest) Deliver(replica ReplicaID, cursor ir.Cursor, projection []ir.Projection, heads []ir.NodeID, loss []string) State

Deliver records the destination's own receipt. It acknowledges only this replica, keeping all provenance and losses; another destination's receipt is unaffected.

func (*Manifest) Departed added in v0.4.2

func (m *Manifest) Departed(current ReplicaID) (Hop, bool)

Departed returns where a replica's branch went after it: the latest hop on its line, when the replica left that line and has not been returned to since. It is the committed movement record, whether or not the move asked for a notice; a fork leaves its parent current and is not a departure.

func (*Manifest) Departure added in v0.4.0

func (m *Manifest) Departure(current ReplicaID) (Hop, bool)

Departure returns the latest unambiguous route away from a replica. A return clears it. Fork notices describe a separate branch and never retire the parent, so a move away from this copy decides its notice whatever separate copies were made from it: they sit on other branches and are never ordered against the move (a real move after an earlier separate copy was once called ambiguous, and the original was left unblocked while hopsesh showed it blocked).

func (*Manifest) Encode

func (m *Manifest) Encode() []byte

Encode is the manifest as its file holds it: FileFormat, compact, one line (indenting a large graph's revisions made about a fifth of the file whitespace, read on every scan).

func (*Manifest) Find

func (m *Manifest) Find(key agent.SessionKey, location string) (Replica, ReplicaID, bool)

func (*Manifest) FindBinding added in v0.4.2

func (m *Manifest) FindBinding(key agent.SessionKey, endpoint, binding string) (Replica, ReplicaID, bool)

FindBinding selects the current segment of one physical session without confusing it with its retained historical login segments.

func (*Manifest) FindEndpoint added in v0.4.0

func (m *Manifest) FindEndpoint(key agent.SessionKey, endpoint string) (Replica, ReplicaID, bool)

func (*Manifest) FindOnBranch added in v0.4.0

func (m *Manifest) FindOnBranch(key agent.SessionKey, location, line string) (Replica, ReplicaID, bool)

func (*Manifest) ForBranch added in v0.4.0

func (m *Manifest) ForBranch(branch string) *Manifest

func (*Manifest) Fork added in v0.4.0

func (m *Manifest) Fork(id string, heads []ir.NodeID) string

func (*Manifest) HasReplica added in v0.4.0

func (m *Manifest) HasReplica(id ReplicaID) bool

func (*Manifest) Heads added in v0.4.0

func (m *Manifest) Heads(ids []ir.NodeID) []ir.NodeID

Heads keeps the ids no other id descends from. One walk over the ancestors of the whole set (it was one graph walk per id, quadratic for a long native fork).

func (*Manifest) Journey added in v0.4.0

func (m *Manifest) Journey() Journey

func (*Manifest) LastHopTo

func (m *Manifest) LastHopTo(id ReplicaID) (Hop, bool)

func (*Manifest) LatestState added in v0.4.0

func (m *Manifest) LatestState(id ReplicaID) (State, bool)

func (*Manifest) Merge

func (m *Manifest) Merge(o *Manifest) error

func (*Manifest) Observe added in v0.4.0

func (m *Manifest) Observe(replica ReplicaID, seg *ir.Segment) (State, error)

Observe validates previously delivered native anchors, then registers only newly authored records. Imported nodes retain their logical origins through every hop.

func (*Manifest) ObserveBinding added in v0.4.0

func (m *Manifest) ObserveBinding(r Replica, seg *ir.Segment) (ReplicaID, State, error)

ObserveBinding starts a new replica segment when the login bound to a root changes. Native anchors verify inherited history; old revisions retain their original author. This never grants permission to replay protected native data across accounts.

func (*Manifest) OrderedHops added in v0.4.0

func (m *Manifest) OrderedHops() []Hop

func (*Manifest) Outline added in v0.4.4

func (m *Manifest) Outline() *Manifest

Outline is what browsing shows (family, branches, replicas, hops and the losses their states record) without the revision graph, which can run to many megabytes per session. It is for display only: it does not validate, and transfers read the full manifest.

func (*Manifest) ReplaceProjection added in v0.4.0

func (m *Manifest) ReplaceProjection(replica ReplicaID, cursor ir.Cursor, projection []ir.Projection, heads []ir.NodeID, loss []string) State

ReplaceProjection is a verified native replacement, not an append receipt.

func (*Manifest) Replica added in v0.4.0

func (m *Manifest) Replica(id ReplicaID) Replica

func (*Manifest) ReturnReplicas added in v0.4.0

func (m *Manifest) ReturnReplicas(current ReplicaID) []Replica

ReturnReplicas lists destinations actually visited by this branch before the selected replica's latest arrival. A sibling's or parent's history is not a return.

func (*Manifest) SetLimits added in v0.4.4

func (m *Manifest) SetLimits(l ir.Limits)

func (*Manifest) State added in v0.4.0

func (m *Manifest) State(id StateID) State

func (*Manifest) UndoOperation added in v0.4.0

func (m *Manifest) UndoOperation(id string) error

func (*Manifest) Upsert

func (m *Manifest) Upsert(r Replica) ReplicaID

func (*Manifest) Validate added in v0.4.0

func (m *Manifest) Validate() error

func (*Manifest) Writable added in v0.4.4

func (m *Manifest) Writable() error

Writable reports a lineage too large to be written, cheaply (see compactSize).

type Range

type Range struct {
	From int64 `json:"from"`
	To   int64 `json:"to"`
}

type Replica

type Replica struct {
	Binding      string           `json:"binding,omitempty"`
	ID           ReplicaID        `json:"id"`
	Key          agent.SessionKey `json:"key"`
	Endpoint     string           `json:"endpoint"`
	Location     string           `json:"location"`
	Line         string           `json:"line"`
	AgentVersion string           `json:"agentVersion,omitempty"`
	// Native checkpoints are derived from immutable states, never merge authorities.
	Head   ir.NodeID `json:"-"`
	Offset int64     `json:"-"`
	Time   time.Time `json:"time"`
	URL    string    `json:"url,omitempty"`
	Branch string    `json:"branch,omitempty"` // code branch, independent of conversation Line
}

type ReplicaID added in v0.4.0

type ReplicaID string

type Revision added in v0.4.0

type Revision struct {
	ID      ir.NodeID   `json:"id"`
	Parents []ir.NodeID `json:"parents,omitempty"`
	Replica ReplicaID   `json:"replica"`
	Anchor  string      `json:"anchor"`
	Hash    string      `json:"hash"`
}

type Rollover added in v0.4.0

type Rollover struct {
	Replica ReplicaID `json:"replica"`
	Cursor  ir.Cursor `json:"cursor"`
}

Rollover records the unchanged replica retained when its active context was full.

type State added in v0.4.0

type State struct {
	ID         StateID         `json:"id"`
	Replica    ReplicaID       `json:"replica"`
	Parents    []StateID       `json:"parents,omitempty"`
	Head       ir.NodeID       `json:"head,omitempty"`
	Offset     int64           `json:"offset"`
	Heads      []ir.NodeID     `json:"heads,omitempty"`
	Projection []ir.Projection `json:"projection,omitempty"`
	Loss       []string        `json:"loss,omitempty"`
}

type StateID added in v0.4.0

type StateID string

Jump to

Keyboard shortcuts

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