Skip to content

fix(android): serialize Android-only teardown under the session lock - #325

Merged
ElbertePlinio merged 5 commits into
mainfrom
fix/321-android-teardown-lock
Oct 9, 2026
Merged

ElbertePlinio merged 5 commits into
mainfrom
fix/321-android-teardown-lock

Conversation

@ElbertePlinio

@ElbertePlinio ElbertePlinio commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Closes #321

Android-only teardown now runs its emulator stop, log retention and finalize under the per-session lock, as desktop and browser teardown already do. To make the lock reachable from Android, withSessionVncLock moved from desktop-linux into @pickforge/lab-core (session-lock.ts) and is exported there. Desktop-linux re-exports it, so its public API is unchanged. The lock file name and path are unchanged, so all teardown paths share one lock per session. The desktop+android path does not take the lock again, because it runs inside the desktop lock and the lock is not reentrant.

API changes, approved by the owner: core now exports withSessionVncLock, SessionVncLockOptions and SESSION_VNC_LOCK_TIMEOUT_MS. teardownAndroidSession and destroyAndroidSession take an optional last options argument that passes an abort signal to the lock wait.

Requirement Verified by Scenario Result Evidence
Serialize Android-only teardown and retention per session Automated test Two concurrent destroys of one session: one succeeds, the other rejects with "not found", the emulator stops once, one stopped.json remains, no lock files remain Pass; both destroys run in full without the lock packages/android/test/reaper.test.ts
No deadlock on the desktop+android path Automated test Duo Android leg runs inside the real desktop lock Pass; times out if the lock is taken again same
Lock behavior unchanged after the move Automated tests Shared lock file name and release, waiting with a live signal, aborted signal skips the operation, aborted wait leaves the session intact Pass packages/core/test/session-lock.test.ts, desktop-linux tests
Abort reaches the lock wait Code check Reapers in android, CLI and MCP, and MCP destroy, pass their signal Wired diff
Review fix: refuse non-Android records Automated test A browser record passed to Android teardown is refused, not finalized, and kept Pass packages/android/test/reaper.test.ts, Fable recheck
Repo checks Automated build, lint, typecheck, PICKFORGE_REQUIRE_BROWSER=1 coverage: 3080 passed, 6 skipped at e40d917; at 7045cd3 three load timeouts in unrelated desktop and CLI files passed 83 of 83 on rerun Pass worker-report-321.md
PickCheck Automated --base origin/main --fail-on new,worsened,unmatched: 63 functions, 0 violations Pass worker-report-321.md

Evidence is in ~/Artifacts/pickforge-batch6-2026-10-09/ on the build host.

No device pass: this changes internal teardown locking with nothing to drive, and the tests cover it.

Follow-up: #326 (session lock errors mention VNC for Android teardown).

withSessionVncLock, SessionVncLockOptions and SESSION_VNC_LOCK_TIMEOUT_MS
now live in lab-core so Android teardown can share them. The lock file
path and behavior are unchanged, and lab-desktop-linux re-exports them.

Refs #321
A reaper teardown and a user destroy of one Android session could stop
the emulator and retain logs at the same time. Android-only teardown now
runs the stop, log retention and finalize inside the session lock and
re-reads the record there. The desktop+android leg already runs inside
the desktop lock, so it does not take the lock again. Reapers and MCP
destroy pass their abort signal to the lock wait.

Closes #321
@ElbertePlinio
ElbertePlinio merged commit 174fdec into main Oct 9, 2026
10 checks passed
@ElbertePlinio
ElbertePlinio deleted the fix/321-android-teardown-lock branch October 9, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

android: serialize teardown and log retention per session

1 participant