Skip to content

fix(canary): docker_tier_pool timeout + metal_monitor ignore for Intel Mac AMD - #1530

Merged
joelteply merged 2 commits into
canaryfrom
59ab3e6f/canary-test-stability
Jun 6, 2026
Merged

joelteply merged 2 commits into
canaryfrom
59ab3e6f/canary-test-stability

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Two test-stability fixes surfaced during canary post-fast-forward verification. Both expose latent issues the test suite was masking on Mac Intel + AMD discrete-GPU hosts.

1. docker_tier_pool::run_docker_prune — hard 30s timeout

A wedged Docker daemon on this Mac pinned cargo test at 0% CPU for 88+ minutes; zombie docker system prune processes accumulated. Command::output() has no timeout, so the test blocked indefinitely waiting on the docker CLI waiting on the docker daemon.

Replaces Command::output() with Command::spawn() + try_wait() loop bounded by DOCKER_INVOKE_TIMEOUT (30s). On timeout: kill the child + reap + return None. The broker's existing failure semantics handle None as "tier can't act, surface pressure to operator" — no caller changes needed.

This is the production fix, not a test-only workaround. The pressure-broker runs evict_at_least() in production; without the timeout a Docker wedge would pin the broker — the very subsystem whose job is to RECOVER from pressure. Per [[every-error-is-an-opportunity-to-battle-harden]].

2. metal_monitor tests — #[ignore] with task #163 link

On Mac Intel + AMD Radeon Pro Vega:

  • memory_signals_are_within_sane_bounds: total=4 GB, free=20 GB, panics on free <= total + 10%. MTLDevice.recommendedMaxWorkingSetSize reports discrete VRAM (4 GB) but host_statistics64 reports system-wide free pages (20 GB) — different memory spaces conflated.
  • pressure_updates_after_first_tick: 1.0 - clamp(free/total) rounds to 0 when free >> total.

Both #[ignore] with the message naming task #163 (MetalMonitor: discrete-GPU memory pressure signal Intel Mac w/ AMD). The tests are correct; the implementation is the bug. Unignore when #163 lands.

Test plan

  • docker_tier_pool tests pass in 30s on this Mac (timeout fires correctly, both evict_at_least_never_panics and implements_resource_pool_via_dyn complete)
  • metal_monitor tests run: 2 pass, 2 ignored with task Bump eslint from 9.31.0 to 9.39.1 #163 link
  • Full canary lib test suite no longer hangs on docker daemon wedge
  • CI confirms no regression on healthy Docker daemon (the timeout only fires on hang)

Doctrine

  • [[every-error-is-an-opportunity-to-battle-harden]] — production fix, not test workaround
  • [[canary-stays-clean-pure-rust]] — failures get fixed or marked with a trail back to the tracking task

card: 59ab3e6f-693e-407a-b6d7-935c6da87cba

…l Mac AMD discrete

Two test-stability fixes surfaced during the post-fast-forward
canary verification cycle. Both surface latent issues the test
suite was masking by hanging or failing on this specific Mac
Intel + AMD discrete-GPU configuration.

## 1. `docker_tier_pool::run_docker_prune` — hard 30s timeout

**Observed**: a wedged Docker daemon on this Mac pinned
`cargo test` at 0% CPU for 88+ minutes; multiple zombie
`docker system prune` processes accumulated across test runs.
`Command::output()` has no timeout, so the test process blocked
indefinitely waiting on the docker CLI which was waiting on the
docker daemon.

**Fix**: replace `Command::output()` with `Command::spawn()` +
manual `try_wait()` loop bounded by `DOCKER_INVOKE_TIMEOUT`
(30s). On timeout, kill the child + reap + return `None`. The
broker's existing failure semantics already handle `None` as
"tier can't act, surface pressure to operator" — no caller
changes needed.

**Why this matters beyond tests**: the pressure-broker runs
`DockerTierPool::evict_at_least()` in production whenever disk
pressure escalates. Without the timeout, a transient Docker
daemon wedge would pin the broker — the very subsystem whose
job is to RECOVER from pressure. Per
`[[every-error-is-an-opportunity-to-battle-harden]]` this fix
lands as production code, not a test-only workaround.

**Tests that no longer hang** (both complete in 30s, return
0 freed bytes as `evict_at_least_never_panics` already documents
as the host-state contract):
  - `evict_at_least_never_panics`
  - `implements_resource_pool_via_dyn`

## 2. `metal_monitor` tests — `#[ignore]` with task #163 link

**Observed failures on this Mac Intel + AMD Radeon Pro Vega
discrete**:
  - `memory_signals_are_within_sane_bounds`: `total=4 GB`,
    `free=20 GB`, panics on `free <= total + 10%` invariant.
    Root cause: `MTLDevice.recommendedMaxWorkingSetSize` reports
    discrete-GPU VRAM (4 GB on this Vega) but
    `host_statistics64` reports system-wide free pages (20 GB)
    — different memory spaces conflated.
  - `pressure_updates_after_first_tick`: pressure stays 0.0
    because `1.0 - clamp(free/total)` rounds to 0 when
    free >> total.

**Fix**: both tests `#[ignore]` with the message naming task
**#163** (`MetalMonitor: discrete-GPU memory pressure signal
Intel Mac w/ AMD`). The tests are correct; the implementation
is the bug. Unignore when #163 lands.

**Why this matters**: muting the tests with bare `#[ignore]`
would lose the trail. The ignore reason names the tracking
task so a future reader can wire them back on the same fix.

