Skip to main content

Module services

Module services 

Source
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_request verifies Ed25519 signatures before dispatching
  • Handlers receive EnvelopeContext with 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 worker::build_authorize_fn;
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-RPC Backend for 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 Mount implementations that proxy to a Cap’n Proto RPC service (nine.capnp envelope).
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 Mount trait to the generated ModelClient RPC.
remote_registry_mount
Remote registry mount — bridges the VFS Mount trait to the registry service’s worktree filesystem via the generated WorktreeClient RPC.
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§

DiscoveryService
Discovery service that exposes EndpointRegistry over RPC.
EnvelopeContext
Context extracted from a verified SignedEnvelope.
FsDirEntryInfo
Directory entry returned by list_dir operations.
StatResult
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§

RequestService
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).