Documentation
¶
Index ¶
- func AdminKeyStreamInterceptor(adminKey *AdminKey) grpc.StreamServerInterceptor
- func AdminKeyUnaryInterceptor(adminKey *AdminKey) grpc.UnaryServerInterceptor
- func LoadPersistedAdminKey(path string) (ed25519.PublicKey, bool, error)
- func SignedDialOptions(privKey ed25519.PrivateKey) []grpc.DialOption
- func SignedStreamInterceptor(privKey ed25519.PrivateKey) grpc.StreamClientInterceptor
- func SignedUnaryInterceptor(privKey ed25519.PrivateKey) grpc.UnaryClientInterceptor
- type AdminKey
- type AllowlistController
- type ChatDispatcher
- type ChatHistoryProvider
- type CommandDispatcher
- type FileDecider
- type HistoryMessage
- type InstallerGate
- type IntroductionDispatcher
- type NodeProvider
- type NonceFlusher
- type PeerConnector
- type PeerDisconnector
- type RemoteCommandSpec
- type RpcDispatcher
- type Server
- func (s *Server) AcceptConnection(_ context.Context, req *apipb.AcceptConnectionRequest) (*apipb.AcceptConnectionResponse, error)
- func (s *Server) AcceptFile(_ context.Context, req *apipb.AcceptFileRequest) (*apipb.AcceptFileResponse, error)
- func (s *Server) AddContact(_ context.Context, req *apipb.AddContactRequest) (*apipb.AddContactResponse, error)
- func (s *Server) AddNode(ctx context.Context, req *apipb.AddNodeRequest) (*apipb.AddNodeResponse, error)
- func (s *Server) AddRegistry(ctx context.Context, req *apipb.AddRegistryRequest) (*apipb.AddRegistryResponse, error)
- func (s *Server) AttachService(stream apipb.EnsembleService_AttachServiceServer) error
- func (s *Server) BrokerLaunch(ctx context.Context, req *apipb.BrokerLaunchRequest) (*apipb.BrokerLaunchResponse, error)
- func (s *Server) CacheRemoteManifest(addr string, handlesCommands bool, version string, specs []RemoteCommandSpec)
- func (s *Server) CallServiceCommand(ctx context.Context, address, name, args string) (string, bool, error)
- func (s *Server) CancelTransfer(_ context.Context, req *apipb.CancelTransferRequest) (*apipb.CancelTransferResponse, error)
- func (s *Server) ClearChatHistory(_ context.Context, req *apipb.ClearChatHistoryRequest) (*apipb.ClearChatHistoryResponse, error)
- func (s *Server) Connect(ctx context.Context, req *apipb.ConnectRequest) (*apipb.ConnectResponse, error)
- func (s *Server) DeleteChatMessage(_ context.Context, req *apipb.DeleteChatMessageRequest) (*apipb.DeleteChatMessageResponse, error)
- func (s *Server) DeleteService(_ context.Context, req *apipb.DeleteServiceRequest) (*apipb.DeleteServiceResponse, error)
- func (s *Server) DeliverCommandResult(commandID, text string, ok bool, _ string)
- func (s *Server) DeliverInboundIntroduction(fromServiceAddr, toAddr, peerAddr, sessionID string, expiresAt int64, ...) bool
- func (s *Server) Disconnect(_ context.Context, req *apipb.DisconnectRequest) (*apipb.DisconnectResponse, error)
- func (s *Server) GetChatHistory(_ context.Context, req *apipb.GetChatHistoryRequest) (*apipb.GetChatHistoryResponse, error)
- func (s *Server) GetDebugInfo(_ context.Context, _ *apipb.GetDebugInfoRequest) (*apipb.GetDebugInfoResponse, error)
- func (s *Server) GetIdentity(_ context.Context, _ *apipb.GetIdentityRequest) (*apipb.GetIdentityResponse, error)
- func (s *Server) GetMetrics(_ context.Context, req *apipb.GetMetricsRequest) (*apipb.GetMetricsResponse, error)
- func (s *Server) GetServiceEnv(ctx context.Context, req *apipb.GetServiceEnvRequest) (*apipb.GetServiceEnvResponse, error)
- func (s *Server) GetStatus(_ context.Context, _ *apipb.GetStatusRequest) (*apipb.GetStatusResponse, error)
- func (s *Server) InstallService(req *apipb.InstallServiceRequest, ...) error
- func (s *Server) ListContacts(_ context.Context, _ *apipb.ListContactsRequest) (*apipb.ListContactsResponse, error)
- func (s *Server) ListInstalledServices(ctx context.Context, req *apipb.ListInstalledServicesRequest) (*apipb.ListInstalledServicesResponse, error)
- func (s *Server) ListPeers(_ context.Context, _ *apipb.ListPeersRequest) (*apipb.ListPeersResponse, error)
- func (s *Server) ListRegistries(ctx context.Context, req *apipb.ListRegistriesRequest) (*apipb.ListRegistriesResponse, error)
- func (s *Server) ListServiceCommands(_ context.Context, req *apipb.ListServiceCommandsRequest) (*apipb.ListServiceCommandsResponse, error)
- func (s *Server) Register(gs *grpc.Server)
- func (s *Server) RegisterService(stream apipb.EnsembleService_RegisterServiceServer) error
- func (s *Server) RejectConnection(_ context.Context, req *apipb.RejectConnectionRequest) (*apipb.RejectConnectionResponse, error)
- func (s *Server) RejectFile(_ context.Context, req *apipb.RejectFileRequest) (*apipb.RejectFileResponse, error)
- func (s *Server) RemoveContact(_ context.Context, req *apipb.RemoveContactRequest) (*apipb.RemoveContactResponse, error)
- func (s *Server) RemoveRegistry(ctx context.Context, req *apipb.RemoveRegistryRequest) (*apipb.RemoveRegistryResponse, error)
- func (s *Server) RollbackService(ctx context.Context, req *apipb.RollbackServiceRequest) (*apipb.RollbackServiceResponse, error)
- func (s *Server) RotateAdminKey(_ context.Context, req *apipb.RotateAdminKeyRequest) (*apipb.RotateAdminKeyResponse, error)
- func (s *Server) SearchRegistries(ctx context.Context, req *apipb.SearchRegistriesRequest) (*apipb.SearchRegistriesResponse, error)
- func (s *Server) SendCommand(req *apipb.SendCommandRequest, stream apipb.EnsembleService_SendCommandServer) error
- func (s *Server) SendFile(req *apipb.SendFileRequest, ...) error
- func (s *Server) SendMessage(ctx context.Context, req *apipb.SendMessageRequest) (*apipb.SendMessageResponse, error)
- func (s *Server) SetAdminKey(ak *AdminKey)
- func (s *Server) SetAllowlistController(a AllowlistController)
- func (s *Server) SetChatDispatcher(d ChatDispatcher)
- func (s *Server) SetChatHistory(h ChatHistoryProvider)
- func (s *Server) SetCommandDispatcher(d CommandDispatcher)
- func (s *Server) SetFileDecider(d FileDecider)
- func (s *Server) SetInstaller(g InstallerGate)
- func (s *Server) SetIntroductionDispatcher(d IntroductionDispatcher)
- func (s *Server) SetMetrics(reg *metrics.Registry)
- func (s *Server) SetPeerConnector(p PeerConnector)
- func (s *Server) SetPeerDisconnector(p PeerDisconnector)
- func (s *Server) SetRegistry(r *services.Registry)
- func (s *Server) SetRegistryManager(m *registry.Manager)
- func (s *Server) SetRpcDispatcher(d RpcDispatcher)
- func (s *Server) SetSeedNodes(seeds []string)
- func (s *Server) SetServiceEnv(ctx context.Context, req *apipb.SetServiceEnvRequest) (*apipb.SetServiceEnvResponse, error)
- func (s *Server) SetSupervisorGate(g SupervisorGate)
- func (s *Server) StartInstalledService(ctx context.Context, req *apipb.StartInstalledServiceRequest) (*apipb.StartInstalledServiceResponse, error)
- func (s *Server) StopInstalledService(ctx context.Context, req *apipb.StopInstalledServiceRequest) (*apipb.StopInstalledServiceResponse, error)
- func (s *Server) StreamCommand(ctx context.Context, req *apipb.SendCommandRequest, ...) error
- func (s *Server) StreamMetrics(req *apipb.StreamMetricsRequest, ...) error
- func (s *Server) StreamServiceLogs(req *apipb.StreamServiceLogsRequest, ...) error
- func (s *Server) Subscribe(_ *apipb.SubscribeRequest, ...) error
- func (s *Server) UninstallService(ctx context.Context, req *apipb.UninstallServiceRequest) (*apipb.UninstallServiceResponse, error)
- func (s *Server) UpgradeService(req *apipb.UpgradeServiceRequest, ...) error
- func (s *Server) VerifyBinding(_ context.Context, req *apipb.VerifyBindingRequest) (*apipb.VerifyBindingResponse, error)
- type SpawnTokenChecker
- type SupervisorGate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdminKeyStreamInterceptor ¶
func AdminKeyStreamInterceptor(adminKey *AdminKey) grpc.StreamServerInterceptor
AdminKeyStreamInterceptor returns a gRPC stream interceptor that verifies streams are signed by the given admin Ed25519 public key. The signature binds the RPC method + timestamp + nonce; per-message body binding is out of scope for streaming RPCs (a future change can add per-message signing if needed). The nonce cache still prevents replay.
SECURITY: because only stream-open is authenticated, the integrity of individual stream messages depends on the transport being confidential and tamper-proof. The daemon serves gRPC as cleartext h2c, so off-loopback exposure requires a trusted TLS terminator in front — the daemon refuses a non-loopback gRPC bind unless the operator asserts one via --trust-proxy-tls (see daemon.validateTransportSecurity, ticket 7c36c17d). Over loopback / the Unix socket there is no on-path attacker, so stream-open auth suffices.
func AdminKeyUnaryInterceptor ¶
func AdminKeyUnaryInterceptor(adminKey *AdminKey) grpc.UnaryServerInterceptor
func LoadPersistedAdminKey ¶
LoadPersistedAdminKey reads a previously-rotated admin pubkey from path. Returns (nil, false, nil) when the file does not exist (the bootstrap flag should be used in that case). Returns (nil, false, err) for any other error so the caller can decide whether to fail closed.
func SignedDialOptions ¶
func SignedDialOptions(privKey ed25519.PrivateKey) []grpc.DialOption
SignedDialOptions returns the gRPC DialOptions required to authenticate outgoing RPCs with the given Ed25519 private key. Convenience helper for callers that build grpc.NewClient invocations.
func SignedStreamInterceptor ¶
func SignedStreamInterceptor(privKey ed25519.PrivateKey) grpc.StreamClientInterceptor
SignedStreamInterceptor returns a grpc.StreamClientInterceptor that signs each new stream with (method | timestamp | nonce). Streaming RPCs do not bind the request body — the body is produced per-message and not available at stream-creation time.
func SignedUnaryInterceptor ¶
func SignedUnaryInterceptor(privKey ed25519.PrivateKey) grpc.UnaryClientInterceptor
SignedUnaryInterceptor returns a grpc.UnaryClientInterceptor that signs each outgoing RPC with (method | timestamp | nonce | sha256(request)). Pair with SignedStreamInterceptor for streaming RPCs.
Types ¶
type AdminKey ¶
type AdminKey struct {
// contains filtered or unexported fields
}
AdminKey holds the daemon's currently-trusted admin Ed25519 public key and supports atomic rotation. The auth interceptors read the current value on every request via Current(), so a Rotate() call takes effect immediately for all subsequent RPCs. If a persistence path is set, Rotate() atomically writes the new pubkey to disk so the rotation survives daemon restart. W3 #627b4e12.
func NewAdminKey ¶
NewAdminKey wraps an Ed25519 public key in an AdminKey. If persistPath is non-empty, Rotate() writes the new pubkey there atomically (tmp + rename). Pass persistPath="" for tests / static-key fixtures that don't need persistence.
func (*AdminKey) Rotate ¶
Rotate swaps the trusted pubkey to newPub and (if a persistence path is configured) writes it to disk atomically before the in-memory swap. The disk write goes first so a crash mid-rotate leaves the in-memory key unchanged AND the next boot reads the value we successfully wrote.
type AllowlistController ¶
type AllowlistController interface {
UpdateAllowlist(fromService string, add, remove []string) error
}
AllowlistController is the seam through which a registered service mutates its live ACL_ALLOWLIST at runtime so a membership change takes effect without re-registering (ADR-0007 §5). Only meaningful for an allowlist-gated service using the built-in default-deny gate; the daemon rejects the update for a decides_connections service (it runs its own policy) or a non-allowlist tier. Pairs with PeerDisconnector: revoke an address, then drop its live connection, to fully evict a member. Authorization is stream ownership, like the above.
type ChatDispatcher ¶
type ChatDispatcher interface {
Send(ctx context.Context, fromService, toAddr, text string) (string, error)
}
ChatDispatcher is the seam through which a registered service's outbound chat goes. The daemon supplies an implementation that translates a service name + recipient address + text into the chat service's send pipeline.
v0 scope: the implementation may dispatch using the daemon's primary chat service (i.e. messages travel under the node's identity, not the registered service's). External services see a working SendMessage but the on-wire "from" address is the node's. T05 / future tickets are expected to wire a per-service chat path so messages travel under the registered service's identity.
type ChatHistoryProvider ¶
type ChatHistoryProvider interface {
GetLatest(peerAddr string, n int) []HistoryMessage
// Delete removes one message by id from a peer's conversation, returning
// false if no such message exists. Clear wipes a whole conversation. Both
// persist (the daemon's *chat.History writes through to disk).
Delete(peerAddr, messageID string) bool
Clear(peerAddr string)
}
ChatHistoryProvider is the narrow seam the gRPC server uses to read and mutate stored chat messages. *chat.History satisfies this via a thin adapter wired in the daemon. Left optional so test harnesses can omit it; GetChatHistory returns an empty response and the delete/clear handlers return FailedPrecondition when it's not set.
type CommandDispatcher ¶
type CommandDispatcher interface {
SendCommand(ctx context.Context, toAddr, commandID, name, args string) error
}
CommandDispatcher is the outbound seam for invoking a command on a service hosted by a DIFFERENT daemon (E3 cross-node). The daemon supplies an implementation that signs a COMMAND envelope under the NODE's identity (not a service's — the operator's node invokes; the host daemon dispatches to its own local service) and writes it to the target peer. It is fire-and-forget: the reply returns asynchronously as a COMMAND_RESULT and is correlated by commandID via DeliverCommandResult. The local-delivery fast path (target is a service registered on this same daemon) bypasses this entirely.
type FileDecider ¶
type FileDecider interface {
AcceptFile(transferID string) error
RejectFile(transferID, reason string) error
}
FileDecider is the seam through which a registered file-handling service's accept/reject decision reaches the filetransfer receiver. The daemon supplies an implementation backed by the receiver's parked-offer decision channels (keyed by transfer_id). AcceptFile always saves into the daemon's configured receive directory — there is deliberately no client-supplied path, because a client-chosen daemon-host path would be a write-anywhere escalation surface.
type HistoryMessage ¶
type HistoryMessage struct {
ID string
From string
To string
Text string
SentAt int64 // unix millis
AckedAt int64 // unix millis; 0 = not acked
Direction string
}
HistoryMessage is the daemon-internal chat message in transport-agnostic form. Decoupled from internal/chat.Message so internal/api doesn't import the chat package (would create a cycle via the existing dispatcher path).
type InstallerGate ¶
type InstallerGate interface {
Install(ctx context.Context, spec apps.SourceSpec, opt apps.InstallOptions, pf apps.ProgressFunc) (*apps.InstallRecord, error)
Upgrade(ctx context.Context, name string, spec apps.SourceSpec, opt apps.InstallOptions, pf apps.ProgressFunc) (*apps.InstallRecord, error)
Uninstall(name string, keepData bool) error
Rollback(name string) (*apps.InstallRecord, error)
Records() ([]*apps.InstallRecord, error)
}
InstallerGate is the api-side seam onto the installer engine (internal/apps.Installer satisfies it). nil on daemons without one.
type IntroductionDispatcher ¶
type IntroductionDispatcher interface {
SendIntroduction(ctx context.Context, fromService, toAddr, peerAddr, sessionID string, expiresAt int64, roleHint string, payload []byte) error
}
IntroductionDispatcher is the outbound seam for peer introductions whose target is on a different daemon (T2). The daemon supplies an implementation that signs a SERVICE_INTRODUCTION envelope under the originating service's keypair and writes it over the libp2p link to the target peer.
The local-delivery fast path (target is a registered service on this same daemon) bypasses this entirely and goes straight to the target bidi stream.
type NodeProvider ¶
type NodeProvider interface {
Identity() *identity.Identity
Address() identity.Address
EventBus() *node.EventBus
TorState() string
LastTorError() string
OnionAddr() string
Connect(ctx context.Context, peerAddr string) (*signaling.HandshakeResult, error)
AcceptConnection(addr string) error
RejectConnection(addr string, reason string) error
PeerCount() int32
RTSize() int
GetDebugInfo() *node.DebugInfo
ListPeers() []node.PeerEntry
Disconnect(addr string)
Contacts() *contacts.Store
ConnectionInfo(addr string) *transport.PeerConnection
ActiveConnections() []*transport.PeerConnection
SendMessage(ctx context.Context, addr, text string) (string, error)
SendFile(ctx context.Context, peerAddr, filePath string) (string, error)
AcceptFile(transferID, savePath string) error
RejectFile(transferID, reason string) error
CancelFile(transferID string) error
AddNode(ctx context.Context, onionAddr string) (int, error)
}
NodeProvider is the minimal interface the gRPC server needs from the node. Methods are added as subsystems are wired in.
type NonceFlusher ¶
type NonceFlusher interface {
Flush()
}
NonceFlusher persists any in-memory nonce state to disk on demand. The daemon holds the value returned by AdminAuthInterceptors and calls Flush at shutdown so nonces accepted inside the debounce window survive a graceful restart (W3 #10f31a8a). Flush is a no-op when the cache is in-memory.
func AdminAuthInterceptors ¶
func AdminAuthInterceptors(adminKey *AdminKey, noncePath string, spawnTokens SpawnTokenChecker) (grpc.UnaryServerInterceptor, grpc.StreamServerInterceptor, NonceFlusher)
AdminAuthInterceptors builds the unary + stream admin interceptors sharing a single nonce cache, and returns a NonceFlusher the caller must Flush at shutdown. When noncePath is non-empty the cache is persisted there so replay protection survives a daemon restart (W3 #097b5d90); pass "" for an in-memory cache. The daemon uses this; the bare AdminKey*Interceptor constructors keep an in-memory cache for tests.
Sharing one cache between the unary and stream paths is safe: the signed digest binds the RPC method, so a nonce captured from a unary call can't be replayed as a stream open (or vice versa) regardless of which path's cache would catch it.
The returned NonceFlusher closes the debounce gap: persistence is debounced during normal operation (one disk write per flushPeriod, not per request), so a nonce accepted between flushes is memory-only until the daemon calls Flush() on graceful shutdown.
type PeerConnector ¶
type PeerConnector interface {
ConnectPeerAs(ctx context.Context, fromService, peerAddr string) error
}
PeerConnector is the outbound seam for service-identity dials (5fb8deb1). The daemon supplies an implementation that opens a connection to peerAddr signing the signaling handshake with the named service's keypair (held in the keystore; never exposed to the client). The responder's gate therefore sees the service address as CONN_REQUEST.FromAddress — matching what a SERVICE_INTRODUCTION named — instead of the dialing daemon's node address.
fromService is the registry name of the service that owns the calling RegisterService stream; the daemon resolves it to that service's keypair. Authorization is stream ownership: a client cannot name a service it does not own (the action handler always passes the stream's own serviceName).
type PeerDisconnector ¶
PeerDisconnector is the seam through which a registered service CLOSES an already-established connection to a peer — the admin "kick" (ADR-0007 §5). reject (pendingRequestStore) decides a connection before accept; this drops a peer that already completed the handshake (e.g. one removed from an allowlist room mid-session). The daemon closes every transport path to the peer address.
fromService is the registry name of the stream's own service; the api layer always passes the stream's serviceName, so authorization is stream ownership (a client cannot kick on behalf of a service it does not own), exactly like ConnectPeerAs.
type RemoteCommandSpec ¶
RemoteCommandSpec is one untrusted command spec from a remote service's pushed manifest. Kept neutral (no protocol-pb types) so the daemon bridges the wire type to this and the api layer owns sanitisation. Field names mirror apipb.CommandSpec.
type RpcDispatcher ¶
type RpcDispatcher interface {
SendRpc(ctx context.Context, fromService, toAddr string, payload []byte) error
}
RpcDispatcher is the outbound seam for SERVICE_TRANSPORT_RPC services. The daemon supplies an implementation that opens a libp2p stream to the named peer and writes a SERVICE_RPC envelope signed by the registered service's identity. Returning an error surfaces a ServiceError to the gRPC client.
type Server ¶
type Server struct {
apipb.UnimplementedEnsembleServiceServer
// contains filtered or unexported fields
}
Server implements the EnsembleService gRPC interface.
func NewServer ¶
func NewServer(n NodeProvider) *Server
NewServer creates a gRPC server backed by the given node. The registry and chat dispatcher are optional; if either is nil, RegisterService returns Unimplemented (the registry case) or surfaces ServiceError on SendMessage (the dispatcher case). The daemon wires both once Tor is ready.
func (*Server) AcceptConnection ¶
func (s *Server) AcceptConnection(_ context.Context, req *apipb.AcceptConnectionRequest) (*apipb.AcceptConnectionResponse, error)
func (*Server) AcceptFile ¶
func (s *Server) AcceptFile(_ context.Context, req *apipb.AcceptFileRequest) (*apipb.AcceptFileResponse, error)
func (*Server) AddContact ¶
func (s *Server) AddContact(_ context.Context, req *apipb.AddContactRequest) (*apipb.AddContactResponse, error)
func (*Server) AddNode ¶
func (s *Server) AddNode(ctx context.Context, req *apipb.AddNodeRequest) (*apipb.AddNodeResponse, error)
func (*Server) AddRegistry ¶
func (s *Server) AddRegistry(ctx context.Context, req *apipb.AddRegistryRequest) (*apipb.AddRegistryResponse, error)
AddRegistry subscribes this node to a registry by E-address. The fetch must verify before anything persists — a subscription that never served a signed index is a typo, not state.
func (*Server) AttachService ¶
func (s *Server) AttachService(stream apipb.EnsembleService_AttachServiceServer) error
AttachService implements the launched-client relay (ADR-0011 §5). The first client message must be ServiceAttachStart; the launch grant rides in x-service-token metadata. The daemon validates the grant, resolves the one backend it authorises, binds this stream as an operator of that backend, and then relays payloads both ways. Closing this stream detaches without tearing the backend down.
func (*Server) BrokerLaunch ¶
func (s *Server) BrokerLaunch(ctx context.Context, req *apipb.BrokerLaunchRequest) (*apipb.BrokerLaunchResponse, error)
BrokerLaunch resolves an installed service's launched client (ADR-0010 §3 / ADR-0011) and returns the spec the app needs to exec it: the absolute argv, the ENSEMBLE_* env contract, and a working dir. The daemon mints a scoped launch grant only when the client is launchable; a missing declared runtime is a ready=false response (with the reason), not an RPC error — the app shows it rather than failing. "this service has no launched client" IS an error: the app should only call this for a launched_client service.
func (*Server) CacheRemoteManifest ¶
func (s *Server) CacheRemoteManifest(addr string, handlesCommands bool, version string, specs []RemoteCommandSpec)
CacheRemoteManifest stores a remote service's capability manifest keyed by its address, for remote /-autocomplete (and, in ticket 4b, the cross-node send-gate). The input is UNTRUSTED: command names that aren't slug-valid are dropped, descriptions/usages are length-bounded, and the set is capped at services.MaxCommandsPerService — the same rules a LOCAL manifest passes at registration. A manifest that sanitises to nothing clears any cached entry, so a service that drops its commands stops advertising them on the next connect.
The cache is authoritative for UI affordance only; the host node stays the final execution authority (the authority rule). It is refreshed on every (re)connect, so staleness self-heals — version is advisory.
func (*Server) CallServiceCommand ¶
func (s *Server) CallServiceCommand(ctx context.Context, address, name, args string) (string, bool, error)
CallServiceCommand invokes ONE command on a service (by E-address) and returns its reply — the daemon-internal twin of StreamCommand's service leg, with no built-in dispatch and no streaming. This is how daemon subsystems talk to remote services: the registry manager fetches signed indices over it (ADR-0009 §7).
Local services are dispatched directly. Remote ones get a connection ensured first (Connector.Connect is idempotent and single-flight — a live pooled connection returns immediately) and then the COMMAND envelope flow with its correlated result. Satisfies registry.CommandCaller.
func (*Server) CancelTransfer ¶
func (s *Server) CancelTransfer(_ context.Context, req *apipb.CancelTransferRequest) (*apipb.CancelTransferResponse, error)
func (*Server) ClearChatHistory ¶
func (s *Server) ClearChatHistory(_ context.Context, req *apipb.ClearChatHistoryRequest) (*apipb.ClearChatHistoryResponse, error)
func (*Server) Connect ¶
func (s *Server) Connect(ctx context.Context, req *apipb.ConnectRequest) (*apipb.ConnectResponse, error)
func (*Server) DeleteChatMessage ¶
func (s *Server) DeleteChatMessage(_ context.Context, req *apipb.DeleteChatMessageRequest) (*apipb.DeleteChatMessageResponse, error)
func (*Server) DeleteService ¶
func (s *Server) DeleteService(_ context.Context, req *apipb.DeleteServiceRequest) (*apipb.DeleteServiceResponse, error)
DeleteService rotates a previously-registered service's identity (bumps its rotation generation + wipes the bundle) so re-registering the name derives a genuinely fresh keypair, address, and onion — the recovery path after a suspected service-key compromise. Refuses reserved names and live services. W3 #a137ce40 / 7a9b8f66.
func (*Server) DeliverCommandResult ¶
DeliverCommandResult correlates an inbound COMMAND_RESULT (a reply to a cross-node command this node invoked) back to its parked SendCommand call. It satisfies the daemon's command-result sink: the rpc layer attributes the sender and hands the verified (command_id, text, ok) here. An unknown id (late reply after a timeout, or a duplicate) is dropped. fromAddr is the attributed host node; carried for parity/forward use, not required to match.
func (*Server) DeliverInboundIntroduction ¶
func (s *Server) DeliverInboundIntroduction(fromServiceAddr, toAddr, peerAddr, sessionID string, expiresAt int64, roleHint string, payload []byte) bool
DeliverInboundIntroduction routes a peer-introduction that arrived from a remote daemon (surfaced by the rpc.Service introduction sink) onto the target service's bidi stream — the same delivery shape as deliverIntroduction's local fast path. Returns true iff a registered service stream for toAddr existed and the event was enqueued; the caller falls back to other surfaces (the EventBus) when it returns false.
fromServiceAddr is the daemon-attested originating service address (derived by rpc.Service from the inbound envelope signature) — not a sender-supplied claim. This closes the asymmetry where same-daemon introductions reached the service stream but cross-daemon ones only reached the daemon-wide EventBus, which service-registered clients (e.g. PUG players) don't consume.
func (*Server) Disconnect ¶
func (s *Server) Disconnect(_ context.Context, req *apipb.DisconnectRequest) (*apipb.DisconnectResponse, error)
func (*Server) GetChatHistory ¶
func (s *Server) GetChatHistory(_ context.Context, req *apipb.GetChatHistoryRequest) (*apipb.GetChatHistoryResponse, error)
func (*Server) GetDebugInfo ¶
func (s *Server) GetDebugInfo(_ context.Context, _ *apipb.GetDebugInfoRequest) (*apipb.GetDebugInfoResponse, error)
func (*Server) GetIdentity ¶
func (s *Server) GetIdentity(_ context.Context, _ *apipb.GetIdentityRequest) (*apipb.GetIdentityResponse, error)
GetIdentity returns the node's address and public key.
func (*Server) GetMetrics ¶
func (s *Server) GetMetrics(_ context.Context, req *apipb.GetMetricsRequest) (*apipb.GetMetricsResponse, error)
GetMetrics returns a one-shot snapshot of the metrics registry for the dashboard's initial paint. Reads are admin-auth'd by the server-wide interceptors like every other RPC.
func (*Server) GetServiceEnv ¶
func (s *Server) GetServiceEnv(ctx context.Context, req *apipb.GetServiceEnvRequest) (*apipb.GetServiceEnvResponse, error)
GetServiceEnv lists the key names of a service's operator env overlay. Values are never returned (the overlay carries secrets).
func (*Server) GetStatus ¶
func (s *Server) GetStatus(_ context.Context, _ *apipb.GetStatusRequest) (*apipb.GetStatusResponse, error)
GetStatus returns the node's current status.
func (*Server) InstallService ¶
func (s *Server) InstallService(req *apipb.InstallServiceRequest, stream grpc.ServerStreamingServer[apipb.InstallProgress]) error
InstallService fetches, verifies, and installs a new service, streaming progress. On success the supervisor picks it up immediately.
func (*Server) ListContacts ¶
func (s *Server) ListContacts(_ context.Context, _ *apipb.ListContactsRequest) (*apipb.ListContactsResponse, error)
func (*Server) ListInstalledServices ¶
func (s *Server) ListInstalledServices(ctx context.Context, req *apipb.ListInstalledServicesRequest) (*apipb.ListInstalledServicesResponse, error)
ListInstalledServices reports every installed service: provenance from install.yaml merged with the supervisor's live state. check_updates additionally compares registry-installed services against the subscribed indices (one best-effort refresh, then cache reads) — surfacing only, never auto-upgrading (ADR-0009 non-goals).
func (*Server) ListPeers ¶
func (s *Server) ListPeers(_ context.Context, _ *apipb.ListPeersRequest) (*apipb.ListPeersResponse, error)
func (*Server) ListRegistries ¶
func (s *Server) ListRegistries(ctx context.Context, req *apipb.ListRegistriesRequest) (*apipb.ListRegistriesResponse, error)
ListRegistries reports every subscription, optionally refreshing first.
func (*Server) ListServiceCommands ¶
func (s *Server) ListServiceCommands(_ context.Context, req *apipb.ListServiceCommandsRequest) (*apipb.ListServiceCommandsResponse, error)
ListServiceCommands returns the commands available for a conversation: daemon built-ins unioned with the service's declared commands, deduped (E1 discovery RPC, implemented here in E4 because the response folds in built-ins). Clients (TUI/web) call this on opening a conversation to drive /-autocomplete. A remote service's declared set isn't visible locally, so the response carries built-ins only for a non-local address — the same deduped shape, just without the service-declared tail.
func (*Server) RegisterService ¶
func (s *Server) RegisterService(stream apipb.EnsembleService_RegisterServiceServer) error
RegisterService implements the bidirectional RegisterService RPC. The first client message must be a manifest; subsequent messages are actions (SendMessage / Accept / Reject). The server streams ServiceEvent messages for inbound chat / connection-request events, plus ServiceError for recoverable handler-side errors.
On stream close (client disconnect, network error, ctx cancel), the service is unregistered. The keypair is retained in the keystore so a reconnect under the same name yields the same address.
func (*Server) RejectConnection ¶
func (s *Server) RejectConnection(_ context.Context, req *apipb.RejectConnectionRequest) (*apipb.RejectConnectionResponse, error)
func (*Server) RejectFile ¶
func (s *Server) RejectFile(_ context.Context, req *apipb.RejectFileRequest) (*apipb.RejectFileResponse, error)
func (*Server) RemoveContact ¶
func (s *Server) RemoveContact(_ context.Context, req *apipb.RemoveContactRequest) (*apipb.RemoveContactResponse, error)
func (*Server) RemoveRegistry ¶
func (s *Server) RemoveRegistry(ctx context.Context, req *apipb.RemoveRegistryRequest) (*apipb.RemoveRegistryResponse, error)
RemoveRegistry drops a subscription and its cached index.
func (*Server) RollbackService ¶
func (s *Server) RollbackService(ctx context.Context, req *apipb.RollbackServiceRequest) (*apipb.RollbackServiceResponse, error)
RollbackService flips an installed service to its previous release and restarts it if it was enabled.
func (*Server) RotateAdminKey ¶
func (s *Server) RotateAdminKey(_ context.Context, req *apipb.RotateAdminKeyRequest) (*apipb.RotateAdminKeyResponse, error)
RotateAdminKey swaps the daemon's trusted admin Ed25519 public key with the caller-supplied one. The request itself has already been verified under the *old* key by AdminKeyUnaryInterceptor by the time this runs, so this handler only enforces shape: pubkey length and atomic persistence. The auth interceptors read the new key on the next request via AdminKey.Current(). W3 #627b4e12.
func (*Server) SearchRegistries ¶
func (s *Server) SearchRegistries(ctx context.Context, req *apipb.SearchRegistriesRequest) (*apipb.SearchRegistriesResponse, error)
SearchRegistries queries the cached (verified) indices of every subscription, merging in locally installed versions.
func (*Server) SendCommand ¶
func (s *Server) SendCommand(req *apipb.SendCommandRequest, stream apipb.EnsembleService_SendCommandServer) error
SendCommand is the gRPC server-streaming entry point: it runs the augment dispatch and streams each reply leg to the caller. The transport-agnostic core is StreamCommand, shared with the in-process DirectBackend so the embedded TUI gets the same streamed legs without a gRPC loopback.
func (*Server) SendFile ¶
func (s *Server) SendFile(req *apipb.SendFileRequest, stream grpc.ServerStreamingServer[apipb.TransferProgress]) error
func (*Server) SendMessage ¶
func (s *Server) SendMessage(ctx context.Context, req *apipb.SendMessageRequest) (*apipb.SendMessageResponse, error)
func (*Server) SetAdminKey ¶
SetAdminKey attaches the daemon's admin-key holder so the RotateAdminKey RPC has something to mutate. Pass nil to leave admin rotation disabled (handler returns FailedPrecondition). W3 #627b4e12.
func (*Server) SetAllowlistController ¶
func (s *Server) SetAllowlistController(a AllowlistController)
SetAllowlistController attaches the seam through which a registered service mutates its live ACL_ALLOWLIST at runtime (ServiceUpdateAllowlist, ADR-0007 §5). May be called once after construction. If unset, an update_allowlist action surfaces a ServiceError.
func (*Server) SetChatDispatcher ¶
func (s *Server) SetChatDispatcher(d ChatDispatcher)
SetChatDispatcher attaches the seam through which a registered service's outbound chat is routed. May be called once after construction.
func (*Server) SetChatHistory ¶
func (s *Server) SetChatHistory(h ChatHistoryProvider)
SetChatHistory attaches the read-only seam GetChatHistory uses.
func (*Server) SetCommandDispatcher ¶
func (s *Server) SetCommandDispatcher(d CommandDispatcher)
SetCommandDispatcher attaches the outbound seam for invoking a command on a service hosted by another daemon (E3 cross-node). May be called once after construction; the daemon wires this once the rpc service is up. If unset, a non-local SendCommand target returns Unimplemented (the local fast-path is unaffected).
func (*Server) SetFileDecider ¶
func (s *Server) SetFileDecider(d FileDecider)
SetFileDecider attaches the seam through which a registered file-handling service's accept_file/reject_file decisions reach the filetransfer receiver. Pass nil to leave file handling unavailable (accept_file/reject_file then surface a ServiceError). The daemon wires this when the receiver exists.
func (*Server) SetInstaller ¶
func (s *Server) SetInstaller(g InstallerGate)
SetInstaller wires the installer engine.
func (*Server) SetIntroductionDispatcher ¶
func (s *Server) SetIntroductionDispatcher(d IntroductionDispatcher)
SetIntroductionDispatcher attaches the outbound seam for cross-daemon peer introductions (T2). May be called once after construction. If unset, IntroducePeer falls back to local-only delivery (works for the integration tests; production paths need the libp2p dispatcher wired in).
func (*Server) SetMetrics ¶
SetMetrics attaches the daemon's metrics registry. Optional: when never called (or called with nil), GetMetrics/StreamMetrics report enabled=false with no data — same as a daemon running without --metrics.
func (*Server) SetPeerConnector ¶
func (s *Server) SetPeerConnector(p PeerConnector)
SetPeerConnector attaches the seam through which a registered service dials a peer under its OWN service identity (5fb8deb1). May be called once after construction; the daemon wires this once the transport.Connector is up. If unset, a service's ServiceConnectPeer action surfaces a ServiceError.
func (*Server) SetPeerDisconnector ¶
func (s *Server) SetPeerDisconnector(p PeerDisconnector)
SetPeerDisconnector attaches the seam through which a registered service kicks an established peer (ServiceDisconnectPeer, ADR-0007 §5). May be called once after construction. If unset, a disconnect_peer action surfaces a ServiceError.
func (*Server) SetRegistry ¶
SetRegistry attaches the service registry that RegisterService dispatches against. May be called once after construction; the daemon does this when the registry is created post-Tor-bootstrap.
func (*Server) SetRegistryManager ¶
SetRegistryManager wires the registry subscription manager (ADR-0009 §7). nil on daemons without one.
func (*Server) SetRpcDispatcher ¶
func (s *Server) SetRpcDispatcher(d RpcDispatcher)
SetRpcDispatcher attaches the outbound seam for SERVICE_TRANSPORT_RPC services. May be called once after construction; the daemon wires this once the transport.Host is up. If unset, services with TransportRPC that try to send bytes get a ServiceError back.
func (*Server) SetSeedNodes ¶
SetSeedNodes records the bootstrap-seed onion list for GetDebugInfo.
func (*Server) SetServiceEnv ¶
func (s *Server) SetServiceEnv(ctx context.Context, req *apipb.SetServiceEnvRequest) (*apipb.SetServiceEnvResponse, error)
SetServiceEnv attaches/updates a service's operator env overlay (ADR-0009 §11) and applies it (restarting a running child). Values are write-only: the response carries only the resulting key names.
func (*Server) SetSupervisorGate ¶
func (s *Server) SetSupervisorGate(g SupervisorGate)
SetSupervisorGate wires the installed-service supervisor. Call at daemon wiring time, before the gRPC server starts serving.
func (*Server) StartInstalledService ¶
func (s *Server) StartInstalledService(ctx context.Context, req *apipb.StartInstalledServiceRequest) (*apipb.StartInstalledServiceResponse, error)
StartInstalledService enables + spawns an installed service.
func (*Server) StopInstalledService ¶
func (s *Server) StopInstalledService(ctx context.Context, req *apipb.StopInstalledServiceRequest) (*apipb.StopInstalledServiceResponse, error)
StopInstalledService stops a service and persists the disabled intent.
func (*Server) StreamCommand ¶
func (s *Server) StreamCommand(ctx context.Context, req *apipb.SendCommandRequest, emit func(*apipb.SendCommandResponse) error) error
StreamCommand invokes a command for a conversation and STREAMS each reply leg to emit (E3 routing + E4 built-ins / augment dispatch). See the RPC doc in ensemble.proto.
Dispatch is AUGMENT, not override: an invoked name may be handled by a daemon built-in (/help /whoami /services /clear), by the active service (req.Address) that declares it, or by BOTH — every matching leg runs and is streamed as its own message. A service can only ADD behaviour to a shared name; the built-in always runs and can never be suppressed (so /help always returns real help, /clear always clears the local transcript). Scope is the built-in plus the one service the operator is talking to — never a broadcast.
The built-in leg is emitted FIRST and immediately (local, instant). The service leg follows when it resolves — a local fast-path, or a cross-node wire invocation whose correlated result streams in when it lands (or a daemon- rendered timeout leg). Streaming means a slow/cross-node service leg never hangs the operator: the instant built-in line is already on screen.
Direction stays safe: the built-in leg acts purely on local node state, and the service leg is an outbound invocation (operator→service, local fast-path or cross-node wire). Nothing remote runs a command on this node.
A name nothing handles is streamed as a single daemon-rendered "unknown command" leg. A non-local target with no command dispatcher wired is an explicit Unimplemented error (only when no built-in already streamed) rather than a hang. emit errors (e.g. the caller's stream broke) abort the dispatch.
func (*Server) StreamMetrics ¶
func (s *Server) StreamMetrics(req *apipb.StreamMetricsRequest, stream apipb.EnsembleService_StreamMetricsServer) error
StreamMetrics is the live feed: a SERVER stream (the gRPC-Web bridge runs without WebSockets, so bidi never reaches the browser — dfb84d1f). The first update carries full state; each later tick sends only descriptors not yet announced and points newer than the previous tick, omitting series with nothing new.
func (*Server) StreamServiceLogs ¶
func (s *Server) StreamServiceLogs(req *apipb.StreamServiceLogsRequest, stream grpc.ServerStreamingServer[apipb.ServiceLogLine]) error
StreamServiceLogs streams a supervised service's captured stdout/stderr: tail first, then (follow=true) live lines until the client hangs up.
func (*Server) Subscribe ¶
func (s *Server) Subscribe(_ *apipb.SubscribeRequest, stream grpc.ServerStreamingServer[apipb.DaemonEvent]) error
Subscribe streams events from the event bus to the gRPC client.
func (*Server) UninstallService ¶
func (s *Server) UninstallService(ctx context.Context, req *apipb.UninstallServiceRequest) (*apipb.UninstallServiceResponse, error)
UninstallService stops a service, removes its files, and optionally purges its identity (RotateBundle — fresh keys on reinstall).
func (*Server) UpgradeService ¶
func (s *Server) UpgradeService(req *apipb.UpgradeServiceRequest, stream grpc.ServerStreamingServer[apipb.InstallProgress]) error
UpgradeService swaps an installed service to a new artifact (identity and data/ kept), streaming progress. Restart goes through the supervisor.
func (*Server) VerifyBinding ¶
func (s *Server) VerifyBinding(_ context.Context, req *apipb.VerifyBindingRequest) (*apipb.VerifyBindingResponse, error)
VerifyBinding verifies a caller-supplied IdentityBinding against a claimed E-address and, on success, returns the bound ed25519 operational key so the caller can verify that identity's per-message signatures locally (cheap native ed25519, no further round-trip). It exists because the ML-DSA-65 verify + canonical binding-bytes format is the one part of "verifiable authorship" a non-Go SDK can't cheaply re-derive — keeping the Go implementation the single source of truth.
It is a pure function of the request: no node state, no secrets. A failed check is a normal "no" (ok=false + a diagnostic reason), NOT a gRPC error — malformed or mismatched inputs are exactly what the caller asked us to detect. Authentication is the socketKeylessMethods carve-out (keyless over the 0600 Unix socket); see auth.go.
type SpawnTokenChecker ¶
SpawnTokenChecker reports whether a presented spawn token is currently valid for some daemon-supervised child (internal/apps.Supervisor implements it). Supervised services cannot produce admin signatures — neither SDK can sign — so on an admin-keyed daemon their RegisterService is admitted by the per-spawn token instead (ADR-0009 §5). The token only opens the RegisterService method; name-binding and the capability ceiling are enforced in the handler via SupervisorGate.AuthorizeRegister.
type SupervisorGate ¶
type SupervisorGate interface {
// AuthorizeRegister gates RegisterService for supervised names: spawn-token
// binding + the install-time capability ceiling (ADR-0009 §2/§5).
// Unsupervised names return nil.
AuthorizeRegister(name, token string, m services.Manifest) error
// NotifyRegistered / NotifyUnregistered are the readiness and liveness
// signals: RegisterService completed / the register stream tore down.
NotifyRegistered(name string)
NotifyUnregistered(name string)
// Statuses snapshots every installed service for GetDebugInfo.
Statuses() []apps.Status
// TailLogs / FollowLogs back StreamServiceLogs.
TailLogs(name string, n int) ([]apps.LogLine, error)
FollowLogs(name string) (<-chan apps.LogLine, func(), error)
// StartService / StopService flip and persist operator intent; Refresh
// re-scans the install tree (the installer calls it after mutations).
StartService(name string) error
StopService(name string) error
Refresh()
// BrokerLaunch resolves a service's launched client into the spec the app
// needs to exec it — abs argv, env contract, working dir — minting a scoped
// launch grant when ready (ADR-0010 §3 / ADR-0011). A missing runtime is a
// not-ready spec, not an error.
BrokerLaunch(name string) (apps.LaunchSpec, error)
// LookupLaunchGrant resolves a launch grant token to the one service it
// authorises attaching to (ADR-0011 §5), or ("", false) when unknown/expired.
// AttachService calls this to bind a launched frontend to its backend.
LookupLaunchGrant(token string) (string, bool)
// SetEnv / GetEnv manage a service's operator env overlay (ADR-0009 §11).
// SetEnv returns the resulting key names (never values) and whether the
// change restarted a running child; GetEnv returns just the key names.
SetEnv(name string, set map[string]string, unset []string, replace bool) ([]string, bool, error)
GetEnv(name string) (apps.EnvView, error)
}
SupervisorGate is the api-side seam onto the daemon's installed-service supervisor (internal/apps.Supervisor satisfies it). nil-able: a daemon (or test fixture) without a supervisor skips every check and surface.