record

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FamilyHistory      Family = "history"
	FamilyEvidence     Family = "evidence"
	KindCreated        Kind   = "created"
	KindApproved       Kind   = "approved"
	KindTaskTransition Kind   = "task_transition"
	KindAttempt        Kind   = "attempt"
	KindCompletion     Kind   = "completion"
	KindObserved       Kind   = "observed"
	KindSynced         Kind   = "synced"
	KindArchived       Kind   = "archived"
	KindFriction       Kind   = "friction"
)
View Source
const ArchiveSchemaVersion = 1
View Source
const AttemptSchemaVersion = 1
View Source
const CompletionSchemaVersion = 1
View Source
const FrictionSchemaVersion = 1
View Source
const SchemaVersion = 1
View Source
const SyncSchemaVersion = 1

Variables

This section is empty.

Functions

func Append

func Append(path string, family Family, record Record) error

func AppendUnderLock

func AppendUnderLock(path string, family Family, record Record) error

AppendUnderLock appends without reacquiring the shared ledger lock. Callers must be inside WithLedgerLock.

func AttemptIdentity

func AttemptIdentity(attempt AttemptPayload) string

func Ensure

func Ensure(path string, family Family) error

func Identity

func Identity(r Record) (string, error)

func Replay

func Replay(path string, family Family) ([]Record, []Diagnostic, error)

func Revision

func Revision(value uint64) *uint64

func WithLedgerLock

func WithLedgerLock(path string, transaction func() error) error

WithLedgerLock serializes a transaction spanning history and evidence, which share one ledger lock in their managed parent.

Types

type ArchivePayload

type ArchivePayload struct {
	SchemaVersion  int        `json:"schema_version"`
	Change         string     `json:"change"`
	Actor          string     `json:"actor"`
	Approver       string     `json:"approver"`
	Source         string     `json:"source"`
	Target         string     `json:"target"`
	ChangeHash     string     `json:"change_hash"`
	Accepted       []SpecHash `json:"accepted"`
	EvidenceSet    string     `json:"evidence_set"`
	SyncRecord     string     `json:"sync_record"`
	Transaction    string     `json:"transaction"`
	RevisionBefore uint64     `json:"revision_before"`
	RevisionAfter  uint64     `json:"revision_after"`
}

ArchivePayload is the exact record of one change folder becoming immutable local history. It carries only local facts: no delivery, deployment, or remote identity may appear here.

func DecodeArchivePayload

func DecodeArchivePayload(raw json.RawMessage) (ArchivePayload, error)

func NewArchivePayload

func NewArchivePayload(value ArchivePayload) (ArchivePayload, error)

func (ArchivePayload) Validate

func (value ArchivePayload) Validate() error

type AttemptPayload

type AttemptPayload struct {
	SchemaVersion  int      `json:"schema_version"`
	ID             string   `json:"id"`
	Change         string   `json:"change"`
	TaskID         string   `json:"task"`
	BaselineHEAD   string   `json:"baseline_head"`
	RevisionBefore uint64   `json:"revision_before"`
	RevisionAfter  uint64   `json:"revision_after"`
	ContractHash   string   `json:"contract_hash"`
	ApprovalHash   string   `json:"approval_hash"`
	StateGuardHash string   `json:"state_guard_hash"`
	DeclaredFiles  []string `json:"declared_files"`
	Actor          string   `json:"actor"`
	Assurance      string   `json:"assurance"`
	ActivityFrom   string   `json:"activity_from"`
	ActivityTo     string   `json:"activity_to"`
}

AttemptPayload is the exact history/state binding for one mutable task attempt. It lives with the codec so KindAttempt cannot accept generic JSON.

func DecodeAttemptPayload

func DecodeAttemptPayload(raw json.RawMessage) (AttemptPayload, error)

func NewAttemptPayload

func NewAttemptPayload(attempt AttemptPayload) (AttemptPayload, error)

func (AttemptPayload) Validate

func (attempt AttemptPayload) Validate() error

type CompletionPayload

