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
2 changes: 1 addition & 1 deletion docs/implementation/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ These three indexing-gated tools share an addressing and lifecycle contract (doc

### Indexing lifecycle (shared across `search_symbols`, `list_files`, `read_file`, `grep_file`)

All four code-navigation tools share the same indexing-retry contract. The state can arrive through either an error response or a success sentinel, and the service layer collapses both to the same typed `CodeNavigationIndexingError` before the envelope builder runs. Agents therefore never see an `indexingStatus` field in a success envelope; they branch on the error path instead.
All four code-navigation tools share the same indexing-retry contract. The state can arrive through either an error response or a success sentinel (`codeIndexState: "INDEXING"`), and the service layer collapses both to the same typed `CodeNavigationIndexingError` before the envelope builder runs. Agents therefore never see a `codeIndexState` field in a success envelope; they branch on the error path instead.

**`INDEXING` error envelope**:
```json
Expand Down
32 changes: 16 additions & 16 deletions src/services/code-navigation-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe("CodeNavigationServiceImpl", () => {
indexedVersion: "4.18.0",
diagnostics: { hint: null },
warning: null,
indexingStatus: "INDEXED",
codeIndexState: "CURRENT",
},
},
}),
Expand Down Expand Up @@ -106,7 +106,7 @@ describe("CodeNavigationServiceImpl", () => {
indexedVersion: null,
diagnostics: { hint: null },
warning: null,
indexingStatus: "INDEXED",
codeIndexState: "CURRENT",
},
},
}),
Expand Down Expand Up @@ -152,7 +152,7 @@ describe("CodeNavigationServiceImpl", () => {
indexedVersion: null,
diagnostics: { hint: null },
warning: null,
indexingStatus: "INDEXING",
codeIndexState: "INDEXING",
indexingRef: "idx-123",
availableVersions: [{ version: "4.18.0", ref: "v4.18.0" }],
},
Expand Down Expand Up @@ -225,7 +225,7 @@ describe("CodeNavigationServiceImpl", () => {
indexedVersion: null,
diagnostics: { hint: null },
warning: null,
indexingStatus: "INDEXED",
codeIndexState: "CURRENT",
},
},
}),
Expand Down Expand Up @@ -604,7 +604,7 @@ describe("CodeNavigationServiceImpl", () => {
indexedVersion: null,
diagnostics: { hint: null },
warning: null,
indexingStatus: "INDEXING",
codeIndexState: "INDEXING",
indexingRef: "idx-123",
},
},
Expand Down Expand Up @@ -698,7 +698,7 @@ describe("CodeNavigationServiceImpl", () => {
indexedVersion: null,
diagnostics: { hint: null },
warning: null,
indexingStatus: "INDEXED",
codeIndexState: "CURRENT",
},
},
}),
Expand Down Expand Up @@ -756,7 +756,7 @@ describe("CodeNavigationServiceImpl", () => {
commitSha: "abc123",
},
diagnostics: null,
indexingStatus: "INDEXED",
codeIndexState: "CURRENT",
},
},
}),
Expand Down Expand Up @@ -802,7 +802,7 @@ describe("CodeNavigationServiceImpl", () => {
indexedVersion: null,
resolution: null,
diagnostics: null,
indexingStatus: "INDEXING",
codeIndexState: "INDEXING",
indexingRef: "ref_xyz",
availableVersions: [{ version: "4.21.0", ref: "v4.21.0" }],
},
Expand Down Expand Up @@ -845,7 +845,7 @@ describe("CodeNavigationServiceImpl", () => {
indexedVersion: "v5.2.1",
resolution: null,
diagnostics: { hint: "No files match that prefix." },
indexingStatus: "INDEXED",
codeIndexState: "CURRENT",
},
},
}),
Expand Down Expand Up @@ -885,7 +885,7 @@ describe("CodeNavigationServiceImpl", () => {
startLine: 1,
endLine: 2,
isBinary: false,
indexingStatus: "INDEXED",
codeIndexState: "CURRENT",
},
},
}),
Expand Down Expand Up @@ -920,7 +920,7 @@ describe("CodeNavigationServiceImpl", () => {
startLine: null,
endLine: null,
isBinary: true,
indexingStatus: "INDEXED",
codeIndexState: "CURRENT",
},
},
}),
Expand Down Expand Up @@ -950,7 +950,7 @@ describe("CodeNavigationServiceImpl", () => {
content: null,
filePath: null,
language: null,
indexingStatus: "INDEXING",
codeIndexState: "INDEXING",
indexingRef: "ref_read",
},
},
Expand Down Expand Up @@ -1044,7 +1044,7 @@ describe("CodeNavigationServiceImpl", () => {
commitSha: "abc",
},
diagnostics: null,
indexingStatus: "INDEXED",
codeIndexState: "CURRENT",
},
},
}),
Expand Down Expand Up @@ -1078,7 +1078,7 @@ describe("CodeNavigationServiceImpl", () => {
matches: [],
totalMatches: 0,
hasMore: false,
indexingStatus: "INDEXING",
codeIndexState: "INDEXING",
indexingRef: "ref_grep",
availableVersions: [{ version: "4.21.0", ref: "v4.21.0" }],
},
Expand Down Expand Up @@ -1117,7 +1117,7 @@ describe("CodeNavigationServiceImpl", () => {
matches: [],
totalMatches: 0,
hasMore: false,
indexingStatus: "INDEXED",
codeIndexState: "CURRENT",
},
},
}),
Expand Down Expand Up @@ -1161,7 +1161,7 @@ describe("CodeNavigationServiceImpl", () => {
files: [],
total: 0,
hasMore: false,
indexingStatus: "INDEXED",
codeIndexState: "CURRENT",
},
},
}),
Expand Down
30 changes: 15 additions & 15 deletions src/services/code-navigation-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ query SearchSymbols(
hint
}
warning
indexingStatus
codeIndexState
indexingRef
availableVersions {
version
Expand Down Expand Up @@ -529,7 +529,7 @@ const searchSymbolsResponseSchema = z.object({
.nullable()
.optional(),
warning: z.string().nullable().optional(),
indexingStatus: z.string(),
codeIndexState: z.string(),
indexingRef: z.string().nullable().optional(),
availableVersions: z.array(availableVersionSchema).nullable().optional(),
});
Expand All @@ -542,7 +542,7 @@ const graphQLErrorSchema = z.object({
// --------------------------------------------------------------------
// Zod schemas + queries for the file-exploration bundle.
// `listRepoFiles` / `fetchCodeContext` / `grepRepoFile` share the same
// indexing lifecycle (`indexingStatus` + `indexingRef` +
// indexing lifecycle (`codeIndexState` + `indexingRef` +
// `availableVersions`) but otherwise have distinct result shapes —
// normalise per tool rather than under one abstraction.
// --------------------------------------------------------------------
Expand Down Expand Up @@ -581,7 +581,7 @@ const listRepoFilesResponseSchema = z.object({
indexedVersion: z.string().nullable().optional(),
resolution: navigationResolutionSchema,
diagnostics: navigationDiagnosticsSchema,
indexingStatus: z.string(),
codeIndexState: z.string(),
indexingRef: z.string().nullable().optional(),
availableVersions: z.array(availableVersionSchema).nullable().optional(),
});
Expand Down Expand Up @@ -636,7 +636,7 @@ query ListRepoFiles(
diagnostics {
hint
}
indexingStatus
codeIndexState
indexingRef
availableVersions {
version
Expand All @@ -659,7 +659,7 @@ const codeContextResponseSchema = z.object({
repoUrl: z.string().nullable().optional(),
gitRef: z.string().nullable().optional(),
isBinary: z.boolean().nullable().optional(),
indexingStatus: z.string(),
codeIndexState: z.string(),
indexingRef: z.string().nullable().optional(),
});

Expand Down Expand Up @@ -705,7 +705,7 @@ query FetchCodeContext(
repoUrl
gitRef
isBinary
indexingStatus
codeIndexState
indexingRef
}
}`;
Expand All @@ -729,7 +729,7 @@ const grepRepoFileResponseSchema = z.object({
indexedVersion: z.string().nullable().optional(),
resolution: navigationResolutionSchema,
diagnostics: navigationDiagnosticsSchema,
indexingStatus: z.string(),
codeIndexState: z.string(),
indexingRef: z.string().nullable().optional(),
availableVersions: z.array(availableVersionSchema).nullable().optional(),
});
Expand Down Expand Up @@ -790,7 +790,7 @@ query GrepRepoFile(
diagnostics {
hint
}
indexingStatus
codeIndexState
indexingRef
availableVersions {
version
Expand Down Expand Up @@ -901,7 +901,7 @@ export class CodeNavigationServiceImpl implements CodeNavigationService {
);
}

if (data.indexingStatus === "INDEXING") {
if (data.codeIndexState === "INDEXING") {
throw new CodeNavigationIndexingError(
this.createIndexingMessage(data.indexingRef ?? undefined),
data.indexingRef ?? undefined,
Expand All @@ -912,7 +912,7 @@ export class CodeNavigationServiceImpl implements CodeNavigationService {
);
}

if (data.indexingStatus === "UNRESOLVABLE") {
if (data.codeIndexState === "UNRESOLVABLE") {
throw new CodeNavigationUnresolvableError(
"The requested target or version could not be resolved.",
);
Expand Down Expand Up @@ -1107,17 +1107,17 @@ export class CodeNavigationServiceImpl implements CodeNavigationService {

/**
* Shared sentinel-promotion for the file-exploration tools. When the backend
* response carries `indexingStatus: "INDEXING"` (data-path variant),
* response carries `codeIndexState: "INDEXING"` (data-path variant),
* throw the typed error so the envelope builder / caller never sees
* the raw sentinel. Mirrors the inline check `searchSymbols` does
* today.
*/
private throwIfIndexing(data: {
indexingStatus: string;
codeIndexState: string;
indexingRef?: string | null;
availableVersions?: Array<{ version?: string | null; ref: string }> | null;
}): void {
if (data.indexingStatus === "INDEXING") {
if (data.codeIndexState === "INDEXING") {
throw new CodeNavigationIndexingError(
this.createIndexingMessage(data.indexingRef ?? undefined),
data.indexingRef ?? undefined,
Expand Down Expand Up @@ -1296,7 +1296,7 @@ export class CodeNavigationServiceImpl implements CodeNavigationService {
// `fetchCodeContext` doesn't return availableVersions; pass a
// minimal object to the shared helper.
this.throwIfIndexing({
indexingStatus: data.indexingStatus,
codeIndexState: data.codeIndexState,
indexingRef: data.indexingRef,
});

Expand Down
2 changes: 1 addition & 1 deletion src/shared/grep-file-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* `resolution` when backend returned one; `hint` when empty
* results carry a backend diagnostic.
* - **No indexing metadata in the success envelope.** Service
* promotes `indexingStatus: INDEXING` to a typed error first.
* promotes `codeIndexState: INDEXING` to a typed error first.
* - **`filter.*` echoes only caller-supplied inputs.**
* - **Regex-char heuristic on empty results (terminal-only).** If
* the pattern looks like unambiguous regex AND zero matches,
Expand Down
2 changes: 1 addition & 1 deletion src/shared/list-files-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* `resolution` appears whenever the backend returned one; `hint`
* appears when empty results carry a backend diagnostic.
* - **No indexing metadata in the success envelope.** The service
* layer promotes `indexingStatus: INDEXING` to a typed error
* layer promotes `codeIndexState: INDEXING` to a typed error
* before the envelope builder runs, so agents never branch on a
* data-path indexing flag.
* - **`filter.*` echoes only caller-supplied inputs.** The default
Expand Down
Loading