Skip to content

Support decorative, non-queryable metadata (annotations) on Actor and ActorTemplate #3617

In review

Description

@shankgan

Summary

Add support for bounded, decorative, non-queryable key-value metadata (map<string, string> annotations) on Actor and ActorTemplate (or ResourceMetadata).

Note: This appears to be related to #186, except that this issue explicitly tracks only Annotations and NOT labels. Happy to de-dup to that issue or any relavent issue if needed.

Motivation

Even when an external harness (such as agent-executor or kagent) creates and tracks actors in its own database, several integration points only see the Substrate Actor or ActorTemplate via ateapi and cannot query the harness's private storage:

  • Out-of-process egress gateways / PEPs & telemetry: External PEPs on the actor egress path (e.g., an external ext_proc service or audit logger, cf. Support bring-your-own ingress and egress gateways #3258 / Support custom ext_proc callouts on ingress and egress #3259) resolve the source Actor via ateapi. Carrying bounded pass-through metadata on the Actor (such as an external workload URI, correlation context, or encoded delegation context attached at creation time) lets the creating harness pass context to downstream PEPs without coupling Substrate's API to harness-specific schemas.
  • Discovery & provenance metadata on ActorTemplate / Actor: External registries and tooling inspecting ActorTemplate or Actor resources need to read non-queryable descriptive metadata such as well-known discovery paths (/.well-known/agent.json), full resource URIs (spiffe://..., https://...), or build provenance links.
  • CLI & multi-tool visibility: Operators and tools (kubectl-ate, observability collectors, CI pipelines) inspecting Actor and ActorTemplate objects directly do not have access to the upstream harness's internal database.

Non-Goals

  • Not queryable or indexed: ListActors and ListActorTemplates will never filter, select, or index on annotations (nor are they intended for building ListWatch controllers).
  • Not for secrets: annotations are returned in plaintext on Get/List; sensitive material belongs in CredentialProvider (ate-secret://).

Proposed

  • Add map<string, string> annotations to Actor and ActorTemplate (plus optional actor_annotations on ActorTemplate to propagate default annotations to actors created from the template), or place annotations directly on ResourceMetadata.
  • Enforce strict bounds in apivalidation: max 64 entries (+k8s:maxProperties=64), k8s-label-key key format, reserved ate.dev/ key prefix rejection, and a small total keys+values byte cap (e.g. 4–16 KiB).
  • Support --annotations in kubectl-ate create actor and kubectl-ate create actor-template.

Activity

  1. added
    kind/feature
    area/api
    on Nov 4, 2026
  2. juli4n commented on Nov 6, 2026

    @juli4n
    Collaborator

    While I agree in that this could be useful, I think we need to think deeply about this. Today Substrate Actors are ~1.5Kb, so this will amplify their sizes up to 8x. An increase in resource sizes like this has a lot of performance implications throughout the whole system so at very least we to measure its impact.

  3. shankgan commented on Nov 11, 2026

    @shankgan
    Author

    Fair point. In #3655, I reduced the ResourceMetadata.annotations limits from 16 KiB / 64 entries down to 4 KiB (4096 bytes total across all keys and values) and at most 16 entries (+k8s:maxProperties=16) to keep Actor records small . Open to tightening the limits further if needed.

    I also did some benchmarking (also in #3655, you can run go test -run='^$' -bench='^BenchmarkActorAnnotations$' -benchmem -count=3 ./cmd/ateapi/internal/controlapi). At the 4 KiB ceiling, a cold ResumeActor + SuspendActor cycle moves by under 0.1 ms (within noise) on a ~12 ms baseline, and GetActor, the warm resume path, slows by 14 µs (5%). CreateActor and UpdateActor pay 0.1 to 0.4 ms more at 4 KiB, almost all of it in protobuf encode/decode and validation of the larger record. ListActors scales linearly with annotation size, which is why the cap is 4 KiB rather than 16 KiB: a 100-actor page at the ceiling takes 2.6 ms and 1.3 MB instead of 0.7 ms and 96 KiB.

    I skipped making changes to the the Locust suites: metadata.annotations never reaches atelet, so the cost appears to be confined to ate-api-server and PostgreSQL. Curious if there are any other performance implications you would consider?

  4. zoez7 commented on Nov 12, 2026

    @zoez7
    Collaborator

    I was a little skeptical of the benchmark results in #3655, and I learned that since makeBenchAnnotations has
    out[k] = strings.Repeat("x", perEntry-len(k)), Postgres's inline compression was able to compress the data much smaller, and didn't trigger TOAST. Can we update makeBenchAnnotations to test non-repeating payloads, and run a more realistic benchmark?

  5. shankgan commented on Nov 13, 2026

    @shankgan
    Author

    I reworked the benchmark (top commit of #3655).
    The DB sub-benchmarks now start from a realistic ~1.4 KiB actor instead of ~130 B. Annotations come in two flavors, random base64 (stored out of line, uncompressed) and text with random IDs (compresses ~2:1, stored out of line compressed), each as 1 entry and as 16 entries. All four 4 KiB shapes hit TOAST in every operation.

    Latency holds up better than I expected. Most of the cost per request is fixed (round trip, lease, commit) and has nothing to do with row size:

    Operation 0B 4 KiB random 4 KiB text
    GetActor 317 µs 448 µs (+41%) 426 µs (+34%)
    UpdateActor 1.95 ms 2.26 ms (+16%) 2.23 ms (+14%)
    CreateActor 724 µs 902 µs (+25%) 1.01 ms (+40%)
    ListActors, 100/page 2.10 ms 5.49 ms 6.77 ms
    Cold resume + suspend 12.5 ms 16.5 ms (+32%) 14.5 ms (+15%)

    WAL is the surprising one:

    Operation 0B 4 KiB random 4 KiB text
    UpdateActor, WAL/op 0.9 KB 7.0 KB (7.7x) 3.8 KB (4.2x)
    Cold cycle, WAL/op 4.4 KB 24.8 KB (5.7x) 15.1 KB (3.5x)

    Back of the envelope, at 500 activations/s that is roughly 1 TB/day of WAL instead of 200 GB. My theory is that an inline update only logs the bytes that changed, while a TOASTed value gets re-inserted as new chunk rows plus index entries on every rewrite, so all 4 KB is logged each time even though the annotations themselves did not change - I have not confirmed this. I don't still have a good sense of how this affects the overall system though.

    The benchmark commit is larger than it should be for this PR (and the payload construction code is quite messy). I will likely pull it out and send it separately before this is ready for review.

  6. thockin commented on Nov 25, 2026

    @thockin
    Collaborator

    I skipped making changes to the the Locust suites: metadata.annotations never reaches atelet, so the cost appears to be confined to ate-api-server and PostgreSQL. Curious if there are any other performance implications you would consider?

    Something useful in Kubernetes was to "project" metadata like annotations into the workload as a virtual file. We don't need to handle that now but I suspect it will come up.

    Not mentioned here is mutability. In Kube, annotations are mutable - I think we would want this to be immutable, wouldn't we? At the least we would want to leave room for mutable AND immutable data.

    Lastly, do we really think this is unique to Actor or is it just part of ResourceMetadata?

  7. thockin commented on Nov 26, 2026

    @thockin
    Collaborator

    Other than mutability / immutability, #3655 looks more or less like what I expected - it being in ResourveMetadata feels right.

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

Metadata

Metadata

Labels

area/apiarea/api-machinerykind/feature

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions