@vibelord/lanes 1.9.4 → 1.9.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibelord/lanes",
3
- "version": "1.9.4",
3
+ "version": "1.9.5",
4
4
  "description": "Installer for Lanes: shared agent terminals over SSH with Zellij views, registry sync, uploads and a phone interface.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1 +1 @@
1
- 1.9.4
1
+ 1.9.5
@@ -496,7 +496,8 @@ def clean_env(extra=None):
496
496
  env = {'HOME': str(Path.home()), 'USER': os.environ.get('USER', 'dev'), 'SHELL': '/bin/bash',
497
497
  'PATH': f"{L.SHARE / 'bin'}:{L.CURRENT / 'bin'}:/usr/local/bin:/usr/bin:/bin",
498
498
  'LANG': 'C.UTF-8', 'LANES_STATE': str(L.STATE), 'LANES_SHARE': str(L.SHARE), 'LANES_ZELLIJ': str(ZELLIJ)}
499
- for key in ('LANES_WORKSPACES', 'XDG_RUNTIME_DIR', 'DBUS_SESSION_BUS_ADDRESS', 'ZELLIJ_SOCKET_DIR') + LOOK_ENV:
499
+ for key in ('LANES_WORKSPACES', 'LANES_SITE_HOOK', 'XDG_RUNTIME_DIR', 'DBUS_SESSION_BUS_ADDRESS',
500
+ 'ZELLIJ_SOCKET_DIR') + LOOK_ENV:
500
501
  if os.environ.get(key): # ZELLIJ_SOCKET_DIR: test isolation
501
502
  env[key] = os.environ[key]
502
503
  if 'XDG_RUNTIME_DIR' not in env and Path(f'/run/user/{os.getuid()}').is_dir():
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schema": "lanes.bin-rs/1",
3
- "commit": "e994613743be1e0eca506ac1e3d1ebfa633a2e58",
3
+ "commit": "53c449872ad1d3d41a9c4138e77c611d27352141",
4
4
  "binaries": []
5
5
  }
@@ -5,6 +5,23 @@ views on desktop or phone. The host owns views and derived registries. The conta
5
5
  terminal. Installing or closing a view does not end a lane. For how to use it, see the [user guide](USERGUIDE.md);
6
6
  for operations, the [runbook](RUNBOOK.md).
7
7
 
8
+ ## Federated attachment invariant
9
+
10
+ The registry and its resolve files carry the endpoint route chosen by the
11
+ catalog. A local route may inspect Docker and `/proc`. A `guest:<alias>` route
12
+ must enter the site's attach adapter before any local process check. Guest
13
+ containers intentionally have no local PID, so the local holder's
14
+ `container … is not running` refusal is invalid for them.
15
+
16
+ `lanes sync` writes one small route file beside each container PID file. The
17
+ interactive tmux holder reads that route and asks the external site hook for an
18
+ attach-only argv. The hook owns the SSH and guest command details. The holder
19
+ never creates a server, provisions a workspace, or falls back to local Docker
20
+ for a guest route. Missing or conflicting adapters fail closed with a
21
+ site-specific refusal. This keeps the existing registry, holder and
22
+ `lanes-site/1` contracts additive while making workspace attachment use the
23
+ same route as discovery and typed actions.
24
+
8
25
  ## Source of truth and sync
9
26
 
10
27
  1. The deployment's `catalog.json` orders workspaces and selects their manifests.
@@ -4371,6 +4371,15 @@ sidebar, `lanes register`).
4371
4371
 
4372
4372
  ## Federation: lanes-site/1 (guests behind a forced-command key)
4373
4373
 
4374
+ ### Interactive attachment route
4375
+
4376
+ The guest route is recorded at sync time beside the container PID projection.
4377
+ An existing viewer can therefore attach to a guest lane without probing local
4378
+ Docker or `/proc`. The tmux holder dispatches `guest:<alias>` to the external
4379
+ site hook, which returns the attach-only client argv. A guest route with no
4380
+ adapter is refused and never retried as a stopped local container. Refresh an
4381
+ old viewer after changing the package so it loads the route-aware holder.
4382
+
4374
4383
  Plan row H1 (BEY-6899, BEY-6912; Lanes2 architecture §3.32 and §7.5; DM-LANES-SITE-ADAPTER). A host whose boards
