Skip to content

ate-api-server: Create one unified configuration file - #2021

Merged
Taahir Ahmed (ahmedtd) merged 3 commits into
agent-substrate:mainfrom
ahmedtd:separate-certs-2
Oct 15, 2026
Merged

Taahir Ahmed (ahmedtd) merged 3 commits into
agent-substrate:mainfrom
ahmedtd:separate-certs-2

Conversation

@ahmedtd

@ahmedtd Taahir Ahmed (ahmedtd) commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Initially, it hosts nothing but logging config.

A follow-on PR will move the authentication config into the unified config.

@mayawang Maya Wang (mayawang) added kind/feature An enhancement / feature request or implementation area/api-machinery labels Sep 30, 2026
Comment thread pkg/proto/ateconfigpb/apiconfig.pb.go Outdated
type APIConfig struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Authentication configuration for users calling the Substrate APIs.
Authentication *APIClientAuthentication `protobuf:"bytes,1,opt,name=authentication,proto3" json:"authentication,omitempty"`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this synced to the proto definition? I only see logging in the proto.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synced


config := &ateconfigpb.APIConfig{}
switch ext := filepath.Ext(l.configFile); ext {
case "pb":

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need support for binary encoding? Also, I don't think people are familiar with textproto format in general. Why not just stick to one format? protojson?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protojson can't have comments, which seem important for a config file unless you are always completely generating it. Textproto seems to fit the bill --- it can have comments, it's a little more compact than JSON, while not having all the scary misfeatures of YAML (references, anchors).

Binary format: Similar to Envoy, I was supposing that you would be able to use different encodings of the same protobuf data model to actually do your config programming. I don't think this is actually that important, but if we don't support multiple formats then I think textproto should be the format.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So keep just textproto? I dont see a use case for binary encoding really. At least for now.

Comment thread cmd/ateapi/main.go Resolved

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the file location. Are we sure we want this file here? Do we expect consumers of the substrate Go module to import this proto? It sounds like we don't? Should we move it under cmd/ateapi/internal/ ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume that external projects would be using these protos? (For example, the setup-gke scripts when they are fully broken out to another repo).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we keep it internal until the time comes for people to consume? We can move it and it should all work. Nobody will check the package in serialized representations (e.g. textproto).

Christian Todie (todie) pushed a commit to unsigned-gg/substrate that referenced this pull request Oct 2, 2026
…bstrate#1965)

Working on agent-substrate#1563

Fixes agent-substrate#1697,
agent-substrate#1701

## Summary

Adds `AccessPolicy` singleton subresources for the Global
(`global:root`) and `Atespace` scopes, stored in PostgreSQL and enforced
through OpenFGA.

### Changes
- **API (`Control` service)**
- Global: `CreateGlobalAccessPolicy`, `GetGlobalAccessPolicy`,
`UpdateGlobalAccessPolicy` (no Delete; an update with empty bindings
clears all grants).
- Atespace: `CreateAtespaceAccessPolicy`, `GetAtespaceAccessPolicy`,
`UpdateAtespaceAccessPolicy`, `DeleteAtespaceAccessPolicy`.
  - `Binding.members` has set semantics.
- **Always-wired authz**: the OpenFGA server, `Authorizer` and
`PolicyManager` are always created. `--experimental-enable-authz` only
controls whether the interceptor enforces checks on regular RPCs. Policy
tuples therefore stay in sync with the store in every mode, and deleting
an atespace always removes its tuples.
- **Governance RPCs are always enforced**: AccessPolicy RPCs are marked
`alwaysEnforce` in the permission registry and are checked even when
enforcement is off, so nobody can grant themselves access before it is
turned on. A test fails if an AccessPolicy RPC is added without that
marker.
- **Bootstrap owners**: `--authz-bootstrap-owners` lists
server-configured owners (required when enforcing). They are never
written to the store: `Authorizer.Check` adds a contextual `owner
global:root` tuple for the calling user only, so access follows the
server config and is dropped on restart without them. A bootstrap owner
creates the global policy.
- **Storage**: migration `000003` adds `global_access_policy` and
`atespace_access_policies`. Deleting an atespace cascades to its policy
row and removes its OpenFGA tuples in the same transaction.
- **Consistency**: `PolicyManager` takes an explicit `pgx.Tx`, locks the
metadata row (`FOR UPDATE`) and reconciles OpenFGA tuples in the same
transaction. Optimistic concurrency via `uid` / `version`.
- **Hardening**: members with control characters are rejected, as are
blank, `*`, or control-character bootstrap owner entries; non-canonical
OpenFGA error codes are mapped to `Internal`.

### Testing
- Interceptor tests for both modes: with enforcement off, regular RPCs
skip the check while governance RPCs are still checked.
- Functional CRUD tests for both AccessPolicy scopes
(`functionaltest/access_policy_test.go`).
- PostgreSQL test that a policy update and its tuple writes commit or
roll back together, including under concurrent updates.
- Governance tests: creating the policy as a bootstrap owner, a
bootstrap owner also stored as owner, and a restart without a bootstrap
owner.

### Notes
- ateapi now needs OpenFGA available at startup even with enforcement
off, and atespace deletes always write OpenFGA tuples.
- TODO: move the authz settings into the hot-reloadable config proto
(agent-substrate#2021) once it lands.
@ahmedtd
Taahir Ahmed (ahmedtd) force-pushed the separate-certs-2 branch 2 times, most recently from 71694c8 to beff0c3 Compare October 8, 2026 22:45
Comment thread pkg/proto/ateconfigpb/apiconfig.proto Resolved
Comment thread cmd/ateapi/main.go Resolved
Comment thread cmd/ate-setup/internal/steps/create.go Outdated
const defaultAPILogLevel = "info"

// CreateAPIConfig writes the ate-api-server config file. ate-api-server
// re-reads it while running, so a changed log level takes effect without a

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this change yet in main.go. It still only reads the config file once at startup right? May be change this to a TODO.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I used to have this functionality, but took it out. Updated the comment.

Comment thread cmd/ateapi/main.go Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable fix needed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ahmedtd
Taahir Ahmed (ahmedtd) added this pull request to the merge queue Oct 15, 2026
Merged via the queue into agent-substrate:main with commit ac296df Oct 15, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api-machinery kind/feature An enhancement / feature request or implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants