Skip to content

Commit 3ebb069

Browse files
committed
Merge origin/main into fix branch
2 parents ae85587 + 26ac4aa commit 3ebb069

32 files changed

Lines changed: 1052 additions & 98 deletions

AGENT_GUIDE.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ CI watching must be bounded. Do not loop indefinitely.
131131

132132
## Status Contract
133133

134-
- `status --json` and related JSON/MCP payloads currently expose the trust fields documented in `README.md` and `DEVELOPER_GUIDE.md`, including `fold_ready`, `fold_ready_reason`, `graph_table_available`, `issues_table_available`, `sql_graph_contract_ready`, `sql_graph_contract_degraded_reason`, `hotspot_family_ready`, `hotspot_family_degraded_reason`, `csharp_symbol_name_ready`, `csharp_metadata_target_ready`, `csharp_metadata_target_degraded_reason`, `indexed_head_commit`, `worktree_head_changed`, `index_writer_version`, `index_newer_than_reader`, `index_newer_than_reader_reason`, `unknown_extension_file_count`, `path_case_sensitive`, `data_dir`, `data_dir_source`, `data_dir_mode`, `mac_profile`, `db_pragma_settings` (`journal_mode`, `synchronous`, `wal_autocheckpoint`, `page_count`, `freelist_count`, `page_size`), `hooks`, MCP-only `mcp_session`, and the `status --check`-only `stale_after_seconds` / `index_age_seconds` threshold audit fields.
135-
- When `fold_ready` or `csharp_metadata_target_ready` is the only degraded readiness bit, the CLI also adds `degraded_reason`, `recommended_action`, and `alternative_action`.
134+
- `status --json` and related JSON/MCP payloads currently expose the trust fields documented in `README.md` and `DEVELOPER_GUIDE.md`, including `fold_ready`, `fold_ready_reason`, `graph_table_available`, `issues_table_available`, `file_issues_data_current`, `migration_in_progress`, `sql_graph_contract_ready`, `sql_graph_contract_degraded_reason`, `hotspot_family_ready`, `hotspot_family_degraded_reason`, `csharp_symbol_name_ready`, `csharp_metadata_target_ready`, `csharp_metadata_target_degraded_reason`, `indexed_head_commit`, `worktree_head_changed`, `index_writer_version`, `index_newer_than_reader`, `index_newer_than_reader_reason`, `unknown_extension_file_count`, `path_case_sensitive`, `data_dir`, `data_dir_source`, `data_dir_mode`, `mac_profile`, `db_pragma_settings` (`journal_mode`, `synchronous`, `wal_autocheckpoint`, `page_count`, `freelist_count`, `page_size`), `hooks`, MCP-only `mcp_session`, and the `status --check`-only `stale_after_seconds` / `index_age_seconds` threshold audit fields.
135+
- When any readiness field is degraded, the CLI adds `degraded_root_cause`, `degraded_reason`, `recommended_action`, `alternative_action`, and `readiness_degradations[]`. `degraded_root_cause` is the primary stable machine code; `readiness_degradations[]` lists every degraded field with `root_cause`, human reason, and remediation strings.
136+
- `issues_table_available` reports physical `file_issues` table presence only. `file_issues_data_current` reports whether the table is also stamped current for the active index generation.
136137
- `index_writer_version` records the `cdidx` version that last wrote to the DB (stamped into `codeindex_meta` as `cdidx_writer_version` on every full scan, update, and MCP index). `index_newer_than_reader` flips to `true` whenever any persisted numeric contract stamp in `codeindex_meta` (or unknown `PRAGMA user_version` readiness bits) exceeds the current binary's compiled maximum, so an older CLI re-opening a DB written by a newer CLI degrades loudly with an audit trail instead of silently dropping back to text-search fallbacks. `index_newer_than_reader_reason` enumerates the specific newer-than-reader stamps.
137138
- `status` also surfaces indexed-HEAD freshness via `indexed_head_sha`, `indexed_head_branch`, `indexed_head_timestamp`, and `commits_ahead_of_indexed_head`. They are stamped by `cdidx index` on every successful run (full scan AND partial update, distinct from `indexed_head_commit` which is full-scan only) on a best-effort basis (never blocks an otherwise-successful index) and omitted on non-git workspaces, detached HEAD (branch only), or legacy DBs created before this contract.
138139
- `status` also surfaces unknown-extension scan coverage via `unknown_extension_file_count`, stamped by successful full-repository index runs (`cdidx index <projectPath>` and MCP `index_project`) as the number of non-indexed files with non-empty extensions that do not map to a known language. It is omitted on legacy DBs or before a current full scan has stamped the value.

