Skip to content

Configure initial egress policies for actors and goldens - #2159

Open
Eitan Yarmush (EItanya) wants to merge 9 commits into
agent-substrate:mainfrom
kagent-dev:feat/template-default-egress-upstream
Open

Eitan Yarmush (EItanya) wants to merge 9 commits into
agent-substrate:mainfrom
kagent-dev:feat/template-default-egress-upstream

Conversation

@EItanya

@EItanya Eitan Yarmush (EItanya) commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Golden initialization can need network access that runtime actors should not inherit. This adds ActorTemplate.goldenEgressPolicy and optional CreateActorRequest.initial_egress_policy. The template reconciler explicitly passes the golden policy through the public CreateActor API, so actor creation does not infer golden intent from the atespace.

The template field requires the GoldenEgressPolicy preview gate on the server and client opt-in through kubectl ate --preview or the Ate-Preview-Allowed: true header. Disabling the gate blocks new templates that set the field; existing templates keep their configuration and can still finish golden initialization or be deleted. CreateActorRequest.initial_egress_policy does not require preview opt-in.

The actor and its initial policy are created in one transaction. Supplying a policy requires permission to create an actor egress policy in addition to the existing actor and template permissions. The RPC accepts a full EgressPolicy, with metadata.name: default and metadata.atespace matching the actor; the server assigns UID, version, and timestamps. The template keeps a metadata-free EgressPolicyTemplate wrapper, which the reconciler turns into a full policy for the RPC. Both require at least one rule and use the existing rule defaults and validation. Omitting the request field creates no policy, including when restoring from a golden snapshot or tag. The resulting policy is managed through the existing Actor egress policy RPCs.

Related to #1324. Motivation and API rationale: #2358.

  • Tests pass — affected API suites, the full functional suite, and tools/apitool pass with -race; all repository verifiers pass. The root-module race run hit a CA reload failure in fake-atelet and color-output failures in internal/e2e, both reproduced on upstream/main. The color tests pass with NO_COLOR unset. CI is rerunning after adding the required request-shape exemption for atomic actor/policy creation.
  • Appropriate changes to documentation are included in the PR

Comment thread pkg/proto/ateapipb/ateapi.proto Outdated
Comment on lines +995 to +1003
// Initial egress policy, copied atomically when an Actor is created from
// this template, including the golden Actor used for initialization. The
// policy is named "default" in the Actor's atespace, with its own metadata.
// Callers may update or delete the copy independently; changing the Actor's
// template does not update its policy. If absent, no policy is created;
// an empty block creates a policy with no rules.
//
// +k8s:optional
EgressPolicyTemplate default_egress_policy = 9;

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 opted to create another message here for simplicity, but we could opt to instead require the whole EgressPolicy object with metadata and require the name to be default etc.

Julian Gutierrez Oschmann (@juli4n) and Tim Hockin (@thockin) for API context

@thockin

Copy link
Copy Markdown
Collaborator

Clarify for me - does this mean that every actor created from such a template has the same policy unless subsequently changed? Maybe that should be opt-in? E.g. create actor --template=<T> --with-template-policy ?

Does this also mean that a subsequent call to set policy will require a read-modify-write? That may be surprising.

@EItanya

Copy link
Copy Markdown
Collaborator Author

Clarify for me - does this mean that every actor created from such a template has the same policy unless subsequently changed? Maybe that should be opt-in? E.g. create actor --template=<T> --with-template-policy ?

Yes it would. However, I think that if you are creating from an ActorTemplate, the default policy is actually something you always want, otherwise your actor probably won't work correct. Minus the policy would probably warrant a separate ActorTemplate. The other option could be to accept a policy when calling CreateActor. Part of the problem is that this field is actually doing 2 important, but separate things.

  1. Setting Policy for the golden snapshot, allowing the actor template to use the network to prepare the golden.
  2. Also adding that same policy as the default policy for the actor itself once created.

Now that I've spelled that out for you, I actually think these should be separate. The field I created here should really be something like golden_egress_policy, and then also accept a policy when calling CreateActor. (Doesn't have to be exactly that, but something in that spirit.)

Does that make sense?

Does this also mean that a subsequent call to set policy will require a read-modify-write? That may be surprising.

Yes, and this is a very good point. I think that can mostly be solved with documentation, but it's definitely an interaction worth calling out. This is also a result of not having multiple policy layers, and therefore needing one policy source of truth for an actor.

