runtime

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 25 Imported by: 1 module, 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 runtime mounts and executes immutable OpenRealtime Graph IR.

Index

Constants

View Source
const (
	ClockServiceName    = "runtime.clock"
	SequenceServiceName = "runtime.sequence"
)
View Source
const MaximumStateSnapshotBytes = 1 << 20

MaximumStateSnapshotBytes bounds predecessor, restored, and migrated graph element state before and after canonicalization.

View Source
const (
	// SecretServiceName is the explicit, node-scoped mount service used to
	// resolve reviewed deployment secret slots. It is runtime-owned so a
	// deployment ServiceSet cannot shadow it with an unsealed implementation.
	SecretServiceName = "runtime.secrets"
)

Variables

View Source
var (
	ErrChannelClosed   = errors.New("graph channel is closed")
	ErrPortUnbound     = errors.New("graph port has no connected lane")
	ErrPortCardinality = errors.New("graph port operation does not match its lane cardinality")
	ErrAlreadyRunning  = errors.New("graph mount is already running or has completed")
	ErrGraphClosed     = errors.New("graph mount closed")
)
View Source
var (
	ErrTraceRecordingDisabled = errors.New("graph trace recording is disabled")
	ErrTraceRecordingNotReady = errors.New("graph trace recording has no complete attested snapshot")
	ErrTraceRecordingClosed   = errors.New("graph trace recording is closed")
)
View Source
var ErrSecretResolution = errors.New("secret provider resolution failed")

Functions

func StandardDependencyArtifact

func StandardDependencyArtifact(name string) (inspect.ArtifactIdentity, bool)

StandardDependencyArtifact returns the exact built-in artifact supplying a mount-owned runtime coeffect. It does not construct a service: Mount creates the clock, sequence allocator, and node-scoped secret access only after the sealed preparation has passed.

func StandardDependencyArtifacts

func StandardDependencyArtifacts() map[string]inspect.ArtifactIdentity

StandardDependencyArtifacts returns an independent deterministic identity map suitable for config discovery and production assembly catalogs.

Types

type BufferTracer

type BufferTracer struct {
	// contains filtered or unexported fields
}

BufferTracer retains a bounded recent trace for tests and lightweight live inspection. It drops the oldest trace record, never graph data.

func NewBufferTracer

func NewBufferTracer(capacity int) *BufferTracer

func (*BufferTracer) Events

func (tracer *BufferTracer) Events() []TraceEvent

func (*BufferTracer) Record

func (tracer *BufferTracer) Record(event TraceEvent)

type Clock

type Clock interface {
	NowNS() uint64
}

Clock is the monotonic time coeffect available to every mounted graph. Elements declare it when timestamps or deadlines affect semantics.

type ClockFunc

type ClockFunc func() uint64

func (ClockFunc) NowNS

func (function ClockFunc) NowNS() uint64

type Config

type Config struct {
	Graph    ir.Graph
	Registry *Registry
	Values   map[string]json.RawMessage
	Services *ServiceSet
	// Configuration is the exact separate values artifact identity. It is
	// optional for historical/local mounts, but remote attestation must refuse
	// a snapshot without it rather than reconstructing it from node values.
	Configuration *inspect.ArtifactIdentity
	// Deployment is the public, redacted deployment identity. Private
	// deployment and secret-catalog identities are installed only by the
	// sealed plan-preparation path through privatePlanIdentity below.
	Deployment *inspect.ArtifactIdentity

	Tracer          Tracer
	Now             func() uint64
	ShutdownTimeout time.Duration
	Inspection      InspectionConfig
	TraceRecording  *TraceRecordingConfig
	// contains filtered or unexported fields
}

type DependencyRegistry

type DependencyRegistry struct {
	// contains filtered or unexported fields
}

DependencyRegistry binds required runtime services to exact executable or provider artifacts. Entries are create-only, so a successful preparation can snapshot them without observing a replacement race.

func NewDependencyRegistry

func NewDependencyRegistry() *DependencyRegistry

func (*DependencyRegistry) Register

func (registry *DependencyRegistry) Register(
	name string,
	artifact inspect.ArtifactIdentity,
	value any,
) error

func (*DependencyRegistry) RegisterMountScoped