DEVELOPER_GUIDE.md

Lines changed: 45 additions & 2 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ cdidx status --check --json
5454
cdidx search "handleRequest"
5555
cdidx definition UserService
5656
cdidx search "Handle" --project MyApp
57+
cdidx validate
5758
cdidx mcp
5859
```
5960

@@ -81,6 +82,15 @@ Output controls:
8182
Use `cdidx` when a repository will be searched repeatedly from terminals,
8283
scripts, CI, or AI tools. Use `rg` when you only need a one-off text scan.
8384

85+
Help discovery:
86+
87+
| Need | Command |
88+
|---|---|
89+
| Concise command overview | `cdidx --help` |
90+
| Full command, flag, and example reference | `cdidx --help-all` or `cdidx --help-extended` |
91+
| Shared flag reference only | `cdidx --help-flags` |
92+
| One command's usage line | `cdidx <command> --help` |
93+
8494
Install choice and network notes:
8595

8696
| Need | Use |
@@ -93,13 +103,24 @@ Install choice and network notes:
93103
See [DISTRIBUTION.md](DISTRIBUTION.md) for the full channel matrix and
94104
[isolated network install notes](USER_GUIDE.md#isolated-networks-and-proxies).
95105

106+
### Validate
107+
108+
Run `cdidx validate [--db <path>] [--json] [--verbose] [--kind <kind>] [--path <glob>]`
109+
to report indexed file issues such as replacement characters (`U+FFFD`), BOMs,
110+
NUL bytes, mixed line endings, UTF-16 BOMs, and likely non-UTF8 content.
111+
Validation findings are reported in the output and do not by themselves make
112+
the command fail; the command exits non-zero when the DB cannot be read or the
113+
command arguments are invalid. Use `--json` for machine-readable issue rows.
114+
96115
### Shell Completion
97116

98117
Generate completion scripts with `cdidx --completions <bash|zsh|fish|powershell>`.
99118
The generated scripts complete subcommands, flags, and common flag values:
100119
`--lang` suggests supported languages, `--kind` suggests symbol/reference
101120
kinds, and path-like options such as `--db`, `--path`, and `--output` use shell
102-
file completion.
121+
file completion. Each generated script includes the `cdidx` version that
122+
produced it; regenerate installed completion scripts after upgrading or
123+
downgrading `cdidx`.
103124

104125
## Highlights
105126

@@ -138,6 +159,7 @@ The documented `status --json` trust contract covers these fields:
138159
<table>
139160
<tbody>
140161
<tr><td><code>fold_ready</code></td><td><code>fold_ready_reason</code></td><td><code>graph_table_available</code></td><td><code>issues_table_available</code></td></tr>
162+
<tr><td><code>file_issues_data_current</code></td><td><code>migration_in_progress</code></td><td><code>degraded_root_cause</code></td><td><code>readiness_degradations</code></td></tr>
141163
<tr><td><code>sql_graph_contract_ready</code></td><td><code>sql_graph_contract_degraded_reason</code></td><td><code>hotspot_family_ready</code></td><td><code>hotspot_family_degraded_reason</code></td></tr>
142164
<tr><td><code>csharp_symbol_name_ready</code></td><td><code>csharp_metadata_target_ready</code></td><td><code>csharp_metadata_target_degraded_reason</code></td><td><code>indexed_head_commit</code></td></tr>
143165
<tr><td><code>worktree_head_changed</code></td><td><code>indexed_head_sha</code></td><td><code>indexed_head_branch</code></td><td><code>indexed_head_timestamp</code></td></tr>
@@ -149,6 +171,8 @@ The documented `status --json` trust contract covers these fields:
149171
</tbody>
150172
</table>
151173

174+
When any readiness field is degraded, `degraded_root_cause` identifies the primary stable code and `readiness_degradations[]` lists every degraded field with `root_cause`, human `degraded_reason`, `recommended_action`, and `alternative_action`. `issues_table_available` reports physical table presence; use `file_issues_data_current` to decide whether `file_issues` rows are current for the index generation.
175+
152176
For MCP `status`, `mcp_session` is session-scoped diagnostic data rather than persisted index state. It includes `log_level`, `roots`, optional `client_info`, and optional `client_capabilities`.
153177

154178
`hotspot_family_degraded_reason` uses these values:
@@ -271,6 +295,7 @@ cdidx status --check --json
271295
cdidx search "handleRequest"
272296
cdidx definition UserService
273297
cdidx search "Handle" --project MyApp
298+
cdidx validate
274299
cdidx mcp
275300
```
276301

