You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(shell): named sessions with --name flag (#50)
* feat(shell): named sessions with --name flag (closes#49)
Introduces human-readable session names, inspired by tmux, to replace
raw PID-based socket paths in the control-channel UX.
Launcher changes:
- Add --name <slug> to Cli; socket at $TMPDIR/shadi-ctl-<name>.sock
- Print "session name: <name>" on startup instead of the raw socket path
Shell changes:
- shadictl shell --attach <name> resolves to the named socket at startup
- /attach accepts a session name OR a full socket path
- /sessions displays human-readable names, not raw socket paths
- Tab completion for /attach offers session names instead of full paths
- /help and usage text updated to mention name support
- Prompt short name strips the shadi-ctl- prefix
policy_watch helpers:
- named_socket_path(name) - name-based socket path (Unix + Windows)
- resolve_session_socket(name_or_path) - accepts name or full path
- session_name_from_path(path) - display name from socket file stem
- sanitize_session_name(name) - allows [a-z0-9_-], replaces other chars
Tests: 6 new unit tests for the helpers; 1 new integration test for
/attach <name> on a non-existent session name.
Signed-off-by: Luca Muscariello <muscariello@ieee.org>
* fix(policy_watch): degrade gracefully when getpeereid(2) fails on macOS
On macOS 15 Sequoia CI runners, getpeereid(2) returns non-zero in some
environments, causing the control socket to reject all connections with
"unauthorized control socket peer" and break the terminate_round_trip test
with EPIPE. The socket is already protected by 0o600 filesystem permissions
set at bind time, so peer-UID verification is defense-in-depth. Degrade
gracefully when the syscall itself fails (allow the connection) while still
actively denying when getpeereid succeeds but reports a UID mismatch.
Signed-off-by: Luca Muscariello <muscariello@ieee.org>
* test(shell): cover cmd_attach success/error paths and /attach completion loop
Add three targeted unit tests to close the diff coverage gap on PR #50:
- given_non_socket_file_when_attach_then_stays_detached: exercises the
Err branch of cmd_attach (file exists but query_policy fails).
- given_live_socket_when_attach_then_sets_socket: exercises the Ok branch
by spinning up a real LivePolicy control socket via start_control_socket,
polling until ready, then attaching and asserting self.socket is set.
- given_session_file_in_tmpdir_when_completing_attach_then_returns_session_name:
exercises the inner loop of the /attach tab-completion handler by placing
a shadi-ctl-*.sock marker file in temp_dir(), completing '/attach ', and
verifying the session name appears in the candidate list. The marker file
is cleaned up (inside catch_unwind) whether the assertion passes or not.
Signed-off-by: Luca Muscariello <muscariello@ieee.org>
---------
Signed-off-by: Luca Muscariello <muscariello@ieee.org>
0 commit comments