Repository navigation
Commit c4bec4a
committed
test(mcp): over-long grep records never invent matches (DeusData#2011)
A grep record longer than the read buffer used to be split across two
reads, and the continuation was parsed as a fresh file:line:content
record — a fragment of matched content became a file path and the text
after the next delimiter became a line number. An agent reading that
result called get_code_snippet on a path that was never in the
repository. The same split could also lose a real match, when the tail
held fewer than two delimiters and the record was dropped instead.
The production fix landed via DeusData#1597 (3c7427e): search_code now reads each
record with cbm_getline into a growable buffer, so a record can no longer
split. That closed DeusData#2011 as a side effect, and nothing on main guards the
shape — the buffer could be reintroduced by a future rewrite of the read
loop with no test to catch it.
Add the regression test the fix never got. It writes a >2 KiB colon-laden
line plus a normal one, calls search_code through cbm_mcp_server_handle,
and asserts the repository's two real matches are reported as two — not
three — and that no row carries the line 0 the fabricated record used to
produce.
Signed-off-by: kavish-19 <63698788+kavish-19@users.noreply.github.com>1 parent fe85a6b commit c4bec4a
1 file changed
Lines changed: 68 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10118 | 10118 | | |
10119 | 10119 | | |
10120 | 10120 | | |
| 10121 | + | |
| 10122 | + | |
| 10123 | + | |
| 10124 | + | |
| 10125 | + | |
| 10126 | + | |
| 10127 | + | |
| 10128 | + | |
| 10129 | + | |
| 10130 | + | |
| 10131 | + | |
| 10132 | + | |
| 10133 | + | |
| 10134 | + | |
| 10135 | + | |
| 10136 | + | |
| 10137 | + | |
| 10138 | + | |
| 10139 | + | |
| 10140 | + | |
| 10141 | + | |
| 10142 | + | |
| 10143 | + | |
| 10144 | + | |
| 10145 | + | |
| 10146 | + | |
| 10147 | + | |
| 10148 | + | |
| 10149 | + | |
| 10150 | + | |
| 10151 | + | |
| 10152 | + | |
| 10153 | + | |
| 10154 | + | |
| 10155 | + | |
| 10156 | + | |
| 10157 | + | |
| 10158 | + | |
| 10159 | + | |
| 10160 | + | |
| 10161 | + | |
| 10162 | + | |
| 10163 | + | |
| 10164 | + | |
| 10165 | + | |
| 10166 | + | |
| 10167 | + | |
| 10168 | + | |
| 10169 | + | |
| 10170 | + | |
| 10171 | + | |
| 10172 | + | |
| 10173 | + | |
| 10174 | + | |
| 10175 | + | |
| 10176 | + | |
| 10177 | + | |
| 10178 | + | |
| 10179 | + | |
| 10180 | + | |
| 10181 | + | |
| 10182 | + | |
| 10183 | + | |
| 10184 | + | |
| 10185 | + | |
| 10186 | + | |
| 10187 | + | |
10121 | 10188 | | |
10122 | 10189 | | |
10123 | 10190 | | |
| |||
19923 | 19990 | | |
19924 | 19991 | | |
19925 | 19992 | | |
| 19993 | + | |
19926 | 19994 | | |
19927 | 19995 | | |
19928 | 19996 | | |
| |||
0 commit comments