func (registry *DependencyRegistry) RegisterMountScoped(
	name string,
	artifact inspect.ArtifactIdentity,
) error

RegisterMountScoped attests a dependency whose service is selected for each PreparedPlan.Mount call. It records only immutable metadata and therefore does not acquire, retain, or inspect the eventual mount service.

func (*DependencyRegistry) RegisterRuntimeOwned

func (registry *DependencyRegistry) RegisterRuntimeOwned(
	name string,
	artifact inspect.ArtifactIdentity,
) error

RegisterRuntimeOwned attests the exact runtime artifact that supplies a mount-scoped standard coeffect. No caller value is accepted because Mount constructs these services itself; accepting one would attest an object that the runtime-owned overlay then shadows.

type FactoryProfile

type FactoryProfile struct {
	Reference    string                       `json:"reference"`
	Artifact     inspect.ArtifactIdentity     `json:"artifact"`
	Placements   []string                     `json:"placements,omitempty"`
	Transports   []string                     `json:"transports"`
	ResourceKeys []string                     `json:"resource_keys,omitempty"`
	SecretSlots  []string                     `json:"secret_slots,omitempty"`
	Capabilities []inspect.CapabilityIdentity `json:"capabilities,omitempty"`
}

FactoryProfile is the immutable startup contract published by one runtime implementation. It contains metadata only: registering a profile must not dial a provider, resolve a secret, open a device, or otherwise acquire a runtime resource. A nil Capabilities slice means that provider capabilities are selected by the factory's live readiness handshake. A non-nil slice, including an explicitly empty one, is an exact registered capability set that live reporting must match.

type FactoryRegistration

type FactoryRegistration struct {
	Profile FactoryProfile
	Factory element.Factory
}

FactoryRegistration couples exact, resource-free startup metadata with the factory that will eventually mount the element. Factory.Mount remains the first operation in this API that is allowed to acquire resources.

type InspectionConfig

type InspectionConfig struct {
	MaxFlows                 int
	MaxEdgesPerFlow          int
	MaxCorrelationBytes      int
	MaxCausalParentsPerStage int
}

InspectionConfig bounds payload-free per-correlation route retention.

type Mounted

type Mounted struct {
	// contains filtered or unexported fields
}

Mounted is one fully validated and resource-mounted graph. Run starts the reaction loops exactly once; Close is idempotent and unwinds lifecycle effects in reverse mount order.

func Mount

func Mount(ctx context.Context, config Config) (*Mounted, error)

Mount validates the exact factory contracts, constructs every bounded channel, resolves required services, and mounts elements without starting their long-lived run loops.

func (*Mounted) CheckpointTrace

func (mounted *Mounted) CheckpointTrace() error

CheckpointTrace synchronously captures the latest best-effort live view. It is normally unnecessary because runtime changes signal the coalescing recorder, but it provides an explicit management-plane consistency point.

func (*Mounted) Close

func (mounted *Mounted) Close(ctx context.Context) error

Close cancels a running graph or disposes a graph that was mounted but never run. It waits only within the caller's context.

func (*Mounted) DeploymentEvidence

func (mounted *Mounted) DeploymentEvidence() (inspect.DeploymentEvidence, bool)

DeploymentEvidence returns an isolated copy of the exact public/private deployment identity and any provider resolutions observed so far. It never contains a deployment secret reference, provider locator, or secret bytes.

func (*Mounted) DeploymentIdentity

func (mounted *Mounted) DeploymentIdentity() (inspect.ArtifactIdentity, bool)

DeploymentIdentity returns the redacted deployment artifact carried through the mount boundary. It is safe for ordinary inspection and telemetry.

func (*Mounted) Done

func (mounted *Mounted) Done() <-chan struct{}

func (*Mounted) Egress

func (mounted *Mounted) Egress(name string) (element.InputPort, error)

func (*Mounted) Err

func (mounted *Mounted) Err() error

func (*Mounted) Graph

func (mounted *Mounted) Graph() ir.Graph

func (*Mounted) Ingress

func (mounted *Mounted) Ingress(name string) (element.OutputPort, error)

func (*Mounted) Live

func (mounted *Mounted) Live() inspect.Live

