Skip to content

docs(adr): 0054 a lease holder tunnels device ports to its own machine - #1111

Merged
V3RON merged 12 commits into
callstackincubator:mainfrom
leonardoxr:feature/1110-adr
Nov 1, 2026
Merged

V3RON merged 12 commits into
callstackincubator:mainfrom
leonardoxr:feature/1110-adr

Conversation

@leonardoxr

@leonardoxr leonardoxr commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

ADR 0054 for #1110, Accepted. A new optional tunnel module (off by default) lets a lease holder carry TCP between its own machine and its leased Android device, reverse and forward, over one lease WebSocket and one uplink channel per simlock tunnel run. It narrows ADR 0005's port-forwarding non-goal; ADR 0005's one-inbound-port rule stands.

This PR is the bottom of #1110's stack and merges with the feature's last task.

🤖 Generated with Claude Code

Status

Review: fix-check passed, 5 fixed; flip to Accepted at 1075c97 (adr-flip-check ok 0054); index row order fixed at 7241ba8 (the same row moved, verified by: coordinator) Gate: running

Review

Spec review: 5 blocking, 5 fixed, 1 notes. Code review: skipped. Claims review: skipped.
Rounds: 2. Tokens: 29.9M.
Runs: 15. Cost USD: 10.9339. Agent seconds: 7632.
Assessment: complete

Written by an agent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nel only

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leonardoxr and others added 4 commits October 31, 2026 00:19
…weep

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rule 2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leonardoxr
leonardoxr marked this pull request as ready for review October 31, 2026 09:45
@leonardoxr

leonardoxr commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

Back to draft: the PR-body check needs a ## Review section on a ready PR, and an ADR PR waits in draft until its stack is merged. ADR 0054 is accepted; this PR is the bottom of the tunnel stack (#1121, #1125, #1126, #1127). Per delivery rule 15 it merges with the stack's last task, #1127, not on its own.

Written by an agent.

@leonardoxr
leonardoxr marked this pull request as draft October 31, 2026 10:23
@V3RON

V3RON commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Findings (round 1, ADR-only: spec lens, Opus/high)

Commit: 2e09e78

  • R1 (blocking) ADR 0054 Decision 4 / Consequences: the worker's loopback listener (ports 47000-47999) accepts any local connection. Holder A can run adb reverse tcp:9000 tcp:<47xxx> through device.exec, so A's device reaches holder B's listener and B's dev server. The Consequence "the device still reaches only the holder's loopback" is false, and the record does not decide how a listener refuses connections that are not its own lease's. [trust boundary]
  • R2 (blocking) Decisions 5 and 6: reclaim and the start sweep remove reverse and forward rules on enrolled phones, through the host's shared default adb server. Safety rule 1 and ADR 0022 section 3 allow one destructive act on a physical device (uninstalling a non-listed app). The record neither limits the removals to emulators nor amends rule 1 / ADR 0022, and does not mention the pre-command host:version check (rule 9). [safety 1, safety 9]
  • R3 (blocking, mechanical) The record narrows ADR 0005 Non-goals, but 0005's Status line and its README row do not point at 0054, as they do for other narrowed ADRs (0028, 0049). [adr-index]

Assessment: complete against the ADRs and binding rules. No issue body was in the inputs (the PR closes no issue), so "every question the specification leaves to a decision" was not checked against #1110.

Rerun: round 2 after fixes.

Written by an agent.

@V3RON

V3RON commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Decision taken

The ADR review (round 1, R1 and R2) found two questions that the spec left open. Both are decided here, pending the maintainer. #1112's body now says the same, with Tests lines that pin each one.

R2: tunnel rules on enrolled phones. Reclaim and the start sweep ran reverse --remove-all and removed forward rules on phones, through the host's shared adb server. Safety rule 1 and ADR 0022 §3 allow only one destructive act on a physical device.

  • (a, taken) Reclaim and the start sweep act on emulators only. On a phone, Simlock removes only the reverse rules its own tunnels set, when their socket closes. What a user sees: after a daemon crash, a tunnel rule can stay on a phone until it reboots, and the docs say so.
  • (b) Keep the phone cleanup and amend safety rule 1 and ADR 0022 to allow removing adb rules. What a user sees: no stale rules on phones, but Simlock now changes phone state it didn't make.

Why (a): it keeps the safety rule as it is, it is the smaller change, and it is easy to widen later. Reverting means option (b): a rule amendment, plus putting the phone branch back in device-tcp.ts.

R1: the loopback listener accepts any local connection. While a tunnel is open, another lease's device on the same worker can reach the holder's tunnelled port: an emulator through 10.0.2.2, or any device through an adb reverse set with device.exec. A local process can reach it too.

Why (a): it is what the code does today, and the exposure is opt-in. Reverting means option (b), which would be a follow-up task under #1110.

Written by an agent.

@V3RON

V3RON commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Decision taken

The ADR review (round 2, R5): a tunnel rule left on a phone (after a daemon crash or a failed removal) keeps pointing at a port in 47000-47999. If nothing reserves that port, a later tunnel on another lease could get it, and would then receive that phone's connections for a different holder.

  • (a, taken) Keep the port reserved. At start, the worker reads reverse --list on every enrolled phone and changes nothing there. Each tunnel port that a rule points to stays reserved. A phone's reclaim reads its rules again and frees only the ports that no rule points to. What a user sees: nothing, unless every tunnel port is used up by stale phone rules, which takes 1000 of them.
  • (b) Allow the reuse, and state that the operator accepts it. What a user sees: one holder's tunnel may carry another lease's phone traffic.

