@vibelord/lanes 1.7.2 → 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 +269 -28
  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
@@ -3,125 +3,61 @@
3
3
  none); `--kdl`, `--css`, `--sh`, `--md`, `--js`, `--ghostty-dark|--ghostty-light` and `--docs-css` write the Zellij
4
4
  theme, the phone CSS, the viewer's shell colour sets, the docs tables, the phone's terminal palette, the optional
5
5
  Ghostty palette files and the docs page's CSS (plan W10 W6) between markers; `--check` fails when any committed block
6
- differs. Spec:
6
+ differs, or when the generated table this module reads is not what the generator derives from the source now. Spec:
7
7
  docs/superpowers/specs/2026-10-03-lanes-cockpit-design.md; palette v2 + the 256-colour set: cockpit v3 P1 (LNS-69).
8
- No third-party code; importable with no side effects."""
8
+
9
+ A READER since Lanes 2.0 fan-out lane F1 (integrated cockpit §5.1, A26): the one hand-edited token source is
10
+ lanes/tokens/tokens.v1.json, and `python3 lanes/tokens/generate.py --write` resolves it into
11
+ lanes/tokens/generated/tokens.resolved.json — the only file this module reads, once, at import — beside the Rust, CSS
12
+ and Swift projections of the same theme revision. No colour, glyph or label is defined here; the meanings and the
13
+ reasons behind each value are recorded with the source (lanes/tokens/README.md). No third-party code; importing it
14
+ reads that one file and nothing else."""
9
15
  import difflib
16
+ import importlib.util
17
+ import json
10
18
  import os
11
19
  import sys
12
20
  from pathlib import Path
13
21
 
14
- ROLES = ('surface', 'surface-raised', 'line', 'accent-wash', 'accent-line', 'press', 'chip',
15
- 'ink', 'ink-dim', 'ink-faint', 'accent', 'on-accent', 'on-accent-urgent',
16
- 'tone-urgent', 'tone-attention', 'tone-working', 'tone-done', 'scrim', 'shadow')
17
- # Palette v2 (cockpit v3 P1, 2026-10-06): vivid, high-contrast roles in both variants. v1 had darkened the light tones
18
- # until they passed (amber #8a5a00 read olive-brown). Surfaces are v1's but for the dark accent-wash, the cursor row.
19
- TOKENS = {
20
- 'dark': {'surface': '#101318', 'surface-raised': '#191e25', 'line': '#2c333d', 'accent-wash': '#1c3326',
21
- 'accent-line': '#4b6955', 'press': '#26332c', 'chip': '#ffffff0f', 'ink': '#f2f5f8', 'ink-dim': '#a6b1be',
22
- 'ink-faint': '#6f7a87', 'accent': '#8fe3a6', 'on-accent': '#101318', 'on-accent-urgent': '#7a1a12',
23
- 'tone-urgent': '#ff7b6e', 'tone-attention': '#ffc233', 'tone-working': '#6fb6ff', 'tone-done': '#5fdc8a',
24
- 'scrim': '#000000a6', 'shadow': '0 -16px 80px #0007'},
25
- 'light': {'surface': '#f3f5f2', 'surface-raised': '#ffffff', 'line': '#d5ded6', 'accent-wash': '#e5f0e6',
26
- 'accent-line': '#acc9b4', 'press': '#d8e9db', 'chip': '#edf3ec', 'ink': '#111a14', 'ink-dim': '#4a5661',
27
- 'ink-faint': '#6f7b87', 'accent': '#1f6f3f', 'on-accent': '#ffffff', 'on-accent-urgent': '#ffd3cc',
28
- 'tone-urgent': '#c41c1c', 'tone-attention': '#a04d00', 'tone-working': '#1a56c4', 'tone-done': '#0d7338',
29
- 'scrim': '#1a222b80', 'shadow': '0 -16px 80px #0003'},
30
- }
22
+ # The resolved table (lanes.tokens.resolved/1). The names and shapes below are this module's public API, unchanged by
23
+ # the move to a generated source: tuples of roles, {variant: {role: value}}, (unicode, ascii, tone) glyph triples.
24
+ RESOLVED = Path(__file__).resolve().parents[1] / 'tokens' / 'generated' / 'tokens.resolved.json'
25
+ try:
26
+ _RESOLVED = json.loads(RESOLVED.read_text(encoding='utf-8'))
27
+ except (OSError, ValueError) as _error:
28
+ raise ImportError(f'{RESOLVED}: unreadable ({_error}); regenerate it with python3 lanes/tokens/generate.py --write') from None
29
+ _TABLES, _SGR = _RESOLVED['tables'], _RESOLVED['sgr']
30
+ _VARIANTS = tuple(_RESOLVED['theme']['variants'])
31
+ THEME_ID, THEME_REVISION, THEME_DIGEST = (_RESOLVED['theme'][key] for key in ('id', 'revision', 'digest'))
32
+ ROLES = tuple(_TABLES['roles'])
33
+ # Palette v2 (cockpit v3 P1): every role per variant; `selected` (the cursor row) is a BACKGROUND role that takes its
34
+ # colour from `accent-wash` and has no CSS variable of its own.
35
+ TOKENS = {variant: dict(_TABLES['tokens'][variant]) for variant in _VARIANTS}
31
36
  # 16-colour fallback: the user's own palette resolves these. Selection is achromatic (bold) there, dim is bright-black.
