From bf32601a9d39589c09368aa3255c6ae3a366f4a4 Mon Sep 17 00:00:00 2001 From: Sebastian Gieseler Date: Fri, 30 Oct 2026 18:47:51 +0100 Subject: [PATCH 1/2] feat: singleton replaces lanes = false; /v1/lanes/main (ADR-0080) The first step of "the main working tree is a lane": a service that runs once per machine is `singleton = true`; `lanes = false` stays an alias that `devstack check` reports as deprecated (ADR-0023). The main tree answers as the lane `main` too: `/v1/lanes/main/v1/...` is its `/v1/...`. No behaviour changes yet. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 13 ++++ crates/devstack-config/src/compat.rs | 15 +++-- crates/devstack-config/src/model.rs | 23 +++++-- crates/devstack-config/src/validate.rs | 2 +- crates/devstack-config/tests/stack_files.rs | 19 +++++- crates/devstack-daemon/src/api.rs | 40 ++++++++++- crates/devstack-daemon/src/commands.rs | 8 +-- crates/devstack-daemon/src/lanes.rs | 2 +- .../src/supervisor/handover.rs | 12 ++-- .../src/supervisor/lifecycle.rs | 10 +-- crates/devstack-daemon/src/supervisor/mod.rs | 4 +- crates/devstack-daemon/src/watch.rs | 2 +- crates/devstack/src/client.rs | 4 +- crates/devstack/tests/daemon_lifecycle.rs | 21 +++++- docs/adr/0080-the-main-tree-is-a-lane.md | 66 +++++++++++++++++++ docs/adr/README.md | 1 + docs/dashboard-api.md | 2 +- docs/stack-file.md | 6 +- 18 files changed, 209 insertions(+), 41 deletions(-) create mode 100644 docs/adr/0080-the-main-tree-is-a-lane.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b1702e7..70630b25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,19 @@ and listed with their assets on the ## [Unreleased] +### Changed + +- **`singleton = true` replaces `lanes = false`** (ADR-0080): a service that + runs once per machine, in the main working tree only. `lanes = false` + still works and means the same; `devstack check` reports it as + deprecated. + +### Added + +- **`/v1/lanes/main/v1/...`** answers as the main working tree's `/v1/...` + (ADR-0080), the first step towards the main tree being a lane like any + other. + ## [0.32.0] - 2026-10-30 A pool's project skills stay in their repository: a skill bound with diff --git a/crates/devstack-config/src/compat.rs b/crates/devstack-config/src/compat.rs index aaf071f0..749a667b 100644 --- a/crates/devstack-config/src/compat.rs +++ b/crates/devstack-config/src/compat.rs @@ -3,8 +3,7 @@ //! A key that is renamed or removed stays readable for a while: the model keeps //! accepting it (`#[serde(alias = "...")]`, or an optional field that is no //! longer used), and it is listed in [`DEPRECATED`], so `devstack check` and -//! `devstack doctor` say what replaces it. The table is empty until the first -//! such change. +//! `devstack doctor` say what replaces it. use crate::validate::Issue; @@ -18,7 +17,11 @@ pub struct Deprecation { pub since: &'static str, } -pub const DEPRECATED: &[Deprecation] = &[]; +pub const DEPRECATED: &[Deprecation] = &[Deprecation { + path: "services.*.lanes", + replacement: "`singleton = true` (ADR-0080)", + since: "0.33.0", +}]; /// Warnings for deprecated keys in a stack file's text (never errors). pub fn warnings(text: &str) -> Vec { @@ -91,7 +94,11 @@ mod tests { } #[test] - fn nothing_is_deprecated_yet() { + fn lanes_false_is_deprecated_for_singleton() { assert!(warnings("version = 1\n[stack]\nname = \"x\"\n").is_empty()); + let w = warnings("version = 1\n[services.tray]\nrun = \"x\"\nlanes = false\n"); + assert_eq!(w.len(), 1); + assert_eq!(w[0].path, "services.tray.lanes"); + assert!(w[0].message.contains("singleton"), "{}", w[0].message); } } diff --git a/crates/devstack-config/src/model.rs b/crates/devstack-config/src/model.rs index b343759b..f07cce57 100644 --- a/crates/devstack-config/src/model.rs +++ b/crates/devstack-config/src/model.rs @@ -941,12 +941,17 @@ pub struct Service { /// Restrict to these platforms; empty = all. #[serde(default)] pub platforms: Vec, - /// `false`: runs in the main working tree only, never in a lane - /// (ADR-0024). For what may run once per machine (a tray app, something - /// that holds a global lock); the main tree's instance serves every lane - /// and keeps its workers while a lane holds the main slot. - #[serde(default = "yes")] - pub lanes: bool, + /// `true`: runs once per machine, in the main working tree only, never in + /// a lane (ADR-0024, ADR-0080). For a tray app or something that holds a + /// global lock; the main tree's instance serves every lane and keeps its + /// workers while a lane holds the main slot. Read through + /// [`Service::singleton`]. + #[serde(default)] + pub singleton: bool, + /// `lanes = false`: the spelling of `singleton = true` before 0.33.0 + /// (deprecated, `compat::DEPRECATED`). + #[serde(default = "yes", rename = "lanes")] + pub legacy_lanes: bool, /// Compose service whose environment is the base (ADR-0014). pub compose: Option, /// Compose services whose `name:port` is rewritten to the published host @@ -1258,6 +1263,12 @@ fn opt_duration<'de, D: serde::Deserializer<'de>>(d: D) -> Result bool { + self.singleton || !self.legacy_lanes + } + /// `https` when the health check speaks TLS (a dev server with a /// certificate), otherwise `http`: how a browser or a command reaches the /// service on its fixed port. diff --git a/crates/devstack-config/src/validate.rs b/crates/devstack-config/src/validate.rs index 6361b94b..baa7d37d 100644 --- a/crates/devstack-config/src/validate.rs +++ b/crates/devstack-config/src/validate.rs @@ -1253,7 +1253,7 @@ pub fn warnings(stack: &Stack) -> Vec { pub fn repo_warnings(stack: &Stack, repo: &std::path::Path) -> Vec { let mut out = Vec::new(); for (name, svc) in &stack.services { - if svc.kind != Kind::Devserver || !svc.lanes || svc.prepare.is_some() { + if svc.kind != Kind::Devserver || svc.singleton() || svc.prepare.is_some() { continue; } let cwd = svc.cwd.as_deref().unwrap_or("."); diff --git a/crates/devstack-config/tests/stack_files.rs b/crates/devstack-config/tests/stack_files.rs index d0fdff2f..8c66c449 100644 --- a/crates/devstack-config/tests/stack_files.rs +++ b/crates/devstack-config/tests/stack_files.rs @@ -1005,7 +1005,7 @@ fn a_dev_server_with_a_package_json_and_no_prepare_is_a_warning() { "port = 5173\nprepare = { run = \"npm ci\" }\n", ); assert!(warnings(&prepared).is_empty()); - let main_only = text.replace("port = 5173\n", "port = 5173\nlanes = false\n"); + let main_only = text.replace("port = 5173\n", "port = 5173\nsingleton = true\n"); assert!(warnings(&main_only).is_empty()); assert!(warnings(&text.replace("cwd = \"web\"", "cwd = \"api\"")).is_empty()); } @@ -1238,3 +1238,20 @@ fn a_services_stop_takes_the_placeholders_of_its_run() { "{all}" ); } + +#[test] +fn singleton_and_the_older_lanes_false_mean_the_same() { + let svc = |extra: &str| { + let s = from_str( + &format!("{MINIMAL}[services.tray]\nrun = \"x\"\n{extra}"), + Path::new("t"), + ) + .unwrap(); + s.services["tray"].singleton() + }; + assert!(!svc("")); + assert!(svc("singleton = true\n")); + assert!(svc("lanes = false\n")); + assert!(!svc("lanes = true\n")); + assert!(!svc("singleton = false\n")); +} diff --git a/crates/devstack-daemon/src/api.rs b/crates/devstack-daemon/src/api.rs index ca664f04..b6e83cbd 100644 --- a/crates/devstack-daemon/src/api.rs +++ b/crates/devstack-daemon/src/api.rs @@ -35,6 +35,42 @@ pub struct AppState { } pub fn router(state: AppState) -> axum::Router { + let main_tree = state.lanes.is_some(); + let app = routes(state); + if !main_tree { + return app; + } + // The main working tree is the lane `main` too (ADR-0080): + // `/v1/lanes/main/v1/...` is its `/v1/...`, so a client can address + // every tree the same way. + let inner = app.clone(); + app.route( + "/v1/lanes/main/v1/{*rest}", + axum::routing::any(move |req: Request| { + use tower::ServiceExt; + let inner = inner.clone(); + async move { + let (mut parts, body) = req.into_parts(); + let path = parts.uri.path().replacen("/v1/lanes/main", "", 1); + let query = parts + .uri + .query() + .map(|q| format!("?{q}")) + .unwrap_or_default(); + let Ok(uri) = format!("{path}{query}").parse() else { + return err(StatusCode::BAD_REQUEST, "bad path"); + }; + parts.uri = uri; + match inner.oneshot(Request::from_parts(parts, body)).await { + Ok(r) => r, + Err(e) => match e {}, + } + } + }), + ) +} + +fn routes(state: AppState) -> axum::Router { axum::Router::new() .route("/v1/stack", get(stack)) .route("/v1/journal", get(journal)) @@ -308,7 +344,7 @@ struct DownQuery { /// `204` once every service (and with `infra`, the default, every Compose /// group) stopped; `409` naming what did not. In the main tree, lanes that /// still run keep the daemon they live in (ADR-0024), what serves them -/// (`lanes = false`, and the containers it comes `after`) and, a lane here, +/// (`singleton`, and the containers it comes `after`) and, a lane here, /// the `shared` containers (ADR-0030): then `200` with `{"lanes": [...], /// "kept": [...], "containers": [...]}`; every other container goes /// (ADR-0068). With `all` the lanes stop first (`Lanes::stop_all`). @@ -326,7 +362,7 @@ async fn down(State(s): State, Query(q): Query) -> Response let local = s.lanes.as_ref().is_some_and(|l| l.any_local()); let infra = q.infra; let sup = s.sup.clone(); - // Lanes that still run keep what serves them (`lanes = false`). + // Lanes that still run keep what serves them (`singleton`). let keeping = !lanes.is_empty() && s.lanes.is_some(); let result = tokio::task::spawn_blocking(move || { if keeping { diff --git a/crates/devstack-daemon/src/commands.rs b/crates/devstack-daemon/src/commands.rs index 9696a5d0..6a609979 100644 --- a/crates/devstack-daemon/src/commands.rs +++ b/crates/devstack-daemon/src/commands.rs @@ -134,7 +134,7 @@ impl Resolve for CommandContext { } /// A `start`, `stop` or `restart` step on a service that runs in the main -/// working tree only (`lanes = false`) has nothing to act on in a lane: the +/// working tree only (`singleton`) has nothing to act on in a lane: the /// main tree's instance serves it. The step is skipped, and the run's log /// says why, as `after` skips such a service: a command written for both /// trees does not end as failed in a lane after everything it needed ran. @@ -147,9 +147,9 @@ fn main_tree_only( else { return None; }; - (!lane.is_empty() && stack.services.get(*name).is_some_and(|s| !s.lanes)).then(|| { + (!lane.is_empty() && stack.services.get(*name).is_some_and(|s| s.singleton())).then(|| { format!( - "`{name}` runs in the main working tree only (`lanes = false`); its instance there serves this lane" + "`{name}` runs in the main working tree only (`singleton`); its instance there serves this lane" ) }) } @@ -433,7 +433,7 @@ services = ["db"] run = "x" [services.worker] run = "x" -lanes = false +singleton = true "#; fn stack() -> devstack_config::Stack { diff --git a/crates/devstack-daemon/src/lanes.rs b/crates/devstack-daemon/src/lanes.rs index f8391376..02d9233d 100644 --- a/crates/devstack-daemon/src/lanes.rs +++ b/crates/devstack-daemon/src/lanes.rs @@ -3473,7 +3473,7 @@ impl Lanes { .iter() .filter(|(_, s)| { s.autostart - && s.lanes + && !s.singleton() && (s.platforms.is_empty() || s.platforms .contains(&devstack_config::model::Platform::Linux)) diff --git a/crates/devstack-daemon/src/supervisor/handover.rs b/crates/devstack-daemon/src/supervisor/handover.rs index 7a185125..b04a8d04 100644 --- a/crates/devstack-daemon/src/supervisor/handover.rs +++ b/crates/devstack-daemon/src/supervisor/handover.rs @@ -80,7 +80,7 @@ impl Supervisor { self.stack .services .iter() - .filter(|(_, s)| s.proxied() && s.lanes && self.runs_here(s)) + .filter(|(_, s)| s.proxied() && !s.singleton() && self.runs_here(s)) .map(|(n, _)| n.clone()) .collect() } @@ -96,7 +96,7 @@ impl Supervisor { s.port.is_some() && !s.proxied() && s.kind != Kind::Job - && s.lanes + && !s.singleton() && self.runs_here(s) }) .map(|(n, _)| n.clone()) @@ -160,9 +160,9 @@ impl Supervisor { self.stack .services .iter() - // `lanes = false` keeps its workers wherever the main slot is. + // A `singleton` keeps its workers wherever the main slot is. .filter(|(n, s)| { - s.workers.is_some() && s.lanes && slots[n.as_str()].view.status.is_active() + s.workers.is_some() && !s.singleton() && slots[n.as_str()].view.status.is_active() }) .map(|(n, _)| n.clone()) .collect() @@ -229,7 +229,7 @@ impl Supervisor { /// such containers only has nothing to move (#184). pub(crate) fn moves_main_slot(stack: &devstack_config::Stack) -> bool { stack.services.values().any(|s| { - s.lanes + !s.singleton() && super::on_this_platform(s) && ((s.port.is_some() && s.kind != Kind::Job) || s.workers.is_some()) }) || stack.compose.values().any(|g| !g.main_ports.is_empty()) @@ -258,7 +258,7 @@ name = \"s\" "[services.once] run = \"x\" port = 9001 -lanes = false +singleton = true " ))); } diff --git a/crates/devstack-daemon/src/supervisor/lifecycle.rs b/crates/devstack-daemon/src/supervisor/lifecycle.rs index 243ba2ef..bc62dade 100644 --- a/crates/devstack-daemon/src/supervisor/lifecycle.rs +++ b/crates/devstack-daemon/src/supervisor/lifecycle.rs @@ -268,7 +268,7 @@ impl Supervisor { } /// Main tree, while lanes run: stop every service but those that serve - /// the lanes, a service with `lanes = false` and what it starts `after` + /// the lanes, a `singleton` service and what it starts `after` /// (ADR-0024 point 5: the main tree's instance serves every lane). With /// `infra` the containers go too (ADR-0068), but those a kept service /// comes `after` and, while `local_lanes`, the `shared` ones (a lane @@ -284,7 +284,7 @@ impl Supervisor { .stack .services .iter() - .filter(|(_, s)| !s.lanes) + .filter(|(_, s)| s.singleton()) .map(|(n, _)| n.clone()) .collect(); let mut containers: BTreeSet<(String, String)> = BTreeSet::new(); @@ -552,7 +552,7 @@ impl Supervisor { } if !self.runs_here(&svc) { return Err(format!( - "`{name}` runs in the main working tree only (`lanes = false`); its instance there serves this lane too" + "`{name}` runs in the main working tree only (`singleton`); its instance there serves this lane too" )); } if let Err(e) = self.ensure_after(&svc) { @@ -990,7 +990,9 @@ impl Supervisor { // A lane without the main slot never runs workers (ADR-0012 interim rule). // What runs in the main tree only keeps its workers: no lane takes them over. is_main: is_main - && (self.owns_main() || !svc.lanes || self.lane_workers.load(Ordering::SeqCst)), + && (self.owns_main() + || svc.singleton() + || self.lane_workers.load(Ordering::SeqCst)), // The slot, not the workers: a lane's main instance is no candidate. candidate: !is_main, // `{lane}`, `{lane_suffix}`, `DEVSTACK_LANE`: on a node the lane's diff --git a/crates/devstack-daemon/src/supervisor/mod.rs b/crates/devstack-daemon/src/supervisor/mod.rs index d1bf15ce..294c6167 100644 --- a/crates/devstack-daemon/src/supervisor/mod.rs +++ b/crates/devstack-daemon/src/supervisor/mod.rs @@ -980,9 +980,9 @@ impl Supervisor { } /// `svc` runs in this supervisor: on this platform, and in a lane only - /// unless it says `lanes = false`. + /// unless it is a `singleton`. fn runs_here(&self, svc: &Service) -> bool { - on_this_platform(svc) && (self.lane.is_empty() || svc.lanes) + on_this_platform(svc) && (self.lane.is_empty() || !svc.singleton()) } /// Run `action` once the changes for `key` have been quiet for a moment. diff --git a/crates/devstack-daemon/src/watch.rs b/crates/devstack-daemon/src/watch.rs index 3080eb5d..0a6ed0a9 100644 --- a/crates/devstack-daemon/src/watch.rs +++ b/crates/devstack-daemon/src/watch.rs @@ -286,7 +286,7 @@ fn watch(sup: Arc) -> Result { let platform = devstack_config::model::Platform::current(); let in_lane = !sup.lane.is_empty(); let runs = |s: &devstack_config::model::Service| { - (s.platforms.is_empty() || s.platforms.contains(&platform)) && (!in_lane || s.lanes) + (s.platforms.is_empty() || s.platforms.contains(&platform)) && (!in_lane || !s.singleton()) }; let built: Vec<(String, GlobSet)> = sup .stack diff --git a/crates/devstack/src/client.rs b/crates/devstack/src/client.rs index 5611ec71..bf830d0e 100644 --- a/crates/devstack/src/client.rs +++ b/crates/devstack/src/client.rs @@ -1186,7 +1186,7 @@ pub fn start_and_wait( && (s.platforms.is_empty() || s.platforms .contains(&devstack_config::model::Platform::current())) - && (c.lane().is_none() || s.lanes) + && (c.lane().is_none() || !s.singleton()) }) .map(|(n, _)| n.clone()) .collect(); @@ -2412,7 +2412,7 @@ pub fn down(stack_file: &Path, infra: bool, all: bool) -> Result<()> { .and_then(|v| serde_json::from_value(v[key].clone()).ok()) .unwrap_or_default() }; - // What serves the lanes (`lanes = false`) runs on for them. + // What serves the lanes (`singleton`) runs on for them. let kept = list("kept"); let containers = list("containers"); let mut stays = vec!["the daemon".to_string()]; diff --git a/crates/devstack/tests/daemon_lifecycle.rs b/crates/devstack/tests/daemon_lifecycle.rs index c3fb3150..2f19be6d 100644 --- a/crates/devstack/tests/daemon_lifecycle.rs +++ b/crates/devstack/tests/daemon_lifecycle.rs @@ -2053,7 +2053,7 @@ fn a_worktree_runs_as_a_lane() { "\n[services.web]\nkind = \"devserver\"\nrun = '\"{BIN}\" serve-static src/Site --port {{port}}'\nport = {web_port}\nprepare = {{ run = \"mkdir deps && echo x>>prepared.count\", outputs = [\"deps\"] }}\n" )); toml.push_str(&format!( - "\n[services.tray]\nkind = \"tool\"\nlanes = false\nrun = '\"{BIN}\" serve-static src/Site --port {{port}}'\nport = {tray_port}\n" + "\n[services.tray]\nkind = \"tool\"\nsingleton = true\nrun = '\"{BIN}\" serve-static src/Site --port {{port}}'\nport = {tray_port}\n" )); toml.push_str( "\n[commands.tray-cycle]\ndescription = \"t\"\nsteps = [{ restart = \"tray\" }, { start = \"tray\" }]\n", @@ -2253,7 +2253,7 @@ fn a_worktree_runs_as_a_lane() { ); // The lane's API takes requests for one service (a path parameter of - // its own under /v1/lanes//v1/...), and a `lanes = false` service + // its own under /v1/lanes//v1/...), and a `singleton = true` service // runs in the main tree only: there it answers, in the lane it is refused. // `devstack env` in the worktree shows what the lane gets, not the main tree. let env = wt_cli(&["env", "api"]); @@ -2292,6 +2292,21 @@ fn a_worktree_runs_as_a_lane() { tray.is_null() || tray["status"]["state"] == "stopped", "no tray in the lane: {tray}" ); + // The main working tree answers as the lane `main` too (ADR-0080). + let tray_of = |view: Value| { + view["services"] + .as_array() + .unwrap() + .iter() + .find(|v| v["name"] == "tray") + .map(|v| v["status"]["state"].clone()) + }; + let as_main = tray_of(s.daemon_get("/v1/lanes/main/v1/stack")); + assert_eq!(as_main, tray_of(s.daemon_get("/v1/stack"))); + assert!( + as_main.is_some_and(|st| st != "stopped"), + "the tray runs in main" + ); // 3. An edit in the worktree reaches the lane only. let main_build = s.info()["build"].as_str().unwrap().to_string(); @@ -2416,7 +2431,7 @@ fn a_worktree_runs_as_a_lane() { s.ok(&["status"]) ); // `down` and `up` in the main tree leave a running lane alone, and what - // serves it from the main tree (`tray`, `lanes = false`) runs on. + // serves it from the main tree (`tray`, `singleton = true`) runs on. let out = s.ok(&["down"]); assert!(out.contains("lanes keep running"), "{out}"); assert!(out.contains("tray that serve them"), "{out}"); diff --git a/docs/adr/0080-the-main-tree-is-a-lane.md b/docs/adr/0080-the-main-tree-is-a-lane.md new file mode 100644 index 00000000..aba7d27c --- /dev/null +++ b/docs/adr/0080-the-main-tree-is-a-lane.md @@ -0,0 +1,66 @@ +# ADR-0080: The main working tree is a lane; the daemon, the main slot and what runs once per machine are the stack's + +- **Status:** Accepted (card in the pull request, points 1 to 7 approved 2026-10-30); built in steps, see "Built" +- **Date:** 2026-10-30 +- **Deciders:** project owner +- **Related:** [ADR-0008](0008-background-workers-run-only-in-the-active-slot.md) (workers in the active slot), [ADR-0010](0010-promotion-mechanism.md) (the proxy holds the fixed ports), [ADR-0023](0023-stack-file-compatibility.md) (a renamed key keeps an alias), [ADR-0024](0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md) (a lane is a supervisor in the main tree's daemon), [ADR-0030](0030-each-lane-has-its-own-infrastructure.md) (each lane has its own infrastructure; `shared`), [ADR-0049](0049-a-lanes-need-is-measured-disk-included.md) (a lane's measured need), [ADR-0068](0068-a-stop-takes-the-containers-too.md) (a stop takes the containers), [ADR-0070](0070-a-review-card-comes-before-the-code-an-adr-records-what-was-built.md), [ADR-0078](0078-the-hub-follows-every-stacks-worktrees.md) (a stopped stack's lane starts without the main tree), [#387](https://github.com/nuetzliches/devstack/issues/387) (several stacks on one machine) + +## Context + +ADR-0024 made every other worktree a lane of the main working tree's +daemon. The main tree itself stayed apart: the daemon is its process, it +owns the artifact store and the fixed ports, its `down` ends the daemon, +`[compose.] shared` services are its containers that lanes use, a +`lanes = false` service runs in it only, and it alone runs background +workers by default. About 130 places in the daemon tell the main tree from +a lane. + +Three things the project wants next run into that difference: a port shift +for a whole stack when several stacks on one machine declare the same ports +(#387), a page per stack above its lanes, and starting the main tree on +another machine as a lane can be. The owner's principle: the main tree's +data is not special. With a correct stack file every lane holds everything +of its own, and nothing of one lane talks to another; worktrees and lanes +are decoupled completely. + +## Decision + +The owner approved the review card in the conversation on **2026-10-30**, +all seven points: + +| Category | Point | Beats | Reversing costs | +|---|---|---|---| +| concept | The daemon belongs to the stack (artifact store, main slot, registry entry, shared services) and runs without any running lane. | The daemon as the main tree's process. | Medium: its lifecycle and the restart (ADR-0052). | +| concept | The main working tree is the lane `main`, equal to and decoupled from every other lane; no lane reaches another. | The main tree as a special case. | High once built upon. | +| contract | Nothing breaks for `main`: offset 0, Compose project ``, its volumes and `/v1/...` stay; `/v1/lanes/main/...` is added. | Renaming it with a data migration. | Low. | +| concept | `shared` belongs to the stack: started with the first lane that needs it, ended with the last, run as its own Compose project `-shared`. | Lanes using the main tree's containers. | Medium. | +| contract | `singleton = true` replaces `lanes = false` (an alias after ADR-0023): exactly once per machine, in the lane that holds the main slot, moving with `promote --lane`. | Main tree only. | Low to medium. | +| term | `devstack down` stops one's own lane, in the main tree too; `--stack` and the dashboard's "Stop stack" stop everything. ADR-0068 point 3's exception goes. | `down` in the main tree ending everything. | Low, but visible. | +| term | The main slot (the fixed ports) belongs to the stack and points at one lane or none; that lane runs the background workers, others only with `--workers` or a profile. It is where #387's shift will live. | Fixed ports and workers as the main tree's. | Low. | + +Decided by the agent alone (not asked): the memory check compares a new +lane's measured need (ADR-0049) with the machine's free memory instead of +with what the main tree takes; the daemon, not the main tree, prunes the +artifact store; a lane without a stack file of its own keeps falling back +to the main tree's for now. + +## Built + +- **0.33.0:** `singleton = true` is the key; `lanes = false` still works, + means the same and is reported by `devstack check` as deprecated + (`compat::DEPRECATED`). Its behaviour is unchanged so far: main tree only. + `/v1/lanes/main/v1/...` answers as the main tree's `/v1/...` (no lane is + ever named `main`: a worktree folder of that name becomes `lane-main`). + +Still to build, each in a pull request of its own: the daemon prunes the +store and the memory check uses measured need; `-shared`; the +main slot as one lane or none, with the singletons and the workers +following it; `down` and `down --stack`. + +## Consequences + +- A client (the dashboard, MCP, the CLI) can address every tree as + `/v1/lanes//v1/...`, `main` included, and stop telling the main + tree apart (the dashboard's part is ADR-0081). +- Stack files keep loading unchanged; `lanes = false` stays readable until + a `version = 2` (ADR-0023). diff --git a/docs/adr/README.md b/docs/adr/README.md index c232dbfa..e41bd1b4 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -162,3 +162,4 @@ stay. | [0077](0077-a-sets-skills-are-grouped-and-switched-one-by-one.md) | A set's skills are grouped by their frontmatter and switched one by one | Accepted (card in the pull request; point 5 taken back) | | [0078](0078-the-hub-follows-every-stacks-worktrees.md) | The hub follows every stack's worktrees; a stopped stack's lane can be started from the dashboard | Accepted (card in the pull request) | | [0079](0079-skills-local-to-a-working-tree.md) | Skills local to a working tree: a pool's project skills bound to their repository, devstack's own untracked | Accepted (card in the pull request) | +| [0080](0080-the-main-tree-is-a-lane.md) | The main working tree is a lane; the daemon, the main slot and what runs once per machine are the stack's | Accepted (card in the pull request); built in steps | diff --git a/docs/dashboard-api.md b/docs/dashboard-api.md index 678429b6..34acbca3 100644 --- a/docs/dashboard-api.md +++ b/docs/dashboard-api.md @@ -405,7 +405,7 @@ type StoreView = { | `POST /v1/lanes/{lane}/stop` | its services stop and it is no longer started (its builds stay); `409` while it serves the main ports. The lanes after it | | `POST /v1/lanes/{lane}/main` | that lane serves the main ports (`main`: the main tree again), workers move with them. A lane on a node only on a dedicated one (ADR-0025 point 4): the fixed ports forward to its ports here, its workers run on the node, and the main tree takes the ports back by itself when the lane is gone (its lease over, its node silent for longer than a lease lives). The main ports are the fixed ports of `[services.*]`, not a Compose container's published ones: `409` for a stack with no service on a port and none with workers, which would move nothing (#184) | | `POST /v1/main-slot {"owns"}` | only the daemon in a lane container on a node: it holds its requester's main slot, or no longer; its worker services restart with the switch. The requester says it again with each renewal. Answers `{"owns"}` | -| `/v1/lanes/{lane}/v1/...` | the lane's own API, every route of this table; `StackView` then carries `lane`, the main one `main_served_by` while a lane serves its ports | +| `/v1/lanes/{lane}/v1/...` | the lane's own API, every route of this table; `StackView` then carries `lane`, the main one `main_served_by` while a lane serves its ports. `/v1/lanes/main/v1/...` is the main working tree's own `/v1/...` (since 0.33.0, [ADR-0080](adr/0080-the-main-tree-is-a-lane.md)), so a client can address every tree the same way; no lane is ever named `main` | | `GET /v1/services/{name}/builds?limit=50` | JSON, the builds of the service newest first, read from the diagnostic log (so across daemon restarts): `[{build, started_ms, updated_ms, outcome, reason, current, artifact, log}]` (`artifact`: the store still has it, so it can be gone back to; `log`: its build log is still kept; older builds outlive both in the list); `outcome` is `live`, `failed`, `superseded` (a newer change replaced it before it went live), `held`, `interrupted` (it was building, starting or switching and is no longer: the daemon stopped, or a stop or restart came between), or the state it is in now (only the candidate's build) | | `GET /v1/services/{name}/logs/files` | JSON, the kept logs newest first: `[{file, kind: "run"\|"build", started_ms, modified_ms, build, port, bytes, current}]` | | `GET /v1/logs?grep=…&tail=50` | text, matching lines of every service's current log as `service \| line` (`grep` is required, `400` without it; `tail` counts per service); with `since=` every instance written to within that time | diff --git a/docs/stack-file.md b/docs/stack-file.md index dae6fb9c..0581794c 100644 --- a/docs/stack-file.md +++ b/docs/stack-file.md @@ -472,7 +472,7 @@ server reloads itself). | Key | Meaning | | --- | --- | | `autostart = false` | started only on demand (`devstack start `) | -| `lanes = false` | runs in the main working tree only, never in a lane: for what may run once per machine (a tray app, something holding a global lock); see `[lanes]` | +| `singleton = true` | runs once per machine, in the main working tree only, never in a lane: for a tray app or something holding a global lock; see `[lanes]`. Before 0.33.0 spelled `lanes = false`, which still works and is reported as deprecated ([ADR-0080](adr/0080-the-main-tree-is-a-lane.md)) | | `platforms = ["windows"]` | only on these platforms (`windows`, `linux`, `macos`); default `[]`: every platform | | `ensure_dirs = ["{repo}/data/files"]` | created before start | | `prepare = { run = "npm ci", inputs = ["web/package-lock.json"] }` | installs what a copy of the source lacks (see below) | @@ -753,7 +753,7 @@ stop the lane first: see `prepare`). Ignored files are not in the snapshot: anyway). - `{lane}` and `{lane_suffix}` (empty in the main tree) are still there, e.g. for a name that shows up outside the stack; data needs them no longer. -- `lanes = false` keeps a service in the main working tree: a lane neither +- `singleton = true` (formerly `lanes = false`) keeps a service in the main working tree: a lane neither starts it nor waits for it (`after`), `devstack start` refuses it there, and the main tree's instance serves every lane. A command's `start`, `stop` or `restart` step on it is skipped in a lane, with a line in the run's log, @@ -839,7 +839,7 @@ A file that uses `{compose..project}` should say `requires = group's `announced_ports` as the tree has them, so `docker compose -p {compose.app.project} up -d media` in a lane keeps the moved port, and the tree's `DEVSTACK_LANE` and `DEVSTACK_LANE_SUFFIX` (ADR-0064). -In a lane, a `start`, `stop` or `restart` step on a `lanes = false` service +In a lane, a `start`, `stop` or `restart` step on a `singleton` service is skipped (the main tree's instance serves the lane), with a line in the run's log. From 531aa26c1c2dedbf31008b57fa4ce6354a218d09 Mon Sep 17 00:00:00 2001 From: Sebastian Gieseler Date: Fri, 30 Oct 2026 20:55:11 +0100 Subject: [PATCH 2/2] feat(config): deprecate `shared`; ADR-0080 records the narrower decision `[compose.] shared` ties a lane to the main tree, reaches only native services, behaves differently for a lane on a node and mixes the lanes' telemetry. It keeps working; `devstack check` and `doctor` now report it, and it goes with `version = 2`. A profile's `skip` saves the memory instead. ADR-0080 now records what was decided after weighing "the main tree is a lane" inside the daemon: the main tree answers as the lane `main`, `singleton` replaces `lanes = false`, and `shared` is deprecated. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 13 +++- crates/devstack-config/src/compat.rs | 27 +++++-- ...s-a-supervisor-in-the-main-trees-daemon.md | 2 +- ...30-each-lane-has-its-own-infrastructure.md | 2 +- .../0068-a-stop-takes-the-containers-too.md | 2 +- ...-answers-as-a-lane-shared-is-deprecated.md | 74 +++++++++++++++++++ docs/adr/0080-the-main-tree-is-a-lane.md | 66 ----------------- docs/adr/README.md | 8 +- docs/dashboard-api.md | 2 +- docs/stack-file.md | 11 ++- skills/devstack-config/SKILL.md | 8 +- skills/devstack/SKILL.md | 2 +- 12 files changed, 130 insertions(+), 87 deletions(-) create mode 100644 docs/adr/0080-the-main-tree-answers-as-a-lane-shared-is-deprecated.md delete mode 100644 docs/adr/0080-the-main-tree-is-a-lane.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 70630b25..508ac3c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,11 +16,20 @@ and listed with their assets on the still works and means the same; `devstack check` reports it as deprecated. +### Deprecated + +- **`[compose.] shared`** (ADR-0080): it works as before, and + `devstack check` and `devstack doctor` report it; it goes with + `version = 2`. It ties a lane to the main tree, reaches only native + services (a lane's containers do not find it by name), behaves + differently for a lane on a node, and mixes the lanes' telemetry. Drop + it: every lane starts its own containers; a profile's `skip` leaves out + what a lane can do without. + ### Added - **`/v1/lanes/main/v1/...`** answers as the main working tree's `/v1/...` - (ADR-0080), the first step towards the main tree being a lane like any - other. + (ADR-0080), so a client addresses every tree as a lane. ## [0.32.0] - 2026-10-30 diff --git a/crates/devstack-config/src/compat.rs b/crates/devstack-config/src/compat.rs index 749a667b..7ccd90de 100644 --- a/crates/devstack-config/src/compat.rs +++ b/crates/devstack-config/src/compat.rs @@ -17,11 +17,18 @@ pub struct Deprecation { pub since: &'static str, } -pub const DEPRECATED: &[Deprecation] = &[Deprecation { - path: "services.*.lanes", - replacement: "`singleton = true` (ADR-0080)", - since: "0.33.0", -}]; +pub const DEPRECATED: &[Deprecation] = &[ + Deprecation { + path: "services.*.lanes", + replacement: "`singleton = true` (ADR-0080)", + since: "0.33.0", + }, + Deprecation { + path: "compose.*.shared", + replacement: "each lane's own containers: drop the key; a profile's `skip` leaves containers out (ADR-0080)", + since: "0.33.0", + }, +]; /// Warnings for deprecated keys in a stack file's text (never errors). pub fn warnings(text: &str) -> Vec { @@ -101,4 +108,14 @@ mod tests { assert_eq!(w[0].path, "services.tray.lanes"); assert!(w[0].message.contains("singleton"), "{}", w[0].message); } + + #[test] + fn shared_is_deprecated() { + let w = warnings( + "version = 1\n[compose.app]\nfiles = [\"c.yml\"]\nservices = [\"mail\"]\nshared = [\"mail\"]\n", + ); + assert_eq!(w.len(), 1); + assert_eq!(w[0].path, "compose.app.shared"); + assert!(w[0].message.contains("own containers"), "{}", w[0].message); + } } diff --git a/docs/adr/0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md b/docs/adr/0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md index c0a775a7..33e20883 100644 --- a/docs/adr/0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md +++ b/docs/adr/0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md @@ -1,6 +1,6 @@ # ADR-0024: A lane is a supervisor in the main working tree's daemon -- **Status:** Accepted, amended 2026-10-15 twice (the lanes are the worktrees; git owns them, lanes run from a copy); point 4 replaced by [ADR-0030](0030-each-lane-has-its-own-infrastructure.md) (2026-10-16); point 1's "devstack never creates or removes one" replaced for the hub by [ADR-0047](0047-the-dashboard-makes-a-lane-from-a-branch.md) (2026-10-21); point 7 amended 2026-10-21 (the removal is shown while it runs) +- **Status:** Accepted, amended 2026-10-15 twice (the lanes are the worktrees; git owns them, lanes run from a copy); point 4 replaced by [ADR-0030](0030-each-lane-has-its-own-infrastructure.md) (2026-10-16); point 1's "devstack never creates or removes one" replaced for the hub by [ADR-0047](0047-the-dashboard-makes-a-lane-from-a-branch.md) (2026-10-21); point 7 amended 2026-10-21 (the removal is shown while it runs); point 5's `lanes = false` is spelled `singleton = true` since [ADR-0080](0080-the-main-tree-answers-as-a-lane-shared-is-deprecated.md) (2026-10-30) - **Date:** 2026-10-15 - **Deciders:** project owner - **Related:** plan §3.5, [ADR-0002](0002-processes-run-from-immutable-artifacts.md), [ADR-0007](0007-one-http-api-is-the-control-surface.md), [ADR-0008](0008-background-workers-run-only-in-the-active-slot.md), [ADR-0010](0010-promotion-mechanism.md), [ADR-0012](0012-shared-infrastructure-between-lanes.md), [ADR-0016](0016-a-daemon-restart-is-a-clean-restart.md), [ADR-0025](0025-a-lane-can-run-on-another-node.md) to [ADR-0029](0029-source-sync-and-port-forwarding-for-remote-lanes.md) (remote lanes, accepted 2026-10-16); [ADR-0044](0044-a-lanes-prepared-directories-can-be-linked-into-its-worktree.md) (prepared directories linked into the worktree) diff --git a/docs/adr/0030-each-lane-has-its-own-infrastructure.md b/docs/adr/0030-each-lane-has-its-own-infrastructure.md index 7da060af..3124d278 100644 --- a/docs/adr/0030-each-lane-has-its-own-infrastructure.md +++ b/docs/adr/0030-each-lane-has-its-own-infrastructure.md @@ -1,6 +1,6 @@ # ADR-0030: Each lane has its own infrastructure -- **Status:** Accepted (2026-10-16) +- **Status:** Accepted (2026-10-16); point 3 (`shared`) deprecated by [ADR-0080](0080-the-main-tree-answers-as-a-lane-shared-is-deprecated.md) (2026-10-30) - **Date:** 2026-10-16 - **Deciders:** project owner - **Related:** plan §3.5, [ADR-0004](0004-infrastructure-is-delegated-to-compose.md), [ADR-0008](0008-background-workers-run-only-in-the-active-slot.md), [ADR-0012](0012-shared-infrastructure-between-lanes.md) (decided here), [ADR-0014](0014-native-services-take-their-configuration-from-compose.md), [ADR-0024](0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md) (point 4 replaced here), [ADR-0025](0025-a-lane-can-run-on-another-node.md), [ADR-0057](0057-a-port-a-container-announces-moves-inside-it-too.md) (point 2 detailed: an announced port moves inside the container too), [ADR-0068](0068-a-stop-takes-the-containers-too.md) (the main tree's stop takes its containers too, but the `shared` ones a lane here uses) diff --git a/docs/adr/0068-a-stop-takes-the-containers-too.md b/docs/adr/0068-a-stop-takes-the-containers-too.md index 44463e5c..79a88301 100644 --- a/docs/adr/0068-a-stop-takes-the-containers-too.md +++ b/docs/adr/0068-a-stop-takes-the-containers-too.md @@ -1,6 +1,6 @@ # ADR-0068: A stop takes the stack's containers too, unless asked to keep them -- **Status:** Accepted (2026-10-27) +- **Status:** Accepted (2026-10-27); point 3's `shared` containers go with `shared`, deprecated by [ADR-0080](0080-the-main-tree-answers-as-a-lane-shared-is-deprecated.md) (2026-10-30) - **Date:** 2026-10-27 - **Deciders:** project owner - **Related:** [ADR-0004](0004-infrastructure-is-delegated-to-compose.md), [ADR-0016](0016-a-daemon-restart-is-a-clean-restart.md), [ADR-0024](0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md) (point 5), [ADR-0030](0030-each-lane-has-its-own-infrastructure.md) (points 3 and 4), [ADR-0038](0038-a-lanes-data-outlives-its-lease.md), [ADR-0052](0052-a-restart-carries-the-lanes-over.md), [ADR-0058](0058-a-profile-can-leave-out-containers-and-services.md) diff --git a/docs/adr/0080-the-main-tree-answers-as-a-lane-shared-is-deprecated.md b/docs/adr/0080-the-main-tree-answers-as-a-lane-shared-is-deprecated.md new file mode 100644 index 00000000..3547825e --- /dev/null +++ b/docs/adr/0080-the-main-tree-answers-as-a-lane-shared-is-deprecated.md @@ -0,0 +1,74 @@ +# ADR-0080: The main working tree answers as the lane `main`; `singleton` replaces `lanes = false`; `shared` is deprecated + +- **Status:** Accepted (2026-10-30; card in the pull request) +- **Date:** 2026-10-30 +- **Deciders:** project owner +- **Related:** [ADR-0023](0023-stack-file-compatibility.md) (a renamed key keeps an alias; a break needs `version = 2`), [ADR-0024](0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md) (a lane is a supervisor in the main tree's daemon; point 5, `lanes = false`), [ADR-0030](0030-each-lane-has-its-own-infrastructure.md) (each lane has its own infrastructure; point 3, `shared`), [ADR-0058](0058-a-profile-can-leave-out-containers-and-services.md) (a profile's `skip`), [ADR-0068](0068-a-stop-takes-the-containers-too.md) (point 3: what a main tree's stop keeps for the lanes), [ADR-0070](0070-a-review-card-comes-before-the-code-an-adr-records-what-was-built.md), [ADR-0078](0078-the-hub-follows-every-stacks-worktrees.md) (a lane starts without the main tree's services), [#387](https://github.com/nuetzliches/devstack/issues/387) (several stacks on one machine) + +## Context + +Three things the project wants next look as if they need the main working +tree to be a lane like any other: a port shift for a whole stack when +several stacks on one machine declare the same ports (#387), a page per +stack above its lanes with one view for every tree, and fewer ties between +a lane and the main tree. The owner's principle: the main tree's data is +not special; with a correct stack file every lane holds everything of its +own, and nothing of one lane talks to another. + +A first card made the main tree the lane `main` inside the daemon as well +(the daemon, the main slot and what runs once per machine the stack's; +`down` stopping one's own lane; workers and singletons following the main +slot). It was approved and then, the same day, weighed again and withdrawn +before anything of it beyond this ADR's points was built: + +- None of the goals needs it. #387's shift belongs to the fixed ports and + the machine's registry; a port graph needs a model of the ports; one view + for every tree needs one API for every tree. Only starting the main + checkout itself on another machine does, and a worktree promoted to the + main ports does that today. +- The pain behind it was a lane on a node needing a local start of the main + tree. Since 0.31.0 (ADR-0078) a lane's start brings up the daemon only; + the main tree's services stay stopped. The daemon itself has to run here: + it syncs a node's lane, renews its lease and forwards its ports. +- The main tree as a lane with offset 0 keeps its exceptions (its ports are + the main slot's, it runs in place, its Compose project has no suffix): + about 130 places in the daemon's most tested code would change and the + difference would remain under another name. A main tree that is truly a + lane needs its own offset and every fixed port held by a forward, a + breaking change of its own, decided when it is needed. + +What does tie a lane to the main tree is `[compose.] shared`: a lane +here uses the main tree's containers. Only native services reach them (a +lane's containers do not find them by name, so one downstream stack lost +the telemetry of its lanes' containers without a word); a lane on a node +runs its own, so the same lane behaves differently by place; every lane +sends into the same telemetry; a lane on another branch gets the main +tree's definition; and `down` in the main tree keeps containers for the +lanes (ADR-0068 point 3). What it saves is memory, which a profile's `skip` +saves too, visibly. + +## Decision + +The owner approved the points in the conversation on **2026-10-30**: + +| Category | Point | Beats | Reversing costs | +|---|---|---|---| +| contract | `/v1/lanes/main/v1/...` is the main working tree's `/v1/...`, so a client addresses every tree as a lane. No lane is ever named `main` (a worktree folder of that name is the lane `lane-main`). | Clients telling the main tree apart by path. | Low: an added route. | +| contract | `singleton = true` names a service that runs once per machine, in the main working tree only. `lanes = false` stays an alias that `devstack check` reports as deprecated. | A name that says where a service does not run instead of what it is. | Low. | +| contract | `[compose.] shared` is deprecated: it works as before, `devstack check` and `devstack doctor` report it, and it goes with `version = 2`. Every lane then starts all of its containers; a profile's `skip` leaves out what a lane can do without. | Building it out (a stack-owned `-shared`, network aliases into every lane): more coupling for a saving a profile gives too. | Low until `version = 2`. | + +Decided by the agent alone (not asked): the deprecation messages name the +replacement; the reference keeps `shared` documented, marked deprecated, +with the reasons. + +## Consequences + +- Stack files load and behave as before; `devstack check` names the two + deprecated keys with what replaces them. +- The dashboard can show every tree, the main one included, through one API + (its part: one view for every tree, a page per stack, ADR-0081). +- When `version = 2` comes, `shared` goes and with it ADR-0068 point 3's + exception and ADR-0030 point 3. +- The daemon stays the main working tree's process. Making the main tree a + lane inside the daemon is a decision of its own, taken when starting the + main checkout on another machine is needed. diff --git a/docs/adr/0080-the-main-tree-is-a-lane.md b/docs/adr/0080-the-main-tree-is-a-lane.md deleted file mode 100644 index aba7d27c..00000000 --- a/docs/adr/0080-the-main-tree-is-a-lane.md +++ /dev/null @@ -1,66 +0,0 @@ -# ADR-0080: The main working tree is a lane; the daemon, the main slot and what runs once per machine are the stack's - -- **Status:** Accepted (card in the pull request, points 1 to 7 approved 2026-10-30); built in steps, see "Built" -- **Date:** 2026-10-30 -- **Deciders:** project owner -- **Related:** [ADR-0008](0008-background-workers-run-only-in-the-active-slot.md) (workers in the active slot), [ADR-0010](0010-promotion-mechanism.md) (the proxy holds the fixed ports), [ADR-0023](0023-stack-file-compatibility.md) (a renamed key keeps an alias), [ADR-0024](0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md) (a lane is a supervisor in the main tree's daemon), [ADR-0030](0030-each-lane-has-its-own-infrastructure.md) (each lane has its own infrastructure; `shared`), [ADR-0049](0049-a-lanes-need-is-measured-disk-included.md) (a lane's measured need), [ADR-0068](0068-a-stop-takes-the-containers-too.md) (a stop takes the containers), [ADR-0070](0070-a-review-card-comes-before-the-code-an-adr-records-what-was-built.md), [ADR-0078](0078-the-hub-follows-every-stacks-worktrees.md) (a stopped stack's lane starts without the main tree), [#387](https://github.com/nuetzliches/devstack/issues/387) (several stacks on one machine) - -## Context - -ADR-0024 made every other worktree a lane of the main working tree's -daemon. The main tree itself stayed apart: the daemon is its process, it -owns the artifact store and the fixed ports, its `down` ends the daemon, -`[compose.] shared` services are its containers that lanes use, a -`lanes = false` service runs in it only, and it alone runs background -workers by default. About 130 places in the daemon tell the main tree from -a lane. - -Three things the project wants next run into that difference: a port shift -for a whole stack when several stacks on one machine declare the same ports -(#387), a page per stack above its lanes, and starting the main tree on -another machine as a lane can be. The owner's principle: the main tree's -data is not special. With a correct stack file every lane holds everything -of its own, and nothing of one lane talks to another; worktrees and lanes -are decoupled completely. - -## Decision - -The owner approved the review card in the conversation on **2026-10-30**, -all seven points: - -| Category | Point | Beats | Reversing costs | -|---|---|---|---| -| concept | The daemon belongs to the stack (artifact store, main slot, registry entry, shared services) and runs without any running lane. | The daemon as the main tree's process. | Medium: its lifecycle and the restart (ADR-0052). | -| concept | The main working tree is the lane `main`, equal to and decoupled from every other lane; no lane reaches another. | The main tree as a special case. | High once built upon. | -| contract | Nothing breaks for `main`: offset 0, Compose project ``, its volumes and `/v1/...` stay; `/v1/lanes/main/...` is added. | Renaming it with a data migration. | Low. | -| concept | `shared` belongs to the stack: started with the first lane that needs it, ended with the last, run as its own Compose project `-shared`. | Lanes using the main tree's containers. | Medium. | -| contract | `singleton = true` replaces `lanes = false` (an alias after ADR-0023): exactly once per machine, in the lane that holds the main slot, moving with `promote --lane`. | Main tree only. | Low to medium. | -| term | `devstack down` stops one's own lane, in the main tree too; `--stack` and the dashboard's "Stop stack" stop everything. ADR-0068 point 3's exception goes. | `down` in the main tree ending everything. | Low, but visible. | -| term | The main slot (the fixed ports) belongs to the stack and points at one lane or none; that lane runs the background workers, others only with `--workers` or a profile. It is where #387's shift will live. | Fixed ports and workers as the main tree's. | Low. | - -Decided by the agent alone (not asked): the memory check compares a new -lane's measured need (ADR-0049) with the machine's free memory instead of -with what the main tree takes; the daemon, not the main tree, prunes the -artifact store; a lane without a stack file of its own keeps falling back -to the main tree's for now. - -## Built - -- **0.33.0:** `singleton = true` is the key; `lanes = false` still works, - means the same and is reported by `devstack check` as deprecated - (`compat::DEPRECATED`). Its behaviour is unchanged so far: main tree only. - `/v1/lanes/main/v1/...` answers as the main tree's `/v1/...` (no lane is - ever named `main`: a worktree folder of that name becomes `lane-main`). - -Still to build, each in a pull request of its own: the daemon prunes the -store and the memory check uses measured need; `-shared`; the -main slot as one lane or none, with the singletons and the workers -following it; `down` and `down --stack`. - -## Consequences - -- A client (the dashboard, MCP, the CLI) can address every tree as - `/v1/lanes//v1/...`, `main` included, and stop telling the main - tree apart (the dashboard's part is ADR-0081). -- Stack files keep loading unchanged; `lanes = false` stays readable until - a `version = 2` (ADR-0023). diff --git a/docs/adr/README.md b/docs/adr/README.md index e41bd1b4..bf8fc67e 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -106,13 +106,13 @@ stay. | [0021](0021-a-hub-serves-the-dashboard.md) | A hub on a fixed port serves the dashboard for every stack | Accepted, amended (streams over WebSocket; the pool area polls, ended by ADR-0073); the tray is the hub's client, ADR-0060 | | [0022](0022-network-egress-sandbox.md) | Outbound network calls of supervised services are visible and need an allow rule | Proposed | | [0023](0023-stack-file-compatibility.md) | Stack files stay readable; migrations once devstack has outside users | Accepted | -| [0024](0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md) | A lane is a supervisor in the main working tree's daemon | Accepted, amended twice (lanes are the worktrees, run from a copy); point 4 replaced by ADR-0030; point 1 replaced in part for the hub by ADR-0047; point 7 amended 2026-10-21 (the removal is shown while it runs); point 6 amended by ADR-0052 (a restart carries the lanes over) | +| [0024](0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md) | A lane is a supervisor in the main working tree's daemon | Accepted, amended twice (lanes are the worktrees, run from a copy); point 4 replaced by ADR-0030; point 1 replaced in part for the hub by ADR-0047; point 7 amended 2026-10-21 (the removal is shown while it runs); point 6 amended by ADR-0052 (a restart carries the lanes over); point 5's `lanes = false` is `singleton` since ADR-0080 | | [0025](0025-a-lane-can-run-on-another-node.md) | A lane can run on another node, as a Linux container with its own infrastructure | Accepted; point 10 (showing and moving a lane) amended; amended 2026-10-19 (a start on a node answers once leased; its phases are timed); noted 2026-10-21 (its daemon starts first, its containers come up under it); points 5 and 7 amended by ADR-0038; point 7 amended by ADR-0052 (a restart keeps the lanes on nodes) | | [0026](0026-placement-by-the-requester-admission-by-the-node.md) | The requester places a lane; the node admits it, under a lease | Accepted; points 1, 3 replaced by ADR-0031; point 5 amended 2026-10-30 (a lease lives a grace without renewals: an hour on a dedicated node, 15 minutes on another) | | [0027](0027-trust-between-nodes.md) | Nodes and requesters trust each other by pinned keys, never by network location | Accepted; points 1, 2 replaced by ADR-0031; point 5 amended | | [0028](0028-lane-images.md) | A remote lane runs in a stack-provided toolchain image; the node supplies devstack | Accepted, amended (a Dockerfile the node builds); point 3 noted 2026-10-26 (`prepare`'s results are in ADR-0062's store); addendum 2026-10-29 (no lane image: refused before the lease) | | [0029](0029-source-sync-and-port-forwarding-for-remote-lanes.md) | A remote lane works on a mirror of the requester's tree; ports and API come back over one connection | Accepted; point 2 amended (`[lanes] sync`); Consequences built by ADR-0038; point 4 extended to UDP by ADR-0056 | -| [0030](0030-each-lane-has-its-own-infrastructure.md) | Each lane has its own infrastructure | Accepted; point 2 detailed by ADR-0057 (an announced port moves inside the container too); the main tree's stop while lanes run, ADR-0068; point 5 amended 2026-10-27 (Docker Desktop's VM checked for the containers) | +| [0030](0030-each-lane-has-its-own-infrastructure.md) | Each lane has its own infrastructure | Accepted; point 2 detailed by ADR-0057 (an announced port moves inside the container too); the main tree's stop while lanes run, ADR-0068; point 5 amended 2026-10-27 (Docker Desktop's VM checked for the containers); point 3 (`shared`) deprecated by ADR-0080 | | [0031](0031-a-coordinator-places-lanes.md) | A coordinator places lanes and admits members; nodes admit leases; data goes directly | Accepted, amended (one binary: `devstack node`), amended 2026-10-19 (versions in the pool), amended 2026-10-21 (no share switch) | | [0032](0032-the-pool-is-administered-in-the-dashboard.md) | The pool is administered in the dashboard, by members with the admin role | Accepted, amended (admins grant nodes); extended by ADR-0039 (updating a server); point 4 detailed by ADR-0076 (tabs, a machine's page) | | [0033](0033-a-node-decides-what-runs-on-it.md) | A node decides who runs lanes on it, and what a lane there may do | Accepted, amended (what Compose files may ask; limits; the node's own policy; amended 2026-10-20: the node runs the model it checked, known keys only, a lane's projects end with it; noted 2026-10-21: what holds while a lane's containers start under its running daemon) | @@ -150,7 +150,7 @@ stay. | [0065](0065-the-store-is-warmed-for-a-ref-before-a-lane-needs-it.md) | The store is warmed for a ref before a lane needs it | Accepted; built, noted 2026-10-26 | | [0066](0066-a-measured-cpu-need-is-capped-at-half-of-what-its-node-gives-lanes.md) | A measured CPU need is capped at half of what its node gives lanes | Accepted | | [0067](0067-a-change-at-runtime-says-who-made-it.md) | A change at runtime says where it came from, and a journal keeps the last ones | Accepted; built 2026-10-27 (point 2 for the main slot and services); addendum 2026-10-27: the dashboard shows the journal | -| [0068](0068-a-stop-takes-the-containers-too.md) | A stop takes the stack's containers too, unless asked to keep them | Accepted | +| [0068](0068-a-stop-takes-the-containers-too.md) | A stop takes the stack's containers too, unless asked to keep them | Accepted; point 3's `shared` containers go with `shared` (deprecated by ADR-0080) | | [0069](0069-devstack-mcp-can-carry-the-tools-of-upstream-mcp-servers.md) | `devstack mcp` can carry the tools of upstream MCP servers, logged in once by the hub | Accepted ([card](https://github.com/nuetzliches/devstack/issues/316#issuecomment-6452598449)): a proxy in the hub, per user; amended 2026-10-27 (keychain via `keyring`, a file on Linux without a Secret Service); addendum 2026-10-28 (option B: a pool names upstreams, a member accepts each); addendum 2026-10-30 (an OAuth app's client secret, for GitHub) | | [0070](0070-a-review-card-comes-before-the-code-an-adr-records-what-was-built.md) | A review card comes before the code; an ADR records what was built | Accepted (supersedes ADR-0001); point 1 amended 2026-10-28 (the card in the conversation and the pull request, no issue) | | [0071](0071-the-dashboard-writes-no-file-of-a-repository.md) | The dashboard writes no file of a repository; a change to one is a prompt for a coding agent | Accepted, amended by ADR-0079 (skills devstack owns, ignored by git, are written into a working tree) | @@ -162,4 +162,4 @@ stay. | [0077](0077-a-sets-skills-are-grouped-and-switched-one-by-one.md) | A set's skills are grouped by their frontmatter and switched one by one | Accepted (card in the pull request; point 5 taken back) | | [0078](0078-the-hub-follows-every-stacks-worktrees.md) | The hub follows every stack's worktrees; a stopped stack's lane can be started from the dashboard | Accepted (card in the pull request) | | [0079](0079-skills-local-to-a-working-tree.md) | Skills local to a working tree: a pool's project skills bound to their repository, devstack's own untracked | Accepted (card in the pull request) | -| [0080](0080-the-main-tree-is-a-lane.md) | The main working tree is a lane; the daemon, the main slot and what runs once per machine are the stack's | Accepted (card in the pull request); built in steps | +| [0080](0080-the-main-tree-answers-as-a-lane-shared-is-deprecated.md) | The main working tree answers as the lane `main`; `singleton` replaces `lanes = false`; `shared` is deprecated | Accepted (card in the pull request) | diff --git a/docs/dashboard-api.md b/docs/dashboard-api.md index 34acbca3..f7842e7b 100644 --- a/docs/dashboard-api.md +++ b/docs/dashboard-api.md @@ -405,7 +405,7 @@ type StoreView = { | `POST /v1/lanes/{lane}/stop` | its services stop and it is no longer started (its builds stay); `409` while it serves the main ports. The lanes after it | | `POST /v1/lanes/{lane}/main` | that lane serves the main ports (`main`: the main tree again), workers move with them. A lane on a node only on a dedicated one (ADR-0025 point 4): the fixed ports forward to its ports here, its workers run on the node, and the main tree takes the ports back by itself when the lane is gone (its lease over, its node silent for longer than a lease lives). The main ports are the fixed ports of `[services.*]`, not a Compose container's published ones: `409` for a stack with no service on a port and none with workers, which would move nothing (#184) | | `POST /v1/main-slot {"owns"}` | only the daemon in a lane container on a node: it holds its requester's main slot, or no longer; its worker services restart with the switch. The requester says it again with each renewal. Answers `{"owns"}` | -| `/v1/lanes/{lane}/v1/...` | the lane's own API, every route of this table; `StackView` then carries `lane`, the main one `main_served_by` while a lane serves its ports. `/v1/lanes/main/v1/...` is the main working tree's own `/v1/...` (since 0.33.0, [ADR-0080](adr/0080-the-main-tree-is-a-lane.md)), so a client can address every tree the same way; no lane is ever named `main` | +| `/v1/lanes/{lane}/v1/...` | the lane's own API, every route of this table; `StackView` then carries `lane`, the main one `main_served_by` while a lane serves its ports. `/v1/lanes/main/v1/...` is the main working tree's own `/v1/...` (since 0.33.0, [ADR-0080](adr/0080-the-main-tree-answers-as-a-lane-shared-is-deprecated.md)), so a client can address every tree the same way; no lane is ever named `main` | | `GET /v1/services/{name}/builds?limit=50` | JSON, the builds of the service newest first, read from the diagnostic log (so across daemon restarts): `[{build, started_ms, updated_ms, outcome, reason, current, artifact, log}]` (`artifact`: the store still has it, so it can be gone back to; `log`: its build log is still kept; older builds outlive both in the list); `outcome` is `live`, `failed`, `superseded` (a newer change replaced it before it went live), `held`, `interrupted` (it was building, starting or switching and is no longer: the daemon stopped, or a stop or restart came between), or the state it is in now (only the candidate's build) | | `GET /v1/services/{name}/logs/files` | JSON, the kept logs newest first: `[{file, kind: "run"\|"build", started_ms, modified_ms, build, port, bytes, current}]` | | `GET /v1/logs?grep=…&tail=50` | text, matching lines of every service's current log as `service \| line` (`grep` is required, `400` without it; `tail` counts per service); with `since=` every instance written to within that time | diff --git a/docs/stack-file.md b/docs/stack-file.md index 0581794c..83999102 100644 --- a/docs/stack-file.md +++ b/docs/stack-file.md @@ -91,7 +91,7 @@ networks = ["shop-shared"] # external networks cre after = ["search"] # other groups that must be healthy first restart_on = { db = ["deploy/dev/db/init/**"] } # a change restarts that container urls = { scheduler = "http://localhost:5100/ui", db = "" } # dashboard links (below) -shared = ["mailbox"] # lanes use the main tree's (see [lanes]) +shared = ["mailbox"] # deprecated: lanes use the main tree's (see [lanes]) main_ports = ["web"] # their fixed ports move with `promote --lane` (below) announced_ports = ["media:7881", "media:7882/udp"] # ports the server tells its clients (below) ``` @@ -472,7 +472,7 @@ server reloads itself). | Key | Meaning | | --- | --- | | `autostart = false` | started only on demand (`devstack start `) | -| `singleton = true` | runs once per machine, in the main working tree only, never in a lane: for a tray app or something holding a global lock; see `[lanes]`. Before 0.33.0 spelled `lanes = false`, which still works and is reported as deprecated ([ADR-0080](adr/0080-the-main-tree-is-a-lane.md)) | +| `singleton = true` | runs once per machine, in the main working tree only, never in a lane: for a tray app or something holding a global lock; see `[lanes]`. Before 0.33.0 spelled `lanes = false`, which still works and is reported as deprecated ([ADR-0080](adr/0080-the-main-tree-answers-as-a-lane-shared-is-deprecated.md)) | | `platforms = ["windows"]` | only on these platforms (`windows`, `linux`, `macos`); default `[]`: every platform | | `ensure_dirs = ["{repo}/data/files"]` | created before start | | `prepare = { run = "npm ci", inputs = ["web/package-lock.json"] }` | installs what a copy of the source lacks (see below) | @@ -748,6 +748,13 @@ stop the lane first: see `prepare`). Ignored files are not in the snapshot: - `[compose.] shared = ["mailbox"]`: services a lane uses from the main tree instead of starting its own, for what holds nothing per lane (a telemetry dashboard, a fake SMTP server); reached by their published ports. + **Deprecated since 0.33.0** ([ADR-0080](adr/0080-the-main-tree-answers-as-a-lane-shared-is-deprecated.md)): + it works as before and `devstack check` says so; it goes with `version = 2`. + It couples a lane to the main tree, reaches only native services (a lane's + containers do not find it by name), behaves differently for a lane on a + node (which runs its own), and lets the lanes' telemetry mix. Drop it: every + lane then starts its own containers. To save memory, a profile leaves + containers out (`skip`, see `[profiles.]`). - Before a lane starts, devstack checks that the machine has about the memory the main tree takes now and refuses otherwise (`devstack up --force` starts it anyway). diff --git a/skills/devstack-config/SKILL.md b/skills/devstack-config/SKILL.md index fbaca362..70e69b89 100644 --- a/skills/devstack-config/SKILL.md +++ b/skills/devstack-config/SKILL.md @@ -51,9 +51,11 @@ without a stack file starts from `devstack init` (a draft with TODOs). `env`. - **Lanes have their own containers.** A worktree runs as a lane with its ports moved (`[lanes] port_step`) and its own Compose project, so its - database is its own and needs no `{lane_suffix}`; services that hold nothing - per lane (a telemetry dashboard, a fake SMTP server) can stay shared: - `[compose.] shared = ["mailbox"]`. A dev server needs `{port}` + database is its own and needs no `{lane_suffix}`. Every lane starts all of + its containers: `[compose.] shared` is deprecated (0.33.0; drop it + when you touch the file), and a profile's `skip` leaves out what a lane + can do without. A service that may run once per machine only (a tray app) + says `singleton = true` (formerly `lanes = false`). A dev server needs `{port}` (in `run`, or in `env` for a config that reads it) to run in a lane. A command names a Compose project as `{compose..project}`, never literally (`docker compose -p {compose.app.project} exec -T db ...`): in a diff --git a/skills/devstack/SKILL.md b/skills/devstack/SKILL.md index 5334b036..ac36deb6 100644 --- a/skills/devstack/SKILL.md +++ b/skills/devstack/SKILL.md @@ -55,7 +55,7 @@ Run from the repository root (devstack looks for `{{devstack:stack_file}}` there | `devstack logs ` | a Compose container's output by its service name (`docker compose logs`, timestamped; `--grep`, `--since 30m`) | | `devstack builds ` | the service's builds, newest first: live, failed (with the reason), superseded by a newer change, held; answers "did my change ever go live" and "since when is it broken" | | `devstack hot-reload on\|off` | for a debugging session: the toolchain's watcher (e.g. `dotnet watch`) from the source tree instead of builds and candidates; needs `hot_reload` in the stack file. Switch it off again afterwards | -| `devstack up` in a `git worktree` | starts that worktree's **lane** (every worktree is one) in the main tree's daemon: its own builds, ports moved by +100 (+200, ...), its own containers (a Compose project per lane, ports moved alike; `shared` services come from the main tree), no background workers (`--workers` turns them on; `--force` skips the memory check). Every command in the worktree then acts on the lane (`devstack lane list` shows all) | +| `devstack up` in a `git worktree` | starts that worktree's **lane** (every worktree is one) in the main tree's daemon: its own builds, ports moved by +100 (+200, ...), its own containers (a Compose project per lane, ports moved alike; the deprecated `shared` services come from the main tree), no background workers (`--workers` turns them on; `--force` skips the memory check). Every command in the worktree then acts on the lane (`devstack lane list` shows all) | | `git worktree add -b ` | a new worktree is a lane at once, not started (devstack never creates or removes worktrees; use git or your tool); tell the user its dashboard page (`devstack ui --link` in it). A lane runs from a copy of its worktree, so `git worktree remove` works while it runs and stops it. `devstack lane stop ` stops a lane and keeps the worktree | | a directory in a worktree that `prepare` links (`node_modules`, see `devstack lane list`: `linked`) | it is **the lane's copy**, not the worktree's own: on Windows a junction, which looks like a folder. Do not reinstall, delete or clean it there (`npm ci`, `rm -rf`, `git clean -x`, an IDE's "delete node_modules"): that empties what the lane runs from (for a lane on a node, its copy from the store), and a running dev server then fails. To install your own, ask the user, then stop the lane (`devstack lane stop ` removes the link) or remove only the link (`cmd /c rmdir ` on Windows, without `/s`; `rm ` elsewhere, no trailing slash), then install. devstack prepares a copy emptied this way again (a notice says so), but the lane's dev server fails until then | | `devstack lane start [--on ]` | start a lane from the main tree (or anywhere in the repository), as `devstack up` in its worktree does; `status` in the main tree lists the lanes in one line. **To run another branch or commit beside the main stack** (an end-to-end run against a given commit, a review): `git worktree add `, `devstack lane start ` (its ports are the main ports plus its offset, `devstack lane list`), test against those, `devstack lane stop `, `git worktree remove `. A commit without a stack file of its own runs with the main tree's. **For an acceptance run** use the stack file's profile if it has one (`status` lists none; `[profiles]` in the file): `devstack lane start --profile

--run` starts the lane as the profile says (a build instead of a dev server, workers, fresh data, the suite's env) and runs its suite command. A worktree another tool or script created is a lane too: starting it gives its own ports, containers and database without building a separate environment |