Files
substrate/internal
Tim Bai e9b2853e10 ateom: add GetActiveWorkloadStats RPC (#899)
First piece of #896 (Phase 1 of #550): `GetActiveWorkloadStats`, a
parameterless sibling to `GetWorkloadStats` for a scraper that
enumerates ateoms and holds no worker-to-actor mapping.

## Contract

* An **available** ateom answers an empty `stats` list, not an error —
an idle worker is a normal thing for a scraper to find.
* An **executing** ateom answers the same sample the keyed read would
give, wrapped in a one-element list.
* `FAILED_PRECONDITION` keeps the meaning it has on `GetWorkloadStats`:
executing, but no numbers yet (mid-boot, guest not answering) — skip
this sample, take the next one.
* Consumers MUST attribute each sample solely from the identity echoed
inside it, never from a mapping they hold: with no asserted uid, the
response is the only statement of who was measured. This rule is on the
RPC's doc comment.

## Implementation

Both runtimes share the measurement half of their existing
`GetWorkloadStats`, extracted as `sampleSandbox` (gVisor) /
`sampleGuest` (micro-VM) — the discovery handler is attribution-load,
empty-if-nil, same helper, re-check. No change to what is measured or
how.

The one deliberate semantic split: a lifecycle transition underneath the
lock-free read is `NOT_FOUND` on the keyed read (the caller asserted an
actor that is now gone; its mapping wants re-resolving) but
`FAILED_PRECONDITION` on the discovery read (there is no requested actor
to disown — the numbers just cannot be attributed to any single actor
this tick).

Naming note: #896's sketch called this `GetCurrentActiveWorkloadStats`;
"current" was redundant with "active", so it landed shorter.

## Testing

* Both runtimes: available → empty list; executing mid-boot (no sandbox
cgroup / no guest target) → `FAILED_PRECONDITION`; and a cross-check
pinning that the discovery sample is identical to the keyed sample
against the same fixture — one measurement, two addressing modes.
* `make verify` clean through the proto checks (`go-generate.sh`
confirms the regenerated `ateom.pb.go` / `ateom_grpc.pb.go` are
canonical).

Part of #896, toward #550.
2026-08-13 17:13:00 -04:00
..
2026-08-07 18:20:22 +00:00