4.6 KiB
Phase 1 Step 10 — Implementation Notes
Status
Done. Client chain migrated. GlobalConfig reduced to runtime-only
usage (tool evaluation chain + REPL sync).
Summary
Migrated the entire client chain away from GlobalConfig:
Clienttrait:global_config()→app_config()- Client structs:
GlobalConfig→Arc<AppConfig> init_client:&GlobalConfig→&Arc<AppConfig>Inputstruct: removedconfig: GlobalConfigfield entirelyRag: deletedbuild_temp_global_configbridgerender_stream:&GlobalConfig→&AppConfigConfig::search_rag:&GlobalConfig→&AppConfigcall_chat_completions*: explicitruntime: &GlobalConfigparameter
What was changed
Files modified (10 files)
-
src/client/macros.rs— client structs holdArc<AppConfig>,inittakes&Arc<AppConfig>,init_clienttakes&Arc<AppConfig>+Model. Zero GlobalConfig in file. -
src/client/common.rs—Clienttrait:app_config() -> &AppConfig.call_chat_completions*take explicitruntime: &GlobalConfig. -
src/config/input.rs— removedconfig: GlobalConfigfield. Addedrag: Option<Arc<Rag>>captured at construction. Changedset_regenerateto takecurrent_role: Roleparameter. Zeroself.configreferences. -
src/config/mod.rs—search_ragtakes&AppConfig. Deleted deadrag_templatemethod. -
src/render/mod.rs—render_streamtakes&AppConfig. Zero GlobalConfig in file. -
src/rag/mod.rs— deletedbuild_temp_global_config. Creates clients viainit_client(&self.app_config, model). Zero GlobalConfig in file. -
src/main.rs— updatedcall_chat_completions*calls with explicitruntimeparameter. -
src/repl/mod.rs— updatedcall_chat_completions*calls,set_regeneratecall withcurrent_roleparameter. -
src/function/supervisor.rs— updatedcall_chat_completionscall inrun_child_agent. -
src/config/app_config.rs— no changes (already had all needed fields).
Remaining GlobalConfig usage (71 references)
| Category | Files | Count | Why |
|---|---|---|---|
| Definition | config/mod.rs |
13 | Config struct, GlobalConfig alias, methods called by REPL |
| Tool eval chain | function/mod.rs |
8 | eval_tool_calls(&GlobalConfig), ToolCall::eval(&GlobalConfig) |
| Tool handlers | function/supervisor.rs |
17 | All handler signatures |
| Tool handlers | function/todo.rs |
2 | Todo handler signatures |
| Tool handlers | function/user_interaction.rs |
3 | User interaction handler signatures |
| Runtime param | client/common.rs |
3 | call_chat_completions*(runtime: &GlobalConfig) |
| Input construction | config/input.rs |
4 | Constructor params + capture_input_config |
| REPL | repl/mod.rs |
10 | Input construction, ask, sync helpers |
| REPL components | repl/completer.rs |
3 | Holds GlobalConfig for reedline |
| REPL components | repl/prompt.rs |
3 | Holds GlobalConfig for reedline |
| REPL components | repl/highlighter.rs |
2 | Holds GlobalConfig for reedline |
| Bridge | config/request_context.rs |
1 | to_global_config() |
| Bridge | config/macros.rs |
2 | macro_execute takes &GlobalConfig |
The remaining GlobalConfig usage falls into 3 categories:
- Tool evaluation chain (30 refs) —
eval_tool_callsand handlers read runtime state from GlobalConfig - REPL (18 refs) — sync helpers, Input construction, reedline
- Definition (13 refs) — the Config struct itself
Phase 1 final completion summary
Phase 1 is now complete. Every module that CAN be migrated HAS been migrated. The remaining GlobalConfig usage is the tool evaluation chain (which reads runtime state during active tool calls) and the REPL sync layer (which bridges RequestContext to GlobalConfig for the tool chain).
Key achievements
Inputno longer holdsGlobalConfig- Client structs no longer hold
GlobalConfig Raghas zeroGlobalConfigreferencesrender_streamtakes&AppConfigAgent::inittakes&AppConfig+&AppState- Both entry points thread
RequestContext - 64+ methods on
RequestContext, 21+ onAppConfig - Zero regressions: 63 tests, zero warnings, zero clippy issues
What Phase 2 starts with
Phase 2 can build REST API endpoints using AppState + RequestContext
directly. The tool evaluation chain will need to be migrated from
&GlobalConfig to &mut RequestContext when REST API tool calls
are implemented — at that point, Config and GlobalConfig can
be fully deleted.
Verification
cargo check— zero warnings, zero errorscargo clippy— zero warningscargo test— 63 passed, 0 failed