Add 'metrics test' subcommand for testing metrics against simulation outputs#89
Conversation
📝 WalkthroughWalkthroughAdds a Changesmetrics test subcommand
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/cli_tests.rs (1)
3048-3111: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd an agent-mode assertion for the new follow-up actions.
These tests only cover plain stdout. Because
emit_one_with_actions()dropsnext_actionsunless agent mode is enabled, a regression in the newnext_actions::get("metrics", &args.metric_id)path would still pass here. Please add one--agentcase that asserts the primary action targetsmetrics get met_abc.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/cli_tests.rs` around lines 3048 - 3111, Add an agent-mode coverage case for metrics test so the new next_actions path is exercised. In test_metrics_test_subcommand (and/or the dev-id variant), add a run with --agent enabled and assert the emitted primary action points to metrics get met_abc, since emit_one_with_actions() only preserves next_actions in agent mode. Use the existing coval() CLI harness and the metrics::test flow to locate the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/cli_tests.rs`:
- Around line 3048-3111: Add an agent-mode coverage case for metrics test so the
new next_actions path is exercised. In test_metrics_test_subcommand (and/or the
dev-id variant), add a run with --agent enabled and assert the emitted primary
action points to metrics get met_abc, since emit_one_with_actions() only
preserves next_actions in agent mode. Use the existing coval() CLI harness and
the metrics::test flow to locate the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 59bb52f4-2415-4098-bfc2-9f44a944b322
📒 Files selected for processing (5)
src/agent_discovery.rssrc/client/mod.rssrc/client/models/metric.rssrc/commands/metrics.rstests/cli_tests.rs
Summary
Exposes the existing
POST /v1/metrics/{metric_id}/testAPI endpoint in the CLI, allowing users to test metrics against simulation outputs from the command line.Changes
Test(TestArgs)subcommand with--simulation-output-id(required) and--dev-id(optional) flagstest()method toMetricsClientthat POSTs to/v1/metrics/{id}/testTestMetricRequestandTestMetricResponsestructs"test"to the metrics command list for agent discoverytest_metrics_test_subcommandtestUsage
Testing
All 91 tests pass, clippy is clean.
Summary by CodeRabbit
New Features
metrics testcommand in the CLI for testing metrics.Bug Fixes
testcommand is recognized as a supported action.Tests
Greptile Summary
This PR exposes the
POST /v1/metrics/{metric_id}/testAPI endpoint through a newmetrics testsubcommand, wiring up request/response models, client method, CLI command, and tests in a style consistent with the rest of the codebase.Test(TestArgs)subcommand added toMetricCommandswith required--simulation-output-idand optional--dev-idflags; the handler builds aTestMetricRequest, calls the newMetricsClient::testmethod, and emits the response.TestMetricRequest/TestMetricResponsemodels added with correctSerialize/Deserializederives;dev_idis conditionally omitted viaskip_serializing_if = "Option::is_none".dev_idand with-dev_idpaths against a mock server returning a 202 response, confirming end-to-end serialization of both fields.Confidence Score: 5/5
Safe to merge — the change is an additive, well-scoped feature that follows established patterns throughout the codebase without modifying any existing behaviour.
All five touched files make straightforward, additive changes: a new subcommand with three small fields, a single new client method, two new model structs with correct derive attributes, and two integration tests that verify both the happy path and the optional --dev-id flag end-to-end. The 202 Accepted response from the API is handled correctly by the shared is_success() check. No existing logic is altered.
No files require special attention.
Important Files Changed
Sequence Diagram
%%{init: {'theme': 'neutral'}}%% sequenceDiagram participant User participant CLI as coval CLI participant Client as MetricsClient participant API as POST /v1/metrics/{id}/test User->>CLI: coval metrics test metric_id --simulation-output-id sim_output_id [--dev-id id] CLI->>CLI: Parse TestArgs, build TestMetricRequest CLI->>Client: "test(&metric_id, TestMetricRequest)" Client->>API: "POST /v1/metrics/{id}/test {simulation_output_id, dev_id?}" API-->>Client: "202 Accepted {metric_output_ulid}" Client-->>CLI: TestMetricResponse CLI->>User: emit_one_with_actions (metric_output_ulid + next actions)%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% sequenceDiagram participant User participant CLI as coval CLI participant Client as MetricsClient participant API as POST /v1/metrics/{id}/test User->>CLI: coval metrics test metric_id --simulation-output-id sim_output_id [--dev-id id] CLI->>CLI: Parse TestArgs, build TestMetricRequest CLI->>Client: "test(&metric_id, TestMetricRequest)" Client->>API: "POST /v1/metrics/{id}/test {simulation_output_id, dev_id?}" API-->>Client: "202 Accepted {metric_output_ulid}" Client-->>CLI: TestMetricResponse CLI->>User: emit_one_with_actions (metric_output_ulid + next actions)Reviews (3): Last reviewed commit: "Fix review: next_actions point at metric..." | Re-trigger Greptile