admin

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package admin validates dashboard operations before touching scoped stores.

Index

Constants

This section is empty.

Variables

View Source
var Schemas = map[string][]Field{
	"instincts":  {required("category", "injection", "exfiltration", "manipulation", "jailbreak"), required("sensitivity", sensitivity...), required("action", "block", "flag", "alert", "redact", "quote"), list("strategies", field("name", "text"), field("weight", "number"), field("config", "json"))},
	"awareness":  {required("focus", focus...), required("action", "redact", "flag", "block", "vault"), list("detectors", field("name", "text"), required("focus", focus...), field("patterns", "tags"), field("config", "json"))},
	"boundaries": {field("response", "textarea"), list("limits", required("scope", "topic", "action", "data", "output", "custom"), field("deny", "tags"), field("allow", "tags"), field("use_allow", "boolean"))},
	"values":     {required("severity", "info", "warning", "error", "critical"), required("action", "block", "flag", "warn"), list("rules", required("principle", "toxicity", "brand_safety", "honesty", "respect", "safety", "privacy", "custom"), field("threshold", "number"), field("categories", "tags"), field("guidelines", "tags"), field("config", "json"))},
	"judgments":  {required("domain", domains...), field("threshold", "number"), required("action", "flag", "block", "warn"), list("assessors", field("name", "text"), required("domain", domains...), field("weight", "number"), field("requires_context", "boolean"), field("config", "json"))},
	"reflexes":   {field("priority", "integer"), list("triggers", required("type", "on_score", "on_finding", "on_pattern", "on_context", "on_rate", "always"), field("pattern", "text"), rateThreshold(), field("window", "text")), list("actions", required("type", "block", "redact", "flag", "rewrite", "escalate", "log", "throttle"), field("target", "text"), field("value", "json_value"), field("fallback", "textarea"))},
	"profiles":   {list("instincts", field("instinct_name", "reference"), field("sensitivity", "select", sensitivity...)), list("awareness", field("awareness_name", "reference")), list("judgments", field("judgment_name", "reference"), field("threshold", "number")), field("boundaries", "references"), field("values", "references"), field("reflexes", "references")},
	"policies":   {list("rules", required("check_type", "instinct", "awareness", "boundary", "values", "judgment", "reflex"), field("condition", "text"), required("action", "block", "flag", "redact", "escalate"), field("error_message", "textarea"), field("priority", "integer"))},
}

Functions

func InputSchema

func InputSchema(kind string, update bool) map[string]any

InputSchema publishes the same limits used by the editor and service.

Types

type Actor

type Actor struct {
	Subject                 string
	Scope                   store.Scope
	Read, Manage, Sensitive bool
}

func (Actor) Check

func (a Actor) Check(write bool) error

type Audit

type Audit func(context.Context, AuditEvent) error

type AuditEvent

type AuditEvent struct {
	Subject  string      `json:"subject"`
	Scope    store.Scope `json:"scope"`
	Action   string      `json:"action"`
	TokenIDs []string    `json:"token_ids"`
	Cutoff   time.Time   `json:"cutoff"`
	Affected int64       `json:"affected"`
}

type Error

type Error struct {
	Code    string
	Message string
	Fields  map[string]string
}

func (*Error) Error

func (e *Error) Error() string

type Field

type Field struct {
	Key          string   `json:"key"`
	Label        string   `json:"label"`
	Type         string   `json:"type"`
	Options      []string `json:"options,omitempty"`
	Fields       []Field  `json:"fields,omitempty"`
	Required     bool     `json:"required,omitempty"`
	MaxLength    int      `json:"max_length,omitempty"`
	MaxItems     int      `json:"max_items,omitempty"`
	JSONBytesMax int      `json:"json_bytes_max,omitempty"`
	Minimum      *float64 `json:"minimum,omitempty"`
	Maximum      *float64 `json:"maximum,omitempty"`
}

type Preview

type Preview struct {
	ID        string    `json:"id"`
	Cutoff    time.Time `json:"cutoff"`
	ExpiresAt time.Time `json:"expires_at"`
	TokenIDs  []string  `json:"token_ids"`
	Total     int64     `json:"total"`
	HasMore   bool      `json:"has_more"`
	// contains filtered or unexported fields
}

type PrivacyPage

type PrivacyPage struct {
	store.Page
	ByType        map[string]int64 `json:"by_type"`
	DistinctTypes int              `json:"distinct_types"`
}

type Service

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

func New

func New(db store.DashboardStore, eng *engine.Engine, audit Audit) *Service

func (*Service) Assign

func (s *Service) Assign(ctx context.Context, a Actor, key string, assigned bool) error

func (*Service) Assigned

func (s *Service) Assigned(ctx context.Context, a Actor, key string) (bool, error)

func (*Service) Create

func (s *Service) Create(ctx context.Context, a Actor, kind string, raw json.RawMessage) (json.RawMessage, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, a Actor, kind, key string) error

func (*Service) Engine

func (s *Service) Engine() *engine.Engine

func (*Service) Get

func (s *Service) Get(ctx context.Context, a Actor, kind, key string) (json.RawMessage, error)

func (*Service) List

func (s *Service) List(ctx context.Context, a Actor, kind string, f store.Filter) (store.Page, error)

func (*Service) PrivacyAvailable

func (s *Service) PrivacyAvailable() bool

func (*Service) Ready

func (s *Service) Ready() bool

func (*Service) References

func (s *Service) References(ctx context.Context, a Actor, kind, name string) ([]string, error)

func (*Service) RetentionExecute

func (s *Service) RetentionExecute(ctx context.Context, a Actor, key string) (int64, error)

func (*Service) RetentionPreview

func (s *Service) RetentionPreview(ctx context.Context, a Actor) (Preview, error)

func (*Service) TokenStats

func (s *Service) TokenStats(ctx context.Context, a Actor, f store.Filter) (PrivacyPage, error)

func (*Service) Tokens

func (s *Service) Tokens(ctx context.Context, a Actor, scanID string, f store.Filter) (store.Page, error)

func (*Service) Update

func (s *Service) Update(ctx context.Context, a Actor, kind, key string, raw json.RawMessage, expectedRevision ...string) (json.RawMessage, error)

Jump to

Keyboard shortcuts

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