4375
4384
  live in containers on other docker hosts (the guests) reaches them through one protocol, `lanes-site/1`: newline JSON
4376
4385
  over one long-lived `ssh -T` per guest, behind a forced-command key on the guest. It ships with the reference server
@@ -12,6 +12,7 @@
12
12
  set -u
13
13
  state=${LANES_STATE:-$HOME/.local/state/lanes}
14
14
  container=${1:-} socket=${2:-} session=${3:-}
15
+ repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd -P)
15
16
  fail() { echo "$2" >&2; exit "$1"; } # the view shows the last stderr line on its status screen
16
17
  case "$container" in ''|-*|*[!A-Za-z0-9_.-]*) fail 64 'invalid container' ;; esac
17
18
  case "$socket" in ''|-*|*[!A-Za-z0-9_.-]*) fail 64 'invalid socket' ;; esac
@@ -26,6 +27,19 @@ case "$socket" in ''|-*|*[!A-Za-z0-9_.-]*) fail 64 'invalid socket' ;; esac
26
27
  # and the pty re-wrap below hands it to `script` through the ENVIRONMENT, never inside a quoted command string.
27
28
  # Control characters stay refused: no listing round-trips them.
28
29
  case "$session" in ''|*[[:cntrl:]]*) fail 64 'invalid session' ;; esac
30
+
31
+ # A guest route is authoritative. Do this before the local pid/Docker check:
32
+ # the guest has no local /proc entry by design, so treating it as a stopped
33
+ # container produces the recurring "container is not running" pane. The
34
+ # helper asks the external site hook for an attach-only argv and never creates
35
+ # a server or a lane.
36
+ route=$(cat "$state/containers/$container.route" 2>/dev/null || :)
37
+ case "$route" in
38
+ guest:*)
39
+ exec python3 -S -E "$repo/libexec/site_attach.py" "$route" "$container" "$socket" "$session"
40
+ ;;
41
+ esac
42
+
29
43
  # Every target carries the WINDOW suffix `:`. A trailing `;` ends a tmux command in ANY argv element, so a bare
30
44
  # `-t "=$session"` on a live session named `foo;` resolved `=foo`: MEASURED (tmux 3.4, scratch server) an
31
45
  # `attach-session -t '=foo;'` put the client on `foo` — a lane the operator did not select — while with `foo`
@@ -803,6 +803,7 @@ def refresh_containers(names):
803
803
  if name in guests: # no local init: its typed actions and reads go through lanes-site/1 (write_route)
804
804
  info[name] = {'pid': 0, 'home': '', 'running': False, 'transport': guests[name], 'container': name}
805
805
  atomic_write_if_changed(STATE / 'containers' / f'{name}.pid', '0\n')
806
+ atomic_write_if_changed(STATE / 'containers' / f'{name}.route', guests[name] + '\n')
806
807
  continue
807
808
  try:
808
809
  if not IDENT.match(name):
@@ -828,6 +829,8 @@ def refresh_containers(names):
828
829
  info[name] = {'pid': 0, 'home': '', 'running': False, 'error': str(error)}
829
830
  # One tiny file per container: the POSIX-sh holders read it without python or docker.
830
831
  atomic_write_if_changed(STATE / 'containers' / f'{name}.pid', f"{info[name]['pid']}\n")
832
+ atomic_write_if_changed(STATE / 'containers' / f'{name}.route',
833
+ str(info[name].get('transport', TRANSPORT_LOCAL)) + '\n')
831
834
  atomic_write_if_changed(STATE / 'containers.json', json.dumps(info, indent=2) + '\n')
832
835
  return info
