Repository navigation
In review
Feature
Copy link
Labels
area/apiUser-facing API changesarea/api-machinerykind/featureAn enhancement / feature request or implementation
Description
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_procservice 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 sourceActorviaateapi. Carrying bounded pass-through metadata on theActor(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 inspectingActorTemplateorActorresources 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) inspectingActorandActorTemplateobjects directly do not have access to the upstream harness's internal database.
Non-Goals
- Not queryable or indexed:
ListActorsandListActorTemplateswill never filter, select, or index onannotations(nor are they intended for buildingListWatchcontrollers). - Not for secrets:
annotationsare returned in plaintext onGet/List; sensitive material belongs inCredentialProvider(ate-secret://).
Proposed
- Add
map<string, string> annotationstoActorandActorTemplate(plus optionalactor_annotationsonActorTemplateto propagate default annotations to actors created from the template), or placeannotationsdirectly onResourceMetadata. - Enforce strict bounds in
apivalidation: max 64 entries (+k8s:maxProperties=64),k8s-label-keykey format, reservedate.dev/key prefix rejection, and a small total keys+values byte cap (e.g. 4–16 KiB). - Support
--annotationsinkubectl-ate create actorandkubectl-ate create actor-template.
Metadata
Metadata
Labels
area/apiUser-facing API changesarea/api-machinerykind/featureAn enhancement / feature request or implementation
Activity
juli4n commentedon Nov 6, 2026
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.
shankgan commentedon Nov 11, 2026
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?
zoez7 commentedon Nov 12, 2026
I was a little skeptical of the benchmark results in #3655, and I learned that since
makeBenchAnnotationshasout[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 updatemakeBenchAnnotationsto test non-repeating payloads, and run a more realistic benchmark?shankgan commentedon Nov 13, 2026
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:
WAL is the surprising one:
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.
thockin commentedon Nov 25, 2026
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,
annotationsare 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?thockin commentedon Nov 26, 2026
Other than mutability / immutability, #3655 looks more or less like what I expected - it being in
ResourveMetadatafeels right.