add trace pruning collapsing cross-service (PR-TRACE-1b)#245
Conversation
Implements four pruning features for the trace BFS engine: - prune_roles soft gate (edges recorded, frontier stops) - fan_out_cap with confidence + role ranking (scaffolding exempt) - collapse_trivial post-BFS pass with parent_edge_id recomputation - cross-service boundary detection (DECLARES_CLIENT/PRODUCER → HTTP/ASYNC_CALLS) Replaces 1a's test_trace_prune_roles_param_accepted_noop stub with test_trace_filter_vs_prune_roles. 10 additional 1b tests. 33 total unique tests (31 pass, 2 skip on fixture gaps). Full suite green (648 passed). No changes to mcp_v2.py, kuzu_queries.py, server.py. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
PR-TRACE-1b ReviewSolid implementation — clean separation between the four features, good test coverage, and consistent with project conventions. A few items: Medium
Low
What looks good
|
- Fix vacuous assertion in test_trace_cross_service_edge_attrs - Add docstring to _collapse_trivial_chains noting single-pass and mutation - Add stderr logging to cross-service exception handlers Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Dead code introduced in review fix commit. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* add trace pruning, collapsing, cross-service (PR-TRACE-1b) Implements four pruning features for the trace BFS engine: - prune_roles soft gate (edges recorded, frontier stops) - fan_out_cap with confidence + role ranking (scaffolding exempt) - collapse_trivial post-BFS pass with parent_edge_id recomputation - cross-service boundary detection (DECLARES_CLIENT/PRODUCER → HTTP/ASYNC_CALLS) Replaces 1a's test_trace_prune_roles_param_accepted_noop stub with test_trace_filter_vs_prune_roles. 10 additional 1b tests. 33 total unique tests (31 pass, 2 skip on fixture gaps). Full suite green (648 passed). No changes to mcp_v2.py, kuzu_queries.py, server.py. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: address review feedback on PR-TRACE-1b (#245) - Fix vacuous assertion in test_trace_cross_service_edge_attrs - Add docstring to _collapse_trivial_chains noting single-pass and mutation - Add stderr logging to cross-service exception handlers Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: remove duplicate continue in cross-service exception handler Dead code introduced in review fix commit. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* add trace pruning, collapsing, cross-service (PR-TRACE-1b) Implements four pruning features for the trace BFS engine: - prune_roles soft gate (edges recorded, frontier stops) - fan_out_cap with confidence + role ranking (scaffolding exempt) - collapse_trivial post-BFS pass with parent_edge_id recomputation - cross-service boundary detection (DECLARES_CLIENT/PRODUCER → HTTP/ASYNC_CALLS) Replaces 1a's test_trace_prune_roles_param_accepted_noop stub with test_trace_filter_vs_prune_roles. 10 additional 1b tests. 33 total unique tests (31 pass, 2 skip on fixture gaps). Full suite green (648 passed). No changes to mcp_v2.py, kuzu_queries.py, server.py. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: address review feedback on PR-TRACE-1b (#245) - Fix vacuous assertion in test_trace_cross_service_edge_attrs - Add docstring to _collapse_trivial_chains noting single-pass and mutation - Add stderr logging to cross-service exception handlers Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: remove duplicate continue in cross-service exception handler Dead code introduced in review fix commit. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* add trace pruning, collapsing, cross-service (PR-TRACE-1b) Implements four pruning features for the trace BFS engine: - prune_roles soft gate (edges recorded, frontier stops) - fan_out_cap with confidence + role ranking (scaffolding exempt) - collapse_trivial post-BFS pass with parent_edge_id recomputation - cross-service boundary detection (DECLARES_CLIENT/PRODUCER → HTTP/ASYNC_CALLS) Replaces 1a's test_trace_prune_roles_param_accepted_noop stub with test_trace_filter_vs_prune_roles. 10 additional 1b tests. 33 total unique tests (31 pass, 2 skip on fixture gaps). Full suite green (648 passed). No changes to mcp_v2.py, kuzu_queries.py, server.py. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: address review feedback on PR-TRACE-1b (#245) - Fix vacuous assertion in test_trace_cross_service_edge_attrs - Add docstring to _collapse_trivial_chains noting single-pass and mutation - Add stderr logging to cross-service exception handlers Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: remove duplicate continue in cross-service exception handler Dead code introduced in review fix commit. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Summary
stats.nodes_pruned_rolecounts pruned nodes.DECLARES_CLIENT,DECLARES_PRODUCER) are exempt.stats.nodes_pruned_fan_outcounts dropped nodes.collapsed=Trueandcollapsed_intermediates=[B.id].parent_edge_idis recomputed for child edges referencing removed edges.stats.edges_collapsed_trivialcounts collapsed chains.HTTP_CALLS/ASYNC_CALLSis inedge_types, BFS follows scaffolding edges (consuming a hop) to Client/Producer, then follows cross-service edges to downstream Route. Edges markedcross_service_boundary=True. Downstream node included innodesdict but NOT added to frontier (boundary-stop).Test plan
tests/test_mcp_trace.py(31 passed, 2 skipped on fixture graph gaps)test_trace_filter_vs_prune_rolesreplaces 1a'stest_trace_prune_roles_param_accepted_noopstub.venv/bin/ruff check .clean.venv/bin/python -m pytest tests -vgreen (648 passed, 11 skipped)git diff experimental -- mcp_v2.py kuzu_queries.py server.pyemptyScope
mcp_trace.py— pruning, collapsing, cross-service implementationtests/test_mcp_trace.py— 11 new/replaced testsmcp_v2.py,kuzu_queries.py,server.py,build_ast_graph.py,java_ontology.py🤖 Generated with Claude Code