@vibelord/lanes 1.7.3 → 1.7.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/README.md +9 -0
- package/package.json +1 -1
- package/payload/lanes/VERSION +1 -1
- package/payload/lanes/bin/lanes +128 -24
- package/payload/lanes/bin/lanes-site-serve +15 -0
- package/payload/lanes/bin-rs/BINARIES.json +5 -0
- package/payload/lanes/container/lane-mcp +108 -5
- package/payload/lanes/container/lane_core.py +116 -0
- package/payload/lanes/container/throttle-pulse +159 -14
- package/payload/lanes/docs/ARCHITECTURE.md +132 -13
- package/payload/lanes/docs/DESIGN.md +10 -8
- package/payload/lanes/docs/INSTALL.md +1 -1
- package/payload/lanes/docs/RUNBOOK.md +436 -8
- package/payload/lanes/docs/USERGUIDE.md +82 -9
- package/payload/lanes/install/host-install.sh +35 -4
- package/payload/lanes/libexec/adopt.py +364 -0
- package/payload/lanes/libexec/attach.py +35 -5
- package/payload/lanes/libexec/cutover.py +656 -0
- package/payload/lanes/libexec/docsd.py +12 -8
- package/payload/lanes/libexec/doctor_lanes2.py +284 -0
- package/payload/lanes/libexec/economy_poll.py +87 -2
- package/payload/lanes/libexec/gc_unregistered.py +407 -0
- package/payload/lanes/libexec/lanes_lib.py +474 -2
- package/payload/lanes/libexec/native.sh +38 -0
- package/payload/lanes/libexec/native_bin.py +670 -0
- package/payload/lanes/libexec/session_actions.py +85 -7
- package/payload/lanes/libexec/shadow.py +1311 -0
- package/payload/lanes/libexec/sidebar.py +252 -30
- package/payload/lanes/libexec/sidebar_status.py +373 -25
- package/payload/lanes/libexec/statusd.py +67 -3
- package/payload/lanes/libexec/tokens.py +99 -131
- package/payload/lanes/libexec/tokens.sh +1 -1
- package/payload/lanes/libexec/update.py +78 -8
- package/payload/lanes/libexec/users.py +282 -0
- package/payload/lanes/site/README.md +9 -0
- package/payload/lanes/site/conformance.py +280 -0
- package/payload/lanes/site/protocol.py +368 -0
- package/payload/lanes/site/server.py +314 -0
- package/payload/lanes/systemd/lanes-gc.service +1 -1
- package/payload/lanes/systemd/lanes-gc.timer +14 -3
- package/payload/lanes/tokens/README.md +156 -0
- package/payload/lanes/tokens/generate.py +930 -0
- package/payload/lanes/tokens/generated/parity.v1.tsv +489 -0
- package/payload/lanes/tokens/generated/tokens.resolved.json +835 -0
- package/payload/lanes/tokens/tokens.v1.json +763 -0
- package/payload/lanes/tokens/tokens.v1.schema.json +143 -0
- package/payload/lanes/web/Caddyfile +11 -0
- package/payload/lanes/web/README.md +253 -4
- package/payload/lanes/web/directory.css +95 -0
- package/payload/lanes/web/directory.js +951 -0
- package/payload/lanes/web/generated/README.md +107 -0
- package/payload/lanes/web/generated/lanes2_protocol.d.mts +1162 -0
- package/payload/lanes/web/generated/lanes2_protocol.mjs +2333 -0
- package/payload/lanes/web/inbox.js +1140 -0
- package/payload/lanes/web/mobile.js +35 -45
- package/payload/lanes/web/tokens.css +137 -0
- package/payload/manifest.json +7 -4
|
@@ -399,13 +399,73 @@ def unregister_lane(lane_id, registry=None):
|
|
|
399
399
|
return dict(unregister_declared(path, name, root=info['home']), lane=lane_id, source=lane['source'])
|
|
400
400
|
|
|
401
401
|
|
|
402
|
-
|
|
403
|
-
|
|
402
|
+
# The unattended close's in-tmux condition (`lanes gc --unregistered`, gc_unregistered.end; PR #750 review): the
|
|
403
|
+
# session's creation time AND no client attached to it, both evaluated by the tmux server in the same if-shell as the
|
|
404
|
+
# kill, so a person who attaches between the sweep's last look and the kill keeps the session. `%s` is the creation-time
|
|
405
|
+
# check every close carries. UNATTENDED_REFUSED is what the server answers when the condition is false.
|
|
406
|
+
UNATTENDED_CONDITION = '#{&&:%s,#{==:#{session_attached},0}}'
|
|
407
|
+
UNATTENDED_REFUSED = 'attached-or-replaced'
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
def close_session(workspace, entry, unattended=False):
|
|
411
|
+
"""Close the exact observed session, never an identically named replacement or a registered lane. `unattended` is
|
|
412
|
+
conservative close mode, never a person's `x`: it refuses while any view member (a Studio
|
|
413
|
+
browser's grouped `view-…` session) shows the session and never kills one, and tmux kills only while no client is
|
|
414
|
+
attached to it, checked inside the server together with the creation time (UNATTENDED_CONDITION)."""
|
|
404
415
|
with L.registry_lock():
|
|
405
|
-
return _close_session(workspace, entry)
|
|
416
|
+
return _close_session(workspace, entry, unattended)
|
|
406
417
|
|
|
407
418
|
|
|
408
|
-
def
|
|
419
|
+
def close_idle_session(workspace, entry, *, idle_s):
|
|
420
|
+
"""GC's close: recheck policy under the registry lock, then guard live facts inside tmux.
|
|
421
|
+
|
|
422
|
+
BEY-7156: a fresh status.json is still a cached observation. The ordinary
|
|
423
|
+
human close may end an attached session and its Studio views; GC may not.
|
|
424
|
+
"""
|
|
425
|
+
import gc_unregistered as gc
|
|
426
|
+
if not isinstance(idle_s, int) or isinstance(idle_s, bool) or idle_s < gc.IDLE_MIN:
|
|
427
|
+
raise L.LanesError('Invalid idle floor; nothing was closed')
|
|
428
|
+
with L.registry_lock():
|
|
429
|
+
status = gc.read_status()
|
|
430
|
+
current = next((row for board, row in gc.listed(status, workspace)
|
|
431
|
+
if row['id'] == entry['id']), None)
|
|
432
|
+
if (current is None or session_key(current) != session_key(entry)
|
|
433
|
+
or current.get('identity') != entry.get('identity')):
|
|
434
|
+
raise L.LanesError('Session changed; nothing was closed')
|
|
435
|
+
now = time.time()
|
|
436
|
+
containers = L.read_json(L.STATE / 'containers.json') or {}
|
|
437
|
+
said, reason = gc.judge(status, current, containers, idle_s, now)
|
|
438
|
+
if said != 'reap':
|
|
439
|
+
raise L.LanesError(f'Session no longer idle: {reason}; nothing was closed')
|
|
440
|
+
quiet, why = gc.nothing_runs(current, containers.get(current.get('container')) or {})
|
|
441
|
+
if not quiet:
|
|
442
|
+
raise L.LanesError(f'Session no longer idle: {why}; nothing was closed')
|
|
443
|
+
return _close_session(workspace, current, unattended=True, idle_before=int(now) - idle_s)
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
def _idle_condition(created, idle_before):
|
|
447
|
+
"""One tmux-format predicate over this exact session and ALL its windows.
|
|
448
|
+
|
|
449
|
+
Empty/malformed activity is not old activity. A window loop contributes a
|
|
450
|
+
marker for every unobserved or recent window; only an empty result is idle.
|
|
451
|
+
No shell is run between evaluating this predicate and the queued close.
|
|
452
|
+
"""
|
|
453
|
+
window_known = '#{&&:#{m/r:^[0-9]+$,#{window_activity}},#{>:#{window_activity},0}}'
|
|
454
|
+
window_idle = '#{&&:' + window_known + ',#{<=:#{window_activity},' + str(idle_before) + '}}'
|
|
455
|
+
conditions = [
|
|
456
|
+
'#{==:#{session_created},' + created + '}',
|
|
457
|
+
'#{==:#{session_attached},0}',
|
|
458
|
+
'#{==:#{session_grouped},0}',
|
|
459
|
+
'#{>:#{session_windows},0}',
|
|
460
|
+
'#{==:#{W:#{?' + window_idle + ',,busy}},}',
|
|
461
|
+
]
|
|
462
|
+
result = conditions.pop()
|
|
463
|
+
for condition in reversed(conditions):
|
|
464
|
+
result = '#{&&:' + condition + ',' + result + '}'
|
|
465
|
+
return result
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
def _close_session(workspace, entry, unattended=False, *, idle_before=None):
|
|
409
469
|
import registrations
|
|
410
470
|
registry = registrations.apply(L.load_registry())
|
|
411
471
|
current = (L.read_json(L.STATE / 'status.json', {}) or {}).get('unregistered', {}).get(workspace, [])
|
|
@@ -439,6 +499,8 @@ def _close_session(workspace, entry):
|
|
|
439
499
|
if not sid.startswith('$') or not sid[1:].isdigit() or not created.isdigit():
|
|
440
500
|
raise L.LanesError('Session identity is not ready; wait for the next status update')
|
|
441
501
|
info = (L.read_json(L.STATE / 'containers.json', {}) or {}).get(container) or {}
|
|
502
|
+
if idle_before is not None and L.write_route(container, info, socket)[0] != L.TRANSPORT_LOCAL:
|
|
503
|
+
raise L.LanesError('No local write route; nothing was closed')
|
|
442
504
|
outcome, actual = L.tmux_probe(info, socket,
|
|
443
505
|
['display-message', '-p', '-t', '=' + name + ':',
|
|
444
506
|
'#{session_id}\t#{session_created}'], 5)
|
|
@@ -456,17 +518,33 @@ def _close_session(workspace, entry):
|
|
|
456
518
|
if outcome != 'ok':
|
|
457
519
|
raise L.LanesError('Could not read the session groups; nothing was closed')
|
|
458
520
|
views, strangers = L.grouped_members(listing, name)
|
|
521
|
+
if idle_before is not None and (views or strangers):
|
|
522
|
+
raise L.LanesError('Session is viewed or grouped; nothing was closed')
|
|
459
523
|
if strangers:
|
|
460
524
|
raise L.LanesError(
|
|
461
525
|
f'{len(strangers)} session(s) are grouped onto it and would keep its panes alive: '
|
|
462
526
|
+ ', '.join(sorted(strangers)[:3]) + ' — end them first; nothing was closed')
|
|
527
|
+
if unattended and views:
|
|
528
|
+
# A view is a person looking (a Studio browser). A person's `x` ends the Host's view first; the sweep never
|
|
529
|
+
# does: it leaves the session to the next night.
|
|
530
|
+
raise L.LanesError(f'{len(views)} view(s) show it: ' + ', '.join(sorted(views)[:3])
|
|
531
|
+
+ ' — someone is looking; nothing was closed')
|
|
463
532
|
for member in views:
|
|
464
|
-
# Named by the listing, targeted exactly, and only ever a name the Studio Host mints
|
|
533
|
+
# Named by the listing, targeted exactly, and only ever a name the Studio Host mints (never unattended: refused
|
|
534
|
+
# above).
|
|
465
535
|
L.tmux_probe(info, socket, ['kill-session', '-t', '=' + member + ':'], 5)
|
|
466
536
|
# The conditional executes inside tmux: even a replacement between the check and kill is protected.
|
|
537
|
+
condition = ('#{==:#{session_created},' + created + '}' if idle_before is None
|
|
538
|
+
else _idle_condition(created, idle_before))
|
|
539
|
+
refusal = 'stale-session' if idle_before is None else 'session-live-or-unobserved'
|
|
540
|
+
if unattended and idle_before is None:
|
|
541
|
+
condition = UNATTENDED_CONDITION % condition
|
|
542
|
+
refusal = UNATTENDED_REFUSED
|
|
467
543
|
outcome, error = L.tmux_probe(info, socket,
|
|
468
|
-
['if-shell', '-F', '-t', sid,
|
|
469
|
-
'kill-session -t ' + shlex.quote(sid), 'display-message -p
|
|
544
|
+
['if-shell', '-F', '-t', sid, condition,
|
|
545
|
+
'kill-session -t ' + shlex.quote(sid), 'display-message -p ' + refusal], 5)
|
|
546
|
+
if unattended and outcome == 'ok' and error.strip() == UNATTENDED_REFUSED:
|
|
547
|
+
raise L.LanesError('A client attached, or the session was replaced, before the close; nothing was closed')
|
|
470
548
|
if outcome != 'ok' or error.strip():
|
|
471
549
|
raise L.LanesError('Could not confirm close: ' + (error or outcome))
|
|
472
550
|
clear_viewers(entry['id'])
|