Skip to content

feat(search): make ranked results explainable and pagination-stable #873

Closed

Description

@Sinity

Problem

Polylogue has basic FTS search hits, snippets, hybrid retrieval, and reader/search surfaces, but ranking/result explainability is not yet a stable shared contract.

Current gaps:

  • query/list/search surfaces do not share one ranked result envelope;
  • hit payloads expose rank/lane/surface/snippet/score but not why-this-matched details;
  • hybrid RRF lane contributions are discarded before surfaces;
  • default date sorting can silently replace ranked search order in non-hit paths;
  • pagination is inconsistent after ranked/filter paths;
  • daemon facets are currently global-style stats rather than scoped query facets;
  • docs risk overstating query syntax and hybrid/auto semantics.

#859 owns the shared read/query/status envelope spine. This issue owns rank semantics, evidence, snippets/highlights, scoped facets, and stable ranked pagination.

Scope

Define canonical ranked search behavior and payloads:

  • ranked result envelope: hits, total or unknown-total, limit, offset/cursor, next marker, query, sort, retrieval lane, ranking policy/version;
  • per-hit explanation payload: matched terms, match surface, evidence IDs, snippet/highlights, score components, lane rank, lane contribution, and raw-score semantics;
  • explicit semantics for dialogue, actions, hybrid, and semantic/vector paths;
  • hybrid RRF explanation that preserves lane ranks/contributions rather than only saying hybrid;
  • stable ranked pagination after filters/ranking, preferably cursor/keyset over ranking policy plus tie-breakers where offset is unsafe;
  • scoped versus global facet counts, with scoped counts computed against the current query/filter set;
  • CLI JSON, MCP, API, and daemon payloads aligned with refactor(api): define shared query/status contracts for all read surfaces #859.

Likely files/modules:

  • polylogue/archive/query/spec.py
  • polylogue/archive/query/plan.py
  • polylogue/archive/query/plan_execution.py
  • polylogue/archive/query/retrieval_search.py
  • polylogue/archive/query/search_hits.py
  • polylogue/archive/query/sorting.py
  • polylogue/storage/search/query_builders.py
  • polylogue/storage/sqlite/queries/conversations_search.py
  • polylogue/storage/search/models.py
  • polylogue/storage/search_providers/hybrid.py
  • polylogue/surfaces/payloads.py
  • polylogue/mcp/server_tools.py
  • polylogue/mcp/payloads.py
  • polylogue/cli/query.py
  • polylogue/cli/query_output.py
  • polylogue/daemon/http.py
  • docs/search.md

Non-goals

Dependencies

Acceptance criteria

  • Search/list ranked responses use one typed envelope across CLI JSON, MCP, API, and daemon where exposed.
  • Every ranked hit has deterministic why-this-matched evidence.
  • Search default ordering is rank-first unless the user explicitly chooses date or another sort.
  • dialogue, actions, hybrid, and semantic/vector paths have documented ranking behavior and tests.
  • Hybrid results expose lane ranks/contributions or another stable explanation of the fused rank.
  • Pagination is stable and applies after filters/ranking.
  • Facets declare whether counts are scoped or global, and scoped counts are available from the archive/query layer.
  • Docs match actual FTS/query syntax and result semantics.

Verification

Focused checks should include:

  • pytest tests/unit/archive/test_search_hits.py tests/unit/archive/test_query_search_runtime.py tests/unit/storage/test_fts5.py tests/unit/storage/test_hybrid.py -q
  • MCP contract tests when MCP payloads change;
  • CLI JSON/plain formatting tests when query output changes;
  • daemon HTTP tests when API list/search/facet payloads change;
  • devtools render-all --check when docs/generated surfaces change;
  • devtools verify --quick, then full devtools verify before PR readiness.

Agent traps:

Refs #859 #819 #848 #865 #860 #838 #817 #828 #829 #839 #864 #872 #852.

