Documentation
¶
Overview ¶
Package access defines the product authorization vocabulary shared by the bot runtime, persistence adapters, and control-plane APIs.
Index ¶
- type AccessEffect
- type ActionName
- type Actor
- type AuthorizationDecision
- type AuthorizationRequest
- type Authorizer
- type BotCapability
- type CapabilityName
- type DecisionFacts
- type DecisionReason
- type DirectChat
- type Evaluator
- type FactSource
- type GateName
- type Group
- type GroupActor
- type Permission
- type ResolvedRoute
- type Route
- type RouteResolver
- type TargetKind
- type TargetRef
- type TransportFactsSource
- type TransportStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessEffect ¶
type AccessEffect string
const ( EffectAllow AccessEffect = "allow" EffectDeny AccessEffect = "deny" )
type ActionName ¶
type ActionName string
const ( ActionAccess ActionName = "access" ActionNotifyReceive ActionName = "notify.receive" ActionNotifyReply ActionName = "notify.reply" ActionRemoteControlStart ActionName = "remote_control.start" ActionRemoteControlApprove ActionName = "remote_control.approve" ActionRemoteControlPrivileged ActionName = "remote_control.privileged" )
func (ActionName) Capability ¶
func (a ActionName) Capability() (CapabilityName, bool)
func (ActionName) RequiresActor ¶
func (a ActionName) RequiresActor() bool
type Actor ¶
type Actor struct {
ID string `json:"id"`
BotUUID string `json:"bot_uuid"`
Platform string `json:"platform"`
ExternalActorID string `json:"external_actor_id"`
DisplayName string `json:"display_name,omitempty"`
LastSeenAt time.Time `json:"last_seen_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type AuthorizationDecision ¶
type AuthorizationDecision struct {
Allowed bool `json:"allowed"`
Reason DecisionReason `json:"reason"`
FailedGate GateName `json:"failed_gate,omitempty"`
Facts DecisionFacts `json:"facts"`
}
func Evaluate ¶
func Evaluate(req AuthorizationRequest, facts DecisionFacts) AuthorizationDecision
Evaluate applies the single, stable authorization order. It is deliberately pure so production, diagnostics, and table tests cannot drift apart.
type AuthorizationRequest ¶
type AuthorizationRequest struct {
BotUUID string `json:"bot_uuid"`
Target TargetRef `json:"target"`
ActorID string `json:"actor_id,omitempty"`
Capability CapabilityName `json:"capability"`
Action ActionName `json:"action"`
RouteID string `json:"route_id,omitempty"`
RequestID string `json:"request_id,omitempty"`
}
type Authorizer ¶
type Authorizer interface {
Evaluate(context.Context, AuthorizationRequest) AuthorizationDecision
}
type BotCapability ¶
type BotCapability struct {
BotUUID string `json:"bot_uuid"`
Name CapabilityName `json:"capability"`
Enabled bool `json:"enabled"`
Config json.RawMessage `json:"config"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type CapabilityName ¶
type CapabilityName string
const ( CapabilityNotify CapabilityName = "notify" CapabilityRemoteControl CapabilityName = "remote_control" )
func (CapabilityName) Valid ¶
func (c CapabilityName) Valid() bool
type DecisionFacts ¶
type DecisionFacts struct {
BotEnabled bool `json:"bot_enabled"`
CapabilityEnabled bool `json:"capability_enabled"`
TransportStatus TransportStatus `json:"transport_status"`
TransportSupports bool `json:"transport_supports"`
TargetFound bool `json:"target_found"`
TargetBlocked bool `json:"target_blocked"`
TargetCapability AccessEffect `json:"target_capability"`
TargetAction AccessEffect `json:"target_action,omitempty"`
PeerActorID string `json:"peer_actor_id,omitempty"`
ActorRegistered bool `json:"actor_registered,omitempty"`
ActorAction AccessEffect `json:"actor_action,omitempty"`
RouteFound bool `json:"route_found,omitempty"`
RouteEnabled bool `json:"route_enabled,omitempty"`
RouteTarget TargetRef `json:"route_target,omitempty"`
PendingRequestFound bool `json:"pending_request_found,omitempty"`
PendingRequestTarget TargetRef `json:"pending_request_target,omitempty"`
}
type DecisionReason ¶
type DecisionReason string
const ( ReasonAllowed DecisionReason = "allowed" ReasonBotDisabled DecisionReason = "bot_disabled" ReasonCapabilityDisabled DecisionReason = "capability_disabled" ReasonTransportOffline DecisionReason = "transport_offline" ReasonTransportUnsupported DecisionReason = "transport_unsupported" ReasonTargetNotFound DecisionReason = "target_not_found" ReasonTargetBlocked DecisionReason = "target_blocked" ReasonTargetCapabilityDenied DecisionReason = "target_capability_denied" ReasonTargetActionDenied DecisionReason = "target_action_denied" ReasonActorRequired DecisionReason = "actor_required" ReasonActorMismatch DecisionReason = "actor_mismatch" ReasonActorNotRegistered DecisionReason = "actor_not_registered" ReasonActorActionDenied DecisionReason = "actor_action_denied" ReasonRouteInactive DecisionReason = "route_inactive" ReasonRouteTargetMismatch DecisionReason = "route_target_mismatch" ReasonPendingRequestExpired DecisionReason = "pending_request_expired" ReasonPendingRequestActorDenied DecisionReason = "pending_request_actor_denied" ReasonEvaluationFailed DecisionReason = "evaluation_failed" )
type DirectChat ¶
type DirectChat struct {
ID string `json:"id"`
BotUUID string `json:"bot_uuid"`
Platform string `json:"platform"`
ExternalChatID string `json:"external_chat_id"`
PeerActorID string `json:"peer_actor_id,omitempty"`
Blocked bool `json:"blocked"`
PairedAt *time.Time `json:"paired_at,omitempty"`
ProjectPath string `json:"project_path,omitempty"`
BashCwd string `json:"bash_cwd,omitempty"`
CurrentAgent string `json:"current_agent,omitempty"`
Verbose *bool `json:"verbose,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
func NewEvaluator ¶
func NewEvaluator(source FactSource) *Evaluator
func (*Evaluator) Evaluate ¶
func (e *Evaluator) Evaluate(ctx context.Context, req AuthorizationRequest) AuthorizationDecision
type FactSource ¶
type FactSource interface {
Snapshot(context.Context, AuthorizationRequest) (DecisionFacts, error)
}
FactSource loads one internally consistent authorization snapshot. Store implementations should use a read transaction when facts span tables.
type GateName ¶
type GateName string
const ( GateBot GateName = "bot" GateCapability GateName = "capability" GateTransport GateName = "transport" GateTarget GateName = "target" GateTargetCapability GateName = "target_capability" GateActor GateName = "actor" GateActorAction GateName = "actor_action" GateRoute GateName = "route" GatePendingRequest GateName = "pending_request" )
type Group ¶
type Group struct {
ID string `json:"id"`
BotUUID string `json:"bot_uuid"`
Platform string `json:"platform"`
ExternalGroupID string `json:"external_group_id"`
Name string `json:"name,omitempty"`
Blocked bool `json:"blocked"`
ProjectPath string `json:"project_path,omitempty"`
BashCwd string `json:"bash_cwd,omitempty"`
CurrentAgent string `json:"current_agent,omitempty"`
Verbose *bool `json:"verbose,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type GroupActor ¶
type Permission ¶
type Permission struct {
Capability CapabilityName `json:"capability"`
Action ActionName `json:"action"`
Effect AccessEffect `json:"effect"`
UpdatedAt time.Time `json:"updated_at"`
}
type ResolvedRoute ¶
type Route ¶
type Route struct {
ID string `json:"id"`
BotUUID string `json:"bot_uuid"`
Name string `json:"name"`
Source string `json:"source"`
EventFilter json.RawMessage `json:"event_filter"`
Target TargetRef `json:"target"`
Enabled bool `json:"enabled"`
Options json.RawMessage `json:"options"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type RouteResolver ¶
type RouteResolver interface {
ResolveRoute(ctx context.Context, source, event string) (*ResolvedRoute, error)
}
type TargetKind ¶
type TargetKind string
const ( TargetDirectChat TargetKind = "direct_chat" TargetGroup TargetKind = "group" )
type TargetRef ¶
type TargetRef struct {
Kind TargetKind `json:"kind"`
ID string `json:"id"`
}
type TransportFactsSource ¶
type TransportFactsSource interface {
TransportFacts(botUUID string, capability CapabilityName, action ActionName) (TransportStatus, bool)
}
type TransportStatus ¶
type TransportStatus string
const ( TransportConnecting TransportStatus = "connecting" TransportOnline TransportStatus = "online" TransportDegraded TransportStatus = "degraded" TransportOffline TransportStatus = "offline" )
Click to show internal directories.
Click to hide internal directories.