Files
loki/docs/testing/plans/01-config-and-appconfig.md
2026-04-15 12:56:00 -06:00

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_id defaults to first available model if empty (requires Config::init, integration test)
  • temperature, top_p default to None
  • stream defaults to true
  • save defaults to false (CORRECTED: was listed as true)
  • highlight defaults to true
  • dry_run defaults to false
  • function_calling_support defaults to true
  • mcp_server_support defaults to true
  • compression_threshold defaults to 4000
  • document_loaders populated from config and defaults (requires Config::init)
  • clients parsed from config (to_app_config_copies_clients)

AppConfig conversion

  • to_app_config() copies all serialized fields correctly
  • clients field populated on AppConfig
  • visible_tools correctly computed from enabled_tools config (deferred to plan 16)
  • mapping_tools correctly parsed
  • mapping_mcp_servers correctly parsed
  • user_agent resolved (auto → crate name/version)

RequestContext conversion

  • to_request_context() copies all runtime fields (to_request_context_creates_clean_state)
  • model field populated with resolved model (requires Model::retrieve_model)
  • working_mode set correctly (Repl vs Cmd)
  • tool_scope starts with default (empty)
  • agent_runtime starts as None

AppConfig field accessors

  • editor() returns configured editor or $EDITOR
  • light_theme() returns theme flag
  • render_options() returns options for markdown rendering
  • sync_models_url() returns configured or default URL

Dynamic config updates

  • update_app_config closure correctly clones and replaces Arc
  • Changes to dry_run, stream, save persist across calls
  • Changes visible to subsequent ctx.app.config reads

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.rsConfig struct, Config::init, defaults
  • src/config/bridge.rsto_app_config, to_request_context
  • src/config/app_config.rsAppConfig struct and methods