32
- ANSI16 = {'ink': '39', 'ink-dim': '90', 'ink-faint': '90', 'accent': '1;39',
33
- 'tone-urgent': '31', 'tone-attention': '33', 'tone-working': '34', 'tone-done': '32'}
34
- # Painted roles that are a BACKGROUND, by the token they take their colour from. `selected` is the cursor row (cockpit
35
- # v3 P2 paints it): the accent-wash the Zellij themes' *_selected components and the phone's current row
36
- # (--lanes-accent-wash) already use, with ink on it. Not a CSS variable of its own: the phone needs none, and a copy
37
- # per variant would cost 58 B of the 37 B mobile.css still has under spec §8's cap.
38
- BACKGROUNDS = {'selected': 'accent-wash'}
39
- PAINTED = tuple(ANSI16) + tuple(BACKGROUNDS) # the roles the TUI ever emits
37
+ ANSI16 = dict(_TABLES['ansi16'])
38
+ BACKGROUNDS = dict(_TABLES['backgrounds'])
39
+ PAINTED = tuple(_TABLES['painted']) # the roles the TUI ever emits: ANSI16's, then BACKGROUNDS'
40
40
  # The colour modes whose colours Lanes defines (cockpit v3 P2/P3): the sidebar spends the palette in them, and view.sh
41
41
  # (`LZ_VIVID`) the warning tone on its lead. 16 is the user's own palette and none has no colour: both keep v1's bytes.
42
- VIVID = ('truecolor', '256')
43
- # The 256-colour set: one xterm index per painted role, always from 16-255 (fixed RGB; 0-15 are the user's palette).
44
- # Each is the nearest entry (RGB distance) in its token's hue family — greys for the inks — that keeps every text role
45
- # >= 4.2:1 on surface, surface-raised and the 256 `selected` band; `selected` is the nearest entry to the wash. The
46
- # floor is 4.2, not 4.5, for the cube's six levels alone (test_tokens.Xterm256 re-derives every index). Light accent
47
- # and done share 22 (#005f00): the nearest passing entry, 23, is a teal.
48
- XTERM256 = {
49
- 'dark': {'ink': 255, 'ink-dim': 249, 'ink-faint': 243, 'accent': 115, 'tone-urgent': 209, 'tone-attention': 215,
50
- 'tone-working': 75, 'tone-done': 78, 'selected': 235},
51
- 'light': {'ink': 233, 'ink-dim': 240, 'ink-faint': 243, 'accent': 22, 'tone-urgent': 160, 'tone-attention': 94,
52
- 'tone-working': 26, 'tone-done': 22, 'selected': 254},
53
- }
54
- # Lane-identity palette for the two places that DEFINE a palette: Zellij's `web_client { theme {} }` (the phone's
55
- # xterm.js; dark only, see _web_client) and the optional Ghostty file. A Zellij theme's legacy `black…white` keys are
56
- # NOT one of them (DEF-1413). The TUI itself keeps 38;5;N. Slots 1-4 are the four tones and 7 / 15 the ink pair
57
- # (PALETTE16_ROLES); v2 re-saturates the rest (more chroma than v1 in every chromatic slot). Every slot >= 4.5:1.
58
- PALETTE16 = {
59
- 'dark': ['#8792a0', '#ff7b6e', '#5fdc8a', '#ffc233', '#6fb6ff', '#c58bff', '#3fd9cf', '#a6b1be',
60
- '#97a3b1', '#ff9a8e', '#86f0ad', '#ffd866', '#98cbff', '#dcb2ff', '#7deee6', '#f2f5f8'],
61
- 'light': ['#2f3b34', '#c41c1c', '#0d7338', '#a04d00', '#1a56c4', '#8228c4', '#006f73', '#4a5661',
62
- '#55625b', '#d0221a', '#0e7a3a', '#a85200', '#1f5fd8', '#9133d0', '#00797c', '#111a14'],
63
- }
64
- PALETTE16_ROLES = {1: 'tone-urgent', 2: 'tone-done', 3: 'tone-attention', 4: 'tone-working', 7: 'ink-dim', 15: 'ink'}
42
+ VIVID = tuple(_TABLES['vivid'])
43
+ # The 256-colour set: one xterm index (16-255) per painted role (test_tokens.Xterm256 re-derives every index).
44
+ XTERM256 = {variant: dict(_TABLES['xterm256'][variant]) for variant in _VARIANTS}
45
+ # Lane-identity palette for the two places that DEFINE a palette (Zellij's `web_client { theme {} }`, the optional
46
+ # Ghostty file); slots 1-4 are the four tones and 7 / 15 the ink pair (PALETTE16_ROLES).
47
+ PALETTE16 = {variant: list(_TABLES['palette16'][variant]) for variant in _VARIANTS}
48
+ PALETTE16_ROLES = {int(slot): role for slot, role in _TABLES['palette16_roles'].items()}
65
49
  # key -> (unicode, ascii twin, tone). Position disambiguates: agent glyphs in column 2, stream glyphs in column 33.
