Repository navigation
fix(canary): docker_tier_pool timeout + metal_monitor ignore for Intel Mac AMD - #1530
Merged
Merged
Conversation
…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]>
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 timeoutA wedged Docker daemon on this Mac pinned
cargo testat 0% CPU for 88+ minutes; zombiedocker system pruneprocesses accumulated.Command::output()has no timeout, so the test blocked indefinitely waiting on the docker CLI waiting on the docker daemon.Replaces
Command::output()withCommand::spawn()+try_wait()loop bounded byDOCKER_INVOKE_TIMEOUT(30s). On timeout: kill the child + reap + returnNone. The broker's existing failure semantics handleNoneas "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_monitortests —#[ignore]with task #163 linkOn Mac Intel + AMD Radeon Pro Vega:
memory_signals_are_within_sane_bounds:total=4 GB,free=20 GB, panics onfree <= total + 10%.MTLDevice.recommendedMaxWorkingSetSizereports discrete VRAM (4 GB) buthost_statistics64reports 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_pooltests pass in 30s on this Mac (timeout fires correctly, bothevict_at_least_never_panicsandimplements_resource_pool_via_dyncomplete)metal_monitortests run: 2 pass, 2 ignored with task Bump eslint from 9.31.0 to 9.39.1 #163 linkDoctrine
[[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 taskcard:
59ab3e6f-693e-407a-b6d7-935c6da87cba