Skip to content

google/ax

Agent Executor (AX) is Google's open agentic orchestration runtime

https://skillcdn.ai/gh/google/ax

Connect this address to your AI to use this skill. How to connect

  • Unverified
  • Default branchmain
  • Commit7236277
  • LicenseApache-2.0
  • Searchwords

Showing commit 7236277

The newest commit, 9a59797, is being indexed. Until it is ready, this page and every agent are served the last indexed commit.
View on GitHub

substrate

How AX depends on Agent Substrate (modules, address contract, mocks, version bumps, E2E pin). Load when touching internal/substrate, bumping Substrate, or triaging make test-e2e.

Path
skills/substrate/SKILL.md
License
Apache-2.0

Agent Substrate in AX

AX schedules every Task as a sandboxed actor on Agent Substrate. AX owns the declarative layer (Task/Workspace/Model, task manager, CLI); Substrate owns isolation, checkpoint/restore, worker placement and in-cluster routing. Facts below were verified against main on 2026-11-06 — re-check go.mod and hack/setup-e2e-kind.sh if they look stale.

1. Module map

ModulePinnedProvidesImported by
go.ate.dev/substratev1.0.0Control API protos api/ateapi/v1 (atespaces, actor templates, actors, tags, snapshot fidelity, suspend/resume, egress rules) and pkg/postgressetupinternal/substrate, internal/substrate/substratetest, internal/install/substrate, internal/server, internal/controller, internal/apivalidation, test/e2e, pkg/apis/v1alpha1 (its .proto files import ateapi.proto)
github.com/agent-substrate/envv0.0.11-0.20260912052224-4468a200b170 (pseudo-version)Guest services served inside the sandbox (process exec + file system gRPC) and proto/ateenv/v1alphainternal/guest, internal/metadata

There is no replace directive for either module. Local hacking against a Substrate checkout goes through SUBSTRATE_DIR in E2E (section 5).

2. The Control API wrapper: internal/substrate.Client

All Control API traffic goes through this package. It encapsulates:

  • Endpoint defaults — api.ate-system.svc.cluster.local:443; authority and TLS ServerName default to api.ate-system.svc when the target contains that string.
  • Auth — bearer token from SUBSTRATE_TOKEN_FILE (in-cluster: projected SA token with audience api.ate-system.svc, see deploy/ax-server.yaml), CA from SUBSTRATE_CA_FILE.
  • Retry — IsTransientError (Unavailable, DeadlineExceeded, Aborted) + callWithRetry (retryOnCodes).
  • Helpers the task and workspace managers rely on — EnsureAtespace, EnsureActorTemplate, EnsureActorTemplateWithImage, BuildActorTemplate, EnsureActor, EnsureActorFromTag, GetActorEgressPolicy, EnsureActorEgressPolicy, CreateTag, GetTag, ListTags, DeleteTag, SuspendActor, SuspendActorAndWaitForSnapshot, ResumeActor, RevertActor, DeleteActor, WorkerIP.
Where a new Control API call lives today
  • internal/substrate/client.go is the only non-test file that calls ateapipb.NewControlClient; every existing RPC is a method on *Client, wrapped in callWithRetry (codes.Unavailable plus optional codes such as codes.Aborted).
  • Each method has a table-driven case in client_test.go (mockControlClient).
  • Callers in internal/controller exercise it through mockControlServer (task_test.go) or internal/substrate/substratetest (workspace_test.go); internal/server and cmd/ax tests also use internal/substrate/substratetest (section 4).

3. Address contract

ValueOccurrences
api.ate-system.svc.cluster.local:443 + authority api.ate-system.svccmd/ax-server/main.go (--substrate-endpoint / --substrate-authority flag defaults), internal/substrate/client.go (NewClientWithOptions: default target, TLS ServerName, authority), deploy/ax-server.yaml, test/e2e/manifests/ax-server.yaml, test/e2e/harness_test.go
atenet-router.ate-system.svc[.cluster.local]cmd/ax-server/main.go (--router-url flag default), internal/controller/task.go (defaultRouterServerName), internal/tunnel/router_tls.go (routerServerName), cmd/ax/main.go (ssh port-forward path), internal/guest/client.go (doc comment), deploy/ax-server.yaml, test/e2e/manifests/ax-server.yaml, docs/networking.md
namespace ate-systemall of the above + test/e2e/harness_test.go (ateSystemNamespace), test/e2e/manifests/credential-policy.yaml, internal/install/axdeploy/authz.go, internal/install/cluster/kind.go, internal/install/substrate/bootstrap.go, internal/install/substrate/pki.go, hack/sync-substrate-manifests.sh (and generated internal/install/substrate/manifests/*.yaml)
pod labels ate.dev/worker-pool (worker pods) and app: atenet-egress (egress gateway)the ax-server NetworkPolicy in deploy/ax-server.yaml and test/e2e/manifests/ax-server.yaml, which keeps both away from ax-server
opentelemetry-collector.otel-system.svc:4317 (the collector Substrate's kind overlay deploys, manifests/ate-install/kind/ate-otel-config.yaml in Substrate)test/e2e/manifests/ax-server.yaml (ax-otel-config ConfigMap). An unreachable address does not fail E2E; ax-server only logs OTLP export errors
kind-registry:5000, the registry container that serves the images of a loopback registry (localhost:5001/...) to an ax local clusterOnly atelet's --localhost-registry-replacement in internal/install/substrate/manifests/05-ate-system.yaml (generated; actor images). LocalRegistryEndpoint (internal/install/substrate/bootstrap.go) reads it from there, and cmd/ax/install_cmd.go passes it as cluster.UpOptions.LocalRegistry to the Kind provider (internal/install/cluster/registry.go), which writes the containerd mirror for pod images such as ax-server. No Go file names the registry; docs/development.md does

Why it matters: tasks never get a Service/Ingress. Every request to a task is proxied by the atenet router, which picks the target from the ate-target-actor header and resumes a suspended actor on demand (docs/networking.md). ax ssh port-forwards to svc/atenet-router on 443 (mTLS) and falls back to 80.

4. Testing against Substrate

Unit tests: in-process mock, no cluster
type mockControlServer struct {
    ateapipb.UnimplementedControlServer
    // record calls / inject failures here
}
grpcServer := grpc.NewServer()
ateapipb.RegisterControlServer(grpcServer, mockSrv)
// serve on a listener, point substrate.NewClientWithOptions at it (Plaintext: true)

Canonical examples: internal/controller/task_test.go (task lifecycle state transitions; the largest test file in the repo). internal/server/server_test.go and cmd/ax/main_test.go run a real TaskManager against internal/substrate/substratetest, an in-memory fake of the same API (atespaces, actor templates, actors, and tags). internal/substrate/client_test.go uses a client-side mockControlClient instead. No mocking library is in go.mod.

Substrate behaviour the code already depends on
  • Actor template images must be digest-pinned (@sha256:…); a tag-only spec.profile.image fails at ActorTemplate creation (docs/manifests.md): CreateTask returns the error, and a Workspace records reason TemplateCreationFailed. make images writes bin/ax-server.digest / bin/ax-runner.digest for this reason.
  • There is no server-wide default task image. A set spec.profile must name image or ateTemplate.name (ValidateCustom_Profile in internal/apivalidation/common.go), a Workspace with setup steps must set one, and a Task that omits it inherits its Workspace's (EffectiveProfile); CreateTask in internal/server/server.go rejects a Task with neither. ResolveProfileTemplate errors on an empty image. E2E Task and Workspace manifests get the image from {{taskImage}} ($AX_E2E_TASK_IMAGE, written to .tmp/e2e.env by hack/setup-e2e-kind.sh).
  • After ResumeActor the actor may be on a different worker, so AX never stores a worker IP: the task manager uses the IP ResumeActor returns only in conditions and logs (internal/controller/task.go), and both ax-server and ax ssh reach the actor through atenet-router.
  • Egress: an actor without an egress policy has no outbound access. For a task that binds a Gateway, bindGateway (internal/controller/task.go) asks Substrate whether the actor has a policy. If it has none, bindGateway creates its one policy (named default) from the Gateway's rules. An actor that has a policy keeps it, so the rules are copied once and never updated; Substrate deletes the policy with the actor. A task without a Gateway gets no policy. bindGateway runs once, when CreateTask has suspended the new actor. Substrate validates the rules when they are copied, and bindGateway fails when Substrate refuses them. ResumeTask treats a deleted Workspace as none, and fails before it touches the actor when the store cannot read it (fetchWorkspace in internal/server/server.go). DeleteWorkspace and DeleteGateway refuse while a task binds the object (findTask, same file).
  • A Task is stored only once its actor exists. When provisioning or the store write fails, CreateTask (internal/server/server.go) deletes the actor and stores nothing (deleteFailedCreate). Only CreateTask creates the actor (Create in internal/controller/task.go). SuspendTask and ResumeTask act on that actor (Suspend, Resume) and fail with FailedPrecondition when it no longer exists (ErrActorNotFound). Resume first reverts a crashed actor with RevertActor; Suspend does not, so suspending a crashed task returns Substrate's error.
  • Actors come from shared profile templates, so the runner learns its work by push: after ResumeActor, ax-server POSTs the Task (and its Workspace) to v1alpha1.RunnerTaskPath, or a Workspace to a setup actor at v1alpha1.RunnerSetupPath, on port 80, then polls /readyz?check=workspace (internal/controller/actorhttp.go), for a task on every resume. The requests go through atenet-router, the only way into an actor (--router-url, ate-target-actor header). The runner never calls ax-server. Resume fails with a transient error when the runner does not accept the push within WorkspaceReadyTimeout, and with a permanent one when the runner refuses the task or reports a failure for a task whose workspace is already set up.
  • status.actorUid is read live by setActorStatus in internal/server/server.go and cleared by storedStatus (same file) before writes. It changes when Substrate recreates the actor and is empty when the actor is missing or cannot be read. ax describe task shows it as Actor UID.
  • Guest services (process + fs) are mounted by internal/metadata/server.go only when task.Spec.Debug is true; ax ssh (cmd/ax/main.go) refuses to connect otherwise.
  • Trust bundle: BuildActorTemplate mounts egress-mitm.ate.dev and system-roots.ate.dev at v1alpha1.EgressTrustBundlePath for every task, and the runner points the CA variables at it (runner/env.go). A Substrate install that lacks either bundle blocks actor startup.
  • Runner volume: BuildActorTemplate mounts the runner volume image (--runner-volume-image, required and digest-pinned) read-only at v1alpha1.RunnerMountPath in every template AX creates and runs ax-runner from it, so a task image needs no AX binaries. Workspace setup runs the image's git and sh. A template named by spec.profile.ateTemplate is used as is and gets no runner.
  • Credential injection replaces a header only on requests that carry it. The runner supplies a placeholder only for git: GIT_ASKPASS is /ax/git-askpass, a link to the running program, and package runner answers from init when a program that imports it is started under that name (runner/env.go). It sets no API key variable, because tools choose a provider by which key is set: a task sets its own placeholders in spec.env. A Gateway's spec is never passed into the sandbox.
  • Readiness: Substrate and the task manager probe the runner on port 80 (/healthz, /readyz?check=workspace, served by internal/metadata); /readyz is 503 until all workspaces are materialized (docs/sandbox.md).
  • Workspace snapshot tags: SuspendActor defaults to asynchronous snapshot upload, whereas CreateTag requires the source actor's snapshot to be recorded, so WorkspaceManager suspends setup actors with SuspendActorAndWaitForSnapshot (DURABILITY_MODE_SYNCHRONOUS, internal/substrate/client.go). Because CreateTag spans two transactions around an object copy, an interrupted call can leave a tag with status.snapshot unset or SNAPSHOT_STORAGE_STATE_PENDING; isTagCompleted (internal/controller/workspace.go) requires SNAPSHOT_STORAGE_STATE_COMPLETED (populated by internal/substrate/substratetest/server.go in tests).
  • Envoy sidecars stay unready after a restart of only the container next to them in stock Substrate v1.0.0 (google/ax#697, https://github.com/agent-substrate/substrate/issues/3601). On SIGTERM the atenet-router container of atenet-router, and ext-proc of atenet-egress, call POST /healthcheck/fail and POST /drain_listeners?graceful&skip_exit over Envoy's admin API (cmd/atenet/internal/router/envoydrain.go in Substrate). When the kubelet restarts only that container, POST /healthcheck/ok alone cannot re-open drained listeners, and the envoy container has no liveness probe in the upstream manifests, so Envoy itself must be restarted. RenderSystemBundle and RenderEgressBundle (internal/install/substrate/bootstrap.go) inject a livenessProbe on /ready (port envoy-metrics) onto the envoy container of atenet-router and atenet-egress so the kubelet restarts a drained Envoy automatically. A cluster installed before that gets the probe the next time alreadyHealthy finds a pod of healthSelectors unready and Bootstrap applies the manifests again.
  • Snapshot storage: Actor templates created by AX leave SnapshotConfig.StorageLocation empty by default so Substrate uses its cluster-wide --snapshot-location. Specifying a custom snapshot bucket (snapshotsBucket in BuildActorTemplate) can only be used when the Substrate cluster has the PerTemplateSnapshotLocation preview feature gate enabled; otherwise Substrate rejects template creation with actor_template.snapshot_config.storage_location: Forbidden. Since v1.0.0 each path segment may contain only [A-Za-z0-9_-] and no segment may be atespaces; AX passes the value through unvalidated, so Substrate is the one that rejects it.

5. E2E and the Substrate version pin

test/e2e is compiled by go test ./... but self-skips unless AX_E2E=true or -args --e2e. The real runs go through make:

TargetSubstrate versionWhen
make test-e2eexactly go list -m -f '{{.Version}}' go.ate.dev/substratePR CI (skipped when only paths-ignore files change, e.g. docs) and the nightly schedule (06:00 UTC) in e2e.yml
make test-e2e SUBSTRATE_REF=<release tag>overridelocal, or workflow_dispatch input substrate_ref in e2e.yml
make e2e-setup / e2e-run / e2e-cleanupsame as aboveiterate without re-provisioning
make test-local-installthe manifests embedded in ax (internal/install/substrate/manifests)job local-install in e2e.yml, with the same triggers; substrate_ref does not apply

make test-local-install (hack/test-local-install.sh) is not part of the E2E suite. It is the only test that runs ax local start, and so the only one that runs the Kind provider, installsubstrate.Bootstrap, and axdeploy.Install on a real cluster. It reads the registry container to start from atelet's --localhost-registry-replacement in the embedded manifests (section 3).

hack/setup-e2e-kind.sh sets up two clusters in one kubeconfig, ax-e2e and a one-worker ax-e2e-remote that TestE2E_Promote promotes a task to (SKIP_REMOTE_KIND=true leaves it out, and the test is skipped).

E2E never builds Substrate. hack/setup-e2e-kind.sh installs the release's published images from ghcr.io/agent-substrate/substrate/<image>:<tag> (SUBSTRATE_IMAGE_REPO to use a mirror) via ATE_IMAGE_REPO/ATE_IMAGE_TAG, and pins the WorkerPool's worker image by digest. It exits early unless:

  • SUBSTRATE_REF is a release tag, vX.Y.Z or vX.Y.Z-rc.N. Branches, commits, and Go pseudo-versions are rejected, and there is no run against Substrate main.
  • The Substrate checkout is clean and at that tag. It still supplies the manifests and ate-setup, so they must match the images.
This skill’s instructions are not fully loaded. Continue to read all inherited rules and required context.

Files of this skill

This skill has no supporting files.

Browse all supporting files