Skip to main content

Module serve

Module serve 

Source
Expand description

tcode serve daemon: STDIO + HTTP JSON-RPC transports + proof-of-life methods.

Why: the foundation of the M1 control-plane cut line (#2053) — proves the transport + router work end-to-end via ping/health before session.* (#2054), task.* (#2056), and harness.describe (#2066) land on top. Both transports dispatch through the same Router, so the method surface can never drift between --stdio and --http. What: build_router, run_stdio, run_http, DEFAULT_HTTP_PORT, and the methods/transport/http submodules. Test: serve::tests::*, serve::methods::tests::*, serve::transport::tests::*, serve::http::tests::*. tcode serve daemon: STDIO + HTTP JSON-RPC transports + proof-of-life, session.*, and task.* methods (#2053, #2054, #2056, #2058, M1 control-plane cut line).

Why: this module is the foundation the tcode serve binary subcommand delegates to. It owns assembling the crate::jsonrpc::Router (and, since #2054, the crate::session::SessionRegistry every session.*/ task.* method shares) and entering whichever transport loop was requested; main.rs stays a thin clap-to-handler shim, matching the rest of the crate’s CLI wiring. What: build_router registers every currently-known method group (today: methods::register’s ping/health proof-of-life pair, crate::session::protocol::register’s eight session.* methods (including #2058’s read-only session.get_transcript), and (#2056) crate::task::protocol::register’s task.run — later tickets add harness.describe #2066 here, one line each). run_stdio and run_http both build a router + registry via build_router and hand them to their respective transport (transport::run_stdio_loop / http::run_http) — every method behaves identically over either transport because both dispatch through the same Router against the same SessionRegistry. Both also call SessionRegistry::shutdown_executions before returning, so a graceful stop (SIGTERM/stdin EOF) gives any in-flight task.run execution a bounded chance to unwind — the same connection-safe-restart discipline (issue #534) this crate’s daemons already apply to connections, now extended to background tasks.

What’s NOT here yet: the transports are independent modes (--stdio xor --http), not simultaneous; running both at once would need a shared Arc<Router>/Arc<SessionRegistry> across two concurrently-spawned tasks, which no current ticket requires (the registry is already Arc, so this is a small extension when it’s needed).

Test: serve::tests::*.

Modules§

discovery
tcode serve --http daemon discovery file (issue #3415, DOC-50 §3.4).
http
HTTP JSON-RPC 2.0 transport for tcode serve --http (#2053, #2054).
methods
Proof-of-life JSON-RPC methods for tcode serve (#2053).
rest
REST resource gateway over the JSON-RPC method registry (#2983, #587, Slice 1 bridge + Slice 2 session.* read routes).
transport
STDIO JSON-RPC transport loop for tcode serve --stdio (#2053, #2054).

Constants§

DEFAULT_HTTP_PORT
Default TCP port for tcode serve --http when --port is omitted.

Functions§

build_router
Assemble the router (+ its session registry) with every method this build of tcode knows about, scoped to project.
run_http
Run tcode serve --http to completion.
run_stdio
Run tcode serve --stdio to completion.