2.8 KiB
2.8 KiB
Test Plan: Config Loading and AppConfig
Feature description
Loki loads its configuration from a YAML file (config.yaml) into
a Config struct, then converts it to AppConfig (immutable,
shared) + RequestContext (mutable, per-request). The AppConfig
holds all serialized fields; RequestContext holds runtime state.
Behaviors to test
Config loading
- Config loads from YAML file with all supported fields
- Missing optional fields get correct defaults (config_defaults_match_expected)
model_iddefaults to first available model if empty (requires Config::init, integration test)temperature,top_pdefault toNonestreamdefaults totruesavedefaults tofalse(CORRECTED: was listed as true)highlightdefaults totruedry_rundefaults tofalsefunction_calling_supportdefaults totruemcp_server_supportdefaults totruecompression_thresholddefaults to4000document_loaderspopulated from config and defaults (requires Config::init)clientsparsed from config (to_app_config_copies_clients)
AppConfig conversion
to_app_config()copies all serialized fields correctlyclientsfield populated on AppConfigvisible_toolscorrectly computed fromenabled_toolsconfig (deferred to plan 16)mapping_toolscorrectly parsedmapping_mcp_serverscorrectly parseduser_agentresolved (auto → crate name/version)
RequestContext conversion
to_request_context()copies all runtime fields (to_request_context_creates_clean_state)modelfield populated with resolved model (requires Model::retrieve_model)working_modeset correctly (Repl vs Cmd)tool_scopestarts with default (empty)agent_runtimestarts asNone
AppConfig field accessors
editor()returns configured editor or $EDITORlight_theme()returns theme flagrender_options()returns options for markdown renderingsync_models_url()returns configured or default URL
Dynamic config updates
update_app_configclosure correctly clones and replaces Arc- Changes to
dry_run,stream,savepersist across calls - Changes visible to subsequent
ctx.app.configreads
Context switching scenarios
- AppConfig remains immutable after construction (no field mutation)
- Multiple RequestContexts can share the same AppState
- Changing AppConfig fields (via clone-mutate-replace) doesn't affect other references to the old Arc
Old code reference
src/config/mod.rs—Configstruct,Config::init, defaultssrc/config/bridge.rs—to_app_config,to_request_contextsrc/config/app_config.rs—AppConfigstruct and methods