mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 22:47:02 +01:00
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
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
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
"""One phone, many Claude sessions: a lease that keeps them from colliding.
|
|
|
|
Two sessions driving the same phone interleave their taps -- on 2026-09-20 a
|
|
tap meant for the workout sandbox landed in another session's manga reader,
|
|
twice. This package hands the phone to one owner at a time:
|
|
|
|
* the lease is a JSON file per serial under ``~/.cache/phone-lease/``, guarded
|
|
by ``flock`` so read-modify-write is atomic across processes;
|
|
* the owner is the nearest ancestor ``claude`` process (one per session), so
|
|
every call from the same session refreshes the same lease and calls from
|
|
another session wait, then fail naming the holder;
|
|
* it expires ``ttl`` seconds after the last refresh, so a session that just
|
|
stops driving frees the phone without anyone remembering to release.
|
|
|
|
``android_ui`` takes the lease on every command and ``phone_deploy.sh`` on
|
|
every deploy, which is every path that touches the phone from a session.
|
|
"""
|
|
|
|
from python_pkg.phone_lease.lease import (
|
|
DEFAULT_TTL,
|
|
DEFAULT_WAIT,
|
|
Clock,
|
|
Lease,
|
|
PhoneBusyError,
|
|
acquire,
|
|
owner_id,
|
|
release,
|
|
status,
|
|
)
|
|
|
|
__all__ = [
|
|
"DEFAULT_TTL",
|
|
"DEFAULT_WAIT",
|
|
"Clock",
|
|
"Lease",
|
|
"PhoneBusyError",
|
|
"acquire",
|
|
"owner_id",
|
|
"release",
|
|
"status",
|
|
]
|