# Handoff notes Dated notes for picking this project back up: what happened, what was learned, and which threads are still open. AGENTS.md carries the distilled rules; this file carries the history behind them. ## 2026-11-05 — false-lock debugging session **Symptoms.** The daemon flipped Present⇄Suspect every minute or so and locked the screen three times in ~20 minutes while the phone sat on the desk at -44..-65 dBm (rssi_lock is -80). **Root causes, in order of discovery:** 1. *Duty math*: at the Present duty cycle (100ms window / 5s interval, ~2% radio), the ~1 Hz beacon was only caught every ~25-50s — at or beyond `presence_timeout_secs` (30). Journal showed Present stretches of 46s/71s/45s, then a Suspect flip the moment a 30s gap appeared. 2. *BlueZ RSSI dedupe*: `device_set_rssi()` early-returns when the value is unchanged, so a stationary phone's event stream goes fully silent (with `DuplicateData = true` and regardless of duty cycle). Silence for `missing_after_secs` (60) → lock, e.g. 14:36:56 and 14:39:07, both exactly 60s after the last event. 3. *Beacon pauses*: the phone's beacon app stops advertising entirely for 60-90s+ stretches (doze / battery optimization). During a pause the phone is undetectable *and* unconnectable — this is why the first 3s connect probe failed at 14:49:56 while the phone was in range. **Fixes shipped:** - `policy.rs`: Present escalates to the Suspect duty once the last sighting ages past half of `presence_timeout_secs`, without leaving Present (kills the flapping; freshness restored within seconds). - `bluez.rs`: pre-lock connect probe (`probe_reachable`), now 10s; a successful connection cancels the lock and returns to Present. Probe outcomes are logged at INFO/WARN — every lock decision is now explainable from the journal. - Config guidance: `missing_after_secs = 120` (sample config and local config) so a lock requires the phone to be silent *and* unconnectable for 130s straight. **Decision: stay scan-only.** The alternative — a persistent LE connection held by the daemon (presence = link, immune to advertising pauses, ~zero desktop scanning while connected) — was tested and is viable: a manual connection held 60s+ through a silent stretch and the daemon stayed Present with no scanning. It remains the guaranteed fix if false locks recur. Watch out if adopting it: connecting to a dual-mode phone registers the PC as an audio device on the phone (A2DP SEPs show up), and the phone battery profile changes (probably better than 1 Hz advertising, but unverified). **Verification notes.** `bluetoothctl connect ` is a quick manual oracle for "is the phone connectable right now". Probe behaviour at INFO: `probe: no connection within 10s, treating phone as out of range` vs `probe: connect rejected: ...`; success logs `connect probe: phone in range, not locking`. **Open threads:** - If false locks recur despite 120s + 10s probe: check the journal for the probe outcome line, then reconsider the persistent connection. - AdvertisementMonitor (README roadmap) removes the RSSI-dedupe class of problems at the controller level; needs BlueZ ≥ 5.65 and `Experimental = true`. - v2 unlock (GATT + biometric-signed nonce, see README) — the probe and the persistent-connection findings are groundwork for that design. - MSRV/toolchain: project pins `rust-version = "1.85"` so Ubuntu 24.04 and 26.04 build identically; Cargo.lock is committed.