Skip to content

Commit d7746da

Browse files
Sellafieldclaude
andauthored
P36.2 (#12)
* Add IMPROVEMENT-021 Phase 1 design spec: graphify-dotnet integration Covers Directory.Build.targets pre-build hook, dotnet-tools.json registration, docs/graph/ committed output, and .claude/knowledge/ Claude consumption artifact. Phase 2 (.NET 10 migration) deferred as independent workstream. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add graphify-dotnet integration implementation plan 5-task plan: tool registration, Directory.Build.targets, artifact verification, Claude knowledge file, and docs/backlog updates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: register graphify-dotnet 0.7.0 local tool * chore: add graphify pre-build target and graph output directory Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: switch graphify output to wiki format, gitignore generated artifacts * chore: switch graphify output to report format Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs: add Claude orientation file for codebase graph * docs: fix codebase-graph.md accuracy (god nodes, .NET version, community count) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * ci: add GitHub Wiki publishing job for codebase graph report * chore: add graphify-out to gitignore, harden CI SHA interpolation * docs: update ARCHITECTURE.md and backlog for graphify integration (IMPROVEMENT-021) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs: final review fixes (heading hierarchy, hardcoded counts, CI path) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3d5bb2a commit d7746da

9 files changed

Lines changed: 655 additions & 27 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Codebase Dependency Graph
2+
3+
Generated by graphify-dotnet from the `src/` directory. Regenerates automatically before
4+
each build of `Perpetuum.Server` (requires .NET 10 SDK for the graphify tool — `dotnet tool restore` from the
5+
solution root).
6+
7+
## Artifacts
8+
9+
- **`docs/graph/graph.json`** — machine-readable graph; gitignored,
10+
present after any local `Perpetuum.Server` build
11+
- **`docs/graph/GRAPH_REPORT.md`** — Markdown architecture report; gitignored, same condition
12+
- **GitHub Wiki** — latest report published by CI:
13+
`https://github.com/OpenPerpetuum/PerpetuumServer2/wiki/Codebase-Graph`
14+
15+
## Graph Structure
16+
17+
Nodes represent C# classes, methods, and namespaces (type: `Entity` or `File`).
18+
Edges represent inheritance, composition, and namespace imports.
19+
Communities (Louvain clustering, clusters) group related symbols.
20+
21+
## How to Use
22+
23+
**Impact analysis** — when a type is modified, query `graph.json` for edges pointing to that
24+
node's `id` to find all dependents before assessing blast radius.
25+
26+
**God-node awareness** — the top 10 most-connected symbols are listed in `GRAPH_REPORT.md`
27+
under "God Nodes". These are the highest-risk symbols to change: `RelocateItems`,
28+
`LootItemRepository`, `PackItems`, `ChangeAmmo`, `UnstackAmount`, `EquipModule`,
29+
`ListContainer`, `IWeatherService`, `SetItemName`, `ILootItemRepository` — see `GRAPH_REPORT.md` for the full list.
30+
31+
**Subsystem navigation** — look up a class node in `graph.json` to find its `community` ID,
32+
then find other nodes with the same `community` to discover related types in the same cluster.
33+
34+
**Dependency verification** — check for edge paths between two namespaces to confirm whether
35+
an unintended cross-subsystem dependency would be introduced by a change.

.config/dotnet-tools.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"graphify-dotnet": {
6+
"version": "0.7.0",
7+
"commands": [
8+
"graphify"
9+
]
10+
}
11+
}
12+
}

