Android backends: one Android driver runs several backends, picked by tags and the operator's order

Đang mở
#2,050 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
30/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Start with the listed modules and the seam tests in #2041, especially src/drivers/android/index.ts, src/core/driver-catalog.test.ts, and src/daemon/driver-discovery.test.ts. Read the referenced ADRs and existing driver and catalog behavior, then run the specified tests, pnpm typecheck, and the contract and gateway checks. Done means every listed behavior and test case passes, existing android.virtualDevices configs still load, and the documented events and configuration are updated.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

platform:android task:ready

Part of #2041.

Scope

An operator lists Android backends in android.virtualDevices (true = ["avd"], false = phones only, or a list in routing order), and the one Android driver runs them side by side with the phones: a lease picks a backend by requires (--requires avd), else the first listed backend that can make it; catalog.get shows one merged Android entry with each backend's id as a tag; the gateway routes on those tags; seeds stay on avd; a backend taken off the list drains. Only avd and test backends exist, so a worker's behaviour changes only when its config lists more than one.

If it goes wrong, a plain Android lease lands on the wrong backend or is refused, phones stop being served, or an existing config stops loading.

Technical spec

Commit b037ae2a0.

Rows
  • Behaviours: B2, B3, B5, B6, B35, B37, B30, B7, B34, B8, B27, B11, B28
  • Interfaces: I2, I3, I4, I6, I16
  • Existing code: X1, X2, X16, X18, X19, X20, X22, X23, X24, X25, X26, X27, X28, X29, X30, X31, X32, X34, X35, X36, X37, X41, X45, X46, X47, X48, X49, X50, X51
Facts

none

Modules touched

src/drivers/android/index.ts (becomes the platform driver), new src/drivers/android/backend.ts and src/drivers/android/backends.ts, src/drivers/android/definition.ts, src/driver-registry/index.ts, src/core/driver-catalog.ts, src/core/config-validators.ts, src/core/doctor.ts (B37), src/daemon/dispatcher-capabilities.ts (I4 messages), src/drivers/android/sdk-paths.ts (X23), src/core/config-types.ts, src/core/startup-converger.ts, src/core/create-core.ts, src/core/physical-enrollment.ts, src/core/physical-auto-enrollment.ts, src/core/seed-settle/settler.ts, src/core/baselines.ts, src/core/warm-pool/learned.ts, src/leasing/acquisition-spec-resolver.ts, src/leasing/lease-acquisition-coordinator.ts, src/leasing/physical-device-watcher.ts, src/daemon/driver-discovery.ts, src/daemon/worker-composition.ts, src/daemon/dispatcher-leases.ts, src/daemon/dispatcher-status.ts, src/bus/index.ts (I6), src/contract/worker-view.ts, src/gateway/worker-link.ts, src/gateway/routing/stages/has-capabilities.ts, docs/internal/EVENTS.md. Searches: the parent's (drivers.get(, catalog.get(, listCatalog(, virtualDevices, virtualTags).

Rules in play
  • ADR 0102 §1, §3, §4, §5 and the drain and tag rules: Accepted — not yet implemented; the parent's rows hold the shapes.
  • ADR 0084 §1 (narrowed): android.virtualDevices widens; true and false keep their meaning, so existing configs load.
  • ADR 0092 §2 and §3 (narrowed): a backend id is a device tag; requires matching is unchanged.
  • ADR 0015 §5: a class or range request never installs (B34).
  • ADR 0065: backend settings are driver keys under android.*; core takes only the sections it reads.
  • ADR 0009 and 0026: the gateway's capability stage routes on the catalog's tags (B27).
  • src/drivers/AGENTS.md: the platform driver still imports only core, ports and shared; facts reach the bus through callbacks (I6).
  • docs/internal/EVENTS.md: driver.backend-rejected and driver.backend-started get their rows.
Retired words
  • android.virtualDevices as a boolean: it is true, false or a list of backend ids; true means ["avd"].
  • "the Android driver" as one emulator driver: the Android driver is the platform driver, holding phones and the listed backends.
