Repository navigation
feat(insights): add session latency profiles - #1539
Conversation
Problem: session insight surfaces exposed workflow shape and terminal state, but still lacked a durable read model for runtime latency, stuck tool calls, and response-gap signals. The live-read plan for #1530 needs those signals materialized through the same convergence paths as session profiles, not recomputed ad hoc from raw provider events. What changed: add session latency facts, a v12 session_latency_profiles table, sync/async rebuild and incremental-refresh writes, repository/API/operations readers, MCP tools for latency profiles/distributions/stuck sessions, and a dedicated latency readiness flag in session-insight status/repair. Document the construct boundary and refresh generated topology/MCP witness artifacts. Verification: pytest tests/unit/core/test_semantic_facts.py tests/unit/storage/test_session_insight_refresh.py tests/unit/storage/test_session_insight_status_descriptors.py tests/unit/storage/test_repair.py tests/unit/storage/test_derived_status.py tests/unit/storage/test_dead_schema_sweep.py tests/unit/mcp/test_insight_shape_tools.py tests/unit/insights/test_fallback_markers.py::test_profile_inference_payload_serializes_fallback_reasons tests/unit/mcp/test_envelope_contracts.py::TestRegistryWideClassification tests/unit/api/test_facade_contracts.py::test_no_undiscovered_async_methods tests/unit/mcp/test_tool_schema_witness.py::test_mcp_tool_catalog_matches_witness -q -> 92 passed. Exact reruns for broad-suite flakes passed: tests/unit/sources/test_parsers_props.py::test_provider_parser_contract[gemini] and tests/unit/ui/test_tui.py::test_browser_node_selection. devtools render-all --check -> OK. devtools verify --quick -> PASS in 36.57s. A widened devtools verify run executed pytest --testmon-noselect and failed before these contract/witness fixes plus two independently passing flaky nodes; not repeated to avoid another broad 5-minute run. Ref #1530
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (38)
📝 WalkthroughWalkthroughThis PR introduces a comprehensive per-session latency profiling system that materializes tool-call durations, stuck-tool counts, and user/agent response latencies. The implementation spans core computation, archive insight models, storage schema, database operations, API/MCP exposure, and extensive test coverage with a full schema version upgrade from 11 to 12. ChangesSession Latency Profile Insights
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0cfb41dd7d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Adds a durable session-latency read model for #1530. The new
session_latency_profilestable materializes provider tool-call latency, stuck unpaired tool starts, agent/user response-gap aggregates, and tool category counts through the same rebuild and incremental-refresh paths as session profiles.Problem
The insights sprint had workflow-shape and terminal-state primitives, but no durable runtime-latency surface. Computing this ad hoc from raw provider events would make MCP/API reads expensive and would leave daemon catch-up unable to converge the read model incrementally. Also, gating latency reads on generic profile readiness would allow stale or missing latency rows to be served silently.
Solution
polylogue/archive/semantic/timing.py.session_latency_profilesplus sync/async storage write/read helpers.latency_profile_rows_readyto session insight status/repair and made latency API reads require it.session_latency_profile,tool_call_latency_distribution, andfind_stuck_sessions.Verification
pytest tests/unit/core/test_semantic_facts.py tests/unit/storage/test_session_insight_refresh.py tests/unit/storage/test_session_insight_status_descriptors.py tests/unit/storage/test_repair.py tests/unit/storage/test_derived_status.py tests/unit/storage/test_dead_schema_sweep.py tests/unit/mcp/test_insight_shape_tools.py tests/unit/insights/test_fallback_markers.py::test_profile_inference_payload_serializes_fallback_reasons tests/unit/mcp/test_envelope_contracts.py::TestRegistryWideClassification tests/unit/api/test_facade_contracts.py::test_no_undiscovered_async_methods tests/unit/mcp/test_tool_schema_witness.py::test_mcp_tool_catalog_matches_witness -q→ 92 passed.pytest 'tests/unit/sources/test_parsers_props.py::test_provider_parser_contract[gemini]' -q→ 1 passed;pytest tests/unit/ui/test_tui.py::test_browser_node_selection -q→ 1 passed.devtools render-all --check→ OK.devtools verify --quick→ PASS in 36.57s before commit and PASS in 34.86s from the pre-push hook on committed HEAD.devtools verifywidened topytest --testmon-noselectand ran 9,487 tests in 293.16s; it failed before the contract/witness fixes above plus the two exact-node flaky failures. I did not repeat the widened broad run after focused fixes to avoid another 5-minute full-suite-equivalent loop.Follow-up
Ref #1530. This PR intentionally does not close #1530 until a schema-v12 live archive rebuild produces real distribution stats and representative stuck-session hand checks.
Summary by CodeRabbit
Release Notes
New Features
Documentation