@vibelord/lanes 1.7.3 → 1.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +9 -0
  2. package/package.json +1 -1
  3. package/payload/lanes/VERSION +1 -1
  4. package/payload/lanes/bin/lanes +97 -17
  5. package/payload/lanes/bin/lanes-site-serve +15 -0
  6. package/payload/lanes/bin-rs/BINARIES.json +5 -0
  7. package/payload/lanes/container/lane-mcp +105 -5
  8. package/payload/lanes/container/lane_core.py +110 -0
  9. package/payload/lanes/container/throttle-pulse +159 -14
  10. package/payload/lanes/docs/ARCHITECTURE.md +108 -11
  11. package/payload/lanes/docs/DESIGN.md +10 -8
  12. package/payload/lanes/docs/INSTALL.md +1 -1
  13. package/payload/lanes/docs/RUNBOOK.md +297 -5
  14. package/payload/lanes/docs/USERGUIDE.md +11 -6
  15. package/payload/lanes/install/host-install.sh +14 -3
  16. package/payload/lanes/libexec/adopt.py +325 -0
  17. package/payload/lanes/libexec/cutover.py +656 -0
  18. package/payload/lanes/libexec/docsd.py +12 -8
  19. package/payload/lanes/libexec/doctor_lanes2.py +213 -0
  20. package/payload/lanes/libexec/economy_poll.py +87 -2
  21. package/payload/lanes/libexec/lanes_lib.py +465 -2
  22. package/payload/lanes/libexec/native.sh +38 -0
  23. package/payload/lanes/libexec/native_bin.py +668 -0
  24. package/payload/lanes/libexec/shadow.py +1311 -0
  25. package/payload/lanes/libexec/sidebar.py +252 -30
  26. package/payload/lanes/libexec/sidebar_status.py +373 -25
  27. package/payload/lanes/libexec/statusd.py +67 -3
  28. package/payload/lanes/libexec/tokens.py +99 -131
  29. package/payload/lanes/libexec/tokens.sh +1 -1
  30. package/payload/lanes/libexec/update.py +48 -5
  31. package/payload/lanes/libexec/users.py +282 -0
  32. package/payload/lanes/site/README.md +9 -0
  33. package/payload/lanes/site/conformance.py +280 -0
  34. package/payload/lanes/site/protocol.py +368 -0
  35. package/payload/lanes/site/server.py +314 -0
  36. package/payload/lanes/tokens/README.md +156 -0
  37. package/payload/lanes/tokens/generate.py +930 -0
  38. package/payload/lanes/tokens/generated/parity.v1.tsv +489 -0
  39. package/payload/lanes/tokens/generated/tokens.resolved.json +835 -0
  40. package/payload/lanes/tokens/tokens.v1.json +763 -0
  41. package/payload/lanes/tokens/tokens.v1.schema.json +143 -0
  42. package/payload/lanes/web/README.md +132 -4
  43. package/payload/lanes/web/directory.css +95 -0
  44. package/payload/lanes/web/directory.js +951 -0
  45. package/payload/lanes/web/generated/README.md +107 -0
  46. package/payload/lanes/web/generated/lanes2_protocol.d.mts +1162 -0
  47. package/payload/lanes/web/generated/lanes2_protocol.mjs +2333 -0
  48. package/payload/lanes/web/mobile.js +17 -21
  49. package/payload/lanes/web/tokens.css +137 -0
  50. package/payload/manifest.json +7 -4
@@ -633,10 +633,15 @@ lanes studio-host re-key --yes after the owner revoked the Host: a new mac
633
633
  The relay keeps keyboard forwarding independent of a blocked display, and current views idle while their tabs
634
634
  have no viewer (BEY-6931/6932). A hidden tab reconnecting to its saved target is normal; the native agent keeps
635
635
  running. `views/<device>/visibility.json` is only a five-second observer hint: uncertainty keeps viewers active.
636
- For a sidebar that refreshes too often, inspect `sidebar-status/<board>.json`; `statusd` updates it only when
637
- that board's rows, shared fleet facts or cross-board attention change (BEY-6933). Older deployments fall back
638
- to `status.json`. These bounds reduce frontend load; exhausted workspace memory or scratch storage still needs
639
- the Fleet owner's resource and retention fix. Do not restart agents or delete tmux sockets to treat latency.
636
+ For a sidebar that refreshes too often, inspect `sidebar-status/@directory.json`, the shared directory every
637
+ sidebar reads: `statusd` rewrites it only when a rendered lane fact, a session listing or a fleet fact changes,
638
+ never for a sample time or process metadata alone, and a sidebar repaints only when its own board's view changed
639
+ apart from the sample times (BEY-6933, Lanes 2.0 C7). A fleet block marked stale on that source while statusd
640
+ runs means statusd stopped publishing payloads: the health line's `status_at` stopped moving
641
+ (`journalctl --user -u lanes-statusd | grep cycle`). Without the directory a sidebar reads
642
+ `sidebar-status/<board>.json`, which `statusd` updates when that board's rows, shared fleet facts or cross-board
643
+ attention change; older deployments fall back to `status.json`. These bounds reduce frontend load; exhausted
644
+ workspace memory or scratch storage still needs the Fleet owner's resource and retention fix. Do not restart agents or delete tmux sockets to treat latency.
640
645
 
