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
+5
View File
@@ -23,6 +23,11 @@ pub struct DaemonConfig {
pub hostname: String,
pub registry_url: String,
pub bind_addr: SocketAddr,
/// Reachable URL for this daemon's per-session WS endpoint, advertised in
/// `Hello` so the registry can hand it to clients via `connect-info`.
/// Distinct from `bind_addr` because the bind may be `0.0.0.0` while the
/// publicly reachable address is a Wireguard / VPN interface.
pub daemon_url: String,
pub token: String,
/// Root for everything daemon-local: sidecars, FIFOs, etc.
/// Default: `~/.local/state/maestrod`.
+1
View File
@@ -71,6 +71,7 @@ async fn run() -> Result<(), Box<dyn Error>> {
config.registry_url.clone(),
config.daemon_id.clone(),
config.hostname.clone(),
config.daemon_url.clone(),
config.token.clone(),
manager.clone(),
);
@@ -41,6 +41,7 @@ pub struct RegistryClient {
registry_url: String,
daemon_id: String,
hostname: String,
daemon_url: String,
token: String,
manager: SessionManager,
}
@@ -50,6 +51,7 @@ impl RegistryClient {
registry_url: impl Into<String>,
daemon_id: impl Into<String>,
hostname: impl Into<String>,
daemon_url: impl Into<String>,
token: impl Into<String>,
manager: SessionManager,
) -> Self {
@@ -57,6 +59,7 @@ impl RegistryClient {
registry_url: registry_url.into(),
daemon_id: daemon_id.into(),
hostname: hostname.into(),
daemon_url: daemon_url.into(),
token: token.into(),
manager,
}
@@ -91,6 +94,7 @@ impl RegistryClient {
hostname: self.hostname.clone(),
version: PROTOCOL_VERSION.into(),
token: self.token.clone(),
daemon_url: self.daemon_url.clone(),
};
sink.send(Message::Text(serde_json::to_string(&hello)?))
.await?;