66
- AGENT_GLYPHS = {'needs_approval': ('◆', '!', 'tone-urgent'), 'needs_input': ('◇', '?', 'tone-attention'),
67
- 'working': ('▸', '>', 'tone-working'), 'done': ('✓', 'v', 'tone-done'),
68
- 'errored': ('✗', 'X', 'tone-urgent'), 'shell': ('_', '_', 'ink-dim'), 'idle': ('·', '.', 'ink-dim')}
69
- GLYPHS = {'active': ('●', '*', 'tone-done'), 'quiet': ('○', 'o', 'ink-dim'), 'missing': ('✗', 'x', 'tone-urgent'),
70
- 'absent': ('–', '-', 'ink-dim'), 'dead': ('!', '!', 'tone-urgent'), 'helper': ('·', '.', 'ink-dim'),
71
- 'unknown': ('?', '?', 'ink-dim')}
72
- MARKS = {'cursor': ('▌', '|', 'accent'), 'viewing': ('›', '=', 'accent'), 'viewport-b': ('²', '2', 'accent'),
73
- 'viewport-c': ('³', '3', 'accent'), 'viewer': ('·', '.', 'ink-dim'), 'truncation': ('…', '~', 'ink'),
74
- 'close': ('×', 'x', 'tone-urgent'), 'new': ('+', '+', 'tone-done'), 'rule': ('─', '-', 'ink-faint'),
75
- 'more': ('⋮', ':', 'ink-dim'), 'warning': ('⚠', '!', 'tone-attention'), 'upload': ('↑', '^', 'ink-dim'),
76
- 'armed': ('↓', 'v', 'tone-done'), 'enter': ('⏎', 'Enter', 'ink-dim'), 'caret': ('█', '_', 'tone-working'),
77
- 'stale': ('?', '?', 'ink-dim'), 'lead': ('›', '>', 'ink'),
78
- # Tone-less punctuation (spec §3 completeness rule): every ` · ` and every quote the sidebar draws is a lookup, so
79
- # LANES_GLYPHS=ascii yields a seven-bit frame. `sep` shares `-` with `rule` on purpose: neither carries state.
80
- 'sep': ('·', '-', 'ink-dim'), 'quote-open': ('‘', "'", 'ink'), 'quote-close': ('’', "'", 'ink'),
81
- # The confirmation's dash (` › close ‘sh’ — y⏎ confirm · Esc cancel`, cockpit v3 S3/S6); `-` like `sep`.
82
- 'dash': ('—', '-', 'ink-dim'),
83
- # The focus legend's arrow (` ▌ keys go to sidebar · Esc → lane`, cockpit v3 S4).
84
- 'arrow': ('→', '->', 'accent'),
85
- # Column 3 of a row whose registration is on its way (`P`, cockpit v3 S8): the session stays listed, dimmed
86
- # mark, until the registry lists its lane. The truncation pair on purpose — position disambiguates (column 3,
87
- # never the end of a name) — and seven-bit `~` is free in column 3 (`=` `2` `3` are the other marks there).
88
- 'pending': ('…', '~', 'ink-dim'),
89
- # Column 3 of a lane its owner pinned (`p`, cockpit v3 R5): it leads its section and never falls below `⋮ N
90
- # more`. The lowest of column 3's marks: pending, the viewports and the viewing mark win over it. Seven-bit
91
- # `^` is free in column 3 (`=` `2` `3` `~` are the others; the upload strip's `^` is no column-3 mark).
92
- 'pinned': ('▲', '^', 'accent'),
93
- # Column 3 of a lane's role and of its messaging name (W15 L2b/L2c, operator 2026-10-25): the leader glyph ★ on
94
- # the workspace's coordinator lane in the attention tone and on the fleet admin's lane in the urgent tone — one
95
- # glyph in two tones, so one twin (a board has one coordinator, the fleet admin is one lane of the site, and
96
- # the `@` sheet names both); `name_mismatch` ≠ on a lane whose agent's messaging name is not its address
97
- # (statusd's `agent.name_match` false), below the role glyph. Above `pinned`, below pending, the viewports and
98
- # the viewing mark. Seven-bit `*` and `/` are free in column 3 (`=` `2` `3` `~` `^` are the others; `*` is
99
- # also column 33's active twin and the fleet provider's — position disambiguates — and `/` is no other twin).
100
- 'coordinator': ('★', '*', 'tone-attention'), 'fleet_admin': ('★', '*', 'tone-urgent'),
101
- 'name_mismatch': ('≠', '/', 'ink-dim'),
102
- # Column 3 of a lane with messages waiting in its inbox (W15 L4: statusd's `inbox.pending` > 0) — ✉ in the
103
- # attention tone: something is on its way to that lane's agent and has not reached it. Below the role glyph,
104
- # above ≠ (a lane's message waiting matters more than its name). Seven-bit `&` is no other mark's twin
105
- # anywhere (column 3's others: `=` `2` `3` `~` `^` `*` `/`).
106
- 'inbox': ('✉', '&', 'tone-attention'),
107
- 'ok': ('✓', 'OK', 'tone-done'), 'fail': ('✗', 'X', 'tone-urgent'),
108
- # The docs cockpit on the upload strip (` ↑ uploads · ▤ docs 3 (U)`, plan W10 W7): the strip's own tone.
109
- # Seven-bit `#` is free on that row (`^` uploads, `v` armed, `-` sep are the others).
110
- 'docs': ('▤', '#', 'ink-dim'),
111
- # The fleet block (W11, spec 2026-10-11 §3), pinned above the upload strip: column 2 of each row says what
112
- # the row is about — Throttle ⚙, a provider's subscription pool ◆, the host and its containers ▣ — in the
113
- # row's worst tone; then a provider's availability bar, ten cells of usable ▰ · cooling ▱ · benched ▪ ·
114
- # dead ·. The seven-bit twins are unique among the block's own marks and against every other mark its rows
115
- # draw (`-` sep, `?` stale, `OK` / `!` / `X` the folded line's verdict). `#` stays the docs twin alone; the
116
- # unicode `·` of a dead cell is the spec's (it shares the separator's glyph, never its place: a bar has no
117
- # blank inside it).
118
- 'fleet-throttle': ('⚙', '@', 'ink-dim'), 'fleet-provider': ('◆', '*', 'ink-dim'),
119
- 'fleet-host': ('▣', '[', 'ink-dim'),
120
- 'bar-usable': ('▰', '=', 'tone-done'), 'bar-cooling': ('▱', '~', 'ink-dim'),
121
- 'bar-benched': ('▪', ':', 'tone-attention'), 'bar-dead': ('·', '.', 'ink-faint')}
122
- ECONOMY_TAIL = {'starving': ('⚠', '!', 'tone-attention'), 'downgraded': ('↓', 'v', 'tone-attention'), 'paid': ('$', '$', 'ink-dim')}
123
- MOBILE_AGENT_LABELS = {'needs_approval': 'Needs approval', 'needs_input': 'Needs you', 'working': 'Working',
124
- 'done': 'Done', 'errored': 'Error', 'shell': 'Shell', 'idle': 'Idle'}
50
+ AGENT_GLYPHS = {key: tuple(entry) for key, entry in _TABLES['agent_glyphs'].items()}
51
+ GLYPHS = {key: tuple(entry) for key, entry in _TABLES['glyphs'].items()}
52
+ MARKS = {key: tuple(entry) for key, entry in _TABLES['marks'].items()}
53
+ ECONOMY_TAIL = {key: tuple(entry) for key, entry in _TABLES['economy_tail'].items()}
54
+ MOBILE_AGENT_LABELS = dict(_TABLES['mobile_agent_labels'])
55
+ # Lanes 2.0 (integrated cockpit §5.1): the text hierarchy, the semantic states with the cues that carry them without
56
+ # colour, and the contrast rules every projection keeps.
57
+ TEXT = dict(_TABLES['text'])
58
+ SEMANTICS = {state: {'role': entry['role'], 'cues': [dict(cue) for cue in entry['cues']]}
59
+ for state, entry in _TABLES['semantics'].items()}
60
+ CONTRAST = [dict(rule) for rule in _TABLES['contrast']]
125
61
 
