Repository navigation
refactor(query): share terminal unit request wiring (#2177) - #2225
Conversation
Problem: daemon and MCP query-unit surfaces each parsed terminal expressions and built session-scope filters by hand before reaching the shared archive executor. What changed: add a QueryUnitRequest boundary in the archive query layer, route the MCP archive helper and daemon endpoint through it, and keep existing public parameters unchanged. Verification: nix develop --command devtools test tests/unit/core/test_query_unit_request.py tests/unit/daemon/test_web_reader.py -k 'query_units_endpoint' tests/unit/mcp/test_server_surfaces.py -k 'query_units_tool' -q; nix develop --command devtools verify --quick
|
Warning Review limit reached
More reviews will be available in 49 minutes and 10 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?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 credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. 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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughIntroduces a frozen ChangesQueryUnitRequest abstraction and caller migration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Problem: Polylogue.query_units still parsed terminal expressions and normalized session filters locally after the daemon and MCP paths moved to QueryUnitRequest. What changed: route the Python API facade through query_unit_request/query_unit_envelope and cover the API-style tuple filters accepted by the shared helper. Verification: nix develop --command devtools test tests/unit/core/test_query_unit_request.py tests/unit/api/test_facade_contracts.py -k 'query_units' tests/unit/daemon/test_web_reader.py -k 'query_units_endpoint' tests/unit/mcp/test_server_surfaces.py -k 'query_units_tool' -q; nix develop --command devtools verify --quick
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7849c5369e
ℹ️ 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".
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/unit/core/test_query_unit_request.py (1)
39-49: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winUse canonical session-filter shape in the prebuilt-filters test.
{"origin": ...}doesn’t match the normalized filter vocabulary used elsewhere ("origins"tuple). The identity assertion still passes, but this weakens contract coverage.Suggested test fixture adjustment
- filters = {"origin": "chatgpt-export"} + filters = {"origins": ("chatgpt-export",)}🤖 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/unit/core/test_query_unit_request.py` around lines 39 - 49, The filters variable in this test is using the non-canonical filter format with "origin" as a string value, but the normalized filter vocabulary elsewhere uses "origins" as a tuple. Update the filters dictionary assignment to use the canonical session-filter shape by changing from a single "origin" key to "origins" key with a tuple value instead of a string, ensuring consistent contract coverage across the test suite.
🤖 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.
Outside diff comments:
In `@tests/unit/core/test_query_unit_request.py`:
- Around line 39-49: The filters variable in this test is using the
non-canonical filter format with "origin" as a string value, but the normalized
filter vocabulary elsewhere uses "origins" as a tuple. Update the filters
dictionary assignment to use the canonical session-filter shape by changing from
a single "origin" key to "origins" key with a tuple value instead of a string,
ensuring consistent contract coverage across the test suite.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 97521bac-58a4-441e-b6a7-f88d390577e0
📒 Files selected for processing (5)
polylogue/archive/query/unit_results.pypolylogue/daemon/http.pypolylogue/mcp/archive_support.pypolylogue/mcp/server_tools.pytests/unit/core/test_query_unit_request.py
Problem: the new QueryUnitRequest test passed singular origin= but asserted the plural origins key. A review caught that the prior focused command had deselected the new test. What changed: assert the singular origin key for origin= and keep the separate origins= tuple coverage for API-style plural filters. Verification: nix develop --command devtools test tests/unit/core/test_query_unit_request.py -q; nix develop --command devtools test tests/unit/api/test_facade_contracts.py tests/unit/daemon/test_web_reader.py tests/unit/mcp/test_server_surfaces.py -k 'query_units or query_units_endpoint or query_units_tool' -q; nix develop --command devtools verify --quick
|
Addressed the Codex inline finding: Verified on the PR branch:
|
|
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 shared terminal query-unit request boundary in the archive query layer and routes the Python API, daemon, and MCP query-unit surfaces through it. Public parameters and payloads are unchanged; expression parsing, terminal-source rejection, session-scope normalization, and envelope execution now converge through
QueryUnitRequest.Problem
Polylogue.query_units(...),/api/query-units, and the MCPquery_unitstool all exposed the same terminal unit-query behavior, but each surface assembled the request independently before calling archive execution. That kept expression parsing, session-scope filter normalization, and envelope execution split across surface code instead of owned by the query substrate.Solution
QueryUnitRequest,query_unit_request(), andquery_unit_envelope()inpolylogue/archive/query/unit_results.py.polylogue/mcp/archive_support.py::archive_query_unit_payload()as the MCP helper, but made it delegate to the shared archive request boundary.polylogue/api/archive.py::query_units,polylogue/mcp/server_tools.py::query_units, andpolylogue/daemon/http.py::_handle_query_unitsso they pass surface parameters into the shared request builder.tests/unit/core/test_query_unit_request.py; existing API, daemon, and MCP query-unit tests continue to prove cross-surface behavior.Verification
nix develop --command devtools test tests/unit/core/test_query_unit_request.py tests/unit/api/test_facade_contracts.py -k 'query_units' tests/unit/daemon/test_web_reader.py -k 'query_units_endpoint' tests/unit/mcp/test_server_surfaces.py -k 'query_units_tool' -q→7 passed, 420 deselectednix develop --command devtools verify --quick→exit_code: 0devtools verify --quick→exit_code: 0Ref #2177