Skip to content

feat(android): opt-in bounded guest readiness before launch or install - #107

Merged
ElbertePlinio merged 2 commits into
mainfrom
fix/105-android-guest-readiness
Sep 5, 2026
Merged

ElbertePlinio merged 2 commits into
mainfrom
fix/105-android-guest-readiness

Conversation

@ElbertePlinio

@ElbertePlinio ElbertePlinio commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Opt-in bounded guest readiness for android install-apk / android launch-app and the matching MCP tools. Default off. Uses lowmemorykiller quiet as the signal from #101, reports each probe as progress, and fails with guest-not-ready without starting the action if the bound is hit. Pickforge still does not retry a launch the guest drops.

Rebased onto main 3adf3a9 (#108). Review fixes from review-pr107.md are in 8ec5cb9.

What this does

  • --wait-ready <seconds> on the CLI; waitReadySeconds on MCP android_install_apk and android_launch_app. 0 or omitted is no wait on both.
  • Quiet means no lowmemorykiller: Kill line for 30 s (logcat -d -v epoch -s lowmemorykiller:I against the guest clock). lmkQuietS is null when the buffer has no kill.
  • Unreadable guest clock or logcat is a typed guest-not-ready ("guest clock or logcat unreadable"), not "still killing".
  • MCP cancellation is honoured (aborted); install/launch never starts after a cancel.
  • Each adb probe timeout and the wait itself are clamped to the remaining wall-clock bound.
  • --wait-ready is validated before session lookup.

What this does not do

Provisioning pickforge-avd with more RAM and a settled first snapshot is #106. It is not deterministic without a measured 3–4 GB trial, and it would not be non-destructive to existing AVDs. picklab-avd is untouched. Disabling Play Protect stays an operator choice.

#105 body now strikes item 2 (pointer to #106) and checklists 1 and 3 as what this PR closes. Default callers still have no wait; the kill itself is not gone.

Tests

  • Deterministic unit tests for parse, wait, fail-closed, default-off, chatter behind 2000+ lines, hung-adb clamp, abort, unreadable probe, CLI, and MCP.
  • Live integration test logs guest pressure then calls waitForGuestReady.
  • Isolated emulator pass on a btrfs reflink clone of picklab-avd (not the real AVD). Script: ~/Projects/Boards/pickforge/0.4-release/android-readiness/run-isolated-pass.sh.

First evidence run (failed, preserved)

~/Projects/Boards/pickforge/0.4-release/android-readiness/first-run-failed/. Inject used parentheses, so logcat had no kill; --wait-ready 1 launched; --wait-ready 90 returned in 65/86 ms with lmkQuietS: null; session destroy --project-dir failed; isolated adb 5147 was left running; checksums predated the manual repair. Diagnosis: first-run-failed/DIAGNOSIS.md.

Scripted rerun

Clone /var/tmp/pf-android-lab/ready-QbX4e7, session andr-de2ae788. Inject verified with the product tag filter. Negative --wait-ready 1 failed closed with guest-not-ready and did not start the action. Positive --wait-ready 90 install waited 28156 ms (lmkQuietS: 31). Launch pid 11553, counter 0 → 1 → 2, independent vision PASS. Destroy via session destroy <id> --json (no --project-dir). Isolated adb 5147 closed. Real ~/.android hashes identical. Report: ~/Projects/Boards/pickforge/0.4-release/android-readiness/.

Gates

bun run typecheck, bun run lint, complexity-gate check on touched files, bun run test (112 files, 1420 passed, 4 skipped), bun run test:coverage (84.98 / 86.81 / 91.18 / 84.98, thresholds unchanged), bun run build.

Closes #105
Refs #93
Refs #101
Refs #106

Wait until guest lowmemorykiller is quiet before android install-apk or
launch-app when --wait-ready / waitReadySeconds is set. Default off.
Fail with guest-not-ready without starting the action; do not retry.
Replace the 2000-line logcat tail with lowmemorykiller tag filtering.
Honour MCP cancellation, return typed unreadable/aborted diagnostics,
clamp each probe to the remaining wall-clock bound, treat 0 as no-wait
on MCP, and validate --wait-ready before session lookup.
@ElbertePlinio
ElbertePlinio force-pushed the fix/105-android-guest-readiness branch from 938dd72 to 8ec5cb9 Compare September 5, 2026 07:09
@ElbertePlinio
ElbertePlinio merged commit 516d8ae into main Sep 5, 2026
10 checks passed
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: first launch of a fresh sideload after a quickboot restore is killed by lowmemorykiller on the 2 GB Play-image AVD

1 participant