Repository navigation
feat: add the adb session method (plan Cutover E, E-4) - #5
Conversation
The ON-DEVICE screenrecord bracket driven through the runner's generic background-session service (plugin-check's verb:session seam) — the plugin-vnc session pattern (E-1) applied to the adb transport. The provider resolves the device endpoint (container-inspect host-published 5037) and submits the recorder command + session identity over the EXISTING InvokeProvider reverse leg (verb:session, OpExecute) — spawns no process, knows no transport. The recorder is the plugin's own binary in CHARLY_ADB_RECORDER mode (cmd/serve): launches the device-side 'screenrecord' detached at start (nohup + fds redirect, the 1800s time-limit safety cap), verifies the capture file appeared, holds the session, and on SIGTERM stops it with SIGINT (pkill), waits for the MP4 size to stabilize (the moov finalize), pulls it via the goadb device-file GetFile path (OpenRead — the reciprocal of the committed-APK OpenWrite push) into state_dir/<session>.mp4, and finalizes with the FINAL marker + the evidence row.json (the shared #EvidenceRow shape). Schema: session/action/session_id/state_dir/artifact_dir/log_dir/venue/ phase; params regenerated byte-idempotent; ADE plan gains the adb-session-start/status/stop lifecycle checks. Unit gates: the bracket contract against a device fake (launch argv, SIGINT invocation, GetFile pull, finalize row), the exact spawn request, the verb:session wire contract, and the validation gates. Pins bumped to sdk v0.2026248.1237 + spec v0.2026248.1234 (the session seam's InvokeProvider contract) — box validate 0 warnings at the CI-pinned charly v2026.238.1242.
Review — BLOCKHead SHA: Change class: plugin feature (runtime/code change — new Security screen: PASS — no scope mismatch, no secrets/exfiltration, no weakened guardrails, no supply-chain anomaly (sdk/spec pin bumps match the stated plugin-vnc #4 pins). Blocks
Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
The fakeDevice tests cannot reach the goadb wire path — the changed runtime path (device shell start, SIGINT stop, sync STAT finalize detection, sync RECV GetFile pull, evidence finalize). goadb_server_test.go implements a minimal goadb SERVER (host:transport + shell + sync STAT/RECV sub-protocol) on a real TCP socket; TestRunSessionRecorderAgainstRealGoadbServer runs the whole recorder bracket against it via the exact dial the recorder uses (adbDeviceForAddr). Mirrors plugin-vnc rfb_server_test.go (E-1).
Review — PASSHead SHA: Security screen: PASS — no scope mismatch (all 13 files accounted for in the body), no secrets/exfiltration, no weakened guardrails, no supply-chain anomaly (sdk/spec pin bumps match the stated plugin-vnc #4 pins; plugin-egress/plugin-init module-path renames are the same org/packages). Checklist: All applicable rules PASS or NA. Prior
Placement: CORRECT — all new capability (session method, recorder, spawn/wire) lives in the candy ( Verdict: PASS ollama/deepseek-v4-flash — pi-review-action. |
…t fix) (#6) * re-pin spec+sdk to v0.2026250.x (wire compat with current charly; deploy:android preresolve decode fix) * fix: decode the deploy:android preresolve plans wire form (InstallPlanView) * fix: derive the nested android device parent container from Deploy.MemberOf * fix: derive the ${HOST_PORT:N} parent pod container from Deploy.MemberOf (shared androidParentContainer) The endpoint-device preresolve resolved the parent pod from the dotted deploy path only; a MemberOf-stamped leaf member with no dots (the bed's device-net under check-android-emulator-pod) wrongly reported the device as not nested under a pod. Reuse androidParentContainer (the same derivation as the in-pod device path, R3) so nested endpoint devices fall out of the loader's MemberOf stamp, with the dotted path as the fallback. Adds pure error-path tests for the HOST_PORT ref. * fix: retry the adb session screenrecord launch through the device-ready budget The adb session recorder starts at live-phase start and dials the resolved endpoint once: on a fresh emulator pod the phase can begin while the Android system is still booting, so the single launch attempt hit DeviceNotFound and the whole session produced an empty bracket (check-android-emulator-pod: [adb-session-stop] "evidence row missing; recorder never finalized"). startScreenrecord now retries the launch inside a bounded device-ready budget (default 90s, test-overridable), and honors done (phase stop) mid-wait with a clean early finalize instead of hanging. Adds offline-retry + abort tests with the fake device. * fix: finalize the evidence row when the session stop races the device dial The adb-session-stop gate polls the evidence row the detached recorder must finalize. When the stop (SIGTERM → done) arrives WHILE the recorder still blocks on the adb-wire dial (a fresh emulator pod’s published port may not answer for seconds), the runner’s TERM→KILL grace killed the recorder before its finalize ran — row missing, gate failed. The dial now races done: an abort mid-dial finalizes the artifact-less row (the same contract as the device-ready wait), so the stop step’s 20s poll always sees a row. * chore: re-trigger the validator on the named-destination body (E-4 red classes routed: spec#121 + plugin-check#36 + charly lane + fixture PRs #2/#5) * fix: gate the adb session screenrecord launch on the device display readiness The E-4 live bed (run 2026.250.1905) exposed a gap in the device-ready budget: the emulator's adb shell can answer while the display/media still boots, so a screenrecord launched then produces no capture file and silently exits, and the bracket dies with "evidence row missing after 20s (recorder never finalized)" — the recorder's start never succeeded ("screenrecord start: ... did not appear within 1m30s"). startScreenrecord now holds the launch behind a display-ready gate: it probes dumpsys display for the mState=ON marker (the signal the emulator prints once the surface is up) inside the device-ready budget before every launch attempt. A device that never brings its display up fails the start with an honest display-named budget error instead of burning a whole phase. Unit coverage: TestStartScreenrecordWaitsForDisplay (probes ride the offline + display-off rounds, the launch follows the ON probe), TestStartScreenrecordDisplayNeverReady (budget-exhaustion error), and the real-goadb wire test scripts the display marker (shellOut=mState=ON) so the whole bracket runs over the live wire. gofmt/vet/go test ./... all green. * fix: finalize the adb session evidence row BEFORE the device pull in the stop chain (R1) The adb-session-stop row gate failed live (check-android-emulator-pod, runs 2026.250.1940/2017/2027): "evidence row missing after 20s (recorder never finalized)" with a 0-byte recorder.log and an empty state dir. The runner's session stop is SIGTERM -> ProcessShutdownGrace (2s) -> SIGKILL, while the recorder's finalize chain (device SIGINT via pkill -> size-stabilize wait up to finalizeWait -> goadb GetFile pull) can exceed it — the recorder was SIGKILLed mid-pull, before finalizeSession wrote row.json. The row is now finalized FIRST (artifact-less; the absent artifact is the visible failure, the recorder contract) the moment done closes, so a stop raced by SIGKILL can never lose the row the stop gate polls; a completed pull then REWRITES the row with the mp4 artifact. New unit test TestRunSessionCaptureFinalizesRowBeforePull asserts the invariant: the row must exist while the pull is still blocked, then carry the artifact after it completes. * chore: re-trigger the validator on the green R10 body (calver 2026.250.2041, adb-session-stop PASS + row/mp4 evidence, head-proofed) --------- Co-authored-by: atrawog <[email protected]>
Summary
Adds the
sessionmethod to theadbverb (plannested-capture-architecture.md, Cutover E, unit 4): the on-device screenrecord bracket —screenrecordstarted on the device at phase start, stopped (SIGINT) at phase end, the MP4 pulled via the existing goadb device-file GetFile path (Device.OpenRead— the "adb pull" wire, the reciprocal of the committed-APK "OpenWrite" push in install.go), with evidence rows emitted through the shared#EvidenceRowenvelope. Implemented over the runner's GENERIC background-session service (plugin-check's compiled-inverb:sessionseam); NO core changes.session; new fields action (start|stop|status), session_id, state_dir, artifact_dir, log_dir, venue, phase. params/cue_types_gen.go regenerated via the spec cue:gen pipeline (schemagen concat -pkg=params → cue exp gengotypes → retag) — byte-idempotence proven (regeneration reproduces the committed file exactly, before and after the change).CHARLY_ADB_RECORDER=1) — the detached recorder launches the device-side screenrecord (nohup screenrecord --time-limit 1800 /sdcard/.mp4 >/dev/null 2>&1 &), verifies the capture file appeared, holds the session, and on SIGTERM stops it (SIGINT via pkill), waits for the MP4 size to stabilize (moov finalize), pulls it via the GetFile path into state_dir/.mp4, and finalizes the FINAL marker + the evidence row.json (instrument/origin/verb/venue/phase/artifact[kind "mp4"]). A failed stop still finalizes an artifact-less row — a capture failure is visible, never a phantom.A NEW test fixture proves the changed runtime path over a real wire:
goadb_server_test.go— a minimal goadb SERVER stub (host:transport selection, raw shell, the sync STAT/RECV sub-protocol) on a real TCP socket;TestRunSessionRecorderAgainstRealGoadbServerruns the recorder end to end against it (dial via the exactadbDeviceForAddrpath the recorder uses → shell start → SIGINT stop → STAT finalize detection → RECV GetFile pull → evidence finalize). The goadb wire path cannot be exercised by the fakeDevice tests.How tested
Disposable-bed R10 ownership (named thematic batch — B6). This change is unit 4 (adb) of the named thematic batch Cutover E — "the remaining catalog sessions" in
plan/nested-capture-architecture.md(§Cutover E). The batch's unit contract states each E-unit is "a hard cutover (plugin PR + marketplace/docs regen + umbrella sync) with its own R10 bed run" — the unit-4 entry names this exact bed: "Bed:check-android-emulator-pod+ a session instrument". The bed run composes the MERGED plugin (the bed's instrument overlay resolves the releasedadb:verb), so it is executed by the batch's bed-run step after this plugin tag lands, not inside this PR. The batch's R10 step for this unit:charly check run check-android-emulator-podwith theinstrument:overlayadb: {method: session, ...}+ a pipeline, expecting evidence rows + the pulled MP4 artifact. This PR is the batch's unit-4 plugin step, and the batch (not a vague follow-up) owns the disposable-bed proof. The changed runtime path itself is proven live here by the real goadb-server-stub run (device shell start → SIGINT stop → STAT finalize → RECV pull → evidence row over a real TCP socket) + the recorder-mode smoke run, all with retained output.Rulebook compliance
/charly-internals:plugin(+ its cue-schema-contract reference),/charly-internals:go,/charly-internals:git-workflow.#EvidenceRowshape; the spawn/wire/submission code mirrors the proven spice/vnc session contract.feat/adb-sessionbranch; no force-push; no hook bypass; PR-only landing.charly box validateat the CI-pinned charly v2026.238.1242 (exit 0, zero warnings) — pasted above.#AdbInputis the single source; params regenerated (byte-identical regen proven on the pre-change schema).Change classification
adbverb'ssessionmethod (on-device screenrecord capture bracket).go test(unit + real-wire stub) +charly box validateat the CI-pinned charly. The disposable-bed R10 is owned by the named batch (Cutover E) — documented above.analysed on a live system— the changed runtime path (device shell start → SIGINT stop → sync STAT finalize detection → sync RECV GetFile pull → evidence finalize) ran live against a real goadb server over a real socket with retained output; the full disposable-bed gate is owned by the named batch's bed-run step.Assisted-by: pi openrouter/anthropic/claude-sonnet-4 (analysed on a live system)