# Next Session: Router Monitoring — Scheduler Bug + Deco Visibility

## What Was Done (Session 389)

### Deferred Items Completed
1. **Loguru format strings**: 18 `%s`→`{}` fixes across agent_scheduler, agent_context, cost_tracker. Logs now show actual values.
2. **SMS sanitization**: `_sanitize_sms()` strips shell metacharacters for SSH→ADB transit. 9 tests.
3. **Lazy router sessions**: File-only queries skip router connection. Saves ~1-2s per call.
4. **Observability flush loop**: `start_flush_loop()` added to server.py — agent events no longer silently dropped.

### Verified
- **Agent model routing**: Triggered `proactive-triage` → log confirms `model=nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4` (Beast Super).
- **Bypass timing**: `classify_network_query()` correctly classifies all query types. Saves one LLM call (~7-10s per network query).

### Deployed
Commit `4d40032`. 2446 tests, 0 failures. Annie restarted on Titan.

## What Needs Doing

### Priority 1: Scheduler Anchor-Resume Bug
The "every" scheduler with anchors doesn't resume mid-day after a restart. When Annie restarts at 11:12 and the anchor is "06:00 IST" with 15m interval, `_compute_first_run()` sets `next_run = tomorrow 06:00` instead of the next 15-minute mark.

**Fix**: In `agent_scheduler.py:_compute_first_run()` (line 138), after computing `anchor_today`, advance by interval steps until past `now`:
```python
# Instead of jumping to tomorrow when anchor has passed:
while self.next_run <= now:
    self.next_run += self.interval_s
```

This is ~5 lines. Affects `proactive-triage` (15m), `network_anomaly_detector` (6h), `router_daily_report` (24h), `meditation_daily` (24h).

### Priority 2: Deco Device Visibility
ASUS router only sees 3 devices (Deco/R15/D-Link). All servers behind Deco are invisible.

**Options** (pick one):
- **Query Deco API**: `tplinkdeco` Python lib can list clients. Add as a secondary data source in `router_monitor.py`.
- **Deco AP mode**: Eliminates double-NAT. All devices visible to ASUS directly. Requires network reconfiguration (Deco gets IP from ASUS, DHCP moves to ASUS).
- **vnstat-only**: Already implemented for bandwidth. Accept that ASUS can't see individual devices.

### Priority 3: Observability Token
`CONTEXT_ENGINE_TOKEN` not in Annie's .env. Events queue but can't POST to context engine. Either:
- Add to Annie's `.env` on Titan
- Or pass via `start.sh` (already done for SSH-launched instances, but manual restarts miss it)

### Priority 4: Reconnect Downstairs Devices
New WiFi password `mango-tiger-92-pixel` needs to be set on devices connected to the 3rd router (downstairs D-Link).

## Key Files
| File | What |
|------|------|
| `services/annie-voice/agent_scheduler.py:138` | `_compute_first_run()` — anchor-resume bug |
| `services/annie-voice/router_monitor.py:644` | `_sanitize_sms()` + `send_sms_alert()` |
| `services/annie-voice/router_monitor.py:940` | `router_status()` with lazy sessions |
| `services/annie-voice/server.py:158` | Observability flush loop startup |

## First Commands
```bash
# Check Annie is running + agent model in logs
ssh titan "pgrep -af server.py && grep 'Agent.*complete.*model' /tmp/annie-voice.log | tail -3"

# Check collector health
ssh titan "tail -3 ~/.her-os/annie/router/collector.log"

# Check cost tracker for Beast model entries
ssh titan "cat ~/.her-os/annie/cost/daily-$(date +%Y-%m-%d).json | python3 -m json.tool"
```

## Prompt
Continue router monitoring from `docs/NEXT-SESSION-ROUTER-ALERTS-4.md`. Session 389 completed deferred items (loguru fix, SMS sanitization, lazy sessions, observability). Priority 1: fix scheduler anchor-resume bug so "every" schedules fire correctly after mid-day restart.
