ateadapter

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package ateadapter implements the frozen agentsessions runtime/substrate.ControlClient over the REAL agent-substrate ate-api Control gRPC (github.com/agent-substrate/substrate/pkg/proto/ateapipb).

Neutrality (hard rule): this lives in its OWN Go module so the core agentsessions module imports zero substrate code and its go.mod stays clean. runtime/substrate.ControlClient is the seam — substrate is one backend that adapts to our interface, not a dependency of the neutral core.

Mapping: Create->CreateActor; Resume->ResumeActor; Suspend->SuspendActor; Delete->DeleteActor; Status->GetActor; clone->CreateTag{source_actor}+CreateActor{source_tag}; release->DeleteTag. The interface is frozen our side; this is a pure translation of the generated client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter implements substrate.ControlClient over the ate-api Control gRPC client.

func FromClient

func FromClient(ctl atepb.ControlClient) *Adapter

FromClient wraps an already-constructed ate-api Control client (used in tests with a double).

func New

func New(conn grpc.ClientConnInterface) *Adapter

New wraps an ate-api Control client over conn. The caller owns dialing and authentication.

func (*Adapter) CreateActor

func (ad *Adapter) CreateActor(ctx context.Context, actor substrate.ActorRef, template substrate.ObjectRef) error

CreateActor creates an actor from an ActorTemplate (atespace + name). With no source tag, substrate seeds it from the template's golden snapshot when one is built. A name already taken is reported as substrate.ErrActorExists, so the backend can attach to the actor another host just created.

func (*Adapter) CreateActorFromTag

func (ad *Adapter) CreateActorFromTag(ctx context.Context, actor substrate.ActorRef, template substrate.ObjectRef, tag substrate.SnapshotID) (substrate.ActorInfo, error)

CreateActorFromTag creates an actor seeded from the snapshot behind tag. Substrate requires the actor's template to be the one the snapshot was taken under. The actor is created SUSPENDED and borrows the tag's snapshot; the caller resumes it to restore the cloned RAM. CreateActor returns the actor it stored, with the UID substrate assigned (RPCService.CreateActor in cmd/ateapi/internal/controlapi/actor.go), so the caller can tell that clone from a later actor under the same name.

func (*Adapter) DeleteActor

func (ad *Adapter) DeleteActor(ctx context.Context, actor substrate.ActorRef) error

DeleteActor deletes a suspended actor.

func (*Adapter) DeleteTag

func (ad *Adapter) DeleteTag(ctx context.Context, tag substrate.SnapshotID) error

DeleteTag removes a tag and collects the snapshot copy it owns.

func (*Adapter) GetActor

func (ad *Adapter) GetActor(ctx context.Context, actor substrate.ActorRef) (substrate.ActorInfo, error)

GetActor reads the actor's current state. A missing actor is reported as substrate.ErrActorNotFound so the backend can tell "never placed" (create it) apart from "already placed" (attach to it) without inspecting gRPC codes itself.

func (*Adapter) ResumeActor

func (ad *Adapter) ResumeActor(ctx context.Context, actor substrate.ActorRef) (substrate.ActorInfo, error)

ResumeActor schedules the actor onto a worker. Substrate restores the actor's own external snapshot when it holds one (including a tag's, borrowed at creation) and cold-boots the template spec otherwise; the request carries no boot flag. Substrate refuses a resume while another operation holds the actor's lease with ABORTED, reported as substrate.ErrActorBusy, and a missing actor with NOT_FOUND (RPCService.ResumeActor in cmd/ateapi/internal/controlapi/actor.go), reported as substrate.ErrActorNotFound. Substrate can also answer NOT_FOUND for an actor that exists, when a volume is missing from its template (createActorVolumes in cmd/ateapi/internal/controlapi/volumes.go, called by ensureVolumesCreated in workflow_resume.go), so the backend checks the actor with GetActor before it reads either as the actor being gone.

func (*Adapter) SuspendActor

func (ad *Adapter) SuspendActor(ctx context.Context, actor substrate.ActorRef) (substrate.ActorInfo, error)

SuspendActor snapshots the actor to durable storage and frees the worker, returning the actor as the suspend left it: the external snapshot's URI and observed fidelity (see heldSnapshot), and its UID. Substrate refuses a suspend while another operation holds the actor's lease with ABORTED, reported as substrate.ErrActorBusy, and a missing actor with NOT_FOUND (RPCService.SuspendActor in cmd/ateapi/internal/controlapi/actor.go maps the store's ErrNotFound from ActorWorkflow.SuspendActor in cmd/ateapi/internal/controlapi/workflow_suspend.go), reported as substrate.ErrActorNotFound, which the ControlClient contract requires: a memory-tier Snapshot reads it as the session's in-RAM state being gone, not as a transport failure.

The suspend is synchronous. SuspendActorRequest at substrate v0.5.0 has no durability option: SuspendActor in cmd/ateapi/internal/controlapi/workflow_suspend.go checkpoints a running actor with UPLOAD_MODE_IMMEDIATE (or uploads a paused actor's local snapshot with PromoteSnapshot), and ensureSuspendedFinalized marks the newest generation COMPLETED before the call returns. The adapter does not rely on that: actorInfo reports a newest generation that is not COMPLETED as SnapshotNotReady, which the backend refuses rather than return or restore a checkpoint. Substrate after v0.5.0 adds SuspendActorRequest.options.mode and defaults it to asynchronous, so TestSuspendActorRequestHasNoDurabilityOption fails on a bump that adds any request field until this call asks for a synchronous suspend explicitly.

func (*Adapter) TagActor

func (ad *Adapter) TagActor(ctx context.Context, source substrate.ActorRef, tag substrate.SnapshotID) error

TagActor tags the external snapshot the suspended source actor holds. Substrate copies the snapshot into tag-owned storage inside the call, so the tag is usable as soon as it returns. The tag uses the ATESPACE scope: it may seed actors only in the source's atespace, which is all a fork needs because the child is created alongside its parent. Publishing (cross-atespace reuse) is deliberately not done here.

A name already taken, whether by a finished tag or one a failed create left pending, is reported as substrate.ErrTagExists, so the backend does not delete a tag this call did not reserve. Substrate refuses a tag while another operation holds the source actor's lease with ABORTED (acquireLease in cmd/ateapi/internal/controlapi/workflow.go, called from TagActorSnapshot in cmd/ateapi/internal/controlapi/workflow_tag.go), reported as substrate.ErrActorBusy. A missing source actor is FAILED_PRECONDITION (RPCService.CreateTag in cmd/ateapi/internal/controlapi/tag.go), which the backend classifies by reading the actor.

Directories

Path Synopsis
cmd
agentsessionsd command
Command agentsessionsd is the Sessions API server with the agent-substrate backend linked in: on top of everything the neutral cmd/agentsessionsd serves, -substrate-harness name=atespace/template runs a harness as one substrate actor per session, created from that ActorTemplate, controlled over the ate-api (-ateapi-addr, -ateapi-token-file) and reached through the atenet-router (-atenet-router).
Command agentsessionsd is the Sessions API server with the agent-substrate backend linked in: on top of everything the neutral cmd/agentsessionsd serves, -substrate-harness name=atespace/template runs a harness as one substrate actor per session, created from that ActorTemplate, controlled over the ate-api (-ateapi-addr, -ateapi-token-file) and reached through the atenet-router (-atenet-router).

Jump to

Keyboard shortcuts

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