641
646
  2026-09-19: ceobox thrashed (load 400+ on 64 cores, swap full, memory pressure 68 %); `coder-dev-work` sat at 207 of
642
647
  its 208 GiB, 95 GiB of that in its RAM-backed `/tmp`. **No lane was lost** — every pane kept its pid — but the
@@ -817,7 +822,8 @@ night sky of single-dot Braille "stars". Started with no client attached it pain
817
822
  - It stops recurring when the clients agree on brightness: the same light/dark choice in Cursor's terminal and in the
818
823
  lanes window (Ghostty `theme = light:…,dark:…` follows the OS and therefore flips twice a day).
819
824
 
820
- The sidebar's own colours and glyphs come from one token table (`libexec/tokens.py`; spec
825
+ The sidebar's own colours and glyphs come from one token source (`tokens/tokens.v1.json`, read through the generated
826
+ table `libexec/tokens.py` loads; regenerate with `python3 tokens/generate.py --write`; spec
821
827
  `docs/superpowers/specs/2026-10-03-lanes-cockpit-design.md` §2.4) and these switches, resolved per device (the
822
828
  notification switch `--notify` / `LANES_NOTIFY` resolves the same way, above):
823
829
 
@@ -2971,6 +2977,172 @@ signature: without `strict` (and without `**kwargs`) it makes the older call and
2971
2977
  on one address then refuse, as before 1.7.0, instead of being listed — and `lanes doctor` prints the same as a `⚠`.
2972
2978
  The hook's fix is to forward keyword arguments (`def build_registry(previous=None, **kw)`), after which nothing is said.
2973
2979
 