Why (a): it closes a path from one lease into another, and it only reads phone state, so safety rule 1 holds. Reverting means dropping the read of phone rules at start and at reclaim.

Written by an agent.

@V3RON

V3RON commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Findings (fix-check, 3f5537e)

R4 and R5 resolved (spec lens, Opus). Note, nonblocking: ADR 0054 line 117 "On a leased device ... the device's reclaim removes the rules" now follows the phone start-read, so it can read as covering phones; lines 97-106 state phone reclaim removes nothing. Assessment: complete.

Written by an agent.

@V3RON

V3RON commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Review ledger

Round 1: 2e09e78
Round 2: 6788e5b
Round fix-check: 3f5537e

Runs: 15. Cost USD: 10.9339. Agent seconds: 7632.
Tokens input 616, output 152939, cache read 20454477, cache write 1061604.
- fix implementer: claude-opus-5-5 834 s $1.9721
- fix implementer: claude-opus-5-5 501 s $2.598
- fix implementer: claude-opus-5-5 4206 s $3.6598
- fix implementer: claude-sonnet-5-5 276 s $0.2005
- fix implementer: claude-sonnet-5-5 345 s $0.1426
- fix implementer: claude-sonnet-5-5 374 s $0.1853
- fix implementer: claude-sonnet-5-5 174 s $0.0716
- review 1 reviewer: claude-sonnet-5-5 278 s $0.3282
- review 1 spec-reviewer spec: claude-opus-5-5 145 s $0.6663
- fix 1 implementer: claude-sonnet-5-5 71 s $0.14
- review 2 reviewer: claude-sonnet-5-5 134 s $0.1915
- review 2 reviewer spec: claude-opus-5-5 69 s $0.2946
- fix 2 implementer: claude-sonnet-5-5 64 s $0.1036
- review fix-check reviewer: claude-sonnet-5-5 109 s $0.1628
- review fix-check spec spec: claude-opus-5-5 52 s $0.217
Finding outcomes: {"fixed":5}. Classes: {"adr-index: old Status points at narrowing ADR":1,"false consequence after narrowed reclaim":1,"safety 1, safety 9":1,"undecided cross-lease routing from stale phone rule":1,"undecided trust boundary; false consequence":1}.
{"findings":[{"id":"R1","role":"spec","class":"undecided trust boundary; false consequence","outcome":"fixed","path":"docs/internal/adr/0054-a-lease-holder-tunnels-device-ports-to-its-own-machine.md","round":"1","fix":"6788e5bc0b71549b33a2cf233189a89b43c46255"},{"id":"R2","role":"spec","class":"safety 1, safety 9","outcome":"fixed","path":"docs/internal/adr/0054-a-lease-holder-tunnels-device-ports-to-its-own-machine.md","round":"1","fix":"6788e5bc0b71549b33a2cf233189a89b43c46255"},{"id":"R3","role":"spec","class":"adr-index: old Status points at narrowing ADR","outcome":"fixed","path":"docs/internal/adr/README.md","round":"1","fix":"6788e5bc0b71549b33a2cf233189a89b43c46255"},{"id":"R4","role":"spec","class":"false consequence after narrowed reclaim","outcome":"fixed","path":"docs/internal/adr/0054-a-lease-holder-tunnels-device-ports-to-its-own-machine.md","round":"2","fix":"3f5537e0eaf852c920874bf3f42a7b2d98c0fc66"},{"id":"R5","role":"spec","class":"undecided cross-lease routing from stale phone rule","outcome":"fixed","path":"docs/internal/adr/0054-a-lease-holder-tunnels-device-ports-to-its-own-machine.md","round":"2","fix":"3f5537e0eaf852c920874bf3f42a7b2d98c0fc66"}]}

Written by an agent.

@V3RON

V3RON commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Review notes

Not blocking, not verified. Each is one reviewer's claim.

  • spec: docs/internal/adr/0054-a-lease-holder-tunnels-device-ports-to-its-own-machine.md:117 "On a leased device it removes nothing ... the device's reclaim removes the rules" can read as covering phones after the phone start-read; lines 97-106 say phone reclaim removes no rules

Written by an agent.

@V3RON
V3RON marked this pull request as ready for review November 1, 2026 16:11
@V3RON

V3RON commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Decisions confirmed

The maintainer confirmed the delivery decisions on 2026-11-01:

  • Phones: reclaim and the start sweep clean adb rules on emulators only. On a phone, Simlock removes only the rules its own tunnels set. Ports of stale phone rules stay reserved, and an aborted lease end on a phone still removes that phone's tunnel rules.
  • Loopback listener: the exposure stays documented for now. A follow-up task under A remote caller's leased device reaches ports on the caller's machine, and back #1110 adds a Unix-socket listener.

Written by an agent.

@V3RON
V3RON merged commit 822ea4c into callstackincubator:main Nov 1, 2026
37 checks passed
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.

2 participants