Skip to content

Unify CodeGraphy on the WebGPU renderer#308

Merged
joesobo merged 186 commits into
mainfrom
feat/unified-webgpu-renderer
Jul 16, 2026
Merged

Unify CodeGraphy on the WebGPU renderer#308
joesobo merged 186 commits into
mainfrom
feat/unified-webgpu-renderer

Conversation

@joesobo

@joesobo joesobo commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Goal

Make CodeGraphy's custom WebGPU and WebAssembly graph stack the single graph renderer while keeping product behavior and renderer control in the VS Code extension.

Package boundary

  • Added the focused, publishable @codegraphy-dev/graph-renderer package.
  • The package owns renderer-facing contracts, WebGPU drawing and geometry, the typed-array physics engine, and the AssemblyScript/WebAssembly physics kernel.
  • The extension still owns UI, settings, persistence, graph state, interaction routing, camera behavior, renderer lifecycle, fixed-timestep scheduling, and the FPS / ms toggle.
  • The renderer package has no extension, React, or runtime dependency. Its root export, declarations, generated WASM, README, license, and package metadata stay owned by the package.

Physically meaningful node size

  • Collision correction uses the opposite node's squared scaled radius, matching d3-force's collision weighting: small nodes move around large hubs instead of splitting every overlap equally.
  • Default charge multipliers scale with semantic node size relative to size 16 and clamp to 0.5–4. Explicit plugin-provided charge multipliers remain authoritative.
  • WebGPU node instances are packed in ascending drawn area so large nodes paint last without changing physics/layout indexes.
  • The size order is cached and rebuilt only when drawn sizes change.
  • Hovered nodes are submitted after every normal node and remain visually topmost.
  • Spatial picking uses the same size-first stacking rule when hit areas overlap.

Draw-order performance

The size-order indirection is effectively free on steady frames and only sorts after a size change. Local measurements found approximately 0.0011 ms / 0.0158 ms / 0.265 ms of steady packing overhead for 10k / 100k / 1M nodes, with one-time size-change sorts of 1.06 ms / 10.91 ms / 115.24 ms. No noticeable renderer slowdown was found at expected graph sizes.

Cleanup

  • Removed @codegraphy-dev/graph-benchmark, its commands, scenarios, generated reports, recordings, and reference media.
  • Removed stage-attribution, interaction-recording, and benchmark-only runtime instrumentation.
  • Kept the compact FPS · ms display with a bounded rolling average.
  • Removed d3-force and @types/d3-force from the workspace.
  • Removed stale extraction paths, duplicated WASM watch builds, obsolete renderer wording, and old renderer screenshots. All renderer-owned TypeScript, AssemblyScript, and generated WASM now live under packages/graph-renderer/src.
  • Cleared every repository CRAP advisory, including the pre-existing backlog, by splitting responsibilities without changing behavior. The organization gate is clean against its refreshed baseline.
  • Kept every production file changed by this PR below 50 Stryker mutation sites; renderer physics and WebGPU modules are grouped by stable behavior ownership.

Physics and renderer regression coverage

The renderer package owns deterministic tests for force primitives, radius-weighted collision movement, mixed-force trajectory hashes, TypeScript/WASM integration, 500-node graph behavior, charge-size mapping, cached instance ordering, hovered-node submission order, WASM loading/retry, device loss and cleanup, geometry, and renderer behavior. Extension tests cover plugin charge precedence and size-aware overlapping-node picking.

Validation

  • Monorepo build, typecheck, and lint: green locally
  • Extension unit tests: 5,756 / 5,756 across 981 files
  • Core unit tests: 1,158 / 1,158 across 251 files
  • Graph renderer tests: 173 / 173 across 30 files
  • Renderer coverage: 97.32% statements, 89.16% branches, 98.93% functions, 98.81% lines
  • Repository and renderer CRAP gates: every function at or below 8; all 65 pre-existing advisories cleared
  • Whole-PR mutation-site inventory remained below the 50-site threshold; this cleanup only moved or further split renderer modules.
  • Boundary/reachability gates: 2,006 files, 0 layer violations, dead surfaces, or dead ends
  • Scoped physics mutation diagnostic: 189 / 196 killed (96.43%), with seven equivalent/cosmetic boundary survivors
  • Scoped renderer mutation diagnostic: 60.29% overall; used to guide focused splits, with broader GPU/cache/frame-queue concerns documented for follow-up rather than churn
  • The cleanup/hardening phase did not edit the human-owned acceptance Gherkin; the PR includes the FPS counter feature spec added with that product behavior.

@changeset-bot

changeset-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6185a96

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@codegraphy-dev/extension Minor
@codegraphy-dev/graph-renderer Minor
@codegraphy-dev/plugin-api Major
@codegraphy-dev/core Major
@codegraphy-dev/plugin-unity Patch
@codegraphy-dev/plugin-godot Patch
@codegraphy-dev/plugin-markdown Patch
@codegraphy-dev/plugin-particles Patch
@codegraphy-dev/plugin-svelte Patch
@codegraphy-dev/plugin-typescript Patch
@codegraphy-dev/plugin-vue Patch
@codegraphy-dev/mcp Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@joesobo
joesobo marked this pull request as ready for review July 16, 2026 03:05
@joesobo
joesobo merged commit 3e6498b into main Jul 16, 2026
35 checks passed
@joesobo
joesobo deleted the feat/unified-webgpu-renderer branch July 16, 2026 03:14
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.

1 participant