Skip to content

Graph PR-A: one-shot physics (settle then stop), spread-start layout, camera centering, layout metrics#62

Merged
mvalancy merged 2 commits into
developfrom
feat/graph-physics-camera-pr-a
Jun 14, 2026
Merged

Graph PR-A: one-shot physics (settle then stop), spread-start layout, camera centering, layout metrics#62
mvalancy merged 2 commits into
developfrom
feat/graph-physics-camera-pr-a

Conversation

@mvalancy

Copy link
Copy Markdown
Member

Fixes "garbage piles" + continuous drift, centers the camera, and adds deep layout metrics. Studied skeptically via the metrics — full investigation in the commit.

Root causes (found via the new metrics)

  • Continuous drift: the 2s data poll called simulation.alpha(0.1).restart() every cycle → the sim never rested.
  • Piles: the force equilibrium itself was overlapping — an inward centering force compressed dense graphs into a core that collision couldn't separate; and layout started from a pile at the origin.

Changes

  • One-shot physics: routine polls no longer reheat a placed/frozen graph; the sim settles to alphaMin and stays idle (no drift).
  • Spread-start: unplaced nodes / Organize start on a clean grid (spacing > collision diameter), so physics refines a non-overlapping layout instead of failing to explode a pile.
  • Force tuning (physicsConfig.ts): centering near-off (tiny containment), stronger/longer-range charge, collision strength 1 + 4 iterations, faster cool-down + damping → dense graphs settle to zero card overlaps and come fully to rest.
  • Camera centers on the graph on load and graph change (login, switch, drill-in) — was keyed on hasNodes only with one stale global transform.
  • Edge labels: forced de-overlap pass at settle + for pinned graphs (which don't tick).
  • Metrics window.__layoutMetrics() (atRest, alpha, TRUE rectangle-overlap pairs, proximity, label overlaps, settle time, drift) + window.__organizeGraph().

Verified (physics-settle.spec.ts)

90-node graph: overlap → 0, sim fully stops (~13s), idleAfterSettle: true. THE GATE 5/5 (grow flow unaffected), typecheck clean.

Known follow-up: ~20 edge-label overlaps remain on very dense graphs (best-effort avoidance). PR-B re-seeds demos clean (no organize needed); PR-C minimap zoom; PR-D explorer tree.

🤖 Generated with Claude Code

…ering, layout metrics (PR-A)

Graphs were "garbage piles" that drifted forever. Root causes (found via new
metrics): the 2s poll re-kicked the sim every cycle (perpetual drift), and the
force equilibrium itself was overlapping (an inward centering force compressed
dense graphs into a core collision couldn't separate).

- One-shot physics: the routine poll no longer reheats a placed/frozen graph;
  the sim settles to alphaMin and STAYS idle (no continuous drift).
- Spread-start: unplaced nodes / Organize start on a clean grid (spacing >
  collision diameter) so physics REFINES a non-overlapping layout instead of
  failing to explode a pile from the origin.
- Force tuning (physicsConfig): centering near-off (tiny containment only),
  stronger/longer-range charge, collision strength 1 + 4 iterations, faster
  cool-down + heavier damping → dense graphs settle to ZERO card overlaps and
  come fully to rest. Verified: a 90-node graph → 0 overlaps, sim stops ~13s.
- Camera centers on the graph on load AND graph change (was keyed on hasNodes
  only with one stale global transform) — covers login, graph switch, drill-in.
- Edge labels: a forced de-overlap pass runs at settle and for pinned graphs
  (which don't tick), so labels start de-overlapped.
- Metrics (window.__layoutMetrics): atRest, alpha, TRUE card-overlap pairs,
  proximity pairs, label overlaps, settle time, drift — for studying the
  behaviour skeptically. window.__organizeGraph triggers a reflow.
- New tests/diagnostics/physics-settle.spec.ts asserts: settles → 0 overlaps →
  fully stops, no drift.

THE GATE 5/5 (grow flow unaffected by the tuning); web typecheck clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🧪 Comprehensive Test Suite

  • Unit suites (Node 18.x & 20.x) — core, web, server, mcp-server: ❌ failure
  • Installer & deploy config: ✅ passed

Full-stack smoke gate runs in the CI workflow.

The defaults test pinned the old tuning (charge -60, velocityDecay 0.65,
collision 0.85); PR-A intentionally retuned for a one-shot non-overlapping
settle. Update the asserted values to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🧪 Comprehensive Test Suite

  • Unit suites (Node 18.x & 20.x) — core, web, server, mcp-server: ✅ passed
  • Installer & deploy config: ✅ passed

Full-stack smoke gate runs in the CI workflow.

@mvalancy mvalancy merged commit 63f3bb5 into develop Jun 14, 2026
16 checks passed
@mvalancy mvalancy deleted the feat/graph-physics-camera-pr-a branch June 14, 2026 19:03
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