SIGN IN SIGN UP

fix(ai_api): the agent-facing memory tool invented figures on macOS

`tool_get_memory` used the real reader on Linux and Windows and hand-rolled the
rest from `sysctl` and `vm_stat`, with four defects an agent had no way to see:

- **A hardcoded 16384-byte page size**, commented "Apple Silicon default". The
  page size on an Intel Mac is 4096, so every figure would be four times too
  large -- a wrong number in the direction that looks plausible.
- A failed `vm_stat` fell to zero pages, computing `free_mb = 0` and
  `used_mb = total`: 100% memory used, reported to an agent as a measurement.
- A failed `hw.memsize` gave a total of 0.
- An unreadable `vm.swapusage` was reported as no swap -- the exact claim the
  `SwapInfo` `Option` refactor was done to stop making, still being made here.

**This is the third consumer found fabricating around
`platform::macos::read_memory_stats`**, after the ontology adopted it in 5.2.0
and `MonitoringBackend` did not (`24a7314`). The note added in `d2cc423` said
adding a reader is not the same as adopting it; three consumers rather than two
is the sharper version.

Swap now emits `null` rather than `0` where the platform reported nothing, so an
agent can tell "no swap configured" from "swap was not readable". Platforms that
are neither Linux, Windows nor macOS get `UnsupportedPlatform` instead of
invented numbers.

Found by grepping fallback values -- `unwrap_or(0)`, `unwrap_or(false)` -- rather
than comments. That sweep finds a different population: the comment grep catches
defects someone documented with an apologetic note; this catches the ones nobody
bothered to comment, and they are more common. Most hits are legitimate
(`unwrap_or(true)` as "no filter, include everything"), so it needs triage. The
signal is a fallback in a reader path, where the value flows outward as a
reading.

Verified: both cross-target checks with `--all-targets`, fmt, clippy
`-D warnings`, 826 lib tests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A
Adam Erickson committed
1cf1980481b75a7de3df7d3b215f7318c0a8ebf1
Parent: f8ae929