settings

package
v1.801.476 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package settings is how an org configures each product it uses, secret fields included.

It is the per-org, per-product configuration plane for the unified Hanzo Cloud binary: the /v1/settings/:product surface behind every product's detail view in console.hanzo.ai (#59). Reads and writes are backed by a durable per-tenant SQLite store with KMS custody for any secret-typed field.

ONE settings engine, EVERY product. The console drives all products' Settings tab through this single surface (product id → :product). There is no per-product bespoke server code — a product is just an (org, product) key.

Surface (all org-scoped; /v1 only):

GET /v1/settings/:product   org config (read, secrets masked)  -> settingsView
PUT /v1/settings/:product   org config (write)                 -> settingsView

TENANT ISOLATION is enforced SERVER-SIDE on every request. The org is principal.Org(c) — the value SanitizeIdentity minted from the VALIDATED bearer owner (HIP-0026) — and is NEVER read from a query param, body, or client header. It is the mandatory predicate on every store statement. The client chooses a PRODUCT (validated against a slug shape); it never supplies the org.

SECRET CUSTODY. A secret field's VALUE lives ONLY in KMS at orgs/{org}/settings/{product}/{key}; the store keeps only the non-secret JSON plus the list of secret key NAMES (so the read path knows which fields are set-but- masked). A plaintext secret can never reach SQLite — a secret write routes to KMS or fails closed (503).

NOT OBSERVABILITY. This surface once shared a package with the o11y read paths; those reads live in apps/o11y now. A product's config and a product's telemetry are different questions with different stores, so they are different planes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mount

func Mount(app cloud.Router, deps cloud.Deps) error

Mount registers the settings surface on app per HIP-0106.

func Shutdown

func Shutdown(_ context.Context) error

Shutdown releases the settings store. Idempotent.

Types

type Settings

type Settings struct {
	Org        string
	Product    string
	Config     string   // opaque non-secret JSON object, stored verbatim (bounded at the edge)
	SecretKeys []string // names of secret fields (values in KMS, never here)
	CreatedAt  int64
	UpdatedAt  int64
}

Settings is the persisted per-(org,product) config record. Config is the non-secret JSON document; SecretKeys names the fields whose values live in KMS.

type SettingsStore

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

SettingsStore is the settings metastore over one SQLite file — the deployment's own "settings" subsystem. Tenancy is the (org, product) key.

func (*SettingsStore) Close

func (s *SettingsStore) Close() error

Close closes the underlying database.

func (*SettingsStore) Get

func (s *SettingsStore) Get(ctx context.Context, org, product string) (Settings, error)

Get returns the persisted settings for (org, product), or errNotFound when the org has never written config for that product (the caller then serves the product defaults merged with an empty override).

func (*SettingsStore) Put

func (s *SettingsStore) Put(ctx context.Context, st Settings) (Settings, error)

Put upserts the non-secret config document + secret-key list for (org, product). It is idempotent on the composite key. The write NEVER carries secret values — those are already in KMS by the time this is called (see the handler).

Jump to

Keyboard shortcuts

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