feat(ezra-graph): dotted-attribute resolution + alias pass + ranking (#54) - #15904
feat(ezra-graph): dotted-attribute resolution + alias pass + ranking (#54)#15904Antman316 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new ezra-graph CLI tool to generate/query a lightweight static code graph (imports, symbols, dotted call edges) to support impact analysis across Hermes-related repos, with improved Python dotted-attribute call extraction, import-alias resolution, and ranked caller results.
Changes:
- Introduces
tools/ezra_graph.pywithrefresh,callers,blast-radius, andorphanscommands backed by a SQLite schema (v2) and ranking logic for caller output. - Adds unit tests validating dotted call extraction and basic alias resolution behavior.
- Documents the workflow as a new skill and exposes the CLI via
pyproject.toml(ezra-graph = tools.ezra_graph:main).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| tools/ezra_graph.py | New CLI implementation: scanning, alias resolution, schema management, and query commands (ranked callers, blast radius, orphans). |
| tests/tools/test_ezra_graph.py | Unittest coverage for dotted call path extraction and aliased import resolution. |
| skills/software-development/codebase-semantic-graph/SKILL.md | New skill documentation describing artifact location, refresh, resolution model, and queries. |
| pyproject.toml | Adds ezra-graph as an installable console script entry point. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the static-analysis contribution. Current main has no ezra-graph implementation, so this is a new feature rather than a stale bug fix.
Problems
tools/ezra_graph.py:167-189mis-resolves dotted imports withoutas:import pkg.submodulebindspkg, but the code maps it topkg.submodule. The existing inline finding is valid and still unresolved.tools/ezra_graph.py:272-283recordsfunction unused() {}/ method declarations as self-calls becauseCALL_REsees the declaration name. That makesorphanssuppress uncalled JS functions;currentalso never leaves the last detected function scope.blast_radius()storesfrom package import targetas separatemodule/importedfields at:207-212, but queries onlyi.moduleat:394-397; those reverse dependencies are missed.- The unresolved hard-coded
/Users/Primedefaults and query-time DB creation at:23-28,:91-96, and:346-424make the installed command nonportable. See existing defaults and query DB comments. - The new skill fails
AGENTS.md:882-950standards: its description is 66 characters atSKILL.md:3, and it lacks the required author/section structure.
Suggested changes
- Add the import and reverse-dependency regression cases; use syntax-aware JS/TS extraction or explicitly limit scope to Python.
- Use portable, profile-aware paths and make query commands require an existing database.
- Modernize the skill and add its required skill test.
Automated hermes-sweeper review.
- Dotted imports without aliases now bind only the top-level package. - Portable, env-overridable defaults for DB path and scan roots. - Query commands (callers, blast-radius, orphans) fail clearly on missing DB. - JS function declarations no longer record a self-call. - blast-radius now matches from-package imports via imported/module normalization. - SKILL.md updated to current Hermes frontmatter and section standards. - Added regression tests for dotted imports, missing DB, JS self-calls, reverse-dependency matching, and SKILL.md structure.
|
All review findings addressed on feat/ezra-graph-dotted-calls-54 @ 65e2824. Focused tests green (9 tool + 4 skill). Ready for maintainer re-review. |
Summary
ezra-graphbuilds a static code graph over Python/JS files and supportscallers,blast-radius, andorphansqueries for triage-driven impact analysis.Changes in this update
tools/ezra_graph.py: portable defaults, explicit missing-DB errors, dotted-import alias fix, JS declaration self-call fix, and from-package reverse-dependency matching.skills/software-development/codebase-semantic-graph/SKILL.md: Hermes-format frontmatter plus When to Use, Quick Reference, Procedure, Pitfalls, and Verification sections.tests/tools/test_ezra_graph.py: regression tests for dotted imports without aliases, missing-DB errors, JS declaration self-calls, and reverse-dependency matching.tests/skills/test_codebase_semantic_graph.py: validates the skill file's frontmatter and required documentation sections.Review findings addressed
import pkg.submodulewithoutasbinds onlypkgcollect_top_level_aliases()only stores aliases for explicitasor non-dotted imports; regression test added./Users/Prime/...defaultsDEFAULT_DBusesEZRA_GRAPH_DBorget_hermes_home()/ezra/graph/ezra-graph.sqlite; roots useEZRA_GRAPH_ROOTSorPath.cwd()._require_db(); query commands exit clearly when DB is missing.scan_js()skips the declaration name on its own line; caller scope is line-local.from package import targetmissed by blast-radiusblast_radius()normalizesmodule.importedfor exact matching.SKILL.mdhas required frontmatter and portable defaults.tests/skills/test_codebase_semantic_graph.py.Test results
Portability statement
EZRA_GRAPH_DBor~/.hermes/ezra/graph/ezra-graph.sqlite(profile-aware viaHERMES_HOME).EZRA_GRAPH_ROOTSor--root; default is the current working directory.Remaining limitations
blast-radiusis static-import based; dynamic dispatch is not captured.ruff/mypywas not run locally (no project venv in this session). Focused unit tests andpy_compilepass.Ready for maintainer re-review.