Skip to content

SP-5/SP-8: EMA cost model, dynamic scraper, backend delivery - #81

Closed
zzylol wants to merge 1 commit into
controllerfrom
controller-runtime
Closed

zzylol wants to merge 1 commit into
controllerfrom
controller-runtime

Conversation

@zzylol

@zzylol zzylol commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • SP-5 EMA cost model: online_cost_model wired into CostModelPlanner via with_online_store(). Scoring now uses a live-blended cost table (70 % online / 30 % benchmark after 5+ observations) instead of static benchmarks, so the planner converges toward real-world behaviour over time.
  • SP-8 feedback loop: Scraper gains dynamic endpoint management (add_endpoint, remove_endpoint, set_sketch_type) backed by Arc<RwLock<Vec<Endpoint>>>. New on_metrics callback delivers ScrapedData (sketch_size_bytes + derived cpu_micros_per_sample) to the EMA store after each successful scrape.
  • OpAMP role tracking: X-Agent-Role: agent|backend header distinguishes edge collectors from aggregation backends. push_to_role() delivers role-appropriate configs: agent YAML to Agent role, backend YAML to Backend role. on_connect/on_disconnect hooks auto-register/deregister scrape endpoints.
  • main.rs wiring: initialise EMA store → build Scraper with EMA callback → build OpampServer with connect/disconnect hooks → CostModelPlanner::with_online_store → start scraper background loop. After each plan: push agent config to agent-role collectors, backend config to backend-role collectors, update endpoint sketch types for EMA attribution.

Test plan

  • cargo test — all 128 tests pass
  • monitor — 8 tests including new on_metrics_callback_fires and add_remove_endpoint
  • opamp — role parsing, push_to_role, connect/disconnect
  • planner::online_cost_model — EMA blending, store init, effective_table fallback
  • All existing cost model, delta cost model, query parser, analyzer, config, and store tests continue to pass

🤖 Generated with Claude Code

…delivery (#80)

- SP-5 (online_cost_model): expose OnlineMetricsStore from planner; wire into
  CostModelPlanner via with_online_store() so scoring uses EMA-blended costs
- SP-8 (feedback loop): Scraper gains dynamic add/remove/set_sketch_type
  endpoints backed by Arc<RwLock<>>; new on_metrics callback feeds observed
  bandwidth + CPU/sample deltas into the EMA store after each scrape
- OpAMP role tracking: X-Agent-Role header distinguishes agent vs backend
  collectors; push_to_role() delivers role-appropriate configs; on_connect /
  on_disconnect callbacks register/deregister scrape endpoints automatically
- main.rs: initialise EMA store, wire Scraper + OpAMP callbacks, start scraper
  background loop, push agent config to Agent-role and backend config to
  Backend-role collectors on every plan

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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