preferencewrite

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: 7 Imported by: 0

Documentation

Overview

Package preferencewrite is the memory Kind for the audit log of first-party human writes to user preferences: every direct edit via the Slack App Home (or other UI surfaces) into the acting user's own user_preference scope. It records who edited what, when, and why, creating a tamper-evident audit chain that lets a human answer "which settings did this user change, and through what path" after the fact — the opposite of preferenceaccess (agent reads on the session chain). Every user preference edit appends a signed, tamper-evident record into the user's own scope, not the session's.

Index

Constants

View Source
const IDPrefix = "prefwr-"

IDPrefix is the literal byte prefix every Entry of this Kind's ID starts with.

View Source
const KindName = "preference_write"

KindName is the registered name of this memory Kind.

Variables

This section is empty.

Functions

func Record

func Record(ctx context.Context, m auditaccessor.Putter, scope memory.Scope, c Content) error

Record appends one preference_write audit entry into scope — the USER scope of the acting user, never a session scope: this is a record of what the USER did to their own preferences, and belongs on their own tamper-evident chain. Every write is user-initiated and authenticated.

m is deliberately auditaccessor.Putter, not memory.Memory: the caller hands this a write-only signing facade, and that facade has no reason to ever gain Query access to this audit trail just to append to it. A memory.Memory value (e.g. a bare *memory.Local in a test) still satisfies this — its method set is a superset.

A unique ID per call (via memory.NewID), and CreatedAt stamped to now — c carries no timestamp field of its own, so every call to Record produces a genuinely new entry, including two back-to-back writes of the exact same preference value.

Types

type Content

type Content struct {
	// Subject is the canonical user id performing the write (the acting user,
	// never an agent on behalf of them).
	Subject string `json:"subject"`
	// ClassNamespace is the agent class namespace.
	ClassNamespace string `json:"classNamespace"`
	// ClassName is the agent class name.
	ClassName string `json:"className"`
	// Key is the preference key being written.
	Key string `json:"key"`
	// Value is the raw JSON bytes of the new value (e.g., "false", "true",
	// "\"notifications_enabled\"", or a complex object). Kept as json.RawMessage
	// to preserve the exact serialization, allowing exact replay or comparison.
	Value json.RawMessage `json:"value"`
	// Via is the UI path or surface the write came through (e.g., "app-home",
	// "web-ui", "cli").
	Via string `json:"via"`
}

Content is one user preference write — a first-party edit into the acting user's own user_preference scope, recorded alongside the user_preference Entry it documents.

func List

func List(ctx context.Context, m memory.Memory, scope memory.Scope) ([]Content, error)

List returns every preference_write entry in scope, oldest-first.

type Kind

type Kind struct{}

func (Kind) ContentSchema

func (Kind) ContentSchema() reflect.Type

func (Kind) IDPrefix

func (Kind) IDPrefix() string

func (Kind) IndexedFields

func (Kind) IndexedFields() []string

IndexedFields: "key" and "via" — fields a forensic sweep filters on (show me every write to "notifications", or every edit via "app-home"). JSON tag, not the Go name, per the Kind interface's own contract.

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 — only platform components (the Slack App Home handler, the CLI preference command, etc.) author this Kind, signed as the acting user through their own signing facade. A session credential can never author a write to a user scope — only the user themselves, through a platform surface.

Jump to

Keyboard shortcuts

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