Android backends: Redroid devices in Docker or Colima

オープン
#2,051 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
android, docker, typescript

調査の方向性

Start with the listed Android backend and driver discovery modules, then read ADR 0102 §6 and src/drivers/android/AGENTS.md for the ownership, retry and adb rules. Use ScriptedProcessRunner and the named lifecycle and driver discovery tests to cover the specified cases; run pnpm test:changed and pnpm typecheck. Done when the slow lane e2e/slow-android-redroid.test.ts passes with Colima and the run leaves no labelled containers.

索引モデルが issue の本文から書いたものです。

説明

platform:android task:ready

Part of #2041.

Scope

An operator adds redroid to android.virtualDevices, points simlock at a Docker engine (android.redroid.context for Colima, or host), and an agent leases a Redroid device with --requires redroid and an installed image: simlock creates a labelled privileged container on a fixed loopback port, waits for the boot, and the agent gets 127.0.0.1:<port> with adb, the console's screen stream, input and reverse tunnels. The device keeps its serial across recovery and daemon restarts; the backend retries an engine that is not up yet, goes back to retrying when the engine stops, and its orphans are listed by doctor.

If it goes wrong, a Redroid lease hangs or times out, a container is left running after its lease, or the agent's serial stops answering mid-lease.

Technical spec

Commit b037ae2a0.

Rows
  • Behaviours: B32, B12, B36, B33, B13, B14, B15, B16, B31, B17, B18, B19, B29, B39
  • Stored state: S3, S4
  • Interfaces: I7, I8, I9, I10, I15
  • Existing code: X6, X7, X8, X10, X11, X19, X21, X33, X38, X39, X40, X41, X42, X43, X44, X52
Facts
# Fact Source
F1 The slow lane runs a named test file with scripts/slow-e2e.sh <test files>; e2e/slow-android-smoke.test.ts is the Android model docs/internal/agent-rules/toolchain.md:224; ls e2e/slow-android-smoke.test.ts
F2 The pinned images 31, 33, 34 and 35 boot on Colima and answer pm path android; a restart boots again when the readiness loop reconnects adb /private/tmp/claude-501/redroid-design/facts12.log (2026-12-02); cited by the parent's I9 and B15
F3 An installed image reads docker image inspect redroid/redroid:<tag> --format '{{.Id}} {{.Size}}' → sha256:0a61… 674553971; an absent one exits 1 Error response from daemon: No such image: …; findComponent/listComponents (src/core/driver.ts:303,316) map to it (I7) /private/tmp/claude-501/redroid-design/facts13.log (2026-12-02)
Modules touched

