[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M698Z8Q42MEPG1SNQGW6RV3N":3,"skill-same:01M698Z8Q42MEPG1SNQGW6RV3N":72},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":51,"repositoryHtmlUrl":52,"repositoryHomepageUrl":53,"ownerHtmlUrl":54,"ownerBlogUrl":55,"ownerDescription":56,"updatedAt":57,"install":58,"resources":71},"01M698Z8Q42MEPG1SNQGW6RV3N","substrate","Agent Substrate 依赖管理","How AX depends on Agent Substrate (modules, address contract, mocks, version bumps, E2E pin). Load when touching internal\u002Fsubstrate, bumping Substrate, or triaging make test-e2e.","AX 如何依赖 Agent Substrate（模块、地址契约、mocks、版本升级、E2E 版本锁定）。当触及 internal\u002Fsubstrate、升级 Substrate 版本或排查 make test-e2e 问题时加载。","google\u002Fax","google","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1342004?v=4","01M698VYEFDM0VJBZDYYJ2T83S","Google","01M698Z78P96HCHMAYBMMRNFE7",14695,"Apache-2.0",null,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fax\u002Fblob\u002Fmain\u002Fskills\u002Fsubstrate\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQ6TKQDF2K4KQS863Q79P4","开发参考","SCENARIO","使用场景",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师","PROFESSION","适用职业",[5,31,32,33,34,35,36,37,38,39,40,41,42],"modules","contract","e2e","load","pin","version","test","ax","how","make","when","mocks","2026-11-10 10:12:30",false,"---\nname: substrate\ndescription: >\n  How AX depends on Agent Substrate (modules, address contract, mocks, version bumps, E2E pin).\n  Load when touching internal\u002Fsubstrate, bumping Substrate, or triaging make test-e2e.\n---\n\n# Agent Substrate in AX\n\nAX schedules every `Task` as a sandboxed **actor** on\n[Agent Substrate](https:\u002F\u002Fgithub.com\u002Fagent-substrate\u002Fsubstrate). AX owns the\ndeclarative layer (Task\u002FWorkspace\u002FModel, reconciler, CLI); Substrate owns\nisolation, checkpoint\u002Frestore, worker placement and in-cluster routing.\nFacts below were verified against `main` on 2026-11-06 — re-check `go.mod`\nand `hack\u002Fsetup-e2e-kind.sh` if they look stale.\n\n## 1. Module map\n\n| Module | Pinned | Provides | Imported by |\n|---|---|---|---|\n| `go.ate.dev\u002Fsubstrate` | `v1.0.0` | Control API protos `api\u002Fateapi\u002Fv1` (atespaces, actor templates, actors, tags, snapshot fidelity, suspend\u002Fresume, egress rules) | `internal\u002Fsubstrate`, `internal\u002Fsubstrate\u002Fsubstratetest`, `internal\u002Fserver`, `internal\u002Fcontroller`, `internal\u002Fapivalidation`, `test\u002Fe2e`, `pkg\u002Fapis\u002Fv1alpha1` (its `.proto` files import `ateapi.proto`) |\n| `github.com\u002Fagent-substrate\u002Fenv` | `v0.0.11-0.20260912052224-4468a200b170` (pseudo-version) | Guest services served inside the sandbox (process exec + file system gRPC) and `proto\u002Fateenv\u002Fv1alpha` | `internal\u002Fguest`, `internal\u002Fmetadata` |\n\nThere is no `replace` directive for either module. Local hacking against a\nSubstrate checkout goes through `SUBSTRATE_DIR` in E2E (section 5).\n\n## 2. The Control API wrapper: `internal\u002Fsubstrate.Client`\n\nAll Control API traffic goes through this package. It encapsulates:\n\n- **Endpoint defaults** — `api.ate-system.svc.cluster.local:443`; authority\n  and TLS `ServerName` default to `api.ate-system.svc` when the target\n  contains that string.\n- **Auth** — bearer token from `SUBSTRATE_TOKEN_FILE` (in-cluster: projected SA\n  token with audience `api.ate-system.svc`, see `deploy\u002Fax-server.yaml`), CA\n  from `SUBSTRATE_CA_FILE`.\n- **Retry** — `IsTransientError` + `callWithRetry` (`retryOnCodes`) for `Unavailable`-class errors.\n- **Helpers** the reconcilers rely on — `EnsureAtespace`, `EnsureActorTemplate`,\n  `EnsureActorTemplateWithImage`, `BuildActorTemplate`, `EnsureActor`,\n  `EnsureActorFromTag`, `GetActorEgressPolicy`, `EnsureActorEgressPolicy`,\n  `CreateTag`, `GetTag`, `ListTags`, `DeleteTag`, `SuspendActor`, `ResumeActor`,\n  `DeleteActor`, `WorkerIP`, `ResourceLimits`.\n\n### Where a new Control API call lives today\n\n- `internal\u002Fsubstrate\u002Fclient.go` is the only non-test file that calls\n  `ateapipb.NewControlClient`; every existing RPC is a method on `*Client`,\n  wrapped in `callWithRetry` (`codes.Unavailable` plus optional codes such as `codes.Aborted`).\n- Each method has a table-driven case in `client_test.go` (`mockControlClient`).\n- Callers in `internal\u002Fcontroller` exercise it through `mockControlServer`;\n  `internal\u002Fserver` and `cmd\u002Fax` tests use `internal\u002Fsubstrate\u002Fsubstratetest`\n  (section 4).\n\n## 3. Address contract\n\n| Value | Occurrences |\n|---|---|\n| `api.ate-system.svc.cluster.local:443` + authority `api.ate-system.svc` | `cmd\u002Fax-server\u002Fmain.go` (`--substrate-endpoint` \u002F `--substrate-authority` flag defaults), `internal\u002Fsubstrate\u002Fclient.go` (3×), `deploy\u002Fax-server.yaml`, `test\u002Fe2e\u002Fmanifests\u002Fax-server.yaml`, `test\u002Fe2e\u002Fharness_test.go` |\n| `atenet-router.ate-system.svc[.cluster.local]` | `internal\u002Fcontroller\u002Freconciler.go` (`defaultRouterServerName`), `internal\u002Ftunnel\u002Frouter_tls.go` (`routerServerName`), `cmd\u002Fax\u002Fmain.go` (ssh port-forward path), `internal\u002Fguest\u002Fclient.go` (doc comment), `deploy\u002Fax-server.yaml`, `test\u002Fe2e\u002Fmanifests\u002Fax-server.yaml`, `docs\u002Fnetworking.md` |\n| namespace `ate-system` | all of the above + `test\u002Fe2e\u002Fharness_test.go` (`ateSystemNamespace`), `test\u002Fe2e\u002Fmanifests\u002Fcredential-policy.yaml` |\n| pod labels `ate.dev\u002Fworker-pool` (worker pods) and `app: atenet-egress` (egress gateway) | the `ax-server` NetworkPolicy in `deploy\u002Fax-server.yaml` and `test\u002Fe2e\u002Fmanifests\u002Fax-server.yaml`, which keeps both away from ax-server |\n| `opentelemetry-collector.otel-system.svc:4317` (the collector Substrate's kind overlay deploys, `manifests\u002Fate-install\u002Fkind\u002Fate-otel-config.yaml` in Substrate) | `test\u002Fe2e\u002Fmanifests\u002Fax-server.yaml` (`ax-otel-config` ConfigMap). An unreachable address does not fail E2E; ax-server only logs OTLP export errors |\n\nWhy it matters: tasks never get a Service\u002FIngress. Every request to a task is\nproxied by the **atenet router**, which picks the target from the\n`ate-target-actor` header and resumes a suspended actor on demand\n(`docs\u002Fnetworking.md`). `ax ssh` port-forwards to `svc\u002Fatenet-router` on 443\n(mTLS) and falls back to 80.\n\n## 4. Testing against Substrate\n\n### Unit tests: in-process mock, no cluster\n\n```go\ntype mockControlServer struct {\n    ateapipb.UnimplementedControlServer\n    \u002F\u002F record calls \u002F inject failures here\n}\ngrpcServer := grpc.NewServer()\nateapipb.RegisterControlServer(grpcServer, mockSrv)\n\u002F\u002F serve on a listener, point substrate.NewClient at it\n```\n\nCanonical examples: `internal\u002Fcontroller\u002Freconciler_test.go` (reconciler state\ntransitions; the largest test file in the repo). `internal\u002Fserver\u002Fserver_test.go`\nand `cmd\u002Fax\u002Fmain_test.go` run a real `TaskReconciler` against\n`internal\u002Fsubstrate\u002Fsubstratetest`, an in-memory fake of the same API (atespaces,\nactor templates, actors, and tags).\n`internal\u002Fsubstrate\u002Fclient_test.go` uses a client-side `mockControlClient`\ninstead. No mocking library is in `go.mod`.\n\n### Substrate behaviour the code already depends on\n\n- Actor template images must be digest-pinned (`@sha256:…`); a tag-only\n  `spec.profile.image` fails at ActorTemplate creation with reason\n  `TemplateCreationFailed` (`docs\u002Fmanifests.md`). `make images` writes\n  `bin\u002Fax-server.digest` \u002F `bin\u002Fax-task-runner.digest` for this reason.\n- After `ResumeActor` the actor may be on a different worker, so AX never\n  stores a worker IP: the reconciler uses the IP `ResumeActor` returns only for\n  its readiness probe (`internal\u002Fcontroller\u002Freconciler.go`), and `ax ssh`\n  connects through `atenet-router`.\n- Egress: an actor without an egress policy has no outbound access. For a\n  task that binds a Gateway, `bindGateway` (`internal\u002Fcontroller\u002Freconciler.go`)\n  asks Substrate whether the actor has a policy. If it has none, `bindGateway`\n  copies the Gateway's rules to the actor as its one policy (named `default`).\n  An actor that has a policy keeps it, so the rules are copied once and never\n  updated. `bindGateway` runs after the actor is suspended (`CreateTask`,\n  `SuspendTask`) and before it is resumed (`ResumeTask`). Substrate validates\n  the rules when they are copied. `bindGateway` fails with reason\n  `GatewayBindingFailed` when Substrate refuses them, or when the actor has no\n  policy and the Gateway cannot be loaded. `SuspendTask` and `ResumeTask` do\n  not fail on the Gateway themselves (`fetchGateway` in\n  `internal\u002Fserver\u002Fserver.go`), so a suspend always reaches `SuspendActor`. A\n  task without a Gateway makes no egress policy call at all.\n- `status.actorUid` is read live by `setActorStatus` in\n  `internal\u002Fserver\u002Fserver.go` and cleared by `storedStatus` before writes.\n  It changes when Substrate recreates the actor and is empty when the actor\n  is missing or cannot be read. `ax describe task` shows it as `Actor UID`.\n- Guest services (process + fs) are mounted by `internal\u002Fmetadata\u002Fserver.go`\n  only when `task.Spec.Debug` is true; `ax ssh` (`cmd\u002Fax\u002Fmain.go`) refuses to\n  connect otherwise.\n- Trust bundle: `BuildActorTemplate` mounts `egress-mitm.ate.dev` and\n  `system-roots.ate.dev` at `v1alpha1.EgressTrustBundlePath` for every task,\n  and the runner points the CA variables at it (`runner\u002Fenv.go`). A\n  Substrate install that lacks either bundle blocks actor startup.\n- Credential injection replaces a header only on requests that carry it. The\n  runner supplies a placeholder only for git: `GIT_ASKPASS` is\n  `\u002Fax\u002Fgit-askpass`, a link to the running program, and package `runner`\n  answers from `init` when a program that imports it is started under that\n  name (`runner\u002Fenv.go`). It sets no API key variable, because tools choose a\n  provider by which key is set: a task sets its own placeholders in\n  `spec.env`. A Gateway's spec is never passed into the sandbox.\n- Readiness: Substrate and the reconciler probe the runner on port 80\n  (`\u002Fhealthz`, `\u002Freadyz?check=workspace`, served by `internal\u002Fmetadata`);\n  `\u002Freadyz` is 503 until all workspaces are materialized (`docs\u002Fsandbox.md`).\n- Snapshot storage: Actor templates created by AX leave `SnapshotConfig.StorageLocation`\n  empty by default so Substrate uses its cluster-wide `--snapshot-location`. Specifying a custom\n  snapshot bucket (`snapshotsBucket` in `BuildActorTemplate`) can only be used when the\n  Substrate cluster has the `PerTemplateSnapshotLocation` preview feature gate enabled;\n  otherwise Substrate rejects template creation with\n  `actor_template.snapshot_config.storage_location: Forbidden`. Since v1.0.0 each path\n  segment may contain only `[A-Za-z0-9_-]` and no segment may be `atespaces`; AX passes\n  the value through unvalidated, so Substrate is the one that rejects it.\n\n## 5. E2E and the Substrate version pin\n\n`test\u002Fe2e` is compiled by `go test .\u002F...` but **self-skips** unless\n`AX_E2E=true` or `-args --e2e`. The real runs go through `make`:\n\n| Target | Substrate version | When |\n|---|---|---|\n| `make test-e2e` | exactly `go list -m -f '{{.Version}}' go.ate.dev\u002Fsubstrate` | PR CI (skipped when only `paths-ignore` files change, e.g. docs) and the nightly schedule (06:00 UTC) in `e2e.yml` |\n| `make test-e2e SUBSTRATE_REF=\u003Crelease tag>` | override | local, or `workflow_dispatch` input `substrate_ref` in `e2e.yml` |\n| `make e2e-setup` \u002F `e2e-run` \u002F `e2e-cleanup` | same as above | iterate without re-provisioning |\n\nE2E never builds Substrate. `hack\u002Fsetup-e2e-kind.sh` installs the release's\npublished images from `ghcr.io\u002Fagent-substrate\u002Fsubstrate\u002F\u003Cimage>:\u003Ctag>`\n(`SUBSTRATE_IMAGE_REPO` to use a mirror) via `ATE_IMAGE_REPO`\u002F`ATE_IMAGE_TAG`,\nand pins the WorkerPool's worker image by digest. It exits early unless:\n\n- `SUBSTRATE_REF` is a release tag, `vX.Y.Z` or `vX.Y.Z-rc.N`. Branches,\n  commits, and Go pseudo-versions are rejected, and there is no run against\n  Substrate `main`.\n- The Substrate checkout is clean and at that tag. It still supplies the\n  manifests and `ate-setup`, so they must match the images.\n- That release's `ate-setup` supports `--image-repo`, and every image the\n  install uses exists under the tag.\n\nThe install enables the `k8s.io` credential provider. For\n`TestE2E_GatewayEgress` the script then:\n\n- Applies `test\u002Fe2e\u002Fmanifests\u002Fcredential-policy.yaml`, which lets tasks in\n  atespace `default` use Secrets labeled `ax.io\u002Fcredential: \"true\"` in the AX\n  namespace, and restarts the provider, which reads its policy only at startup.\n- Runs Substrate's `hack\u002Fsetup-e2e-egress-tls-kind.sh`, which makes the egress\n  gateway trust Substrate's service-DNS CA.\n- Deploys the echo server (`test\u002Fe2e\u002Fmanifests\u002Fecho.yaml`), whose certificate\n  comes from that CA.\n\nUseful env (full list in `test\u002Fe2e\u002FREADME.md`): `SUBSTRATE_DIR` (local\ncheckout; a detached worktree is created under `.tmp\u002F` if HEAD ≠ ref),\n`SUBSTRATE_REPO`, `E2E_ARGS='-test.run TestE2E_ModelCRUD'`.\n\n## 6. Bumping Substrate\n\nWhat the repo mechanically requires when `go.ate.dev\u002Fsubstrate` or\n`github.com\u002Fagent-substrate\u002Fenv` changes in `go.mod`:\n\n```bash\ngo get go.ate.dev\u002Fsubstrate@vX.Y.Z            # and\u002For github.com\u002Fagent-substrate\u002Fenv@\u003Csha>\ngo mod tidy                                    # CI diffs go.mod\u002Fgo.sum\nmake generate                                  # buf reads ateapi.proto from the new version\ngo build .\u002F... && go test .\u002F...                # unit tests compile against the new ateapipb\nmake test-e2e                                  # hack\u002Fsetup-e2e-kind.sh installs the go.mod version\n```\n\n`go.ate.dev\u002Fsubstrate` must stay on a release tag: E2E installs that\nrelease's published images, and a pseudo-version fails E2E setup.\n\n`Gateway.spec.egress` is Substrate's `EgressRule`, so a bump can change what\nusers may write in a Gateway. Diff the egress messages in\n`api\u002Fateapi\u002Fv1\u002Fateapi.proto` between the two versions. If the new version adds\na rule kind besides `http`, `https`, and `tlsPassthrough`, `ValidateGateway`\n(`internal\u002Fapivalidation\u002Fgateway.go`) rejects rules of that kind until its\nchecks cover it. `docs\u002Fmanifests.md` links to Substrate's egress credential\ninjection guide at the pinned version.\n","# Agent Substrate in AX\n\nAX schedules every `Task` as a sandboxed **actor** on\n[Agent Substrate](https:\u002F\u002Fgithub.com\u002Fagent-substrate\u002Fsubstrate). AX owns the\ndeclarative layer (Task\u002FWorkspace\u002FModel, reconciler, CLI); Substrate owns\nisolation, checkpoint\u002Frestore, worker placement and in-cluster routing.\nFacts below were verified against `main` on 2026-11-06 — re-check `go.mod`\nand `hack\u002Fsetup-e2e-kind.sh` if they look stale.\n\n## 1. Module map\n\n| Module | Pinned | Provides | Imported by |\n|---|---|---|---|\n| `go.ate.dev\u002Fsubstrate` | `v1.0.0` | Control API protos `api\u002Fateapi\u002Fv1` (atespaces, actor templates, actors, tags, snapshot fidelity, suspend\u002Fresume, egress rules) | `internal\u002Fsubstrate`, `internal\u002Fsubstrate\u002Fsubstratetest`, `internal\u002Fserver`, `internal\u002Fcontroller`, `internal\u002Fapivalidation`, `test\u002Fe2e`, `pkg\u002Fapis\u002Fv1alpha1` (its `.proto` files import `ateapi.proto`) |\n| `github.com\u002Fagent-substrate\u002Fenv` | `v0.0.11-0.20260912052224-4468a200b170` (pseudo-version) | Guest services served inside the sandbox (process exec + file system gRPC) and `proto\u002Fateenv\u002Fv1alpha` | `internal\u002Fguest`, `internal\u002Fmetadata` |\n\nThere is no `replace` directive for either module. Local hacking against a\nSubstrate checkout goes through `SUBSTRATE_DIR` in E2E (section 5).\n\n## 2. The Control API wrapper: `internal\u002Fsubstrate.Client`\n\nAll Control API traffic goes through this package. It encapsulates:\n\n- **Endpoint defaults** — `api.ate-system.svc.cluster.local:443`; authority\n  and TLS `ServerName` default to `api.ate-system.svc` when the target\n  contains that string.\n- **Auth** — bearer token from `SUBSTRATE_TOKEN_FILE` (in-cluster: projected SA\n  token with audience `api.ate-system.svc`, see `deploy\u002Fax-server.yaml`), CA\n  from `SUBSTRATE_CA_FILE`.\n- **Retry** — `IsTransientError` + `callWithRetry` (`retryOnCodes`) for `Unavailable`-class errors.\n- **Helpers** the reconcilers rely on — `EnsureAtespace`, `EnsureActorTemplate`,\n  `EnsureActorTemplateWithImage`, `BuildActorTemplate`, `EnsureActor`,\n  `EnsureActorFromTag`, `GetActorEgressPolicy`, `EnsureActorEgressPolicy`,\n  `CreateTag`, `GetTag`, `ListTags`, `DeleteTag`, `SuspendActor`, `ResumeActor`,\n  `DeleteActor`, `WorkerIP`, `ResourceLimits`.\n\n### Where a new Control API call lives today\n\n- `internal\u002Fsubstrate\u002Fclient.go` is the only non-test file that calls\n  `ateapipb.NewControlClient`; every existing RPC is a method on `*Client`,\n  wrapped in `callWithRetry` (`codes.Unavailable` plus optional codes such as `codes.Aborted`).\n- Each method has a table-driven case in `client_test.go` (`mockControlClient`).\n- Callers in `internal\u002Fcontroller` exercise it through `mockControlServer`;\n  `internal\u002Fserver` and `cmd\u002Fax` tests use `internal\u002Fsubstrate\u002Fsubstratetest`\n  (section 4).\n\n## 3. Address contract\n\n| Value | Occurrences |\n|---|---|\n| `api.ate-system.svc.cluster.local:443` + authority `api.ate-system.svc` | `cmd\u002Fax-server\u002Fmain.go` (`--substrate-endpoint` \u002F `--substrate-authority` flag defaults), `internal\u002Fsubstrate\u002Fclient.go` (3×), `deploy\u002Fax-server.yaml`, `test\u002Fe2e\u002Fmanifests\u002Fax-server.yaml`, `test\u002Fe2e\u002Fharness_test.go` |\n| `atenet-router.ate-system.svc[.cluster.local]` | `internal\u002Fcontroller\u002Freconciler.go` (`defaultRouterServerName`), `internal\u002Ftunnel\u002Frouter_tls.go` (`routerServerName`), `cmd\u002Fax\u002Fmain.go` (ssh port-forward path), `internal\u002Fguest\u002Fclient.go` (doc comment), `deploy\u002Fax-server.yaml`, `test\u002Fe2e\u002Fmanifests\u002Fax-server.yaml`, `docs\u002Fnetworking.md` |\n| namespace `ate-system` | all of the above + `test\u002Fe2e\u002Fharness_test.go` (`ateSystemNamespace`), `test\u002Fe2e\u002Fmanifests\u002Fcredential-policy.yaml` |\n| pod labels `ate.dev\u002Fworker-pool` (worker pods) and `app: atenet-egress` (egress gateway) | the `ax-server` NetworkPolicy in `deploy\u002Fax-server.yaml` and `test\u002Fe2e\u002Fmanifests\u002Fax-server.yaml`, which keeps both away from ax-server |\n| `opentelemetry-collector.otel-system.svc:4317` (the collector Substrate's kind overlay deploys, `manifests\u002Fate-install\u002Fkind\u002Fate-otel-config.yaml` in Substrate) | `test\u002Fe2e\u002Fmanifests\u002Fax-server.yaml` (`ax-otel-config` ConfigMap). An unreachable address does not fail E2E; ax-server only logs OTLP export errors |\n\nWhy it matters: tasks never get a Service\u002FIngress. Every request to a task is\nproxied by the **atenet router**, which picks the target from the\n`ate-target-actor` header and resumes a suspended actor on demand\n(`docs\u002Fnetworking.md`). `ax ssh` port-forwards to `svc\u002Fatenet-router` on 443\n(mTLS) and falls back to 80.\n\n## 4. Testing against Substrate\n\n### Unit tests: in-process mock, no cluster\n\n```go\ntype mockControlServer struct {\n    ateapipb.UnimplementedControlServer\n    \u002F\u002F record calls \u002F inject failures here\n}\ngrpcServer := grpc.NewServer()\nateapipb.RegisterControlServer(grpcServer, mockSrv)\n\u002F\u002F serve on a listener, point substrate.NewClient at it\n```\n\nCanonical examples: `internal\u002Fcontroller\u002Freconciler_test.go` (reconciler state\ntransitions; the largest test file in the repo). `internal\u002Fserver\u002Fserver_test.go`\nand `cmd\u002Fax\u002Fmain_test.go` run a real `TaskReconciler` against\n`internal\u002Fsubstrate\u002Fsubstratetest`, an in-memory fake of the same API (atespaces,\nactor templates, actors, and tags).\n`internal\u002Fsubstrate\u002Fclient_test.go` uses a client-side `mockControlClient`\ninstead. No mocking library is in `go.mod`.\n\n### Substrate behaviour the code already depends on\n\n- Actor template images must be digest-pinned (`@sha256:…`); a tag-only\n  `spec.profile.image` fails at ActorTemplate creation with reason\n  `TemplateCreationFailed` (`docs\u002Fmanifests.md`). `make images` writes\n  `bin\u002Fax-server.digest` \u002F `bin\u002Fax-task-runner.digest` for this reason.\n- After `ResumeActor` the actor may be on a different worker, so AX never\n  stores a worker IP: the reconciler uses the IP `ResumeActor` returns only for\n  its readiness probe (`internal\u002Fcontroller\u002Freconciler.go`), and `ax ssh`\n  connects through `atenet-router`.\n- Egress: an actor without an egress policy has no outbound access. For a\n  task that binds a Gateway, `bindGateway` (`internal\u002Fcontroller\u002Freconciler.go`)\n  asks Substrate whether the actor has a policy. If it has none, `bindGateway`\n  copies the Gateway's rules to the actor as its one policy (named `default`).\n  An actor that has a policy keeps it, so the rules are copied once and never\n  updated. `bindGateway` runs after the actor is suspended (`CreateTask`,\n  `SuspendTask`) and before it is resumed (`ResumeTask`). Substrate validates\n  the rules when they are copied. `bindGateway` fails with reason\n  `GatewayBindingFailed` when Substrate refuses them, or when the actor has no\n  policy and the Gateway cannot be loaded. `SuspendTask` and `ResumeTask` do\n  not fail on the Gateway themselves (`fetchGateway` in\n  `internal\u002Fserver\u002Fserver.go`), so a suspend always reaches `SuspendActor`. A\n  task without a Gateway makes no egress policy call at all.\n- `status.actorUid` is read live by `setActorStatus` in\n  `internal\u002Fserver\u002Fserver.go` and cleared by `storedStatus` before writes.\n  It changes when Substrate recreates the actor and is empty when the actor\n  is missing or cannot be read. `ax describe task` shows it as `Actor UID`.\n- Guest services (process + fs) are mounted by `internal\u002Fmetadata\u002Fserver.go`\n  only when `task.Spec.Debug` is true; `ax ssh` (`cmd\u002Fax\u002Fmain.go`) refuses to\n  connect otherwise.\n- Trust bundle: `BuildActorTemplate` mounts `egress-mitm.ate.dev` and\n  `system-roots.ate.dev` at `v1alpha1.EgressTrustBundlePath` for every task,\n  and the runner points the CA variables at it (`runner\u002Fenv.go`). A\n  Substrate install that lacks either bundle blocks actor startup.\n- Credential injection replaces a header only on requests that carry it. The\n  runner supplies a placeholder only for git: `GIT_ASKPASS` is\n  `\u002Fax\u002Fgit-askpass`, a link to the running program, and package `runner`\n  answers from `init` when a program that imports it is started under that\n  name (`runner\u002Fenv.go`). It sets no API key variable, because tools choose a\n  provider by which key is set: a task sets its own placeholders in\n  `spec.env`. A Gateway's spec is never passed into the sandbox.\n- Readiness: Substrate and the reconciler probe the runner on port 80\n  (`\u002Fhealthz`, `\u002Freadyz?check=workspace`, served by `internal\u002Fmetadata`);\n  `\u002Freadyz` is 503 until all workspaces are materialized (`docs\u002Fsandbox.md`).\n- Snapshot storage: Actor templates created by AX leave `SnapshotConfig.StorageLocation`\n  empty by default so Substrate uses its cluster-wide `--snapshot-location`. Specifying a custom\n  snapshot bucket (`snapshotsBucket` in `BuildActorTemplate`) can only be used when the\n  Substrate cluster has the `PerTemplateSnapshotLocation` preview feature gate enabled;\n  otherwise Substrate rejects template creation with\n  `actor_template.snapshot_config.storage_location: Forbidden`. Since v1.0.0 each path\n  segment may contain only `[A-Za-z0-9_-]` and no segment may be `atespaces`; AX passes\n  the value through unvalidated, so Substrate is the one that rejects it.\n\n## 5. E2E and the Substrate version pin\n\n`test\u002Fe2e` is compiled by `go test .\u002F...` but **self-skips** unless\n`AX_E2E=true` or `-args --e2e`. The real runs go through `make`:\n\n| Target | Substrate version | When |\n|---|---|---|\n| `make test-e2e` | exactly `go list -m -f '{{.Version}}' go.ate.dev\u002Fsubstrate` | PR CI (skipped when only `paths-ignore` files change, e.g. docs) and the nightly schedule (06:00 UTC) in `e2e.yml` |\n| `make test-e2e SUBSTRATE_REF=\u003Crelease tag>` | override | local, or `workflow_dispatch` input `substrate_ref` in `e2e.yml` |\n| `make e2e-setup` \u002F `e2e-run` \u002F `e2e-cleanup` | same as above | iterate without re-provisioning |\n\nE2E never builds Substrate. `hack\u002Fsetup-e2e-kind.sh` installs the release's\npublished images from `ghcr.io\u002Fagent-substrate\u002Fsubstrate\u002F\u003Cimage>:\u003Ctag>`\n(`SUBSTRATE_IMAGE_REPO` to use a mirror) via `ATE_IMAGE_REPO`\u002F`ATE_IMAGE_TAG`,\nand pins the WorkerPool's worker image by digest. It exits early unless:\n\n- `SUBSTRATE_REF` is a release tag, `vX.Y.Z` or `vX.Y.Z-rc.N`. Branches,\n  commits, and Go pseudo-versions are rejected, and there is no run against\n  Substrate `main`.\n- The Substrate checkout is clean and at that tag. It still supplies the\n  manifests and `ate-setup`, so they must match the images.\n- That release's `ate-setup` supports `--image-repo`, and every image the\n  install uses exists under the tag.\n\nThe install enables the `k8s.io` credential provider. For\n`TestE2E_GatewayEgress` the script then:\n\n- Applies `test\u002Fe2e\u002Fmanifests\u002Fcredential-policy.yaml`, which lets tasks in\n  atespace `default` use Secrets labeled `ax.io\u002Fcredential: \"true\"` in the AX\n  namespace, and restarts the provider, which reads its policy only at startup.\n- Runs Substrate's `hack\u002Fsetup-e2e-egress-tls-kind.sh`, which makes the egress\n  gateway trust Substrate's service-DNS CA.\n- Deploys the echo server (`test\u002Fe2e\u002Fmanifests\u002Fecho.yaml`), whose certificate\n  comes from that CA.\n\nUseful env (full list in `test\u002Fe2e\u002FREADME.md`): `SUBSTRATE_DIR` (local\ncheckout; a detached worktree is created under `.tmp\u002F` if HEAD ≠ ref),\n`SUBSTRATE_REPO`, `E2E_ARGS='-test.run TestE2E_ModelCRUD'`.\n\n## 6. Bumping Substrate\n\nWhat the repo mechanically requires when `go.ate.dev\u002Fsubstrate` or\n`github.com\u002Fagent-substrate\u002Fenv` changes in `go.mod`:\n\n```bash\ngo get go.ate.dev\u002Fsubstrate@vX.Y.Z            # and\u002For github.com\u002Fagent-substrate\u002Fenv@\u003Csha>\ngo mod tidy                                    # CI diffs go.mod\u002Fgo.sum\nmake generate                                  # buf reads ateapi.proto from the new version\ngo build .\u002F... && go test .\u002F...                # unit tests compile against the new ateapipb\nmake test-e2e                                  # hack\u002Fsetup-e2e-kind.sh installs the go.mod version\n```\n\n`go.ate.dev\u002Fsubstrate` must stay on a release tag: E2E installs that\nrelease's published images, and a pseudo-version fails E2E setup.\n\n`Gateway.spec.egress` is Substrate's `EgressRule`, so a bump can change what\nusers may write in a Gateway. Diff the egress messages in\n`api\u002Fateapi\u002Fv1\u002Fateapi.proto` between the two versions. If the new version adds\na rule kind besides `http`, `https`, and `tlsPassthrough`, `ValidateGateway`\n(`internal\u002Fapivalidation\u002Fgateway.go`) rejects rules of that kind until its\nchecks cover it. `docs\u002Fmanifests.md` links to Substrate's egress credential\ninjection guide at the pinned version.\n",{"name":5,"description":7},"main","68877621f9e2dc8fe5b82d397b1e46a49f571b9b","skills\u002Fsubstrate",793,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fax","https:\u002F\u002Fagentexecutor.io","https:\u002F\u002Fgithub.com\u002Fgoogle","https:\u002F\u002Fopensource.google\u002F","Google ❤️ Open Source","2026-11-15 01:49:41",{"source":9,"skillName":5,"commands":59,"prompt":69,"zipAvailable":70},[60,63,66],{"tool":61,"command":62},"npx","npx skills add google\u002Fax --skill substrate",{"tool":64,"command":65},"bunx","bunx skills add google\u002Fax --skill substrate",{"tool":67,"command":68},"pnpm","pnpm dlx skills add google\u002Fax --skill substrate","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fax\u002Fblob\u002Fmain\u002Fskills\u002Fsubstrate\u002FSKILL.md",true,[],[73],{"skillNo":74,"name":75,"nameZh":76,"description":77,"descriptionZh":78,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":79,"categories":80,"keywords":85,"publishedAt":43},"01M698ZA33DW1Q5VCBYA8SXE94","sync-contract","AGENTS.md 与技能文档同步","End-of-change pass that brings AGENTS.md and skills\u002F back in step with the code. Load after any code change, before declaring done; it is the last step of the Definition of done.","变更收尾检查，使 AGENTS.md 和 skills\u002F 与代码保持同步。在任何代码变更之后、宣告完成之前加载使用；它是“完成定义”（Definition of done）的最后一步。","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fax\u002Fblob\u002Fmain\u002Fskills\u002Fsync-contract\u002FSKILL.md",[81,82],{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},{"categoryNo":83,"categoryName":84,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BR5V701HCN066VEP7H4812","代码仓库协作管理",[86,87,32,88,89,90,91,92,93,94,95,96,34,97],"sync contract","sync","definition of done","change","code","back","done","end","it","with","last","definition"]