Skip to content

fix(classdiagram): resolve remaining class-diagram audit Lows (§4.2 #10/#11/#13/#14 + §5.2) - #168

Merged
HandyS11 merged 13 commits into
developfrom
revamp/classdiagram-lows
Jul 20, 2026
Merged

fix(classdiagram): resolve remaining class-diagram audit Lows (§4.2 #10/#11/#13/#14 + §5.2)#168
HandyS11 merged 13 commits into
developfrom
revamp/classdiagram-lows

Conversation

@HandyS11

Copy link
Copy Markdown
Owner

Summary

Phase 2 themed PR: fixes the ten remaining class-diagram findings from the 2026-07-14 audit re-audit — the four deferred §4.2 Lows, both §5.2 Mediums, and the four §5.2 class-diagram Lows. This closes out the class-diagram section of the audit entirely.

Spec: docs/superpowers/specs/2026-07-17-classdiagram-lows-design.md · Plan: docs/superpowers/plans/2026-07-17-classdiagram-lows-plan.md · One commit per finding, TDD throughout.

Finding Fix
§4.2 #10 (L) generic outer types discarded Result<Order> now keeps an edge to the user-defined Result<T> container (BCL containers still reduced to their arguments)
§4.2 #11 (L) collection detection by name substring Collection-ness now = implements System.Collections.IEnumerable; Settings<T> is no longer a "collection", custom collections are. Name heuristic kept only as fallback for unresolved (error) symbols
§4.2 #13 (L) dedupe keys use simple names Relationship dedupe keyed by fully-qualified name — A.Order and B.Order both keep their edges
§4.2 #14 (L) Sanitize merges distinct IDs Collision-aware node-ID map: Ns.Foo_Bar / Ns.Foo.Bar get distinct Mermaid IDs (_2 suffix); output unchanged unless a real collision exists
§5.2 (M) bare relative filename aborts projgraph class Foo.cs resolves the start directory from the full path instead of passing "" to the workspace walk
§5.2 (M) method arrays produce no edge Order[] GetAll() / Save(Order[] batch) now yield dependency edges (residual of §4.2 #8)
§5.2 (L) unguarded directory enumeration Mid-scan IOException/UnauthorizedAccessException degrades to a partial scan instead of aborting
§5.2 (L) external nodes drop generic arity External AbstractValidator<T> renders with its type parameters, matching in-source generics
§5.2 (L) trailing separator drops title projgraph class ./src/ keeps src as the diagram title
§5.2 (L) optimistic pass double-IO + tie-break override Single deterministic root scan; resolution no longer depends on which directory a type lives in

A self-review pass (8 finder angles + verification) caught one interaction bug before this PR: the newly-kept user collection container (PagedList<Order>) received the * cardinality on its own edge although the member holds exactly one container — * now applies only to element types (fixed in the last commit).

Known accepted trade-offs (documented in the spec): multi-definition type resolution now always uses the path-sorted tie-break (previously Models/ etc. won); removing the optimistic pass means a full root scan per distinct unresolved type name (memoized per name via TypeFileLookupCache).

Test plan

  • 15 new unit tests (one+ per finding) in Tests.Unit.ClassDiagram, TDD red→green
  • Full suite: 905 passed (baseline 890), 0 failed
  • dotnet format --verify-no-changes clean
  • EF goldens untouched (class diagrams have no goldens)

🤖 Generated with Claude Code

HandyS11 and others added 13 commits July 17, 2026 12:28
… + §5.2)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ration

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ndency edges

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…trings

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ionships

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…name

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…g separator

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ration guard

Review findings: a user-defined collection container (PagedList<Order>) got the
'*' cardinality on its own edge although the member holds exactly one container
instance — '*' now applies only to extracted element types. Also collapses the
two copy-paste enumeration try/catch blocks into EnumerateSafely.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 17, 2026 10:55

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

This PR completes the remaining class-diagram audit items by tightening type discovery, relationship analysis, and Mermaid rendering so diagrams are more deterministic, semantically accurate, and resilient to filesystem/runtime edge cases across CLI inputs.

Changes:

  • Make workspace type discovery deterministic (single root scan) and resilient to mid-enumeration IO failures.
  • Improve relationship extraction (fully-qualified dedupe, semantic collection detection, preserve user generic containers, handle arrays in method signatures, correct cardinality placement).
  • Prevent Mermaid node merges on sanitize collisions; preserve generic arity in external node names; fix analysis edge-cases for bare relative file inputs and trailing directory separators.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/ProjGraph.Tests.Unit.ClassDiagram/WorkspaceTypeDiscoveryTests.cs Adds unit coverage for deterministic resolution and partial-results behavior when enumeration throws.
tests/ProjGraph.Tests.Unit.ClassDiagram/SymbolResolverTests.cs Verifies unresolved external generic types keep generic arity in the rendered node name.
tests/ProjGraph.Tests.Unit.ClassDiagram/RelationshipAnalyzerTests.cs Adds coverage for fq-name dedupe, semantic collection detection, user generic containers, and arrays in method signatures.
tests/ProjGraph.Tests.Unit.ClassDiagram/MermaidClassDiagramRendererTests.cs Adds regression test for sanitize-collision-safe Mermaid IDs.
tests/ProjGraph.Tests.Unit.ClassDiagram/AnalyzeFileUseCaseTests.cs Covers bare relative filename handling so workspace scanning has a valid start directory.
tests/ProjGraph.Tests.Unit.ClassDiagram/AnalyzeDirectoryUseCaseTests.cs Covers directory title extraction when input has a trailing separator.
src/ProjGraph.Lib.ClassDiagram/Rendering/MermaidClassDiagramRenderer.cs Introduces collision-aware node ID mapping so distinct types don’t merge after sanitization.
src/ProjGraph.Lib.ClassDiagram/Infrastructure/WorkspaceTypeDiscovery.cs Removes optimistic pre-pass; adds defensive enumeration materialization for resilient scans.
src/ProjGraph.Lib.ClassDiagram/Infrastructure/TypeAnalyzer.cs Exposes a shared short-name formatter used for consistent generic rendering.
src/ProjGraph.Lib.ClassDiagram/Infrastructure/SymbolResolver.cs Uses the shared short-name formatter for external nodes (preserves generic arity).
src/ProjGraph.Lib.ClassDiagram/Infrastructure/RelationshipAnalyzer.cs Updates dedupe keys to fully-qualified names, semantic collection detection, array unwrapping for methods, and user generic container retention.
src/ProjGraph.Lib.ClassDiagram/Application/UseCases/AnalyzeFileUseCase.cs Resolves start directory from full path to avoid empty-string directory issues.
src/ProjGraph.Lib.ClassDiagram/Application/UseCases/AnalyzeDirectoryUseCase.cs Trims trailing directory separators to preserve diagram titles.
docs/superpowers/specs/2026-07-17-classdiagram-lows-design.md Adds design spec describing each finding and the chosen implementation approach.
docs/superpowers/plans/2026-07-17-classdiagram-lows-plan.md Adds detailed implementation plan and verification steps for the ten findings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@HandyS11
HandyS11 merged commit e182fa7 into develop Jul 20, 2026
7 checks passed
@HandyS11
HandyS11 deleted the revamp/classdiagram-lows branch July 20, 2026 08:51
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.

2 participants