Skip to content

Fix daemon socket-transport accuracy and Windows test-cleanup flake - #10

Merged
wheresoli merged 6 commits into
mainfrom
fix/socket-transport-accuracy-and-win-test-cleanup
Jul 10, 2026
Merged

Fix daemon socket-transport accuracy and Windows test-cleanup flake#10
wheresoli merged 6 commits into
mainfrom
fix/socket-transport-accuracy-and-win-test-cleanup

Conversation

@wheresoli

Copy link
Copy Markdown
Owner

Summary

LiveShell ships a loopback-TCP socket transport (serve_socket / liveshell daemon serve / daemon start / LiveShellClient.connect) alongside stdio, but capability discovery and the docs still described it as stdio-only. That's a false contract for any consumer that negotiates on capability.discover, and the docs actively tell readers a socket transport "is not included." This PR corrects the contract and the documentation, and fixes a related Windows test flake found while verifying.

1. capabilities.pydaemon.protocol was lying

daemon.protocol advertised {"transport": "stdio", "network": False} despite the shipping socket transport. Now:

{ "transports": ["stdio", "socket"], "socket_scope": "loopback", "remote_network": false }

This still asserts the true guarantee (no remote/auto-started server) while telling the truth about the two supported transports. Added a test locking the shape.

2. Docs (README.md, PROTOCOL.md) — removed false statements

Corrected claims that contradicted the code:

  • "Local named pipe or Unix socket daemon transport is not included in this slice. The stdio protocol is the supported live transport"
  • "The protocol is local-only stdio" / "does not ... expose a default network server"

Now: documents both transports, the daemon serve/start/stop CLI commands (previously undocumented), attaching via LiveShellClient.connect(state_dir), and a new Transports section in PROTOCOL.md. The accurate security posture is preserved: loopback-only, opt-in, no remote/auto-started listener, no URL handlers.

3. Windows test-cleanup flake

The suite intermittently errored during TemporaryDirectory cleanup when a daemon-held WAL sqlite file raced rmtree (NotADirectoryError / WinError 267). Added ignore_cleanup_errors=True to the 62 strict-cleanup TemporaryDirectory sites across 6 test files — consistent with the existing rmtree_retry workaround in test_persistent_daemon.py.

Verification

  • python -m unittest discover -s tests90 passing (was 89), 3 consecutive green runs on Windows (the flake no longer reproduces).
  • ruff not run locally (dev extra not installed); CI will lint.

Not in scope (noted for follow-up)

  • command.exit_code.native: true is reported for all shells, but cmd/bash exit codes are parsed from a sentinel (only hosted PowerShell is truly native). Left as-is to keep this PR focused on the transport inaccuracy; worth a separate look.

🤖 Generated with Claude Code

…s test-cleanup flake

The package ships a loopback-TCP socket transport (serve_socket / `daemon
serve` / `daemon start` / LiveShellClient.connect) alongside stdio, but
capability discovery and the docs still described it as stdio-only. This
corrects the contract and the documentation, and fixes a Windows test flake.

capabilities.py:
- `daemon.protocol` advertised `{"transport": "stdio", "network": False}`,
  which is false — a loopback socket transport exists. Now advertises
  `{"transports": ["stdio", "socket"], "socket_scope": "loopback",
  "remote_network": False}`, preserving the true "no remote server" guarantee.
- Added a test asserting the accurate shape.

docs (README.md, PROTOCOL.md):
- Removed the inaccurate claims that a socket/network transport "is not
  included", that the protocol is "local-only stdio", and that there is no
  network server. There is an opt-in, loopback-only socket daemon.
- Documented `daemon serve`/`start`/`stop` in the CLI list and how to attach
  with LiveShellClient.connect; added a Transports section to PROTOCOL.md.
- Kept the accurate posture: loopback-only, opt-in, no remote/auto-started
  listener, no URL handlers.

tests (Windows flake):
- The suite intermittently errored during TemporaryDirectory cleanup when a
  daemon-held WAL sqlite file raced rmtree (NotADirectoryError / WinError 267).
- Added `ignore_cleanup_errors=True` to the strict-cleanup TemporaryDirectory
  sites (62 across 6 files), consistent with the existing rmtree_retry
  workaround in test_persistent_daemon.py.

Verification: `python -m unittest discover -s tests` → 90 passing (was 89),
3 consecutive green runs on Windows. ruff not run locally (dev extra not
installed); CI will lint.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 10, 2026 10:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR corrects the daemon transport “contract” by updating capability discovery and documentation to reflect that LiveShell supports both stdio and a loopback-only TCP socket transport, and it hardens the Windows test suite against intermittent temp-dir cleanup failures.

Changes:

  • Update daemon.protocol capability details to advertise both stdio and socket transports, and add a regression test.
  • Update README + protocol docs to remove stdio-only claims and document the socket-based daemon workflow (daemon serve / daemon start / LiveShellClient.connect).
  • Reduce Windows cleanup flakes by setting TemporaryDirectory(ignore_cleanup_errors=True) across affected tests.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/liveshell/capabilities.py Updates daemon.protocol capability details to report both transports.
tests/test_capabilities.py Adds a test that locks the new daemon.protocol capability shape.
README.md Updates docs to describe both stdio + socket transports and relevant CLI commands.
docs/PROTOCOL.md Updates protocol docs to be transport-agnostic and adds a “Transports” section.
tests/test_store.py Uses ignore_cleanup_errors=True to avoid Windows temp cleanup flakes.
tests/test_production_readiness.py Same cleanup hardening across production-readiness tests.
tests/test_handles.py Same cleanup hardening across handle tests.
tests/test_daemon.py Same cleanup hardening across daemon/protocol tests.
tests/test_client.py Same cleanup hardening across client tests.
tests/test_cli.py Same cleanup hardening across CLI tests (including prefixed temp dirs).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md
Comment thread docs/PROTOCOL.md Outdated
wheresoli and others added 3 commits July 10, 2026 13:27
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@wheresoli wheresoli changed the title Fix daemon socket-transport accuracy (capabilities + docs) and Windows test-cleanup flake Fix daemon socket-transport accuracy and Windows test-cleanup flake Jul 10, 2026
@wheresoli
wheresoli merged commit 92a8660 into main Jul 10, 2026
8 checks passed
@wheresoli
wheresoli deleted the fix/socket-transport-accuracy-and-win-test-cleanup branch July 10, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants