Repository navigation
feat(telemetry): bounded route-latency observation, wired to status routes - #3140
Conversation
…outes Problem: polylogue-jtwu names one unified route-observation contract (CLI/HTTP/query/convergence/embed/SQL/web instrumented with shared request/run/parent ids, projected into p50/p95 analysis, histograms, and slow-request traces) as the interactive-latency epic's remaining executable slice, but nothing reads the ops-tier telemetry that already exists (mcp_call_log, query_runs) -- list_mcp_calls/list_otlp_spans are defined and never called anywhere. Separately, polylogue-20d.17's AC #4 wants randomized CLI/MCP status sampling with per-component timing and product budgets set from measured distributions, and had no substrate at all. Scope decision (recorded on both beads): jtwu's own AC #1 wants literal write-path unification across every route including HTTP, query, and embed/convergence work. Two things make that unsafe to attempt whole in one pass: jtwu's own stated dependency (polylogue-1xc.14, WorkloadReceipt) is itself still open, and this lane's own prompt explicitly excludes daemon/http.py (Lane E's active six-tool/webui-v2 territory this cycle; confirmed still hot via `git log` on that file before starting). This lands the genuinely new coverage that needed none of that: CLI invocation and MCP sub-route detail. query_runs/mcp_call_log stay separate, federated at the read layer rather than migrated -- named explicitly as remaining jtwu scope, not silently dropped. What changed: - New ops-tier table `route_observations` (polylogue/storage/sqlite/ archive_tiers/ops.py) -- disposable, additive DDL, no migration needed (ops.db reapplies its DDL idempotently on every same-version open). Bounded by both a 7-day retention window and a 20k-row cap, mirroring mcp_call_log's existing retention pattern. - polylogue/operations/route_observation.py: `observe_route()`, a context manager that times a block and records a best-effort receipt (never raises on telemetry failure, never blocks the operation being observed -- a missing archive or locked ops.db just drops the observation). `compute_latency_percentiles()` federates route_observations with mcp_call_log into grouped p50/p95 buckets, flagging any bucket under 5 samples as low_confidence rather than presenting an unreliable percentile as a real budget number. - Wired into three call sites: the MCP six-tool status(scope=coordination) handler (records archive-evidence-degraded state from the envelope's own advisories), `polylogue agents <view>` (all coordination CLI views), and `polylogue status` (records daemon-reachable vs direct fallback). - New `polylogue analyze latency` CLI command reads and renders the federated p50/p95 view. - New benchmark tests/benchmarks/test_cli_cold_start.py backs a new informational `cli_status_cold` SLO row: measured baseline p50 ~1.80s (5 rounds), which is polylogue-8s70's own cProfile finding restated as a runnable number instead of a one-off manual measurement -- the row's target (500/800ms) is the aspirational post-8s70-fix budget, not today's passing bar. Verification: devtools test tests/unit/operations/test_route_observation.py tests/unit/storage/test_archive_tiers_ops_write.py tests/unit/cli/test_status.py tests/unit/cli/test_status_diagnostics.py tests/unit/cli/commands/test_status.py tests/unit/cli/test_agents_command.py tests/unit/mcp/test_status_scope_coordination.py: 202 passed. tests/unit/cli/test_diagnostics.py -k latency: 3 passed (the file's other 8 test_tools_* failures are pre-existing and unrelated -- confirmed via git stash comparison against the same baseline before this change). Manual end-to-end proof: real CLI invocations against an initialized-but-empty archive produced real route_observations rows that `analyze latency` then read back with correct p50/p95. mypy --strict across all 12 touched/added source files: clean. devtools verify --quick: exit 0 (required adding record_route_observation to docs/plans/layering.yaml's ops_write.py entrypoint declaration, and tests/unit/cli/test_diagnostics.py to docs/plans/test-clock-allowlist.yaml for its --since-hours-window fixture construction, which legitimately reads real wall time to match the production command's own time.time() usage). Ref polylogue-jtwu, polylogue-20d.17
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
Next review available in: 11 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (18)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Lands the genuinely-new-coverage slice of polylogue-jtwu (route-latency observation) and closes polylogue-20d.17's AC #4 (randomized CLI/MCP status sampling with per-component timing, product budgets from measured distributions).
Problem
mcp_call_log,query_runs) has no reader at all —list_mcp_calls/list_otlp_spansare defined and never called anywhere in the codebase.Scope decision (recorded on both beads)
jtwu's own AC #1 wants literal write-path unification across every route including HTTP, query, and embed/convergence work. Two things make attempting that whole in one pass unsafe:
daemon/http.py(Lane E's active six-tool/webui-v2 territory this cycle — confirmed still hot viagit logon that file before starting: most recent touch was hours before this PR).This PR lands the genuinely new coverage that needed neither: CLI invocation and MCP sub-route detail.
query_runs/mcp_call_logstay separate, federated at the read layer rather than migrated — named explicitly as remaining jtwu scope in the bead notes, not silently dropped.Solution
route_observations(disposable, additive DDL —ops.dbreapplies its DDL idempotently, no migration needed). Bounded by a 7-day retention window and a 20k-row cap, mirroringmcp_call_log's existing pattern.polylogue/operations/route_observation.py:observe_route()— a context manager that times a block and records a best-effort receipt (never raises on telemetry failure, never blocks the operation being observed).compute_latency_percentiles()federatesroute_observationswithmcp_call_loginto grouped p50/p95 buckets, flagging buckets under 5 samples aslow_confidencerather than presenting an unreliable percentile as a real budget number.status(scope=coordination)handler (records archive-evidence-degraded state from the envelope's own advisories),polylogue agents <view>(all coordination CLI views), andpolylogue status(records daemon-reachable vs direct fallback).polylogue analyze latencyCLI command reads and renders the federated p50/p95 view.tests/benchmarks/test_cli_cold_start.pybacks a new informationalcli_status_coldSLO row: measured baseline p50 ~1.80s (5 rounds) — this is polylogue-8s70's own cProfile finding restated as a runnable number instead of a one-off manual measurement. The row's target (500/800ms) is the aspirational post-8s70-fix budget, not today's passing bar.Verification
devtools test tests/unit/operations/test_route_observation.py tests/unit/storage/test_archive_tiers_ops_write.py tests/unit/cli/test_status.py tests/unit/cli/test_status_diagnostics.py tests/unit/cli/commands/test_status.py tests/unit/cli/test_agents_command.py tests/unit/mcp/test_status_scope_coordination.py— 202 passed.tests/unit/cli/test_diagnostics.py -k latency— 3 passed (the file's other 8test_tools_*failures are pre-existing and unrelated — confirmed viagit stashcomparison against the same baseline before this change).route_observationsrows thatanalyze latencythen read back with correct p50/p95.mypy --strictacross all touched/added source files — clean.devtools verify --quick— exit 0 (required addingrecord_route_observationtodocs/plans/layering.yaml'sops_write.pyentrypoint declaration, andtests/unit/cli/test_diagnostics.pytodocs/plans/test-clock-allowlist.yamlfor its--since-hourswindow fixture construction, which legitimately reads real wall time to match the production command's owntime.time()usage).Ref polylogue-jtwu, polylogue-20d.17