126
62
 
127
63
  def hex_of(variant, role):
@@ -149,19 +85,14 @@ def sgr_table(mode, variant, dim16=None):
149
85
  Foreground roles are `38;…`, `selected` (the cursor row) `48;…`; in 16/none it is empty — the palette there is the
150
86
  user's, and the cursor stays the bold bar. `dim16` overrides the 16-colour dim (default: `LANES_DIM=2` -> SGR 2,
151
87
  else 90); the shell renderer pins 90 so the committed block never depends on the generator's environment."""
152
- table = {'bold': '\033[1m', 'reset': '\033[0m'}
153
88
  if dim16 is None:
154
- dim16 = '\033[2m' if os.environ.get('LANES_DIM') == '2' else '\033[90m'
155
- for role in PAINTED:
156
- bold, layer = '\033[1m' if role == 'accent' else '', 48 if role in BACKGROUNDS else 38
157
- if mode == 'none':
158
- table[role] = bold
159
- elif mode == '16':
160
- table[role] = '' if role in BACKGROUNDS else dim16 if role in ('ink-dim', 'ink-faint') else f'\033[{ANSI16[role]}m'
161
- elif mode == '256':
162
- table[role] = bold + '\033[%d;5;%dm' % (layer, XTERM256[variant][role])
163
- else:
164
- table[role] = bold + '\033[%d;2;%d;%d;%dm' % ((layer,) + rgb(hex_of(variant, role)))
89
+ dim16 = _SGR['dim16']['LANES_DIM=2'] if os.environ.get('LANES_DIM') == '2' else _SGR['dim16']['default']
90
+ tier = mode if mode in ('none', '16', '256') else 'truecolor'
91
+ table = {'bold': _SGR['bold'], 'reset': _SGR['reset']}
92
+ # 16 and none do not depend on the variant (the user's palette, or none): the generator emits both alike.
93
+ table.update(_SGR['tiers'][tier][_VARIANTS[0] if tier in ('16', 'none') else variant])
94
+ if tier == '16':
95
+ table.update((role, dim16) for role in _SGR['dim16']['roles'])
165
96
  return table
