feat(host): populate OS name on macOS via sw_vers #134

Merged
longjacksonle merged 1 commit from feat/macos-osinfo into main 2026-07-14 16:17:43 +02:00

What

Follow-up to VA-133. That change added macOS backends for host::sysinfo and host::cpuinfo, so the agent Overview now shows kernel, CPU, memory, uptime, and load on a Mac. One field stayed blank: OS. The Overview osName is derived from host::osinfo (pretty_name / name), and osinfo still returned a default snapshot on macOS, so osName was null.

This adds a macOS osinfo backend.

How

snapshot() gains a macOS arm that reads product name/version/build from sw_vers and the per-machine IOPlatformUUID from ioreg -rd1 -c IOPlatformExpertDevice (matching the identifier the C agent reports). The raw-to-OsInfo shaping is a pure osinfo_from_macos(), and the IOPlatformUUID line extraction is a pure parse_ioplatform_uuid(); both are unit-tested off-macOS. pretty_name (which feeds osName) is composed as "<name> <version> (<build>)", dropping missing parts, and falls back to a literal "macOS" when sw_vers yields nothing, so the OS field is never blank on a Mac.

Testing

Pure helpers gated cfg(any(target_os = "macos", test)), so they compile and run under test on Linux. 11 host::osinfo lib tests pass; clippy --deny warnings and fmt clean on the Linux box. The sw_vers/ioreg process shells are macOS-only and need a native build to confirm live values; validated end to end on an Intel Mac against the dev stack alongside the rest of the Overview (kernel/CPU/memory/uptime/load already confirmed from VA-133).

## What Follow-up to VA-133. That change added macOS backends for `host::sysinfo` and `host::cpuinfo`, so the agent Overview now shows kernel, CPU, memory, uptime, and load on a Mac. One field stayed blank: **OS**. The Overview `osName` is derived from `host::osinfo` (`pretty_name` / `name`), and `osinfo` still returned a default snapshot on macOS, so `osName` was null. This adds a macOS `osinfo` backend. ## How `snapshot()` gains a macOS arm that reads product name/version/build from `sw_vers` and the per-machine `IOPlatformUUID` from `ioreg -rd1 -c IOPlatformExpertDevice` (matching the identifier the C agent reports). The raw-to-`OsInfo` shaping is a pure `osinfo_from_macos()`, and the `IOPlatformUUID` line extraction is a pure `parse_ioplatform_uuid()`; both are unit-tested off-macOS. `pretty_name` (which feeds `osName`) is composed as `"<name> <version> (<build>)"`, dropping missing parts, and falls back to a literal `"macOS"` when `sw_vers` yields nothing, so the OS field is never blank on a Mac. ## Testing Pure helpers gated `cfg(any(target_os = "macos", test))`, so they compile and run under `test` on Linux. 11 `host::osinfo` lib tests pass; clippy `--deny warnings` and fmt clean on the Linux box. The `sw_vers`/`ioreg` process shells are macOS-only and need a native build to confirm live values; validated end to end on an Intel Mac against the dev stack alongside the rest of the Overview (kernel/CPU/memory/uptime/load already confirmed from VA-133).
feat(host): populate OS name on macOS via sw_vers
All checks were successful
Check / fmt + clippy + tests (pull_request) Successful in 4m8s
Create release / Create release from merged PR (pull_request) Has been skipped
d7c49bf63a
VA-133 gave macOS a sysinfo/cpuinfo backend, filling kernel, CPU, memory, uptime, and load in the agent Overview, but the OS field stayed blank: host::osinfo still returned a default snapshot on macOS, so the sysinfo `osName` (derived from osinfo pretty_name/name) was null.

Add a macOS osinfo backend reading product name/version/build from sw_vers and the per-machine IOPlatformUUID from ioreg. The raw-to-OsInfo shaping lives in a pure osinfo_from_macos() so it is unit-tested off-macOS, and the IOPlatformUUID line parser has its own Linux-runnable test. pretty_name (which feeds Overview osName) is composed as "<name> <version> (<build>)", dropping missing parts, and falls back to a literal "macOS" when sw_vers yields nothing so the OS field is never blank on a Mac.

The pure helpers are gated cfg(any(target_os = "macos", test)); only the sw_vers/ioreg process shells are macOS-only. Linux and other-platform paths are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BFsMi3Vmf3pCc7mBdhZqoV
longjacksonle deleted branch feat/macos-osinfo 2026-07-14 16:17:43 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/vervain-agent!134
No description provided.