Skip to content

fix(search): ground lexical identifier evidence - #207

Closed
PatrickSys wants to merge 3 commits into
masterfrom
rescue/l27-cbc-157-convention-exemplars
Closed

PatrickSys wants to merge 3 commits into
masterfrom
rescue/l27-cbc-157-convention-exemplars

Conversation

@PatrickSys

@PatrickSys PatrickSys commented Dec 6, 2026 •

Copy link
Copy Markdown
Owner

Fixes lexical rescue false positives by masking comments, retaining quoted config literals, and using Unicode-aware identifier boundaries for admission.

Validation:

  • node scripts/run-vitest.mjs: 168 files passed; 1,612 passed, 2 skipped.
  • node node_modules/typescript/bin/tsc --noEmit: passed.
  • Focused search fallback suite: 55 passed, 1 skipped.
  • Prettier check and git diff --check: passed.

Verify ranked project-relative paths and category filtering through the executable in text and JSON. Document how callers can refresh examples from older indexes.

Agent: codex gpt-6.2-sol 01a24913-17e6-7211-965f-9513e7747f28
Accept whole environment and configuration identifiers as file-local clues, and apply the existing indexed import proof to underscored declarations. Keep the candidate window and source validation for rescued hits.

Agent: codex gpt-6.2-sol 01a24913-17e6-7211-965f-9513e7747f28
Agent: codex gpt-6.2-sol 01a24930-57ce-7221-97a4-ba695a5d5e08
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-06T02:55:54.008555Z ae1c2a6 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ae1c2a6559

ℹ️ 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".

Comment thread src/utils/tree-sitter.ts
Comment on lines +565 to +566
const lineComment =
(char === '/' && next === '/') || char === '#' || (char === '-' && next === '-');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make comment delimiters conditional on the source language

For JavaScript/TypeScript, # can introduce a private field and -- is a decrement operator, but this treats both as line comments. For example, #limit = process.env.WIDGET_RETRY_LIMIT; loses the entire identifier during masking. Consequently, a query combining that identifier with one natural-language clue cannot rescue the file, even when both clues are present. Use language-aware comment recognition rather than applying every supported language's delimiters simultaneously; this also preserves the repository's language-agnostic search contract.

AGENTS.md reference: AGENTS.md:L108-L108

Useful? React with 👍 / 👎.

Comment thread src/core/search.ts

const literalMatches = (item: CodeChunk, nominationText: string): string[] => {
if (!literalAnchors.some((anchor) => nominationText.includes(anchor))) return [];
const code = maskComments(item.content).toLowerCase();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve comment context across chunk boundaries

When a multiline comment crosses a chunk boundary, masking item.content starts with no knowledge of the opening delimiter. The line-based chunker in src/utils/chunking.ts slices files every 50 lines without preserving comment boundaries, so an identifier appearing only inside a comment after that boundary remains unmasked. Combined with one natural clue elsewhere in the file, it becomes sufficient rescue evidence and returns a comment-only identifier match, contrary to the new admission contract. Mask the complete source before selecting chunk intervals, or retain the lexical state at each chunk's start.

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5RetriggerView in Greptile

[Medium impact] The main reach is searches that use the model-free fallback.

The PR appears safe to merge, with non-blocking search edge cases in comment masking.

Findings

  1. P2 Private fields lose search evidence ▶
  2. P2 Template comments count as evidence ▶
  3. P2 Split comments count as evidence ▶

Summary

Extends lexical rescue to use undeclared camelCase and snake_case identifiers alongside natural-language clues.

  • Search rescue uses whole undeclared identifiers as local evidence.
  • The patterns docs explain how example files appear.

Reviews (1) · Last reviewed commit: "fix(search): ground lexical identifier e..." · Reviewed by Greptile

Comment thread src/utils/tree-sitter.ts
Comment on lines +565 to +566
const lineComment =
(char === '/' && next === '/') || char === '#' || (char === '-' && next === '-');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Private fields lose search evidence

maskComments treats # and -- as comments in every language. In valid TypeScript such as class Settings { #limit = process.env.WIDGET_RETRY_LIMIT; }, it erases the environment variable along with the private field. A question about WIDGET_RETRY_LIMIT and one other clue then misses this file because only the other clue survives. Use the chunk's language to decide which comment markers apply.

Comment thread src/utils/tree-sitter.ts
Comment on lines +539 to +548
if (quote) {
if (escaped) escaped = false;
else if (char === '\\') escaped = true;
else if (char === quote) quote = undefined;
continue;
}

if (char === '"' || char === "'" || char === '`') {
quote = char;
continue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Template comments count as evidence

maskComments leaves comments inside template expressions untouched. For example, const text = ${/* WIDGET_RETRY_LIMIT */ 3}; keeps WIDGET_RETRY_LIMIT because the opening backtick puts the entire template into quoted mode. Another clue such as throttling in the same file then makes this comment-only mention count toward admission. Track template expressions separately so their comments are removed while literal template text stays searchable.

Comment thread src/core/search.ts

const literalMatches = (item: CodeChunk, nominationText: string): string[] => {
if (!literalAnchors.some((anchor) => nominationText.includes(anchor))) return [];
const code = maskComments(item.content).toLowerCase();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Split comments count as evidence

maskComments starts fresh for each chunk, but chunks can begin inside a block comment. The line-based splitter cuts files every 50 lines without carrying comment state. In a CSS file with a long opening comment, a chunk starting at line 51 can contain WIDGET_RETRY_LIMIT without the earlier /*; the mask keeps it, and another matching word admits the file. Build the comment mask from the full source before selecting the chunk's range, or preserve the comment state across chunk boundaries.

@PatrickSys

Copy link
Copy Markdown
Owner Author

FIX FIRST. I did not merge PR #207. The current head is ae1c2a65595507d7f08c04e1b0c6b6428d87ee98, but the independent real-searcher review found four regressions: decrement operands and private-field identifiers are deleted as comments (expected one result, got zero); quotes inside a regex and comments inside template interpolation cause comment-only identifiers to be admitted (expected zero, got one). The earlier trailing and multiline comment cases pass, but these failures still need correction in the language-aware comment handling and real-searcher regression coverage before this PR can land. The PR remains open; no branches were deleted.

@PatrickSys

Copy link
Copy Markdown
Owner Author

Verdict: FIX FIRST. The reviewed PR head ae1c2a6 still has three landing blockers: language independent masking removes executable operators/fields (including TypeScript decrement/private fields and Python floor division); regex and nested template handling can admit identifiers that occur only in comments; and masking each chunk separately loses block comment state across chunk boundaries. Independent real searcher probes failed 14 of 31 cases. Keep this PR open and repair the source language aware masking across full source, then rerun the regression probes and suite. No merge was made.

@PatrickSys PatrickSys closed this Dec 6, 2026
@PatrickSys
PatrickSys deleted the rescue/l27-cbc-157-convention-exemplars branch December 6, 2026 05:02
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