2980
+ ## Federation: lanes-site/1 (guests behind a forced-command key)
2981
+
2982
+ Plan row H1 (BEY-6899, BEY-6912; Lanes2 architecture §3.32 and §7.5; DM-LANES-SITE-ADAPTER). A host whose boards
2983
+ live in containers on other docker hosts (the guests) reaches them through one protocol, `lanes-site/1`: newline JSON
2984
+ over one long-lived `ssh -T` per guest, behind a forced-command key on the guest. It ships with the reference server
2985
+ and stays inert until a catalog board names a guest transport: with no `transport` key anywhere every call path is
2986
+ the one of before, and `containers.json` keeps its bytes.
2987
+
2988
+ **What v1 does and does not do on the host.** Before the aggregator duty (Lanes2 W20) a host builds no lanes for a
2989
+ guest board: `lanes sync` refuses it with the board error `aggregator_absent: board <id> is behind guest:<alias>; …`
2990
+ (shown by `lanes doctor` under `registry clean`) and keeps the lanes the board had, stale; statusd never reads a
2991
+ guest's lanes as `missing` (it does not observe them, so they stay stale, then `unknown`); `lanes upload` into a guest
2992
+ board refuses before anything lands (a guest's files are not readable from here); statusd neither delivers, renames
2993
+ nor re-arms there (the guest's own statusd does all three). What it gives now: `lanes doctor` greets every guest a
2994
+ board names (`✓ guest:<alias> answers lanes-site/1`, the O-3 installed witness), and the host client
2995
+ (`lanes_lib.SiteClient`, `lane_write`'s `tmux_write` arm, `guest_probe`) that a host whose registry carries a guest's
2996
+ lanes types through — today only a host whose registry a runtime hook builds (rd-control; which functions its hook
2997
+ replaces is O-3 part 1's anchor list, [inferred] not measured here).
2998
+
2999
+ **Choosing the transport.** A board of `catalog.json` takes an optional `"transport"`: `"local"` (the default: its
3000
+ containers run on this docker host) or `"guest:<ssh alias>"`. Every container a board's manifest names gets that
3001
+ board's transport. A board whose transport is invalid, or that puts a container behind another transport than a
3002
+ second board does, costs that board only: `lanes sync` makes it the board's error (its previous lanes kept, stale),
3003
+ its containers get no route (a typed action says `no write transport for <c> (catalog.json board <b>: transport … is
3004
+ not …)`), and every other board keeps its route. A guest's containers are not asked of `docker inspect` here:
3005
+ `lanes sync` records them in `containers.json` as
3006
+ `{"pid": 0, "home": "", "running": false, "transport": "guest:<alias>", "container": "<name>"}`.
3007
+
3008
+ ```json
3009
+ {"version": 1, "workspaces": [
3010
+ {"id": "work", "title": "Work", "manifest": "workspaces.work.json", "transport": "guest:rd-work-site"}]}
3011
+ ```
3012
+
3013
+ **On the guest.** The guest runs its own Lanes (its registry and containers files are what the server answers from).
3014
+ The aggregator's site key gets one `authorized_keys` line (AR §3.32's path), and nothing else may run with it:
3015
+
3016
+ ```text
3017
+ command="/home/<user>/.local/share/lanes/current/bin/lanes-site-serve",restrict ssh-ed25519 AAAA... lanes-site@<aggregator>
3018
+ ```
3019
+
3020
+ `bin/lanes-site-serve` (POSIX sh) execs `python3 -S -E -B site/server.py`. When `$LANES_STATE/flags/rs-site` exists it
3021
+ names the native adapter (`lanesd site-serve`, W20), which no guest has yet, so it answers one
3022
+ `adapter_unavailable` frame and exits 69 instead of serving something else. `restrict` gives no pty, no forwarding and
3023
+ no agent, and the client's requested command is ignored. On the aggregator, `~/.ssh/config` names the alias
3024
+ (`Host rd-work-site`, its `HostName`, `User`, `IdentityFile` of the site key, `IdentitiesOnly yes`). The site alias is
3025
+ never the alias a holder attaches through: attaching needs a pty, which this key refuses.
3026
+
3027
+ **What it serves (v1).** `hello` (first, always: `lanes_site`/`proto` 1, `guest_id`, `boot_id`, `versions`,
3028
+ `capabilities`, `ops`, `epochs` — `{}` until an owner fences a workspace; a newer major is refused
3029
+ `version_unsupported`), `boards.list`, `boards.lanes{board}`, `tmux_read{container, socket, args}` (a read-only verb
3030
+ allowlist: `list-sessions`, `list-panes`, `list-windows`, `list-clients`, `has-session`, `display-message -p`,
3031
+ `capture-pane -p`; no format job `#(`, no `E:`/`T:` format modifier, which expands a value such as a pane title as a
3032
+ format again, no `pane_start_command` and no `@` user option inside a format, no word ending in `;`, only a socket a
3033
+ registered lane of that container uses; the reply's text is cut to a byte budget that always fits one frame, a
3034
+ capture keeping its newest lines), ONE write `tmux_write{lane, text, enter}` (send-keys only, into the active pane of
3035
+ a lane registered on that guest, at most 4000 printable characters on one line, under the recipient's dispatch lock
3036
+ `~/.lz/state/dispatch/<lane>.lock`, the Enter as a second client 0.5 s later), and `exec{template, args: {container}}`
3037
+ by template id only: `pulse.rearm` and `peerd.rearm` (plan row H1's two re-arms, 10 s each). The guest decides
3038
+ whether a re-arm is due by its own statusd's checks — `busy` while its own health is critical, `skipped` (with the
3039
+ reason in `detail`) when the loop is not installed or its state file is fresh, `off` with `LANES_PEERS=0` — so the
3040
+ aggregator is never a second actor. The mutating ops take an optional `intent` (echoed) and `epoch`; v1 enforces
3041
+ neither, and the owner fence's codes (`epoch_required`, `intent_required`, `stale_epoch`, `owner_unclaimed`, …) are
3042
+ reserved so that turning it on stays additive. Every adapter checks a request's shape, verb allowlist and text bound
3043
+ before its recipient. Errors are typed (`hello_required`, `lane_unregistered`, `verb_refused`, `argv_refused`,
3044
+ `template_unknown`, `busy`, `text_too_long`, … — `site/protocol.py` `ERRORS`). No op serves a lane's create recipe
3045
+ or a secret-looking key; `tmux_read` returns what tmux shows of a registered socket (a screen can hold anything typed
3046
+ into it). There is no file read or write, no message store op and no stream in v1: those arrive with the owner
3047
+ runtime (§3.32 W17/W20).
3048
+
3049
+ **Typed actions with no write transport.** A container with no local init and no guest transport is asked through
3050
+ `tmux_probe` first, looked up at call time: when the fleet's runtime hook replaces it and it answers, typing goes on
3051
+ (`lanes upload --paste` types through it, and `lanes doctor` prints `✓ write transport for <c> — tmux_probe
3052
+ reaches it …`), while `lanes names sync` and `lanes message` refuse, because their recipient checks read the container's own
3053
+ files. Only when `tmux_probe` answers `noserver` (rd-control's boards with no hook on `tmux_probe`, BEY-6899) does
3054
+ every typed action say `not typed: no write transport for <container> (…)`: on stderr with exit 1 (`lanes upload
3055
+ --paste` after its files landed and its `.done` was written, `lanes message`, `lanes names sync` with or without
3056
+ `--write`), once per change in statusd's journal (`transport <container>: not typed: …`), and as one
3057
+ `✗ write transport for <container>` line in `lanes doctor`. `lanes upload --paste` exits 1 for every paste that typed
3058
+ nothing (a guest's refusal, a guest that gave no answer — whether it was typed is then not known and it is not
3059
+ resent — or a lane that is no tmux lane). `lanes names sync --write` into a guest's lane is `not typed here` and
3060
+ exit 1: lanes-site/1 v1 carries no rename; run it on the guest. A stopped local container stays
3061
+ `container <name> is not running`.
3062
+
3063
+ **The site hook.** `lanes doctor` prints a site hook that replaced `lanes_lib.build_registry` without `strict`
3064
+ (`site_hook_old()`, BEY-6912) as a `⚠` until the O-3 installed witness (W20) — never by release count; site.conf
3065
+ `LANES_SITE_HOOK=refuse` refuses it now (`✗`, exit status 1). The fix is the hook's: forward keyword arguments, or
3066
+ retire it for `guest:` boards.
3067
+
3068
+ **Conformance.** One kit drives any adapter over stdio through the protocol suite (hello, version and epochs, typed
3069
+ errors, the read allowlist, writes refused outside the registered set and over their bounds, malformed intents, exec
3070
+ by template only, no secret-looking key in any reply). Because it exists to catch an adapter that does not conform,
3071
+ it aims every refused write, refused verb, out-of-bound text and exec at an unregistered target, and asks a
3072
+ registered lane one harmless read (`has-session`); a non-conforming adapter fails the check without anything
3073
+ reaching a lane:
3074
+
3075
+ ```sh
3076
+ python3 lanes/site/conformance.py -- ssh -T -o BatchMode=yes rd-work-site
3077
+ python3 lanes/site/conformance.py -- python3 -S -E -B lanes/site/server.py
3078
+ ```
3079
+
3080
+ ## Lanes 2.0 native binaries and flags (`lanes rs`; every flag off)
3081
+
3082
+ Lanes 2.0 moves components to Rust one at a time, each behind a flag (lanes2 Round 1 H2, BEY-6988; the Lanes2
3083
+ architecture specification §7.3, §7.4, §9.3 and decision D9, and the Rust runtime specification §3.1, §3.2, which takes
3084
+ precedence). No release ships a native binary yet, nothing reads a flag yet, and every path below stays the Python
3085
+ one. Measured on the dev container only; no reference machine has run a native component.
3086
+
3087
+ **Flags.** One `site.conf` line per component (`~/.config/lanes/site.conf`, the same `LANES_<KEY>=<value>` grammar as
3088
+ the site facts), AR §7.3's components:
3089
+
3090
+ | Key | Native binary | Round 1 |
3091
+ | --- | --- | --- |
3092
+ | `LANES_RS_RELAY` | `lanes-terminal` (its `relay` mode, `connection.py`'s arguments) | `on` admitted for a verified binary; read by lane C7's view hook (`view.sh` and `holders/ssh.sh`), not yet |
3093
+ | `LANES_RS_SIDEBAR` | `lanes-terminal` (its `sidebar` mode) | `on` admitted for a verified binary; read by lane C7's sidebar-wrapper hook, not yet |
3094
+ | `LANES_RS_KEY` | `lanes-terminal` (the hot keys, lane C6) | `on` admitted for a verified binary; no reader yet |
3095
+ | `LANES_RS_SIGNAL` | `lanes-hook` (the hook emitter behind `lane-signal`) | `on` admitted for a verified binary; container install is a later round |
3096
+ | `LANES_RS_MCP`, `LANES_RS_AGENTD` | none yet: no lanes crate declares one | refused `binary_absent` |
3097
+ | `LANES_RS_STATUSD`, `VISIBILITY`, `NOTIFY`, `ECONOMY`, `SYNC`, `SITE`, `STORE` | none: duties of the host coordinator, which the throttle-rc Studio Host composes | refused `host_composed`: one host owner per state root, no second daemon beside the Studio host (RT §3.2); the cutover fence (lane H3) activates them in that composition |
3098
+
3099
+ Values are `off` (the default, also for a missing line), `shadow` and `on`. Any other value reads as `off`, and a
3100
+ `LANES_RS_<X>` that names no component above is ignored (`LANES_RS_MCP_EXCLUDE` is a setting, not a component).
3101
+ `shadow` is refused (`shadow_unsupported`) for a component whose strangler row has no shadow step (relay, sidebar,
3102
+ key, signal).
3103
+
3104
+ **`lanes rs apply`** is the one writer of the flag files: it turns the lines into empty files,
3105
+ `~/.local/state/lanes/flags/native.<component>` for `on` and `native.<component>.shadow` for `shadow`, each only for a
3106
+ mode it admits. Otherwise it prints `! LANES_RS_<C>=<mode> refused, kept off: <reason>` with `host_composed`,
3107
+ `binary_absent` (nothing installed or shipped), `digest_mismatch` (other bytes than the recorded sha256, or a binary
3108
+ the tree ships unlisted), `not_executable`, `shadow_unsupported` or `arch_unsupported` (not x86_64), and exits 3.
3109
+ Every other `native.*` file is removed. `lanes sync` and its timer never write a flag. `lanes rs status` shows, per
3110
+ component, the `site.conf` mode, the flag file and what runs (the binary's path, or `python`). A shell reader never
3111
+ parses `site.conf`: it sources `libexec/native.sh` and tests the flag with `[ -e ]`, then takes the first binary
3112
+ candidate that exists and only if it passes the same structural test `apply` applied (never the next one).
3113
+
3114
+ **Binaries.** Both `apply` and the readers look in the same two places, in this order:
3115
+
3116
+ 1. `lanes rs install --from PATH --sha256 HEX`, for a locally built binary (development and offline). PATH must be a
3117
+ regular executable file named `lanes-terminal` or `lanes-hook`. `--sha256` is required and checked before anything
3118
+ is written; under the lock `~/.local/share/lanes/bin-rs/.lock` the copy is hashed again, placed as
3119
+ `bin-rs/<name>-<sha12>`, recorded in `bin-rs/INSTALLED.json`, and only then is the link `bin-rs/<name>` moved. It
3120
+ changes no flag and restarts nothing. Exit 0 installed, 2 usage, 3 refused (`binary_mismatch`,
3121
+ `installed_malformed`: a record it cannot read is never reset, `busy`).
3122
+ 2. The release tree. The npm payload carries `bin-rs/x86_64-unknown-linux-musl/<name>` and `bin-rs/BINARIES.json`
3123
+ (`name`, `target`, `sha256`, `size`, `commit`) inside `pkg/<version>/`, so the `current` flip that updates or rolls
3124
+ back the Python moves the binaries with it in one rename. `npm/lanes/scripts/build-payload.mjs` ships a binary
3125
+ only from `LANES_RS_ARTIFACTS=<dir>`, built from the same commit (npm/lanes/README.md, Maintainers).
3126
+
3127
+ `lanes rs verify` checks both against their records and prints a `WARN` line for an explicit install that runs
3128
+ instead of a shipped binary with other bytes (exit 0 all match or none exists, 3 a mismatch); `lanes rs verify --tree`
3129
+ checks the release tree alone.
3130
+
3131
+ **Updates.** The server installer's commit phase (`install/host-install.sh`, an update and a full install alike) runs
3132
+ `libexec/native_bin.py verify-tree` on the tree it is about to install, before `current` moves: a binary that is
3133
+ unlisted, not executable or has other bytes than its digest refuses the install (`refused`, exit 3; the installed
3134
+ release keeps running and nothing changes). Then every `native.*` flag that tree cannot serve is removed, and the
3135
+ post-commit checks the tree again as the step `verify bin-rs` (only for a tree that carries binaries). An explicit
3136
+ install is never the update's to judge. While `flags/native.statusd` exists (no verb writes it in Round 1) the
3137
+ post-commit skips statusd's restart with a warning.
3138
+
3139
+ **Rollback.** A behaviour: set the line to `off` (or delete it), run `lanes rs apply`, then `lanes reload-views` once
3140
+ a reader exists. An explicit install: `lanes rs uninstall NAME` removes the link (the placed file and its record stay)
3141
+ so the release tree's binary runs again, and removes each flag the tree cannot serve; `lanes rs status` and `lanes rs
3142
+ verify` show which binary runs. A release: `lanes update --rollback` removes, before its flip, every flag the release
3143
+ it returns to cannot serve (a flag file it cannot remove refuses the rollback). Never stop or start a unit by hand to
3144
+ switch a component: no unit is rendered from a flag in Round 1.
3145
+
2974
3146
  ## Safety rules baked into the code (do not remove)
2975
3147
 
2976
3148
  - tmux is always called with `-N` (`attach-session`, `new-session` and `start-server` on a missing socket start
@@ -3042,3 +3214,123 @@ the relevant view panes when activating a changed supervisor, never the lane.
3042
3214
  Catalog fields are additive to site schema 1. Back up the catalog and running
3043
3215
  checkout before updating the server. Restore those files to roll back; do not
3044
3216
  rebuild device sessions as a rollback shortcut. Previously added tabs remain open.
3217
+
3218
+ ## Lanes 2.0 cutover, per state domain (`libexec/cutover.py`; nothing has cut over)
3219
+
3220
+ Journal readers bind the embedded domain to the requested filename (BEY-7053): a canonical `messages` record in
3221
+ `attention.json` is `record_malformed`, including for status, admission and rollback. It cannot authorize a change to
3222
+ another domain. The Python writer, like Rust `write_all`, completes every byte before fsync and rename; a short write
3223
+ continues, and zero progress refuses as `record_unwritable`, removes the temporary and preserves the previous record.
3224
+ `test_cutover.OldBinary` covers the real-file CLI boundary, short writes and stopped writes. These source repairs do
3225
+ not activate a cutover.
3226
+
3227
+ Plan row H3 (lanes2 Round 1, BEY-6988; the Rust runtime specification §17.1, §16.1 and §16.2; witness QI-15;
3228
+ DM-LANES2-CUTOVER-RECORD, DM-LANES2-CUTOVER-INTAKE). The Rust candidate takes each state domain (attention, receipts,
3229
+ …) from the Python host one at a time, at a recorded epoch, and only through a fence: quiesce the old owner (no new
3230
+ admission, no new effect), drain or reconcile what is in flight, have it seal, import the final cut from where the
3231
+ preparatory snapshot stopped (the mandatory catch-up: work accepted during the snapshot is not lost), then commit the
3232
+ new epoch only when the old owner refuses a probe effect and the verified cut is durable in the candidate's store
3233
+ through the seal, and activate only when every legacy endpoint a live producer may use is kept or forwarded. An effect
3234
+ that was in flight at the cut stays an unknown outcome and is reconciled, never replayed. Today this is source and
3235
+ tests only (`crates/lanes-runtime/src/cutover/**` and this script): no domain has moved, no flag is on and the Python
3236
+ host owns everything. Since lanes2 Round 2 S12 an adopted host holds each domain's initial record (`shadow`, epoch 1,
3237
+ owner `lanes-py`), the one the fence would create on its first open (next section). Measured on the dev container only.
3238
+
3239
+ **One journal of record.** `$LANES_STATE/cutover/<domain>.json` (`lanes.cutover/1`, one canonical JSON line) is the only
3240
+ place ownership is decided: the Rust fence and this script read it and compare-and-swap it under the same flock on
3241
+ `<domain>.lock`. Never edit it by hand and never delete it to recover.
3242
+
3243
+ **Where a domain stands.** `python3 libexec/cutover.py status [DOMAIN…] [--json]`. `check DOMAIN --holder H --schema N
3244
+ [--admit] [--legacy L]` answers for one binary: exit 0 (`ok`, or `no_cutover` when there is no record and H is the
3245
+ legacy owner L, default `lanes-py`), exit 3 with `schema_ahead` (this binary cannot read the domain's active schema — it
3246
+ refuses whoever the record names), `owned_elsewhere` (also: no record and H is not the legacy owner), `fenced` (with
3247
+ `--admit`, between the fence and activation) or `record_malformed` (a record that cannot be read is never treated as
3248
+ absent).
3249
+
3250
+ **A cutover that stopped half-way.** A domain left in `quiesced`, `drained` or `cut_verified` (the candidate crashed, or
3251
+ its final cut is refused every time, for example `cut_provenance_changed` after the old host restarted) admits nothing
3252
+ anywhere until the fence is aborted: `cutover.py rollback DOMAIN --to <the recorded owner> --schema N` writes
3253
+ `rolled_back` at the next epoch with the seal lifted, and the old owner resumes; the candidate never owned anything, and
3254
+ its next step loses the compare-and-swap. Start a new cutover from a fresh snapshot afterwards. `rollback_not_owner`:
3255
+ `--to` must name the recorded (fenced) owner.
3256
+
3257
+ **Rollback of an active domain.** Once the epoch is committed (`epoch_committed`, `active`) the candidate may have
3258
+ accepted and executed work, so a record write never takes the domain back: `cutover.py rollback` refuses
3259
+ (`rollback_needs_fence`, exit 3, nothing written). The rollback is the reverse fence in the Rust runtime
3260
+ (`rollback_plan` with the newest release that reads the active schema, then `DomainFence`): it quiesces, drains and
3261
+ seals the candidate and makes its final cut, unknown outcomes kept, durable in the target's store before the target owns
3262
+ anything (`stale_snapshot` if the store holds less), so nothing accepted is lost and nothing performed is performed
3263
+ again. A release that cannot read the active schema refuses (`no_compatible_runtime`). The lanes and their agents keep
3264
+ running throughout; nothing restarts a native session.
3265
+
3266
+ **Legacy producers.** A lane started before the cutover keeps the hook configuration it started with. A legacy spool
3267
+ endpoint with a live producer is forwarded; a socket or state file is kept and served in place (the forwarder never
3268
+ reads or deletes it); a producer whose endpoint is missing from the inventory refuses the plan
3269
+ (`endpoint_live_not_planned`). `cutover.py forward SPOOL INTAKE --endpoint ID` links each committed envelope into
3270
+ `INTAKE/ID/` without replacing anything, then releases it. Exit 1 on any `conflict`, `refused:*` or `release_failed:*`
3271
+ (each stays in the spool for inspection; a failed release is retried on the next pass as a `duplicate`); a link, fifo or
3272
+ other special file is reported `skipped:not_regular` and does not fail the pass. It runs on every pass while the rollback
3273
+ window is open, not once. `cutover.py retire ENDPOINT --census FILE` retires an endpoint only when no live generation or
3274
+ installed hook configuration in the census names it; an empty endpoint directory proves nothing (a publisher can be
3275
+ paused just before its commit).
3276
+
3277
+ ## Lanes 2.0 runtime signals in `lanes doctor` (`libexec/doctor_lanes2.py`; no host exports them yet)
3278
+
3279
+ Plan slice R2-DOCTOR (lanes2 Round 2, BEY-6988; the Rust runtime specification §16.3, the Lanes–Throttle integration
3280
+ contract §11; DM-LANES2-RT16-SIGNALS). A Lanes 2.0 host keeps one bounded metrics registry
3281
+ (`crates/lanes-runtime/src/signals/`) over every Round-1/2 subsystem: RT 14.1 ready-to-dispatch queue ages, permits
3282
+ (live workers apart from waiting callers, refusals, retained bytes, helpers, survivors, unsettled effects), admission
3283
+ refusals and group bytes, the store (mailbox, quota, WAL, checkpoints, storage faults, the slowest durable acceptance),
3284
+ ingress pressure and fairness, hook health records, the delivery ladder, effect phases, answer certainty, cutover phases,
3285
+ capacity freshness, protocol negotiation, projection streams and resyncs, directory freshness, holder reconnects and
3286
+ client frame times. The signal set, each signal's unit, closed label set, delay origin and threshold rule are
3287
+ `docs/contracts/lanes2/manifests/signals.json`; the host resolves the thresholds from its own resource manifest
3288
+ (`resources.<profile>.json`, the G2 admission limits and group peaks) and `benchmark.json` (RT 14.1 maxima, RT 15.3
3289
+ budgets), and exports `$LANES_STATE/signals/lanes2.json` (`lanes2.signals.snapshot/1`) change-only, rewritten at least
3290
+ every 10 s.
3291
+
3292
+ **What doctor prints.** Nothing until that file exists: no host composes the registry before integration gate I1, so
3293
+ today's `lanes doctor` output is unchanged. Once a host exports it, doctor adds after the release checks: a header (the
3294
+ host instance, lanes-runtime version, profile and manifest revisions), `✓ lanes2 signals snapshot fresh` (or `✗` when it
3295
+ is older than 30 s: the host stopped exporting and the values shown are its last), one `delay origin:` line naming,
3296
+ for each RT 16.3 origin (client rendering, Lanes queueing, storage, holder, network, native harness), its worst state
3297
+ and the signals that put it there, one `facets:` line (resources, custody, owner sources), then exactly one line per
3298
+ signal: `✗` past an alert bound (doctor exits 1), `⚠` past a warning bound, an information line otherwise. A signal
3299
+ whose owner has not activated reads `unavailable (<reason>)`, never zero: `capacity.*` without a capacity source
3300
+ (`owner_contract_inactive`), `client.*` while no terminal client reports frame times (`no_client_frame_report`),
3301
+ `protocol.epoch` before any handshake (`no_negotiation`); a signal whose producer the host did not run reads
3302
+ `unavailable (not_sampled)`. No lane, operation or prompt identity and no terminal content is ever in the file.
3303
+
3304
+ **Reading it by hand.** `python3 libexec/doctor_lanes2.py [--snapshot PATH] [--now-ms MS]` prints the same lines (exit 1
3305
+ when one is `✗`, 0 with no snapshot). The Throttle monitor tab reads the same file: it is self-describing (every signal
3306
+ carries its doctor phrase, unit, origin, state and resolved bounds), so a reader needs no manifest.
3307
+
3308
+ ## Lanes 2.0 adoption (`libexec/adopt.py`; `lanes update` carries it; every flag off)
3309
+
3310
+ Plan row S12 (lanes2 Round 2, BEY-6988; the Rust runtime specification §17.1, the adoption half; P32;
3311
+ DM-LANES2-S12-ADOPTION). An existing 1.x server adopts the Lanes 2.0 state layout without a manual step: the last
3312
+ post-commit step of every `lanes update` (`adopt lanes2`, from the tree it installed) runs `python3 libexec/adopt.py
3313
+ adopt --state <state> --tree <tree>`. For each of the fourteen state domains (owner-epochs, bindings, receipts,
3314
+ attention, effects, inbox-outbox, projects, schedules, connectors, projections, preferences, builds, notify, drafts) it
3315
+ writes the domain's initial cutover record where none exists: `shadow`, epoch 1, owner `lanes-py`, schema 1, exactly
3316
+ the record the Rust fence creates on its first open. A record that exists is never touched (a cutover in progress, a
3317
+ domain the Rust host took). It creates `$LANES_STATE/store/` (0700) and never the store file (the host coordinator's
3318
+ store owner creates and migrates `coordination.sqlite` on its first open), then writes `$LANES_STATE/lanes2/adoption.json`
3319
+ listing every domain whose record it read back from disk; a domain it could not adopt is listed under `refused` with its
3320
+ code and never reported adopted.
3321
+
3322
+ What it never does: write `flags/native.*` or site.conf's `LANES_RS_*` (lane H2; every component stays off), import
3323
+ legacy data (a domain's records move only through its cutover fence), start a unit or run a Rust binary. While the
3324
+ records name `lanes-py`, a Rust host that recovers comes up fenced and read-only (`owned_elsewhere`).
3325
+
3326
+ **Check it.** `lanes doctor` prints, after the update line, one information line (when, which release, the store, the
3327
+ flags) and one line per domain: `✓` adopted (phase, owner, epoch, where the 1.x owner keeps it), `⚠` not adopted
3328
+ (the refusal's code, or a domain a newer release added: the next update adopts it), `⚠` fenced in `quiesced` …
3329
+ `epoch_committed` (see the cutover section above), `✗` listed as adopted but its record is missing or unreadable
3330
+ (the next update adopts it again). Nothing is printed before the first adoption. `python3 libexec/adopt.py status
3331
+ [--json]` exits 0 only when every domain is adopted and its record verifies.
3332
+
3333
+ **The update step.** Exit 1 (an I/O failure) and 3 (a domain refused, for example a malformed record) are warnings in
3334
+ `update/last.json`, never a `partial` update; `lanes doctor` names the domain. Run it by hand with the same command; it
3335
+ is idempotent and rewrites nothing that is already in place. A rollback to a tree without `libexec/adopt.py` runs no
3336
+ such step and leaves the records as they are (a `shadow` record owned by `lanes-py` is what no record means).
@@ -2450,11 +2450,16 @@ systemctl --user enable --now lanes-notify.service
2450
2450
 
2451
2451
  ## 9. Appearance
2452
2452
 
2453
- One token table, `libexec/tokens.py`, defines every colour and glyph. It generates marked blocks in
2454
- `zellij/config.kdl` (the `lanes-dark` / `lanes-light` themes and the web client palette), `web/mobile.css`,
2455
- `web/mobile.js`, `libexec/tokens.sh` (the viewer's status screens), `docs/DESIGN.md` and the optional Ghostty palette
2456
- files. `python3 libexec/tokens.py --check` fails on drift; `--write` regenerates all blocks; `--kdl`, `--css`, `--sh`,
2457
- `--md`, `--js`, `--ghostty-dark` and `--ghostty-light` print one block.
2453
+ One token source, `tokens/tokens.v1.json`, defines every colour and glyph ([`tokens/README.md`](../tokens/README.md)).
2454
+ Edit it, never a generated file. `python3 tokens/generate.py --write` regenerates everything derived from it: the
2455
+ resolved table `libexec/tokens.py` reads, the browser's `web/tokens.css`, the Rust and Swift tokens (in a repository
2456
+ checkout only), and the marked blocks in `zellij/config.kdl` (the `lanes-dark` / `lanes-light` themes and the web
2457
+ client palette), `web/mobile.css`, `web/mobile.js`, `libexec/tokens.sh` (the viewer's status screens),
2458
+ `docs/DESIGN.md` and the optional Ghostty palette files. `python3 tokens/generate.py --check` fails on drift (in an
2459
+ installed tree it compares the files inside `lanes/` only); `python3 libexec/tokens.py --check` covers the marked
2460
+ blocks and the generated files inside `lanes/`. `tokens.py` is the reader: `--kdl`, `--css`, `--sh`, `--md`, `--js`,
2461
+ `--ghostty-dark` and `--ghostty-light` print one block, and its own `--write` only re-splices the marked blocks from the
2462
+ generated table, so a source edit needs `generate.py --write`.
2458
2463
 
2459
2464
  | Switch | Values | Default |
2460
2465
  | --- | --- | --- |
@@ -2678,7 +2683,7 @@ Server (`~/.local/state/lanes/`, `$LANES_STATE`):
2678
2683
  | `upload-requests/<device>/` | Upload hand-off between sidebar and helper |
2679
2684
  | `economy.json`, `economy.cursor.json` | The opt-in economy projection and its log cursor |
2680
2685
  | `notify.enrol-seen.json` | The enrolment requests the opt-in push notifier already announced (0600, pruned to the requests on disk); deleting it announces the ones still pending once more |
2681
- | `flags/` | `coexist`, `readonly`, `tmpreap.armed`, `sockets-lost` |
2686
+ | `flags/` | `coexist`, `readonly`, `tmpreap.armed`, `sockets-lost`; Lanes 2.0's `native.<component>` (`on`) and `native.<component>.shadow` (`shadow`): empty files `lanes rs apply` writes from `site.conf`'s `LANES_RS_<COMPONENT>` for a verified native binary only, removed otherwise (RUNBOOK, "Lanes 2.0 native binaries and flags") |
2682
2687
  | `cursor-sync-backups/` | Backups taken by `cursor-sync --write` |
2683
2688
  | `migrations/<UTC stamp>/` | One directory per `lanes migrate addresses --write` (0700): a copy of each file it changed as it was (`<NN>-<file name>`, 0600) and `receipt.json` (`{v, verb, at, board, files: [{path, backup, change, sha256_before, sha256_after}]}`) |
2684
2689
  | `invariant.json` | `lanes invariant save` |
@@ -6,7 +6,10 @@
6
6
  # pre-commit preflight (prerequisites, the user manager, Docker, an installed release: an update restarts what the
7
7
  # full install enabled and enables nothing, so with no `current` it is refused), the pinned binaries
8
8
  # (sha256), terminfo, the catalog: a failure here leaves the installed release running exactly as it was;
9
- # commit install/services.py --install: every unit, then current.previous, then the flip of `current` (W9 U1);
9
+ # commit Lanes 2.0's native binaries of this tree against its bin-rs/BINARIES.json (libexec/native_bin.py
10
+ # verify-tree: a binary unlisted, not executable or with other bytes is refused, exit 3, and nothing
11
+ # changes), every flags/native.* file this tree does not admit removed, then install/services.py
12
+ # --install: every unit, then current.previous, then the flip of `current` (W9 U1);
10
13
  # post-commit libexec/update.py post-commit, from the tree just installed: daemon-reload, `lanes sync`, restart
11
14
  # lanes-statusd, try-restart each optional service (right after lanes-docsd's, install/enable-docs.sh:
12
15
  # the docs page's pinned Mermaid, a warning when it is skipped or refused, W10 W8), `lanes
@@ -92,8 +95,9 @@ phase() {
92
95
  phase=$1
93
96
  }
94
97
  # --update-only, before the commit: whatever ends the run is recorded (`set -e`, an `exit`, a signal). refused: the
95
- # preflight (no installed release among its checks), or install/services.py's refusal (exit 3: another install holds
96
- # its lock, a link that is no symlink);
98
+ # preflight (no installed release among its checks), or in the commit phase native_bin.py verify-tree's refusal (exit
99
+ # 3: a native binary that does not verify) or install/services.py's (exit 3: another install holds its lock, a link
100
+ # that is no symlink);
97
101
  # failed: anything else — unless the flip happened before services.py failed (its command link), which is installed
98
102
  # but not restarted: partial. After the commit the post-commit records its own outcome.
99
103
  update_ended() {
@@ -218,6 +222,13 @@ if [ ! -e "$catalog" ] && [ ! -d "$repo/workspaces" ] && [ -z "${LANES_WORKSPACE
218
222
  printf '{"version":1,"workspaces":[]}\n' > "$catalog"
219
223
  fi
220
224
  phase commit
225
+ # Lanes 2.0 native binaries (lanes2 Round 1 H2; AR 9.3, D9), right before the flip: this tree's bin-rs/ against its
226
+ # BINARIES.json (a full install too). A binary that is unlisted, not executable or has other bytes than its digest is
227
+ # refused (exit 3: an update records `refused`, and the installed release keeps running exactly as it was), so
228
+ # `current` never names a tree whose binaries nobody verified. Then every flags/native.* file this tree does not admit
229
+ # is removed (a component whose binary it no longer ships returns to Python), so after the flip each shell reader that
230
+ # finds a flag runs a binary that was checked. A tree without binaries passes and prunes only those flags.
231
+ python3 "$repo/libexec/native_bin.py" verify-tree "$repo" --state "$state" --prune-flags
221
232
  # --install: the server installer is the one caller that makes its own tree the installed release (`current`);
222
233
  # the enable steps re-render the release `current` names (install/services.py, DEF-1835).
223
234
  python3 "$repo/install/services.py" --install