Documentation
¶
Index ¶
- Constants
- Variables
- type Admission
- type AttachRequest
- type ClaudeIdentity
- type DeliveredMessage
- type DirectProof
- type DurableRegistrar
- type ManagementCheck
- type Message
- type MessageBatch
- type PendingProbe
- type ProbeAnswer
- type ProbeResult
- type QueueReceipt
- type RegisterRequest
- type RegisterResult
- type RemoteService
- func NewPersistentRemoteService(root string) (*RemoteService, error)
- func NewRemoteService() *RemoteService
- func NewSQLitePersistentRemoteService(root string) (*RemoteService, error)
- func NewSQLitePersistentRemoteServiceWithBatchCleanup(root string, cleanup func([]access.DetachedRemovalProof) error) (*RemoteService, error)
- func (s *RemoteService) AnswerProbe(ctx context.Context, a ProbeAnswer) (ProbeResult, error)
- func (s *RemoteService) AttachSession(ctx context.Context, r AttachRequest) (Session, error)
- func (s *RemoteService) AttachmentsAvailable() bool
- func (s *RemoteService) BackfillRegistrationOwners(bindings map[string]string) error
- func (s *RemoteService) BugReportManagementSession(ctx context.Context) (Session, error)
- func (s *RemoteService) BugReportSession(ctx context.Context) (Session, error)
- func (s *RemoteService) CheckManagementAccess(ctx context.Context, selector string, check ManagementCheck) error
- func (s *RemoteService) CheckRegistrationHolder(ctx context.Context, r RegisterRequest, id string) error
- func (s *RemoteService) CheckSessionAccess(ctx context.Context, selector string) error
- func (s *RemoteService) Close() error
- func (s *RemoteService) DownloadAttachment(ctx context.Context, recipient, id string) (*attachments.Download, error)
- func (s *RemoteService) GetSession(ctx context.Context, name string) (Session, error)
- func (s *RemoteService) GetSessionObserved(ctx context.Context, selector string) (Session, error)
- func (s *RemoteService) InspectConversationHandover(ctx context.Context, r RegisterRequest, id string) (DirectProof, error)
- func (s *RemoteService) InspectDirectRegistration(ctx context.Context, harness, session, client, id, secret string) (DirectProof, error)
- func (s *RemoteService) InspectRebindResult(id, request, caller string, expected uint64) (protocol.RebindResult, bool)
- func (s *RemoteService) ListSessions(ctx context.Context) ([]Session, error)
- func (s *RemoteService) ManageSession(ctx context.Context, selector, kind string, check ManagementCheck, ...) error
- func (s *RemoteService) PendingRegistrationOwnerBackfills(bindings map[string]string) int
- func (s *RemoteService) RebindConversation(ctx context.Context, r RegisterRequest, id string) (DirectProof, error)
- func (s *RemoteService) RegisterSession(ctx context.Context, r RegisterRequest) (RegisterResult, error)
- func (s *RemoteService) RegistrationAdmissionMatches(id, grant string) bool
- func (s *RemoteService) RegistrationOwners() map[string]string
- func (s *RemoteService) RemoveDetachedSession(ctx context.Context, selector string, cleanup func(Session) error) error
- func (s *RemoteService) RemoveDetachedSessions(ctx context.Context, selectors []string) ([]string, error)
- func (s *RemoteService) RenameDirectRegistration(ctx context.Context, id, secret string, revision uint64, name string) (DirectProof, error)
- func (s *RemoteService) RenameSession(ctx context.Context, r RenameRequest) (Session, error)
- func (s *RemoteService) RenewLease(ctx context.Context, r RenewRequest) (RegisterResult, error)
- func (s *RemoteService) ReportIngressFailure(ctx context.Context, id, lease string) error
- func (s *RemoteService) ResumeSession(ctx context.Context, r ResumeRequest) (RegisterResult, error)
- func (s *RemoteService) RetireManaged(ctx context.Context, r protocol.RetireRequest, check ManagementCheck, ...) (protocol.RetireResult, error)
- func (s *RemoteService) SendAnnouncement(ctx context.Context, recipient, body string) (SendResult, error)
- func (s *RemoteService) SendMessage(ctx context.Context, m Message) (SendResult, error)
- func (s *RemoteService) SessionActivityOutputAllowed(ctx context.Context) bool
- func (s *RemoteService) SessionRuntimeInfo() map[string]protocol.RuntimeInfoSnapshot
- func (s *RemoteService) SetAdmission(a Admission)
- func (s *RemoteService) SetAttachments(store *attachments.Store)
- func (s *RemoteService) SetProbeSchedule(after, window, bootGrace time.Duration)
- func (s *RemoteService) SetSuspended(ctx context.Context, selector string, suspended bool) error
- func (s *RemoteService) StopSession(ctx context.Context, name string) error
- func (s *RemoteService) UploadAttachment(ctx context.Context, from, name string, size int64, body io.Reader) (protocol.Attachment, error)
- func (s *RemoteService) WaitForIngress(ctx context.Context, name, lease string) (Message, error)
- func (s *RemoteService) WaitForIngressAck(ctx context.Context, r protocol.IngressRequest) (Message, error)
- func (s *RemoteService) WaitForMessage(context.Context, string) (Message, error)
- func (s *RemoteService) WithDirectRegistration(ctx context.Context, r RegisterRequest, id string, handover bool, ...) error
- type RenameRequest
- type RenewRequest
- type ResumeRequest
- type SendResult
- type Session
- type SessionStatus
- type WakeLease
- type WakeStatus
- type WakeWarning
Constants ¶
const ( SelectorRegistration = protocol.SelectorRegistration SelectorName = protocol.SelectorName SelectorSession = protocol.SelectorSession )
Typed selector prefixes address exactly one namespace. Names can never start with one of them, so a bare selector stays backward compatible.
const ( CodeInvalid = protocol.CodeInvalid CodeNotFound = protocol.CodeNotFound CodeDetached = protocol.CodeDetached CodeSuspended = protocol.CodeSuspended CodeOwned = protocol.CodeOwned CodeRevisionMismatch = protocol.CodeRevisionMismatch CodeStaleProbe = protocol.CodeStaleProbe CodeStorage = protocol.CodeStorage CodeCapacity = protocol.CodeCapacity CodeInvalidToken = protocol.CodeInvalidToken )
Wire result codes retain compatibility with the neutral protocol package.
const ( StatusAlive = protocol.StatusAlive StatusWorking = protocol.StatusWorking StatusIdle = protocol.StatusIdle StatusMissing = protocol.StatusMissing StatusSuspended = protocol.StatusSuspended StatusStalled = protocol.StatusStalled StatusStarting = protocol.StatusStarting StatusStopping = protocol.StatusStopping StatusWaking = protocol.StatusWaking StatusDegraded = protocol.StatusDegraded WakeNotNeeded = protocol.WakeNotNeeded WakeConfirmed = protocol.WakeConfirmed WakeFailed = protocol.WakeFailed WakeDegraded = protocol.WakeDegraded WakeWarningStopFailed = protocol.WakeWarningStopFailed WakeWarningResumeFailed = protocol.WakeWarningResumeFailed WakeWarningRosterMismatch = protocol.WakeWarningRosterMismatch WakeWarningIdentityCommit = protocol.WakeWarningIdentityCommit WakeWarningQueueRekey = protocol.WakeWarningQueueRekey WakeWarningClaimUnconfirmed = protocol.WakeWarningClaimUnconfirmed WakeWarningRestartRecovery = protocol.WakeWarningRestartRecovery )
Variables ¶
var ErrQueueFull = errors.New("message queue is full")
ErrSessionIdentityUnauthorized is fixed and safe to expose through guidance.
var ErrSessionNotFound = errors.New("session not found")
var ErrSessionSuspended = errors.New("session is suspended")
Functions ¶
This section is empty.
Types ¶
type Admission ¶
type Admission interface {
Admit(ctx context.Context, request RegisterRequest) (name string, code string, err error)
}
Admission decides the communication name for a binding in token-protected projects. Admit is called outside the service lock, must not bind anything, and returns the enforced name (UUID-shaped names issued by the UI are accepted) or a rejection code such as CodeInvalidToken.
An admission that also implements reservedAdmission can answer per request whether a token grant applies. Requests without a grant then follow the open policy (requested name, UUID nickname on conflict) and legacy attach stays available. Without that method every request is treated as reserved.
An admission that also implements claimingAdmission is asked to bind the grant only after the request proved ownership of any existing registration, passed the revision and lease checks, and the name is available; a non-empty code rejects and nothing is persisted. Claim runs outside the service lock and must not call back into the service.
type AttachRequest ¶
type AttachRequest = protocol.AttachRequest
type ClaudeIdentity ¶
type ClaudeIdentity = protocol.ClaudeIdentity
type DeliveredMessage ¶
type DeliveredMessage = protocol.DeliveredMessage
type DirectProof ¶
type DurableRegistrar ¶
type DurableRegistrar interface {
RegisterSession(context.Context, RegisterRequest) (RegisterResult, error)
ResumeSession(context.Context, ResumeRequest) (RegisterResult, error)
RenewLease(context.Context, RenewRequest) (RegisterResult, error)
AnswerProbe(context.Context, ProbeAnswer) (ProbeResult, error)
}
DurableRegistrar is implemented by backends that own durable registrations.
type ManagementCheck ¶
type ManagementCheck func(target Session, recordedOwner string, callers []Session) (protocol.ManagementEvent, error)
ManagementCheck is server-only authorization. It runs under the mutation lock, must recheck live policy, and must not call back into this broker.
type MessageBatch ¶
type MessageBatch = protocol.MessageBatch
type PendingProbe ¶
type PendingProbe = protocol.PendingProbe
type ProbeAnswer ¶
type ProbeAnswer = protocol.ProbeAnswer
type ProbeResult ¶
type ProbeResult = protocol.ProbeResult
type QueueReceipt ¶
type QueueReceipt = protocol.QueueReceipt
type RegisterRequest ¶
type RegisterRequest = protocol.RegisterRequest
Registration DTO aliases are shared by remote services and local clients.
type RegisterResult ¶
type RegisterResult = protocol.RegisterResult
type RemoteService ¶
type RemoteService struct {
// contains filtered or unexported fields
}
RemoteService trusts local MCP relays to observe their own agents. It never interprets a reported PID or cwd in the central server's process/filesystem. Lease identifiers separate receivers; they are not user authentication. Durable registrations (see remote_durable.go) persist only the name→identity binding; liveness always comes from a current lease.
func NewPersistentRemoteService ¶
func NewPersistentRemoteService(root string) (*RemoteService, error)
NewPersistentRemoteService restores durable registrations from root and writes every binding change through to it. Restored registrations are missing until their owner resumes with the secret and a fresh lease.
func NewRemoteService ¶
func NewRemoteService() *RemoteService
NewRemoteService keeps every registration in memory only.
func NewSQLitePersistentRemoteService ¶
func NewSQLitePersistentRemoteService(root string) (*RemoteService, error)
NewSQLitePersistentRemoteService stores registration bindings in SQLite. Valid legacy JSON records are imported once and retained as backups.
func NewSQLitePersistentRemoteServiceWithBatchCleanup ¶
func NewSQLitePersistentRemoteServiceWithBatchCleanup(root string, cleanup func([]access.DetachedRemovalProof) error) (*RemoteService, error)
NewSQLitePersistentRemoteServiceWithBatchCleanup installs policy before startup sweeps.
func (*RemoteService) AnswerProbe ¶
func (s *RemoteService) AnswerProbe(ctx context.Context, a ProbeAnswer) (ProbeResult, error)
func (*RemoteService) AttachSession ¶
func (s *RemoteService) AttachSession(ctx context.Context, r AttachRequest) (Session, error)
func (*RemoteService) AttachmentsAvailable ¶
func (s *RemoteService) AttachmentsAvailable() bool
func (*RemoteService) BackfillRegistrationOwners ¶
func (s *RemoteService) BackfillRegistrationOwners(bindings map[string]string) error
BackfillRegistrationOwners only fills missing owners from retained server grants. Each write is atomic; a failed startup can safely retry the remainder.
func (*RemoteService) BugReportManagementSession ¶
func (s *RemoteService) BugReportManagementSession(ctx context.Context) (Session, error)
BugReportManagementSession additionally requires a live, non-suspended lease.
func (*RemoteService) BugReportSession ¶
func (s *RemoteService) BugReportSession(ctx context.Context) (Session, error)
BugReportSession selects a server-owned registration by its credential binding, without requiring roster scopes or accepting a caller-supplied session selector.
func (*RemoteService) CheckManagementAccess ¶
func (s *RemoteService) CheckManagementAccess(ctx context.Context, selector string, check ManagementCheck) error
func (*RemoteService) CheckRegistrationHolder ¶
func (s *RemoteService) CheckRegistrationHolder(ctx context.Context, r RegisterRequest, id string) error
CheckRegistrationHolder performs a read-only preflight after the panel has authenticated the project-token owner. Rebind/Register/Resume repeat the same guard at mutation time; this avoids issuing credentials while waiting.
func (*RemoteService) CheckSessionAccess ¶
func (s *RemoteService) CheckSessionAccess(ctx context.Context, selector string) error
CheckSessionAccess keeps authorization and journal recovery under the same lock as rename, even for the runtime boundary's preliminary checks.
func (*RemoteService) Close ¶
func (s *RemoteService) Close() error
Close stops background cleanup and releases blocked receivers. It attempts one dirty LastSeen flush before closing the store; Batch/fsync has no hard time bound. State access still works afterwards, with sweeps only on demand.
func (*RemoteService) DownloadAttachment ¶
func (s *RemoteService) DownloadAttachment(ctx context.Context, recipient, id string) (*attachments.Download, error)
func (*RemoteService) GetSession ¶
func (*RemoteService) GetSessionObserved ¶
GetSessionObserved confirms only a name read through a session-bound credential. Ordinary internal GetSession calls and unbound roster reads remain observations-free.
func (*RemoteService) InspectConversationHandover ¶
func (s *RemoteService) InspectConversationHandover(ctx context.Context, r RegisterRequest, id string) (DirectProof, error)
func (*RemoteService) InspectDirectRegistration ¶
func (s *RemoteService) InspectDirectRegistration(ctx context.Context, harness, session, client, id, secret string) (DirectProof, error)
func (*RemoteService) InspectRebindResult ¶
func (s *RemoteService) InspectRebindResult(id, request, caller string, expected uint64) (protocol.RebindResult, bool)
InspectRebindResult proves the exact apply for a pending server-side journal. Startup recovery uses this without exposing a resume secret or identity.
func (*RemoteService) ListSessions ¶
func (s *RemoteService) ListSessions(ctx context.Context) ([]Session, error)
func (*RemoteService) ManageSession ¶
func (s *RemoteService) ManageSession(ctx context.Context, selector, kind string, check ManagementCheck, audit func(protocol.ManagementEvent) error) error
ManageSession is a trusted runtime path. Authorization is mandatory and is repeated inside the same lock as the durable write. SetSuspended's blanket rejection of session-granted callers is intentionally unchanged.
func (*RemoteService) PendingRegistrationOwnerBackfills ¶
func (s *RemoteService) PendingRegistrationOwnerBackfills(bindings map[string]string) int
PendingRegistrationOwnerBackfills counts eligible records, without exporting identities.
func (*RemoteService) RebindConversation ¶
func (s *RemoteService) RebindConversation(ctx context.Context, r RegisterRequest, id string) (DirectProof, error)
Broker -> policy is the only nested lock order. The policy callback rechecks the issued child/owner while the broker's proof and receiving state are locked.
func (*RemoteService) RegisterSession ¶
func (s *RemoteService) RegisterSession(ctx context.Context, r RegisterRequest) (RegisterResult, error)
func (*RemoteService) RegistrationAdmissionMatches ¶
func (s *RemoteService) RegistrationAdmissionMatches(id, grant string) bool
func (*RemoteService) RegistrationOwners ¶
func (s *RemoteService) RegistrationOwners() map[string]string
RegistrationOwners returns a detached snapshot keyed by registration ID.
func (*RemoteService) RemoveDetachedSession ¶
func (s *RemoteService) RemoveDetachedSession(ctx context.Context, selector string, cleanup func(Session) error) error
RemoveDetachedSession releases a detached registration. The admission cleanup runs under the broker lock, before removal, so an explicit re-registration cannot race token revocation. cleanup must not call the broker. StopSession itself retains its MCP contract of allowing explicit re-registration. For legacy (non-durable) entries, callers must fence replaying legacy clients before removal; the managed production runtime accepts token-based clients only.
func (*RemoteService) RemoveDetachedSessions ¶
func (s *RemoteService) RemoveDetachedSessions(ctx context.Context, selectors []string) ([]string, error)
RemoveDetachedSessions skips invalid or unauthorized rows independently. Policy commits before one storage transaction; failures retain every accepted row.
func (*RemoteService) RenameDirectRegistration ¶
func (s *RemoteService) RenameDirectRegistration(ctx context.Context, id, secret string, revision uint64, name string) (DirectProof, error)
Direct recovery has a verified resume proof instead of an active receiver lease, but uses the exact existing atomic rename journal/persistence path.
func (*RemoteService) RenameSession ¶
func (s *RemoteService) RenameSession(ctx context.Context, r RenameRequest) (Session, error)
RenameSession preserves the registration, active lease and queued envelopes. Both the lease and, on protected projects, the current credential must own it.
func (*RemoteService) RenewLease ¶
func (s *RemoteService) RenewLease(ctx context.Context, r RenewRequest) (RegisterResult, error)
func (*RemoteService) ReportIngressFailure ¶
func (s *RemoteService) ReportIngressFailure(ctx context.Context, id, lease string) error
func (*RemoteService) ResumeSession ¶
func (s *RemoteService) ResumeSession(ctx context.Context, r ResumeRequest) (RegisterResult, error)
func (*RemoteService) RetireManaged ¶
func (s *RemoteService) RetireManaged(ctx context.Context, r protocol.RetireRequest, check ManagementCheck, cleanup func(access.RetirementTarget, func() error) ([]protocol.RevokedCredential, error)) (protocol.RetireResult, error)
RetireManaged keeps authorization, detach, policy cleanup and removal in one mutation lock. cleanup must not call the broker; lock order is broker -> store.
func (*RemoteService) SendAnnouncement ¶
func (s *RemoteService) SendAnnouncement(ctx context.Context, recipient, body string) (SendResult, error)
SendAnnouncement is an internal administrator entry point, never an MCP tool. The control panel/runtime must authorize the administrator before calling it.
func (*RemoteService) SendMessage ¶
func (s *RemoteService) SendMessage(ctx context.Context, m Message) (SendResult, error)
func (*RemoteService) SessionActivityOutputAllowed ¶
func (s *RemoteService) SessionActivityOutputAllowed(ctx context.Context) bool
SessionActivityOutputAllowed is a compatibility hint for strict MCP output schemas, not an authorization decision. Only the authenticated caller's own current lease can prove support. Freshness of display evidence is separate: once a valid sample was accepted, TTL expiry or a missing sample does not downgrade that lease. issueLeaseLocked resets this proof on replacement.
func (*RemoteService) SessionRuntimeInfo ¶
func (s *RemoteService) SessionRuntimeInfo() map[string]protocol.RuntimeInfoSnapshot
SessionRuntimeInfo is an internal panel projection, never part of MCP Session. The panel performs its ordinary project membership check before calling it.
func (*RemoteService) SetAdmission ¶
func (s *RemoteService) SetAdmission(a Admission)
SetAdmission installs the token-mode name policy. Without it the project is open: the requested name is used and a conflict yields a UUID nickname.
func (*RemoteService) SetAttachments ¶
func (s *RemoteService) SetAttachments(store *attachments.Store)
func (*RemoteService) SetProbeSchedule ¶
func (s *RemoteService) SetProbeSchedule(after, window, bootGrace time.Duration)
SetProbeSchedule overrides how long a registration may stay missing before a probe is issued, how long the probe may stay unanswered, and the grace after a server start before a probe is considered unanswered. A zero after or window keeps the current value; the grace is always replaced.
func (*RemoteService) SetSuspended ¶
SetSuspended changes durable management policy without releasing the name or ownership binding. Only trusted management callers may invoke it; a session token grant never authorizes this operation, even for its own name. A successful transition discards pending messages and fences the receiver. Lifting suspension leaves the registration missing until a fresh lease is presented, with a new cleanup grace period.
func (*RemoteService) StopSession ¶
func (s *RemoteService) StopSession(ctx context.Context, name string) error
func (*RemoteService) UploadAttachment ¶
func (s *RemoteService) UploadAttachment(ctx context.Context, from, name string, size int64, body io.Reader) (protocol.Attachment, error)
func (*RemoteService) WaitForIngress ¶
func (*RemoteService) WaitForIngressAck ¶
func (s *RemoteService) WaitForIngressAck(ctx context.Context, r protocol.IngressRequest) (Message, error)
WaitForIngressAck is the wire receiver. The legacy Go entry point shares its loop.
func (*RemoteService) WaitForMessage ¶
func (*RemoteService) WithDirectRegistration ¶
func (s *RemoteService) WithDirectRegistration(ctx context.Context, r RegisterRequest, id string, handover bool, apply func(DirectProof) error) error
WithDirectRegistration fences the final proof and policy exchange against retire. The callback runs under the broker lock and must not call back into the broker.
type RenameRequest ¶
type RenameRequest = protocol.RenameRequest
type RenewRequest ¶
type RenewRequest = protocol.RenewRequest
type ResumeRequest ¶
type ResumeRequest = protocol.ResumeRequest
type SendResult ¶
type SendResult = protocol.SendResult
type SessionStatus ¶
type SessionStatus = protocol.SessionStatus
type WakeStatus ¶
type WakeStatus = protocol.WakeStatus
type WakeWarning ¶
type WakeWarning = protocol.WakeWarning
Source Files
¶
- announcement.go
- conversation_handover.go
- direct_registration.go
- holder_guard.go
- manual_rebind.go
- registration_owner.go
- remote.go
- remote_ack.go
- remote_activity.go
- remote_attachment.go
- remote_bugreport.go
- remote_durable.go
- remote_lastseen.go
- remote_management.go
- remote_remove.go
- remote_rename.go
- remote_retire.go
- remote_runtime_info.go
- remote_sqlite_store.go
- remote_stale_name.go
- remote_store.go
- remote_store_pin_other.go
- remote_suspend.go
- service.go
- types.go