settings

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package settings implements ctx.settings with layered scopes, path operations, CAS revisions, and secret redaction, matching settings/settings and settings-file. Host defaults are overridden by nearer session values. Set/unset operations use expectedRevision for optimistic concurrency. Redacted descriptions reveal only set/unset status for secret paths, never plaintext values in model output or logs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRevisionMismatch

func IsRevisionMismatch(err error) bool

IsRevisionMismatch identifies revision-conflict errors.

Types

type DescribedSetting

type DescribedSetting struct {
	Path   Path   `json:"path"`
	Op     string `json:"op"` // "set" / "unset" / "default"
	Value  any    `json:"value,omitempty"`
	Secret bool   `json:"secret,omitempty"`
}

DescribedSetting is one described setting.

type ErrRevisionMismatch

type ErrRevisionMismatch struct {
	Expected uint64
	Actual   uint64
}

ErrRevisionMismatch indicates a CAS revision conflict.

func (*ErrRevisionMismatch) Error

func (e *ErrRevisionMismatch) Error() string

Error implements error.

type Path

type Path string

Path is a dot-separated setting path, such as sandbox.mode.

type PathOp

type PathOp struct {
	// Set supplies a value when nonnil; nil means unset.
	Set *json.RawMessage `json:"set,omitempty"`
}

PathOp describes one setting-path operation.

func NewSetOp

func NewSetOp(v any) PathOp

NewSetOp constructs a set operation.

func NewUnsetOp

func NewUnsetOp() PathOp

NewUnsetOp constructs an unset operation.

type SettingsNamespace

type SettingsNamespace struct {
	// Name identifies the namespace.
	Name string
	// SecretPaths identifies paths redacted in descriptions.
	SecretPaths map[Path]struct{}
}

SettingsNamespace defines a namespace and its secret paths.

func NewNamespace

func NewNamespace(name string) *SettingsNamespace

NewNamespace creates a settings namespace.

func (*SettingsNamespace) IsSecret

func (ns *SettingsNamespace) IsSecret(p Path) bool

IsSecret reports whether a path is secret.

func (*SettingsNamespace) MarkSecret

func (ns *SettingsNamespace) MarkSecret(p Path)

MarkSecret marks a path as secret.

type SettingsScope

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

SettingsScope provides a host-and-session layered settings view.

func NewSettingsScope

func NewSettingsScope(ns *SettingsNamespace) *SettingsScope

NewSettingsScope creates settings with the host layer first.

func (*SettingsScope) ApplyHost

func (s *SettingsScope) ApplyHost(path Path, value any) error

ApplyHost sets host defaults; expectedRevision=0 means initialization or force.

func (*SettingsScope) Describe

func (s *SettingsScope) Describe(redactSecrets bool) []DescribedSetting

Describe reports current settings; redacted secrets expose operation state only.

func (*SettingsScope) Get

func (s *SettingsScope) Get(path Path) (json.RawMessage, bool)

Get resolves a path nearest-first and returns raw JSON bytes.

func (*SettingsScope) Replace

func (s *SettingsScope) Replace(expectedRevision uint64, values map[Path]any) error

Replace replaces all session settings using CAS.

func (*SettingsScope) Revision

func (s *SettingsScope) Revision() uint64

Revision returns the revision incremented by update or replace.

func (*SettingsScope) Update

func (s *SettingsScope) Update(expectedRevision uint64, ops map[Path]PathOp) error

Update applies operations to the session layer using CAS. expectedRevision must match Revision or ErrRevisionMismatch is returned. Success increments the revision and session values override host defaults.

Jump to

Keyboard shortcuts

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