userpreference

package
v0.0.0-...-2769864 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package userpreference is the memory Kind for one user's saved preference values, keyed per (classNamespace, className, key) in the user's own scope (memory.UserScope). Mutable — last write wins on the deterministic entry ID. ComponentWritten: only the operator's preferences commit path may author it; a session bearer is refused at the facade door, which is the structural guard that keeps a prompt-injected agent from bypassing the human-confirm flow.

Index

Constants

View Source
const IDPrefix = "upref-"

IDPrefix is the literal byte prefix every Entry of this Kind's ID starts with. EntryID always includes it — deliberately unlike factcontent.EntryID, whose callers apply the prefix themselves — because this Kind has exactly one deterministic-ID producer and no reason to make a caller repeat it.

View Source
const KindName = "user_preference"

KindName is the registered name of this memory Kind.

View Source
const SoftCap = 1024

SoftCap bounds pathology across classes; the schema already bounds keys per class.

Variables

This section is empty.

Functions

func EntryID

func EntryID(classNS, className, key string) string

EntryID is deterministic per (classNS, className, key) so a re-save overwrites; the 0x1f separator prevents field-boundary collisions (("ns","a","bc") must not hash the same as ("ns","ab","c")).

Types

type Kind

type Kind struct{}

Kind is the memory.Kind implementation for user_preference.

func (Kind) ContentSchema

func (Kind) ContentSchema() reflect.Type

func (Kind) IDPrefix

func (Kind) IDPrefix() string

func (Kind) IndexedFields

func (Kind) IndexedFields() []string

func (Kind) Name

func (Kind) Name() string

func (Kind) NewScopeHooks

func (Kind) NewScopeHooks(_ memory.Scope) memory.ScopeHooks

func (Kind) Retention

func (Kind) Retention() memory.Retention

func (Kind) WriteAuthority

func (Kind) WriteAuthority() memory.WriteAuthority

WriteAuthority: ComponentWritten — the operator's preferences commit path is the only author; see the package doc for the threat this closes.

type Preference

type Preference struct {
	// ClassNamespace is the AgentClass namespace the preference was set for.
	ClassNamespace string `json:"classNamespace"`
	// ClassName is the AgentClass name the preference was set for.
	ClassName string `json:"className"`
	// Key is the preference's declared key within the class's schema.
	Key string `json:"key"`
	// Value is the saved value, or JSON null for a cleared tombstone: an
	// explicit "the user unset this" distinct from "never set", so a later
	// read does not fall back to the class default it was deliberately
	// cleared away from.
	Value json.RawMessage `json:"value"`
	// SetViaSession names the session the value was set through, when set
	// through one — empty for values set by another route (e.g. a CLI/admin
	// write).
	SetViaSession string `json:"setViaSession,omitempty"`
}

Preference is the Kind's Content payload: one saved value for one class's declared preference key, in the user's own scope.

Jump to

Keyboard shortcuts

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