Live returns one consistent best-effort inspection snapshot without blocking graph execution on a telemetry consumer.

func (*Mounted) MarshalRecordedTrace

func (mounted *Mounted) MarshalRecordedTrace() ([]byte, error)

MarshalRecordedTrace returns deterministic, newline-terminated strict JSON.

func (*Mounted) PrivateIdentity

func (mounted *Mounted) PrivateIdentity() (PrivatePlanIdentity, bool)

PrivateIdentity returns the opaque deployment/secret identity carried by a graph-native prepared mount. Generic JSON and formatting remain redacted.

func (*Mounted) RecordedTrace

func (mounted *Mounted) RecordedTrace() (inspect.LiveTrace, error)

RecordedTrace returns a recursively independent, fingerprinted artifact and verifies deterministic replay against the exact mounted Graph IR.

func (*Mounted) Run

func (mounted *Mounted) Run(parent context.Context) error

Run supervises all element reaction loops. The first unexpected node error cancels sibling work; shutdown is bounded and reports any element that does not honor cancellation.

type PlanPreparation

type PlanPreparation struct {
	Factories       *Registry
	Dependencies    *DependencyRegistry
	SecretCatalog   *graphsecret.Document
	SecretProviders *graphsecret.Registry
}

PlanPreparation contains the mutable assembly registries consulted during the resource-free preparation phase. The returned PreparedPlan owns sealed snapshots and no longer consults these registries.

type PreparedDependency

type PreparedDependency struct {
	Name     string                      `json:"name"`
	Artifact inspect.ArtifactIdentity    `json:"artifact"`
	Scope    graphconfig.DependencyScope `json:"scope"`
}

PreparedDependency is the exact public identity of a required service.

type PreparedMountDependency

type PreparedMountDependency struct {
	Name     string
	Artifact inspect.ArtifactIdentity
	Service  any
}

PreparedMountDependency supplies one service whose name, artifact, and mount scope were frozen by config.Create and PreparePlan. The slice form is intentional so duplicate contributions can be rejected instead of being overwritten by map construction.

type PreparedMountOptions

type PreparedMountOptions struct {
	Dependencies    []PreparedMountDependency
	Tracer          Tracer
	Now             func() uint64
	ShutdownTimeout time.Duration
	Inspection      InspectionConfig
	TraceRecording  *TraceRecordingConfig
}

PreparedMountOptions contains runtime supervision/inspection policy and the exact caller-supplied service overlay for externally hosted mount-scoped dependencies. Topology, values, implementations, dependency identities, and process-scoped services come exclusively from the sealed PreparedPlan.

type PreparedNode

type PreparedNode struct {
	NodeID           string                       `json:"node_id"`
	DeploymentDigest string                       `json:"deployment_digest"`
	Reference        string                       `json:"reference"`
	Artifact         inspect.ArtifactIdentity     `json:"artifact"`
	Placement        string                       `json:"placement,omitempty"`
	Transport        string                       `json:"transport"`
	ResourceKeys     []string                     `json:"resource_keys,omitempty"`
	SecretSlots      []string                     `json:"secret_slots,omitempty"`
	Capabilities     []inspect.CapabilityIdentity `json:"capabilities,omitempty"`
}

PreparedNode is the public, redacted launch projection for one graph node. Secret slot names are contracts; secret references and resource values are deliberately absent.

type PreparedPlan

type PreparedPlan struct {
	// contains filtered or unexported fields
}

PreparedPlan is a sealed plan-to-runtime handoff. Preparation resolves and checks every factory, capability, transport, resource/secret-slot contract, and required dependency before Mount can acquire the first resource.

func PreparePlan

func PreparePlan(
	ctx context.Context,
	plan *graphconfig.Plan,
	assembly PlanPreparation,
) (*PreparedPlan, error)

PreparePlan validates a complete immutable config.Plan against exact live assembly registrations. It is metadata-only and never invokes Factory.Mount or a service/secret provider.

func (*PreparedPlan) Graph

func (prepared *PreparedPlan) Graph() ir.Graph

func (*PreparedPlan) Identity

func (prepared *PreparedPlan) Identity() graphconfig.Identity

Identity returns the public plan identity. Its deployment digest is the redacted identity frozen into Graph IR.