Tests

Seam: each row's Seam cell in #2041, with fake backend definitions (a backend fake) and the real-discovery tests at src/daemon/driver-discovery.test.ts:133; model on src/core/driver-catalog.test.ts and src/daemon/driver-discovery.test.ts.

  • B2: The Android platform driver sends every virtual verb of a device to the backend its spec names, and every phone verb to its phone part; phones are served whatever the list holds.: provision, makeReady, shutdown, destroy, estimate, screen, input, device TCP and passthrough on an emulator device reach the avd backend only; the same on the fake backend; enrolment, presence, physical lease and inspect reach the phone part with ["redroid"], with false and with the avd backend skipped; a device of a backend not running → BackendNotRunningError (I17), never NoDriverError
  • B3: The platform driver's listing and catalog survive one backend failing: listManaged lists the others and names the failed one unreadable (I14); the catalog leaves the failed backend out.: both list; one throws → its devices absent, backend in unreadableBackends; a backend not running (retrying, or its engine stopped) → unreadable; a drained backend whose engine is unreachable → unreadable; catalog with one throwing → the other's entry; all throw → the read throws as today
  • B5: An operator sets android.virtualDevices (I3) or a tag list, and the config loads or is refused with the message in I3.: every row of the first Examples table with fake in place of redroid
  • B6: The daemon starts the Android platform driver when adb is found, with each listed backend in list order; a listed backend that cannot start is skipped with driver.backend-rejected (I6) and the others and the phones run.: true; false (no backend, phones served); ["avd"] with no emulator binary → emulator skipped sdk-incomplete, phones served; no adb → no Android driver, as today; owned root refused → driver.root-rejected, platform skipped as today; adb server occupied → driver.adb-server-rejected as today; createCore gets backendBytesPerDevice from the listed and drained backends' bytesPerDevice(settings) (fake at 1 GiB → its devices count 1 GiB); seam for this case: a helper backendRamFigures(definitions, settings) exported from src/daemon/worker-composition.ts, unit-tested in a new src/daemon/worker-composition.test.ts, whose result is passed to createCore at src/daemon/worker-composition.ts:274 (discoverDrivers builds no core)
  • B35: A backend taken off android.virtualDevices while records name it is drained (I16): loaded for cleanup only, it makes no devices, is in neither the catalog nor virtualTags; its free devices are deleted at start as under virtualDevices: false (src/core/startup-converger.ts:69), leased ones when their lease ends.: ["avd", "redroid"] → ["avd"], one free and one leased Redroid device: free deleted at start (virtual-devices-off), leased served to its end then deleted, --requires redroid → CAPABILITY_MISSING; engine down at start → both kept, unreadable, no driver call (B38); core.resumeBackend for it (engine back) → free one deleted then (B38); ["redroid"] from both → free emulators deleted, sources and baselines untouched; no record names it → not loaded
  • B37: A configured worker tag or android.virtualTags entry equal to a backend id loads and names that backend: only its devices carry it; doctor warns tag-names-absent-backend (I16) when the worker does not run it.: android.virtualTags: ["redroid"], Redroid running → --requires redroid gets only Redroid, no finding; Redroid not listed → loads, finding, CAPABILITY_MISSING; worker tags: ["avd"] on ["redroid"] → finding; ["emulator"] → an ordinary tag, as today
  • B30: catalog.get answers one android entry made from every running backend's catalog: models, runtimes, model runtimes, details and custom models in union, the first backend's default runtime and images from the backends that have them (I1).: two backends with overlapping models; a model only one backend has; one backend's catalog throws → the other's; class defaults computed on the merged entry; no running backend → the entry a platform with no virtual devices has today (phonesOnlyEntry, src/core/driver-catalog.ts:54), so phones still route
  • B7: An agent's virtual lease is routed to a backend by its requires and the operator's order (I4), class and range requests included.: every row of the second Examples table but the baseline and physical rows; --requires redroid --image-tag google_apis with no model → BAD_REQUEST before the class path (src/leasing/acquisition-requests.ts:65 would else answer RUNTIME_MISSING); plain lease with ["redroid"] and its engine down, or true with avd skipped → NO_DRIVER; --requires avd --image-tag google_apis not installed → RUNTIME_MISSING as today; tag, only Redroid running → BAD_REQUEST
  • B34: A class or ranged request walks the backends and never installs: with no installed pairing anywhere it answers the first candidate's RUNTIME_MISSING, downloadable: false (ADR 0015 §5).: --requires redroid --os 35, no 35 → RUNTIME_MISSING, no install; --os 36, order ["redroid", "avd"], neither has it → the same; --os ">=34", only avd has 35 → avd, 35; downloads on → no change
  • B8: A lease naming a baseline goes to the backend that saved it, and is refused when requires names another backend.: baseline of backend A, no requires → A; requires A → A; requires B → CAPABILITY_MISSING (I4)
  • B27: catalog.get lists the running backends' ids in the platform's virtualTags, after the configured tags (a configured tag equal to a backend id: listed once, left out while that backend is not listed or running, so the gateway refuses up front); the gateway routes --requires redroid only to workers whose catalog has it, rereading a catalog at once on driver.backend-started and driver.backend-rejected.: one backend; two; ["redroid"] → no avd; false → none, as today; 8 configured tags plus 2 ids → 10 accepted; redroid configured and running → once; android.virtualTags: ["redroid"] with Redroid not listed, or listed but not running → redroid left out, gateway CAPABILITY_MISSING; gateway: worker with redroid picked, worker without passed over; driver.backend-rejected pushed → catalog read again before the next pick; no event → the 30 s refresh
  • B11: The warm pool learns a kind only from a grant on the platform's first running backend, and its targets resolve as plain leases.: a grant on the second backend learns nothing; a grant on the first learns as today; a target with order ["redroid", "avd"] makes the first backend's devices
  • B28: Seeds, settles and baselines stay with the avd backend: listSources, destroySource, settleSeed, ensureSeed and simlock seed reach it whatever the order, and resolveSeedSpec resolves on avd alone, with no backend walk.: order ["redroid", "avd"]: simlock seed --platform android resolves an avd spec and settles an emulator seed; baseline list, stale check, remove and nuke reach the emulator's sources; with no avd backend → no sources, simlock seed refused as for a platform with no settle

Done when

  • pnpm test:changed and pnpm typecheck pass; each Tests line above is a case table in one test.
  • node .agents/scripts/protocol-bump-check.mjs passes: if a contract file changes (the catalog's tags, a worker view), PROTOCOL_VERSION_RANGE is one above main's.
  • A config from main with android.virtualDevices: true, false or unset loads, and simlock config get android.virtualDevices prints what was written.
  • pnpm test:e2e e2e/contract-surface.test.ts e2e/gateway-component-install.test.ts pass (catalog and gateway routing on the fake driver).
  • docs/internal/EVENTS.md lists the two new events, and the website pages updated in this PR (documentation rule 9): website/src/content/docs/docs/reference/configuration.mdx (android.virtualDevices), .../reference/events.mdx, .../using-devices/lease-a-specific-device.mdx (--requires avd).
  • No real-device test in this task: only avd runs on hardware, and its path is unchanged; #2051 adds the Redroid one.

Out of scope

The Redroid backend and its settings (#2051), Redroid components and doctor checks (#2052).

Depends on

  • #2049
  • #2037 because: src/leasing/ acquisition (the planner and acquisition-spec-resolver.ts) it changes
  • #2038 because: the warm pool (src/core/warm-pool/) B11 changes
  • #2043 because: IdleDeviceDeletion and deleteIdle (src/core/create-core.ts:425), and EventMap in src/bus/index.ts

Written by an agent.

Ngôn ngữ chính
TypeScript
Star
730
Fork
44
Merge trung bình
15 giờ 28 phút
Pull request đã merge (30 ngày)
387

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của callstackincubator/simlock

Tất cả issue của callstackincubator/simlock

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.