@@ -298,12 +323,31 @@ cdidx mcp
298323
ターミナル、スクリプト、CI、AI ツールから同じリポジトリを繰り返し検索する
299324
場合は `cdidx` が向いています。1回限りのテキスト検索には `rg` が向いています。
300325

326+
help の探し方:
327+
328+
| 目的 | コマンド |
329+
|---|---|
330+
| 短いコマンド概要 | `cdidx --help` |
331+
| 全コマンド、flag、例の完全版 | `cdidx --help-all` または `cdidx --help-extended` |
332+
| 共有 flag だけの一覧 | `cdidx --help-flags` |
333+
| 1 コマンドの usage 行 | `cdidx <command> --help` |
334+
335+
### Validate
336+
337+
`cdidx validate [--db <path>] [--json] [--verbose] [--kind <kind>] [--path <glob>]`
338+
は、index 済みファイルの replacement character (`U+FFFD`)、BOM、NUL byte、
339+
混在改行、UTF-16 BOM、非 UTF-8 らしい内容などを報告します。validation finding は
340+
出力で報告され、それ自体では command failure になりません。DB を読めない場合や
341+
引数が不正な場合は non-zero で終了します。機械処理には `--json` を使えます。
342+
301343
### シェル補完
302344

303345
`cdidx --completions <bash|zsh|fish|powershell>` で補完スクリプトを生成できます。
304346
生成されたスクリプトは subcommand、flag、よく使う flag 値を補完します。
305347
`--lang` は対応言語、`--kind` は symbol / reference kind を提示し、`--db`
306348
`--path``--output` など path 系 option は shell の file completion を使います。
349+
生成された script には生成元の `cdidx` version が含まれるため、`cdidx`
350+
upgrade / downgrade 後はインストール済み補完 script を再生成してください。
307351

308352
## 特長
309353

