fix(telemetry): snapshot contract realignment (Issues #30 + #31) #35

Merged
gronod merged 1 commits from fix/30-31-snapshot-contract into milestone/m6-bugfix-stability 2026-09-08 15:09:48 +01:00
Owner

Summary

Fixes the provider↔store snapshot contract drift: decodeSnapshot looked up identifiers and field keys the providers never emitted.

Identifier fixes (#30)

  • …telemetry.cpu…telemetry.cpuload, …telemetry.kernel…telemetry.kernel.counters, …telemetry.systemload…telemetry.system.load, …telemetry.diskio…telemetry.storage.io

Field fixes (#31)

  • CPU: *Percent keys, cores dicts → perCoreLoad, frequencyHz → MHz
  • Kernel: *Rate rates + cumulative_* totals
  • Load avg: load1m/load5m/load15m
  • Disk I/O: *BytesPerSec + cumulative*Bytes
  • Memory: utilizationPercentage computed as used/total
  • Storage: usedPercent, fsType
  • Fans: fanIndex, utilizationPercent, name
  • Processes: residentBytes, virtualBytes
  • Network: name, ipv4Address, *BytesPerSec, cumulative*

New provider emissions

  • isUp from getifaddrs IFF_UP flags (network)
  • isStopped/isZombie from pbi_status SSTOP/SZOMB (processes)
  • name from SMC F{i}ID key (fans)

Tests

  • New Tests/MMSnapshotContractTests.swift — 6 synthetic-dict conformance tests. 93 tests, 0 failures; decodeSnapshot relaxed to internal for @testable.

Verified

  • xcodebuild build test -scheme MacMonitor -destination 'platform=macOS,arch=x86_64' — 93/93 pass
  • swiftlint lint — 0 violations

Fixes #30, fixes #31.

## Summary Fixes the provider↔store snapshot contract drift: `decodeSnapshot` looked up identifiers and field keys the providers never emitted. ### Identifier fixes (#30) - `…telemetry.cpu` → `…telemetry.cpuload`, `…telemetry.kernel` → `…telemetry.kernel.counters`, `…telemetry.systemload` → `…telemetry.system.load`, `…telemetry.diskio` → `…telemetry.storage.io` ### Field fixes (#31) - CPU: `*Percent` keys, `cores` dicts → `perCoreLoad`, `frequencyHz` → MHz - Kernel: `*Rate` rates + `cumulative_*` totals - Load avg: `load1m`/`load5m`/`load15m` - Disk I/O: `*BytesPerSec` + `cumulative*Bytes` - Memory: `utilizationPercentage` computed as `used/total` - Storage: `usedPercent`, `fsType` - Fans: `fanIndex`, `utilizationPercent`, `name` - Processes: `residentBytes`, `virtualBytes` - Network: `name`, `ipv4Address`, `*BytesPerSec`, `cumulative*` ### New provider emissions - `isUp` from `getifaddrs` `IFF_UP` flags (network) - `isStopped`/`isZombie` from `pbi_status` `SSTOP`/`SZOMB` (processes) - `name` from SMC `F{i}ID` key (fans) ### Tests - New `Tests/MMSnapshotContractTests.swift` — 6 synthetic-dict conformance tests. **93 tests, 0 failures**; `decodeSnapshot` relaxed to internal for `@testable`. ### Verified - `xcodebuild build test -scheme MacMonitor -destination 'platform=macOS,arch=x86_64'` — 93/93 pass - `swiftlint lint` — 0 violations Fixes #30, fixes #31.
gronod added 1 commit 2026-09-08 15:09:35 +01:00
Providers emitted identifiers and field keys that decodeSnapshot never
looked up, leaving CPU/kernel/load/disk sections zeroed and memory%,
storage%, network, process RSS, and fan fields decoded as zero.

Store-side decode now reads the emitted schema; providers gain the
previously-missing fields: network isUp (IFF_UP via getifaddrs), process
isStopped/isZombie (pbi_status), fan name (F{i}ID). Memory utilization is
computed as used/total in the decoder. decodeSnapshot is internal for
@testable access; new MMSnapshotContractTests cover the emitted-key
contract with synthetic dictionaries (93 tests total, 0 failures).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
gronod added the Bug/BackendKind/Bug
Priority
Critical
1
Project/Antigravity
labels 2026-09-08 15:09:41 +01:00
gronod merged commit 9933c87004 into milestone/m6-bugfix-stability 2026-09-08 15:09:48 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gronod/MacMonitor#35