testsAndMisc/docs/superpowers/evidence/phone-lease-2026-09-20.json
Krzysztof kuhy Rudnicki b7e537fe01
Some checks failed
dependency freshness / dependencies on newest stable (push) Has been cancelled
md-naming / markdown naming convention (push) Has been cancelled
Pre-commit checks / pre-commit (push) Has been cancelled
Python tests / test (push) Has been cancelled
Shell tests / shell-tests (push) Has been cancelled
Shell tests / arch-tests (push) Has been cancelled
phone_lease: one session drives the phone at a time; android_ui takes the lease on every call
Two sessions driving the same phone interleave their taps: on 2026-09-20 a
tap meant for the workout sandbox opened another session's manga reader,
twice. The lease is a flock-guarded JSON file per serial under
~/.cache/phone-lease/, owned by the nearest ancestor `claude` process (one per
session), refreshed on every android_ui call and expiring 180 s after the
last one, so a quiet session frees the phone without anyone remembering to.
A foreign fresh lease makes a call wait up to 60 s, then exit 3 naming the
holder and pointing at the alternatives (the phone's virtual display, the
headless emulator) instead of inviting a retry loop. phone_deploy.sh takes
the same lease (exit 40).

The oldest evidence artifact is pruned to stay under the 60-file cap; it
remains in history.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YbBZqUaNWyhHYfzz6zGC7q
2026-09-20 18:50:26 +02:00

34 lines
1.9 KiB
JSON

{
"intent": "Two Claude sessions can no longer drive the phone at the same time: every android_ui call and every phone_deploy.sh run takes a per-serial lease owned by the session, and a foreign holder is refused by name with the alternatives spelled out.",
"scope": [
"python_pkg/phone_lease (new): lease file, owner identity, acquire/release/status, CLI",
"python_pkg/android_ui/cli.py: acquire the lease before every command (exit 3 when held elsewhere)",
"Non-goal: parallel driving of one screen; that is what the virtual display / emulator scripts in ~/.claude/scripts are for"
],
"changes": [
"flock-guarded JSON lease per serial under ~/.cache/phone-lease/, 180 s TTL refreshed on every call",
"owner = nearest ancestor `claude` process (one per session); PHONE_LEASE_OWNER overrides",
"android_ui main() refuses with exit 3 and the holder's name; phone_deploy.sh exits 40"
],
"verification": [
{
"command": "pre-commit run --files python_pkg/phone_lease/... python_pkg/android_ui/...",
"result": "pass",
"evidence": "all hooks passed; python_pkg 1886 passed, 100% line+branch coverage"
},
{
"command": "python3 -m python_pkg.android_ui -s 23181JEGR08034 focus; PHONE_LEASE_OWNER=other python3 -m python_pkg.android_ui -s 23181JEGR08034 focus",
"result": "pass",
"evidence": "first call refreshed claude:4102845's lease; the foreign call waited 60 s and exited 3: 'phone 23181JEGR08034 held by claude:4102845 (android_ui focus) until 17:32:00'"
}
],
"risks": [
"A session that keeps calling android_ui holds the phone indefinitely (by design); `python3 -m python_pkg.phone_lease release <serial>` drops it",
"Raw adb use bypasses the lease; only the sanctioned tools take it"
],
"rollback": [
"Revert this commit; android_ui returns to lease-free operation",
"Validate: python3 -m python_pkg.android_ui focus runs without touching ~/.cache/phone-lease"
]
}