166
97
 
167
98
 
@@ -246,10 +177,9 @@ def render_kdl():
246
177
  return '\n'.join(lines) + '\n'
247
178
 
248
179
 
249
- ALIASES = {'bg': 'surface', 'panel': 'surface-raised', 'border': 'line', 'text': 'ink', 'muted': 'ink-dim',
250
- 'current': 'accent-wash', 'current-border': 'accent-line'}
251
- ZJ = {'bg': 'surface', 'surface': 'surface-raised', 'border': 'line', 'text': 'ink', 'text-dim': 'ink-dim',
252
- 'green': 'tone-done', 'blue': 'tone-working', 'red': 'tone-urgent', 'yellow': 'tone-attention'}
180
+ # The phone CSS's legacy `--lanes-<alias>` names and Zellij's `--zj-<slot>` theme slots, by role.
181
+ ALIASES = dict(_TABLES['aliases'])
182
+ ZJ = dict(_TABLES['zj'])
253
183
 
254
184
 
255
185
  def render_css():
@@ -275,7 +205,7 @@ def render_css():
275
205
  # shell: no html.lanes-mobile, no Zellij data-zj-theme. Its block puts the roles it paints on :root, dark by default and
276
206
  # light under the system's prefers-color-scheme, and only those roles (docs.css has a 2.5 KB cap; the full --css block
277
207
  # alone is 2 KB). test_docs_assets pins that docs.css uses exactly these.
278
- DOCS_ROLES = ('surface', 'surface-raised', 'line', 'ink', 'ink-dim', 'accent')
208
+ DOCS_ROLES = tuple(_TABLES['docs_roles'])
279
209
 
280
210
 
281
211
  def render_docs_css():
@@ -288,9 +218,7 @@ def render_docs_css():
288
218
 
289
219
 
290
220
  # The painted roles as the viewer's shell variables (`tokens.sh`), in PAINTED order. LZ_DIM kept its v1 name.
291
- SH_NAMES = {'ink': 'LZ_INK', 'ink-dim': 'LZ_DIM', 'ink-faint': 'LZ_FAINT', 'accent': 'LZ_ACCENT',
292
- 'tone-urgent': 'LZ_URGENT', 'tone-attention': 'LZ_ATTENTION', 'tone-working': 'LZ_WORKING',
293
- 'tone-done': 'LZ_DONE', 'selected': 'LZ_SELECTED'}
221
+ SH_NAMES = dict(_TABLES['sh_names'])
294
222
  SH_SETS = (('256', 'dark'), ('256', 'light'), ('truecolor', 'dark'), ('truecolor', 'light'))
