controller: stitch planner per-metric output into emitter's metric_to_family map - #342
Merged
Merged
Conversation
…_family map (#46) PR #339 (planner: per-metric SketchExpr) and PR #340 (emitter: metric_to_family-driven 5-sketch routing) landed in parallel, but nothing populated `EdgeStageConfig.metric_to_family`, so the new routing-connector wire path stayed dormant — every bootstrap and OpAMP-push emitted single-pipeline DDSketch even with the six contract metrics declared in `workloads.yaml`. This stitches them: a new `config::collect_metric_to_family` walks the workload registry, runs `bind_workload_typed` per metric, and collects committed sketch families into the HashMap. Metrics that decline binding (`http_requests_total` raw passthrough, exact-required, multi-intent) are skipped — the emitter routes those to `metrics/raw_passthrough` by default. Wired into both: * `main::emit_bootstrap_typed` — also generalised the candidate resolution so a registry whose first agent-role entry is raw (e.g. `http_requests_total`) walks to the next binding metric for the edge_cfg shape rather than falling back to legacy. * `replan::Replanner::try_emit_typed_edge_yaml_for_workload` — same stitch so OpAMP-pushed YAML on reconnect / replan also activates the routing connector. Acceptance test (`api_tests::bootstrap_emits_5sketch_routing_for_six_contract_metrics`): loads all six MVP §46 contract metrics into the registry, hits the bootstrap GET endpoint with `USE_TYPED_STAGE_SPLIT=1`, and asserts the emitted YAML contains all 5 sketch processors, `routing` under `connectors:` (not `processors:`), all 6 named pipelines, and a `route() where metric.name == "..."` rule for each sketched metric. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stitches PR #339 (planner per-metric SketchExpr) to PR #340 (emitter
metric_to_family-driven 5-sketch routing). Without this, the new routing-connector wire path stayed dormant — every bootstrap and OpAMP-push emitted single-pipeline DDSketch even with the six MVP §46 contract metrics declared.New helper
config::collect_metric_to_familywalks the workload registry, runsbind_workload_typedper metric, collects committed sketch families into the HashMap. Raw passthrough / multi-intent metrics that decline binding are skipped — the emitter routes those tometrics/raw_passthroughby default.Wired into both
main::emit_bootstrap_typedandreplan::Replanner::try_emit_typed_edge_yaml_for_workloadso bootstrap GET + OpAMP-on-connect + replan all pick up the typed routing.Test plan
cargo test -p controller— all greenapi_tests::bootstrap_emits_5sketch_routing_for_six_contract_metricstest loads all 6 MVP contract metrics, hits bootstrap GET, asserts emitted YAML contains 5 sketch processors +routingunderconnectors:+ 6 named pipelines +route() where metric.name == "..."rule per sketched metricRefs: #46, builds on #339 + #340.
🤖 Generated with Claude Code