Activity

  1. added
    type:feat
    theme:command-surface
    area:core
    area:daemon
    on May 7, 2026
  2. Sinity commented on May 7, 2026

    @Sinity
    OwnerAuthor

    Reconnaissance Report: #873 ranked results explainable and pagination-stable

    Status: CANNOT START until #859 lands (shared read/query/status envelope spine). Can do architectural scoping of the ranked result envelope and per-hit explanation model now. Must coordinate closely with #859 and #819 for surface alignment.

    Build this

    1. Canonical ranked result envelope (extend polylogue/archive/query/spec.py or new polylogue/archive/query/ranked_result.py):

      • RankedResult[T]: items/hits (list[T]), total (int | None, None when unknown), limit (int | None), offset (int) or cursor (str | None), next_marker (str | None), query (str), sort (str), retrieval_lane (str), ranking_policy (str), ranking_policy_version (str).
      • This replaces the current ad-hoc {"hits": [...], "total": N} shapes in daemon HTTP, CLI output, MCP responses.
      • The field name debate (items vs hits) from refactor(api): define shared query/status contracts for all read surfaces #859 applies here. The issue body says "items or hits" — choose one and be consistent. Current code uses "hits" in daemon HTTP and "items" in some MCP paths. Adopt "hits" for search results (with evidence), keep "items" for non-search list results.
    2. Per-hit explanation payload (extend ConversationSearchHit in polylogue/archive/query/search_hits.py):
      Current fields: summary, rank, retrieval_lane, match_surface, message_id, snippet, score.
      Add:

      • matched_terms: tuple[str, ...] — which query terms matched
      • evidence_ids: tuple[str, ...] — message IDs or content block IDs that contributed to the match
      • score_components: dict[str, float] — breakdown of score (bm25, term_frequency, proximity, lane_bonus, etc.)
      • lane_rank: int | None — rank within the retrieval lane before fusion
      • lane_contribution: float | None — RRF contribution from this lane
      • raw_score: float | None — unnormalized score from the retrieval engine (e.g., raw BM25)
        Note: bm25 is lower-is-better in SQLite FTS5 (negative scores). Document this or normalize it before exposing to users.
    3. Hybrid RRF explanation (modify search_hybrid_results in polylogue/archive/query/retrieval_search.py):
      Currently: text_ranked, action_ranked, vector_ranked are computed, fused via RRF, then lane info is DISCARDED. Only the fused order is returned.
      Change: preserve per-lane ranks and contributions in each hit.

    4. Stable ranked pagination (modify polylogue/archive/query/sorting.py and plan execution):

      • Default ordering: sort field in ConversationQuerySpec defaults to None. When None and search terms exist → rank-first. When None and no search terms → date descending (current behavior).
      • When using rank-first sort: use cursor/keyset pagination. The cursor is a combination of (score, conversation_id) or (rank, tiebreaker) to ensure stability.
      • Offset-based pagination is unsafe for ranked results (new results can shift rankings). Document offset as "best-effort, not stable."
      • Add next_cursor field to the ranked result envelope.
      • Tie-breaking: when scores are equal, fall back to conversation_id (deterministic) or updated_at.
    5. Scoped vs global facets (modify polylogue/daemon/http.py _do_facets and add archive/query facet support):

      • Current: _do_facets returns global stats from poly.stats().
      • Add: GET /api/facets?query=...&provider=...&since=... applies the same filters as list/search and returns facet counts scoped to that filter set.
      • Facet model: ScopedFacets with providers, tags, has_types, message_types, time_range, cwd_prefixes, each with count and is_scoped: bool flag.
      • Global /api/facets (no query params) returns is_scoped: false for all counts.
      • The archive/query layer must compute scoped counts from the query/filter, not from a pre-computed global snapshot.
    6. Surface alignment (CLI JSON, MCP, daemon HTTP, Python API):

      • CLI JSON output: use the same RankedResult[ConversationSearchHit] shape.
      • MCP search tools: adapt the same envelope (coordinate with fix(mcp): add pagination envelopes and structured resource errors #819 for MCP-specific response wrapping).
      • Daemon HTTP: GET /api/conversations returns a RankedResult envelope.
      • Python API: Polylogue.search() or query_conversations() returns RankedResult.
      • The current ConversationSearchHit from polylogue/archive/query/search_hits.py and ConversationSearchEvidenceHit from polylogue/storage/search/models.py should CONVERGE into one canonical model.
    7. Docs update (docs/search.md):

      • Document actual FTS query syntax supported (SQLite FTS5).
      • Document retrieval lanes: dialogue, actions, hybrid, semantic.
      • Document ranking behavior: BM25 for FTS, action scoring heuristic, RRF for hybrid.
      • Document pagination stability guarantees and cursor vs offset tradeoffs.
      • Remove any claims that do not match actual behavior.

    Do NOT build this

    Files to touch

    Modified files (core search/query):

    • polylogue/archive/query/search_hits.py — extend ConversationSearchHit with explanation fields; add RankedResult model
    • polylogue/archive/query/retrieval_search.py — preserve lane ranks/contributions in hybrid RRF; return explanation-bearing hits
    • polylogue/archive/query/sorting.py — add rank-first sort mode; add cursor/keyset pagination support
    • polylogue/archive/query/plan.py — add ranking_policy, ranking_policy_version fields to plan
    • polylogue/archive/query/spec.py — sort defaults to None (meaning rank-first when search terms present); add cursor param
    • polylogue/archive/query/plan_execution.py — wire ranked pagination into execution
    • polylogue/storage/search/models.py — converge ConversationSearchEvidenceHit into the canonical model from search_hits.py (or vice versa)
    • polylogue/storage/search_providers/hybrid.py — expose RRF lane scores/contributions in result objects
    • polylogue/storage/search/query_builders.py — add scoped facet query support
    • polylogue/storage/sqlite/queries/conversations_search.py — add scoped facet queries

    Modified files (surface adapters):

    • polylogue/daemon/http.py — _do_list builds ConversationQuerySpec from params, returns RankedResult; _do_facets accepts query params and returns scoped facets
    • polylogue/surfaces/payloads.py — add ranked result envelope serialization
    • polylogue/mcp/server_tools.py — adapt MCP search tools to return RankedResult envelope
    • polylogue/mcp/payloads.py — MCP-specific wrapping of RankedResult
    • polylogue/cli/query.py — return RankedResult from CLI query operations
    • polylogue/cli/query_output.py — render ranked results with evidence in plain/JSON output

    Modified files (docs):

    • docs/search.md — update with actual behavior

    Test files:

    • tests/unit/archive/test_search_hits.py — rank evidence tests
    • tests/unit/archive/test_query_search_runtime.py — ranked pagination, cursor stability tests
    • tests/unit/storage/test_fts5.py — FTS score consistency tests
    • tests/unit/storage/test_hybrid.py — lane contribution tests
    • tests/unit/daemon/ — API list/search/facet payload contract tests
    • tests/unit/mcp/ — MCP search envelope contract tests
    • tests/unit/cli/ — CLI JSON/plain output tests for search results

    Coordination

    Focused tests

    # Core search/ranking tests:
    pytest tests/unit/archive/test_search_hits.py -q -k "explanation or evidence or matched_terms"
    pytest tests/unit/archive/test_query_search_runtime.py -q -k "ranked or pagination or cursor"
    pytest tests/unit/storage/test_fts5.py -q -k "score or rank or snippet"
    pytest tests/unit/storage/test_hybrid.py -q -k "rrf or lane or contribution"
    
    # Surface contract tests:
    pytest tests/unit/daemon -q -k "search or facets or list or api"
    pytest tests/unit/mcp -q -k "search or envelope or pagination"
    pytest tests/unit/cli -q -k "query or search or json"
    
    # Docs and rendering:
    devtools render-all --check
    devtools verify --quick

    Acceptance criteria mapping

    Criteria How verified
    Search/list ranked responses use one typed envelope across CLI JSON, MCP, API, daemon Contract test: same query produces same envelope shape across all surfaces (compare JSON schema)
    Every ranked hit has deterministic why-this-matched evidence Test: search "python analysis" in synthetic archive, assert each hit has non-empty matched_terms and evidence_ids
    Search default ordering is rank-first unless user explicitly chooses date Test: query with search terms, no sort param specified → results ordered by score descending, not date
    dialogue, actions, hybrid, semantic paths have documented ranking behavior and tests Test: exercise each lane, assert documented behavior matches (BM25 for dialogue, action scoring for actions, RRF for hybrid)
    Hybrid results expose lane ranks/contributions Test: search via hybrid lane, assert each hit has lane_contributions dict with per-lane rank and score
    Pagination is stable and applies after filters/ranking Test: paginate through results with cursor, re-run same query, assert same items appear at same positions
    Facets declare scoped vs global, scoped counts available from archive/query layer Test: GET /api/facets?query=python returns scoped counts that differ from GET /api/facets global counts
    Docs match actual FTS/query syntax and result semantics Manual review: docs/search.md checked for accuracy against implemented behavior

    Ambiguities and stale claims

    • Two ConversationSearchHit models: polylogue/archive/query/search_hits.py defines one; polylogue/storage/search/models.py defines another (slightly different fields). These need convergence. The archive/query version is the canonical one (used by CLI/MCP/API surfaces); the storage version is internal. Decision needed: converge into one model in archive/query/search_hits.py OR keep two and add a mapper.
    • ConversationSearchEvidenceHit in storage/search/models.py already has retrieval_lane, match_surface, message_id, snippet, score — but it is NOT used by the archive/query layer. The search_hits_for_plan function uses ConversationSearchHit from archive/query. These two models should be merged.
    • Hybrid lane contributions: Currently search_hybrid_results computes per-lane ranked lists but only uses them for RRF fusion, then returns conversation objects without lane metadata. The lane info is lost. To add explanation, either (a) restructure the function to return hits with per-lane data, or (b) re-derive lane information after fusion from the per-lane result sets.
    • Scoped facets: The issue body says facet counts should be "computed against the current query/filter set." The current archive layer computes facets from poly.stats() which is global. Adding scoped facets requires new query logic in the archive/query layer that applies filters before counting.
    • Cursor pagination: The codebase currently uses offset-based pagination everywhere. Adding cursor/keyset pagination is a new mechanism. The "next_cursor" should be an opaque token encoding (last_score, last_conversation_id) that the server can decode to resume scanning.
    • Default sort=None vs sort="date": The query_spec_to_plan function defaults sort to "date" even when spec.sort is None. This MUST change: when search terms exist and sort is None, use rank-first. When no search terms, fall back to date. This is a breaking behavior change for any code that relied on implicit date sorting for searched results.
  3. Sinity commented on May 7, 2026

    @Sinity
    OwnerAuthor

    Implementation scope for #873

    Starting implementation on branch feature/feat/explainable-search-873.

    In scope

    1. ConversationSearchHit explanation fields — Add matched_terms: tuple[str, ...] and score_components: dict[str, float] to ConversationSearchHit in polylogue/archive/query/search_hits.py. Populate in FTS5 path (extract matched terms from query) and hybrid path (expose per-lane scores). Update all constructors.

    2. Rank-first default sort — Fix query_spec_to_plan() in polylogue/archive/query/spec.py to stop defaulting sort=None to sort="date". Change ConversationQueryPlan.sort to SortField | None with default None. In plan_execution.py, when plan.fts_terms exist and plan.sort is None, preserve natural search ranking instead of re-sorting by date.

    3. Preserve hybrid lane contributions — Modify search_hybrid_results in polylogue/archive/query/retrieval_search.py to carry score_components with per-lane (text, action, vector) rank and score through to hits. Extend reciprocal_rank_fusion in polylogue/storage/search_providers/hybrid.py to optionally return lane-level data.

    4. Cursor/keyset pagination — Add next_cursor: str | None to the paginated result envelope in polylogue/mcp/payloads.py. Produce a simple opaque cursor encoding (score, last_conversation_id) for rank-first search results.

    5. Surface payload alignment — Extend ConversationSearchMatchPayload in polylogue/surfaces/payloads.py with new explanation fields: matched_terms, score_components, lane_rank, lane_contribution, raw_score.

    6. Daemon HTTP — In polylogue/daemon/http.py, when the query spec has search terms, return ranked result envelope with match evidence instead of plain row dicts.

    Non-goals (per the issue)

    Files expected to change

    File Change
    polylogue/archive/query/search_hits.py Add matched_terms, score_components to dataclass; update constructors
    polylogue/archive/query/spec.py Fix default sort; add cursor param
    polylogue/archive/query/plan.py Change sort default to None; add cursor, ranking_policy fields
    polylogue/archive/query/plan_execution.py Preserve rank ordering when sort is None and search terms exist
    polylogue/archive/query/retrieval_search.py Preserve lane ranks/contributions in hybrid
    polylogue/archive/query/sorting.py Handle None sort (no-op, keep rank order)
    polylogue/storage/search_providers/hybrid.py Expose RRF lane scores
    polylogue/storage/repository/archive/search.py Pass through new explanation fields from evidence hits
    polylogue/surfaces/payloads.py Extend ConversationSearchMatchPayload
    polylogue/mcp/payloads.py Add next_cursor to search result envelope
    polylogue/daemon/http.py Return ranked result envelope for queries with search terms
    polylogue/storage/search/models.py Add lanes/contributions to ConversationSearchEvidenceHit
    tests/ Add/update tests for explanation fields, rank-first sort, cursor stability
  4. Sinity commented on May 7, 2026

    @Sinity
    OwnerAuthor

    Completion report: #873 explainable search implementation

    Branch: feature/feat/explainable-search-873 (commit e9dd5392)

    What was implemented

    1. ConversationSearchHit explanation fields (polylogue/archive/query/search_hits.py)

    • Added matched_terms: tuple[str, ...] = () — which query terms matched
    • Added score_components: dict[str, float] = field(default_factory=dict) — breakdown by lane/key
    • Both fields are populated in all three search paths (dialogue via FTS5, hybrid via RRF lanes, action search)
    • search_hits_for_plan now populates matched_terms from search_terms(query_terms) for all lanes

    2. Rank-first default sort (polylogue/archive/query/spec.py, plan.py, plan_execution.py, sorting.py)

    • ConversationQueryPlan.sort changed from SortField = "date" to SortField | None = None
    • query_spec_to_plan() changed from sort=spec.sort or "date" to sort=spec.sort (no auto-default)
    • _plan_sort_is_rank_first() helper: when plan.fts_terms and plan.sort is None, results preserve natural search ranking
    • Both list_for_plan and list_summaries_for_plan skip _sort_conversations/_sort_summaries when rank-first is active
    • QuerySortPlan protocol updated to accept SortField | None

    3. Preserve hybrid lane contributions (polylogue/archive/query/retrieval_search.py)

    • search_hybrid_results now returns tuple[list[Conversation], dict[str, dict[str, int | None]]]
    • The lane_ranks dict maps conversation_id → {"text": rank_or_None, "action": rank_or_None, "vector": rank_or_None}
    • search_hits_for_plan directly calls search_hybrid_results for hybrid lane and builds score_components with per-lane ranks (text_rank, action_rank, vector_rank)
    • retrieval_candidates.py:fetch_search_results updated to unpack new tuple

    4. Cursor/keyset pagination (polylogue/mcp/payloads.py)

    • Added next_cursor: str | None to MCPPaginatedSearchResultPayload
    • _build_search_cursor() creates opaque base64 cursor from last hit's rank + conversation_id
    • Cursor emitted when results fill the page (len(hits) == limit)

    5. Surface payload alignment (polylogue/surfaces/payloads.py)

    • ConversationSearchMatchPayload extended with matched_terms and score_components
    • ConversationSearchHitPayload.from_search_hit() passes through new fields

    6. Daemon HTTP (polylogue/daemon/http.py)

    • _do_list now dispatches to _do_search_list when query/contains params are present
    • _do_search_list returns ranked search hits with match evidence (rank, retrieval_lane, snippet, score, matched_terms, score_components)

    7. Storage model alignment (polylogue/storage/search/models.py)

    • ConversationSearchEvidenceHit extended with matched_terms, score_components, lane_rank, lane_contribution, raw_score

    8. Test update (tests/unit/archive/test_query_search_runtime.py)

    • Updated test_search_hybrid_results_orders_fused_ids_and_skips_missing to unpack new tuple return and verify lane ranks

    Verification

    • ruff check: All checks passed (13 files)
    • mypy --strict: Success, no issues found (13 files)
    • ruff format --check: All files already formatted
    • pytest tests/unit/archive/test_query_search_runtime.py: 7 passed
    • Pre-commit hook: passed (format + lint)

    What was NOT done (and why)

    Pre-existing test failures (not caused by this PR)

    The following tests fail on origin/master (commit 18e68c02) as well:

    • test_search_with_empty_query — KeyError: 'results' (likely stale test against updated payload contract)
    • test_mcp_search_params_match_query_spec — hardcoded MCP param names don't match spec field names
    • Several storage/cli/mcp tests — appear to be from other in-flight work
  5. Sinity commented on May 7, 2026

    @Sinity
    OwnerAuthor

    Closed-issue reconciliation note: leaving this closed for now because ranked search/cursor pieces exist, but the closure is not complete enough to ignore.

    Residuals tracked in #944: search hit models are still split, /api/facets remains global rather than query-scoped, reader/API/search result shapes are not fully converged, and the implementation still needs a truth pass before claims like stable explainable search or scoped facets are used in PR/history text.

    #944 should either converge the present pieces or open a narrow follow-up with exact remaining contract gaps.

  6. 23 remaining items

  7. Sinity commented on May 25, 2026

    @Sinity
    OwnerAuthor

    Merged #1563 as a cursor correctness slice.

    Landed:

    • cursors minted for a resolved concrete lane (for example dialogue) can now be reused by a follow-up request that still says retrieval_lane=auto;
    • concrete lane switches are still rejected, so a dialogue cursor cannot silently continue under hybrid ranking;
    • the rule is centralized in the shared cursor helper and used by the Python API envelope builder;
    • focused regressions cover both apply_search_cursor and build_archive_search_envelope.

    Verification before merge:

    • focused cursor/envelope tests: 21 passed;
    • devtools verify --json: exit 0, 299 pytest-testmon selected tests passed;
    • pre-push quick gate passed;
    • PR CI passed. CodeRabbit posted only a rate-limit notice, no actionable findings.
  8. Sinity commented on May 25, 2026

    @Sinity
    OwnerAuthor

    Merged two more #873 hardening slices.

    #1564 — cross-surface envelope evidence + shared spec builder:

    • API and daemon HTTP now share build_search_envelope_for_spec() for cursor handling, diagnostics, hit payload conversion, and envelope assembly once a ConversationQuerySpec exists.
    • The cross-surface envelope test now compares the canonical per-hit match evidence across API/helper, MCP, and CLI JSON: match surface, message id, snippet, score, score kind, matched terms, score components, lane rank, lane contribution, and raw score.
    • Verification: focused API/surface/daemon tests passed; devtools verify --json passed with 415 selected tests; PR CI passed. CodeRabbit remained on a review-in-progress placeholder with no inline comments.

    #1565 — storage search DTO naming cleanup:

    • Renamed storage-only ConversationSearchHit to ConversationSearchIdHit and storage-only ConversationSearchEvidenceHit to ConversationSearchEvidenceRow.
    • Repository search still hydrates those rows into the public archive ConversationSearchHit before surfaces see ranked evidence.
    • No compatibility aliases were added.
    • Verification: focused storage/search tests passed; devtools verify --json passed with 630 selected tests; PR CI passed. CodeRabbit was rate-limited only.

    Remaining #873 scope after these slices looks like acceptance proof rather than obvious missing fields: rank-first/default-sort behavior, cursor behavior under mixed filters, complete scoped-facet coverage across supported dimensions, and docs truth pass against the now-real contracts.

  9. Sinity commented on May 25, 2026

    @Sinity
    OwnerAuthor

    Merged #1566 as the docs truth pass.

    Landed:

    • docs/search.md now describes the current public SearchEnvelope contract conservatively: action-only hits preserve rank/evidence but do not expose action BM25 scores; match_surface examples use the actual public tokens; BM25 is lower-is-better; hybrid fusion includes dialogue/action/semantic lanes; sort=null preserves natural rank order; cursors carry rank/score/conversation/lane.

    Verification before merge:

    • devtools verify-doc-commands passed;
    • devtools render-pages rebuilt the local site cache;
    • devtools render-all --check passed;
    • devtools verify --json passed with all static/generated checks green and 0 testmon-selected tests;
    • PR CI passed. CodeRabbit was rate-limited only.

    Remaining #873 questions now look test/proof oriented:

    • explicit rank-first behavior under mixed filters and explicit sort overrides;
    • cursor continuity under mixed filters beyond the pure payload laws;
    • complete scoped-facet behavior across all supported filter dimensions and surfaces.
  10. Sinity commented on May 25, 2026

    @Sinity
    OwnerAuthor

    Merged #1567 as the rank-first ordering proof.

    Landed:

    • list_for_plan() now has focused tests proving an unsorted search plan (query_terms + sort=None) preserves provider/candidate rank order even when conversation timestamps would sort the opposite way.
    • The paired explicit sort=date test proves user-selected date sort still overrides rank order.

    Verification before merge:

    • focused archive query-runtime pytest passed;
    • ruff and mypy on the touched test passed;
    • devtools verify --json passed with 9 selected tests;
    • PR CI passed. CodeRabbit was rate-limited only.

    Remaining #873 work has narrowed further: cursor continuity under mixed filters at the API/daemon builder level, and scoped-facet completeness across supported filter dimensions/surfaces.

  11. Sinity commented on May 25, 2026

    @Sinity
    OwnerAuthor

    Merged #1568 as filtered cursor-builder proof.

    Landed:

    • build_search_envelope_for_spec() now has a regression proving cursor fetch advancement preserves provider/tag/since filters while moving the backend offset/limit to the cursor window.
    • The same test verifies the public envelope keeps the original caller-facing limit/offset rather than leaking the buffered fetch window.

    Verification before merge:

    • focused API + cursor payload tests passed;
    • ruff and mypy on the touched test passed;
    • devtools verify --json passed with 2 selected tests;
    • PR CI passed. CodeRabbit was rate-limited only.

    Remaining #873 scope now looks mostly like scoped-facet completeness across dimensions/surfaces, plus deciding whether the issue can close with action-lane score evidence explicitly documented as not yet part of the public contract.

  12. Sinity commented on May 25, 2026

    @Sinity
    OwnerAuthor

    Merged #1569 as the MCP scoped-facets surface slice.

    Landed:

    • facets now exposes the shared optional query field in its MCP input schema, while search keeps query required.
    • The shared MCP signature builder distinguishes "include query" from "require query" so facets can stay callable with no filters and still support query-scoped counts.
    • The MCP schema derivation tests now include facets, and the committed MCP tool-schema witness was regenerated.

    Verification before merge:

    • pytest -q tests/unit/mcp/test_tool_schema_witness.py tests/unit/mcp/test_query_tool_schema_derivation.py --tb=short passed (10 tests);
    • devtools verify --json passed with 1 selected pytest-testmon node;
    • pre-push quick gate passed;
    • PR CI passed. CodeRabbit was rate-limited only, with no actionable review findings.

    #873 now has CLI/API/daemon/MCP scoped-facet entrypoints through the shared typed contract. I’m treating the remaining work as a final acceptance/readiness pass over facet dimensions and result-envelope consistency before deciding whether to close or keep a narrow residual issue open.

  13. Sinity commented on May 25, 2026

    @Sinity
    OwnerAuthor

    Merged #1570 as the final MCP facets runtime proof.

    Landed:

    • Added tests/unit/mcp/test_facets_tool_contract.py proving the registered MCP facets tool forwards query + provider into a ConversationQuerySpec before calling the shared Polylogue.facets() contract.
    • Added the paired global-view assertion: no filters calls poly.facets(None).
    • Kept the proof in a small dedicated file rather than growing test_tool_contracts.py past its file-size budget.

    Verification before merge:

    • focused MCP facets/schema tests passed;
    • ruff + mypy on touched test files passed;
    • devtools verify --json passed with 66 selected pytest-testmon nodes;
    • pre-push quick gate passed;
    • PR CI passed. CodeRabbit was rate-limited only, with no actionable findings.

    Final acceptance status for #873:

    I’m closing this as realized. Semantic embedding operationalization remains separately tracked by #1503 and is not part of this ranked-result contract closure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliarea:corearea:daemonarea:mcparea:storagetheme:command-surfacetype:feat

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions