diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 5544cb777a..818c5bb74d 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -801,7 +801,7 @@ See [Exit codes](USER_GUIDE.md#exit-codes) in USER_GUIDE. ## Error code taxonomy -Process exit codes are coarse (`0` success, `1` usage, `2` not-found, `3` db, `4` feature-unavailable, `5` stale). Scripts, oncall runbooks, and AI agents that need to react to *which* failure happened — not just the bucket — should read the stable `Exxx_NAME` taxonomy emitted on every CLI / MCP error path. The user-facing table lives in [Error codes](USER_GUIDE.md#error-codes); this section captures the developer contract. +Process exit codes are coarse (`0` success including valid zero-row queries, `1` usage, `2` not-found or strict zero-row query, `3` db, `4` feature-unavailable, `5` stale). Query commands return `0` for genuine zero-row results by default and reserve `2` for missing indexed data or callers that opt into `--strict-not-found`. Scripts, oncall runbooks, and AI agents that need to react to *which* failure happened — not just the bucket — should read the stable `Exxx_NAME` taxonomy emitted on every CLI / MCP error path. The user-facing table lives in [Error codes](USER_GUIDE.md#error-codes); this section captures the developer contract. **Where it surfaces** diff --git a/README.md b/README.md index d1e2c7603a..87df9e57bc 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ file completion. | DB maintenance | New indexes use SQLite incremental auto-vacuum. `cdidx vacuum` reclaims free pages from existing DBs, including a one-time full `VACUUM` conversion for legacy no-autovacuum DBs, and `status --json` reports metrics under `db_pragma_settings`. | | Security defaults | On POSIX systems, `.cdidx` is created with `0700` permissions and `status --json` reports the effective `data_dir_mode` when available. | | Diagnostics | `status --explain ` describes readiness fields and remediation. Read commands support `--profile`, `--slow-query-ms `, and --trace=stderr|file|none; file traces write daily `query-trace-YYYYMMDD.jsonl` files next to the lifecycle log. | +| Query exit codes | Valid zero-result query commands exit `0` by default. Pass `--strict-not-found` when scripts should treat zero rows as exit code `2`. | | Drift checks | `cdidx diff ` compares schema, file, symbol, and reference deltas with stable exit codes: `0` identical, `1` drift, `2` schema mismatch, `3` unreadable DB. | | Extensibility and feedback | Post-extraction hooks from `~/.config/cdidx/hooks/*.dll` or `CDIDX_HOOKS_DIR` can enrich symbols and references. `cdidx suggestions` lists, inspects, and exports local suggestion history, with fuzzy MCP suggestion deduplication controlled by CLI, env, or `.cdidxrc.json`. | | Language coverage | 78 detected languages, with symbol and graph support where available. | diff --git a/USER_GUIDE.md b/USER_GUIDE.md index d196035d29..2e4fb5bd15 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -989,6 +989,7 @@ cdidx report --output report.tgz --json | `--since ` | `search`, `definition`, `symbols`, `files` | Filter to files modified since this ISO 8601 timestamp. Offsetless values (e.g. `2024-01-01T00:00:00`) are treated as UTC so the same flag resolves to the same instant in every timezone; append `Z` or an explicit offset (`+09:00`) to be explicit. | | `--no-dedup` | `search` | Disable overlapping-chunk deduplication for raw results | | `--reverse` | `deps` | Reverse lookup: show files that depend ON the matched path | +| `--strict-not-found` | Query commands | Return exit code `2` when a valid query produces zero rows. Without this flag, zero-result queries exit `0` and keep their normal empty/zero-result output. | | `--top ` | Query commands | Alias for `--limit` | | `--color ` | All commands | Control ANSI color output. Accepts `auto` (default), `always`, or `never`. Precedence: `--color` flag > `CLICOLOR_FORCE` > `NO_COLOR` > `CLICOLOR=0` > terminal capability auto-detect. Auto mode treats redirected stdout and StringWriter-style test capture as non-ANSI; on Windows it also accepts ConPTY/Windows Terminal virtual-terminal support and terminal hints such as `WT_SESSION`, `WT_PROFILE_ID`, `TERM_PROGRAM`, or non-`dumb` `TERM`. Use `--color=always` to keep colored kind labels through a pager such as `cdidx symbols Foo \| less -R`; use `--color=never` (or `NO_COLOR=1`) to suppress ANSI even on a TTY. | | `--palette ` | All commands | Choose the ANSI palette used when color output is enabled. Accepts `basic` (8-color SGR 30–37, the default fallback for minimal SSH/CI terminals), `256` (256-color `\x1b[38;5;Nm`), or `truecolor` (24-bit RGB `\x1b[38;2;R;G;Bm`). Precedence: `--palette` flag > `CDIDX_COLOR_PALETTE` env var > `COLORTERM` / `TERM` auto-detect. The basic palette avoids `\x1b[90m` (bright-black / dim), which is unreadable on many minimal terminals. | @@ -1000,9 +1001,9 @@ If a query itself begins with `-`, pass it as `--query ` or `-- `. | Code | Meaning | |---|---| -| `0` | Success | +| `0` | Success, including valid queries that produce zero rows | | `1` | Usage error (missing command, missing required positional input, or command-shape error) | -| `2` | Not found (no search results, missing directory) | +| `2` | Not found (missing indexed path or zero-result query when `--strict-not-found` is set) | | `3` | Permanent database error | | `4` | Feature unavailable on this build (for example CLI `--json` on a manually trimmed custom build) | | `5` | Stale index (`status --check` found DB/workspace differences) | diff --git a/changelog.d/unreleased/1425.changed.md b/changelog.d/unreleased/1425.changed.md new file mode 100644 index 0000000000..b43d36e0ea --- /dev/null +++ b/changelog.d/unreleased/1425.changed.md @@ -0,0 +1,20 @@ +--- +category: changed +issues: + - 1425 +affected: + - src/CodeIndex/Cli/QueryCommandRunner.cs + - src/CodeIndex/Cli/CliFlagSchema.cs + - tests/CodeIndex.Tests/QueryCommandRunnerTests.cs + - README.md + - USER_GUIDE.md + - DEVELOPER_GUIDE.md +--- + +## English + +- **Zero-result query exit codes are consistent by default (#1425)** — valid query commands now exit `0` for genuine zero-row results, and `--strict-not-found` restores exit code `2` for scripts that require non-zero empty results. + +## 日本語 + +- **0 件クエリの終了コードを既定で統一しました (#1425)** — 有効な query コマンドが本当に 0 件を返す場合は終了コード `0` になり、空結果を非 0 として扱いたいスクリプト向けに `--strict-not-found` で終了コード `2` を返せます。 diff --git a/src/CodeIndex/Cli/CliFlagSchema.cs b/src/CodeIndex/Cli/CliFlagSchema.cs index d29fa52cb8..5a1ce19d13 100644 --- a/src/CodeIndex/Cli/CliFlagSchema.cs +++ b/src/CodeIndex/Cli/CliFlagSchema.cs @@ -97,6 +97,11 @@ internal static class CliFlagSchema "search", "definition", "references", "callers", "callees", "symbols", "files", "find", "impact", "unused", "hotspots", ]; + private static readonly string[] StrictNotFoundCommands = + [ + "search", "definition", "references", "callers", "callees", "symbols", + "files", "find", "excerpt", "map", "inspect", "deps", "impact", "unused", "hotspots", + ]; private static readonly string[] KindCommands = [ @@ -206,6 +211,7 @@ private static IReadOnlyList BuildAll() new() { Name = "--rank-by", ValuePlaceholder = "", Description = "Rank callers/callees by weighted structural score, raw count, or kind bucket", Commands = Set(RankByCommands) }, new() { Name = "--raw-kinds", Description = "Show raw reference kinds instead of logical graph kinds", Commands = Set(RawKindsCommands) }, new() { Name = "--count", Description = "Count only", Commands = Set(CountCommands) }, + new() { Name = "--strict-not-found", Description = "Return exit code 2 when a valid query has zero rows", Commands = Set(StrictNotFoundCommands) }, new() { Name = "--since", ValuePlaceholder = "", Description = "Filter by modified-since timestamp", Commands = Set(SinceCommands) }, new() { Name = "--bytes", Description = "Show raw byte counts in human output", Commands = Set(ByteFormatCommands) }, new() { Name = "--query", ValuePlaceholder = "", Description = "Literal query", Commands = Set(QueryCommands) }, diff --git a/src/CodeIndex/Cli/QueryCommandRunner.cs b/src/CodeIndex/Cli/QueryCommandRunner.cs index 93fd68a74b..d7a6afc92f 100644 --- a/src/CodeIndex/Cli/QueryCommandRunner.cs +++ b/src/CodeIndex/Cli/QueryCommandRunner.cs @@ -150,6 +150,7 @@ private sealed record StatusReadinessField( "--fts", "--body", "--count", + "--strict-not-found", "--no-dedup", "--no-visibility-rank", "--exact", @@ -407,7 +408,7 @@ public static int RunSearch(string[] cmdArgs, JsonSerializerOptions jsonOptions) WriteLangHint(options.Lang, reader); WriteZeroResultHints(options, reader); } - return CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.Json) @@ -562,7 +563,7 @@ public static int RunDefinition(string[] cmdArgs, JsonSerializerOptions jsonOpti WriteLangHint(options.Lang, reader); WriteZeroResultHints(options, reader, "Try 'search' for full-text matches instead of symbol lookup."); } - return CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.Json) @@ -711,7 +712,7 @@ public static int RunReferences(string[] cmdArgs, JsonSerializerOptions jsonOpti WriteLangHint(options.Lang, reader); WriteDegradedGraphZeroResult(reader, "references", json: false, graphAvailable: reader._hasReferencesTable, jsonOptions); } - return CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.Json) @@ -837,7 +838,7 @@ public static int RunCallers(string[] cmdArgs, JsonSerializerOptions jsonOptions WriteLangHint(options.Lang, reader); WriteDegradedGraphZeroResult(reader, "callers", json: false, graphAvailable: reader._hasReferencesTable, jsonOptions); } - return CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.Json) @@ -963,7 +964,7 @@ public static int RunCallees(string[] cmdArgs, JsonSerializerOptions jsonOptions WriteLangHint(options.Lang, reader); WriteDegradedGraphZeroResult(reader, "callees", json: false, graphAvailable: reader._hasReferencesTable, jsonOptions); } - return CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.Json) @@ -1136,7 +1137,7 @@ public static int RunSymbols(string[] cmdArgs, JsonSerializerOptions jsonOptions WriteLangHint(options.Lang, reader); WriteZeroResultHints(options, reader); } - return CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.Json) @@ -1211,7 +1212,7 @@ public static int RunFiles(string[] cmdArgs, JsonSerializerOptions jsonOptions) WriteLangHint(options.Lang, reader); WriteZeroResultHints(options, reader); } - return CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.Json) @@ -1327,7 +1328,7 @@ public static int RunExcerpt(string[] cmdArgs, JsonSerializerOptions jsonOptions { if (!options.Json) Console.Error.WriteLine("No excerpt found."); - return CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.Json) @@ -1448,7 +1449,7 @@ public static int RunFind(string[] cmdArgs, JsonSerializerOptions jsonOptions) WriteZeroResultHints(options, reader, filterHint: "try broadening --path or adding another --path value; --path is required for find."); } } - return CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.Json) @@ -1638,7 +1639,7 @@ public static int RunMap(string[] cmdArgs, JsonSerializerOptions jsonOptions) { Console.Error.WriteLine("No files found matching the given filters."); } - return CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.Json) @@ -1793,7 +1794,7 @@ public static int RunInspect(string[] cmdArgs, JsonSerializerOptions jsonOptions WriteRepoMapSection("Callees", analysis.Callees.Select(item => $"{item.CallerName ?? ""} -> {item.CalleeName} ({item.ReferenceCount} refs)")); } - return CommandExitCodes.Success; + return IsEmptySymbolAnalysis(analysis) ? ZeroResultExitCode(options) : CommandExitCodes.Success; }); } @@ -2485,7 +2486,7 @@ public static int RunImpact(string[] cmdArgs, JsonSerializerOptions jsonOptions) WriteGraphSupportHint(options.Lang); WriteDegradedGraphZeroResult(reader, "callers", json: false, graphAvailable: reader._hasReferencesTable, jsonOptions); } - return options.CountOnly ? CommandExitCodes.Success : CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.CountOnly) @@ -2651,7 +2652,7 @@ public static int RunDeps(string[] cmdArgs, JsonSerializerOptions jsonOptions) WriteSqlGraphContractWarningIfNeeded(json: false, sqlGraphSignal, reader, options); WriteDegradedGraphZeroResult(reader, "edges", json: false, graphAvailable: reader._hasReferencesTable, jsonOptions); } - return CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.Json) @@ -2900,7 +2901,7 @@ public static int RunHotspots(string[] cmdArgs, JsonSerializerOptions jsonOption WriteSqlGraphContractWarningIfNeeded(json: false, effectiveSqlGraphSignal, reader, options); WriteDegradedGraphZeroResult(reader, "hotspots", json: false, graphAvailable: reader._hasReferencesTable, jsonOptions); } - return options.CountOnly ? CommandExitCodes.Success : CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } var definitionSiteTotal = groupedResults.Sum(g => g.DefinitionSites); @@ -3046,7 +3047,7 @@ public static int RunHotspots(string[] cmdArgs, JsonSerializerOptions jsonOption WriteSqlGraphContractWarningIfNeeded(json: false, effectiveSqlGraphSignal, reader, options); WriteDegradedGraphZeroResult(reader, "hotspots", json: false, graphAvailable: reader._hasReferencesTable, jsonOptions); } - return options.CountOnly ? CommandExitCodes.Success : CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.CountOnly) @@ -3173,7 +3174,7 @@ public static int RunHotspots(string[] cmdArgs, JsonSerializerOptions jsonOption WriteSqlGraphContractWarningIfNeeded(json: false, sqlGraphSignal, reader, options); WriteDegradedGraphZeroResult(reader, "hotspots", json: false, graphAvailable: reader._hasReferencesTable, jsonOptions); } - return options.CountOnly ? CommandExitCodes.Success : CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.CountOnly) @@ -3334,7 +3335,7 @@ public static int RunUnused(string[] cmdArgs, JsonSerializerOptions jsonOptions) WriteSqlGraphContractWarningIfNeeded(json: false, sqlGraphSignal, reader, options); WriteDegradedGraphZeroResult(reader, "symbols", json: false, graphAvailable: reader._hasReferencesTable, jsonOptions); } - return options.Json ? CommandExitCodes.Success : CommandExitCodes.NotFound; + return ZeroResultExitCode(options); } if (options.Json) @@ -3660,6 +3661,7 @@ public static QueryCommandOptions ParseArgs(string[] args, bool jsonDefault, boo bool rawFts = false; bool includeBody = false; bool countOnly = false; + bool strictNotFound = false; int? startLine = null; int? endLine = null; int contextBefore = 0; @@ -3921,6 +3923,9 @@ void WarnIfDuplicateSingleValueOption(string canonicalName, string newValue) case "--count": countOnly = true; break; + case "--strict-not-found": + strictNotFound = true; + break; case "--by-bucket": break; case "--no-dedup": @@ -4301,6 +4306,7 @@ void WarnIfDuplicateSingleValueOption(string canonicalName, string newValue) ExcludeTests = excludeTests, IncludeGenerated = includeGenerated, CountOnly = countOnly, + StrictNotFound = strictNotFound, Since = since, NoDedup = noDedup, NoVisibilityRank = noVisibilityRank, @@ -4609,6 +4615,17 @@ private static bool TryRejectMultipleExactFlags(QueryCommandOptions options, out // preview 系オプションの検証はコマンド別 allowlist に寄せたため、この shim は常に null を返す。 private static string? ValidatePreviewOptions(string commandName, string[] args, bool allowMaxLineWidth, bool allowFocusOptions) => null; + private static int ZeroResultExitCode(QueryCommandOptions options) + => options.StrictNotFound ? CommandExitCodes.NotFound : CommandExitCodes.Success; + + private static bool IsEmptySymbolAnalysis(SymbolAnalysisResult analysis) + => analysis.File == null + && analysis.Definitions.Count == 0 + && analysis.NearbySymbols.Count == 0 + && analysis.References.Count == 0 + && analysis.Callers.Count == 0 + && analysis.Callees.Count == 0; + private static int WithDb(QueryCommandOptions options, JsonSerializerOptions jsonOptions, Func action, Action? afterProfile = null) { var dbPath = options.DbPath; @@ -6754,6 +6771,7 @@ public sealed class QueryCommandOptions public bool ExcludeTests { get; init; } public bool IncludeGenerated { get; init; } public bool CountOnly { get; init; } + public bool StrictNotFound { get; init; } public DateTime? Since { get; init; } public bool NoDedup { get; init; } public bool NoVisibilityRank { get; init; } diff --git a/tests/CodeIndex.Tests/IndexCommandRunnerTests.cs b/tests/CodeIndex.Tests/IndexCommandRunnerTests.cs index 40a2119581..6d18af07bf 100644 --- a/tests/CodeIndex.Tests/IndexCommandRunnerTests.cs +++ b/tests/CodeIndex.Tests/IndexCommandRunnerTests.cs @@ -7149,7 +7149,7 @@ public void Call(Api api) var dbPath = Path.Combine(projectRoot, ".cdidx", "codeindex.db"); var (hotspotsExitCode, hotspotsJson) = RunHotspotsJsonWithPaths(dbPath, "csharp", "function", ["projA/", "projB/"]); - Assert.Equal(CommandExitCodes.NotFound, hotspotsExitCode); + Assert.Equal(CommandExitCodes.Success, hotspotsExitCode); Assert.True(hotspotsJson.GetProperty("hotspot_family_ready").GetBoolean()); Assert.Equal(0, hotspotsJson.GetProperty("count").GetInt32()); Assert.Empty(hotspotsJson.GetProperty("hotspots").EnumerateArray()); diff --git a/tests/CodeIndex.Tests/JsonEnvelopeWrapperTests.cs b/tests/CodeIndex.Tests/JsonEnvelopeWrapperTests.cs index 7689f38e0f..d85ce3da72 100644 --- a/tests/CodeIndex.Tests/JsonEnvelopeWrapperTests.cs +++ b/tests/CodeIndex.Tests/JsonEnvelopeWrapperTests.cs @@ -66,10 +66,10 @@ public void Search_WithEnvelope_ZeroResultsKeepsEnvelopeAndPropagatesExitCode() _jsonOptions, "1.0.0")); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); using var document = JsonDocument.Parse(stdout); var metadata = document.RootElement.GetProperty("metadata"); - Assert.Equal(CommandExitCodes.NotFound, metadata.GetProperty("exit_code").GetInt32()); + Assert.Equal(CommandExitCodes.Success, metadata.GetProperty("exit_code").GetInt32()); Assert.Equal("DoesNotExist_xyz_123", metadata.GetProperty("query_normalized").GetString()); var results = document.RootElement.GetProperty("results"); @@ -200,7 +200,7 @@ public void Search_WithoutEnvelope_ZeroResultsEmitsDoneSentinel() _jsonOptions, "1.0.0")); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); var lines = stdout.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries); Assert.Equal(2, lines.Length); using var zeroDocument = JsonDocument.Parse(lines[0]); diff --git a/tests/CodeIndex.Tests/ProgramCliTests.cs b/tests/CodeIndex.Tests/ProgramCliTests.cs index 33baeb58ff..64dfa7d058 100644 --- a/tests/CodeIndex.Tests/ProgramCliTests.cs +++ b/tests/CodeIndex.Tests/ProgramCliTests.cs @@ -104,7 +104,7 @@ public void QueryQuietFlag_SuppressesInformationalStderrOnZeroResults(string qui var (exitCode, stdout, stderr) = RunCliInSubprocess([quietFlag, "search", "definitely_missing_query", "--db", dbPath]); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stdout); Assert.Equal(string.Empty, stderr); } @@ -127,7 +127,7 @@ public void QueryQuietEnvironment_SuppressesVerboseStderr() ["search", "definitely_missing_query", "--verbose", "--db", dbPath], new Dictionary { [ProgramRunner.QuietEnvironmentVariable] = "1" }); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stdout); Assert.Equal(string.Empty, stderr); } diff --git a/tests/CodeIndex.Tests/QueryCommandRunnerTests.cs b/tests/CodeIndex.Tests/QueryCommandRunnerTests.cs index 9a27d3aa2d..210c2a4833 100644 --- a/tests/CodeIndex.Tests/QueryCommandRunnerTests.cs +++ b/tests/CodeIndex.Tests/QueryCommandRunnerTests.cs @@ -385,7 +385,7 @@ public void RunSearch_JsonArrayNoResultsEmitsEmptyArray_Issue1850() ["Missing", "--db", dbPath, "--json=array"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); using var document = JsonDocument.Parse(stdout); Assert.Equal(JsonValueKind.Array, document.RootElement.ValueKind); @@ -398,6 +398,63 @@ public void RunSearch_JsonArrayNoResultsEmitsEmptyArray_Issue1850() } } + [Fact] + public void RunSearch_StrictNotFoundReturnsNotFoundForZeroResults_Issue1425() + { + var projectRoot = TestProjectHelper.CreateTempProject("cdidx_search_strict_not_found"); + try + { + var dbPath = TestProjectHelper.CreateProjectDb(projectRoot); + TestProjectHelper.InsertIndexedFile( + dbPath, + "src/auth.cs", + "csharp", + "public class AuthFixture { }\n"); + + var (exitCode, stdout, stderr) = CaptureConsole(() => QueryCommandRunner.RunSearch( + ["Missing", "--db", dbPath, "--strict-not-found"], + _jsonOptions)); + + Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(string.Empty, stdout); + Assert.Contains("No results found", stderr); + } + finally + { + TestProjectHelper.DeleteDirectory(projectRoot); + } + } + + [Fact] + public void RunInspect_StrictNotFoundReturnsNotFoundForEmptyAnalysis_Issue1425() + { + var projectRoot = TestProjectHelper.CreateTempProject("cdidx_inspect_strict_not_found"); + try + { + var dbPath = TestProjectHelper.CreateProjectDb(projectRoot); + TestProjectHelper.InsertIndexedFile( + dbPath, + "src/auth.cs", + "csharp", + "public class AuthFixture { }\n"); + + var (exitCode, stdout, stderr) = CaptureConsole(() => QueryCommandRunner.RunInspect( + ["Missing", "--db", dbPath, "--json", "--strict-not-found"], + _jsonOptions)); + + Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(string.Empty, stderr); + using var document = ParseJsonOutput(stdout); + Assert.Equal("Missing", document.RootElement.GetProperty("query").GetString()); + Assert.Empty(document.RootElement.GetProperty("definitions").EnumerateArray()); + Assert.Empty(document.RootElement.GetProperty("references").EnumerateArray()); + } + finally + { + TestProjectHelper.DeleteDirectory(projectRoot); + } + } + [Fact] public void RunSearch_JsonFormatRejectsUnknownValue_Issue1850() { @@ -2071,7 +2128,7 @@ public void RunSearch_ZeroResultsHumanOutputIncludesQueryFilterContext() ["missing-token", "--db", dbPath, "--path", "src/**", "--lang", "csharp", "--limit", "7"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stdout); Assert.Contains("No results found. (query: \"missing-token\", path: src/**, lang: csharp, limit: 7)", stderr); } @@ -2098,7 +2155,7 @@ public void RunSearch_ZeroResultsJsonIncludesStructuredQueryContext() ["missing-token", "--db", dbPath, "--path", "src/**", "--lang", "csharp", "--limit", "7", "--json"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); using var document = ParseJsonOutput(stdout); var root = document.RootElement; @@ -4011,7 +4068,7 @@ public void RunSearch_LangTypo_SuggestsClosestLanguage_Issue1582() ["nothing_matches_xyzzy", "--db", dbPath, "--lang", "csarp"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stdout); Assert.Contains("No results found.", stderr); Assert.Contains("Did you mean: --lang csharp?", stderr); @@ -4047,7 +4104,7 @@ public void RunSearch_LangNotIndexedButSupported_DoesNotSelfSuggest_Issue1582() ["nothing_matches_xyzzy", "--db", dbPath, "--lang", "java"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stdout); Assert.Contains("No results found.", stderr); Assert.Contains("'java' not found in index", stderr); @@ -4239,7 +4296,7 @@ public void RunSymbols_JsonZeroResults_ReturnEmptyStdout() ["MissingSymbol", "--db", dbPath, "--json"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stdout); Assert.Equal(string.Empty, stderr); } @@ -4280,7 +4337,7 @@ public void RunReferences_JsonZeroResults_EmitEnvelopeAndFreshness() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); AssertZeroResultPayload(json, "references"); Assert.True(json.GetProperty("graph_table_available").GetBoolean()); @@ -5605,7 +5662,7 @@ public void RunReferences_JsonZeroResults_WithMissingGraphTable_ReturnsDegradedP using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.False(json.GetProperty("graph_table_available").GetBoolean()); @@ -5756,7 +5813,7 @@ public string Render() Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("references").GetArrayLength()); @@ -5974,7 +6031,7 @@ public void RunCallers_JsonZeroResults_WithMissingGraphTable_ReturnsDegradedPayl using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.False(json.GetProperty("graph_table_available").GetBoolean()); @@ -6422,7 +6479,7 @@ public void RunCallees_JsonZeroResults_WithMissingGraphTable_ReturnsDegradedPayl using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.False(json.GetProperty("graph_table_available").GetBoolean()); @@ -7714,7 +7771,7 @@ public void RunSymbols_CssExactNameSeparatesLiteralSelectors() Assert.Equal("%button-base", placeholderRows[0].RootElement.GetProperty("name").GetString()); Assert.Equal("class", placeholderRows[0].RootElement.GetProperty("kind").GetString()); - Assert.Equal(CommandExitCodes.NotFound, fontFaceExitCode); + Assert.Equal(CommandExitCodes.Success, fontFaceExitCode); Assert.Equal(string.Empty, fontFaceStderr); Assert.Equal(string.Empty, fontFaceStdout); } @@ -8267,10 +8324,10 @@ public enum Mode Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, valueExitCode); + Assert.Equal(CommandExitCodes.Success, valueExitCode); Assert.Equal(string.Empty, valueStdout); Assert.Equal(string.Empty, valueStderr); - Assert.Equal(CommandExitCodes.NotFound, otherExitCode); + Assert.Equal(CommandExitCodes.Success, otherExitCode); Assert.Equal(string.Empty, otherStdout); Assert.Equal(string.Empty, otherStderr); } @@ -8988,7 +9045,7 @@ public Money(decimal amount) { } ["--db", dbPath, "--lang", "csharp", "--kind", "function", "--name", "explicit operator Money", "--exact-name"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Contains("No symbols found.", stderr); Assert.Contains("WARN: --exact symbol query may return false negatives", stderr); Assert.Contains("csharp_symbol_name_ready=false", stderr); @@ -11207,7 +11264,7 @@ public void ZeroResultJson_SymbolAndTextCommands_EmitEnvelopeAndFreshness(string using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); AssertZeroResultPayload(json, resultsKey); } @@ -11232,7 +11289,7 @@ public void ZeroResultJson_GraphCommands_EmitEnvelopeAndFreshness(string command using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); AssertZeroResultPayload(json, command); Assert.True(json.GetProperty("graph_table_available").GetBoolean()); @@ -11257,7 +11314,7 @@ public void ZeroResultJson_AggregateCommands_EmitEnvelopeAndFreshness(string com using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); AssertZeroResultPayload(json, resultsKey); Assert.True(json.GetProperty("graph_table_available").GetBoolean()); @@ -11282,7 +11339,7 @@ public void RunHotspots_ZeroJson_ReportsDegradedHotspotFamilyTrust() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.False(json.GetProperty("hotspot_family_ready").GetBoolean()); @@ -11328,7 +11385,7 @@ WHERE file_id IN ( using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.False(json.GetProperty("hotspot_family_ready").GetBoolean()); Assert.True(json.GetProperty("degraded").GetBoolean()); @@ -12087,7 +12144,7 @@ public void RunDeps_ZeroJson_StaleSqlGraphContractIncludesDegradedStateWhenSqlSc using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.False(json.GetProperty("sql_graph_contract_ready").GetBoolean()); @@ -12115,7 +12172,7 @@ public void RunHotspots_ZeroJson_StaleSqlGraphContractIncludesDegradedStateWhenS using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.False(json.GetProperty("sql_graph_contract_ready").GetBoolean()); @@ -12202,7 +12259,7 @@ public void RunHotspots_ZeroJson_StaleSqlGraphContractStaysCleanWhenSqlSymbolsCa using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.False(json.TryGetProperty("sql_graph_contract_ready", out _)); @@ -12513,7 +12570,7 @@ public void RunHotspots_ZeroJson_ReportsMissingMarkerFingerprintAsDegraded() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.False(json.GetProperty("hotspot_family_ready").GetBoolean()); @@ -12546,7 +12603,7 @@ public void RunHotspots_ZeroJson_ReportsStaleHotspotFamilyMetadata() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.False(json.GetProperty("hotspot_family_ready").GetBoolean()); @@ -12570,7 +12627,7 @@ public void RunHotspots_HumanOutput_WarnsWhenHotspotFamilyTrustIsDegraded() ["--db", dbPath, "--lang", "csharp", "--kind", "function"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Contains("cross-file hotspot family grouping", stderr); Assert.Contains("authoritative cross-file hotspot families", stderr); } @@ -12594,7 +12651,7 @@ public void RunImpact_ZeroJson_EmitsEnvelopeAndFreshness() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); AssertZeroResultPayload(json, "callers"); Assert.Equal("DefinitelyMissingSymbol", json.GetProperty("query").GetString()); @@ -12655,7 +12712,7 @@ public void RunFiles_ZeroJson_OnEmptyIndex_EmitsNullIndexedAt() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("files").GetArrayLength()); @@ -12685,7 +12742,7 @@ public void RunFiles_ZeroJson_OnLegacyReadOnlyDb_EmitsFreshnessDegradedSignal() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("files").GetArrayLength()); @@ -12720,7 +12777,7 @@ public void RunSearch_ZeroResultJson_EmitsStructuredPayloadWithFreshnessHint() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal("MissingTarget", json.GetProperty("query").GetString()); @@ -12749,7 +12806,7 @@ public void RunSearch_ZeroResultJson_EmptyIndexEmitsNullIndexedAt() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal("MissingTarget", json.GetProperty("query").GetString()); @@ -12896,7 +12953,7 @@ public void RunReferences_UnsupportedLanguageWithoutMatches_PrintsGraphSupportHi ["MissingSymbol", "--db", dbPath, "--lang", "markdown"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Contains("No references found.", stderr); Assert.Contains("call-graph queries are not indexed for 'markdown'", stderr); } @@ -12923,7 +12980,7 @@ public void GraphCommands_SymbolKindArgumentWarnsAboutReferenceKindSemantics(str [query, "--db", dbPath, "--kind", "class"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Contains("symbol kind", stderr); Assert.Contains("filters by reference kind", stderr); Assert.Contains("call", stderr); @@ -14048,7 +14105,7 @@ public void Ready() { } using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("references").GetArrayLength()); @@ -14230,7 +14287,7 @@ public void Ready() { } using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("callers").GetArrayLength()); @@ -14274,7 +14331,7 @@ public class UsesEnum using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("callees").GetArrayLength()); @@ -14312,7 +14369,7 @@ public void Ready() { } using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("callees").GetArrayLength()); @@ -14846,7 +14903,7 @@ public int Read() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("references").GetArrayLength()); @@ -16090,7 +16147,7 @@ public IEnumerable Read(IEnumerable items) Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -16208,7 +16265,7 @@ public IEnumerable Read(IEnumerable items) Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -16326,7 +16383,7 @@ public IEnumerable Read(IEnumerable items) Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -16450,7 +16507,7 @@ orderby items.Count(), nested.Count() Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -16743,7 +16800,7 @@ orderby select(items), items.Count() Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -16799,7 +16856,7 @@ orderby items.Count() > select(items) ? 1 : 0, items.Count() Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -16855,7 +16912,7 @@ orderby items.Count() < select(items) ? 1 : 0, items.Count() Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -16911,7 +16968,7 @@ public IEnumerable Read(IEnumerable items) Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -16968,7 +17025,7 @@ orderby await select(items), items.Count() Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -17025,7 +17082,7 @@ public async Task> Read(IEnumerable items) Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -17144,7 +17201,7 @@ public IEnumerable Read(IEnumerable items) Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -17200,7 +17257,7 @@ public IEnumerable Read(IEnumerable items) Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -17258,7 +17315,7 @@ orderby items.Count() > Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -17525,15 +17582,15 @@ public void RunReferences_ExactJson_SqlModifierPrefixedObjectsResolveRealNames() Assert.Equal("fn_users", fnRow.RootElement.GetProperty("symbol_name").GetString()); Assert.Equal("call", fnRow.RootElement.GetProperty("reference_kind").GetString()); - Assert.Equal(CommandExitCodes.NotFound, topExitCode); + Assert.Equal(CommandExitCodes.Success, topExitCode); Assert.Equal(string.Empty, topStderr); Assert.Equal(0, topDocument.RootElement.GetProperty("count").GetInt32()); - Assert.Equal(CommandExitCodes.NotFound, onlyExitCode); + Assert.Equal(CommandExitCodes.Success, onlyExitCode); Assert.Equal(string.Empty, onlyStderr); Assert.Equal(0, onlyDocument.RootElement.GetProperty("count").GetInt32()); - Assert.Equal(CommandExitCodes.NotFound, lateralExitCode); + Assert.Equal(CommandExitCodes.Success, lateralExitCode); Assert.Equal(string.Empty, lateralStderr); Assert.Equal(0, lateralDocument.RootElement.GetProperty("count").GetInt32()); } @@ -17598,7 +17655,7 @@ public void RunReferences_ExactJson_SqlTruncateTargetsHandleOnlyAndMultipleTarge Assert.Equal(string.Empty, accountsStderr); Assert.Single(accountsRows); - Assert.Equal(CommandExitCodes.NotFound, onlyExitCode); + Assert.Equal(CommandExitCodes.Success, onlyExitCode); Assert.Equal(string.Empty, onlyStderr); Assert.Equal(0, onlyDocument.RootElement.GetProperty("count").GetInt32()); @@ -17607,15 +17664,15 @@ public void RunReferences_ExactJson_SqlTruncateTargetsHandleOnlyAndMultipleTarge Assert.Equal(1, qualifiedDocument.RootElement.GetProperty("line").GetInt32()); Assert.Equal("users", qualifiedDocument.RootElement.GetProperty("symbol_name").GetString()); - Assert.Equal(CommandExitCodes.NotFound, mangledBracketExitCode); + Assert.Equal(CommandExitCodes.Success, mangledBracketExitCode); Assert.Equal(string.Empty, mangledBracketStderr); Assert.Equal(0, mangledBracketDocument.RootElement.GetProperty("count").GetInt32()); - Assert.Equal(CommandExitCodes.NotFound, mangledBacktickExitCode); + Assert.Equal(CommandExitCodes.Success, mangledBacktickExitCode); Assert.Equal(string.Empty, mangledBacktickStderr); Assert.Equal(0, mangledBacktickDocument.RootElement.GetProperty("count").GetInt32()); - Assert.Equal(CommandExitCodes.NotFound, mangledDoubleQuoteExitCode); + Assert.Equal(CommandExitCodes.Success, mangledDoubleQuoteExitCode); Assert.Equal(string.Empty, mangledDoubleQuoteStderr); Assert.Equal(0, mangledDoubleQuoteDocument.RootElement.GetProperty("count").GetInt32()); } @@ -17689,11 +17746,11 @@ public void RunReferences_ExactJson_SqlDeleteUsingCapturesSourceReferences() Assert.Equal(3, qualifiedSourceDocument.RootElement.GetProperty("line").GetInt32()); Assert.Equal("stage_log", qualifiedSourceDocument.RootElement.GetProperty("symbol_name").GetString()); - Assert.Equal(CommandExitCodes.NotFound, mangledBracketExitCode); + Assert.Equal(CommandExitCodes.Success, mangledBracketExitCode); Assert.Equal(string.Empty, mangledBracketStderr); Assert.Equal(0, mangledBracketDocument.RootElement.GetProperty("count").GetInt32()); - Assert.Equal(CommandExitCodes.NotFound, mangledDoubleQuoteExitCode); + Assert.Equal(CommandExitCodes.Success, mangledDoubleQuoteExitCode); Assert.Equal(string.Empty, mangledDoubleQuoteStderr); Assert.Equal(0, mangledDoubleQuoteDocument.RootElement.GetProperty("count").GetInt32()); } @@ -17761,7 +17818,7 @@ WHEN MATCHED THEN Assert.Equal("staging_archive", archiveSourceRow.RootElement.GetProperty("symbol_name").GetString()); Assert.Equal("reference", archiveSourceRow.RootElement.GetProperty("reference_kind").GetString()); - Assert.Equal(CommandExitCodes.NotFound, btreeExitCode); + Assert.Equal(CommandExitCodes.Success, btreeExitCode); Assert.Equal(string.Empty, btreeStderr); Assert.Equal(0, btreeDocument.RootElement.GetProperty("count").GetInt32()); @@ -18203,7 +18260,7 @@ public void RunReferences_ExactJson_SqlBareDollarIdentifiersStayWhole() Assert.Equal(5, dollarRows.Count); Assert.All(dollarRows, row => Assert.Equal("my$table", row.RootElement.GetProperty("symbol_name").GetString())); - Assert.Equal(CommandExitCodes.NotFound, prefixExitCode); + Assert.Equal(CommandExitCodes.Success, prefixExitCode); Assert.Equal(string.Empty, prefixStderr); Assert.Equal(0, prefixDocument.RootElement.GetProperty("count").GetInt32()); } @@ -18282,7 +18339,7 @@ SELECT id INTO #declare_temp FROM users Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, futureExitCode); + Assert.Equal(CommandExitCodes.Success, futureExitCode); Assert.Equal(string.Empty, futureStderr); Assert.Equal(0, futureDocument.RootElement.GetProperty("count").GetInt32()); @@ -18402,7 +18459,7 @@ public void RunReferences_ExactJson_SqlDoubleQuotedDynamicSqlDoesNotEstablishTem Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -18512,7 +18569,7 @@ public void RunReferences_ExactJson_SqlEscapedSingleQuotedStringsDoNotLeakPhanto Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, phantomExitCode); + Assert.Equal(CommandExitCodes.Success, phantomExitCode); Assert.Equal(string.Empty, phantomStderr); Assert.Equal(0, phantomDocument.RootElement.GetProperty("count").GetInt32()); @@ -18563,7 +18620,7 @@ FROM phantom Assert.Equal("users", usersRow.RootElement.GetProperty("symbol_name").GetString()); Assert.Equal(6, usersRow.RootElement.GetProperty("line").GetInt32()); - Assert.Equal(CommandExitCodes.NotFound, tempExitCode); + Assert.Equal(CommandExitCodes.Success, tempExitCode); Assert.Equal(string.Empty, tempStderr); Assert.Equal(0, tempDocument.RootElement.GetProperty("count").GetInt32()); } @@ -18610,7 +18667,7 @@ public void RunReferences_ExactJson_SqlNonCodeRegionsDoNotLeakPhantomReference() Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, phantomExitCode); + Assert.Equal(CommandExitCodes.Success, phantomExitCode); Assert.Equal(string.Empty, phantomStderr); Assert.Equal(0, phantomDocument.RootElement.GetProperty("count").GetInt32()); @@ -18674,7 +18731,7 @@ public IEnumerable Read(IEnumerable items) Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -18958,7 +19015,7 @@ public IEnumerable Read(IEnumerable items) Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Empty(json.GetProperty("references").EnumerateArray()); @@ -20832,7 +20889,7 @@ public IEnumerable Read(IEnumerable items) using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("references").GetArrayLength()); @@ -21074,7 +21131,7 @@ public int Read(IEnumerable items) using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("references").GetArrayLength()); @@ -21185,7 +21242,7 @@ public int Read(IEnumerable items) using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("references").GetArrayLength()); @@ -21298,7 +21355,7 @@ public int Read(IEnumerable items) using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("references").GetArrayLength()); @@ -21477,7 +21534,7 @@ public IEnumerable Read(IEnumerable items) using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("references").GetArrayLength()); @@ -22196,7 +22253,7 @@ void Run(Color value) using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); } @@ -22755,7 +22812,7 @@ void Run(object value) Assert.Equal(2, nonExactRows.Count); Assert.Equal([13, 15], nonExactRows.Select(row => row.GetProperty("line").GetInt32()).OrderBy(line => line).ToArray()); - Assert.Equal(CommandExitCodes.NotFound, exactExitCode); + Assert.Equal(CommandExitCodes.Success, exactExitCode); Assert.Equal(string.Empty, exactStderr); Assert.Equal(0, exactDocument.RootElement.GetProperty("count").GetInt32()); @@ -22834,7 +22891,7 @@ void Run(object value) Assert.Equal(2, nonExactRows.Count); Assert.Equal([13, 15], nonExactRows.Select(row => row.GetProperty("line").GetInt32()).OrderBy(line => line).ToArray()); - Assert.Equal(CommandExitCodes.NotFound, exactExitCode); + Assert.Equal(CommandExitCodes.Success, exactExitCode); Assert.Equal(string.Empty, exactStderr); Assert.Equal(0, exactDocument.RootElement.GetProperty("count").GetInt32()); @@ -22915,7 +22972,7 @@ public enum Color ["references", "Red", "--db", dbPath, "--json", "--lang", "csharp", "--exact-name", "--count"]); using var countDocument = ParseJsonOutput(countStdout); - Assert.Equal(CommandExitCodes.NotFound, exactExitCode); + Assert.Equal(CommandExitCodes.Success, exactExitCode); Assert.Equal(string.Empty, exactStderr); Assert.Equal(0, exactDocument.RootElement.GetProperty("count").GetInt32()); @@ -22973,7 +23030,7 @@ void Run(object value) using var document = ParseJsonOutput(stdout); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, document.RootElement.GetProperty("count").GetInt32()); } @@ -23034,7 +23091,7 @@ void Run(object value) Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, referencesExitCode); + Assert.Equal(CommandExitCodes.Success, referencesExitCode); Assert.Equal(string.Empty, referencesStderr); Assert.Equal(0, referencesDocument.RootElement.GetProperty("count").GetInt32()); @@ -23042,7 +23099,7 @@ void Run(object value) Assert.Equal(string.Empty, countStderr); Assert.Equal(0, countDocument.RootElement.GetProperty("count").GetInt32()); - Assert.Equal(CommandExitCodes.NotFound, callersExitCode); + Assert.Equal(CommandExitCodes.Success, callersExitCode); Assert.Equal(string.Empty, callersStderr); Assert.Equal(0, callersDocument.RootElement.GetProperty("count").GetInt32()); } @@ -23489,11 +23546,11 @@ void Run(object value) _jsonOptions)); using var redCountDocument = ParseJsonOutput(redCountStdout); - Assert.Equal(CommandExitCodes.NotFound, redExitCode); + Assert.Equal(CommandExitCodes.Success, redExitCode); Assert.Equal(string.Empty, redStderr); Assert.Equal(0, redDocument.RootElement.GetProperty("count").GetInt32()); - Assert.Equal(CommandExitCodes.NotFound, blueExitCode); + Assert.Equal(CommandExitCodes.Success, blueExitCode); Assert.Equal(string.Empty, blueStderr); Assert.Equal(0, blueDocument.RootElement.GetProperty("count").GetInt32()); @@ -23549,7 +23606,7 @@ class Demo _jsonOptions)); using var redCountDocument = ParseJsonOutput(redCountStdout); - Assert.Equal(CommandExitCodes.NotFound, redExitCode); + Assert.Equal(CommandExitCodes.Success, redExitCode); Assert.Equal(string.Empty, redStderr); Assert.Equal(0, redDocument.RootElement.GetProperty("count").GetInt32()); @@ -23850,7 +23907,7 @@ class Demo _jsonOptions)); using var document = ParseJsonOutput(stdout); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, document.RootElement.GetProperty("count").GetInt32()); } @@ -23947,7 +24004,7 @@ class Demo _jsonOptions)); using var document = ParseJsonOutput(stdout); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, document.RootElement.GetProperty("count").GetInt32()); } @@ -24049,7 +24106,7 @@ void Run(object value) _jsonOptions)); using var document = ParseJsonOutput(stdout); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, document.RootElement.GetProperty("count").GetInt32()); } @@ -24248,7 +24305,7 @@ bool Match(object value) Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, document.RootElement.GetProperty("count").GetInt32()); } @@ -24498,7 +24555,7 @@ class Demo using var document = ParseJsonOutput(stdout); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, document.RootElement.GetProperty("count").GetInt32()); } @@ -24602,7 +24659,7 @@ class Derived : Base using var document = ParseJsonOutput(stdout); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, document.RootElement.GetProperty("count").GetInt32()); } @@ -24657,7 +24714,7 @@ void ProbeType() using var document = ParseJsonOutput(stdout); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, document.RootElement.GetProperty("count").GetInt32()); } @@ -25161,7 +25218,7 @@ bool Match(object value) => value is using var document = ParseJsonOutput(stdout); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, document.RootElement.GetProperty("count").GetInt32()); } @@ -25274,7 +25331,7 @@ void Run(object value) using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); } @@ -25380,7 +25437,7 @@ void M() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); } @@ -25903,7 +25960,7 @@ public void Boot(FooService service) using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal("none", json.GetProperty("impact_mode").GetString()); Assert.True(json.GetProperty("has_multiple_definitions").GetBoolean()); @@ -25947,7 +26004,7 @@ public void Stop() { } using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal("none", json.GetProperty("impact_mode").GetString()); Assert.Equal(0, json.GetProperty("count").GetInt32()); @@ -26003,7 +26060,7 @@ public void Boot(BarService service) using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal("none", json.GetProperty("impact_mode").GetString()); Assert.False(json.GetProperty("heuristic").GetBoolean()); @@ -26058,7 +26115,7 @@ public void Boot(OtherService service) using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal("none", json.GetProperty("impact_mode").GetString()); Assert.Equal(0, json.GetProperty("count").GetInt32()); @@ -26112,7 +26169,7 @@ public void Boot(Worker worker) using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal("none", json.GetProperty("impact_mode").GetString()); Assert.Equal(0, json.GetProperty("hint_count").GetInt32()); @@ -26161,7 +26218,7 @@ public void Boot(FooService service) using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal("none", json.GetProperty("impact_mode").GetString()); Assert.Equal(0, json.GetProperty("count").GetInt32()); @@ -26194,7 +26251,7 @@ import requests using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal("none", json.GetProperty("impact_mode").GetString()); Assert.Equal(1, json.GetProperty("definition_count").GetInt32()); @@ -26472,7 +26529,7 @@ public void Handle(FooService service) using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal("none", json.GetProperty("impact_mode").GetString()); Assert.Equal(0, json.GetProperty("hint_count").GetInt32()); @@ -26518,7 +26575,7 @@ public void Run() { } using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal("none", json.GetProperty("impact_mode").GetString()); Assert.Equal(2, json.GetProperty("definition_count").GetInt32()); @@ -26564,7 +26621,7 @@ public void Run() { } ["FooService", "--db", dbPath], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.DoesNotContain("file_dependency_hints", stdout); Assert.Contains("2 definitions across 1 file", stderr); } @@ -26712,7 +26769,7 @@ public void Boot() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal("none", json.GetProperty("impact_mode").GetString()); Assert.Equal(0, json.GetProperty("hint_count").GetInt32()); @@ -26747,7 +26804,7 @@ public class @class using var jsonDocument = ParseJsonOutput(jsonStdout); var json = jsonDocument.RootElement; - Assert.Equal(CommandExitCodes.NotFound, jsonExitCode); + Assert.Equal(CommandExitCodes.Success, jsonExitCode); Assert.Equal(string.Empty, jsonStderr); Assert.Equal("@missing", json.GetProperty("query").GetString()); Assert.Equal("@missing", json.GetProperty("resolved_name").GetString()); @@ -26757,7 +26814,7 @@ public class @class ["@missing", "--db", dbPath, "--lang", "csharp"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, humanExitCode); + Assert.Equal(CommandExitCodes.Success, humanExitCode); Assert.Equal(string.Empty, humanStdout); Assert.Contains("No impact found for '@missing'.", humanStderr); } @@ -26930,7 +26987,7 @@ public void RunHotspots_SqlJson_DefaultsGroupedByStatement() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal("statement", json.GetProperty("grouped_by").GetString()); } @@ -27089,7 +27146,7 @@ private void SharedHelper() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("definition_site_total").GetInt32()); @@ -27334,7 +27391,7 @@ public void HandleRequest() { } ["Handle", "--db", dbPath, "--json", "--exact"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stdout); Assert.Equal(string.Empty, stderr); } @@ -28154,7 +28211,7 @@ public void HandleRequest() { } ["Handle", "--db", dbPath, "--exact"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Contains("No references found.", stderr); Assert.Contains("--exact found 0 matches, but substring matching would return 1", stderr); Assert.Contains("`HandleRequest`", stderr); @@ -28178,7 +28235,7 @@ public void RunReferences_ExactWithoutGraphTable_DoesNotClaimSlowButCorrect() ["Run", "--db", dbPath, "--exact"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.DoesNotContain("Results are correct but may be slow", stderr); Assert.Contains("symbol_references table missing", stderr); } @@ -28534,7 +28591,7 @@ public void RunFind_ZeroResultHintDistinguishesPathMatchesFromQueryMiss_Issue140 _jsonOptions)); var normalizedStderr = stderr.ToLowerInvariant(); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Contains("No matches found.", stderr); Assert.Contains("--path matched 1 file, but the query did not match their contents", stderr); Assert.Contains("try a broader query or check the query syntax", normalizedStderr); @@ -28565,7 +28622,7 @@ public void RunFind_ZeroResultHintStillSuggestsBroadeningUnmatchedPath_Issue1406 _jsonOptions)); var normalizedStderr = stderr.ToLowerInvariant(); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Contains("broadening --path or adding another --path value", normalizedStderr); Assert.DoesNotContain("query did not match", normalizedStderr); } @@ -29422,7 +29479,7 @@ public void Go() { } Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stdout); Assert.Equal(string.Empty, stderr); } @@ -29475,7 +29532,7 @@ public void Go() { } Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("references").GetArrayLength()); @@ -29518,7 +29575,7 @@ public class Phantom Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stdout); Assert.Equal(string.Empty, stderr); } @@ -29585,7 +29642,7 @@ public void RunMap_NonexistentPathReturnsNotFound() ["--db", dbPath, "--path", "nonexistent/"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Contains("No files found", stderr); } finally @@ -29610,7 +29667,7 @@ public void RunFiles_ZeroResultJson_EmitsStructuredPayloadWithFreshnessHint() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("files").GetArrayLength()); @@ -29638,7 +29695,7 @@ public void RunFiles_ZeroResultJson_EmptyIndexEmitsNullIndexedAt() using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, json.GetProperty("count").GetInt32()); Assert.Equal(0, json.GetProperty("files").GetArrayLength()); @@ -29719,7 +29776,7 @@ public void RunMap_NonexistentPathJsonReturnsNotFoundWithPayload() ["--db", dbPath, "--path", "nonexistent/", "--json"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); using var document = ParseJsonOutput(stdout); Assert.Equal(0, document.RootElement.GetProperty("file_count").GetInt32()); } @@ -30211,7 +30268,7 @@ public void RunSearch_ZeroResultsHonorsStaleAfterEnvironment() ["MissingSymbol", "--db", dbPath], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stdout); Assert.Contains("threshold: 1m", stderr); } @@ -31248,7 +31305,7 @@ public void RunSymbols_EmitsLangHintForUnknownLang() ["--db", dbPath, "--lang", "nonexistent"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Contains("'nonexistent' not found in index. Available: python", stderr); } finally @@ -31270,7 +31327,7 @@ public void RunDefinition_EmitsLangHintForUnknownLang() ["hello", "--db", dbPath, "--lang", "nonexistent"], _jsonOptions)); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Contains("'nonexistent' not found in index. Available: python", stderr); } finally @@ -33004,7 +33061,7 @@ public void Stop() { } using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); AssertZeroResultPayload(json, "callers"); Assert.Equal("none", json.GetProperty("impact_mode").GetString()); @@ -33037,7 +33094,7 @@ import requests using var document = ParseJsonOutput(stdout); var json = document.RootElement; - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); AssertZeroResultPayload(json, "callers"); Assert.Equal("none", json.GetProperty("impact_mode").GetString()); @@ -33099,10 +33156,10 @@ function realCall() {} Assert.Equal(CommandExitCodes.Success, indexExitCode); Assert.Equal(string.Empty, indexStderr); - // Phantom symbols must not exist — both queries should return NotFound. - // phantom シンボルは存在してはならない — どちらのクエリも NotFound になること。 - Assert.Equal(CommandExitCodes.NotFound, phantomFnExit); - Assert.Equal(CommandExitCodes.NotFound, phantomClsExit); + // Phantom symbols must not exist; zero-result queries now exit successfully by default. + // phantom シンボルは存在してはならない。0 件クエリは既定で成功終了する。 + Assert.Equal(CommandExitCodes.Success, phantomFnExit); + Assert.Equal(CommandExitCodes.Success, phantomClsExit); // The real call inside the `${...}` interpolation hole must still be visible. // ${...} 補間ホール内の本物の呼び出しは参照として残っていること。 @@ -33168,7 +33225,7 @@ class Demo using var document = ParseJsonOutput(stdout); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, document.RootElement.GetProperty("count").GetInt32()); } @@ -33218,7 +33275,7 @@ bool Match(object value) => value is using var document = ParseJsonOutput(stdout); - Assert.Equal(CommandExitCodes.NotFound, exitCode); + Assert.Equal(CommandExitCodes.Success, exitCode); Assert.Equal(string.Empty, stderr); Assert.Equal(0, document.RootElement.GetProperty("count").GetInt32()); }