Skip to content

refactor(acp): centralize ACP session config wiring#1834

Merged
bug-ops merged 2 commits intomainfrom
refactor-acp-centralize-acp-se
Mar 15, 2026
Merged

refactor(acp): centralize ACP session config wiring#1834
bug-ops merged 2 commits intomainfrom
refactor-acp-centralize-acp-se

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 15, 2026

Closes #1812

Summary

  • Introduce AgentSessionConfig in zeph-core with from_config(&Config, budget_tokens) — single constructor mapping all 25 config-derived fields
  • Add Agent::apply_session_config(cfg: AgentSessionConfig) — takes ownership and destructures by value (compile-time exhaustiveness on consumption side)
  • Replace ~25 individual builder calls in spawn_acp_agent, runner.rs, and daemon.rs with a single apply_session_config() call
  • Fix pre-existing correctness bug: daemon.rs was missing orchestration_config and server_compaction wiring
  • Replace hardcoded 0.20 with exported CONTEXT_BUDGET_RESERVE_RATIO constant

Any new field added to AgentConfig now requires exactly 3 edits (add field, map in from_config, apply in apply_session_config) vs the previous 6+ manual edits across 3 files. Compile-time enforcement prevents silent omissions.

Test plan

  • All 5793 tests pass (cargo nextest run --workspace --features full --lib --bins)
  • cargo clippy --workspace --features full -- -D warnings clean
  • cargo +nightly fmt --check clean
  • New tests: apply_session_config_wires_graph_orchestration_anomaly, apply_session_config_skips_anomaly_detector_when_disabled
  • 299/299 zeph-acp tests pass (existing behavior unchanged)
  • Security audit: no new attack surface, acp_auth_bearer_token stays in SharedAgentDeps

Introduce AgentSessionConfig with from_config() constructor and
Agent::apply_session_config() method that replaces ~25 individual
builder calls across spawn_acp_agent, runner.rs, and daemon.rs.

Any new field added to AgentConfig is now wired in one place and
propagated to all channels automatically, preventing feature drift.

- Add AgentSessionConfig struct with 25 config-derived fields
- Add AgentSessionConfig::from_config(&Config, budget_tokens) mapping all fields
- Add Agent::apply_session_config() destructuring by value for compile-time exhaustiveness
- Shrink SharedAgentDeps: replace 25 scalar fields with session_config
- Remove 60-line field-copy block from spawn_acp_agent
- Apply centralization to runner.rs and daemon.rs
- Fix daemon.rs missing orchestration_config and server_compaction wiring
- Replace hardcoded 0.20 with CONTEXT_BUDGET_RESERVE_RATIO constant
- Add tests: apply_session_config_wires_graph_orchestration_anomaly,
  apply_session_config_skips_anomaly_detector_when_disabled
@github-actions github-actions bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate refactor Code refactoring without functional changes size/XL Extra large PR (500+ lines) labels Mar 15, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 15, 2026 15:17
@bug-ops bug-ops merged commit 106edb9 into main Mar 15, 2026
15 checks passed
@bug-ops bug-ops deleted the refactor-acp-centralize-acp-se branch March 15, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation refactor Code refactoring without functional changes rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(acp): centralize ACP session config wiring to prevent feature drift

1 participant