Skip to content

Android: a quick seed's snapshot is saved again from an idle copy, and copies and deletions take turns #1748

Done

Description

@V3RON

Part of #1732.

Scope

An Android worker (macOS, Linux and Windows) settles its quick seeds in the background: after a kind's first lease, once the worker is quiet, the seed's simlock_boot is saved again from an idle copy that has a default network (#1631), and later Android leases boot with almost no post-boot work. A seed's copies and its deletion take turns, so no copy is made from a folder being deleted.

If this goes wrong, a user would notice an Android lease waiting behind a settle, a copy that fails because its seed folder vanished, or an emulator left running after a restart mid-settle.

Technical spec

Commit fb42676.

Rows

  • Behaviours: B18, B19, B20, B21, B22
  • Stored state: S3, S4
  • Interfaces: I1, I2, I3, I10, I11 (implements or uses)
  • Existing code: X8, X9, X10, X11

Facts

# Fact Source
F1 android_source_data has a unique index on spec_key for ready seeds, and its schema owner is at version 2 src/drivers/android/source-data.ts:29-33
F2 provision finds the seed under seed:<spec key> and copies it after the lock is let go src/drivers/android/seeds.ts:439-455
F3 withLock is a per-id promise chain with no time limit src/drivers/android/device-table.ts:84-96
F4 A lease boots a copy with -snapshot simlock_boot on a reserved console port src/drivers/android/index.ts:631-632
F5 The snapshot save is emu avd snapshot save simlock_boot, checked with snapshot list src/drivers/android/seeds.ts:663-685
F6 A snapshot saved before the guest has a default network restores offline; one saved with it restores online at ready #1631 (13 of 13 leases offline); measured here on Android 36 google_apis, emulator 37.2.13 (3 of 3 restores online, ping 8.8.8.8 at ready)
F7 ConnectivityService logs Sending CONNECTED broadcast for type <n> [<id> <transport>] isDefaultNetwork=true at debug level when it picks a default network; logcat -e matches the message only, not the tag, so the tag goes in the filter spec measured on Android 36; -e 'ConnectivityService.*…' never matched
F8 Before that, dumpsys connectivity prints Active default network: none; after it, Active default network: <netId> measured on Android 36

Modules touched

Searches: android_source_data, findReadySeed, #copySeed, #removeSource, #removeSeed, destroySource, destroySeedsOf, #sweepLeftovers, withReservedPort, currentConfigHash. Files: src/drivers/android/seeds.ts, source-data.ts, index.ts, the driver's AGENTS.md, and the Android create options in src/daemon/driver-discovery.ts (the processTable #1746 adds to the context).

Rules in play

  • android manual "Seeds and copies": "A seed is never leased or booted after its snapshot save" holds for the seed; the copy boots (ADR 0090 §3); the manual line is reworded to say so.
  • android manual "Boot": the copy boots with -snapshot simlock_boot, -no-snapshot-save and the leases' launch flags; the save is the explicit snapshot save.
  • android manual "One make per kind at a time": the settle holds seed:<spec key> only for the check and the swap.
  • android manual "Containment": every call carries the copy's ANDROID_AVD_HOME and Simlock's adb port; an emulator is stopped only after emu avd path names its folder.
  • ADR 0090 §3: the swap is one transaction; the old folder is deleted once its copies end.
  • Android: android.emulator.cores sets the cores of new emulators and baselines #1740: a settle copy boots with the launch settings a lease copy gets once Android: android.emulator.cores sets the cores of new emulators and baselines #1740 lands (its android.emulator.cores written before the boot), so the new seed's config hash matches what a provision checks.

Tests

Driven through AndroidDriver with the fake emulator host of src/drivers/android/test-seed-harness.ts, modelled on src/drivers/android/seeds-copies.test.ts.

  • B18: a plain lease adds one to its seed's lease count: plain provision; a baseline copy; a copy that fails; a seed from before this feature; a first lease of a new kind
  • B19: settleSeed saves an idle copy's snapshot as the seed: idle at 181 s; idle with no default network yet (waits for the listener, then saves); listener never fires but dumpsys connectivity shows a default network (saved); no default network by the cap (saved); idle only at the cap; busy at the cap; a provision of the kind meanwhile; snapshot not listed; emulator exits early; aborted; not a ready quick seed; win32 readings
  • B20: copies and deletions take turns: stale remake, destroySource, destroySeedsOf and a settle's swap during a copy; a copy asked for after a deletion began; two deletions of one seed at once run one after the other (decided in delivery, pending the maintainer)
  • B21: a restart's leftovers of a settle are swept: another process's settle row; a retired quick seed's row; a make during this process's settle
  • B22: ensureSeed: fresh; stale; none; two calls at once

Done when

  • pnpm test:changed passes, with the B18 to B22 cases above.
  • pnpm typecheck passes.
  • The Android driver manual's Seeds rules say what a settle does and that copies and deletions take turns.
  • On a Mac with an Android SDK, scripts/slow-e2e.sh e2e/slow-android-smoke.test.ts passes.
  • On a Mac with an Android SDK, a lease of a kind whose seed was settled has Active default network: <number> in dumpsys connectivity when simlock lease returns (Android: boot snapshot is saved before the cellular data call is up, so every lease starts offline #1631).
  • B19's win32 case parses a Get-CimInstance Win32_Process answer captured on a real Windows host and checked in as its fixture; the PR says where it was captured.

Out of scope

Depends on

Written by an agent.

Activity

  1. added
    task:draft
    on Nov 19, 2026
  2. added
    task:ready
    and removed
    task:draft
    on Nov 19, 2026
  3. github-actions commented on Nov 23, 2026

    @github-actions
    Contributor

    Claim released: no activity for 3 days. The label is unchanged; the next agent starts from the branch and the last handoff.

  4. self-assigned this
    on Nov 24, 2026
  5. 17 remaining items

  6. added
    task:blocked
    and removed
    task:ready
    on Nov 24, 2026
  7. removed their assignment
    on Nov 24, 2026
  8. added
    task:ready
    and removed
    task:blocked
    on Nov 25, 2026
  9. self-assigned this
    on Nov 25, 2026
  10. added
    task:draft
    and removed
    task:ready
    on Nov 25, 2026
  11. github-actions commented on Nov 25, 2026

    @github-actions
    Contributor

    Back to task:draft: .agents/scripts/spec-lint.mjs found blocking lines. Fix them in the body, then set task:ready again.

    B 1748 Done when: "On a Mac with an Android SDK, a lease of a kind whose seed w…" needs the slow lane but names no `e2e/slow-*.test.ts`; name it
    
  12. added
    task:ready
    and removed
    task:draft
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

task:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions