Skip to content

feat(routing): allow tuning classifier weights via grob_configure (T-P5a)#268

Merged
Destynova2 merged 1 commit intomainfrom
feat/classifier-config-section
Apr 25, 2026
Merged

feat(routing): allow tuning classifier weights via grob_configure (T-P5a)#268
Destynova2 merged 1 commit intomainfrom
feat/classifier-config-section

Conversation

@Destynova2
Copy link
Copy Markdown
Contributor

Summary

  • Adds `Classifier` variant to `ConfigSection` so MCP clients can read and update `[classifier.weights]` (5 signals) and `[classifier.thresholds]` (2 tier boundaries) at runtime.
  • Hot-reload reuses the existing `config_guard::reload_state()` pipeline — `Router::new(config)` rebuilds the scorer, in-flight requests continue on the old snapshot.
  • Unblocks the auto-tune MCP tool (T-P5b).

Whitelisted keys

  • `weights.max_tokens`, `weights.tools`, `weights.context_size`, `weights.keywords`, `weights.system_prompt` (f32)
  • `thresholds.medium_threshold`, `thresholds.complex_threshold` (f32)

Other keys → `unknown classifier key: `. The deny-list (anything containing `api_key`) still blocks credential-shaped names.

Files changed

  • `src/features/mcp/server/types.rs` — `ConfigSection::Classifier` variant + `Display`
  • `src/server/mcp_handlers.rs` — `read_config_section` + `apply_config_update` branches; tool description JSON updated; `tools/list` JSON enum extended; `wizard_get_config` includes classifier
  • `src/server/config_guard.rs` — exhaustive match arm

Test plan

  • `cargo check --lib` clean
  • `cargo clippy --lib --tests -- -D warnings` clean
  • `cargo test server::mcp_handlers::tests::test_configure_` — 23 passed (4 new for classifier)
  • All prek pre-commit + pre-push hooks green
  • CI green (auto-merge enabled below)

Example MCP call

```json
{
"method": "grob_configure",
"params": {
"action": "update",
"section": "classifier",
"key": "weights.tools",
"value": 5.0
}
}
```

…P5a)

Adds a `Classifier` variant to `ConfigSection` so MCP clients can read
and update the [classifier.weights] (5 signals) and [classifier.thresholds]
(2 tier boundaries) sections at runtime. Hot-reload reuses the existing
`config_guard::reload_state()` pipeline — no extra plumbing.

Whitelisted keys:
- weights.{max_tokens,tools,context_size,keywords,system_prompt}
- thresholds.{medium_threshold,complex_threshold}

Other keys are rejected with `unknown classifier key`. The existing
`is_key_denied` deny-list still blocks anything containing `api_key`.

Unblocks the auto-tune MCP tool (T-P5b) which will batch-suggest weight
patches based on observed metrics.
@Destynova2 Destynova2 enabled auto-merge April 25, 2026 18:26
@Destynova2 Destynova2 merged commit e111873 into main Apr 25, 2026
42 checks passed
@Destynova2 Destynova2 deleted the feat/classifier-config-section branch April 25, 2026 18:33
Destynova2 pushed a commit that referenced this pull request Apr 25, 2026
…bration (T-P5b)

Closes the Phase P routing-intelligence work. Pairs with the
ConfigSection::Classifier work (T-P5a, #268) by exposing a higher-level
MCP surface dedicated to classifier tuning.

Two actions:

- action=suggest — returns the seven classifier weights/thresholds
  (5 weights + 2 tier thresholds) as TuneSuggestion entries. The MVP
  reports the current values with proposed == current; future
  revisions will infer patches from observed traffic. Operators can
  still iterate manually using the rationale field as a placeholder.

- action=apply — accepts a list of {key, value} patches and persists
  them via the existing config_guard::persist_and_reload pipeline.
  This is sugar over batching multiple grob_configure calls into one
  MCP round-trip; the same deny-list (api_key, providers, dlp) and
  whitelist (weights.*, thresholds.*) apply.

Files:
- src/routing/classify/autotune.rs — new module with TuneSuggestion,
  AutotunePatch, current_snapshot() + 4 unit tests.
- src/routing/classify/mod.rs — registers the autotune module.
- src/server/mcp_handlers.rs — handle_autotune handler, dispatch
  registration, tool description in tools/list.

The implementation is intentionally minimal: it ships the surface
without speculating on the inference strategy. See
docs/how-to/auto-tune-routing.md for the manual tuning workflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant