runneragent

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package runneragent dispatches authenticated runner RPCs to a local substrate. Session admission, durable offline enforcement and stream bridges remain separate dependencies; no test server is used by the production daemon.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	RunnerID  string
	Substrate substrate.Substrate
	// HoldsSandbox reports whether a local ref is a sandbox this runner created
	// and durably holds. Any other ref reaches the substrate only when the
	// substrate proves it a sandbox created for this runner.
	HoldsSandbox func(string) bool
	// BeforeCreate durably establishes a unique creation intent and live lease.
	// Nil proves a NEW run; every existing or ambiguous intent must refuse.
	BeforeCreate func(context.Context, runner.SandboxSpec) error
	// Created durably binds the run to its local ref before success is reported.
	Created func(context.Context, runner.SandboxSpec, string) error
	// CreateFailed durably contains a failed NEW intent, including partial
	// provisioning. It must retain output and retry proxy containment locally.
	CreateFailed func(context.Context, runner.SandboxSpec) error
	// BeforeRefCall enforces offline/lease policy before a state-changing call.
	// The generation is the explicit Exec/Start CALL identity, zero otherwise.
	BeforeRefCall func(context.Context, string, string, uuid.UUID) error
	// AfterRefCall persists successful state changes with the same generation.
	// The exec id is populated for MethodExec, empty otherwise. Persistence
	// failures must contain the proxy before returning their error.
	AfterRefCall func(context.Context, string, string, string, uuid.UUID) error
	// MutationFinished runs after every admitted mutation, including substrate
	// failures, output rollback and detached persistence. Create supplies run ID;
	// ref calls supply the checked local ref and explicit execution generation.
	MutationFinished func(context.Context, string, string, uuid.UUID, uuid.UUID, error) error
	// ExecutionResult recovers a durable intent/handle without executing it again.
	ExecutionResult func(context.Context, string, uuid.UUID) (runnerwire.ExecutionResult, error)
	// Streams serves attach/exec/resize/wait/output, with ref validation of its own.
	Streams      func(context.Context, *runnerwire.Peer, uint32, string, json.RawMessage) (any, error)
	Output       func(uuid.UUID) (io.Writer, error)
	BindOutput   func(uuid.UUID, string) error
	ForgetOutput func(uuid.UUID) error
	// Resident is the runner_resident adapter; nil refuses both verbs and any
	// create or proxy replacement that names a resident grant.
	Resident *Resident
}

Config supplies the local executor and the production safety adapters.

type Dispatcher

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

func New

func New(cfg Config) (*Dispatcher, error)

func (*Dispatcher) Call

func (d *Dispatcher) Call(ctx context.Context, peer *runnerwire.Peer, id uint32, method string, args json.RawMessage) (any, error)

Call is RunnerHooks.Call. Byte stream verbs go to the H4 adapter; everything else calls the same substrate interfaces as the local orchestrator.

type Keystore

type Keystore struct {
	Set    func(account, value string) error
	Get    func(account string) (string, error)
	Delete func(account string) error
}

Keystore is where resident values live; production is package keystore.

type Resident

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

Resident is the runner half of runner_resident delivery (design 0.9 §7.4). Values live only in the keystore and in the sandbox or proxy they are applied to. The index of what this runner holds (never a value) is kept in the state directory, so a restarted runner can still erase at run end.

func NewResident

func NewResident(ks Keystore, stateDir string) (*Resident, error)

NewResident loads the index at stateDir/resident.json.

func (*Resident) Call

func (r *Resident) Call(ctx context.Context, peer *runnerwire.Peer, method string, args json.RawMessage) (any, error)

Call serves deliver_resident and erase_resident.

func (*Resident) EraseExpired

func (r *Resident) EraseExpired(ctx context.Context, now time.Time) error

EraseExpired deletes every held value whose NotAfter has passed by now, whether or not its run's end ever reached this runner (an org erase that never arrived, a run the org lost). A value whose delete fails stays indexed, so the next sweep retries it.

func (*Resident) SweepExpired

func (r *Resident) SweepExpired(ctx context.Context, every time.Duration)

SweepExpired runs EraseExpired every interval until ctx ends.

Jump to

Keyboard shortcuts

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