Skip to content

Commit e2567c7

Browse files
test(core): measure the failed-lookup claim on the observe entry point
1 parent b93ed68 commit e2567c7

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

‎src/core/tools/__tests__/readFileTool.spec.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,8 @@ describe("ReadFileTool", () => {
18501850
observationRegistry: new ObservationRegistry(),
18511851
})
18521852
const callbacks = createMockCallbacks()
1853+
const reg = mockTask.observationRegistry!
1854+
const observeSpy = vi.spyOn(reg, "observe")
18531855

18541856
// Only computeVersionToken asks for bigint stats, so arm the failure on that
18551857
// call rather than on call parity, which ties the test to how many stats a read
@@ -1874,9 +1876,10 @@ describe("ReadFileTool", () => {
18741876
expect(callbacks.pushToolResult).toHaveBeenCalledWith(expect.stringContaining("existing.ts"))
18751877
expect(callbacks.pushToolResult).toHaveBeenCalledWith(expect.stringContaining("content"))
18761878

1877-
// The failed token lookup observed nothing, and the name's claim is about the
1878-
// registry, not only about this path: it is still empty.
1879-
const reg = mockTask.observationRegistry!
1879+
// The failed token lookup recorded nothing. The registry-wide claim in the name
1880+
// is measured on the observe entry point against this row's fresh registry, and
1881+
// the path-level get stays as the concrete symptom.
1882+
expect(observeSpy).toHaveBeenCalledTimes(0)
18801883
expect(reg.get(path.resolve("/test/workspace", "existing.ts"))).toBeUndefined()
18811884
})
18821885

@@ -1935,6 +1938,8 @@ describe("ReadFileTool", () => {
19351938
observationRegistry: new ObservationRegistry(),
19361939
})
19371940
const callbacks = createMockCallbacks()
1941+
const reg = mockTask.observationRegistry!
1942+
const observeSpy = vi.spyOn(reg, "observe")
19381943

19391944
// Same shape as the native case, on the legacy multi-file path: only the bigint
19401945
// stat that computeVersionToken asks for is made to reject.
@@ -1973,8 +1978,9 @@ describe("ReadFileTool", () => {
19731978
expect(callbacks.pushToolResult).toHaveBeenCalledWith(expect.stringContaining("legacy.ts"))
19741979
expect(callbacks.pushToolResult).toHaveBeenCalledWith(expect.stringContaining("legacy content"))
19751980

1976-
// Same claim as the native case, measured on the registry itself.
1977-
const reg = mockTask.observationRegistry!
1981+
// Same claim as the native case: nothing recorded against this row's fresh
1982+
// registry, plus the path-level get as the concrete symptom.
1983+
expect(observeSpy).toHaveBeenCalledTimes(0)
19781984
expect(reg.get(path.resolve("/test/workspace", "legacy.ts"))).toBeUndefined()
19791985
})
19801986

0 commit comments

Comments
 (0)