Documentation
¶
Overview ¶
Package offline defines extraction-ready build manifests and an embedded workflow runner for the conservative daemon-less execution subset.
Execution deliberately uses the ordinary runtime binding, recovery, ready-queue, dispatch, and output-finalization contracts. The current process-lifetime implementation is provided by runtime/inmemory; it is encapsulated here so generated artifacts do not acquire a second scheduler or reimplement graph semantics. Hosts that promise restart recovery must inject durable storage through ExecuteWithStore.
Index ¶
- Constants
- Variables
- func AdaptExecutionRegistry(plan compile.ExecutionPlan, source stepkind.Registry, input []ExternalBinding) (*stepkind.MemoryRegistry, error)
- func OutputObject(set values.ValueSet) (map[string]any, error)
- func ParseCLIInputs(manifest Manifest, arguments []string) (map[string]any, error)
- func RegisterManifestKinds(registry stepkind.Registry, manifest Manifest, localKinds ...stepkind.StepKind) error
- func RunCLI(ctx context.Context, manifest Manifest, registry stepkind.Registry, ...) error
- func RunCLIWithOptions(ctx context.Context, manifest Manifest, options ExecuteOptions, ...) error
- func ServeMCP(ctx context.Context, manifest Manifest, registry stepkind.Registry, ...) error
- func ServeMCPWithOptions(ctx context.Context, manifest Manifest, options ExecuteOptions, ...) error
- func WriteCLIHelp(manifest Manifest, output io.Writer) error
- type BindingCatalog
- type BindingCatalogFunc
- type BindingDescription
- type BuildOptions
- type BuildResult
- type DiagnosticError
- type ExecuteOptions
- type ExecutionResult
- type ExecutionStore
- type ExternalBinding
- type Manifest
- type Mode
- type RemoteExecutionProfile
- type ResolvedBinding
- type RunFailureError
- type RuntimeRegistryBinder
- type RuntimeRegistryBinderFunc
- type SchemaField
Constants ¶
const ( MaximumCLIArguments = 512 MaximumInputBytes = 4 << 20 MaximumRPCBytes = 8 << 20 )
const ( ManifestSchemaVersion = "1" ModeCLI = Mode("cli") ModeMCPServer = Mode("mcp-server") DefaultMaxManifestBytes = 8 << 20 MaximumManifestBytes = 64 << 20 DefaultMaxBindingBytes = 256 << 10 MaximumBindings = 256 CodeInvalidBuild diagnostic.Code = "HADR-HOST-030" CodeUnknownKind diagnostic.Code = "HADR-HOST-031" CodeEmbeddedUnsupported diagnostic.Code = "HADR-HOST-032" CodeUnsupportedEffect diagnostic.Code = "HADR-HOST-033" CodeBindingRequired diagnostic.Code = "HADR-HOST-034" CodeBindingInvalid diagnostic.Code = "HADR-HOST-035" CodeWaitServiceRequired diagnostic.Code = "HADR-HOST-036" )
const DefaultMaxExecutionSteps = 10000
const (
DriverRemoteDaemonHTTP = "hadron-remote-http-v1"
)
Variables ¶
var ( ErrInvalidBuild = errors.New("invalid offline workflow build") ErrExecutionStalled = errors.New("offline workflow execution made no progress") )
Functions ¶
func AdaptExecutionRegistry ¶
func AdaptExecutionRegistry(plan compile.ExecutionPlan, source stepkind.Registry, input []ExternalBinding) (*stepkind.MemoryRegistry, error)
AdaptExecutionRegistry constructs the exact executable catalog for a plan. Unbound kinds preserve their registered implementations and specs. A kind selected by the versioned remote driver becomes an explicit polling proxy: its original immutable contract remains recorded on ResolvedBinding while this returned registry supplies the actual manifest/runtime contract.
func OutputObject ¶
OutputObject returns the declared workflow data projection. Inline values become their native JSON payloads; artifact and secret references remain opaque typed envelopes and never resolve content or credentials.
func ParseCLIInputs ¶
ParseCLIInputs parses generated --<input> flags without consulting ambient environment or configuration. Non-string inputs are exact single JSON values decoded with json.Number preservation.
func RegisterManifestKinds ¶
func RegisterManifestKinds(registry stepkind.Registry, manifest Manifest, localKinds ...stepkind.StepKind) error
RegisterManifestKinds reconstructs the closed executable catalog embedded by a generator. The caller supplies concrete local implementations; all remaining accepted specs must be backed by the explicit remote-daemon HTTP binding selected at build time. Workflow core never imports those adapters.
func RunCLIWithOptions ¶
func RunCLIWithOptions(ctx context.Context, manifest Manifest, options ExecuteOptions, arguments []string, stdout io.Writer) error
RunCLIWithOptions runs the generated CLI using the supplied exact runtime composition options. Parsed CLI inputs replace any Inputs in options.
func ServeMCP ¶
func ServeMCP(ctx context.Context, manifest Manifest, registry stepkind.Registry, input io.Reader, output io.Writer) error
ServeMCP exposes exactly one generated workflow tool over newline-delimited MCP JSON-RPC on stdio. It implements only initialize, tools/list, and tools/call plus notification tolerance; no Hadron daemon tools are exposed.
func ServeMCPWithOptions ¶
func ServeMCPWithOptions(ctx context.Context, manifest Manifest, options ExecuteOptions, input io.Reader, output io.Writer) error
ServeMCPWithOptions exposes the generated tool using the supplied exact runtime composition options. Each tool call supplies its own typed inputs.
Types ¶
type BindingCatalog ¶
type BindingCatalog interface {
DescribeBinding(context.Context, ExternalBinding, graph.Node, stepkind.StepKindSpec) (BindingDescription, error)
}
BindingCatalog proves that a binding is backed by a functional runtime bridge. Merely placing a binding-shaped object in a manifest never makes an otherwise unsupported node buildable.
type BindingCatalogFunc ¶
type BindingCatalogFunc func(context.Context, ExternalBinding, graph.Node, stepkind.StepKindSpec) (BindingDescription, error)
BindingCatalogFunc adapts one deterministic binding description function.
func (BindingCatalogFunc) DescribeBinding ¶
func (f BindingCatalogFunc) DescribeBinding(ctx context.Context, binding ExternalBinding, node graph.Node, spec stepkind.StepKindSpec) (BindingDescription, error)
type BindingDescription ¶
type BindingDescription struct {
EffectiveEffects graph.EffectSet `json:"effective_effects,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
RemoteWait bool `json:"remote_wait,omitempty"`
}
BindingDescription is the trusted node-scoped execution profile returned by the closed versioned bridge. MCP/LLM source specs conservatively advertise their maximum effects; ADR 0011 permits only an exact node/kind/version/config binding to narrow that maximum to a safe remote operation. Ordinary graph effect declarations never narrow either source or effective effects.
type BuildOptions ¶
type BuildOptions struct {
Registry stepkind.Registry
// SourceRegistry is the authoring/daemon catalog when Registry contains
// explicit binding-backed executable proxies. Nil means Registry.
SourceRegistry stepkind.Registry
Bindings []ExternalBinding
BindingCatalog BindingCatalog
Mode Mode
ToolName string
MaxManifestBytes int
MaxBindingBytes int
}
type BuildResult ¶
type BuildResult struct {
Manifest *Manifest
Bytes []byte
Diagnostics []diagnostic.Diagnostic
}
func Build ¶
func Build(ctx context.Context, plan *compile.ExecutionPlan, options BuildOptions) (BuildResult, error)
Build validates and canonicalizes an already compiled plan. Diagnostics are stable and source-mapped; no artifact is returned when any diagnostic exists.
type DiagnosticError ¶
type DiagnosticError struct{ Diagnostics []diagnostic.Diagnostic }
func (*DiagnosticError) Error ¶
func (e *DiagnosticError) Error() string
type ExecuteOptions ¶
type ExecuteOptions struct {
Registry stepkind.Registry
RegistryBinder RuntimeRegistryBinder
Verifiers verification.Registry
Inputs map[string]any
Now func() time.Time
MaxSteps int
// PollInterval bounds durable external-operation observation cadence.
// Zero selects 100ms; tests may inject a shorter positive cadence.
PollInterval time.Duration
// RunID and IdempotencyKey let an ordinary host use the embedded engine
// while preserving its caller-visible identity. Generated/offline callers
// may omit both and receive deterministic content-derived defaults.
RunID runtime.RunID
IdempotencyKey string
}
type ExecutionResult ¶
type ExecutionResult struct {
Run runtime.RunSnapshot `json:"run"`
Outputs values.ValueSet `json:"outputs,omitempty"`
}
func Execute ¶
func Execute(ctx context.Context, manifest Manifest, options ExecuteOptions) (ExecutionResult, error)
Execute runs an exact manifest through the ordinary durable runtime over a fresh concurrency-safe in-memory store. It never interprets graph edges or expressions independently of runtime coordinators.
func ExecuteWithStore ¶
func ExecuteWithStore(ctx context.Context, manifest Manifest, options ExecuteOptions, store ExecutionStore) (ExecutionResult, error)
ExecuteWithStore runs the same embedded host loop against an injected implementation of the ordinary runtime storage contracts. It is useful for daemon/offline parity checks; generated artifacts use Execute's private in-memory instance.
type ExecutionStore ¶
type ExecutionStore interface {
runtime.StateStore
runtime.RecoveryStore
runtime.NodeInputStore
runtime.ControlFlowStore
runtime.RunPolicyStore
runtime.FanOutStore
}
ExecutionStore is the existing runtime contract subset needed by the embedded host loop. SQLite-backed daemon hosts and the in-memory offline implementation can therefore be parity-tested without alternate semantics.
type ExternalBinding ¶
type ExternalBinding struct {
NodeID string `json:"node_id"`
Kind string `json:"kind"`
Version string `json:"version"`
Driver string `json:"driver"`
Config graph.Config `json:"config,omitempty"`
Effects graph.EffectSet `json:"effects,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
}
ExternalBinding is a non-secret, node-scoped declaration for a capability that the generated host must actually provide. Config may contain opaque secret:// references, but never resolved credentials. Driver is a stable implementation identity and therefore participates in the build digest.
type Manifest ¶
type Manifest struct {
SchemaVersion string `json:"schema_version"`
Mode Mode `json:"mode"`
BuildDigest string `json:"build_digest"`
PlanDigest string `json:"plan_digest"`
Plan compile.ExecutionPlan `json:"plan"`
Visibility compile.ValueVisibilityPlan `json:"visibility"`
Inputs []SchemaField `json:"inputs,omitempty"`
Outputs []SchemaField `json:"outputs,omitempty"`
StepKinds []stepkind.StepKindSpec `json:"step_kinds"`
Bindings []ResolvedBinding `json:"bindings,omitempty"`
ToolName string `json:"tool_name,omitempty"`
}
Manifest is the canonical, executable offline envelope. PlanDigest is repeated beside Plan so inspection does not need to understand plan JSON. Input/Output schema projections are also repeated and exact-checked.
func ParseManifest ¶
type RemoteExecutionProfile ¶
type RemoteExecutionProfile struct {
Driver string `json:"driver"`
NodeID string `json:"node_id"`
Kind string `json:"kind"`
Version string `json:"version"`
NodeConfigDigest string `json:"node_config_digest"`
SourceSpecDigest string `json:"source_spec_digest"`
ExecutionSpecDigest string `json:"execution_spec_digest"`
Effects graph.EffectSet `json:"effects,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
}
type ResolvedBinding ¶
type ResolvedBinding struct {
Binding ExternalBinding `json:"binding"`
Description BindingDescription `json:"description"`
// SourceSpec is the exact daemon kind contract adapted by the versioned
// remote driver. Manifest StepKinds contains the actual executable proxy
// contract; recording both makes the adaptation explicit and reviewable.
SourceSpec stepkind.StepKindSpec `json:"source_spec"`
// ExecutionProfile labels the binding-backed proxy rather than presenting
// it as the original public adapter contract. It is sent on every remote
// invocation so the daemon can enforce the exact build-time narrowing.
ExecutionProfile RemoteExecutionProfile `json:"execution_profile"`
}
type RunFailureError ¶
type RunFailureError struct {
Run runtime.RunSnapshot
Failure *runtime.Failure
}
func (*RunFailureError) Error ¶
func (e *RunFailureError) Error() string
type RuntimeRegistryBinder ¶
type RuntimeRegistryBinder interface {
BindRuntimeRegistry(context.Context, stepkind.Registry, ExecutionStore, Manifest) (stepkind.Registry, error)
}
RuntimeRegistryBinder adapts an exact immutable build registry to an execution store without teaching workflow core about concrete adapters. The returned registry must advertise exactly the manifest StepKinds.
type RuntimeRegistryBinderFunc ¶
type RuntimeRegistryBinderFunc func(context.Context, stepkind.Registry, ExecutionStore, Manifest) (stepkind.Registry, error)
RuntimeRegistryBinderFunc adapts a runtime-registry binding function.
func (RuntimeRegistryBinderFunc) BindRuntimeRegistry ¶
func (f RuntimeRegistryBinderFunc) BindRuntimeRegistry(ctx context.Context, registry stepkind.Registry, store ExecutionStore, manifest Manifest) (stepkind.Registry, error)
BindRuntimeRegistry implements RuntimeRegistryBinder.