.github/workflows/dotnet.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,46 @@ jobs:
5757
name: Perpetuum-AdminTool-Installer-${{ github.sha }}
5858
path: ${{ env.Workspace }}/src/Perpetuum.AdminToolInstaller/bin/x64/Release/en-US/*.msi
5959
if: ${{ github.event_name == 'push' }}
60+
61+
publish-wiki:
62+
63+
runs-on: windows-latest
64+
needs: build
65+
if: github.event_name == 'push'
66+
permissions:
67+
contents: write
68+
69+
steps:
70+
- uses: actions/checkout@v4
71+
72+
- name: Setup .NET 10 (graphify tool requirement)
73+
uses: actions/setup-dotnet@v4
74+
with:
75+
dotnet-version: 10.0.x
76+
77+
- name: Restore dotnet tools
78+
run: dotnet tool restore
79+
80+
- name: Generate codebase report
81+
working-directory: ${{ github.workspace }}
82+
run: dotnet tool run graphify run src -o graphify-out -f report
83+
84+
- name: Publish report to GitHub Wiki
85+
shell: pwsh
86+
env:
87+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
COMMIT_SHA: ${{ github.sha }}
89+
run: |
90+
git clone "https://x-access-token:$env:GH_TOKEN@github.com/OpenPerpetuum/PerpetuumServer2.wiki.git" wiki-repo
91+
Copy-Item "graphify-out/GRAPH_REPORT.md" -Destination "wiki-repo/Codebase-Graph.md" -Force
92+
Set-Location wiki-repo
93+
git config user.name "github-actions[bot]"
94+
git config user.email "github-actions[bot]@users.noreply.github.com"
95+
git add "Codebase-Graph.md"
96+
$changes = git status --porcelain
97+
if ($changes) {
98+
git commit -m "Update codebase graph report [$env:COMMIT_SHA]"
99+
git push
100+
} else {
101+
Write-Host "No wiki changes to publish"
102+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ Releases/
2323
.planning/
2424
*.log
2525
*_wpftmp.csproj
26+
27+
# graphify-dotnet generated output (regenerates on build)
28+
docs/graph/
29+
graphify-out/

Directory.Build.targets

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<Target Name="GenerateCodeGraph" BeforeTargets="Build"
3+
Condition="'$(MSBuildProjectName)' == 'Perpetuum.Server'">
4+
<Exec Command="dotnet tool run graphify run &quot;$(MSBuildThisFileDirectory)src&quot; -o &quot;$(MSBuildThisFileDirectory)docs\graph&quot; -f json,report"
5+
ContinueOnError="true"
6+
WorkingDirectory="$(MSBuildThisFileDirectory)" />
7+
</Target>
8+
</Project>

docs/backlog/improvements.md

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -499,41 +499,32 @@ Installer output should be a single executable or package that operators can dis
499499

500500
---
501501

502-
## IMPROVEMENT-021 - Upgrade to .NET 10 and Integrate Graphify
502+
## IMPROVEMENT-021 - Graphify Codebase Graph Integration
503503

504-
Status: TODO
504+
Status: DONE
505505
Priority: HIGH
506506
Area: Infrastructure / Tooling / AI
507+
Spec: docs/superpowers/specs/2026-05-23-improvement-021-graphify-integration-design.md
507508

508509
### Description
509-
Plan and execute a careful migration of the entire solution from .NET 8 to .NET 10, then integrate the [Graphify](https://github.com/willibrandon/graphify) package (a .NET 10 dependency) to generate a structural graph of the codebase and wire it to Claude for enhanced code understanding and navigation.
510-
511-
### Impact
512-
.NET 10 (LTS) brings performance improvements, new C# language features, and long-term support beyond .NET 8. The Graphify integration would give Claude (and operators) a machine-readable dependency/call graph of the server codebase, enabling more accurate impact analysis, smarter navigation, and reduced hallucination risk when reasoning about unfamiliar subsystems.
510+
Integrated `graphify-dotnet` (https://github.com/elbruno/graphify-dotnet) as a local dotnet
511+
tool. Generates a structural JSON graph and Markdown architecture report before every
512+
`Perpetuum.Server` build. CI publishes the report to the GitHub Wiki on each push to `develop`.
513513

514-
### Proposed Implementation
515-
516-
**Phase 1 — .NET 10 upgrade**
517-
- Audit current NuGet dependencies for .NET 10 compatibility; flag any packages with no .NET 10 target or known breaking changes.
518-
- Update all `<TargetFramework>` entries in `.csproj` files from `net8.0` to `net10.0`.
519-
- Address any breaking API changes surfaced by the build (`dotnet build`): BCL changes, removed APIs, updated semantics.
520-
- Update the CI workflow (`.github/workflows/dotnet.yml`) to use the .NET 10 SDK.
521-
- Validate a full Release build and a local server run before proceeding to Phase 2.
522-
- Update `docs/STACK.md` to reflect the new runtime version.
523-
524-
**Phase 2 — Graphify integration**
525-
- Add the Graphify NuGet package to the solution (targeting the appropriate project — likely a standalone tooling project or the AdminTool).
526-
- Configure Graphify to analyze the `PerpetuumServer2` solution and output a dependency/call graph in a Claude-consumable format (JSON, Markdown, or Graphify's native output).
527-
- Define what graph artifacts are most useful for Claude: namespace dependency graph, class hierarchy, inter-module call graph, or a combination.
528-
- Automate graph regeneration (e.g. as a pre-build step or CI artifact) so the graph stays current as the codebase evolves.
529-
- Document how Claude should load and interpret the graph output — update `.claude/knowledge/architecture.md` with a pointer to the graph artifact and a brief explanation of its structure.
514+
### Implementation
515+
- `.config/dotnet-tools.json` registers `graphify-dotnet@0.7.0` (command: `graphify`)
516+
- `Directory.Build.targets` (solution root) fires `GenerateCodeGraph` before `Perpetuum.Server`
517+
builds; `ContinueOnError="true"` soft-fails on machines without .NET 10 SDK
518+
- `-f json,report` produces `docs/graph/graph.json` and `docs/graph/GRAPH_REPORT.md` (gitignored)
519+
- `.github/workflows/dotnet.yml` `publish-wiki` job pushes `GRAPH_REPORT.md` to GitHub Wiki as
520+
`Codebase-Graph.md` on each push to `develop`
521+
- `.claude/knowledge/codebase-graph.md` added for Claude orientation
530522

531523
### Notes
532-
.NET 10 is on the STS/LTS release train; verify its LTS status and release date before committing to the upgrade timeline.
533-
Graphify requires .NET 10 — Phase 1 must be complete and stable before Phase 2 begins.
534-
The upgrade should be done on a dedicated branch with a full build + manual smoke test before merging.
535-
Pay special attention to any use of reflection, source generators, or runtime behaviour that changed between .NET 8 and .NET 10.
536-
Autofac and other DI/serialization libraries should be verified for .NET 10 compatibility early — these are common sources of upgrade friction.
524+
Phase 2 (.NET 8 → .NET 10 project TFM migration) is deferred as an independent workstream.
525+
The graphify tool requires .NET 10 SDK but the project TFMs remain at net8.0.
526+
Run `dotnet tool restore` once after cloning to enable graph regeneration.
527+
GitHub Wiki must have at least one page initialized before the CI publish job can push.
537528

538529
---
539530

docs/codebase/ARCHITECTURE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,15 @@ Post-commit hooks via `Transaction.Current.OnCommited(...)` (`src/Perpetuum/Data
339339
---
340340

341341
*Architecture analysis: 2026-05-11*
342+
343+
## Graph Artifact
344+
345+
A structural graph of this codebase is generated by graphify-dotnet on every `Perpetuum.Server`
346+
build (requires .NET 10 SDK and `dotnet tool restore`):
347+
348+
- `docs/graph/graph.json` — machine-readable nodes/edges (gitignored, regenerates on build)
349+
- `docs/graph/GRAPH_REPORT.md` — Markdown architecture report (gitignored, regenerates on build)
350+
- GitHub Wiki — latest report published by CI on each push to `develop`:
351+
`https://github.com/OpenPerpetuum/PerpetuumServer2/wiki/Codebase-Graph`
352+
353+
See `.claude/knowledge/codebase-graph.md` for how Claude uses these artifacts.

0 commit comments

Comments
 (0)