@@ -328,6 +372,7 @@ cdidx mcp
328372
<table>
329373
<tbody>
330374
<tr><td><code>fold_ready</code></td><td><code>fold_ready_reason</code></td><td><code>graph_table_available</code></td><td><code>issues_table_available</code></td></tr>
375+
<tr><td><code>file_issues_data_current</code></td><td><code>migration_in_progress</code></td><td><code>degraded_root_cause</code></td><td><code>readiness_degradations</code></td></tr>
331376
<tr><td><code>sql_graph_contract_ready</code></td><td><code>sql_graph_contract_degraded_reason</code></td><td><code>hotspot_family_ready</code></td><td><code>hotspot_family_degraded_reason</code></td></tr>
332377
<tr><td><code>csharp_symbol_name_ready</code></td><td><code>csharp_metadata_target_ready</code></td><td><code>csharp_metadata_target_degraded_reason</code></td><td><code>indexed_head_commit</code></td></tr>
333378
<tr><td><code>worktree_head_changed</code></td><td><code>indexed_head_sha</code></td><td><code>indexed_head_branch</code></td><td><code>indexed_head_timestamp</code></td></tr>
@@ -339,6 +384,8 @@ cdidx mcp
339384
</tbody>
340385
</table>
341386

387+
readiness field のいずれかが degraded の場合、`degraded_root_cause` は primary の安定コードを示し、`readiness_degradations[]` は degraded な各 field と `root_cause`、人間向け `degraded_reason``recommended_action``alternative_action` を列挙します。`issues_table_available` は物理 table の有無を表し、`file_issues` 行が現在の index generation に対して current かどうかは `file_issues_data_current` を使って判定します。
388+
342389
MCP `status``mcp_session` は永続化された index 状態ではなく、セッション単位の診断情報です。`log_level``roots`、任意の `client_info`、任意の `client_capabilities` を含みます。
343390

