Skip to content

fix(daemon): a lane being forgotten no longer holds the main tree's down - #589

Merged
p-i-p merged 1 commit into
mainfrom
fix/forgotten-lane-holds-main-down
Nov 19, 2026
Merged

p-i-p merged 1 commit into
mainfrom
fix/forgotten-lane-holds-main-down

Conversation

@p-i-p

@p-i-p p-i-p commented Nov 19, 2026

Copy link
Copy Markdown
Member

What and why

A downstream user stopped a lane (devstack down in its worktree), removed the worktree (git worktree remove), and ran devstack down in the main tree right after. The main tree's daemon was still forgetting the lane (closing its supervisor, removing its Compose projects and data; about 90 s with Docker Desktop on Windows). For all of that time the lane sat in pending, which active() and any_local() read as "started":

  • devstack down in the main tree kept the containers and services that serve the lanes (... removed but infra.a, infra.b, infra.c (lanes run: x)),
  • devstack down --all failed with did not stop: lane x: lane x is not started, because stop() looks the lane up in map, which the forget had already left,
  • the MCP lanes tool did not list the lane at all, and status said 0 started, so nothing explained why.

Daemon log of the case (names replaced):

01:27:07 request POST /v1/lanes/x/v1/down 204 (cli)
01:28:41 lane_forget_deferred lane=x why="it is being removed already"
01:28:48 main_down_kept containers=[infra.a, infra.b, infra.c] services=[...] why="they serve the lanes that run"
01:29:09 request POST /v1/down 409 "did not stop:\nlane `x`: lane `x` is not started (see `devstack lane list`)"
01:30:14 lane_removed lane=x why="its worktree is gone"

Change

  • Lanes::active() and Lanes::any_local() leave out lanes in forgetting: such a lane stops already, nothing is kept for it and down --all has nothing of it to stop. It is in pending only to keep a start out.
  • Lanes::any_running() still counts it, so the forget keeps the daemon, and Lanes::down_all() lets a forget end before the daemon stops (bounded by the shutdown's existing SHUTDOWN_STOP), instead of cutting it off with the lane's containers half removed. This also keeps a lane being forgotten out of the restart's carry_now(), which logged it as "its start or move was under way".
  • The MCP lanes tool says being removed (its worktree is gone), as devstack lane list says removing.

No review card: a bug fix within ADR-0024 and ADR-0030 (lanes that run keep the daemon and what serves them); a lane being removed does not run. Decided on my own: the wait in down_all(), and the MCP wording.

Siblings

  • stop_all() during a lane's start (in pending, not yet in map) still answers "is not started" for it. Left as it is: a start can be waited for or refused, which is a different decision.
  • After devstack down in a lane, a restart_on change still restarts that lane's Compose containers (restart_container does not check that the container runs; services skip with "it is not running"). Here it failed only because the worktree was gone (os error 267). Not changed here; worth an issue of its own.

Verification

  • New unit test lanes::tests::a_lane_being_forgotten_is_not_started: red without the fix at active() (left: ["gone"], right: []), green with it. Two wrong versions fail it at their own assertion: no wait in down_all() ("down_all ended while a lane was being forgotten"), and an active() that drops every pending lane (left: [], right: ["next"]).
  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets --locked -- -D warnings, cargo test -p devstack-daemon --lib (221 passed) and cargo test -p devstack --bins, in a Linux container (rust:latest): the Windows machine's MSVC toolset was incomplete at the time. Windows runs in CI.
  • Not reproduced end to end with a lane and Docker: the timing window (a forget that takes a minute) is what the unit test sets up directly.

🤖 Generated with Claude Code

When a lane's worktree is removed, the main tree's daemon forgets the
lane: its supervisor closes, its Compose projects and data are removed.
That takes a while (about 90 s seen with Docker Desktop on Windows), and
for all of it the lane sits in `pending`, which `active()` and
`any_local()` read as "started". So `devstack down` in the main tree
kept the containers and services that serve the lanes ("lanes run: x"),
and `devstack down --all` failed with "lane `x` is not started", because
`stop()` looks the lane up in `map`, which the forget had already left.

`active()` and `any_local()` now leave out the lanes in `forgetting`;
`any_running()` still counts them, so the forget keeps the daemon, and
`down_all()` lets a forget end before the daemon stops instead of
cutting it off half way. The MCP `lanes` tool says that such a lane is
being removed, as `devstack lane list` does.

Verification: the new unit test `a_lane_being_forgotten_is_not_started`
fails without the fix at `active()` (left ["gone"], right []), passes
with it; two wrong versions (no wait in `down_all`, `active()` without
any pending lane) fail it at their own assertion. fmt, clippy and the
tests of devstack-daemon and devstack in a Linux container.

Bug-Class: transition-read-as-running

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@p-i-p
p-i-p merged commit d3fdd65 into main Nov 19, 2026
14 checks passed
@p-i-p
p-i-p deleted the fix/forgotten-lane-holds-main-down branch November 19, 2026 00:57
@7schmiede 7schmiede mentioned this pull request Nov 19, 2026
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