295
223
 
296
224
 
@@ -422,6 +350,41 @@ def check(repo):
422
350
  return drifted
423
351
 
424
352
 
353
+ def check_input(repo):
354
+ """The generated files under `repo` (the lanes tree) that differ from what lanes/tokens/generate.py derives from
355
+ tokens.v1.json now — this module's own input first — or the source's own refusal: a source edited without
356
+ `generate.py --write`, or a hand-edited resolved table, is drift. Loaded only here, never by a renderer import."""
357
+ spec = importlib.util.spec_from_file_location('lanes_tokens_generate', Path(repo) / 'tokens' / 'generate.py')
358
+ generate = importlib.util.module_from_spec(spec)
359
+ spec.loader.exec_module(generate)
360
+ try:
361
+ return generate.check(repo, kinds=generate.LANES_OUTPUTS)
362
+ except generate.TokenError as error:
363
+ return [str(error)]
364
+
365
+
366
+ def _replace(path, text):
367
+ """Write a marker target through a sibling temporary file and os.replace, keeping its mode: a viewer sourcing
368
+ tokens.sh, or a page loading mobile.css, while --write runs sees the old file or the new one, never half of it."""
369
+ import tempfile
370
+ try:
371
+ mode = path.stat().st_mode & 0o7777
372
+ except OSError:
373
+ mode = 0o644
374
+ fd, tmp = tempfile.mkstemp(prefix='.' + path.name + '.', dir=str(path.parent))
375
+ try:
376
+ with os.fdopen(fd, 'w') as handle:
377
+ handle.write(text)
378
+ os.chmod(tmp, mode)
379
+ os.replace(tmp, path)
380
+ except BaseException:
381
+ try:
382
+ os.unlink(tmp)
383
+ except OSError:
384
+ pass
385
+ raise
386
+
387
+
425
388
  def main(argv):
426
389
  repo = Path(__file__).resolve().parents[1]
427
390
  if argv[:1] == ['--check']:
@@ -430,12 +393,17 @@ def main(argv):
430
393
  kind = next(k for k, r in TARGETS.items() if r == rel)
431
394
  current = (repo / rel).read_text() if (repo / rel).exists() else ''
432
395
  sys.stdout.writelines(difflib.unified_diff(current.splitlines(True), _splice(current, kind).splitlines(True), rel, rel + ' (generated)'))
433
- return 1 if drifted else 0
396
+ stale = check_input(repo)
397
+ for rel in stale:
398
+ sys.stdout.write(f'{rel}: not what lanes/tokens/generate.py derives from tokens.v1.json; run '
399
+ 'python3 lanes/tokens/generate.py --write\n')
400
+ return 1 if drifted or stale else 0
434
401
  if argv[:1] == ['--write']:
435
402
  for kind, rel in TARGETS.items():
436
403
  path = repo / rel
437
404
  current = path.read_text() if path.exists() else ''
438
- path.write_text(_splice(current, kind))
405
+ if _splice(current, kind) != current:
406
+ _replace(path, _splice(current, kind))
439
407
  return 0
440
408
  kind = argv[0].lstrip('-') if argv else ''
441
409
  if kind not in RENDERERS:
@@ -2,7 +2,7 @@
2
2
  # 256-colour, truecolor and none sets (`lz_tones none` takes one argument; safe under view.sh's `set -u`). view.sh calls
3
3
  # `lz_tones "$color" "$theme"` with its device's clients/<device>.color and .theme stamps on every status screen; every
4
4
  # set also says LZ_VIVID (`1` in truecolor and 256, the colours Lanes defines). Sourced, never executed.
5
- # The block below is generated: edit libexec/tokens.py and run `python3 libexec/tokens.py --write`.
5
+ # The block below is generated: edit tokens/tokens.v1.json and run `python3 tokens/generate.py --write`.
6
6
  # BEGIN lanes tokens (generated by libexec/tokens.py --sh; do not edit by hand)
7
7
  LZ_BOLD='\033[1m'
8
8
  LZ_RESET='\033[0m'
@@ -13,7 +13,14 @@ catalog — a failure there leaves the installed release running as it was. comm
13
13
  (every unit, `current.previous`, then the flip of `current`; W9 U1). post-commit: this module, run from the tree just
14
14
  installed. Its steps run in this order, each whatever the ones before it returned, each bounded by STEP_TIMEOUT seconds
15
15
  (its whole process group is stopped when it does not finish):
