access

package
v0.260813.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package access defines the product authorization vocabulary shared by the bot runtime, persistence adapters, and control-plane APIs.

Index

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

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

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 GroupActor struct {
	GroupID     string       `json:"group_id"`
	Actor       Actor        `json:"actor"`
	Label       string       `json:"label,omitempty"`
	Permissions []Permission `json:"permissions"`
	CreatedAt   time.Time    `json:"created_at"`
	UpdatedAt   time.Time    `json:"updated_at"`
}

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 ResolvedRoute struct {
	Route            Route  `json:"route"`
	ExternalTargetID string `json:"external_target_id"`
}

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"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL