#pragma once // Read/write access to the `settings` table (key -> JSON-text value). The table starts // empty; a key with no row falls back to the built-in default that mirrors // Settings.schema.json. Typed helpers cover what the daemon reads internally (governor // config, allowed roots); the full settings.get / settings.set projection onto the wire // `Settings` object lands with those handlers. #include #include #include #include #include #include #include "store/sqlite.hpp" namespace velox::daemon::store { class Settings { public: explicit Settings(Db& db) : db_(db) {} // Raw JSON text for one key: the stored row, or the built-in default, or nullopt if // the key is unknown to the daemon entirely. DbResult> get_raw(std::string_view key); // Replace one key's value. `json_text` must be a valid JSON document; the caller // (settings.set handler) validates it against the schema first. DbResult set_raw(std::string_view key, std::string_view json_text); // Every stored override (not merged with defaults). DbResult> overrides(); // Typed convenience over get_raw + the defaults. A malformed stored value falls back // to the default rather than throwing. std::int64_t get_int(std::string_view key); std::string get_string(std::string_view key); std::vector get_string_array(std::string_view key); // The built-in default JSON for `key`, or nullopt if unknown. static std::optional default_for(std::string_view key); private: Db& db_; }; } // namespace velox::daemon::store