Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (claude): probe powermetrics sudo specifically + preserve telemetry on resume

[._.]/ Adam Eivy0410b9f52a9e
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md
index 5774cc1424..5b6fc6f7c0 100644
--- a/docs/TROUBLESHOOTING.md
+++ b/docs/TROUBLESHOOTING.md
@@ -301,13 +301,14 @@ thrash are secondary possibilities. First observed 2026-06-13 (twice in one day)
- Training checkpoints at least every `ceil(totalSteps/4)` steps
(`MFLUX_MIN_CHECKPOINTS`), so a crash loses at most ~¼ of a run. Resume from the
newest `checkpoints/*.zip` via the UI's resume action or `--resume-checkpoint`.
-- Each run captures GPU/thermal/power telemetry to `<run>/powermetrics.log` when
- passwordless `powermetrics` is configured (see the incident record for the
- sudoers rule).
+- Each run captures GPU/thermal/power telemetry to `<run>/powermetrics.log` (a
+ resume rolls to a timestamped `powermetrics.<ts>.log` so the pre-crash log is
+ preserved) when passwordless `powermetrics` is configured (see the incident
+ record for the sudoers rule).
**What to do / how to investigate**: see the full incident record and checklist in
[`docs/research/2026-06-13-mflux-training-watchdog-panic.md`](research/2026-06-13-mflux-training-watchdog-panic.md).
-Short version: read the run's `powermetrics.log` (climbing GPU temp → cooling/power;
+Short version: read the run's newest `powermetrics*.log` (climbing GPU temp → cooling/power;
log just stops at normal temps → driver hang), reduce batch size/resolution/rank as
a test, and update macOS + `mflux`/`mlx`.
diff --git a/docs/research/2026-06-13-mflux-training-watchdog-panic.md b/docs/research/2026-06-13-mflux-training-watchdog-panic.md
index 3f8d281d5b..e1e383d59c 100644
--- a/docs/research/2026-06-13-mflux-training-watchdog-panic.md
+++ b/docs/research/2026-06-13-mflux-training-watchdog-panic.md
@@ -81,7 +81,9 @@ Without this the sidecar simply skips capture — training is unaffected.
## If it recurs — investigation checklist
-1. **Read the telemetry.** Open `<run>/powermetrics.log` from the crashed run.
+1. **Read the telemetry.** Open the newest `<run>/powermetrics*.log` from the
+ crashed run (a resume rolls the prior log to a timestamped name, so the
+ pre-crash capture is the one with the highest timestamp / matching the run).
- GPU die temp climbing toward ~100°C / SMC throttle flags set right before
the gap → **thermal/power**. Improve cooling, ensure high-watt AC adapter,
reduce load.
diff --git a/scripts/train_mflux_lora.py b/scripts/train_mflux_lora.py
index 0f6102d8f4..702fb43eb3 100644
--- a/scripts/train_mflux_lora.py
+++ b/scripts/train_mflux_lora.py
@@ -38,6 +38,7 @@ import sys
import threading
import zipfile
from collections import deque
+from datetime import datetime
from pathlib import Path
CHILD = None
@@ -193,29 +194,44 @@ class TelemetrySidecar:
hang. This streams `powermetrics` into <output_dir>/powermetrics.log so a
post-crash investigation can tell a thermal/power fault from a driver hang.
- powermetrics requires root. We gate on a *non-interactive* `sudo -n` probe:
- if passwordless sudo isn't configured the sidecar no-ops with a single
- STATUS note and training proceeds unaffected — it never prompts or blocks.
+ powermetrics requires root. We gate on a *non-interactive* `sudo -n -l`
+ probe of powermetrics specifically: if passwordless sudo for that command
+ isn't configured the sidecar no-ops with a single STATUS note and training
+ proceeds unaffected — it never prompts or blocks.
"""
SAMPLE_INTERVAL_MS = 5000
def __init__(self, output_dir: Path):
- self.log_path = output_dir / "powermetrics.log"
+ # Don't clobber a prior run's telemetry on resume — the post-crash
+ # investigation reads it from this dir, and `powermetrics --output-file`
+ # truncates. Roll to a timestamped name when the default already exists
+ # so each launch keeps its own forensic log.
+ base = output_dir / "powermetrics.log"
+ if base.exists():
+ base = output_dir / f"powermetrics.{datetime.now():%Y%m%d_%H%M%S}.log"
+ self.log_path = base
self.proc = None
def start(self):
- if sys.platform != "darwin" or not shutil.which("powermetrics"):
+ if sys.platform != "darwin":
return
- # `sudo -n true` returns non-zero (and prints nothing usable) when a
- # password would be required — cheaper than letting powermetrics fail.
- probe = subprocess.run(["sudo", "-n", "true"], capture_output=True)
+ pm = shutil.which("powermetrics")
+ if not pm:
+ return
+ # Probe whether *powermetrics specifically* is permitted under
+ # passwordless sudo. The documented sudoers rule grants NOPASSWD for
+ # powermetrics only, so a generic `sudo -n true` probe (which runs
+ # /usr/bin/true) would fail for exactly the users who configured it
+ # correctly. `sudo -n -l <cmd>` lists the permission without running
+ # powermetrics and without prompting; non-zero means not allowed.
+ probe = subprocess.run(["sudo", "-n", "-l", pm], capture_output=True)
if probe.returncode != 0:
log("STATUS:GPU telemetry disabled — passwordless sudo for powermetrics not configured; "
"see docs/TROUBLESHOOTING.md to enable thermal/power capture. Continuing without it.")
return
cmd = [
- "sudo", "-n", "powermetrics",
+ "sudo", "-n", pm,
"--samplers", "gpu_power,thermal,smc",
"-i", str(self.SAMPLE_INTERVAL_MS),
"--output-file", str(self.log_path),