Skip to content

controller: stitch planner per-metric output into emitter's metric_to_family map - #342

Merged
zzylol merged 1 commit into
mainfrom
mvp/stitch-planner-to-5sketch-emitter
May 8, 2026
Merged

zzylol merged 1 commit into
mainfrom
mvp/stitch-planner-to-5sketch-emitter

Conversation

@zzylol

@zzylol zzylol commented May 8, 2026

Copy link
Copy Markdown
Contributor

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_family walks the workload registry, runs bind_workload_typed per metric, collects committed sketch families into the HashMap. Raw passthrough / multi-intent metrics that decline binding are skipped — the emitter routes those to metrics/raw_passthrough by default.

Wired into both main::emit_bootstrap_typed and replan::Replanner::try_emit_typed_edge_yaml_for_workload so bootstrap GET + OpAMP-on-connect + replan all pick up the typed routing.

Test plan

  • cargo test -p controller — all green
  • New api_tests::bootstrap_emits_5sketch_routing_for_six_contract_metrics test loads all 6 MVP contract metrics, hits bootstrap GET, asserts emitted YAML contains 5 sketch processors + routing under connectors: + 6 named pipelines + route() where metric.name == "..." rule per sketched metric

Refs: #46, builds on #339 + #340.

🤖 Generated with Claude Code

…_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>
@zzylol
zzylol merged commit 791d6d2 into main May 8, 2026
@zzylol
zzylol deleted the mvp/stitch-planner-to-5sketch-emitter branch May 9, 2026 18:00
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