New src/drivers/android/redroid/ (definition.ts, the backend, Docker CLI calls, port allocator, device data table), src/drivers/android/backends.ts (one line), src/driver-registry/index.ts (one line), src/drivers/android/index.ts (adb server kept at dispose, B29), src/drivers/android/profiles/index.ts, src/drivers/android/device-tcp.ts and src/core/device-tcp.ts and its caller src/tunnel/sessions.ts:429-432, which passes the backend (emulatorPort refused, B17), src/core/driver.ts (saveRefusal, I10), src/core/fake-driver.ts (B19's seam), src/core/baselines.ts (save refusal), src/daemon/driver-discovery.ts (onBackendStarted bridge), new src/daemon/backend-start-sink.ts, src/daemon/worker-composition.ts, new e2e/slow-android-redroid.test.ts. Searches: rg "saveSource|ScreenTarget|emulatorAttached|onSlimmed" src.

Rules in play
  • ADR 0102 §6 and the port, retry and engine-stop rules: Accepted — not yet implemented; the parent's rows hold the shapes.
  • ADR 0001 (as applied by the parent): ownership is the container's labels, never its name; only doctor --purge-orphans destroys what the registry does not hold.
  • ADR 0061 §4: Redroid refuses baseline save before the lease ends (I10).
  • ADR 0022 §5 and src/drivers/android/AGENTS.md: Redroid serials live on simlock's adb server, never 5037; the server is kept while a Redroid serial is connected.
  • src/ports/AGENTS.md: every docker and adb call through ProcessRunner with its timeoutMs (I7, I8).
  • docs/internal/VENDORED-CODE.md and ADR 0102 §6: simlock pulls redroid/redroid at run time and ships no image.
Tests

Seam: each row's Seam cell in #2041, the Redroid backend over ScriptedProcessRunner (src/ports/scripted-process-runner.ts:51) answering the captured replies of I7 and I8; model on src/drivers/android/index-lifecycle.test.ts and src/daemon/driver-discovery.test.ts.

  • B32: With the real backend registry the config loader accepts ["avd", "redroid"], ["redroid", "avd"] and ["redroid"], and refuses an unknown id naming avd, redroid.: the Examples rows naming redroid; ["docker"] → expected a backend this worker knows (avd, redroid), not "docker"
  • B12: The operator lists redroid; the platform driver starts the Redroid backend when the engine answers as Linux. Otherwise it skips it with driver.backend-rejected naming why, checks again every 30 s, and starts it with driver.backend-started when the engine answers.: engine Linux arm64 → starts; docker not found; context not found; engine unreachable; engine not Linux; unreachable then answering after one 30 s tick → started, event once; the same reason twice → one event; config with both android.redroid.context and host → refused with the I9 message (config loader)
  • B36: A running Redroid backend whose engine stops goes back to not running: the 30 s engine check (B12's timer, always on) or a failed docker ps in listManaged (health monitor, src/leasing/lease-health-monitor.ts:187) emits driver.backend-rejected engine-unreachable; redroid leaves virtualTags; its devices are unreadable (I14), leases run to their TTL; when the engine answers, driver.backend-started, and a stopped container boots again at its port (B15).: docker info fails → one event, tag gone, --requires redroid → CAPABILITY_MISSING, held lease kept; that lease ends while the engine is down → device stays reclaiming, not quarantined, keeps its slot, reclaimed on driver.backend-started (B38, B39); answering after one tick → started, devices listed; container exited on return → recovered at the same port; docker ps fails between ticks → down at once; two failed ticks → one event
  • B33: Redroid's resolveSpec with an image tag: a tag the request names is refused; the worker's default tag finds nothing, so the resolver's default-tag attempt falls through (src/leasing/acquisition-spec-resolver.ts:97).: imageTag: "google_apis" → BAD_REQUEST android lease requests do not take an image tag on redroid; defaultTag: true → RuntimeMissingError with no component and downloadable: false; no tag, redroid-34 installed → spec 34
  • B13: An agent leases Redroid: simlock takes a free port of the range, creates a labelled container, starts it, connects adb on simlock's server and waits for boot (I7, I8), then grants serial 127.0.0.1:<port>.: success; a port taken by another program (loopback probe answers) → next port; a port another instance's container holds (label) → next port; range full → provision failure No free Redroid port in 5700-5799; adb connect prints failed to connect (exit 0) then succeeds; device offline while booting; the readiness loop re-issues adb connect 127.0.0.1:<port> before every getprop poll (facts12.log; facts4.log's lasting device offline came from not reconnecting); sys.boot_completed never 1 within android.bootTimeoutMs → boot failure, container removed; container exits during boot (docker inspect state exited) → failure naming the exit code; the engine refuses the port at start (port is already allocated) → boot failure; name clash on create (Conflict) → provision failure
  • B14: A Redroid lease ends: simlock disconnects adb, stops the container and removes it; the next lease's device has none of the first's data.: stop then remove; remove of a container already gone (docker rm -f exits 0, prints nothing) → done; docker stop of a missing container → treated gone; second lease: /data/local/tmp/m written by the first is absent
  • B15: A Redroid device booted again (health recovery, or after the engine or the daemon restarted) answers at the serial it was granted.: port 5701 before stop and after start (captured in I7); the stored port reused, never read back; address returned equals the stored one; docker stop -t 2 (exit 137) then docker start → the reconnecting readiness loop of B13 sees sys.boot_completed 1, with or without an adb disconnect first (facts12.log, 6 s and 7 s)
  • B16: After a daemon restart the Redroid backend lists the containers labelled with this instance and connects adb to the running ones; doctor lists a labelled container no record names, and doctor --purge-orphans removes it.: running container with a record → connected, running; stopped container → stopped; record whose container is gone → missing; container of another instance → not listed; orphan → finding, purged only with --purge-orphans
  • B31: The health monitor sees a Redroid device as running only when its container runs and its serial is a device on simlock's server; a running container whose serial dropped off is connected again in the listing.: container running, serial device → running; serial absent, connect succeeds → running; connect fails → stopped (the monitor recovers it after health.stableObservations); serial offline → transitioning
  • B17: A Redroid lease's commands, screen, input and tunnels work through simlock's adb server: the lease environment names the server port; passthrough is scoped to the serial and refuses emu; the screen and input use the same target as an emulator's; the emulatorPort tunnel is refused.: adb shell runs; adb emu ... refused; adb -s <other serial> refused; console stream shows frames (slow lane); a tap through the input socket lands (slow lane); tunnel --emulator-port adb → TUNNEL_UNSUPPORTED emulator adb: the lease is on a Redroid device; emulator ports need an Android emulator; reverse tunnel works (slow lane)
  • B18: catalog.get on a worker with Redroid lists the phone and tablet library profiles and the API levels whose images are installed (I9).: image redroid-34 installed → runtime 34; none installed → no runtimes; TV, Wear, automotive and desktop profiles absent
  • B19: baseline save on a Redroid lease is refused before the lease ends (I10); the lease goes on.: Redroid lease → BAD_REQUEST, lease still held; emulator lease → saved as today
  • B29: At daemon stop the shared adb server is kept while any Redroid serial is connected, as while an emulator is attached, and adopted by the next start.: Redroid serial connected → server left; emulator attached → left as today; neither → stopped as today; adb devices unreadable → stopped as today
  • B39: A backend that starts calls the driver callback onBackendStarted(platform, backend); src/daemon/driver-discovery.ts bridges it, like onSlimmed (:209), to driver.backend-started and a BackendStartSink bound to core.resumeBackend (I17) after core.connect (earlier calls queue, run once after converge). What resumeBackend does is #2049's (B38).: callback → one event and one sink call; callback before the sink is bound → queued, run once after binding, never twice; a second start → nothing more; a Redroid lease ended while the engine was down → reclaimed after the engine returns (slow lane)

Done when

  • pnpm test:changed and pnpm typecheck pass; each Tests line above is a case table in one test, its fake replies taken from the parent's captured runs.
  • Slow lane, on a Mac with Colima and binder loaded: scripts/slow-e2e.sh e2e/slow-android-redroid.test.ts passes. Its setup pulls each image of the table with docker pull redroid/redroid:<tag> (component install arrives in #2052), boots each, leases with --requires redroid, drives adb, the screen stream, input and a reverse tunnel, restarts the daemon mid-lease and finds the same serial, and ends the lease with no container left. A tag that fails to boot is dropped from the table in this PR.
  • The same run leases an avd emulator beside a Redroid device on one worker.
  • docker ps -a --filter label=simlock.instance=<id> lists nothing after the slow-lane run.
  • The website pages updated in this PR (documentation rule 9): website/src/content/docs/docs/reference/configuration.mdx (android.redroid.*), .../reference/events.mdx (reasons), .../using-devices/run-commands.mdx and .../using-devices/tunnels.mdx (a 127.0.0.1:<port> serial; no emulatorPort tunnel on Redroid).

Out of scope

Redroid components (component install/list/remove), the doctor checks and the setup guide (#2052); baselines and warm-pool devices on Redroid; Windows hosts.

Depends on

  • #2050
  • #2049

Written by an agent.

主要言語
TypeScript
スター
730
フォーク
44
平均マージ
15時間 28分
マージ済み PR(30日)
387

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

callstackincubator/simlock のほかの issue

callstackincubator/simlock の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。