## Doctrine

- `[[every-error-is-an-opportunity-to-battle-harden]]` — the
  docker hang surfaced a real production-risk bug; the fix is
  the production fix, not a test workaround.
- `[[canary-stays-clean-pure-rust]]` — pre-existing failures
  pollute the green-test signal; either fix them or mark them
  with a trail back to the tracking task.

card: 59ab3e6f-693e-407a-b6d7-935c6da87cba

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Properly fixes the Intel Mac + AMD discrete-GPU memory accounting
that the earlier commit (55a1bb9) marked `#[ignore]` as a
stop-gap. Removes both ignores; both tests now pass on this
MacBookPro15,1 with Radeon Pro Vega.

## Root cause

`recommended_max_working_set_size` (Metal) and Mach VM
`host_statistics64` read from different memory spaces:

  - **Apple Silicon** (unified memory): GPU + CPU share one
    address space. Mach VM stats ARE the GPU memory signal.
    Existing code was correct here.
  - **Intel Mac + discrete GPU** (AMD / NVIDIA): GPU has its own
    VRAM, separate from system DRAM. Mach VM reports system-wide
    free pages (20 GB), Metal reports discrete VRAM total (4 GB),
    so `free=20 GB > total=4 GB` — invariant blown. Same broken
    arithmetic was driving pressure to 0 because
    `1.0 - clamp(20/4)` rounds to 0.

The earlier code only worked on Apple Silicon. Intel Macs got
either nonsense signals or crashed test invariants.

## Fix

Detect `MTLDevice.hasUnifiedMemory()` at construction; branch the
sampler between two strategies:

```rust
pub enum MemoryMode { Unified, Discrete }

fn sample_memory(mode: MemoryMode, total: u64, device: &Device) -> (u64, u64) {
    match mode {
        Unified  => (read_system_free_bytes(), read_phys_footprint()),
        Discrete => {
            let allocated = device.current_allocated_size();
            (total.saturating_sub(allocated), allocated)
        }
    }
}
```

Discrete mode uses `MTLDevice.currentAllocatedSize()` — the
device-scoped allocation tracker — for this-process GPU usage,
and derives free as `total - allocated`. This OVER-reports free
because it ignores other processes' GPU consumption on the same
device, but always satisfies the broker's
`free <= total` invariant. IOReport.framework (Phase 2.0a)
tightens this when wired.

The metal crate's `metal::Device` auto-implements `Send + Sync`
via `foreign_obj_type!`, so the device handle moves cleanly into
the spawned sampler task.

## Tests (+2 new, both originally-ignored now pass)

- `memory_signals_are_within_sane_bounds` — UNIGNORED.
  Force-allocates a 16 MB Metal buffer before measurement so the
  `proc > 0` invariant holds on Discrete even with no prior GPU
  work in the test process.
- `pressure_updates_after_first_tick` — UNIGNORED. Same forced
  allocation guarantees `pressure > 0` on Discrete devices
  (`pressure = allocated/total`).
- `memory_mode_matches_device_unified_flag` — NEW. Pins that
  `memory_mode()` agrees with `device.has_unified_memory()` at
  construction. Catches refactor accidents that hard-code one mode.
- `sample_memory_discrete_never_exceeds_total` — NEW. Pure
  function test on the Discrete branch. Closes the
  `free > total` class of bug for good with a deterministic
  invariant check.

Verified on MacBookPro15,1 (Intel + AMD Radeon Pro Vega) with
`cargo test -p continuum-core --lib --features metal,accelerate
metal_monitor`: **11/11 pass, 0 ignored**.

## Doctrine

- `[[every-error-is-an-opportunity-to-battle-harden]]` — the
  failing test surfaced a real bug; the fix is the proper
  production fix, not a permanent ignore.
- `[[organization-purity-as-we-migrate]]` — `MemoryMode` makes
  the discrete vs unified distinction first-class instead of
  implicit-in-platform-detection-hacks.
- `[[test-fixtures-are-system-primitives]]` — `sample_memory`
  exposed `pub(super)` so the discrete branch is testable as a
  pure function.

card: 59ab3e6f-693e-407a-b6d7-935c6da87cba
closes: #163

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@github-actions github-actions Bot added size: L and removed size: M labels Jun 5, 2026
@joelteply
joelteply merged commit 6d9de34 into canary Jun 6, 2026
3 checks passed
@joelteply
joelteply deleted the 59ab3e6f/canary-test-stability branch June 6, 2026 01:01
joelteply added a commit that referenced this pull request Oct 4, 2026
…ay's airc-lib fixes (#4735)

Kimi on the 5090 kept hitting "settled work is not claimable" on her own card
with her daemon already at #1532: the claim gate is airc-lib, compiled into
this core at the pinned rev, and 7499136 predates every airc fix of
2026-10-04. A daemon update cannot deliver an airc-lib fix to personas; only
this pin can.

Adopts #1528 (right-sized payloads), #1529 (per-channel ring byte bound;
channel_count and ring_bytes_total in status), #1530 (verbs are never room
names), #1531 (the owner resumes her own card after her lease lapses), #1532
(ownership durable, the lease is presence, from 2026-10-04T16:00Z), #1533
(test) and #1534 (work claim/update/link --room).

continuum-core lib + bins + tests type-check clean against it (mac-cpu-only
features), 0 errors. Lockfile changes outside airc are only windows-sys /
windows-core versions inside airc crates' dependency lists (#1480).

Card 86c5eb48.


Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant