Skip to content

feat(telemetry): bounded route-latency observation, wired to status routes - #3140

Merged
Sinity merged 1 commit into
masterfrom
feature/perf/snappy-surfaces
Jul 18, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/perf/snappy-surfaces

Conversation

@Sinity

@Sinity Sinity commented Jul 18, 2026

Copy link
Copy Markdown
Owner

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

  • jtwu wants one unified route-observation contract projected into p50/p95 analysis, but the ops-tier telemetry that already exists (mcp_call_log, query_runs) has no reader at all — list_mcp_calls/list_otlp_spans are defined and never called anywhere in the codebase.
  • 20d.17's AC refactor: split CLI into command modules and add HTML preview output #4 wants randomized CLI/MCP status sampling with per-component timing and budgets set from measured distributions — no substrate existed for this.

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:

  • jtwu's own stated dependency (polylogue-1xc.14, WorkloadReceipt) is itself still open.
  • 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: 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_log stay separate, federated at the read layer rather than migrated — named explicitly as remaining jtwu scope in the bead notes, not silently dropped.

Solution

  • New ops-tier table route_observations (disposable, additive DDL — ops.db reapplies its DDL idempotently, no migration needed). Bounded by a 7-day retention window and a 20k-row cap, mirroring mcp_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() federates route_observations with mcp_call_log into grouped p50/p95 buckets, flagging buckets 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) — 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 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 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

…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
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 11 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5c5737c5-57ff-4116-bfa2-6adadeb78708

📥 Commits

Reviewing files that changed from the base of the PR and between bce1faa and 638cf8a.

📒 Files selected for processing (18)
  • docs/cli-reference.md
  • docs/plans/layering.yaml
  • docs/plans/slo-catalog.yaml
  • docs/plans/test-clock-allowlist.yaml
  • docs/plans/topology-target.yaml
  • docs/topology-status.md
  • polylogue/cli/commands/agents.py
  • polylogue/cli/commands/diagnostics.py
  • polylogue/cli/commands/status.py
  • polylogue/cli/query_verbs.py
  • polylogue/mcp/server_cutover.py
  • polylogue/operations/route_observation.py
  • polylogue/storage/sqlite/archive_tiers/ops.py
  • polylogue/storage/sqlite/archive_tiers/ops_write.py
  • tests/benchmarks/test_cli_cold_start.py
  • tests/unit/cli/test_diagnostics.py
  • tests/unit/operations/test_route_observation.py
  • tests/unit/storage/test_archive_tiers_ops_write.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/perf/snappy-surfaces

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Sinity
Sinity merged commit 86ca328 into master Jul 18, 2026
3 checks passed
@Sinity
Sinity deleted the feature/perf/snappy-surfaces branch July 18, 2026 23:11
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