func (*PreparedPlan) MarshalJSON

func (prepared *PreparedPlan) MarshalJSON() ([]byte, error)

func (*PreparedPlan) Mount

func (prepared *PreparedPlan) Mount(
	ctx context.Context,
	options PreparedMountOptions,
) (*Mounted, error)

Mount validates the sealed handoff immediately before delegating to the graph runtime. Runtime.Mount again checks every descriptor, dependency, and value before it invokes the first Factory.Mount.

func (*PreparedPlan) PrivateBinding

func (prepared *PreparedPlan) PrivateBinding(nodeID string) (PrivateNodeBinding, bool)

PrivateBinding returns an isolated operator-only deployment view for one node. The boolean is false for an unknown node.

func (*PreparedPlan) PrivateIdentity

func (prepared *PreparedPlan) PrivateIdentity() PrivatePlanIdentity

func (*PreparedPlan) Public

func (prepared *PreparedPlan) Public() PublicPreparation

func (*PreparedPlan) Validate

func (prepared *PreparedPlan) Validate() error

Validate repeats the complete resource-free handoff verification. It also detects descriptor mutation after preparation and is safe for concurrent launcher calls.

type PrivateNodeBinding

type PrivateNodeBinding struct {
	// contains filtered or unexported fields
}

PrivateNodeBinding is an explicit operator-only view of one deployment binding. Its generic string and JSON representations never reveal resource values or secret references.

func (PrivateNodeBinding) GoString

func (PrivateNodeBinding) GoString() string

func (PrivateNodeBinding) Implementation

func (binding PrivateNodeBinding) Implementation() string

func (PrivateNodeBinding) MarshalJSON

func (PrivateNodeBinding) MarshalJSON() ([]byte, error)

func (PrivateNodeBinding) Placement

func (binding PrivateNodeBinding) Placement() string

func (PrivateNodeBinding) Resources

func (binding PrivateNodeBinding) Resources() map[string]string

func (PrivateNodeBinding) SecretReferences

func (binding PrivateNodeBinding) SecretReferences() map[string]string

func (PrivateNodeBinding) String

func (PrivateNodeBinding) String() string

func (PrivateNodeBinding) Transport

func (binding PrivateNodeBinding) Transport() string

type PrivatePlanIdentity

type PrivatePlanIdentity struct {
	// contains filtered or unexported fields
}

PrivatePlanIdentity is deliberately opaque to generic JSON/logging paths. Deployment operators can request each fingerprint explicitly when binding private evidence, while its default projection remains redacted.

func (PrivatePlanIdentity) DeploymentFingerprint

func (identity PrivatePlanIdentity) DeploymentFingerprint() string

func (PrivatePlanIdentity) GoString

func (PrivatePlanIdentity) GoString() string

func (PrivatePlanIdentity) MarshalJSON

func (PrivatePlanIdentity) MarshalJSON() ([]byte, error)

func (PrivatePlanIdentity) SecretCatalogFingerprint

func (identity PrivatePlanIdentity) SecretCatalogFingerprint() string

func (PrivatePlanIdentity) String

func (PrivatePlanIdentity) String() string

type PublicPreparation

type PublicPreparation struct {
	Plan         graphconfig.Identity `json:"plan"`
	Nodes        []PreparedNode       `json:"nodes"`
	Dependencies []PreparedDependency `json:"dependencies,omitempty"`
}

PublicPreparation is safe for default inspection and logging. It contains the plan's redacted deployment identity but no private deployment fingerprint, secret-catalog fingerprint, resource values, or secret references.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry maps deployment implementation references to factories. A factory is admitted only after its immutable descriptor identity is computed.

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Register

func (registry *Registry) Register(implementation string, factory element.Factory) error

func (*Registry) RegisterArtifact

func (registry *Registry) RegisterArtifact(
	implementation string, artifact inspect.ArtifactIdentity, factory element.Factory,
) error

RegisterArtifact binds an element factory to an exact deployment artifact. It remains the compatible API for direct Config mounts. Graph-plan launchers use RegisterFactory instead, because a Plan also freezes transport, placement, resource/secret-slot, and capability evidence.

func (*Registry) RegisterFactory

