Documentation
¶
Overview ¶
Package runtime mounts and executes immutable OpenRealtime Graph IR.
Index ¶
- Constants
- Variables
- func StandardDependencyArtifact(name string) (inspect.ArtifactIdentity, bool)
- func StandardDependencyArtifacts() map[string]inspect.ArtifactIdentity
- type BufferTracer
- type Clock
- type ClockFunc
- type Config
- type DependencyRegistry
- func (registry *DependencyRegistry) Register(name string, artifact inspect.ArtifactIdentity, value any) error
- func (registry *DependencyRegistry) RegisterMountScoped(name string, artifact inspect.ArtifactIdentity) error
- func (registry *DependencyRegistry) RegisterRuntimeOwned(name string, artifact inspect.ArtifactIdentity) error
- type FactoryProfile
- type FactoryRegistration
- type InspectionConfig
- type Mounted
- func (mounted *Mounted) CheckpointTrace() error
- func (mounted *Mounted) Close(ctx context.Context) error
- func (mounted *Mounted) DeploymentEvidence() (inspect.DeploymentEvidence, bool)
- func (mounted *Mounted) DeploymentIdentity() (inspect.ArtifactIdentity, bool)
- func (mounted *Mounted) Done() <-chan struct{}
- func (mounted *Mounted) Egress(name string) (element.InputPort, error)
- func (mounted *Mounted) Err() error
- func (mounted *Mounted) Graph() ir.Graph
- func (mounted *Mounted) Ingress(name string) (element.OutputPort, error)
- func (mounted *Mounted) Live() inspect.Live
- func (mounted *Mounted) MarshalRecordedTrace() ([]byte, error)
- func (mounted *Mounted) PrivateIdentity() (PrivatePlanIdentity, bool)
- func (mounted *Mounted) RecordedTrace() (inspect.LiveTrace, error)
- func (mounted *Mounted) Run(parent context.Context) error
- type PlanPreparation
- type PreparedDependency
- type PreparedMountDependency
- type PreparedMountOptions
- type PreparedNode
- type PreparedPlan
- func (prepared *PreparedPlan) Graph() ir.Graph
- func (prepared *PreparedPlan) Identity() graphconfig.Identity
- func (prepared *PreparedPlan) MarshalJSON() ([]byte, error)
- func (prepared *PreparedPlan) Mount(ctx context.Context, options PreparedMountOptions) (*Mounted, error)
- func (prepared *PreparedPlan) PrivateBinding(nodeID string) (PrivateNodeBinding, bool)
- func (prepared *PreparedPlan) PrivateIdentity() PrivatePlanIdentity
- func (prepared *PreparedPlan) Public() PublicPreparation
- func (prepared *PreparedPlan) Validate() error
- type PrivateNodeBinding
- func (PrivateNodeBinding) GoString() string
- func (binding PrivateNodeBinding) Implementation() string
- func (PrivateNodeBinding) MarshalJSON() ([]byte, error)
- func (binding PrivateNodeBinding) Placement() string
- func (binding PrivateNodeBinding) Resources() map[string]string
- func (binding PrivateNodeBinding) SecretReferences() map[string]string
- func (PrivateNodeBinding) String() string
- func (binding PrivateNodeBinding) Transport() string
- type PrivatePlanIdentity
- type PublicPreparation
- type Registry
- type SecretAccess
- type SecretResolution
- type SequenceAllocator
- type ServiceSet
- type TraceEvent
- type TraceFunc
- type TraceKind
- type TraceRecordingConfig
- type Tracer
Constants ¶
const ( ClockServiceName = "runtime.clock" SequenceServiceName = "runtime.sequence" )
const MaximumStateSnapshotBytes = 1 << 20
MaximumStateSnapshotBytes bounds predecessor, restored, and migrated graph element state before and after canonicalization.
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 ¶
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") )
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") )
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 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 ¶
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 ¶
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 ¶
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) Live ¶
Live returns one consistent best-effort inspection snapshot without blocking graph execution on a telemetry consumer.
func (*Mounted) MarshalRecordedTrace ¶
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 ¶
RecordedTrace returns a recursively independent, fingerprinted artifact and verifies deterministic replay against the exact mounted Graph IR.
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) 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
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 ¶
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.
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 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)
}