Commit 6a9b146
authored
feat(mcp): surface alias keys a documented data-shape omits (#780)
The documented-shape path answers "what fields does <blob> contain" at high
confidence and tells the caller no verification Read is needed. But a docstring
lists the declared shape, which can be a subset of what the records actually
carry: consumers often read a legacy alias the doc never mentions. For
co_change_partners_json, four consumers defensively read
`partner.get("co_change_count") or partner.get("count")` and
`... or partner.get("path")`, so `count` and `path` are real keys the documented
shape omits. Answering high-confidence "cite it, no Read needed" while hiding
those is a confidently-incomplete answer.
Mine them and surface them. After the documented shape is chosen, scan the
identifier's consumer files for the alias idiom `<recv>.get("<A>") or
<recv>.get("<B>")` where one key is a documented field; the other is an alias for
it. Requiring the `or` fallback on a shared receiver keeps this tight: an
assignment that merely co-mentions a documented key on an unrelated record, or a
test assertion, does not match. The extras ride back in a new
`data_shape.also_accessed` block (field + file:line), and the answer text names
them so the agent handles them instead of trusting a subset. The documented
fields stay authoritative; confidence stays high on the declared core.
Adds three tests: an omitted `or`-fallback alias is surfaced, a clean shape with
no divergence carries no also_accessed, and a cross-record co-mention (an
assignment, not a fallback) is correctly not reported as an alias.1 parent 199293a commit 6a9b146
3 files changed
Lines changed: 205 additions & 13 deletions
File tree
- packages/server/src/repowise/server/mcp_server/tool_answer
- tests/unit/server/mcp
Lines changed: 33 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| 306 | + | |
306 | 307 | | |
307 | 308 | | |
308 | 309 | | |
309 | 310 | | |
310 | 311 | | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
321 | 343 | | |
322 | 344 | | |
323 | 345 | | |
| |||
340 | 362 | | |
341 | 363 | | |
342 | 364 | | |
| 365 | + | |
343 | 366 | | |
344 | 367 | | |
345 | 368 | | |
| |||
Lines changed: 74 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
146 | 148 | | |
147 | 149 | | |
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
151 | 153 | | |
152 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
153 | 168 | | |
154 | 169 | | |
155 | 170 | | |
| |||
259 | 274 | | |
260 | 275 | | |
261 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
262 | 311 | | |
263 | 312 | | |
264 | 313 | | |
| |||
323 | 372 | | |
324 | 373 | | |
325 | 374 | | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
326 | 378 | | |
327 | 379 | | |
328 | 380 | | |
| |||
344 | 396 | | |
345 | 397 | | |
346 | 398 | | |
| 399 | + | |
347 | 400 | | |
348 | 401 | | |
349 | 402 | | |
| |||
352 | 405 | | |
353 | 406 | | |
354 | 407 | | |
| 408 | + | |
355 | 409 | | |
356 | 410 | | |
357 | 411 | | |
| |||
387 | 441 | | |
388 | 442 | | |
389 | 443 | | |
390 | | - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
391 | 459 | | |
392 | 460 | | |
393 | 461 | | |
394 | 462 | | |
395 | 463 | | |
396 | 464 | | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
397 | 468 | | |
398 | 469 | | |
399 | 470 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
240 | 338 | | |
241 | 339 | | |
0 commit comments