Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ untruncated output. Attestation still relies on the verifier's exit status.

## C# search-origin context

Issue #5348 adds explicit `--origin-passes` (1–16, default 1) to CLI search/audit/regex-find. `DbSearchReader.CSharpOrigins.cs` supplies successive bounded windows to one `CSharpOriginContext`; lexical locals, interpolation frames, labels and schema state survive each window. Limits apply per pass, including overlapping chunk characters, with at most 65,536 lines / 128 Mi source characters retained per file. State never survives a query; local `total_changes()` and external `data_version` checks discard contexts if their indexed generation changes. Preserve missing/conflicting-line holes, cancellation, fixed per-query pass budgets, cursor/replay binding, and bounded retry diagnostics. A zero-progress window cannot request another pass. See [continuation behavior](docs/find-scan-controls.md#bounded-c-lexical-continuation-5348).

Compare newly encountered overlap with retained bounded evidence before resuming. Conflicting overlap discards the entire provisional context: earlier interpolation decisions may depend on its closing text.

Read the bounded prefix independently of the last returned chunk so later closing delimiters cannot change earlier origins across pages. Interpolation frames isolate schema-call state (including alignment commas) while retaining nested builder detection. Ordinary interpolation format text cannot cross a physical newline; verbatim/raw formats can.

Issue #5321 resumes ordinary/verbatim/raw interpolation with at most 64 active interpolation frames and 64 balanced delimiters per expression. Nested comments/strings are consumed by the same cancellable prefix pass. Merge adjacent literal spans, preserve UTF-16 coordinates, and keep unsupported formats or unbalanced/missing context unknown with bounded `SearchMatchFacet.OriginUnavailable` reason/start/extent evidence. No work budget depends on requested matches or pagination.

`DbSearchReader.AttachCSharpOriginLines` supplies shared, indexed file prefixes to the snippet classifier. Preserve the per-file 4,096-line, 8 Mi-character and 128-chunk read limits, including overlap accounting; query pagination must not change those budgets. The character limit leaves room above existing 4 Mi-character semantic-analysis windows. Keep missing lines absent so the lexical classifier returns `unknown` rather than assuming code. Ordinary/token-boundary row and count paths and MCP must retain identical origin decisions and original UTF-16 coordinates. No persisted schema changes are involved.
`DbSearchReader.AttachCSharpOriginLines` supplies shared, indexed file prefixes to the snippet classifier. Preserve the per-pass, per-file 4,096-line, 8 Mi-character and 128-chunk read limits, including overlap accounting; query pagination must not change those budgets. The character limit leaves room above existing 4 Mi-character semantic-analysis windows. Keep missing lines absent so the lexical classifier returns `unknown` rather than assuming code. Ordinary/token-boundary row and count paths and MCP must retain identical origin decisions and original UTF-16 coordinates. No persisted schema changes are involved.

Build `CSharpOriginContext` once per file prefix with cancellation and share its origin spans across rows and occurrences. Track schema argument positions during that same lexical pass, with at most 64 active builder invocations and a 64-line lookback; overflow leaves affected labels unknown. Cache regex/help classification per opening line, with cancellation at label lookup. Do not rescan preceding lines or reconstruct schema context per match or per literal.

Expand Down Expand Up @@ -4641,11 +4645,15 @@ JSON の `installer_output_incomplete` に記録します。判明した親の

## C# 検索 origin のコンテキスト

Issue #5348 は CLI の search/audit/regex-find に明示的な `--origin-passes`(1〜16、既定 1)を追加します。`DbSearchReader.CSharpOrigins.cs` は同じ `CSharpOriginContext` へ上限付きの窓を順次渡し、字句状態、補間フレーム、ラベル、schema の文脈を引き継ぎます。重複チャンクの文字数を含む上限はパスごとに適用し、保持するソースはファイルごとに最大 65,536 行/128 Mi 文字です。クエリを越えて状態を保持せず、同一接続の `total_changes()` と外部変更の `data_version` によって索引世代の変化時に文脈を破棄します。欠落・不整合な行、キャンセル、クエリごとに固定したパス数、カーソル・再実行条件の紐づけ、上限付き再試行診断を維持してください。前進できない窓では追加パスを案内しません。[継続動作の説明](docs/find-scan-controls.md#上限付き-c-字句分類の継続-5348)も参照してください。

継続前に、新しく読み取った重複部分を保持済みの上限付き証拠と照合します。不一致があれば暫定文脈全体を破棄します。先行する補間の判定が、その部分の閉じ区切りに依存する場合があるためです。

返す最後のチャンクとは独立して上限付きの先頭部分を読み取り、後続の閉じ区切りによってページ間で先行箇所の origin が変わらないようにします。補間フレームは配置指定のカンマを含む schema 呼び出し状態を分離し、入れ子の builder 検出も維持します。通常の補間書式部分では物理改行を許可せず、verbatim/raw の書式部分では許可します。

Issue #5321 は、同時に開いている補間フレームを最大 64、式ごとの対応する区切りを最大 64 として、通常/verbatim/raw 補間から走査を再開します。入れ子のコメントと文字列も同じキャンセル可能な先頭部分の走査で処理します。隣接するリテラル区間を結合し、UTF-16 座標を保持してください。未対応の書式や不均衡・欠落した文脈は、上限付きの `SearchMatchFacet.OriginUnavailable` の理由・開始位置・範囲を伴う不明状態にします。処理上限は一致数やページングに依存しません。

`DbSearchReader.AttachCSharpOriginLines` は共有のインデックス済みファイル先頭部分を snippet 分類器へ渡します。ファイルごとの 4,096 行、8 Mi 文字、128 チャンクの読み取り上限と重複分の計上を維持し、query のページングで上限を変えないでください。文字数上限は既存の 4 Mi 文字の意味解析ウィンドウより大きく設定しています。欠落行を補わず、字句分類器がコードと推測せず `unknown` を返すようにします。通常/token-boundary の行・件数経路と MCP で同じ origin 判定と元の UTF-16 座標を維持してください。永続スキーマの変更はありません。
`DbSearchReader.AttachCSharpOriginLines` は共有のインデックス済みファイル先頭部分を snippet 分類器へ渡します。ファイル・パスごとの 4,096 行、8 Mi 文字、128 チャンクの読み取り上限と重複分の計上を維持し、query のページングで上限を変えないでください。文字数上限は既存の 4 Mi 文字の意味解析ウィンドウより大きく設定しています。欠落行を補わず、字句分類器がコードと推測せず `unknown` を返すようにします。通常/token-boundary の行・件数経路と MCP で同じ origin 判定と元の UTF-16 座標を維持してください。永続スキーマの変更はありません。

`CSharpOriginContext` はキャンセルに対応してファイル先頭部分ごとに一度だけ構築し、origin の区間を行・一致間で共有します。同じ字句走査で schema の引数位置を追跡し、同時に開いている builder 呼び出しは最大 64、遡及範囲は 64 行とし、超過時は対象ラベルを不明にします。regex/help 分類は開始行ごとにキャッシュし、ラベル照会時にもキャンセルを確認してください。一致やリテラルごとに先行行を再走査したり schema コンテキストを再構築したりしないでください。

Expand Down
4 changes: 4 additions & 0 deletions TESTING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ EOF; Windows runs it through the synchronous-pipe adapter.

## C# multiline search-origin coverage

`OriginContinuationIssue5348Tests` covers three lexical windows, comments and ordinary/verbatim/raw interpolations, malformed/missing context, Unicode and zero-width coordinates, row/count/search/find parity, cursor pass binding, character limits, cancellation, generation invalidation, and conflicting/consistent overlaps at the 128-chunk boundary. The existing #5307 chunk-limit fixture also resumes with two passes. Run these with #5307/#5321/#5324 and CLI help/completion tests on net8/net9; retain one-pass defaults and unknown/partial controls.

