Skip to content

chore: polish bundle — correctness/robustness nits (#359)#370

Merged
HumanBean17 merged 4 commits into
masterfrom
chore/polish-bundle
Jul 4, 2026
Merged

chore: polish bundle — correctness/robustness nits (#359)#370
HumanBean17 merged 4 commits into
masterfrom
chore/polish-bundle

Conversation

@HumanBean17

Copy link
Copy Markdown
Owner

What

A bundle of low-severity correctness/robustness nits from #359. Each independently small.

  1. exclude_roles now disables role weighting (search_lancedb.py) — skip_role_weight = bool(role or role_in), so an exclude_roles-only filter still applied role weights (asymmetric with role/role_in). Now includes exclude_roles.
  2. _parse_ladybug_json quotes only key positions (ladybug_queries.py) — the old (\w+): regex matched word: inside values too (e.g. a URL https://...), corrupting them. Now quotes keys only after { / , / [. Also fixed the misleading "counts_json" log label (the helper parses many graph_meta blobs). New unit test test_parse_ladybug_json_handles_colon_in_values.
  3. resolve rejects wildcards consistently (mcp_v2.py) — * / ? silently returned status='none', while search/find/neighbors reject them. Now success=False with a pointer to search(query=...). Renamed/updated the wildcard test.
  4. Client-kind literals de-leaked (java_ontology/ast_java/build_ast_graph) — feign_method/rest_template/web_client were emitted and matched directly. Added named CLIENT_KIND_* constants (exported in __all__) and reference them at every emit/match site so a rename in VALID_CLIENT_KINDS can't silently desync callers.
  5. CALLS dedup key includes call_site_byte (build_ast_graph.py) — two call sites of the same method on the same source line (same arg_count) no longer collapse into one edge. Regenerated the bank-chat baseline CALLS count (678 → 684; sampled CALLS first-3 are byte-identical since the new edges land later in insertion order) and mirrored the byte-inclusive key in the dedup test.
  6. Malformed YAML no longer silently swallowed (config.py) — load_yaml_mapping caught bare Exception and returned {}. Now catches yaml.YAMLError and emits a stderr hint.
  7. table_names()list_tables() (config.py, cli.py) — the lancedb DeprecationWarning is gone (lance_optimize already preferred list_tables with a fallback).

Deferred (with justification)

  • FastMCP.run_stdio_async "coroutine never awaited" RuntimeWarning (server.py:752): benign — the server runs fine; run_stdio_async is a clean coroutine properly awaited by asyncio.run, and the root cause appears to be inside the FastMCP stdio transport on premature stdin close. A speculative entry-point change risks destabilizing MCP server startup for no functional gain, so I left it rather than guess.

Test

.venv/bin/python -m pytest tests/test_ast_graph_build.py tests/test_mcp_v2.py tests/test_incremental_graph.py \
  tests/test_ladybug_queries.py tests/test_call_invariant.py tests/test_call_graph_smoke_roundtrip.py \
  tests/test_call_edges_e2e.py tests/test_bank_chat_brownfield_integration.py tests/test_brownfield_clients.py \
  tests/test_brownfield_routes.py tests/test_config.py tests/test_search_lancedb.py tests/test_client_hint_recovery.py -q
# 109 + 30 + ... all green; no regressions
.venv/bin/python -m pytest tests/test_java_codebase_rag_cli.py -q   # 61 passed (table_names deprecation warnings gone)

The bank-chat full-build smoke also passes (build_ast_graph.py --source-root tests/bank-chat-system).

Notes

  • The CALLS dedup change (PR-A1: Route schema + literal extractor (B2a) #5) is the only one that changes indexed output: bank-chat gains 6 CALLS edges that were previously wrongly collapsed. The baseline regeneration reflects this intended correction. No ontology_version bump (full-rebuild semantics are the canonical reference; this makes CALLS edges more granular, not differently typed).

Closes #359.

🤖 Generated with Claude Code

HumanBean17 and others added 4 commits July 4, 2026 00:14
- exclude_roles now disables role weighting (search_lancedb): skip_role_weight
  was bool(role or role_in), so an exclude_roles-only filter still applied role
  weights — asymmetric with role/role_in. Include exclude_roles.
- _parse_ladybug_json quotes only key positions (ladybug_queries): the old
  (\\w+): regex matched word-colon runs inside values too (e.g. a URL), corrupting
  them. Quote keys only after { , [ ; fix the misleading "counts_json" log label.
- resolve rejects wildcards consistently (mcp_v2): * / ? silently returned
  status='none'; search/find/neighbors reject them. Now success=False with a
  pointer to search(query=...). Updated the wildcard test accordingly.
- client-kind literals de-leaked: feign_method/rest_template/web_client emitted
  and matched directly; reference named CLIENT_KIND_* constants from
  java_ontology so a rename can't desync the emit/match sites.
- CALLS dedup key includes call_site_byte (build_ast_graph): two call sites of
  the same method on the same source line (same arg_count) no longer collapse
  into one edge. Regenerated the bank-chat baseline CALLS count (678 -> 684) and
  mirrored the byte-inclusive key in the dedup test.
- malformed YAML no longer silently swallowed (config): catch yaml.YAMLError and
  emit a stderr hint instead of a bare except returning {}.
- table_names() -> list_tables() (config, cli): the lancedb deprecation warning
  is gone (lance_optimize already preferred list_tables).

Deferred: the FastMCP run_stdio_async "coroutine never awaited" RuntimeWarning —
benign (the server runs; run_stdio_async is a clean coroutine awaited by
asyncio.run), root cause elusive without FastMCP stdio-transport internals, and
a speculative entry-point change risks destabilizing server startup.

Co-Authored-By: Claude <noreply@anthropic.com>
_write_meta deduped CALLS with the pre-#370 4-tuple (no call_site_byte)
while _write_edges wrote edges with the 5-tuple, so counts['calls']
(678) diverged from the real CALLS edge count (684) and describe/stats
undercounted. Mirror the 5-tuple in _write_meta and bump the bank-chat
baseline's counts_json.calls to 684.

Verified red->green: with only the fixture bumped, the baseline test
fails (rebuild yields 678); with the _write_meta fix it passes.

Co-Authored-By: Claude <noreply@anthropic.com>
The client-kind literal de-leak missed graph_enrich.py, which still
emitted the bare "rest_template" default when synthesizing a brownfield
HttpClientHint with no anchor. Reference the named constant so a future
rename in VALID_CLIENT_KINDS cannot silently desync this emit site.

Co-Authored-By: Claude <noreply@anthropic.com>
Narrowing the except to yaml.YAMLError let OSError (chmod 000,
stat/read TOCTOU) and UnicodeDecodeError (non-UTF-8 config) propagate
and abort startup, breaking the loader's return-{} contract. Catch all
three so an unreadable/malformed config degrades to defaults; keep the
stderr hint (generalized).

Co-Authored-By: Claude <noreply@anthropic.com>
@HumanBean17

Copy link
Copy Markdown
Owner Author

Addressed 3 findings from a multi-agent review pass:

  1. counts.calls undercount (medium)_write_meta deduped CALLS with the pre-widening 4-tuple key while _write_edges wrote with the 5-tuple (+ call_site_byte), so describe reported calls: 678 while the graph held 684 edges. Mirrored the 5-tuple in _write_meta and bumped the baseline counts_json.calls → 684. Verified red→green (baseline test fails with only the fixture bumped).
  2. Missed client-kind literal (low)graph_enrich.py still emitted a bare "rest_template" default at the synthesized-hint site; now uses CLIENT_KIND_REST_TEMPLATE.
  3. load_yaml_mapping except narrowed too far (low)OSError (chmod 000, stat/read TOCTOU) and UnicodeDecodeError (non-UTF-8) propagated instead of degrading to {}. Broadened to (yaml.YAMLError, OSError, UnicodeDecodeError); kept the stderr hint.

3 commits on this branch. ruff check clean; test_ast_graph_build.py + test_config.py green.

@HumanBean17 HumanBean17 merged commit b652df3 into master Jul 4, 2026
1 check passed
@HumanBean17 HumanBean17 deleted the chore/polish-bundle branch July 4, 2026 09:57
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.

polish bundle: small correctness/robustness nits

1 participant