# IMPLEMENTATION — vram-detect-cross-platform **Implementer:** local LLM (gemma-4-26B-A4B-it-uncensored-Q4_K_M.gguf via headroom @ localhost:8787, model id `local-llm`) **Orchestrator:** opencode (glm-5.2) ## What changed in `scripts/vram_detect.py` | Function | Author | Change | |---|---|---| | `import platform` (new top-level import) | Orchestrator (mechanical) | Added to support `platform.system()` dispatch | | `detect_gpu_vram()` | Local LLM | Branched on `platform.system()`. Linux: unchanged. Darwin: `system_profiler SPDisplaysDataType` parser (Apple Silicon → unified memory via `sysctl -n hw.memsize`; Intel Macs → `VRAM (Total):`). Windows: `wmic path win32_VideoController get AdapterRAM,Name /format:list` + PowerShell fallback. | | `detect_ram()` + `_detect_ram_linux/_darwin/_windows()` | Local LLM + Orchestrator refactor | Local LLM produced inline branches; Orchestrator extracted private helpers to match subtask-3 test contract (`_detect_ram_linux()`). Linux path byte-identical. macOS: `sysctl hw.memsize` (no available RAM, reports total). Windows: `wmic` + PowerShell fallback. | | `MODEL_CONTEXT_WINDOWS` | Local LLM | Added 14 local-LLM entries (llama-3.1, qwen2.5, mistral, deepseek-r1/v3, glm-4/4.5, gemma-2, phi-3/4) with source-cited context sizes. Conservative values where YaRN extends context. | | `_probe_ollama_model()` (new) | Local LLM | Calls `ollama list`, parses first non-header row's NAME column, strips `:latest`. Returns None on any error or if ollama not installed. | | `detect_model_context()` | Orchestrator (mechanical wire-up) | Calls `_probe_ollama_model()` as last-resort fallback after all config-file probes fail. | | `run_command()` | Local LLM | On Windows, if first cmd arg starts with `Get-` or contains `CimInstance`, rewrites cmd to `['powershell', '-NoProfile', '-NoLogo', '-Command', ' '.join(cmd)]` before `shutil.which` check. Preserves Linux behavior. | ## BEFORE vs AFTER on this Darwin arm64 (Apple M5, 32GB) - **BEFORE:** `gpu_vram_gb: 0` (macOS not supported, falls through to "no GPU") - **AFTER:** `gpu_vram_gb: 32`, `GPU: Apple Silicon (unified memory)`, `Total System RAM (Shared VRAM): 32768 MB` - Target context correctly jumped 12k → 42k (reflects shared VRAM budget). - JSON shape unchanged (same 8 keys, same order, same types). ## Anti-spin rails that fired - **Signature mismatch on `_detect_ram_linux()`:** subtask-3's test expected a private helper; local LLM's first refactor put Linux path inline in `detect_ram()`. Orchestrator (me) extracted the helper to match the test contract — NOT weakening the test, the opposite: making code more testable per the contract. - All other local-LLM output was applied verbatim after passing py_compile. ## Streak verifier result ``` STREAK_COMPLETE attempt=1 clean=10/10 ``` The independent checker model (the streak verifier, per article #2/#9/#13) ran the full suite 10 consecutive times with no edits between. The worker (local LLM) did not grade its own homework. ## Test count - 235 passed (was 224; subtask-3 added 11 cross-platform tests). - 0 errors, 0 skipped. - Suite runtime ~3.5s. ## Files touched (and ONLY this file) - `scripts/vram_detect.py` (+ 1 new top-level import, +14 dict entries, +1 new helper function `_probe_ollama_model`, refactor of 3 existing functions, +1 new branch in `run_command`, +1 wire-up call in `detect_model_context`)