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 ¶
- func IsRevisionMismatch(err error) bool
- type DescribedSetting
- type ErrRevisionMismatch
- type Path
- type PathOp
- type SettingsNamespace
- type SettingsScope
- func (s *SettingsScope) ApplyHost(path Path, value any) error
- func (s *SettingsScope) Describe(redactSecrets bool) []DescribedSetting
- func (s *SettingsScope) Get(path Path) (json.RawMessage, bool)
- func (s *SettingsScope) Replace(expectedRevision uint64, values map[Path]any) error
- func (s *SettingsScope) Revision() uint64
- func (s *SettingsScope) Update(expectedRevision uint64, ops map[Path]PathOp) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRevisionMismatch ¶
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 ¶
ErrRevisionMismatch indicates a CAS revision conflict.
func (*ErrRevisionMismatch) Error ¶
func (e *ErrRevisionMismatch) Error() string
Error implements error.
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.
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.