Skip to content

feat(api): add egress, secret-backed env vars, and SecretStore to the API - #499

Closed
MushuEE wants to merge 1 commit into
mainfrom
creds/1-api
Closed

MushuEE wants to merge 1 commit into
mainfrom
creds/1-api

Conversation

@MushuEE

@MushuEE MushuEE commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

First step for #475: the API for egress hosts and secret-backed env vars, with no behavior change yet. Splitting this up so the API shape can be reviewed on its own before anything acts on it.

What's in here

TaskSpec.egress.hosts: the outbound hosts a task may reach (TLS on 443, *. prefix for subdomains).

EnvVar.secretRef: an env var backed by a secret instead of a literal value. The task gets a placeholder, and the secret is meant to be injected into outbound requests by Substrate's egress gateway. inject mirrors Substrate's CredentialHeader (header + prefix), plus the host it applies to:

env:
  - name: STRIPE_API_KEY
    secretRef:
      name: stripe
      key: api-key
      # store: default
      inject:
        host: api.stripe.com
        header: Authorization
        prefix: "Bearer "

SecretStore: a new atespace-scoped resource for where an atespace's secrets live, so tasks just name a secret and the atespace decides the backend. v1 has a Kubernetes Secrets backend only (spec.kubernetes.namespace, defaulting to the atespace name). Get/List/Update/Delete RPCs are defined.

Validation covers hostnames, header names, mutually exclusive value/secretRef, URI-safe secret names and keys, and the same header injected twice for one host.

Nothing acts on it yet

  • CreateTask returns Unimplemented for tasks that set egress or secretRef, so nothing runs without the network or credentials it asked for.
  • The SecretStore RPCs are unimplemented.

Coming next

The rest of the stack is tracked on #475:

  1. This PR: API
  2. SecretStore storage, server CRUD, CLI, and the Substrate credential provider setup docs
  3. Actor egress policies from egress.hosts plus the egress trust bundle (Tasks have no network access on current Agent Substrate because ax never creates an egress policy #449)
  4. Credential injection for secretRef

Notes

  • ax_grpc.pb.go was regenerated with protoc 5.28.2 to match ax.pb.go, so its header version line changes.
  • go vet ./... and go test ./... pass.

@mayawang

Copy link
Copy Markdown
Collaborator

FYI @MushuEE, @bdubs00 has a working branch for Task egress on #449 (spec.egress with per-protocol rules, hostnames and ports): #449 (comment). Worth comparing with the egress shape here, so we land one API.

@mayawang

Copy link
Copy Markdown
Collaborator

FYI @MushuEE, Jaana's direction on #501 applies here too: AX should express Substrate networking policies as YAML and stay 100% compatible with them rather than define its own shape. Probably worth checking both this and the #449 branch against Substrate's EgressPolicy schema.

bdubs00 added a commit to bdubs00/ax that referenced this pull request Oct 22, 2026
spec.egress.hosts replaces spec.egress.rules, the shape that google#499
proposes for the API: a list of DNS names, each with an optional scheme
and port. A name alone is TLS on port 443 that the egress gateway
forwards without decryption, http:// is cleartext HTTP on port 80,
https:// is HTTPS on port 443 that the gateway intercepts, and a port
after the name replaces the default. ParseEgressHost reads one entry.
The API server validates every entry at apply time and refuses two
entries that name the same host and port, which Substrate refuses in
one policy. The controller writes one rule per host.

The scheme and the port matter for a task that reaches services inside
the cluster, such as a model proxy or a message bus on port 8080 over
cleartext HTTP, which a hosts-only list over TLS on 443 cannot express.

Refs google#449, google#499
@bdubs00

bdubs00 commented Oct 23, 2026

Copy link
Copy Markdown

FYI @MushuEE, Jaana's direction on #501 applies here too: AX should express Substrate networking policies as YAML and stay 100% compatible with them rather than define its own shape. Probably worth checking both this and the #449 branch against Substrate's EgressPolicy schema.

Hey Maya! I lined the branch up with #499 (main...bdubs00:ax:feat/task-egress-policy)- spec.egress is now a hosts list, and the controller creates the actor’s egress policy right after EnsureActor. To reach in-cluster services over cleartext HTTP or non-443 ports, entries can also take http://, https://, or :port. Each form maps directly to a Substrate rule (TLSPassthroughRule, HTTPRule, HTTPSRule), so per Jaana’s note on #501 it stays within the EgressPolicy schema rather than defining its own shape. Everything else behaves as before, and make test passes.

yangbooom added a commit to yangbooom/ax that referenced this pull request Oct 27, 2026
Agent Substrate denies all sandbox egress by default, so a task that
calls a model API has to say which hosts it needs. spec.egress.hosts
lists lowercase DNS names, optionally with a leading "*." label, or
"*"; apply-time validation also rejects duplicates, numeric top-level
labels and more than 256 hosts, all of which Substrate would refuse
later on a task that cannot be edited. The message and field name match
upstream's draft google#499; the field number is 8 because this fork
already uses 7 for agent. The runner's unknown-field test now uses a
field that is still unknown.
… API

API only. TaskSpec gains egress.hosts (field 8), and EnvVar gains secretRef:
a secret in one of the atespace's SecretStores plus where Agent Substrate's
egress gateway should inject it (host, header, prefix, matching Substrate's
CredentialHeader). SecretStore is a new atespace-scoped resource for where
secrets live, with a Kubernetes Secrets backend.

Nothing acts on these yet: CreateTask rejects tasks that use egress or
secretRef with Unimplemented, and the SecretStore RPCs are unimplemented.
Follow-up changes add the store, egress policies (#449), and credential
injection.

The runner's unknown-field test used "egress" as its example of an unknown
field; it now uses a name that stays unknown.

Part of #475.
@MushuEE

MushuEE commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Closing in favor of other changes from branch drift

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants