Expand description
Service layer for hyprstream
This module provides services for inference and registry operations. Services use Cap’n Proto for serialization via moq-net + UDS transport.
§Security
All requests are wrapped in SignedEnvelope for authentication:
process_requestverifies Ed25519 signatures before dispatching- Handlers receive
EnvelopeContextwith verified identity - Services use
ctx.subject()for policy checks and resource isolation
§Architecture
┌─────────────────────────────────────────────────────────────┐
│ hyprstream/src/services/ │
│ ├── core.rs ← RequestService trait re-exports │
│ ├── types.rs ← Shared types (FsDirEntry, ModelInfo, etc.)│
│ ├── registry.rs ← Registry server │
│ └── inference.rs ← Inference server │
└─────────────────────────────────────────────────────────────┘§Usage
Services implement RequestService and are automatically Spawnable via blanket impl:
ⓘ
use crate::services::{EnvelopeContext, RequestService};
use hyprstream_rpc::prelude::*;
use hyprstream_rpc::transport::TransportConfig;
struct MyService {
transport: TransportConfig,
signing_key: SigningKey,
}
impl RequestService for MyService {
async fn handle_request(&self, ctx: &EnvelopeContext, payload: &[u8]) -> Result<(Vec<u8>, Option<Continuation>)> {
println!("Request from: {}", ctx.subject());
Ok((vec![], None))
}
fn name(&self) -> &str { "my-service" }
fn transport(&self) -> &TransportConfig { &self.transport }
fn signing_key(&self) -> SigningKey { self.signing_key.clone() }
}
let service = MyService { transport, signing_key };
let manager = InprocManager::new();
let handle = manager.spawn(Box::new(service)).await?;
// Connect a client (signing is automatic)
let client = ZmqClient::new("inproc://my-service", context, signing_key, identity);
let response = client.call(payload, None).await?;
// Stop the service
handle.stop().await;Re-exports§
pub use image_substrate::create_image_substrate_router;pub use image_substrate::ImageSubstratePolicy;pub use image_substrate::ImageSubstrateState;pub use inference::InferenceService;pub use inference::InferenceServiceConfig;pub use inference::INFERENCE_ENDPOINT;pub use model::ModelService;pub use model::ModelServiceConfig;pub use model::StagingModelPin;pub use model::MODEL_ENDPOINT;pub use namespace_builder::build_standard_namespace;pub use namespace_builder::StandardNamespaceConfig;pub use oai::OAIService;pub use oauth::OAuthService;pub use policy::PolicyService;pub use registry::RegistryService;pub use xet::XetService;pub use xet::XetState;pub use mcp_service::McpConfig;pub use mcp_service::McpService;
Modules§
- at9p_
renewal - In-daemon at9p service-identity renewal timer (design O-Ia).
- discovery
- Discovery service — re-exports from
hyprstream-discovery. - editing
- CRDT-based collaborative file editing.
- event_
network - Authenticated Event transport and profile-aware initialization. Native Event transport bootstrap. Identity admission and MAC are independent.
- factories
- Service factory functions for inventory-based registration.
- fs
- Reusable synthetic 9P filesystem for services.
- generated
- RPC surface used by the AGPL daemon.
- image_
substrate - HTTP image substrate for stock nydus-snapshotter consumers (#789).
- inference
- ZMQ-based inference service for text generation
- kata_
9p_ backend ModelBackend— the capnp-RPCBackendfor the Kata 9P translator.- mcp_
service - MCP (Model Context Protocol) service — UUID-keyed tool registry
- model
- Model service for managing InferenceService instances over ZMQ
- namespace_
builder - Shared “standard namespace” composition for VFS consumers.
- native_
event_ policy - Finite internal Event policy. Enrollment grants clearance; accepted state supplies live identity/key/currentness. Neither source alone grants access.
- ninep_
bridge - Shared sync→async bridge for 9P-style
Mountimplementations that proxy to a Cap’n Proto RPC service (nine.capnpenvelope). - oai
- OAIService - OpenAI-compatible HTTP API
- oauth
- OAuth 2.1 Authorization Server for hyprstream.
- policy
- Policy service for authorization checks over ZMQ
- public_
repo - Durable public AT Protocol repository transactions.
- registry
- ZMQ-based registry service for repository management
- remote_
mount - Remote model mount — bridges the VFS
Mounttrait to the generatedModelClientRPC. - remote_
registry_ mount - Remote registry mount — bridges the VFS
Mounttrait to the registry service’s worktree filesystem via the generatedWorktreeClientRPC. - revocation
- Policy-authority credential revocation and session registry: one canonical store of each kind per deployment.
- router
- Leaf-tier cell-router for federated inference scheduling (#322).
- rpc_
types - RPC types: re-exports and inference-specific stream payload types.
- stream_
network - Native producer/Streams carrier admission and lifecycle. Native Streams origins. Carrier admission is independent of stream payload authentication and MAC authorization performed by the producing RPC service.
- typed
- Typed response carrying JSON (human-readable) and optionally capnp (machine-readable).
- worker
- Worker service types and helpers.
- xet
- XetService — HuggingFace-XET CAS HTTP face (epic #654, task #5, FOUNDATION).
- xet_
provenance - XET content provenance store (the #436 / #509 fix).
Structs§
- Discovery
Service - Discovery service that exposes EndpointRegistry over RPC.
- Envelope
Context - Context extracted from a verified SignedEnvelope.
- FsDir
Entry Info - Directory entry returned by list_dir operations.
- Stat
Result - Stat result for backward compatibility with callers using the old API.
Constants§
- DEFAULT_
IOUNIT - Default iounit for 9P read/write operations (64 KiB). This is the maximum bytes per single read/write message. Clients must loop to transfer files larger than this.
- DMDIR
- Directory flag in perm field
- MAX_
FDS_ GLOBAL - MAX_
FDS_ PER_ CLIENT - MAX_
FS_ IO_ SIZE - MAX_
IOUNIT - Maximum allowed iounit (16 MiB). Server will never return an iounit larger than this, regardless of what the client requests.
- ORCLOSE
- Remove on clunk (OR’d with above)
- ORDWR
- Open for read+write
- OREAD
- Open for reading
- OTRUNC
- Truncate on open (OR’d with above)
- OWRITE
- Open for writing
- QTDIR
- Directory
- QTFILE
- Regular file
Traits§
- Request
Service - Trait for RPC services.
Functions§
- discovery_
client_ for_ process - Discovery’s required reach/evidence comes from the checkpoint-backed resolver.
- policy_
client_ for_ process - Construct on the caller’s runtime, using the authenticated process profile.
Type Aliases§
- Continuation
- Work to execute after the RPC response is sent (e.g., stream publishing).