Skip to content

Reconcile the lexical-match flag across widened search results - #1146

Merged
alexeyzimarev merged 1 commit into
mainfrom
fix/1143-widen-no-lexical-match
Sep 24, 2026
Merged

alexeyzimarev merged 1 commit into
mainfrom
fix/1143-widen-no-lexical-match

Conversation

@alexeyzimarev

Copy link
Copy Markdown
Member

Closes #1143 — AI-3175

What & why

search_sessions auto-widen merged the all-repos hits into the cwd-scoped body but kept the scoped no_lexical_match. Widening fires when the scoped page is short, so the merged result commonly said no_lexical_match: true beside widened hits whose lanes include transcript. The merged flag is now first && widened; a side without a bool defers to the other, and with neither the key is left as the scoped body had it.

Verification

  • The new tests failed before the fix: the issue's case read true instead of false, and (null, true) read null instead of true.
  • McpSessionsServerTests: 84/84 passed after the fix.
  • dotnet publish -c Release: no IL2026/IL3050 warnings.

🤖 Generated with Claude Code

Widening fires when the scoped page is short, which is when its lexical lanes most often found nothing, so the scoped flag alone contradicted the widened lexical hits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T14:30:45.283359Z 535738b PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Reconcile lexical-match status across widened session searches

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Reconciles lexical-match status across scoped and all-repository search responses.
• Prevents widened lexical hits from retaining a contradictory no-match indicator.
• Covers boolean, null, and missing-field combinations with unit tests.
Diagram

graph TD
  A["Scoped response"] --> C["Merge bodies"] --> D["Reconciled response"]
  B["Widened response"] --> C
Loading
High-Level Assessment

The tri-state boolean reconciliation is the appropriate approach: logical AND makes no_lexical_match true only when every reported scope found no lexical match, while treating a missing or non-boolean value as unknown preserves information from the other response. Inferring the status from merged hit lanes was considered but would couple response metadata to potentially capped or incomplete hit data.

Files changed (2) +43 / -0

Bug fix (1) +11 / -0
McpSessionsServer.csReconcile lexical-match metadata during widened-result merging +11/-0

Reconcile lexical-match metadata during widened-result merging

• Reads valid no_lexical_match booleans from both scoped and widened responses, then combines them with logical AND. Missing or non-boolean values defer to the valid side, while the original scoped field remains unchanged when neither side supplies a boolean.

src/Capacitor.Cli/Commands/McpSessionsServer.cs

Tests (1) +32 / -0
McpSessionsServerTests.csCover widened lexical-match reconciliation +32/-0

Cover widened lexical-match reconciliation

• Adds a regression test for lexical hits found only after widening. Parameterized cases verify true, false, explicit null, and missing-field combinations across both response bodies.

test/Capacitor.Cli.Tests.Unit/Commands/McpSessionsServerTests.cs

@qodo-code-review

qodo-code-review Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (1) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Commit subject fails merge format 📘 Rule violation ⚙ Maintainability
Description
The commit subject Reconcile no_lexical_match across auto-widened search bodies (#1143) contains
an underscore and a hyphen, so it does not match the required words-only subject grammar. This
occurs when the commit is merged using the supplied subject, while its issue suffix and length
otherwise satisfy the format.
Code

src/Capacitor.Cli/Commands/McpSessionsServer.cs[556]

+            // The flag describes one request's lexical lanes; a lexical hit in either scope clears it.
Relevance

●●● Strong

Explicit commit-subject grammar makes punctuation violation a deterministic compliance fix.

PR-#526

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2897961 requires the merge subject to match its alphanumeric, space-separated
grammar and end with a GitHub issue reference; the supplied commit subject contains punctuation
within two words.

Rule 2897961: Enforce single-clause imperative commit subject with GitHub issue reference and 80-char limit


2. Merged searches omit lexical status ✗ Dismissed 🔗 Cross-repo conflict ≡ Correctness
Description
MergeWidenedBody reads no_lexical_match, but kcap-server's SessionSearchResponse has no
corresponding member and its handler constructs the response with only hits and resolved-author
data. Against the pinned server both reads are always null, so widened MCP responses still omit the
lexical-match status this change intends to reconcile.
Code

src/Capacitor.Cli/Commands/McpSessionsServer.cs[R557-558]

+            var firstNoLexical   = ReadNoLexicalMatch(first);
+            var widenedNoLexical = ReadNoLexicalMatch(widened);
Relevance

●●● Strong

Recent history accepts fixes for client/server contract mismatches and response semantics in this
MCP server.

PR-#1135
PR-#501

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR explicitly reads no_lexical_match, while the server's complete response record does not
define it and the endpoint response construction supplies no equivalent value.

src/Capacitor.Cli/Commands/McpSessionsServer.cs[556-562]
External repo: kurrent-io/kcap-server, src/Capacitor.Api.Public.Abstractions/Sessions/SessionSearchResponse.cs [7-15]
External repo: kurrent-io/kcap-server, src/Capacitor.Api.Public/Sessions/SessionSearchHandler.cs [175-181]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The CLI reconciles `no_lexical_match`, but the pinned kcap-server search response never emits that field, leaving the new logic inactive for real server responses.

## Fix Focus Areas
- src/Capacitor.Cli/Commands/McpSessionsServer.cs[556-562]
- /cross_repos/kcap-server/src/Capacitor.Api.Public.Abstractions/Sessions/SessionSearchResponse.cs[7-15]
- /cross_repos/kcap-server/src/Capacitor.Api.Public/Sessions/SessionSearchHandler.cs[175-181]

## Recommended Fix
Add and correctly compute `NoLexicalMatch` in kcap-server's session-search response, update its HTTP contract tests, and coordinate the server release or minimum compatible version with this CLI change. If the server change cannot be coordinated, derive the merged status from existing response data instead of relying on a field the endpoint does not provide.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 64 rules
✅ Cross-repo context — repo relationships
  Explored: repo: kurrent-io/kcap-server (sha: a0a303c0)
Review mode: ⚖️ Balanced: This is a localized runtime behavior change in JSON merge semantics with edge-case handling, so it warrants a complete single-pass review despite the small diff.

Grey Divider

Tip of the day
💡 Did you know, you can choose which labels appear on a finding, and whether they show icons or text

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread src/Capacitor.Cli/Commands/McpSessionsServer.cs
Comment thread src/Capacitor.Cli/Commands/McpSessionsServer.cs
@alexeyzimarev alexeyzimarev changed the title Reconcile no_lexical_match across auto-widened search bodies Reconcile the lexical-match flag across widened search results Sep 24, 2026
@alexeyzimarev
alexeyzimarev merged commit 61caaf2 into main Sep 24, 2026
7 checks passed
@alexeyzimarev
alexeyzimarev deleted the fix/1143-widen-no-lexical-match branch September 24, 2026 15:24
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.

search_sessions: reconcile no_lexical_match when the auto-widen merges bodies

1 participant