Skip to content

docs(adr): 0031 a physical iPhone streams through CoreDevice's media stream, behind a screen-source seam - #622

Merged
V3RON merged 3 commits into
mainfrom
feature/617-adr
Oct 18, 2026
Merged

V3RON merged 3 commits into
mainfrom
feature/617-adr

Conversation

@V3RON

@V3RON V3RON commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Proposes ADR 0031 for #617, task #619 (a physical iPhone's screen stream).

It decides:

  • A physical iPhone's screen comes from CoreDevice's media stream. simlock negotiates it, receives the RTP/HEVC on its own socket and decodes it with VideoToolbox. It never goes through avconferenced, so it needs no restricted entitlement and no Camera permission.
  • vendor/screen-capture/ becomes one package with a shared library and two programs: simlock-screen-capture (simulators, as today) and simlock-device-capture (iPhones, the only one linking CoreDevice). A CoreDevice change can never stop simulator streams.
  • A ScreenSource seam with the simulator and CoreDevice sources now. CoreMediaIO (the QuickTime path) is named as the replacement inside simlock-device-capture, with no TypeScript change.
  • CoreDevice major 642 (Xcode 27) only. Another version, or none, ends the capture with a reason that reaches the viewer as a 503. pnpm build skips the iPhone program elsewhere.
  • HEVC is re-encoded as H.264, so the envelope, the console and browsers do not change.
  • The program stops only the stream it started and releases its usage assertion on every way out.

docs/internal/adr/0031-device-stream-poc/ holds the proof of concept as evidence: its sources, stubs, build script and findings notes, plus two packet stats files. No screenshots, logs or packet captures.

Stays open as the bottom of #617's stack until the feature's last task merges.

Status

  • ADR drafted at Proposed, index row added
  • Spec check findings folded in
  • Maintainer accepts the ADR (Accepted — not yet implemented)

Assumptions

None.

Review

Spec review: skipped. Code review: skipped. Claims review: skipped.
Rounds: 0. Tokens: 0M.

ADR PR: docs only. The maintainer accepted the ADR directly.

Written by an agent.

@V3RON
V3RON merged commit 60f2b68 into main Oct 18, 2026
23 checks passed
@V3RON
V3RON deleted the feature/617-adr branch October 18, 2026 15:53
V3RON added a commit that referenced this pull request Oct 18, 2026
Closes #619

### Status

