From c4a53e3f88fa54310b68ad1729356bb523284835 Mon Sep 17 00:00:00 2001 From: Sebastian Gieseler Date: Wed, 21 Oct 2026 18:24:54 +0200 Subject: [PATCH 1/4] docs(adr): 0048, a container's main port can move with the main slot (Proposed) Part 2 of #184. Opt-in per Compose service (`main_ports`): the main tree's overlay publishes such a container on an instance port, devstack holds the fixed port with a forward (ADR-0043's Front, on the Compose file's address), and `promote --lane` flips it to the lane's port. The main tree's container keeps running; TCP only. Co-Authored-By: Claude Opus 5.5 --- ...s-main-port-can-move-with-the-main-slot.md | 118 ++++++++++++++++++ docs/adr/README.md | 1 + 2 files changed, 119 insertions(+) create mode 100644 docs/adr/0048-a-containers-main-port-can-move-with-the-main-slot.md diff --git a/docs/adr/0048-a-containers-main-port-can-move-with-the-main-slot.md b/docs/adr/0048-a-containers-main-port-can-move-with-the-main-slot.md new file mode 100644 index 00000000..8bf3645c --- /dev/null +++ b/docs/adr/0048-a-containers-main-port-can-move-with-the-main-slot.md @@ -0,0 +1,118 @@ +# ADR-0048: A container's main port can be devstack's, and then moves with the main slot + +- **Status:** Proposed +- **Date:** 2026-10-21 +- **Deciders:** project owner +- **Related:** [#184](https://github.com/nuetzliches/devstack/issues/184) (part 2), [ADR-0008](0008-background-workers-run-only-in-the-active-slot.md), [ADR-0024](0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md) point 5, [ADR-0029](0029-source-sync-and-port-forwarding-for-remote-lanes.md), [ADR-0030](0030-each-lane-has-its-own-infrastructure.md), [ADR-0043](0043-a-dev-servers-fixed-port-is-devstacks.md), [ADR-0047](0047-the-dashboard-makes-a-lane-from-a-branch.md) + +## Context + +`promote --lane` (ADR-0024 point 5) moves the fixed ports of `[services.*]`: +a proxied service's upstream, a dev server's forward (ADR-0043). A Compose +container publishes its port itself: the main tree runs the Compose files +unchanged, Docker binds `3306`, and devstack is not in front of it. A lane +already publishes its containers on the Compose file's host port plus its +offset (ADR-0030; a lane on a node: forwarded here on the same number, +ADR-0029), so the lane's side exists. Only the main tree's side is missing. + +A stack whose processes all run in containers (Linux binaries built by a +command, a game server, a vendor image) therefore has no switch: +`promote --lane` is refused for it since #188, and ADR-0047's "a branch runs +in a lane, which then serves the main ports" does not hold there. Its other +branch runs on the lane's ports, and every client (a game client, a +desktop tool, a browser bookmark) must be pointed there and back. + +A container's port behind devstack differs from a dev server's in two ways +that matter: containers outlive the daemon (`devstack down` without +`--infra` leaves them running, and they run while a daemon restarts), and a deployment +file's port may be meant for other machines (`3724:3724` binds every +interface; a game client on the LAN uses it). + +## Decision + +1. **Opt-in per Compose service.** `[compose.] main_ports = ["realmd", + "mangosd"]` names the services whose published ports are devstack's in + the main tree. Without it nothing changes: Docker binds the ports, and + the main slot does not move them. +2. **The main tree's overlay moves those ports to an instance port.** As a + lane's overlay does (ADR-0030), the main tree gets one for such a group: + each TCP port of a named service is published on a port Docker assigns, + on loopback (`127.0.0.1::`); devstack reads it from `compose ps` + as it already does. +3. **devstack holds the fixed port with a forward** (`tcpfwd::Front`, + ADR-0043): on the address the Compose file names (none: every interface, + as Docker would bind it; `127.0.0.1`: loopback), *hold* while the + container starts or is recreated, *forward* to its instance port, + *refuse* while it is stopped. A recreated container gets another + instance port; the forward follows it. +4. **The main slot flips the forward.** `promote --lane` points it at the + lane's port for that container: the Compose file's host port plus the + lane's offset, published by a local lane, forwarded here for a lane on a + node. `--lane main` points it back. Such a service counts as a main port + for `moves_main_slot` (#184), so the stack is no longer refused. +5. **The main tree's container keeps running** while a lane has its ports. + It has no workers to move (ADR-0008 is about `[services.*]`); only + clients on the host reach the lane. Clients inside the main tree's + Compose network still reach the main tree's container, and the lane's + containers reach each other on the lane's network, as now. +6. **TCP only.** A UDP port of a named service stays Docker's in the main + tree and does not move; the stack file check warns about it, and + `promote --lane` says which ports stayed. + +## Alternatives considered + +- **Always, for every published port.** It needs no setting, but it puts + devstack in front of every database port too, which then closes when the + daemon stops while the container runs on, the opposite of today. Opt-in + confines that to the services whose clients have to follow a lane. +- **Recreate containers on the fixed port.** Stop the main tree's container + and publish the lane's on the fixed host port. It costs a container + recreation in both trees per switch, takes seconds instead of a flip, and + for a lane on a node, there is no container here to publish anything. +- **The OS forwards (`netsh interface portproxy`, `iptables`).** It needs + administrator rights, differs per platform, and does not hold a + connection while a container starts. +- **Leave it, and say so (status since #188).** Stacks of containers keep no + switch; ADR-0047's model has a hole exactly where container-only stacks + are common. + +## Consequences + +- A named service's fixed port answers only while the daemon runs. A daemon + restart closes it for a moment (a connection is refused, then held); with + the daemon down, the container runs on its instance port, which the + dashboard and `devstack status` show. +- The fixed port on every interface is bound by devstack instead of Docker: + the same exposure as before, but a firewall rule for Docker's process no + longer covers it, and Windows Firewall may ask once to allow devstack. +- One more forward per connection on the host (a copy in the daemon), as for + dev servers. +- A UDP service (a game's voice port, DNS) does not follow a lane. +- The view of such a container shows the fixed and the instance port, as a + proxied service's does. + +## Enforced by + +Where it will live: + +- `crates/devstack-config/src/model.rs` (`main_ports` in `[compose.]`, + the check that it names services of the group, the UDP warning), + `docs/stack-file.md`. +- `crates/devstack-compose/src/lib.rs` (the main tree's overlay for those + services), `crates/devstack-daemon/src/supervisor/infra.rs` (the overlay in + the main tree, the instance port from `compose ps`, the fronts). +- `crates/devstack-daemon/src/supervisor/handover.rs` (`moves_main_slot`), + `crates/devstack-daemon/src/lanes.rs` (`take_main`, `give_back` flip the + fronts). +- `crates/devstack-daemon/src/tcpfwd.rs` (`Front` on a given address, not + loopback only). +- `docs/dashboard-api.md` (`InfraView`: fixed and instance port). + +## What this ADR does not say + +- Nothing about `[services.*]`: their main ports work as before. +- Nothing about a lane's own ports: they stay the Compose file's plus the + offset. +- Nothing about naming in `devstack status` (#184 point 3): its container + rows have no `SERVICE` header; `devstack top` does, which is a separate + wording question. diff --git a/docs/adr/README.md b/docs/adr/README.md index b4f58cc4..208d28c6 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -96,3 +96,4 @@ stay. | [0045](0045-the-hub-notifies-the-desktop.md) | The hub notifies the desktop of what needs attention, without a tray | Accepted, amended 2026-10-21 (`guest_lane`) | | [0046](0046-the-hub-opens-a-worktree-in-the-users-programs.md) | The hub opens a stack's worktree in the user's own programs, from a fixed list | Accepted | | [0047](0047-the-dashboard-makes-a-lane-from-a-branch.md) | The dashboard makes a lane from a branch; the main tree's checkout stays the user's | Accepted | +| [0048](0048-a-containers-main-port-can-move-with-the-main-slot.md) | A container's main port can be devstack's, and then moves with the main slot | Proposed | From c453c4cdbdbe7635403df261fabd345f8eaeca4d Mon Sep 17 00:00:00 2001 From: Sebastian Gieseler Date: Wed, 21 Oct 2026 18:37:25 +0200 Subject: [PATCH 2/4] docs(adr): 0048 names what switches: what the developer reaches directly; no crosstalk Co-Authored-By: Claude Opus 5.5 --- ...ers-main-port-can-move-with-the-main-slot.md | 17 ++++++++++++++++- ui/src/components/TopBar.vue | 5 ++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/adr/0048-a-containers-main-port-can-move-with-the-main-slot.md b/docs/adr/0048-a-containers-main-port-can-move-with-the-main-slot.md index 8bf3645c..092a15a7 100644 --- a/docs/adr/0048-a-containers-main-port-can-move-with-the-main-slot.md +++ b/docs/adr/0048-a-containers-main-port-can-move-with-the-main-slot.md @@ -28,12 +28,23 @@ that matter: containers outlive the daemon (`devstack down` without file's port may be meant for other machines (`3724:3724` binds every interface; a game client on the LAN uses it). +What has to switch is narrow. The developer works with a few services +directly: the UI in the browser, the API a desktop tool or the browser +calls. Those have to answer on the main ports from the lane chosen. What +they use in turn may run on any port, as long as each lane's services reach +their own lane's and never another's: the goal is no crosstalk between +lanes, not every port moving. + ## Decision 1. **Opt-in per Compose service.** `[compose.] main_ports = ["realmd", "mangosd"]` names the services whose published ports are devstack's in the main tree. Without it nothing changes: Docker binds the ports, and - the main slot does not move them. + the main slot does not move them. The list names what the developer + reaches directly from the host (the UI, the API the browser calls), not + what those services use: a lane's containers reach the lane's own on its + Compose network or its moved ports (ADR-0030), whichever lane serves the + main ports. 2. **The main tree's overlay moves those ports to an instance port.** As a lane's overlay does (ADR-0030), the main tree gets one for such a group: each TCP port of a named service is published on a port Docker assigns, @@ -88,6 +99,10 @@ interface; a game client on the LAN uses it). - One more forward per connection on the host (a copy in the daemon), as for dev servers. - A UDP service (a game's voice port, DNS) does not follow a lane. +- Crosstalk stays possible where a stack makes it: a browser that calls an + API by its fixed port while only the UI is named reaches the main tree's + API from the lane's UI. Name both, or let the UI reach the API through its + own origin (a dev proxy, a relative URL). - The view of such a container shows the fixed and the instance port, as a proxied service's does. diff --git a/ui/src/components/TopBar.vue b/ui/src/components/TopBar.vue index d15b65b4..2c5960d7 100644 --- a/ui/src/components/TopBar.vue +++ b/ui/src/components/TopBar.vue @@ -171,9 +171,12 @@ const mismatch = computed(() => { background: color-mix(in srgb, var(--bg-elev) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); + /* The border counts: the sticky parts below it are `100vh - --topbar-h` + tall, and one pixel more here made the page scroll by one. */ + height: var(--topbar-h); } .topbar-inner { - height: var(--topbar-h); + height: 100%; display: flex; align-items: center; gap: 10px; From 830da5e4fb50b432a39271f95df7c68f9720066a Mon Sep 17 00:00:00 2001 From: Sebastian Gieseler Date: Wed, 21 Oct 2026 18:37:38 +0200 Subject: [PATCH 3/4] docs(adr): leave an unrelated TopBar change out of this branch Co-Authored-By: Claude Opus 5.5 --- ui/src/components/TopBar.vue | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ui/src/components/TopBar.vue b/ui/src/components/TopBar.vue index 2c5960d7..d15b65b4 100644 --- a/ui/src/components/TopBar.vue +++ b/ui/src/components/TopBar.vue @@ -171,12 +171,9 @@ const mismatch = computed(() => { background: color-mix(in srgb, var(--bg-elev) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); - /* The border counts: the sticky parts below it are `100vh - --topbar-h` - tall, and one pixel more here made the page scroll by one. */ - height: var(--topbar-h); } .topbar-inner { - height: 100%; + height: var(--topbar-h); display: flex; align-items: center; gap: 10px; From abc7bcda5916c762714d6f54b0a7c7149b0a6b4e Mon Sep 17 00:00:00 2001 From: Sebastian Gieseler Date: Wed, 21 Oct 2026 18:44:15 +0200 Subject: [PATCH 4/4] docs(adr): accept 0048; UDP is #192 Co-Authored-By: Claude Opus 5.5 --- ...8-a-containers-main-port-can-move-with-the-main-slot.md | 7 +++++-- docs/adr/README.md | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/adr/0048-a-containers-main-port-can-move-with-the-main-slot.md b/docs/adr/0048-a-containers-main-port-can-move-with-the-main-slot.md index 092a15a7..1cd9bdb3 100644 --- a/docs/adr/0048-a-containers-main-port-can-move-with-the-main-slot.md +++ b/docs/adr/0048-a-containers-main-port-can-move-with-the-main-slot.md @@ -1,6 +1,6 @@ # ADR-0048: A container's main port can be devstack's, and then moves with the main slot -- **Status:** Proposed +- **Status:** Accepted (2026-10-21) - **Date:** 2026-10-21 - **Deciders:** project owner - **Related:** [#184](https://github.com/nuetzliches/devstack/issues/184) (part 2), [ADR-0008](0008-background-workers-run-only-in-the-active-slot.md), [ADR-0024](0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md) point 5, [ADR-0029](0029-source-sync-and-port-forwarding-for-remote-lanes.md), [ADR-0030](0030-each-lane-has-its-own-infrastructure.md), [ADR-0043](0043-a-dev-servers-fixed-port-is-devstacks.md), [ADR-0047](0047-the-dashboard-makes-a-lane-from-a-branch.md) @@ -68,7 +68,10 @@ lanes, not every port moving. containers reach each other on the lane's network, as now. 6. **TCP only.** A UDP port of a named service stays Docker's in the main tree and does not move; the stack file check warns about it, and - `promote --lane` says which ports stayed. + `promote --lane` says which ports stayed. devstack forwards no UDP + anywhere yet (a lane on a node neither), which is a known limitation of + its own ([#192](https://github.com/nuetzliches/devstack/issues/192)); once + it does, `main_ports` moves UDP too. ## Alternatives considered diff --git a/docs/adr/README.md b/docs/adr/README.md index 399e297f..0056b924 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -96,4 +96,4 @@ stay. | [0045](0045-the-hub-notifies-the-desktop.md) | The hub notifies the desktop of what needs attention, without a tray | Accepted, amended 2026-10-21 (`guest_lane`) | | [0046](0046-the-hub-opens-a-worktree-in-the-users-programs.md) | The hub opens a stack's worktree in the user's own programs, from a fixed list | Accepted, amended 2026-10-21 (the program opens in front on Windows; GitHub Desktop) | | [0047](0047-the-dashboard-makes-a-lane-from-a-branch.md) | The dashboard makes a lane from a branch; the main tree's checkout stays the user's | Accepted | -| [0048](0048-a-containers-main-port-can-move-with-the-main-slot.md) | A container's main port can be devstack's, and then moves with the main slot | Proposed | +| [0048](0048-a-containers-main-port-can-move-with-the-main-slot.md) | A container's main port can be devstack's, and then moves with the main slot | Accepted |