833
836
 
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env python3
2
+ """Execute the declared site hook's attach-only command for one guest lane."""
3
+
4
+ import os
5
+ import re
6
+ import sys
7
+ from pathlib import Path
8
+
9
+ import site_hooks
10
+
11
+
12
+ IDENT = re.compile(r'^[A-Za-z0-9_.-]+$')
13
+ ROUTE = re.compile(r'^guest:[A-Za-z0-9_][A-Za-z0-9_.-]{0,62}$')
14
+
15
+
16
+ def main(argv):
17
+ if len(argv) != 4:
18
+ raise SystemExit('usage: site_attach.py <route> <container> <socket> <session>')
19
+ route, container, socket_name, session = argv
20
+ if (not ROUTE.fullmatch(route) or not IDENT.fullmatch(container)
21
+ or not IDENT.fullmatch(socket_name) or not session
22
+ or any(ord(c) < 32 or ord(c) == 127 for c in session)):
23
+ raise SystemExit('invalid guest holder target')
24
+ try:
25
+ command = site_hooks.holder_attach(route, container, socket_name, session)
26
+ except RuntimeError as error:
27
+ raise SystemExit(f'guest route attach adapter refused: {error}') from error
28
+ if not isinstance(command, (list, tuple)) or not command or any(
29
+ not isinstance(word, str) or not word for word in command):
30
+ raise SystemExit('guest route has no attach adapter')
31
+ executable = Path(command[0])
32
+ if not executable.is_absolute() or '/' not in str(executable):
33
+ raise SystemExit('guest attach adapter must use an absolute executable')
34
+ os.execv(command[0], list(command))
35
+
36
+
37
+ if __name__ == '__main__':
38
+ main(sys.argv[1:])
@@ -63,3 +63,38 @@ def apply(stage, *args):
63
63
  f = getattr(mod, fn, None)
64
64
  if f is not None:
65
65
  f(*args)
66
+
67
+
68
+ def holder_attach(route, container, socket_name, session):
69
+ """Return an attach argv for a declared guest route, or ``None``.
70
+
71
+ The interactive holder is a shell process, while federation hooks are
72
+ Python modules outside the package tree. This small value-only seam lets
73
+ the holder ask the same site hook that builds the registry for its attach
74
+ command. Hooks never receive a shell command string and the caller still
75
+ validates the returned argv before executing it.
76
+ """
77
+ if not isinstance(route, str) or not route.startswith('guest:'):
78
+ return None
79
+ answer = None
80
+ for mod in _load():
81
+ fn = getattr(mod, 'holder_attach', None)
82
+ if fn is not None:
83
+ candidate = fn(route, container, socket_name, session)
84
+ else:
85
+ # 1.9.2 hooks predate this callback but already expose the
86
+ # transport's config, container name and attach client. Keep
87
+ # those deployed hooks usable while they are upgraded. This is
88
+ # deliberately read-only and only returns the hook's own fixed
89
+ # client argv.
90
+ configured = getattr(mod, 'config', None)
91
+ expected = getattr(mod, 'CONTAINER', None)
92
+ client = getattr(mod, 'CLIENT', None)
93
+ candidate = ([client, 'attach', socket_name, session]
94
+ if callable(configured) and configured() and container == expected
95
+ and isinstance(client, str) and client.startswith('/') else None)
96
+ if candidate is not None:
97
+ if answer is not None:
98
+ raise RuntimeError('multiple site hooks supplied a guest holder')
99
+ answer = candidate
100
+ return answer
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@vibelord/lanes",
3
- "version": "1.9.4",
4
- "commit": "e994613743be1e0eca506ac1e3d1ebfa633a2e58",
5
- "digest": "sha256:efaf62178559325740e341999a6bc3f3632326d277ce12293a3e04b1376f950b",
3
+ "version": "1.9.5",
4
+ "commit": "53c449872ad1d3d41a9c4138e77c611d27352141",
5
+ "digest": "sha256:287c1e9a5e6de67520adcd5638fe51c1305c2cf3db62ab4f92e99a0b0cdcfce8",
6
6
  "executables": [
7
7
  "bin/lanes",
8
8
  "bin/lanes-site-serve",