Documentation
¶
Overview ¶
Package ledger binds the canonical C ledger through its described library interface. Store and recorder operations execute in C; Go retains wire types.
Shared contracts are defined in engine/ledger; aliases preserve type identity.
Shared contracts are defined in engine/ledger; aliases preserve type identity.
Index ¶
- Constants
- Variables
- type AdapterObservation
- type AliasObservation
- type Change
- type Commit
- type ContextCandidate
- type ContextObservation
- type ContextProgram
- type Edge
- type EdgeQuery
- type EdgeRef
- type FilesystemRequirement
- type Graph
- func (g *Graph) CheckHostAccess(ctx context.Context, path, what string) error
- func (g *Graph) Close() error
- func (g *Graph) Collect(ctx context.Context, what string, options map[string]any, out any) error
- func (g *Graph) FilesystemAt(ctx context.Context, path string) (wire.FilesystemInfo, error)
- func (g *Graph) InspectProcess(ctx context.Context, pid int, opts wire.ProcessOptions) (out wire.ProcessSnapshot, err error)
- func (g *Graph) ObserveHost(ctx context.Context, in HostInventory) error
- func (g *Graph) ObserveInventory(ctx context.Context, adapters []AdapterObservation, aliases []AliasObservation, ...) error
- func (g *Graph) ObserveProcesses(ctx context.Context, in wire.ProcessSnapshot) error
- func (g *Graph) ObserveRequirements(ctx context.Context, r OperationRequirements) (HostSnapshot, error)
- func (g *Graph) ObserveShell(ctx context.Context, cwd, profile string, selections map[string]string) error
- func (g *Graph) ObserveWeb(ctx context.Context, provider, profile, scheme, host string) error
- func (g *Graph) ReadHost(ctx context.Context) (out HostSnapshot, err error)
- func (g *Graph) Record(ctx context.Context, op string, input, out any) error
- func (g *Graph) ResolveInventory(ctx context.Context, runtime string) (out Inventory, err error)
- func (g *Graph) ScanHost(ctx context.Context) (out HostInventory, err error)
- func (g *Graph) ScanProcesses(ctx context.Context, opts wire.ProcessOptions) (out wire.ProcessSnapshot, err error)
- type HostCandidates
- type HostInventory
- type HostRequirementError
- type HostSnapshot
- type InstallerObservation
- type Inventory
- type Library
- func (l *Library) CanonicalTransaction(ctx context.Context, tx Transaction) (json.RawMessage, string, error)
- func (l *Library) CheckHostAccess(ctx context.Context, path, what string) error
- func (l *Library) Collect(ctx context.Context, what string, options map[string]any, out any) error
- func (l *Library) CreatePrivateVolume(ctx context.Context, path string, limits PrivateVolumeLimits) (PrivateVolume, error)
- func (l *Library) FilesystemAt(ctx context.Context, path string) (wire.FilesystemInfo, error)
- func (l *Library) InspectPrivateVolume(ctx context.Context, path string, limits PrivateVolumeLimits) (PrivateVolume, error)
- func (l *Library) InspectProgram(ctx context.Context, name, path string) (Program, error)
- func (l *Library) InspectService(ctx context.Context, definition ServiceDefinition, directory string) (ServiceInspection, error)
- func (l *Library) Objects() *library.Described
- func (l *Library) OpenStore(ctx context.Context, backend, path string, options Options) (*NativeStore, error)
- func (l *Library) ProcessStart(ctx context.Context, pid int) (string, error)
- func (l *Library) PublishService(ctx context.Context, definition ServiceDefinition, directory string) (ServiceInspection, error)
- func (l *Library) RemovePrivateVolume(ctx context.Context, volume PrivateVolume, limits PrivateVolumeLimits) error
- func (l *Library) RemoveService(ctx context.Context, definition ServiceDefinition, directory string) (ServiceInspection, error)
- func (l *Library) RenderService(ctx context.Context, platform string, spec ServiceSpec) (ServiceDefinition, error)
- func (l *Library) ScanPrograms(ctx context.Context, names []string, searchPath string) ([]Program, error)
- func (l *Library) ValidateAttributes(ctx context.Context, attributes map[string]any) error
- type NativeStore
- func (s *NativeStore) Apply(ctx context.Context, tx Transaction) (out Commit, err error)
- func (s *NativeStore) Changes(ctx context.Context, ns string, after uint64, limit int) (out []Change, err error)
- func (s *NativeStore) Close() error
- func (s *NativeStore) GetEdge(ctx context.Context, ns, id string) (out Edge, err error)
- func (s *NativeStore) GetVertex(ctx context.Context, ns, id string) (out Vertex, err error)
- func (s *NativeStore) OpenChild(ctx context.Context, kind string, config map[string]any) (*library.Object, error)
- func (s *NativeStore) OpenWatch(ctx context.Context, namespace string, after uint64, buffer int) (*NativeWatch, error)
- func (s *NativeStore) Peers(ctx context.Context) (out []Vertex, err error)
- func (s *NativeStore) PublishPeer(ctx context.Context, id string, registration any, lease time.Duration) error
- func (s *NativeStore) QueryEdges(ctx context.Context, q EdgeQuery) (out []Edge, err error)
- func (s *NativeStore) QueryVertices(ctx context.Context, q VertexQuery) (out []Vertex, err error)
- func (s *NativeStore) Reconcile(ctx context.Context, desired Snapshot) (out Commit, err error)
- func (s *NativeStore) Register(ctx context.Context, schema Schema) error
- func (s *NativeStore) Snapshot(ctx context.Context, ns string) (out Snapshot, err error)
- func (s *NativeStore) Traverse(ctx context.Context, namespace, start string, maxDepth, maxVertices int) (out []Path, err error)
- func (s *NativeStore) Watch(ctx context.Context, namespace string, after uint64, buffer int) (<-chan Change, error)
- func (s *NativeStore) WithdrawPeer(ctx context.Context, id string) error
- type NativeWatch
- type OperationRequirements
- type Options
- type Path
- type PreparedHost
- type PrivateVolume
- type PrivateVolumeLimits
- type Program
- type Provenance
- type RelationObservation
- type Relationship
- type ResourceObservation
- type Schema
- type ServiceDefinition
- type ServiceInspection
- type ServiceSpec
- type ShellRequirement
- type Snapshot
- type Store
- type Transaction
- type Vertex
- type VertexQuery
- type VertexRef
- type WebviewRequirement
- type WebviewValidator
Constants ¶
const DefaultMaxChangeBytes = shared.DefaultMaxChangeBytes
const DefaultMaxChanges = shared.DefaultMaxChanges
const DefaultMaxRecordBytes = shared.DefaultMaxRecordBytes
const DefaultMaxResults = shared.DefaultMaxResults
const DefaultMaxSnapshotRecords = shared.DefaultMaxSnapshotRecords
const DefaultMaxTransactionRecords = shared.DefaultMaxTransactionRecords
const MaxStringBytes = shared.MaxStringBytes
const Namespace = shared.Namespace
Variables ¶
var ( ErrUnsafeVolumePath = errors.New("unsafe private volume path") ErrStaleVolume = errors.New("private volume identity changed") ErrVolumeLimit = errors.New("private volume limit exceeded") ErrInvalidVolume = errors.New("invalid private volume") )
var Code = shared.Code
var ErrBusy = shared.ErrBusy
var ErrClosed = shared.ErrClosed
var ErrConflict = shared.ErrConflict
var ErrCursorExpired = shared.ErrCursorExpired
var ErrDanglingEdge = shared.ErrDanglingEdge
var ErrIdempotency = shared.ErrIdempotency
var ErrIncidentEdges = shared.ErrIncidentEdges
var ErrInvalid = shared.ErrInvalid
var ErrInvalidName = shared.ErrInvalidName
var ErrLimitRequired = shared.ErrLimitRequired
var ErrNotFound = shared.ErrNotFound
var ErrNotRegistered = shared.ErrNotRegistered
var ErrSchemaMismatch = shared.ErrSchemaMismatch
var ErrSchemaViolation = shared.ErrSchemaViolation
var ErrSecretValue = shared.ErrSecretValue
var ErrTooLarge = shared.ErrTooLarge
var ErrUnsupported = shared.ErrUnsupported
var SafeOrigin = shared.SafeOrigin
Functions ¶
This section is empty.
Types ¶
type AdapterObservation ¶
type AdapterObservation = shared.AdapterObservation
type AliasObservation ¶
type AliasObservation = shared.AliasObservation
type ContextCandidate ¶
type ContextCandidate = shared.ContextCandidate
type ContextObservation ¶
type ContextObservation = shared.ContextObservation
type ContextProgram ¶
type ContextProgram = shared.ContextProgram
type FilesystemRequirement ¶
type FilesystemRequirement = shared.FilesystemRequirement
type Graph ¶
type Graph struct {
Store *NativeStore
// contains filtered or unexported fields
}
func NewGraph ¶
func NewGraph(ctx context.Context, s *NativeStore) (*Graph, error)
NewGraph opens a C recorder on a C store. The graph owns the store on success.
func (*Graph) CheckHostAccess ¶
func (*Graph) FilesystemAt ¶
func (*Graph) InspectProcess ¶
func (g *Graph) InspectProcess(ctx context.Context, pid int, opts wire.ProcessOptions) (out wire.ProcessSnapshot, err error)
func (*Graph) ObserveHost ¶
func (g *Graph) ObserveHost(ctx context.Context, in HostInventory) error
func (*Graph) ObserveInventory ¶
func (g *Graph) ObserveInventory(ctx context.Context, adapters []AdapterObservation, aliases []AliasObservation, installers ...InstallerObservation) error
func (*Graph) ObserveProcesses ¶
func (*Graph) ObserveRequirements ¶
func (g *Graph) ObserveRequirements(ctx context.Context, r OperationRequirements) (HostSnapshot, error)
ObserveRequirements refreshes requested observations through C; consumers select and validate resources.
func (*Graph) ObserveShell ¶
func (*Graph) ObserveWeb ¶
func (*Graph) ReadHost ¶
func (g *Graph) ReadHost(ctx context.Context) (out HostSnapshot, err error)
func (*Graph) ResolveInventory ¶
func (*Graph) ScanHost ¶
func (g *Graph) ScanHost(ctx context.Context) (out HostInventory, err error)
func (*Graph) ScanProcesses ¶
func (g *Graph) ScanProcesses(ctx context.Context, opts wire.ProcessOptions) (out wire.ProcessSnapshot, err error)
type HostCandidates ¶
type HostCandidates = shared.HostCandidates
type HostInventory ¶
type HostInventory = shared.HostInventory
type HostRequirementError ¶
type HostRequirementError = shared.HostRequirementError
type HostSnapshot ¶
type HostSnapshot = shared.HostSnapshot
type InstallerObservation ¶
type InstallerObservation = shared.InstallerObservation
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
func Bind ¶
Bind binds an explicitly supplied native library. Loading and installation policy belong to the application; the binding never falls back to a Go engine.
func BindInterface ¶
BindInterface accepts the canonical described ABI from any explicit driver.
func (*Library) CanonicalTransaction ¶
func (l *Library) CanonicalTransaction(ctx context.Context, tx Transaction) (json.RawMessage, string, error)
CanonicalTransaction asks C for the canonical JSON and its idempotency fingerprint.
func (*Library) CheckHostAccess ¶
CheckHostAccess checks execute or directory-write access without a probe file.
func (*Library) CreatePrivateVolume ¶
func (l *Library) CreatePrivateVolume(ctx context.Context, path string, limits PrivateVolumeLimits) (PrivateVolume, error)
CreatePrivateVolume creates and inspects a caller-selected private directory. Ledger never chooses the path or authorizes its removal.
func (*Library) FilesystemAt ¶
FilesystemAt asks the C ledger for the mount containing one existing path.
func (*Library) InspectPrivateVolume ¶
func (l *Library) InspectPrivateVolume(ctx context.Context, path string, limits PrivateVolumeLimits) (PrivateVolume, error)
InspectPrivateVolume validates a private directory and measures its contents.
func (*Library) InspectProgram ¶
InspectProgram checks one caller-declared executable path without running it.
func (*Library) InspectService ¶
func (l *Library) InspectService(ctx context.Context, definition ServiceDefinition, directory string) (ServiceInspection, error)
InspectService checks the installed definition against the expected content.
func (*Library) Objects ¶
Objects exposes the complete described C API, including watches and supervisors, without requiring a separate hand-maintained wrapper per method.
func (*Library) ProcessStart ¶
ProcessStart reads the OS birth token for a PID so an action can reject a process generation different from the one it observed.
func (*Library) PublishService ¶
func (l *Library) PublishService(ctx context.Context, definition ServiceDefinition, directory string) (ServiceInspection, error)
PublishService writes the definition without replacing an existing file.
func (*Library) RemovePrivateVolume ¶
func (l *Library) RemovePrivateVolume(ctx context.Context, volume PrivateVolume, limits PrivateVolumeLimits) error
RemovePrivateVolume reopens and remeasures the exact inspected directory before removing it. The caller remains responsible for authorization.
func (*Library) RemoveService ¶
func (l *Library) RemoveService(ctx context.Context, definition ServiceDefinition, directory string) (ServiceInspection, error)
RemoveService removes the definition only while its content still matches.
func (*Library) RenderService ¶
func (l *Library) RenderService(ctx context.Context, platform string, spec ServiceSpec) (ServiceDefinition, error)
RenderService produces a platform definition without invoking a manager.
type NativeStore ¶
type NativeStore struct {
// contains filtered or unexported fields
}
func (*NativeStore) Apply ¶
func (s *NativeStore) Apply(ctx context.Context, tx Transaction) (out Commit, err error)
func (*NativeStore) Close ¶
func (s *NativeStore) Close() error
func (*NativeStore) OpenChild ¶
func (s *NativeStore) OpenChild(ctx context.Context, kind string, config map[string]any) (*library.Object, error)
OpenChild opens a described object owned by this store. Close the child before closing the store; C enforces that lifetime even for concurrent callers.
func (*NativeStore) OpenWatch ¶
func (s *NativeStore) OpenWatch(ctx context.Context, namespace string, after uint64, buffer int) (*NativeWatch, error)
func (*NativeStore) Peers ¶
func (s *NativeStore) Peers(ctx context.Context) (out []Vertex, err error)
Peers returns the live provider registrations in the shared ledger.
func (*NativeStore) PublishPeer ¶
func (s *NativeStore) PublishPeer(ctx context.Context, id string, registration any, lease time.Duration) error
PublishPeer creates or renews an immutable registration for a session.
func (*NativeStore) QueryEdges ¶
func (*NativeStore) QueryVertices ¶
func (s *NativeStore) QueryVertices(ctx context.Context, q VertexQuery) (out []Vertex, err error)
func (*NativeStore) Reconcile ¶
Reconcile replaces the complete desired namespace at its observed revision.
func (*NativeStore) Register ¶
func (s *NativeStore) Register(ctx context.Context, schema Schema) error
func (*NativeStore) Watch ¶
func (s *NativeStore) Watch(ctx context.Context, namespace string, after uint64, buffer int) (<-chan Change, error)
Watch preserves the compatibility channel API. OpenWatch exposes terminal error details; Store.Close terminates these compatibility channels.
func (*NativeStore) WithdrawPeer ¶
func (s *NativeStore) WithdrawPeer(ctx context.Context, id string) error
WithdrawPeer removes a provider's registration for this session.
type NativeWatch ¶
type NativeWatch struct {
// contains filtered or unexported fields
}
NativeWatch retains terminal errors explicitly, unlike the compatibility channel API. Next and Close are safe to call concurrently.
func (*NativeWatch) Close ¶
func (w *NativeWatch) Close() error
type OperationRequirements ¶
type OperationRequirements = shared.OperationRequirements
type PreparedHost ¶
type PreparedHost = shared.PreparedHost
type PrivateVolume ¶
type PrivateVolume struct {
Path string `json:"path"`
Identity string `json:"identity"`
Created bool `json:"created"`
Entries int `json:"entries"`
Bytes int64 `json:"bytes"`
// contains filtered or unexported fields
}
PrivateVolume is the result of a ledger inspection. Only a value returned by CreatePrivateVolume or InspectPrivateVolume can be removed through Go.
type PrivateVolumeLimits ¶
type PrivateVolumeLimits struct {
MaxEntries int `json:"max_entries"`
MaxBytes int64 `json:"max_bytes"`
MaxDepth int `json:"max_depth"`
}
PrivateVolumeLimits bounds native inspection and removal. Zero selects the ledger's default (10,000 entries, 1 GiB and 32 path components).
type Program ¶
type Program struct {
Name string `json:"name"`
Path string `json:"path"`
RealPath string `json:"realpath"`
Source string `json:"source"`
OnPath bool `json:"on_path"`
}
Program is a named executable observed on a caller-supplied PATH. The ledger checks and resolves it without running it; selection remains with the caller.
type Provenance ¶
type Provenance = shared.Provenance
type RelationObservation ¶
type RelationObservation = shared.RelationObservation
type Relationship ¶
type Relationship = shared.Relationship
type ResourceObservation ¶
type ResourceObservation = shared.ResourceObservation
type ServiceDefinition ¶
type ServiceInspection ¶
type ServiceInspection struct {
Path string `json:"path"`
Installed bool `json:"installed"`
Matches bool `json:"matches"`
Created bool `json:"created"`
Existing bool `json:"existing"`
Digest string `json:"digest,omitempty"`
}
ServiceInspection reports the state of a rendered definition in one caller-selected directory. Created and Existing describe a publish attempt.
type ServiceSpec ¶
type ServiceSpec struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Executable string `json:"executable"`
Arguments []string `json:"arguments,omitempty"`
Environment map[string]string `json:"environment,omitempty"`
WorkingDirectory string `json:"working_directory,omitempty"`
Restart string `json:"restart,omitempty"`
RestartSeconds int `json:"restart_seconds,omitempty"`
UserID string `json:"user_id,omitempty"`
}
ServiceSpec describes a caller-selected per-user OS service. The C ledger validates and renders it; a platform adapter registers the definition with its native manager.
type ShellRequirement ¶
type ShellRequirement = shared.ShellRequirement
type Transaction ¶
type Transaction = shared.Transaction
type VertexQuery ¶
type VertexQuery = shared.VertexQuery
type WebviewRequirement ¶
type WebviewRequirement = shared.WebviewRequirement
type WebviewValidator ¶
type WebviewValidator = shared.WebviewValidator
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Shared contracts are defined in core; aliases preserve type identity.
|
Shared contracts are defined in core; aliases preserve type identity. |