16
- systemctl --user daemon-reload · lanes sync · systemctl --user restart lanes-statusd.service ·
16
+ systemctl --user daemon-reload · `python3 libexec/native_bin.py verify-tree <tree> --prune-flags` (the step `verify
17
+ bin-rs`: only for a tree that carries Lanes 2.0 native binaries, native_bin.carries_binaries — a tree with no bin-rs/
18
+ or an empty BINARIES.json runs no such step. The tree's own binaries only, never `lanes rs install`'s: host-install.sh
19
+ ran the same check before its commit, so this is the second; a binary whose size or sha256 differs from the list, an
20
+ unlisted one, or a list that is not well formed fails it, and any flags/native.* file the tree does not admit is
21
+ removed) · lanes sync · systemctl --user restart lanes-statusd.service (skipped with a warning while
22
+ flags/native.statusd exists: that flag gives observation to the host coordinator, AR 9.4, so its Python twin is not
23
+ started again; `lanes rs apply` never writes it in Round 1, host_composed) ·
17
24
  systemctl --user try-restart <unit> for each optional service in TRY_RESTART (restarted only when it runs), and
18
25
  right after lanes-docsd's, `sh install/enable-docs.sh` of the tree (the docs page's pinned Mermaid, plan W10 W8:
19
26
  DOCS_STEP; skipped for a tree that has no such script) ·
@@ -23,7 +30,13 @@ installed. Its steps run in this order, each whatever the ones before it returne
23
30
  or docker said that container is gone or has no home volume (daemon_gone) — run by the tree just
24
31
  installed — it re-ships the container contract files, the Throttle pulse among them since 1.4.0 (plan W11 Track D:
25
32
  so the pulse updates with the host; spec §2.1 has where its loop runs), after statusd's restart ·
26
- lanes reload-views (the viewports; sidebars swap by themselves, W9 U5) · lanes ensure --if-layout-changed (W9 U6).
33
+ lanes reload-views (the viewports; sidebars swap by themselves, W9 U5) · lanes ensure --if-layout-changed (W9 U6) ·
34
+ `python3 libexec/adopt.py adopt --state <state> --tree <tree>` (the step `adopt lanes2`, lanes2 Round 2 S12: only for
35
+ a tree that carries libexec/adopt.py, so a rollback to an older tree runs no such step): the Lanes 2.0 store's
36
+ installed adoption, idempotent on every update — each state domain's initial cutover record (shadow, owner lanes-py)
37
+ where none exists, the store's directory and `lanes2/adoption.json`; it never writes a flag, never moves ownership and
38
+ never starts anything (adopt.py). Its exit statuses 1 (an I/O failure) and 3 (a domain refused, e.g. a malformed
39
+ record) are warnings: `lanes doctor` names the domain, and a partial update would re-run every post-commit step.
27
40
  Step output goes to the log (`update/last.log`); stdout gets one line per step and a summary, which names the Mermaid
28
41
  outcome (`mermaid ok`, `mermaid skipped: <reason>`, …) whenever its step ran.
29
42
 
@@ -86,6 +99,7 @@ import time
86
99
  import traceback
87
100
 
88
101
  import lanes_lib as L
102
+ import native_bin
89
103
 
90
104
  STEP_TIMEOUT = 300 # seconds per post-commit step; then its process group is stopped and the step is rc 124
91
105
  STOP_WAIT = 5 # seconds between SIGTERM and SIGKILL of a step's process group, and after it
@@ -110,10 +124,19 @@ REFUSED = 3 # `lock`'s exit status when another run holds the ru
110
124
  # the download failed: skipped), 3 (refused: no valid pin in holders.lock, a digest mismatch; nothing installed) and
111
125
  # 124 (the download did not finish in STEP_TIMEOUT: skipped) are warnings; any other status (2 usage, 127 could not
112
126
  # start, a signal) is a failure like any other step's. An installed file with the pinned digest is kept: no download.
127
+ # Lanes 2.0 (lanes2 Round 1 H2; AR 9.3, 9.5, D9): the native binaries live inside the tree (`pkg/<version>/bin-rs/`),
128
+ # so the commit's `current` flip — and a rollback's — moves them with the Python in one rename. Before a flip the flags
129
+ # are made true to the tree it moves to (host-install.sh: verify-tree --prune-flags, refused on a mismatch; a rollback:
130
+ # native_bin.prune_flags); after the commit this step checks the tree again.
131
+ BIN_RS_STEP = 'verify bin-rs'
132
+ STATUSD_UNIT = 'lanes-statusd.service'
113
133
  DOCS_UNIT = 'lanes-docsd.service'
114
134
  DOCS_STEP = 'enable-docs'
115
135
  DOCS_SCRIPT = 'install/enable-docs.sh'
