Repository navigation
Commit b7e18c8
fix(mcp): harden semantic search inputs and store-error handling
Land the four residual hardening points from DeusData#938 on the current
semantic-search design (semantic_limit/offset, the certified top-K
fetch loop):
- extract_semantic_keywords rejects a semantic_query array that holds a
non-string element instead of silently running the string subset; the
caller gets the same isError as for a bare-string semantic_query.
- run_semantic_query_core fails closed when the vector scan itself
fails ("semantic search failed", isError) instead of rendering a store
error as zero matches plus the broaden-your-keywords hint.
cbm_store_vector_search now tells the two states apart: a store with
no node_vectors table (lean index) is CBM_STORE_NOT_FOUND and keeps
the empty-page + moderate/full-index hint that main relied on by
swallowing the "no such table" prepare failure; a failing scan is
CBM_STORE_ERR.
- vs_min_cosine_score hoists the keyword norms (once per search) and
the node norm (once per node) out of the per-(node, keyword) loop.
The integer sums are exact, so every score stays bit-identical.
- vs_append_result checks its strdup results, frees the partial row on
failure and counts a row only once every copy succeeded, so the
caller's free path stays valid.
Two reproduce-first tests in the mcp suite fail on main and pass with
the change: non-string elements produce the type error, and a forced
cbm_cosine_i8 failure produces the fail-closed error for semantic-only
and combined calls while a missing node_vectors table still yields the
lean-index hint.
Refs DeusData#915
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Co-authored-by: Dustin Persek <dustin.persek@protonmail.com>1 parent fe85a6b commit b7e18c8
4 files changed
Lines changed: 258 additions & 57 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4195 | 4195 | | |
4196 | 4196 | | |
4197 | 4197 | | |
4198 | | - | |
| 4198 | + | |
| 4199 | + | |
| 4200 | + | |
4199 | 4201 | | |
4200 | | - | |
4201 | | - | |
4202 | | - | |
4203 | | - | |
4204 | 4202 | | |
4205 | 4203 | | |
4206 | 4204 | | |
4207 | 4205 | | |
4208 | 4206 | | |
4209 | | - | |
| 4207 | + | |
| 4208 | + | |
| 4209 | + | |
| 4210 | + | |
4210 | 4211 | | |
4211 | 4212 | | |
4212 | 4213 | | |
| |||
4237 | 4238 | | |
4238 | 4239 | | |
4239 | 4240 | | |
| 4241 | + | |
| 4242 | + | |
| 4243 | + | |
| 4244 | + | |
| 4245 | + | |
| 4246 | + | |
4240 | 4247 | | |
4241 | 4248 | | |
4242 | | - | |
4243 | | - | |
4244 | | - | |
4245 | | - | |
4246 | | - | |
| 4249 | + | |
| 4250 | + | |
| 4251 | + | |
| 4252 | + | |
| 4253 | + | |
| 4254 | + | |
4247 | 4255 | | |
4248 | 4256 | | |
4249 | 4257 | | |
| |||
4256 | 4264 | | |
4257 | 4265 | | |
4258 | 4266 | | |
4259 | | - | |
| 4267 | + | |
4260 | 4268 | | |
4261 | | - | |
| 4269 | + | |
4262 | 4270 | | |
4263 | 4271 | | |
4264 | 4272 | | |
4265 | | - | |
4266 | | - | |
4267 | | - | |
4268 | | - | |
4269 | | - | |
4270 | | - | |
4271 | | - | |
| 4273 | + | |
| 4274 | + | |
| 4275 | + | |
| 4276 | + | |
| 4277 | + | |
| 4278 | + | |
| 4279 | + | |
| 4280 | + | |
| 4281 | + | |
| 4282 | + | |
| 4283 | + | |
| 4284 | + | |
| 4285 | + | |
4272 | 4286 | | |
4273 | 4287 | | |
4274 | 4288 | | |
4275 | 4289 | | |
4276 | 4290 | | |
4277 | | - | |
| 4291 | + | |
4278 | 4292 | | |
4279 | 4293 | | |
4280 | 4294 | | |
| |||
5134 | 5148 | | |
5135 | 5149 | | |
5136 | 5150 | | |
5137 | | - | |
5138 | | - | |
5139 | | - | |
| 5151 | + | |
| 5152 | + | |
| 5153 | + | |
5140 | 5154 | | |
5141 | 5155 | | |
5142 | 5156 | | |
| |||
5146 | 5160 | | |
5147 | 5161 | | |
5148 | 5162 | | |
| 5163 | + | |
| 5164 | + | |
| 5165 | + | |
| 5166 | + | |
| 5167 | + | |
| 5168 | + | |
5149 | 5169 | | |
5150 | 5170 | | |
5151 | | - | |
5152 | | - | |
5153 | | - | |
| 5171 | + | |
| 5172 | + | |
| 5173 | + | |
5154 | 5174 | | |
5155 | 5175 | | |
5156 | 5176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10018 | 10018 | | |
10019 | 10019 | | |
10020 | 10020 | | |
| 10021 | + | |
| 10022 | + | |
| 10023 | + | |
| 10024 | + | |
| 10025 | + | |
| 10026 | + | |
| 10027 | + | |
| 10028 | + | |
| 10029 | + | |
| 10030 | + | |
| 10031 | + | |
| 10032 | + | |
10021 | 10033 | | |
10022 | | - | |
10023 | | - | |
| 10034 | + | |
| 10035 | + | |
| 10036 | + | |
| 10037 | + | |
| 10038 | + | |
10024 | 10039 | | |
10025 | | - | |
| 10040 | + | |
| 10041 | + | |
10026 | 10042 | | |
10027 | 10043 | | |
10028 | 10044 | | |
| 10045 | + | |
| 10046 | + | |
| 10047 | + | |
| 10048 | + | |
| 10049 | + | |
10029 | 10050 | | |
10030 | 10051 | | |
10031 | 10052 | | |
10032 | | - | |
10033 | | - | |
10034 | 10053 | | |
10035 | 10054 | | |
10036 | | - | |
10037 | | - | |
10038 | 10055 | | |
10039 | | - | |
| 10056 | + | |
10040 | 10057 | | |
10041 | 10058 | | |
10042 | 10059 | | |
| |||
10045 | 10062 | | |
10046 | 10063 | | |
10047 | 10064 | | |
10048 | | - | |
10049 | | - | |
10050 | | - | |
10051 | | - | |
10052 | | - | |
10053 | | - | |
| 10065 | + | |
| 10066 | + | |
| 10067 | + | |
| 10068 | + | |
| 10069 | + | |
| 10070 | + | |
| 10071 | + | |
| 10072 | + | |
10054 | 10073 | | |
10055 | 10074 | | |
10056 | | - | |
| 10075 | + | |
10057 | 10076 | | |
10058 | | - | |
| 10077 | + | |
10059 | 10078 | | |
10060 | | - | |
| 10079 | + | |
10061 | 10080 | | |
10062 | 10081 | | |
10063 | | - | |
10064 | | - | |
| 10082 | + | |
| 10083 | + | |
10065 | 10084 | | |
10066 | 10085 | | |
10067 | 10086 | | |
10068 | 10087 | | |
10069 | | - | |
10070 | | - | |
10071 | | - | |
10072 | | - | |
| 10088 | + | |
| 10089 | + | |
| 10090 | + | |
| 10091 | + | |
| 10092 | + | |
| 10093 | + | |
| 10094 | + | |
| 10095 | + | |
| 10096 | + | |
| 10097 | + | |
| 10098 | + | |
10073 | 10099 | | |
10074 | 10100 | | |
10075 | | - | |
10076 | | - | |
| 10101 | + | |
| 10102 | + | |
| 10103 | + | |
| 10104 | + | |
| 10105 | + | |
| 10106 | + | |
| 10107 | + | |
| 10108 | + | |
| 10109 | + | |
| 10110 | + | |
| 10111 | + | |
| 10112 | + | |
| 10113 | + | |
| 10114 | + | |
| 10115 | + | |
| 10116 | + | |
| 10117 | + | |
| 10118 | + | |
| 10119 | + | |
| 10120 | + | |
| 10121 | + | |
| 10122 | + | |
| 10123 | + | |
| 10124 | + | |
| 10125 | + | |
| 10126 | + | |
| 10127 | + | |
10077 | 10128 | | |
10078 | 10129 | | |
10079 | 10130 | | |
| |||
10097 | 10148 | | |
10098 | 10149 | | |
10099 | 10150 | | |
| 10151 | + | |
| 10152 | + | |
| 10153 | + | |
| 10154 | + | |
| 10155 | + | |
10100 | 10156 | | |
10101 | 10157 | | |
10102 | 10158 | | |
10103 | 10159 | | |
10104 | 10160 | | |
| 10161 | + | |
| 10162 | + | |
10105 | 10163 | | |
10106 | 10164 | | |
10107 | 10165 | | |
| |||
10141 | 10199 | | |
10142 | 10200 | | |
10143 | 10201 | | |
10144 | | - | |
10145 | | - | |
10146 | | - | |
| 10202 | + | |
| 10203 | + | |
10147 | 10204 | | |
10148 | 10205 | | |
10149 | 10206 | | |
10150 | | - | |
10151 | 10207 | | |
10152 | 10208 | | |
10153 | 10209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1048 | 1048 | | |
1049 | 1049 | | |
1050 | 1050 | | |
1051 | | - | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
1052 | 1056 | | |
1053 | 1057 | | |
1054 | 1058 | | |
| |||
0 commit comments