feat(maestro): registry HTTP API, cookie auth, JWT issuance, events WS
ci / rust (push) Successful in 48s

Adds the client-facing surface on the registry (NAP-215). Endpoints:

- GET /api/daemons — list connected daemons (with daemon_url)
- GET /api/sessions — flat session catalog
- POST /api/sessions — forwards CreateSession to chosen daemon, 504 on
  10s daemon timeout
- DELETE /api/sessions/:id — forwards KillSession
- GET /api/sessions/:id/connect-info — returns {daemon_url, jwt} with a
  5min HS256-signed attach JWT
- WS /api/events — snapshot + delta broadcast of catalog and presence
- GET / placeholder served until NAP-218 web bundle lands

Cookie auth middleware mints a long-lived httpOnly JWT cookie on first
request and reissues silently on missing/tampered cookies. Per spec the
perimeter is the operator's network — the cookie is a second factor.

Protocol additions: daemon_url on Hello, DaemonInfo, ConnectInfo,
RegistryEvent. Daemon config + RegistryClient now carry daemon_url.

Registry state now exposes an event broadcast channel (subscribe gives
a snapshot + tokio::sync::broadcast::Receiver) and helper lookups
daemon_for_session / daemon_url.

Tests: 11 reqwest-driven HTTP integration tests cover every endpoint,
the cookie flow, 504 timeout path, worktree forwarding, and events WS
propagation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-24 17:08:41 +00:00
co-authored by Claude Opus 4.7
parent 499cffe397
commit 18bd385a2a
17 changed files with 2058 additions and 72 deletions
+4 -3
View File
@@ -37,13 +37,14 @@ pub async fn handle_socket(
None => return None,
};
let (daemon_id, hostname, version, token) = match hello {
let (daemon_id, hostname, version, token, daemon_url) = match hello {
DaemonOutbound::Hello {
daemon_id,
hostname,
version,
token,
} => (daemon_id, hostname, version, token),
daemon_url,
} => (daemon_id, hostname, version, token, daemon_url),
_ => {
let _ = send_error(&mut sink, "expected_hello", "first message must be Hello").await;
return None;
@@ -57,7 +58,7 @@ pub async fn handle_socket(
let (out_tx, mut out_rx) = mpsc::channel::<DaemonInbound>(OUTBOUND_BUFFER);
registry
.register(daemon_id.clone(), hostname, version, out_tx)
.register(daemon_id.clone(), hostname, version, daemon_url, out_tx)
.await;
let _ = sink