Skip to content

fix: entry_function is a real AST filter, not an LLM-enrichment hint (#312) - #317

Merged
piyushmakhija28 merged 3 commits into
mainfrom
fix/312-entry-function-bfs-filter
Sep 7, 2026
Merged

piyushmakhija28 merged 3 commits into
mainfrom
fix/312-entry-function-bfs-filter

Conversation

@piyushmakhija28

Copy link
Copy Markdown
Collaborator

Summary

  • generate_sequence_diagram(call_chains=None, context="") passed its context parameter straight into _llm_enrich() whenever non-empty, silently replacing the deterministic AST rendering with LLM output.
  • mcp-uml-diagram/server.py's generate_sequence_diagram tool passed its entry_function parameter ("Optional function name to trace the call chain from") into that same context= argument — so any caller who supplied entry_function to what is documented and labelled a Tier 2 AST tool got an LLM-authored diagram instead, with the response's own "source": "derived" field claiming otherwise. There was no actual entry-function tracing implemented anywhere in the method.

Fix

  • Renamed the parameter to entry_function and gave it real meaning: a BFS filter on caller→callee reachability from the named function, via a new _filter_chains_from_entry() helper.
  • Removed the context-triggered LLM enrichment path entirely from both generate_sequence_diagram and _sequence_from_fqn_chains (confirmed via grep: nothing else in the class called _llm_enrich, so nothing else relied on this path).
  • Updated the mcp-uml-diagram tool call site (separate PR, that repo) to pass entry_function=entry_function instead of context=entry_function.

Deliberately not touched, disclosed rather than silently decided

_llm_enrich() itself is now unreferenced by any production code path in this file, but tests/test_udm_generate_from_data.py monkeypatches it defensively (asserting the deterministic UDM path never reaches it). Deleting it risks breaking that test's setup, and auditing whether other Tier-2-hybrid methods in this class still need it is out of this issue's scope.

Test plan

  • New TestSequenceDiagramEntryFunctionFilter (4 tests): entry_function never reaches an LLM call (explicit explosion-on-call guard), filters to only reachable calls, an unmatched entry_function gets its own explicit message distinct from "no call chains found", and the empty/default case remains unfiltered
  • Full relevant suite: pytest tests/test_uml_generators.py tests/test_udm_generate_from_data.py — 106/106 pass

Closes #312.

🤖 Generated with Claude Code

https://claude.ai/code/session_01477SY6G5x6ft5PGe3C5xPh

piyushmakhija28 and others added 3 commits September 6, 2026 18:37
locate_library_root() searched Path(search_from).parent for
claude-global-library, treating the plugin root's parent as the workspace
root. It is actually the engine repo root, one level short of the real
sibling relationship, so auto-discovery silently reported NO_LIBRARY
instead of STALE on a dev machine with both checkouts present -- exactly
the scenario this check exists to catch (verified: pinned 29.73.0 vs live
29.97.4, 21 agents missing from the snapshot). Fixed to ascend two levels,
matching the already-correct scripts/build_library_snapshot.py, and added
a regression test that exercises the auto-discovery path with a directory
layout mirroring the real repo instead of always passing library_root
explicitly.

Fixes #315

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012xm5ALQHK3gnBQq4dMfPFD
…et built

README.md said register-mcp reports the version-push-gate capability as
unavailable because it is "catalogued but not yet built." That has been
false since src/mcp/push_gate/server.py landed (ADR-006, commit 0900fff) --
both capabilities are registered and REACHABLE today, verified via
`python scripts/mcp_registration.py status`.

Fixes #316

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012xm5ALQHK3gnBQq4dMfPFD
…312)

generate_sequence_diagram(call_chains=None, context="") passed its
context parameter straight into _llm_enrich() whenever non-empty,
silently replacing the deterministic AST rendering with LLM output.
mcp-uml-diagram/server.py's generate_sequence_diagram tool passed its
entry_function parameter ("Optional function name to trace the call
chain from") into that same context= argument - so any caller who
supplied entry_function to what is documented and labelled a Tier 2
AST tool got an LLM-authored diagram instead, with the response's own
"source": "derived" field claiming otherwise.

There was no actual entry-function tracing implemented anywhere in the
method; passing a non-empty entry_function did nothing but trigger LLM
enrichment.

Fix: renamed the parameter to entry_function and gave it real meaning -
a BFS filter on caller->callee reachability from the named function,
via a new _filter_chains_from_entry() helper - and removed the
context-triggered LLM enrichment path entirely from both
generate_sequence_diagram and _sequence_from_fqn_chains (confirmed via
grep: nothing else in the class called _llm_enrich, so nothing else
relied on this path). Updated the mcp-uml-diagram tool call site to
pass entry_function=entry_function instead of context=entry_function,
and corrected its docstring.

Not touched, disclosed rather than silently decided either way:
_llm_enrich() itself is now unreferenced by any production code path
in this file, but tests/test_udm_generate_from_data.py monkeypatches it
defensively (asserting the deterministic UDM path never reaches it), so
deleting it risks breaking that test's setup, and auditing whether
other Tier-2-hybrid methods in this class still need it is out of this
issue's scope.

Adds 4 regression tests in TestSequenceDiagramEntryFunctionFilter:
entry_function never reaches an LLM call (explicit explosion-on-call
guard), filters to only reachable calls, an unmatched entry_function
gets its own explicit message distinct from "no call chains found",
and the empty/default case remains unfiltered. Full relevant suite:
106/106 pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01477SY6G5x6ft5PGe3C5xPh
@piyushmakhija28
piyushmakhija28 merged commit 4cbdac8 into main Sep 7, 2026
4 of 6 checks passed
@piyushmakhija28
piyushmakhija28 deleted the fix/312-entry-function-bfs-filter branch September 7, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generate_sequence_diagram silently returns LLM output whenever context is non-empty, despite being labelled a Tier 2 AST tool

1 participant