Keep cross-chunk closing evidence independent of row limits in database, CLI counts and MCP tests; include schema alignment commas/nested builders and ordinary-format newline rejection with verbatim/raw controls.

Issue #5321 extends this fixture with interpolation recovery before row/count/recipe/MCP matches and chunk-budget boundaries. The focused classifier matrix covers expression code, nested strings/comments, ordinary/verbatim/raw forms, escaped braces, malformed delimiters, format text, nesting limits, Unicode coordinates and bounded unavailability metadata. Run both net8/net9 lanes with the #5307 negative controls.
Expand Down Expand Up @@ -1516,6 +1518,8 @@ net8/net9 で #3831 の末尾保持と JSON 成功・失敗時の収集完了フ

## C# 複数行検索 origin の検証

`OriginContinuationIssue5348Tests` は 3 つの字句処理窓、コメント、通常/verbatim/raw 補間、不正・欠落文脈、Unicode とゼロ幅の座標、行/件数/search/find の一致、パス数とカーソルの紐づけ、文字数上限、キャンセル、世代変更による無効化、128 チャンク境界で重複行が不一致・一致する場合を検証します。既存の #5307 チャンク上限 fixture でも 2 パスで継続します。#5307/#5321/#5324 と CLI のヘルプ・補完テストとともに net8/net9 で実行し、既定の 1 パス動作と unknown/partial の対照を維持してください。

チャンクをまたぐ終端の証拠が行数上限に依存しないことを、DB・CLI 件数・MCP のテストで維持してください。schema の配置指定カンマ/入れ子の builder と、通常書式での改行拒否および verbatim/raw の対照も含めます。

Issue #5321 は同じ fixture に、行/件数/recipe/MCP の一致より前の補間回復とチャンク上限境界を追加します。分類器の専用マトリクスでは、式のコード、入れ子の文字列/コメント、通常/verbatim/raw 形式、波括弧のエスケープ、不正な区切り、書式部分、入れ子の上限、Unicode 座標、上限付きの分類不能メタデータを検証します。#5307 の負例とともに net8/net9 の両方で実行してください。
Expand Down
4 changes: 2 additions & 2 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2342,7 +2342,7 @@ Search origin filters and facets carry C# block-comment, verbatim-string and raw

Interpolation nesting and expression delimiters each have a depth limit of 64. Unbalanced or unsupported interpolation (including quoted/braced format components) remains `unknown` from the outer string onward. Unknown C# match facets expose `origin_unavailable` (MCP: `originUnavailable`) with a fixed `reason`, one-based `start_line` / `start_column` (MCP: `startLine` / `startColumn`) and `extent=remaining_file` (`line` for mismatched indexed text). Inspect these facets without an origin filter, or with `--origin unknown`; a code-only zero count cannot establish absence when classification is unavailable.

