Skip to content

Add an opt-in network listener for remote engine access #209

Closed

Description

@cjus

Goal

Allow cb2026 to be used by a client on another computer through an explicitly enabled network listener, while preserving existing local CLI, UCI, XBoard and CNP stdin/stdout behavior.

Requested by Carlos on October 26, 2026. This issue records future engineering work; it does not start implementation or expose a listening port.

Existing foundation

  • crates/cnp/src/lib.rs already provides CNP JSON-RPC 2.0 over stdin/stdout, one message per line, initialization/capabilities, search progress, stop/cancellation and structured responses.
  • The current node advertises one active search at a time and returns Busy for conflicting work. Requests carry their own position/options, while a game hint can retain search state between related requests.
  • Follow the repository architecture: networking belongs in a thin adapter, not the I/O-free chess or engine library crates.

Design decisions to record before implementation

  • Select and document the first transport and framing contract: assess reusing CNP over a stream such as TCP versus another transport. Do not introduce a second chess command language unnecessarily.
  • Define whether the first release serves one client, serializes clients, or creates isolated per-client engine instances. Advertise limits truthfully and bound total resource usage.
  • Define the remote-access security boundary: authenticated transport and TLS directly, or a documented trusted tunnel/proxy arrangement. Do not ship an accidentally unauthenticated public listener.
  • Define connection/session ownership, request IDs, cancellation scope, disconnect behavior, idle/read/write deadlines, and whether reconnect resumes anything. Default to no implicit resumption.

Scope and acceptance criteria

  • Listener mode is opt-in with documented bind address/port. Default binding is loopback; non-loopback exposure requires explicit configuration and a documented security model.
  • Ordinary engine invocation opens no network port. Existing UCI/XBoard/CNP stdio behavior and search semantics remain compatible.
  • Reuse existing CNP capabilities, results, progress, error and cancellation semantics where applicable; document any necessary transport-specific extensions.
  • A client cannot read another client's responses or retained game state, cancel its work, change its options, or shut down the entire service through a connection-scoped command.
  • Per-client and process-wide limits bound connections, queued work, threads, hash memory, MultiPV, message size and search time. Return predictable Busy/overload errors rather than creating unbounded engines or queues.
  • Enforce bounded framing and parsing for partial, oversized, malformed and slow input; validate positions and options before expensive work. Do not expose arbitrary filesystem paths or shell execution through remote options.
  • Handle slow readers/backpressure, disconnects during search and cancellation races. Cancel or finish work according to the documented policy, with no stale move response delivered to a different request or connection.
  • Authentication failures and malformed traffic cannot crash the process or leak credentials. Sensitive connection information is redacted from logs.
  • Graceful shutdown stops accepting work, terminates or drains active searches within a bound, closes connections and joins workers without leaving orphan work.
  • Document startup, connection examples, supported transport/security setup, limits, diagnostics and shutdown. Keep configuration names explicit; final CLI spelling is a design decision.

Verification

  • Loopback end-to-end client test: initialize, inspect capabilities, evaluate/search, receive progress, cancel/stop and disconnect.
  • Two-client tests for isolation, request-ID reuse across connections, simultaneous searches, limits and reconnects.
  • Negative tests for unauthenticated access under the selected security mode, oversized/fragmented/malformed messages, slow input/output, invalid positions/options, connection exhaustion and queue saturation.
  • Test disconnect and shutdown while searching, cancellation immediately followed by another search, and absence of stale responses or resource leaks.
  • Confirm no listener in normal mode and regression-test existing protocol adapters.
  • Follow repository definition of done, including scripts/check.sh, relevant documentation, and unchanged search/bench evidence when the change is transport-only.

Boundaries

This is a generic engine networking feature. Client-specific integration and deployment are separate work. No hosting provider, product-specific access model, deadline or implementation schedule is selected here.

Activity

  1. added a commit that references this issue on Nov 5, 2026
  2. cjus commented on Nov 11, 2026

    @cjus
    OwnerAuthor

    Retired by /pr:triage on 2026-11-11. Done: the listener, TLS pairing, discovery, hardening and documentation are merged (#256, #257, #259, #260, #261, #262, #264, with crates/net and docs/network-play.md on main), and docs/status.md says network play now waits only on the two-computer try, which #263 tracks. Not checked: each acceptance criterion in the body one by one; reopen if an audit finds a gap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions