# Next Session: Post-Scheduler Fix — Remaining Cleanup

## What Was Done (Session 390)

### Scheduler Anchor-Resume Bug Fixed (3 bugs in 1)
1. **`_compute_first_run()` rewritten**: Grid-aligned computation using `math.ceil(elapsed / interval)`. Cross-midnight handled by referencing yesterday's anchor (`anchor_ts -= 86400`).
2. **`advance()` cascade prevention**: Snaps forward to next grid point in O(1) after machine sleep. Prevents rapid-fire executions.
3. **Adversarial review** caught 2 critical bugs in the naive fix before implementation.
4. **6 new tests**: mid-day restart, cross-midnight, before-anchor, 24h daily, cascade prevention, non-anchored regression.

### Deployed + Verified
- Commit `9c86cf2`. Deployed to Titan. Annie restarted at 12:27 IST.
- `proactive-triage` fired at **12:30:00 IST** — the next 15-minute grid slot. Previously would have waited until 06:00 IST tomorrow.
- 2452 tests passing, 0 failures.

## What Needs Doing

### Priority 1: Fix remaining `%s` in proactive_pulse.py
Line 431 in `proactive_pulse.py` still has a loguru `%s` format string (`SKIP — %s`). Session 389 fixed 18 occurrences in agent_scheduler/agent_context/cost_tracker but missed proactive_pulse. Grep for `%s` across all annie-voice `.py` files to find any others.

```bash
grep -rn '%s' services/annie-voice/*.py | grep -v test | grep logger
```

### Priority 2: Set CONTEXT_ENGINE_TOKEN in Annie's .env
Observability events queue but can't POST to context engine because `CONTEXT_ENGINE_TOKEN` is not set. Check `~/.her-os-token` for the value, add to Annie's `.env` on Titan.

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

### Priority 4: Deco Device Visibility
ASUS router only sees 3 devices (Deco, R15, D-Link). All servers behind Deco are invisible. Options:
- **Query Deco API**: `tplinkdeco` Python lib can list clients
- **Deco AP mode**: Eliminates double-NAT, all devices visible to ASUS
- **vnstat-only**: Already have bandwidth per server, accept ASUS can't see individual devices

## Key Files
| File | What |
|------|------|
| `services/annie-voice/agent_scheduler.py:139-162` | Fixed `_compute_first_run()` |
| `services/annie-voice/agent_scheduler.py:134-143` | Fixed `advance()` cascade prevention |
| `services/annie-voice/proactive_pulse.py:431` | Remaining `%s` loguru bug |
| `services/annie-voice/server.py:158` | Observability flush loop |

## First Commands
```bash
# Check Annie is running + scheduler health
ssh titan "pgrep -af server.py && grep 'Firing job' /tmp/annie-voice.log | tail -5"

# Find all remaining %s in loguru calls
grep -rn '%s' services/annie-voice/*.py | grep -v test | grep logger

# Check observability token status
ssh titan "grep CONTEXT_ENGINE_TOKEN ~/workplace/her/her-os/services/annie-voice/.env"
```

## Prompt
Continue from `docs/NEXT-SESSION-ROUTER-ALERTS-5.md`. Session 390 fixed the scheduler anchor-resume bug and deployed. Priority 1: grep for remaining `%s` loguru format strings in annie-voice and fix them. Priority 2: set CONTEXT_ENGINE_TOKEN.