Classification reads an indexed prefix bounded by 4,096 lines, 8,388,608 UTF-16 characters and 128 chunks per file (overlapping chunk characters count toward the read budget). Missing prefix lines or exhausted bounds produce `unknown`, which does not satisfy `--origin code`. It does not read live source or require a rebuild. Inspect unknown matches without an origin filter when reviewing incomplete or large files.
Classification defaults to one indexed-prefix pass bounded by 4,096 lines, 8,388,608 UTF-16 characters and 128 chunks per file (overlapping chunk characters count toward the read budget). CLI `search`, `audit`, and `find --regex` accept `--origin-passes <1-16>` to explicitly continue lexical state through additional windows with the same per-pass limits. Restart without `--cursor` when changing the pass count. `origin_unavailable` adds optional `retry_origin_passes` and `recovery_guidance`; find counts/terminals also report `origin_passes` and `classification_incomplete_reasons`. Missing/conflicting lines, malformed constructs and exhausted bounds stay `unknown`, which does not satisfy `--origin code`. State is confined to one indexed snapshot and discarded on generation changes; live source reads, schema migration and rebuild are unnecessary. MCP retains one pass. See [bounded continuation and remaining limits](docs/find-scan-controls.md#bounded-c-lexical-continuation-5348).

#### Shell search origins

Expand Down Expand Up @@ -6420,7 +6420,7 @@ function CreateUser src/Services/UserService.cs:

補間の入れ子と式の区切りの深さには、それぞれ 64 の上限があります。不均衡または未対応の補間(引用符や波括弧を含む書式部分など)は、外側の文字列以降を `unknown` とします。不明な C# の一致 facet には `origin_unavailable`(MCP: `originUnavailable`)を付け、固定の `reason`、1 始まりの `start_line` / `start_column`(MCP: `startLine` / `startColumn`)、`extent=remaining_file`(インデックス済みテキストの不一致では `line`)を示します。origin フィルターを外すか `--origin unknown` で確認してください。分類できない場合、コードのみの件数がゼロでも不存在を証明できません。

分類は各ファイルのインデックス済み先頭部分を、4,096 行、UTF-16 で 8,388,608 文字、128 チャンクを上限として読み取ります(重複チャンクの文字も読み取り上限に含みます)。先頭からの行が欠けている場合や上限を超える場合は `unknown` となり、`--origin code` には一致しません。実ファイルの読み取りや rebuild は不要です。不完全なファイルや大きなファイルのレビューでは、origin フィルターを外して不明な一致も確認してください
分類は既定で各ファイルの索引済み先頭部分を 1 パス読み取り、4,096 行、UTF-16 で 8,388,608 文字、128 チャンクを上限とします(重複チャンクの文字も読み取り上限に含みます)。CLI の `search`、`audit`、`find --regex` では `--origin-passes <1-16>` を明示し、各パスの上限を維持したまま次の窓へ字句状態を引き継げます。パス数を変える場合は `--cursor` を外して再開始してください。`origin_unavailable` に任意の `retry_origin_passes` と `recovery_guidance` が加わり、find の件数・終端は `origin_passes` と `classification_incomplete_reasons` も示します。行の欠落・不整合、不正な構文、上限超過は `unknown` のままで、`--origin code` には一致しません。状態は同じ索引スナップショット内に限定し、世代変更時に破棄します。実ソースの読み取り、スキーマ移行、rebuild は不要です。MCP は 1 パスを維持します。[上限付き継続と残る制限](docs/find-scan-controls.md#上限付き-c-字句分類の継続-5348)も参照してください

#### Shell検索の由来分類

Expand Down
17 changes: 17 additions & 0 deletions changelog.d/unreleased/5348.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
category: fixed
issues:
- 5348
affected:
- src/CodeIndex/Database/SearchMatchClassifier.CSharp.cs
- src/CodeIndex/Database/DbSearchReader.CSharpOrigins.cs
- src/CodeIndex/Cli/QueryCommandRunner.Find.cs
---

## English

- **Continue bounded C# origin classification beyond the initial prefix (#5348)** — `search`, `audit`, and `find --regex` accept `--origin-passes` (1–16, default 1). Each additional pass resumes lexical state within the indexed snapshot while retaining the 4,096-line, 8 Mi-character and 128-chunk limits. Generation changes or conflicting overlap discard the provisional context. Unknown diagnostics identify exhausted budgets and bounded retry actions; missing or malformed context remains unknown, and find origin filters, counts and cursor pages retain conservative completeness semantics.

## 日本語

- **C# の origin 分類を最初のプレフィックス以降へ上限付きで継続可能に (#5348)** — `search`、`audit`、`find --regex` に `--origin-passes`(1〜16、既定 1)を追加しました。追加パスは同じ索引スナップショット内で字句状態を引き継ぎ、各パスの 4,096 行・8 Mi 文字・128 チャンクの上限を維持します。索引世代の変更や重複行の不一致があれば暫定文脈を破棄します。unknown の診断は到達した上限と上限付き再試行を案内し、文脈の欠落や不正な構文は unknown のまま扱い、find の origin フィルター・件数・カーソルページで保守的な完全性判定を維持します。
Loading
Loading