Skip to content

feat(module-graph): draw inheritance alone where a pair both imports and extends - #749

Merged
zaebee merged 2 commits into
mainfrom
feat/748-module-graph-extends-covers-import
Oct 23, 2026
Merged

zaebee merged 2 commits into
mainfrom
feat/748-module-graph-extends-covers-import

Conversation

@zaebee

@zaebee zaebee commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Closes #748.

I checked cgis_module_graph against owner-api's own generated graph (docs/architecture/domain-modules.md, Ownima/owner-api#2317).

  • Before: on its reservation domain we had all 25 of its edges plus 5 more. Each extra was an import beside an inheritance edge for the same pair, e.g. core --> effects and core ==> effects.
  • Now: inheritance implies the import, so only ==> is drawn. The count is reported as covered in the JSON and as "Imports drawn as their inheritance: N." under the diagram.
  • Reduction unchanged: this applies after the transitive reduction, so which imports are implied is still decided over all of them.
  • Result: reservation now matches owner-api's picture edge for edge, 25 = 25.

Tests

  • two new tests: an import covered by inheritance, and imports alone kept intact;
  • the CLI test is updated, since creation --> core is now drawn as creation ==> core;
  • self-parsing passes, and so do mypy and interrogate.

🤖 Generated with Claude Code

…and extends

Checked against owner-api's own generated graph (Ownima/owner-api#2317): on
its reservation domain, cgis_module_graph had all 25 of its edges plus 5 more,
each an import beside an inheritance edge of the same pair (core --> effects
and core ==> effects). Inheritance implies the import, so only ==> is drawn
now, and the count is reported: `covered` in the JSON, "Imports drawn as
their inheritance: N." under the diagram.

Applied after the reduction, so which imports are implied by a longer path
is still decided over all of them. On reservation the picture now matches
owner-api's edge for edge (25 = 25).

Closes #748

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

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a mechanism to omit redundant import edges from the module graph when an inheritance ('extends') edge already exists between the same pair of modules. It adds a 'covered' attribute to track these omitted imports, updating the API documentation, Mermaid rendering, and JSON serialization accordingly. The review feedback correctly identifies a potential bug where the 'found' parameter in '_uncovered' is annotated as 'Iterable'. Since 'found' is evaluated multiple times, passing a non-reusable iterator could lead to silent exhaustion bugs; updating this annotation to 'Sequence' is recommended.

Comment thread src/cgis/query/analysis/module_graph.py Outdated
…in a cycle

Review of #749:
- Coverage came from the unreduced extends set, so where a ==> b was reduced
  away (implied through c) the import a --> b vanished too and the pair had no
  arrow at all, while the footnote counted it as "drawn as inheritance". It now
  comes from the kept extends edges.
- An import that closes an import cycle is never covered, so the cycle stays
  readable in --> alone.
- The legend, the dataclass and the MCP docstring say that a covered pair's
  ==> also stands for the import, so an import closure reads over both kinds;
  "inheritance implies the import" was too strong at module level.

Each fix has a test that failed first. owner-api's reservation still matches
its own diagram, 25 = 25.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@zaebee
zaebee merged commit 020a24a into main Oct 23, 2026
4 checks passed
@zaebee
zaebee deleted the feat/748-module-graph-extends-covers-import branch October 23, 2026 09:23
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.

module-graph: draw inheritance alone where a pair both imports and extends

1 participant