func (registry *Registry) RegisterFactory(registration FactoryRegistration) error

RegisterFactory records the complete production startup profile for an implementation. Register and RegisterArtifact remain compatibility APIs; plans prepared through PreparePlan deliberately refuse those incomplete registrations.

type SecretAccess

type SecretAccess interface {
	Resolve(context.Context, string) (*graphsecret.Value, SecretResolution, error)
}

SecretAccess resolves only the slot names bound to the calling node. The deployment reference and provider locator are deliberately absent from this API; callers receive an erasable handle and safe provider evidence only.

type SecretResolution

type SecretResolution struct {
	BindingFingerprint string
	Provider           string
	ProviderRuntime    inspect.ArtifactIdentity
}

SecretResolution is safe to retain in inspection and benchmark evidence. BindingFingerprint covers provider plus locator without revealing either the locator or the secret reference. It never hashes credential bytes.

type SequenceAllocator

type SequenceAllocator struct {
	// contains filtered or unexported fields
}

SequenceAllocator supplies monotonic, mount-scoped namespaces. It avoids a hidden package-global counter while allowing several independently authored elements to allocate one canonical revision domain.

func NewSequenceAllocator

func NewSequenceAllocator() *SequenceAllocator

func (*SequenceAllocator) Next

func (allocator *SequenceAllocator) Next(namespace string) (uint64, error)

type ServiceSet

type ServiceSet struct {
	// contains filtered or unexported fields
}

ServiceSet is a concurrency-safe dependency context. Revision increases on replacement so future reconciliation can detect coeffect changes.

func NewServiceSet

func NewServiceSet() *ServiceSet

func (*ServiceSet) InstallIfAbsent

func (services *ServiceSet) InstallIfAbsent(entries map[string]any) (map[string]uint64, error)

InstallIfAbsent atomically publishes a non-empty batch of services if none of their canonical names is already registered. Validation and collision checks complete before any service is visible. The returned revisions are keyed by canonical service name.

The create-only guarantee applies at this method's linearization point. A later Set call may deliberately replace an installed service as part of reconciliation.

func (*ServiceSet) Lookup

func (services *ServiceSet) Lookup(name string) (any, uint64, bool)

func (*ServiceSet) Remove

func (services *ServiceSet) Remove(name string) (uint64, bool)

func (*ServiceSet) Set

func (services *ServiceSet) Set(name string, value any) (uint64, error)

type TraceEvent

type TraceEvent struct {
	Kind        TraceKind `json:"kind"`
	AtNS        uint64    `json:"at_ns"`
	Graph       string    `json:"graph"`
	Fingerprint string    `json:"fingerprint"`
	Channel     string    `json:"channel"`
	ItemID      string    `json:"item_id,omitempty"`
	TraceID     string    `json:"trace_id,omitempty"`
	RunID       string    `json:"run_id,omitempty"`
	Occupancy   int       `json:"occupancy"`
	Depth       int       `json:"depth"`
}

TraceEvent contains causal and timing metadata but never the item payload.

type TraceFunc

type TraceFunc func(TraceEvent)

func (TraceFunc) Record

func (function TraceFunc) Record(event TraceEvent)

type TraceKind

type TraceKind string
const (
	TraceEnqueue      TraceKind = "enqueue"
	TraceDequeue      TraceKind = "dequeue"
	TraceDrop         TraceKind = "drop"
	TraceBackpressure TraceKind = "backpressure"
)

type TraceRecordingConfig

type TraceRecordingConfig struct {
	Limits                inspect.TraceLimits
	SessionCorrelationKey []byte
	MaxRetainedBytes      int
	CaptureInterval       time.Duration
}

TraceRecordingConfig opts one mounted graph into bounded, payload-free live trace retention. SessionCorrelationKey must be a fresh cryptographically random 32-byte value for this session. The runtime copies and erases its copy during shutdown; it never creates an ambient process-wide correlation key.

MaxRetainedBytes bounds the compact JSON size of retained snapshot/event records, in addition to Limits. CaptureInterval coalesces media-path signals; zero selects a conservative default and a negative duration is invalid.

type Tracer

type Tracer interface {
	Record(TraceEvent)
}

Jump to

Keyboard shortcuts

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