type CompletionPayload struct {
	SchemaVersion  int    `json:"schema_version"`
	Change         string `json:"change"`
	TaskID         string `json:"task"`
	AttemptID      string `json:"attempt"`
	EvidenceID     string `json:"evidence"`
	Actor          string `json:"actor"`
	ActivityFrom   string `json:"activity_from"`
	ActivityTo     string `json:"activity_to"`
	RevisionBefore uint64 `json:"revision_before"`
	RevisionAfter  uint64 `json:"revision_after"`
}

func DecodeCompletionPayload

func DecodeCompletionPayload(raw json.RawMessage) (CompletionPayload, error)

func NewCompletionPayload

func NewCompletionPayload(value CompletionPayload) (CompletionPayload, error)

func (CompletionPayload) Validate

func (value CompletionPayload) Validate() error

type Diagnostic

type Diagnostic struct {
	Code   string
	File   string
	Line   int
	Reason string
}

type Family

type Family string

type FrictionPayload

type FrictionPayload struct {
	SchemaVersion    int    `json:"schema_version"`
	Change           string `json:"change"`
	TaskID           string `json:"task"`
	Operation        string `json:"operation"`
	Domain           string `json:"domain"`
	Blocker          string `json:"blocker"`
	Consequence      string `json:"consequence"`
	Actor            string `json:"actor"`
	ObservedRevision uint64 `json:"observed_revision"`
	ContractHash     string `json:"contract_hash"`
	StateHash        string `json:"state_hash"`
	EvidenceSet      string `json:"evidence_set"`
}

FrictionPayload is the exact record of one real blocker observed against a deferred domain (D14). It carries no revision transition: friction observes truth and never moves lifecycle, authority, or approval, so the observed revision and the hashes it was observed against live in the payload as facts.

func DecodeFrictionPayload

func DecodeFrictionPayload(raw json.RawMessage) (FrictionPayload, error)

func NewFrictionPayload

func NewFrictionPayload(value FrictionPayload) (FrictionPayload, error)

func (FrictionPayload) Validate

func (value FrictionPayload) Validate() error

type Kind

type Kind string

type Record

type Record struct {
	SchemaVersion     int             `json:"schema_version"`
	ID                string          `json:"id"`
	Family            Family          `json:"family"`
	Kind              Kind            `json:"kind"`
	Change            string          `json:"change"`
	ExpectedRevision  *uint64         `json:"expected_revision,omitempty"`
	ResultingRevision *uint64         `json:"resulting_revision,omitempty"`
	Timestamp         string          `json:"timestamp"`
	Actor             string          `json:"actor"`
	Payload           json.RawMessage `json:"payload"`
}

func New

func New(r Record) (Record, error)

func (Record) Validate

func (r Record) Validate() error

type SpecHash

type SpecHash struct {
	Capability string `json:"capability"`
	Path       string `json:"path"`
	Before     string `json:"before,omitempty"`
	After      string `json:"after"`
}

SpecHash identifies one accepted capability document by its managed-relative path and content. Before is empty exactly when the capability was created.

type SyncPayload

type SyncPayload struct {
	SchemaVersion  int        `json:"schema_version"`
	Change         string     `json:"change"`
	Approver       string     `json:"approver"`
	ActorClass     string     `json:"actor_class"`
	Reason         string     `json:"reason"`
	ApprovalHash   string     `json:"approval_hash"`
	PlanHash       string     `json:"plan_hash"`
	EvidenceSet    string     `json:"evidence_set"`
	Transaction    string     `json:"transaction"`
	Outputs        []SpecHash `json:"outputs"`
	RevisionBefore uint64     `json:"revision_before"`
	RevisionAfter  uint64     `json:"revision_after"`
	Assurance      string     `json:"assurance"`
}

SyncPayload is the exact record of one accepted-truth mutation. It binds the human who authorized it, the artifact hashes that authorization covered, the reconciliation plan, the consumed evidence set, and the exact output bytes, so history identifies inputs and outputs without replaying the filesystem.

func DecodeSyncPayload

func DecodeSyncPayload(raw json.RawMessage) (SyncPayload, error)

func NewSyncPayload

func NewSyncPayload(value SyncPayload) (SyncPayload, error)

func (SyncPayload) Validate

func (value SyncPayload) Validate() error

Jump to

Keyboard shortcuts

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