Skip to content

feat(ezra-graph): dotted-attribute resolution + alias pass + ranking (#54) - #15904

Open
Antman316 wants to merge 3 commits into
NousResearch:mainfrom
Antman316:feat/ezra-graph-dotted-calls-54
Open

feat(ezra-graph): dotted-attribute resolution + alias pass + ranking (#54)#15904
Antman316 wants to merge 3 commits into
NousResearch:mainfrom
Antman316:feat/ezra-graph-dotted-calls-54

Conversation

@Antman316

@Antman316 Antman316 commented Apr 26, 2026

Copy link
Copy Markdown

Summary

ezra-graph builds a static code graph over Python/JS files and supports callers, blast-radius, and orphans queries 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

Review finding Resolution
Dotted import pkg.submodule without as binds only pkg collect_top_level_aliases() only stores aliases for explicit as or non-dotted imports; regression test added.
Hard-coded /Users/Prime/... defaults DEFAULT_DB uses EZRA_GRAPH_DB or get_hermes_home()/ezra/graph/ezra-graph.sqlite; roots use EZRA_GRAPH_ROOTS or Path.cwd().
Query commands silently create missing DB Added _require_db(); query commands exit clearly when DB is missing.
JS declarations recorded as self-calls scan_js() skips the declaration name on its own line; caller scope is line-local.
from package import target missed by blast-radius blast_radius() normalizes module.imported for exact matching.
Skill doc uses absolute Prime paths / lacks frontmatter SKILL.md has required frontmatter and portable defaults.
No dedicated skill format test Added tests/skills/test_codebase_semantic_graph.py.

Test results

$ python3 -m py_compile tools/ezra_graph.py tests/tools/test_ezra_graph.py tests/skills/test_codebase_semantic_graph.py
compile: ok

$ python3 -m unittest tests.tools.test_ezra_graph -v
Ran 9 tests — OK

$ python3 -m unittest tests.skills.test_codebase_semantic_graph -v
Ran 4 tests — OK

Portability statement

  • No absolute machine or user paths remain in code or skill docs.
  • Database path: EZRA_GRAPH_DB or ~/.hermes/ezra/graph/ezra-graph.sqlite (profile-aware via HERMES_HOME).
  • Scan roots: EZRA_GRAPH_ROOTS or --root; default is the current working directory.

Remaining limitations

  • JS/TS extraction is regex-based and best-effort.
  • blast-radius is static-import based; dynamic dispatch is not captured.
  • Full ruff/mypy was not run locally (no project venv in this session). Focused unit tests and py_compile pass.

Ready for maintainer re-review.

Copilot AI review requested due to automatic review settings April 26, 2026 05:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py with refresh, callers, blast-radius, and orphans commands 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.

Comment thread tests/tools/test_ezra_graph.py
Comment thread tools/ezra_graph.py Outdated
Comment thread tools/ezra_graph.py Outdated
Comment thread tools/ezra_graph.py Outdated
Comment thread skills/software-development/codebase-semantic-graph/SKILL.md Outdated
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/tools Tool registry, model_tools, toolsets tool/skills Skills system (list, view, manage) labels Apr 26, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-189 mis-resolves dotted imports without as: import pkg.submodule binds pkg, but the code maps it to pkg.submodule. The existing inline finding is valid and still unresolved.
  • tools/ezra_graph.py:272-283 records function unused() {} / method declarations as self-calls because CALL_RE sees the declaration name. That makes orphans suppress uncalled JS functions; current also never leaves the last detected function scope.
  • blast_radius() stores from package import target as separate module/imported fields at :207-212, but queries only i.module at :394-397; those reverse dependencies are missed.
  • The unresolved hard-coded /Users/Prime defaults and query-time DB creation at :23-28, :91-96, and :346-424 make the installed command nonportable. See existing defaults and query DB comments.
  • The new skill fails AGENTS.md:882-950 standards: its description is 66 characters at SKILL.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.

Comment thread tools/ezra_graph.py
Comment thread tools/ezra_graph.py Outdated
@teknium1 teknium1 added sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 12, 2026
Antman316 and others added 2 commits July 18, 2026 21:19
- 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.
@Antman316
Antman316 requested a review from a team July 19, 2026 02:24
@Antman316

Copy link
Copy Markdown
Author

All review findings addressed on feat/ezra-graph-dotted-calls-54 @ 65e2824. Focused tests green (9 tool + 4 skill). Ready for maintainer re-review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows tool/skills Skills system (list, view, manage) type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants