Implementation:1ay1 Agentty Settings Registry
| Knowledge Sources | |
|---|---|
| Domains | Configuration, Settings |
| Last Updated | 2026-10-28 12:00 GMT |
Overview
Single compile-time table of every user-facing setting, with derived operations for env reading, JSON persistence, UI form rendering, validation, and CLI get/set.
Description
The settings::registry is a single `constexpr` array (`kSettings`) of `SettingDef` rows that is the source of truth for every user-facing policy knob. Each row carries an id, env name, label, help text, group, tier, type, a pointer-to-member binding (`slot`) into the persisted config struct, bounds, and enum options. Everything else — env reading, settings.json load/save, the settings UI, validation, `agentty config` — is DERIVED by walking the table.
Adding a knob is adding a row, not four edits across three files. The binding is a `std::variant` of pointer-to-member into one of four config structs (Rag, Smart, WebSearch, Paste), so a row knows how to read and write its own value. Compile-time proofs enforce that ids are unique, envs are unique, ranges are sane, enums have options, slot types match declared types, and id prefixes match their owner struct.
Usage
Import this when you need to: render the settings UI panes, read/apply environment variable overrides, load/save settings.json, validate setting values, or implement `agentty config get/set`.
Code Reference
Source Location
- Repository: 1ay1_Agentty
- File: include/agentty/runtime/settings_registry.hpp
- Lines: 1-805
Signature
namespace agentty::settings::registry {
enum class Group : std::uint8_t {
Sources, Pipeline, Fusion, Proactive, Infra, Routing,
WebSearch, WebSearchServices, PasteRoutes, PasteFiles, PasteExpert
};
enum class Tier : std::uint8_t { Basic, Advanced };
enum class Type : std::uint8_t { Bool, Real, Int, Enum, Text };
enum class Owner : std::uint8_t { Rag, Smart, WebSearch, Paste };
struct SettingDef {
std::string_view id; // settings.json key AND form field id
std::string_view env; // legacy env name; "" = no env alias
std::string_view label; // UI
std::string_view help; // one-line description
Group group;
Tier tier;
Type type;
Slot slot; // pointer-to-member into config struct
double min = 0.0;
double max = 1.0;
double step = 0.05;
std::string_view options; // pipe-separated enum options
[[nodiscard]] constexpr Owner owner() const noexcept;
};
inline constexpr std::array kSettings = std::to_array<SettingDef>({
{"rag.skills", "AGENTTY_RAG_SKILLS", "Index skills", ...},
// ~35 rows covering RAG, Smart Mode, web_search, paste
});
[[nodiscard]] constexpr const SettingDef* find(std::string_view id) noexcept;
// Derived operations (settings_registry.cpp) — overloaded per owner:
[[nodiscard]] EnvSnapshot read_env(Io);
void apply_env(store::RagConfig& c, const EnvSnapshot& env);
[[nodiscard]] std::string get(const store::RagConfig& c, const SettingDef& d);
[[nodiscard]] bool set(store::RagConfig& c, const SettingDef& d, std::string_view v);
[[nodiscard]] bool is_default(const store::RagConfig& c, const SettingDef& d);
[[nodiscard]] std::string env_override(const SettingDef& d, const EnvSnapshot& env);
void reset(store::RagConfig& c, const SettingDef& d);
// Form rendering — the single way a pane renders settings rows.
template <class C>
inline void add_rows(form::Builder& b, const C& cfg, const EnvSnapshot& env,
Owner owner, bool advanced, bool& first, Group& last_group);
template <class C>
inline bool read_row(C& cfg, const SettingDef& d, const form::Field& row);
}
Import
#include "agentty/runtime/settings_registry.hpp"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| kSettings | constexpr std::array<SettingDef> | Yes | The single table — every user-facing setting as a row |
| cfg | store::RagConfig / smart::RoleConfig / ... | Yes | The config struct a row binds to (read/write via pointer-to-member) |
| env | EnvSnapshot | Yes | Process environment overrides, read once |
| id | std::string_view | Yes | Setting id for lookup (e.g. "rag.mmr") |
Outputs
| Name | Type | Description |
|---|---|---|
| get() | std::string | The row's value as a string (for JSON / CLI) |
| set() | bool | Success (false for unknown id or invalid value) |
| add_rows() | void | Populates a form::Builder with all rows of an owner |
| env_override() | std::string | The env var name overriding a row, or "" when none |
Usage Examples
Apply Environment Overrides
#include "agentty/runtime/settings_registry.hpp"
auto env = agentty::settings::registry::read_env(io);
store::RagConfig rag = store.load_settings().rag;
agentty::settings::registry::apply_env(rag, env);
// Every rag.* row's env var (if set) is applied and clamped to .range
Render Settings Pane
form::Builder b;
bool first = true;
agentty::settings::registry::Group last_group{};
agentty::settings::registry::add_rows(
b, settings.rag, env,
agentty::settings::registry::Owner::Rag,
show_advanced, first, last_group);
// The form now has toggles, sliders, choices for every RAG row
// with labels, help, bounds, and env-lock provenance from the table
CLI Get/Set
const auto* def = agentty::settings::registry::find("rag.mmr");
if (def) {
std::string val = agentty::settings::registry::get(settings.rag, *def);
// "true" or "false"
agentty::settings::registry::set(settings.rag, *def, "false");
}