Repository navigation
Commit 9b10ba2
committed
fix(mcp): answer a bare name with every arity of a function
Two query paths read a bare function name, and neither could see an arity fence.
get_code_snippet returned one body. Before arity was part of identity, fetch/1, fetch/2
and fetch/3 were one node and it returned whichever survived the collision, with
no ambiguity signal. Now they are three nodes, and a bare `fetch` answers that
the name is ambiguous, with one suggestion per arity. pick_resolved_node gains
`fold_arity`, and get_code_snippet passes false.
trace_call_path wants the opposite. "Who calls fetch" wants the callers of every
arity, and bfs_union_same_name already unions the seeds it is given, so it passes
true and candidates whose QNs are equal once the fence is removed fold into one
logical symbol, the same way a body-less `.d.ts` stub already folds into its
implementation. Two genuinely different same-named functions live in different
containers, so their stripped QNs still differ and they are still reported
ambiguous.
The flag gates both tallies, the top-score tie and the rival-definition count,
because either one alone decides the answer. Honouring it in only one left
ambiguity resting on whether two clauses happened to have the same line count.
For the same reason a fenced QN counts as a rival definition even with a
one-line span. The body-less rule exists for ambient declarations; a fence is
minted only from a definition head the extractor actually saw, so
`def size(x), do: byte_size(x)` is a whole definition that merely occupies one
line. Judging it by span would go back to deciding the answer by how many lines
a body happens to take up.
cbm_store_find_nodes_by_qn_suffix gains a third alternative matching the fenced
forms of the same dotted tail. Without it, get_code_snippet("fetch"), the
bare-name convention every agent is told to use, reached no arity of an
overloaded function. '#' is not a LIKE metacharacter, so it is matched
literally.
On a three-arity fixture, get_code_snippet("fetch") answered with one arity's
body and status "ok" before this commit and answers status "ambiguous" with one
suggestion per arity after it, whatever the relative body lengths.
trace_call_path is deliberately unchanged: it keeps folding the arities into one
union, which is why the two paths need a flag between them.
tests/test_mcp.c: snippet_bare_name_every_arity_is_ambiguous_whatever_the_spans
pins that the answer does not depend on relative body length, and
snippet_arity_fold_still_traces_every_arity_under_one_bare_name pins the trace
side of the same flag. tests/test_store_nodes.c:
store_find_by_qn_suffix_matches_arity_fence pins the probe.
Its content dependency is the module/arity identity commit, which mints the
fenced QNs this commit teaches the MCP layer to read.
Signed-off-by: Chad <4307099+BobbieBarker@users.noreply.github.com>1 parent 4f5cb98 commit 9b10ba2
4 files changed
Lines changed: 348 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8393 | 8393 | | |
8394 | 8394 | | |
8395 | 8395 | | |
8396 | | - | |
8397 | | - | |
8398 | | - | |
8399 | | - | |
8400 | | - | |
8401 | | - | |
8402 | | - | |
8403 | | - | |
| 8396 | + | |
| 8397 | + | |
| 8398 | + | |
| 8399 | + | |
| 8400 | + | |
| 8401 | + | |
| 8402 | + | |
| 8403 | + | |
| 8404 | + | |
| 8405 | + | |
| 8406 | + | |
| 8407 | + | |
| 8408 | + | |
| 8409 | + | |
| 8410 | + | |
| 8411 | + | |
| 8412 | + | |
| 8413 | + | |
| 8414 | + | |
| 8415 | + | |
| 8416 | + | |
| 8417 | + | |
| 8418 | + | |
| 8419 | + | |
| 8420 | + | |
| 8421 | + | |
| 8422 | + | |
| 8423 | + | |
| 8424 | + | |
| 8425 | + | |
| 8426 | + | |
| 8427 | + | |
| 8428 | + | |
| 8429 | + | |
| 8430 | + | |
| 8431 | + | |
| 8432 | + | |
| 8433 | + | |
| 8434 | + | |
| 8435 | + | |
| 8436 | + | |
| 8437 | + | |
8404 | 8438 | | |
8405 | 8439 | | |
8406 | 8440 | | |
8407 | 8441 | | |
8408 | 8442 | | |
8409 | 8443 | | |
8410 | | - | |
| 8444 | + | |
| 8445 | + | |
| 8446 | + | |
| 8447 | + | |
8411 | 8448 | | |
8412 | 8449 | | |
8413 | 8450 | | |
8414 | 8451 | | |
8415 | 8452 | | |
8416 | 8453 | | |
8417 | | - | |
| 8454 | + | |
8418 | 8455 | | |
8419 | 8456 | | |
8420 | 8457 | | |
8421 | 8458 | | |
8422 | 8459 | | |
8423 | | - | |
| 8460 | + | |
| 8461 | + | |
| 8462 | + | |
| 8463 | + | |
| 8464 | + | |
| 8465 | + | |
| 8466 | + | |
| 8467 | + | |
| 8468 | + | |
| 8469 | + | |
| 8470 | + | |
| 8471 | + | |
| 8472 | + | |
| 8473 | + | |
| 8474 | + | |
| 8475 | + | |
8424 | 8476 | | |
8425 | 8477 | | |
8426 | 8478 | | |
| |||
8436 | 8488 | | |
8437 | 8489 | | |
8438 | 8490 | | |
| 8491 | + | |
| 8492 | + | |
| 8493 | + | |
| 8494 | + | |
| 8495 | + | |
| 8496 | + | |
| 8497 | + | |
| 8498 | + | |
| 8499 | + | |
| 8500 | + | |
| 8501 | + | |
| 8502 | + | |
| 8503 | + | |
| 8504 | + | |
| 8505 | + | |
| 8506 | + | |
| 8507 | + | |
| 8508 | + | |
| 8509 | + | |
| 8510 | + | |
| 8511 | + | |
| 8512 | + | |
8439 | 8513 | | |
8440 | 8514 | | |
8441 | | - | |
| 8515 | + | |
| 8516 | + | |
| 8517 | + | |
| 8518 | + | |
| 8519 | + | |
| 8520 | + | |
| 8521 | + | |
| 8522 | + | |
| 8523 | + | |
| 8524 | + | |
| 8525 | + | |
| 8526 | + | |
8442 | 8527 | | |
8443 | | - | |
| 8528 | + | |
| 8529 | + | |
| 8530 | + | |
| 8531 | + | |
| 8532 | + | |
| 8533 | + | |
| 8534 | + | |
| 8535 | + | |
| 8536 | + | |
| 8537 | + | |
| 8538 | + | |
| 8539 | + | |
| 8540 | + | |
| 8541 | + | |
| 8542 | + | |
8444 | 8543 | | |
8445 | 8544 | | |
8446 | 8545 | | |
| |||
9188 | 9287 | | |
9189 | 9288 | | |
9190 | 9289 | | |
9191 | | - | |
| 9290 | + | |
9192 | 9291 | | |
9193 | 9292 | | |
9194 | 9293 | | |
| |||
12456 | 12555 | | |
12457 | 12556 | | |
12458 | 12557 | | |
12459 | | - | |
| 12558 | + | |
12460 | 12559 | | |
12461 | 12560 | | |
12462 | 12561 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4383 | 4383 | | |
4384 | 4384 | | |
4385 | 4385 | | |
4386 | | - | |
| 4386 | + | |
| 4387 | + | |
| 4388 | + | |
| 4389 | + | |
| 4390 | + | |
| 4391 | + | |
| 4392 | + | |
4387 | 4393 | | |
4388 | | - | |
| 4394 | + | |
| 4395 | + | |
| 4396 | + | |
4389 | 4397 | | |
4390 | 4398 | | |
4391 | 4399 | | |
4392 | 4400 | | |
4393 | | - | |
| 4401 | + | |
| 4402 | + | |
4394 | 4403 | | |
4395 | 4404 | | |
4396 | | - | |
| 4405 | + | |
| 4406 | + | |
4397 | 4407 | | |
4398 | 4408 | | |
4399 | 4409 | | |
| |||
4407 | 4417 | | |
4408 | 4418 | | |
4409 | 4419 | | |
| 4420 | + | |
4410 | 4421 | | |
4411 | 4422 | | |
4412 | 4423 | | |
| 4424 | + | |
4413 | 4425 | | |
4414 | 4426 | | |
4415 | 4427 | | |
| |||
0 commit comments