344391
`hotspot_family_degraded_reason` は次の値を使います。
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
category: fixed
3+
issues:
4+
- 1422
5+
affected:
6+
- src/CodeIndex/Cli/ConsoleUi.cs
7+
- tests/CodeIndex.Tests/ConsoleUiTests.cs
8+
---
9+
10+
## English
11+
12+
- **Per-command usage lines now show `--top` beside `--limit` (#1422)** — query commands that accept the result cap alias now document `[--limit <n>|--top <n>]`, matching the parser and shell-completion schema.
13+
14+
## 日本語
15+
16+
- **各 command の usage 行で `--limit` と並べて `--top` を表示するようになりました (#1422)** — result cap alias を受け付ける query command が `[--limit <n>|--top <n>]` を記載し、parser と shell-completion schema と一致します。
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
category: fixed
3+
issues:
4+
- 1484
5+
- 1486
6+
- 1761
7+
- 1931
8+
affected:
9+
- src/CodeIndex/Cli/QueryCommandRunner.cs
10+
- src/CodeIndex/Database/DbReader.FilesStatus.cs
11+
- src/CodeIndex/Models/QueryResults.cs
12+
---
13+
14+
## English
15+
16+
- **Status readiness degradation now has structured guidance (#1484, #1931)**`status --json` now reports `degraded_root_cause` and `readiness_degradations[]` for every degraded readiness field, including multi-degraded states.
17+
- **Status separates issue-table presence from issue-row freshness (#1486)**`issues_table_available` now reports physical table presence, while `file_issues_data_current` reports whether validate issue rows are current for the index generation.
18+
- **Status identifies active migration/write windows (#1761)**`status --json` now exposes `migration_in_progress` so clients can distinguish temporary writer activity from permanent readiness degradation.
19+
20+
## 日本語
21+
22+
- **status readiness degradation に構造化 guidance を追加しました (#1484, #1931)**`status --json` は multi-degraded 状態を含むすべての degraded readiness field について `degraded_root_cause``readiness_degradations[]` を返すようになりました。
23+
- **status が issue table の存在と issue row の鮮度を分離しました (#1486)**`issues_table_available` は物理 table の存在を表し、`file_issues_data_current` が validate issue row が現在の index generation に対して current かどうかを表します。
24+
- **status が active migration/write window を識別するようになりました (#1761)**`status --json``migration_in_progress` を公開し、クライアントが一時的な writer activity と恒久的な readiness degradation を区別できるようになりました。
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
category: docs
3+
issues:
4+
- 1694
5+
affected:
6+
- README.md
7+
- DEVELOPER_GUIDE.md
8+
- src/CodeIndex/Cli/ConsoleUi.cs
9+
---
10+
11+
## English
12+
13+
- **Documented `cdidx validate` in user-facing help and guides (#1694)**`validate` now appears in the top-level command summaries, README, and developer guidance so indexed-content validation is discoverable without reading source.
14+
15+
## 日本語
16+
17+
- **`cdidx validate` をユーザー向け help と guide に記載しました (#1694)**`validate` が top-level command summary、README、developer guidance に表示されるようになり、source を読まなくても indexed content validation を見つけられます。
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
category: changed
3+
issues:
4+
- 1702
5+
affected:
6+
- src/CodeIndex/Cli/ConsoleUi.cs
7+
- src/CodeIndex/Cli/ProgramRunner.cs
8+
- tests/CodeIndex.Tests/ConsoleUiTests.cs
9+
- tests/CodeIndex.Tests/ProgramCliTests.cs
10+
- README.md
11+
- DEVELOPER_GUIDE.md
12+
---
13+
14+
## English
15+
16+
- **Top-level help is now brief by default (#1702)**`cdidx --help` prints a concise overview, while `--help-all` / `--help-extended` retain the full reference and `--help-flags` prints only shared flag tables.
17+
18+
## 日本語
19+
20+
- **top-level help の既定表示を短くしました (#1702)**`cdidx --help` は簡潔な概要を表示し、完全版は `--help-all` / `--help-extended`、共有 flag 一覧は `--help-flags` で確認できます。
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
category: added
3+
issues:
4+
- 1730
5+
affected:
6+
- src/CodeIndex/Cli/QueryCommandRunner.cs
7+
- src/CodeIndex/Database/DbContext.cs
8+
- DEVELOPER_GUIDE.md
9+
---
10+
11+
## English
12+
13+
- **Added read-only database opens for query commands (#1730)** — query commands now accept `--read-only` / `--immutable` and translate normal database paths into SQLite immutable read-only URIs.
14+
15+
## 日本語
16+
17+
- **クエリコマンドで読み取り専用 DB オープンを追加しました (#1730)** — クエリコマンドは `--read-only` / `--immutable` を受け付け、通常の DB パスを SQLite の immutable read-only URI に変換します。
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
category: security
3+
issues:
4+
- 1794
5+
affected:
6+
- src/CodeIndex/Database/DbContext.cs
7+
- src/CodeIndex/Models/QueryResults.cs
8+
- DEVELOPER_GUIDE.md
9+
---
10+
11+
## English
12+
13+
- **Restricted SQLite database file permissions on POSIX (#1794)** — cdidx now applies `0600` to `codeindex.db` and WAL/SHM sidecars and reports `db_file_mode` in `status --json`.
14+
15+
## 日本語
16+
17+
- **POSIX で SQLite DB ファイル権限を制限しました (#1794)** — cdidx は `codeindex.db` と WAL/SHM sidecar に `0600` を適用し、`status --json``db_file_mode` を出します。
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
category: fixed
3+
issues:
4+
- 1798
5+
affected:
6+
- src/CodeIndex/Cli/IndexCommandRunner.cs
7+
- src/CodeIndex/Database/DbContext.cs
8+
- src/CodeIndex/Database/DbReader.FilesStatus.cs
9+
- src/CodeIndex/Models/QueryResults.cs
10+
---
11+
12+
## English
13+
14+
- **Checkpoint WAL before read-only fallback (#1798)** — writable-open fallback now attempts `wal_checkpoint(TRUNCATE)` first and exposes fallback/checkpoint diagnostics in `status --json`.
15+
16+
## 日本語
17+
18+
- **読み取り専用フォールバック前に WAL checkpoint を試みるようにしました (#1798)** — writable open のフォールバック前に `wal_checkpoint(TRUNCATE)` を試行し、fallback / checkpoint 診断を `status --json` に出します。

0 commit comments

Comments
 (0)