Implement: done, including the 2026-10-18 spec changes (an iPhone below
iOS 27 refused before the capture starts, F47; the stream on iOS 27 a
known gap). Review: round 1 (8 findings, fixed), round 2 clean at
`15826ff2`; the iOS 27 change's review was waived by the maintainer (its
unit tests checked by mutation: disabling the check fails 2, asking a
simulator fails 1). Hardware: iPhone lane pass at `444f571d` on an
iPhone 11 Pro Max (iOS 26.5), 13 passed, the stream case skipped below
iOS 27 and the refusal case passing; simulator stream lane pass at
`8d91662a`, 2/2. Stack: synced with `main` and on #662 (`3ed4c4ca`).
Gate: run with the stack (#686).

## Done when

- [x] The tests above pass.
- [x] `pnpm build` on this Mac (Xcode 27) puts both programs in
`dist/bin/`.
- [x] Slow lane: `e2e/slow-ios-stream.test.ts` passes (2/2 at
`8d91662a`); the refusal case in `e2e/slow-ios-physical.test.ts` passes
on an iPhone 11 Pro Max on iOS 26.5 (13 passed at `444f571d`). The
stream cases on iOS 27 are a known gap (#619 item 7). The
person-at-the-phone lock case was not run.
- [x] `GET /v1/stream/leases/{leaseId}` for a physical iPhone no longer
answers 415.

## Assumptions

- Assumption: how the physical-lane stream claims are grouped into tests
— one test for the version table, one for "642.x goes on, an unknown
UDID exits 1 within 26 s", one long test for stream + still screen +
second viewer + no-capture-left-and-restream, and the lock case in the
manual lane. Grouping the lease-backed claims keeps one lease and one
rig for the whole lifecycle, as the existing stream lanes do; a separate
test per claim would lease the same iPhone four times, which is slower
and harder to pin.
- Assumption: "the suite fails, not skips, when
`dist/bin/simlock-device-capture` is missing" — it is its own test ("the
device capture program is built") rather than a guard inside
`describe.skipIf`. Every other test in the file then fails on its own
missing-program error too; an assertion in a test is the shape the suite
already has for a broken build, and it keeps `describe.skipIf` about the
machine's fitness, not the checkout's.
- Assumption: how the build test makes one Swift product fail — a
`SIMLOCK_FAKE_SWIFT_FAIL` name list read by the test's own fake `swift`.
The fake is the test's own helper, so a variable of its own invents no
surface; it is the smallest way to have one product build while the
other does not.
- Assumption: the stream-envelope reader both iOS stream lanes need —
moved to `e2e/helpers/screen-frames.ts` and re-exported from the helpers
barrel, with `slow-ios-stream.test.ts` reading it from there. Sharing
one copy keeps the two lanes' claim about "meta, an avcC description and
a key frame" one claim (testing rule 7); the code itself is unchanged.

- Assumption: the console keeps a 415 branch, and its text names no
platform. No device the iOS driver knows is refused with 415 after this
task, and the item-6 wording ("no device the drivers know is refused
with 415 any more") only holds once #618 lands the Android half; until
then a physical Android phone still answers 415, so `docs/HTTP-API.md`
and `docs/CONSOLE.md` are written for what this tree does rather than
for the pair of tasks. A later change that removes the last refusal
should drop the branch and the two sentences with it.
- Assumption: `src/source-hygiene.test.ts`'s license name-vs-text check
gains the same verbatim-text exemption it already carries for
BSD-3-Clause, now for MIT — the spec asks for
`LICENSES/idevice.MIT.txt`, and idevice's MIT text, like BSD's, never
contains the word "MIT".
- Assumption: which way out wins when a `start` fails at the same moment
the caller asks to stop — the start's reason (exit 1 with that line)
rather than the clean end (exit 0). The spec pins both codes without
ordering them; the reason is the smaller choice because the daemon turns
a non-zero exit's last line into the 503 a viewer reads, while exit 0
leaves "wrote nothing", and it keeps the restructure from moving the
64/1/0 codes F39 pins. A source refusing to begin because it was already
told to stop throws its own `StoppedBeforeStart` and stays exit 0, so a
stop is never dressed up as a failure.
- Assumption: how long the lifecycle waits for a `start` it cannot
cancel to report its last word once it is on its way out — 0.4 s, which
is what is left of the caller's 2 s grace after the source's own 1.5 s
`stop()` bound. Past it the program exits, which is the case the manual
already names as a known gap; without any bound the exit could hang on a
CoreDevice call and turn the caller's stop into a SIGKILL.
- Assumption: what the device source does when CoreDevice starts a
stream and then shares no socket for it — the start fails with a
one-line reason, so the viewer reads a 503 that names it. The spec names
no fallback for that case, and the comment this fix replaced claimed the
socket bound for the tunnel route was one; it cannot be, because the
iPhone's sender is the peer of the socket CoreDevice opens, so a loop
reading the reserved-port socket would receive nothing and report
nothing. Refusing inside the start's own deadline is the conservative
option: it is the shape every other failed step already has (F34 turns
it into a 503 within the stream's 30 s bound), and it is the smaller
change, since it adds no new state — the alternative, running the loop
on a socket that receives nothing, shows a viewer a stream that never
paints.

_This PR is stacked on #622 (`feature/617-adr`): the ADR and its PoC,
which this spec cites as `poc/`, are on that branch._

## Review

Spec review: 0 blocking, 0 fixed, 0 notes. Code review: 4 blocking, 4
fixed, 1 note. Claims review: 4 blocking, 4 fixed, 2 notes.
Rounds: 2. Tokens: n/a.

- Round 1 (at `50e62330`): code — `DeviceScreenSource.swift:316` SSRC
read at the wrong level (`e51b5259`); `SimlockMediaBridge.m:191` adopt
never adopted and `:182` `send` on an unconnected socket (`71c30e76`);
`NOTICE.md:208` "three" for four (`3ed01f28`). Claims —
`docs/CONFIGURATION.md:42` (`6579747b`), the stub's pin note
(`7128722e`), `SimlockMediaBridge.h:25` `simlockAdoptedSocket`,
`main.swift:8` exit codes (`4534a4ae`).
- Round 2 (at `15826ff2`; code and claims lenses, spec skipped as no fix
changed acceptance): all eight hold, no new blocking findings. Notes
kept: `HEVCDecoder.swift:256-258` names the wrong mechanism for the old
slot; `SimlockMediaBridge.h:40` "the first descriptor" depends on an
unspecified order; `DeviceScreenSource.swift:5` describes the local
socket loosely.
- Hardware fixes, coordinator diff check: `ab1dc980`
(`slow-ios-physical`) and `8d91662a` (`slow-ios-stream`) — the stream
cases read a locked or endless body for an assertion message; the status
is now checked before the reader is taken, and the stream's waits are
bounded.
- Spec change (`444f571d`, review waived by the maintainer): refuse an
iPhone below iOS 27 before the capture starts.
- Stack sync (`3ed4c4ca`): `main` merged up the stack and `task/619`
onto `task/618`, four conflicts resolved; ADR 0031 set to Accepted. A
base merge, checked by CI.

_Written by an agent._

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: OpenCode <noreply@opencode.ai>
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.

1 participant