Repository navigation
fix(hydrator): read sandbox identity from device.container - #24
kperry-godaddy merged 3 commits into
Conversation
OpenShell after v0.1.7 (NVIDIA/OpenShell#5048) moves supervisor sandbox identity from the top-level container object to device.container. The hydrator read only the top-level field, so every record from an upgraded supervisor was unmapped. Prefer device.container and fall back to the top-level container so mixed fleets keep attributing during upgrades. Fixes agentnameservice#23 Signed-off-by: chou-godaddy <chou@godaddy.com>
kperry-godaddy
left a comment
There was a problem hiding this comment.
Approving. This is the hydrator's half of NVIDIA/OpenShell#5048: upstream moved supervisor sandbox identity under device.container after v0.1.7, and without this change every record from an upgraded supervisor lands in Unmapped, which fails a fully upgraded fleet outright and silently drops the upgraded sandboxes in a mixed one. Routing all three readers through one Event.Sandbox() accessor is the right shape for it: the precedence rule lives in one place, the top-level fallback is contained in one function to retire later, and decoding only the device's container keeps a gateway record's device.uid and device.name (the installation name) from ever being mistaken for a sandbox. I checked that claim against upstream's Device::gateway and Device::linux constructors on main; it holds.
What I verified at a9dfd5d: build, vet, gofmt, go test -race ./... and golangci-lint v2.10.1 under Go 1.26.9 are clean; hydrator coverage is 98.0% with Sandbox, Lookup, attributor.add and activitySandbox fully covered. Three mutations of the resolver (device-only, fallback removed, empty device.container guard removed) each fail at least one test, so the new behaviour and the legacy path are both pinned. The 14-record capture carries no credentials; the only environment detail in it is the dev address noted inline.
Two notes inline, neither blocking. One item for later rather than for this PR: once v0.1.8 ships, refreshing testdata/supervisor-device-container.jsonl from the release build would retire the pre-release caveat in the PR body.
Related issue
Fixes #23
Summary
NVIDIA/OpenShell#5048, merged after v0.1.7, moves supervisor sandbox identity from the top-level
containerobject todevice.container.ans-ocsf-hydratorreads only the top-level field, so every record from an upgraded supervisor is unmapped: a fully upgraded fleet fails the run, and in a mixed fleet the upgraded sandboxes silently get no new observation. This PR readsdevice.containerfirst and falls back to the top-levelcontainer.Changes
internal/hydrator/event.go):Event.Sandbox()returnsdevice.containerwhen it has a UID or name, otherwise the top-levelcontainer. The device's ownuid,nameandhostnameare not decoded: upstream leavesuidandnameempty on supervisor records and sets them to the gateway installation name on gateway records.agentmap.go,aggregate.go,activity.go): agent lookup, theNoContainercount and the activity sandbox key (decision times, destination keys, policy context) use the resolver. No other logic changes.doc.go, theNoContainercomment inrun.goanddeploy/examples/hydrator.yamlname both locations and drop the removed schema-downgrade wording.Report.NoContainerand theno_containerlog key keep their names; they now mean no sandbox in either location.A record whose
device.containermatches no agent is not matched again through a top-levelcontainer. Upstream emits one shape per record, and its OCSF validator rejects a top-levelcontainer.Testing
go test -race ./...,go vet ./...,gofmtandgolangci-lintv2.10.1: all pass, 0 issues. Library coverage 98.5%.device.container, a device identity without a container), lookup bydevice.containerUID and name, and policy context keyed bydevice.container, including a policy record before the window.mainat1cdfe70(0.1.8-dev.29+g1cdfe7088), nine commits after fix(ocsf): validate sandbox attribution against exported schemas NVIDIA/OpenShell#5048. Its records carry the sandbox only indevice.container. The hydrator on currentmainattributed 0 of 14 captured records; with this change it attributes 14 of 14. The 14 records are included unedited asinternal/hydrator/testdata/supervisor-device-container.jsonl, andTestRunUpstreamDeviceContainerCaptureruns them with the agent mapped by sandbox UID and by name. The capture comes from a pre-release, so it should be refreshed if the shape changes before OpenShell's next release.Sandbox()reduced toreturn e.Container, thedevice.containertests fail.Out of scope
Gateway-origin records, which carry the sandbox in
resourcesorunmapped.sandbox_id: the hydrator's input is supervisor records only (README). Removing the top-level fallback, once OpenShell releases before the change are no longer supported.AI assistance
Assisted-by: Cursor (Claude Opus 5.5)
Checklist
git commit -s) certifying the DCO