@EItanya Eitan Yarmush (EItanya) changed the title Apply template default egress policies to golden and newly created actors Configure egress access during golden initialization Oct 6, 2026

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 am worried on just "goldenEgressPolicy". There are going to be many usecases that you need to just fetch github repos/s3/gcs for some assets. Not necessrially part of "golden" - how do we get those to work.

maybe its an "init actor" support and a policy for that? A very common use case for that is "I want an actor with no network, but give it all this github repos available in local folders (e.g for RL)

FWIW init actor can be useful for many other things.

@EItanya

Copy link
Copy Markdown
Collaborator Author

I am worried on just "goldenEgressPolicy". There are going to be many usecases that you need to just fetch github repos/s3/gcs for some assets. Not necessrially part of "golden" - how do we get those to work.

If it's not part of the golden then it's already supported. When an actor comes up from golden it will already have its own identity. I specifically narrowed the scope of this PR to just handle the golden identity.

Adding policy for pre readyz should already work.

maybe its an "init actor" support and a policy for that? A very common use case for that is "I want an actor with no network, but give it all this github repos available in local folders (e.g for RL)

That would be exactly what this would enable. The actor identity would not be allowed to make network calls, only during golden preparation. Mounting other data can/should be done with volumes otherwise.

FWIW init actor can be useful for many other things.

Comment thread cmd/ateapi/internal/controlapi/actor.go Outdated
// Save the data in the storage layer.
stored, err := s.store.CreateActor(ctx, outActor)
var policy *ateapipb.EgressPolicy
if initial := template.GetGoldenEgressPolicy(); initial != nil && atespace == resources.GoldenActorAtespace {

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.

Shouldn't this policy only be used when creating a golden for the template, rather than every CreateActor() ? IIUC this will use the golden policy for every derived actor, which is exactly what we said it was NOT?

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.

This is a leftover, I agree with you. However, this and the comment below do basically land us at changing the RPC to accept an optional initial policy, which could be used internally for goldens, and externally to use a single call to create the Actor. Overall I think the UX would be improved there anyway.

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.

This is especially relevant given that we're moving goldens out of this magical atespace

storageClassLister storagev1listers.StorageClassLister
}

var _ store.Interface = (*ServiceImpl)(nil)

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 know Julian Gutierrez Oschmann (@juli4n) thinking about layers

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.

As I said above, going to change the RPC and see how we feel about that

@EItanya Eitan Yarmush (EItanya) changed the title Configure egress access during golden initialization Configure initial egress policies for actors and goldens Oct 14, 2026
@EItanya
Eitan Yarmush (EItanya) force-pushed the feat/template-default-egress-upstream branch from 2555fa5 to 8f23f53 Compare October 14, 2026 13:51
@bowei Bowei Du (bowei) added area/api User-facing API changes area/api-machinery area/security Security related issue/pr kind/feature An enhancement / feature request or implementation labels Oct 14, 2026
Copy an optional template policy when creating an actor, including the golden actor, and write the actor and policy in one transaction. Preserve the distinction between an absent default and an explicitly empty policy, and let each actor policy evolve independently.

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Expose golden_egress_policy for network access during golden initialization. Create its policy atomically with the golden actor while leaving ordinary actors, including golden snapshot restores, without an inherited runtime policy. Preserve absent and explicitly empty policies.

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Reject a configured golden policy with no rules, since it grants no access beyond omitting the policy. Keep the policy object for future fields.

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Pass the required policy name when reading actor egress policies so the tests follow the updated singleton subresource API.

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Follow the public API proto initialism naming so golden egress tests compile against the current generated types.

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Have the template reconciler explicitly supply the golden policy through CreateActor instead of inferring golden intent from the atespace. Validate and authorize optional initial policies and create them atomically with their actors.

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
@EItanya
Eitan Yarmush (EItanya) force-pushed the feat/template-default-egress-upstream branch from 8f23f53 to 70da2cd Compare October 15, 2026 12:44
Require the GoldenEgressPolicy server gate and client preview opt-in when creating templates with a golden egress policy. Keep existing templates usable after the gate is disabled and leave explicit CreateActor policies available without preview.

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Use the existing policy resource and metadata validation for atomic actor creation. Materialize golden policy templates in the reconciler so the RPC and storage interfaces share the same policy type.

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
CreateActor deliberately accepts a second resource so its egress policy can be created in the same transaction. Record that exception to the single-resource create request convention.

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api User-facing API changes area/api-machinery area/network area/security Security related issue/pr kind/feature An enhancement / feature request or implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants