safety

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Rolling window for counting reports (reportsInWindow)
	ReportsWindowDuration = 7 * 24 * time.Hour

	MinReportsToTriggerCheck = 5

	// Threshold formula: max(MinReportRate, SqrtActiveUsersScaleFactor/sqrt(activeUsers))
	MinReportRate              = 0.02
	SqrtActiveUsersScaleFactor = 0.5

	// Cooldown before user can update last_reported_at; stricter when paused
	ReportCooldown       = 24 * time.Hour
	ReportPausedCooldown = 7 * 24 * time.Hour
)

Variables

View Source
var (
	ErrGloballyDisabled = errors.New("action disabled globally")
	ErrPluginDisabled   = errors.New("action disabled for plugin")
	ErrUnknownAction    = errors.New("unknown action")
)

Functions

func CalculateThreshold

func CalculateThreshold(activeUsers int) float64

func IsDisabledError

func IsDisabledError(err error) bool

func ShouldAutoPause

func ShouldAutoPause(reportsInWindow, activeUsers int) (should bool, rate, threshold float64)

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(db storage.ControlFlagsRepository, logger *logrus.Logger) *Manager

func (*Manager) EnforceKeygen

func (m *Manager) EnforceKeygen(ctx context.Context, pluginID string) error

func (*Manager) EnforceKeysign

func (m *Manager) EnforceKeysign(ctx context.Context, pluginID string) error

Jump to

Keyboard shortcuts

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