Skip to content

ateom: pluralize the discovery read for multi-actor workers - #1644

Merged
Jeff Luo (JeffLuoo) merged 1 commit into
agent-substrate:mainfrom
baizhenyu:stats-multiactor-samples
Sep 17, 2026
Merged

Jeff Luo (JeffLuoo) merged 1 commit into
agent-substrate:mainfrom
baizhenyu:stats-multiactor-samples

Conversation

@baizhenyu

@baizhenyu Tim Bai (baizhenyu) commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

Step 1 of #1640 (adapting the actor resource-telemetry stack to multi-actor workers, #1266): the discovery read's wire shape breaks in place, ahead of the runtime work, while the capacity cap still holds every list to at most one entry.

Contract

GetActiveWorkloadStatsResponse becomes:

message GetActiveWorkloadStatsResponse {
  repeated WorkloadStatsSample samples = 1;
}

The oneof {sample | no_sample_reason} and the NoSampleReason enum are deleted outright — no reserved tombstones, per the accepted-skew stance below.

  • Available = the empty list. "Available" stopped being a reason; it is the absence of workloads.
  • Not measurable yet (boot, restore, teardown, a lifecycle transition underneath the lock-free read) = a pending entry: full attribution + sandbox class with source = STATS_SOURCE_UNSPECIFIED, whose "not measured" meaning WorkloadStatsSample already defines. It became a per-workload statement because with N workloads it can't be a response-level one — and it closes an old gap: a workload that dies during boot is attributable to a blind caller instead of anonymous.
  • The keyed GetWorkloadStats is untouched: uid-addressed, per-actor codes correct at any occupancy.

Consumers

The atelet sweep folds every entry of every response; nothing in it assumes at most one. Pending entries contribute nothing anywhere — not to the aggregates (sampled_actors keeps meaning "measured"), not to the CPU delta baselines, and no usage event — exactly matching the old no-sample behavior, so metrics and events are byte-identical before and after this change on a capacity-1 fleet.

Version skew: broken

There is no dual population, no fallback decode, no rollout gate (per the decision recorded on #1640). Given that this is prior to GA, I recommend making the breaking change in favor of code simplicity..

Testing

  • Both runtimes: available → empty list; mid-boot → one pending entry asserted in full (attribution, class, observed_at set); transition-mid-read → pending entry for the new occupant / empty when the slot cleared; the discovery sample stays byte-identical to the keyed read's against the same fixture.
  • atelet: pending entries skipped for aggregates, baselines, and events; multi-entry folding exercised by the loop shape.
  • verify-all.sh clean end to end (includes proto regen check and the metrics registry).

Part of #1640, toward #1266.

GetActiveWorkloadStatsResponse's singular oneof said so itself: "an
ateom serves one actor at a time, so the sample slot is singular".
Multi-actor workers retire that premise, and this is the wire shape
changing in place ahead of them, while the capacity cap still makes the
list hold at most one entry:

  repeated WorkloadStatsSample samples = 1;

"Available" is the empty list. A workload with no numbers to give yet
(boot, restore, teardown, a lifecycle transition underneath the read)
is a PENDING entry: attribution and the runtime family with source left
STATS_SOURCE_UNSPECIFIED, whose "not measured" meaning the sample
already defines. That retires NoSampleReason -- "available" stopped
being a reason and "not measurable yet" became a per-workload statement
-- and it closes an old gap: a workload that dies during boot is now
attributable to a blind caller instead of anonymous.

The atelet sweep folds every entry of every response; pending entries
contribute nothing anywhere -- not to the aggregates, so
sampled_actors keeps meaning "measured", not to the CPU baselines, and
no usage event -- exactly as the old no-sample answers behaved. The
keyed GetWorkloadStats is untouched: uid-addressed, its per-actor codes
stay correct at any worker occupancy.

Version skew during a mixed rollout is accepted rather than bridged
(no dual population, no fallback decode): singular and repeated message
fields of one number share a wire encoding, so mixed versions degrade
to undercounting a multi-actor worker or reading a booting one as
available for a tick, and converge with the rollout.
@git286

Copy link
Copy Markdown
Collaborator

so an old atelet sees a multi-actor worker as its last sample

Is it true? When the same message field shows up twice, protobuf merges the second into the first instead of replacing it and so the data can be mixed actually

@baizhenyu

Copy link
Copy Markdown
Collaborator Author

so an old atelet sees a multi-actor worker as its last sample

Is it true? When the same message field shows up twice, protobuf merges the second into the first instead of replacing it and so the data can be mixed actually

I don't think so. I would just assume version skew would break the gRPC. Since this is before public GA, so I did not really handle the breaking changes in a graceful way.

@JeffLuoo
Jeff Luo (JeffLuoo) merged commit 0109b8e into agent-substrate:main Sep 17, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants