Repository navigation
Commit 02bc9f2
committed
fix(mcp): clamp search_code context on both sides, add sink ceilings
The search_code `context` argument had no upper bound while every sibling
sizing argument (result_limit, match_limit, source_max_lines, raw_limit,
directory_limit) is clamped on both sides. A large value made every hit
return its file from the match to the end, and the window arithmetic in
attach_result_source could overflow int. `context` now gets the same
0..200 clamp as source_max_lines (MCP_SEARCH_CONTEXT_MAX_LINES), the
window computation is overflow-safe on its own, and the tool schema states
default, minimum and maximum like its siblings. Values inside the bound
return exactly the lines they did before.
Sink ceilings: cbm_cypher_execute clamps a caller-supplied max_rows to
CYPHER_RESULT_CEILING (nothing above it is ever materialized) and
execute_single checks the binding array it sizes from that value instead
of writing through a failed allocation.
Tests pin the context window and the extreme values (INT_MAX, negative),
the query_graph max_rows ceiling, the search_graph limit ceiling, the
trace cursor token truncated after the leg character, the quote rejection
in file_pattern, and the engine-side max_rows clamp.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>1 parent cb7d937 commit 02bc9f2
5 files changed
Lines changed: 399 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5138 | 5138 | | |
5139 | 5139 | | |
5140 | 5140 | | |
5141 | | - | |
| 5141 | + | |
| 5142 | + | |
| 5143 | + | |
| 5144 | + | |
| 5145 | + | |
5142 | 5146 | | |
5143 | 5147 | | |
5144 | 5148 | | |
| |||
5448 | 5452 | | |
5449 | 5453 | | |
5450 | 5454 | | |
5451 | | - | |
| 5455 | + | |
| 5456 | + | |
| 5457 | + | |
5452 | 5458 | | |
5453 | 5459 | | |
5454 | 5460 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | | - | |
| 337 | + | |
| 338 | + | |
338 | 339 | | |
339 | 340 | | |
340 | 341 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| |||
701 | 705 | | |
702 | 706 | | |
703 | 707 | | |
704 | | - | |
| 708 | + | |
705 | 709 | | |
706 | 710 | | |
707 | 711 | | |
| |||
13328 | 13332 | | |
13329 | 13333 | | |
13330 | 13334 | | |
13331 | | - | |
13332 | | - | |
13333 | | - | |
13334 | | - | |
13335 | | - | |
| 13335 | + | |
| 13336 | + | |
| 13337 | + | |
| 13338 | + | |
| 13339 | + | |
| 13340 | + | |
| 13341 | + | |
| 13342 | + | |
| 13343 | + | |
13336 | 13344 | | |
13337 | 13345 | | |
13338 | 13346 | | |
| |||
14902 | 14910 | | |
14903 | 14911 | | |
14904 | 14912 | | |
| 14913 | + | |
| 14914 | + | |
| 14915 | + | |
| 14916 | + | |
| 14917 | + | |
14905 | 14918 | | |
14906 | 14919 | | |
14907 | 14920 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
4862 | 4863 | | |
4863 | 4864 | | |
4864 | 4865 | | |
| 4866 | + | |
| 4867 | + | |
| 4868 | + | |
| 4869 | + | |
| 4870 | + | |
| 4871 | + | |
| 4872 | + | |
| 4873 | + | |
| 4874 | + | |
| 4875 | + | |
| 4876 | + | |
| 4877 | + | |
| 4878 | + | |
| 4879 | + | |
| 4880 | + | |
| 4881 | + | |
| 4882 | + | |
| 4883 | + | |
| 4884 | + | |
| 4885 | + | |
| 4886 | + | |
| 4887 | + | |
4865 | 4888 | | |
4866 | 4889 | | |
4867 | 4890 | | |
| |||
5089 | 5112 | | |
5090 | 5113 | | |
5091 | 5114 | | |
| 5115 | + | |
5092 | 5116 | | |
0 commit comments