116
- WARN_RC = {'sync': (1,), DOCS_STEP: (1, 3, 124)}
136
+ # Lanes 2.0 installed adoption (lanes2 Round 2 S12): libexec/adopt.py of the tree just installed, run last.
137
+ ADOPT_STEP = 'adopt lanes2'
138
+ ADOPT_SCRIPT = 'libexec/adopt.py'
139
+ WARN_RC = {'sync': (1,), DOCS_STEP: (1, 3, 124), ADOPT_STEP: (1, 3)}
117
140
  # The steps whose outcome the record and the summary name (any status not listed: `failed`).
118
141
  STEP_OUTCOMES = {DOCS_STEP: {0: 'ok', 1: 'skipped', 3: 'refused', 124: 'skipped'}}
119
142
  REASON_LIMIT = 300 # characters of a step's last line kept as its `reason` (a refusal names two digests)
@@ -388,13 +411,20 @@ def post_commit(tree, state, log, steps=(), before=None, started=None, out=None,
388
411
 
389
412
  def skip(name, reason):
390
413
  # Not run: install-container would exit 1 for it (no such container, no home volume), every run, a
391
- # condition the update neither caused nor can mend (DAEMON_SKIP_RC).
414
+ # condition the update neither caused nor can mend (DAEMON_SKIP_RC); and statusd's restart while
415
+ # flags/native.statusd gives its duty to the host coordinator (Lanes 2.0).
392
416
  steps.append((name, DAEMON_SKIP_RC, True, {'outcome': 'skipped', 'reason': reason}))
393
417
  print(f'WARN {name} (skipped: {reason})', file=out, flush=True)
394
418
  try:
395
419
  step('daemon-reload', [systemctl, '--user', 'daemon-reload'])
420
+ if native_bin.carries_binaries(tree):
421
+ step(BIN_RS_STEP, [sys.executable, str(Path(tree) / 'libexec' / 'native_bin.py'), 'verify-tree',
422
+ str(tree), '--state', str(state), '--prune-flags'])
396
423
  step('sync', [lanes, 'sync'])
397
- step('restart lanes-statusd', [systemctl, '--user', 'restart', 'lanes-statusd.service'])
424
+ if os.path.lexists(Path(state) / 'flags' / native_bin.flag_file('statusd', 'on')):
425
+ skip('restart lanes-statusd', 'flags/native.statusd: observation belongs to the host coordinator')
426
+ else:
427
+ step('restart lanes-statusd', [systemctl, '--user', 'restart', STATUSD_UNIT])
398
428
  for unit in TRY_RESTART:
399
429
  step('try-restart ' + unit[:-len('.service')], [systemctl, '--user', 'try-restart', unit])
400
430
  if unit == DOCS_UNIT and (Path(tree) / DOCS_SCRIPT).is_file():
@@ -413,6 +443,9 @@ def post_commit(tree, state, log, steps=(), before=None, started=None, out=None,
413
443
  step('install-container ' + daemon, [lanes, 'install-container', daemon])
414
444
  step('reload-views', [lanes, 'reload-views'])
415
445
  step('ensure', [lanes, 'ensure', '--if-layout-changed'])
446
+ adopter = Path(tree) / ADOPT_SCRIPT
447
+ if adopter.is_file():
448
+ step(ADOPT_STEP, [sys.executable, str(adopter), 'adopt', '--state', str(state), '--tree', str(tree)])
416
449
  finished = True
417
450
  finally:
418
451
  ok = finished and not failed_steps(steps)
@@ -945,6 +978,16 @@ class Update:
945
978
  services.Refusal: nothing written) or FAILED (anything else; the traceback is in the log)."""
946
979
  services = services_module()
947
980
  with open(self.log, 'a') as log, contextlib.redirect_stderr(log):
981
+ # Lanes 2.0 (lanes2 Round 1 H2; AR 9.3, D9): before the flip, every flags/native.* file whose binary the
982
+ # tree rolled back to does not ship verified (or no explicit install serves) is removed, so no reader runs a
983
+ # binary nobody checked once `current` names that tree. Never a refusal of the rollback itself — unless a
984
+ # flag file cannot be removed: then nothing is flipped.
985
+ removed, problems = native_bin.prune_flags(self.state, previous, L.SHARE)
986
+ for name, reason in removed:
987
+ log.write(f'native flag flags/{name} removed before the flip: {reason}\n')
988
+ if problems:
989
+ log.write(''.join(f'native flags: {problem}; refused, nothing was changed\n' for problem in problems))
990
+ return REFUSED
948
991
  log.write(f'== install/services.py of {L.REPO}: install {previous}\n')
949
992
  log.flush()
950
993
  try: