Docs navigation

Guides / design / dashboard-v2 · Edit on GitHub

Universe Dashboard v2 & HTTP Server — Engineering Design

This document specifies the Universe Dashboard v2, Static Artifact Bundle (rgctl-dashboard), and Local HTTP Query Server (rgctl serve) in rgctl (crates/rgctl-dashboard/, dashboard/, and src/cli/http_serve.rs). It details the end-to-end data flow from rgctl discover --with-universe to the React 19 + WASM + Three.js / Sigma.js browser client, the ambient StableNodeKey Focus mechanism, the 7-Room + 6-Lens information architecture, and the /api/query, /api/cpg, and /api/semantic HTTP endpoints.


1. System Overview & End-to-End Data Flow

┌──────────────────────────────────────────────────────────────────────────────┐
│ 1. BUNDLE GENERATION (`rgctl discover . --with-universe`)                    │
│                                                                              │
│  `crates/rgctl-dashboard` writes `.rgctl/dashboard/`:                        │
│    ├─► `manifest.json` (`graph_digest`, coverage flags, mode = `"universe"`) │
│    ├─► `graph_payload.bin` (compact binary topology for browser WASM engine) │
│    ├─► `metagraph.json` & `communities.json` (L0 namespaces, L1 packages,    │
│    │     Fast-Leiden labels, coupling web)                                   │
│    ├─► `migration_graph.json` (v3) & `migration_plan.json` (v2)              │
│    ├─► `function_metrics.json` (or `sparse_mode: "community_only"` >= 50k)   │
│    └─► Optional sidecars: `cfg_index.json`, `slice_index.json`,              │
│        `taint_index.json`, `blast_index.json`, `.rgctl/workflows/review.json`│
└───────────────────────────────────────┬──────────────────────────────────────┘
                                        │
                                        ▼
┌──────────────────────────────────────────────────────────────────────────────┐
│ 2. LOCAL HTTP SERVER (`rgctl serve [--open] [--watch]`, `http_serve.rs`)     │
│                                                                              │
│  • Serves static `.rgctl/dashboard/` + embedded `dashboard/dist` assets      │
│  • `POST /api/query` (`/graphql`) → Structured & GQL graph queries           │
│  • `POST /api/cpg`                → Hybrid CPG (`status`, `mutations`, etc.) │
│  • `GET  /api/semantic/status` & `POST /api/semantic/query`                  │
│  • Optional `--watch`: 25ms debounced `notify` watcher → `IncrementalUpdater`│
└───────────────────────────────────────┬──────────────────────────────────────┘
                                        │
                                        ▼
┌──────────────────────────────────────────────────────────────────────────────┐
│ 3. BROWSER CLIENT (`dashboard/src/v2/`, React 19 + Web Worker WASM)          │
│                                                                              │
│  • Persistent Instrument Bar: Coverage · Digest · `⌘K` Omnibox · Focus Bar   │
│  • Portable URL Focus (`?focus=<path\x1fname>&room=<room>&lens=<lens>`)      │
│  • Orientation: `Repo` ("Where do I start?")                                 │
│  • 7 Rooms: `Architecture` (landing) · `Review` · `Taint` · `Migration` ·    │
│             `Understand` · `Agent` · `Proof`                                 │
│  • 6 Lenses: `CFG` · `Dataflow` · `Slice/Trace` · `Blast` · `Metrics` · `Time`│
└──────────────────────────────────────────────────────────────────────────────┘

2. Theoretical Foundations Mapped to rgctl

ConceptTheoretical OriginHow rgctl Applies It in Rust & TypeScript
Hierarchical Software Landscape Metaphor (L0/L1/L2 Universe)Knight & Munro (2000), Virtual But Visible Software; Wettel & Lanza (2007), Visualizing Software Systems as CitiesInstead of dumping 100,000 raw nodes onto a 2D hairball canvas, the Architecture room renders a 3-tier spatial hierarchy in imperative three.js: L0 namespace volumes, L1 package districts (metagraph.json), and L2 coupling arcs, drilling down to symbol-level lenses only on selection.
Location-Independent Ambient Focus StatePortable entity addressing across views (StableNodeKey)dashboard/src/v2/focus.ts encodes the active symbol selection as a stable (path, name, type) key in the URL search parameters (?focus=...&room=...&lens=...) rather than a volatile array index, surviving re-indexing across commits.
Digest-Keyed Immutable Client CachingContent-addressable state invalidation (@tanstack/react-query)Every query key in the browser client is prefixed with manifest.graph_digest and configured with staleTime: Infinity. Bundle artifacts are never refetched while the snapshot digest is unchanged, and automatically invalidate the instant rgctl serve --watch publishes a new digest.

3. Binary Layout, Data Structures & Memory Discipline

3.1 .rgctl/dashboard/ Artifact Manifest (manifest.json)

Generated by crates/rgctl-dashboard/src/manifest.rs:

Field / FilePurpose & Scale Guardrail
manifest.jsonRecords graph_digest, node/edge counts, mode: "universe", and boolean capability flags (cfg_available, taint_available, migration_available, semantic_available).
graph_payload.binCompact binary node/edge topology loaded into the browser Web Worker (wasm-bindgen) for sub-millisecond client-side BFS, blast-radius, and neighborhood queries.
metagraph.json & communities.jsonPackage-level macro nodes, inter-package call weights, and Fast-Leiden community labels (member_indices omitted above 50k nodes to bound JSON size).
function_metrics.jsonPer-function PageRank, betweenness, harmonic, and blast scores; switches to sparse_mode: "community_only" when $V \ge 50,000$.
cfg_index.jsonPer-function CFG/PDG index; switches to detail_mode: "archive_only" on large repositories so per-function records are fetched lazily on demand.

3.2 Seven Core UI Engineering Rules

  1. Answer First, Graph Second: Every room opens on a ranked conclusion and its evidence table; the graph canvas is an inspection lens, never an unlabeled landing hairball.
  2. Every Number Carries a Receipt: Every score, count, or verdict exposes its exact inputs and the reproducible rgctl CLI command.
  3. Lenses, Not Tabs: CFG, Dataflow, Slice/Trace, Blast, Metrics, and Time inspect the current Focus subject without resetting room context.
  4. One Focus, Many Views: Selecting a symbol in Review carries into Taint, Architecture, and Understand via the URL search parameters.
  5. Explicit Scope Boundaries: When an analysis is intra-procedural or when --with-cfg / --with-taint was not run during discover, the UI states the exact boundary and the CLI command to enable it.
  6. Zero Cloud / Zero Telemetry: All rendering, WASM graph traversal, and queries run 100% locally against 127.0.0.1.
  7. Imperative Three.js Lifecycle: 3D scenes in Architecture mount imperatively with explicit WebGL geometry/material/renderer disposal on unmount and requestAnimationFrame demand rendering (needsRender dirty flag).

3.3 Ask mode (⌘K)

Semantic search is a mode of the command palette, not an eighth room and not a lens. It answers the question "what should I look at for this phrase?" and then hands the chosen function to the existing Focus/lens system.

  • Retrieval, not a prose model: POST /api/semantic/query returns ranked function hits plus expansion.blast (direct callers / impact zone). The answer card is assembled deterministically from those fields; the UI labels it as evidence-backed, not as an LLM answer.
  • Focus handoff: a hit's node_id is the function UUID, so selecting it writes ?focus=<uuid> and opens Understand. Hits without a local function row are marked evidence only rather than navigating to an unresolvable Focus.
  • Scope boundary: /api/semantic/status is authoritative. Missing index, a static host, or a digest that differs from manifest.graph.digest is stated with the command that fixes it (rgctl semantic index / rgctl serve).
  • Complete function index: lightweight --with-universe bundles have no cfg_index.json / slice_index.json; they carry function_index.json so semantic hits can resolve into Focus without a full CFG build.
  • No per-keystroke load: the server caches SemanticIndex and AnalysisResults; the UI runs a query on submit, using expand: "blast" rather than the slower all expansion because the answer only needs caller/impact evidence.

3.4 Understand lenses

Understand implements three lenses against the current Focus:

  • CFG — source + control-flow graph via SymbolReader.
  • PDG / Dataflow — def-use edges via the shared DfgGraph, loaded through useDfgDetail (per-file or record-pack).
  • Blast — upstream caller shells via the shared BlastStage and the lazy WASM engine.

The Taint room and Understand share CfgGraph, DfgGraph, and BlastStage; only the surrounding room and test identity differ. Slice/Trace, Metrics, and Time remain explicit absences until their views land.


4. CLI Contract, JSON Schema & Implementation Map

4.1 CLI Commands & HTTP Endpoints

Verified against rgctl discover --help and rgctl serve --help (src/cli/mod.rs):

# 1. Discover and export the Universe Dashboard bundle (.rgctl/dashboard/)
rgctl discover . --with-universe

# 2. Full discovery (CFG/PDG, taint, harmonic centrality, and Universe Dashboard)
rgctl discover . --full

# 3. Serve the dashboard and HTTP query API locally (opens browser at http://127.0.0.1:8080)
rgctl serve --open

# 4. Serve with live file-watching incremental updates (25ms debounce)
rgctl serve --open --watch

# 5. Serve only the HTTP query APIs (no static dashboard UI required)
rgctl serve --query-only --host 127.0.0.1 --port 8080

Local HTTP Endpoints (src/cli/http_serve.rs)

EndpointMethodPurpose
/GETServes the Universe Dashboard SPA (.rgctl/dashboard/ + embedded bundle).
/api/query (alias /graphql)POSTExecutes structured queries or GQL queries against the live snapshot.
/api/cpgPOSTExecutes Hybrid CPG operations (status, function, calls, mutations, flows, pdg, slice).
/api/semantic/statusGETReports .rgctl/semantic_index.bin readiness, model ID, and row count.
/api/semantic/queryPOSTRuns two-stage Hamming + late-fusion semantic search.

4.2 Implementation Map

ComponentSource FileKey Types & Functions
Rust Dashboard Bundle Exportercrates/rgctl-dashboard/src/lib.rs, manifest.rs, metagraph.rsexport_dashboard_bundle, DashboardManifest, build_metagraph
HTTP Server & Live Watchersrc/cli/http_serve.rs, src/cli/file_watch.rsserve, handle_api_query, handle_api_cpg
Dashboard v2 Shell & Focusdashboard/src/v2/focus.ts, DEFAULT_ROOM, ArchitectureRoom, ReviewRoom
Ask mode (semantic retrieval)dashboard/src/v2/Palette.tsx, dashboard/src/v2/ask.tsaskSemantic, answerFor, Focus handoff via pickKey
Understand lensesdashboard/src/v2/App.tsx, rooms/Cfg.tsx, rooms/DfgGraph.tsx, rooms/BlastStage.tsxCfg, DataflowLens, BlastLens; shared with Taint
Complete function indexcrates/rgctl-dashboard/src/function_index_export.rsFUNCTION_INDEX_FILE, export_function_index
Legacy & Lens Viewsdashboard/src/App.tsx, BlastView.tsx, CfgView.tsx, DataflowView.tsx, SliceView.tsx, TaintView.tsx, MigrationView.tsx, SearchView.tsx

5. Performance Guardrails & Verification Checklist

5.0 Browser loading model (v2)

  • View-scoped function index: Architecture can render without cfg_index.json / slice_index.json. useFocus enables the function query only for Repo/Understand/Review, a URL Focus, or an open ⌘K palette. The key includes manifest.graph.digest once the manifest resolves.
  • Lazy rooms: Architecture, Migration, and Taint are React.lazy chunks with a shell-level Suspense fallback. A direct /understand link does not parse the Architecture room or its Three.js scene.
  • Shared worker: expandEngine owns one module-level worker for Architecture member expansion and blast queries. Blast lenses no longer create per-mount Workers, so graph_payload.bin is downloaded and parsed once.
  • Detail caches: CFG detail promises and DFG detail promises are cached by function id (DFG also by detail directory and graph digest); in-flight requests are deduplicated.
  • Worker-side detail parsing: CFG archive records are decoded with parseCfgDetail inside the shared worker; PDG record-pack JSON is decoded and parsed there too. The main thread receives plain objects, and the worker caches parsed details by function id.
  • Bounded UI work: Focus resolution uses a Map, palette filtering uses useDeferredValue, and Migration plan/layout recomputation is debounced by 200 ms.
  • Compressed static JSON: serve applies gzip content encoding when the client advertises support.
  • Function data over the API: the shell asks GET /api/functions for a 500-row directory and for palette search; it resolves an out-of-directory Focus by UUID through the same endpoint. The 67 MB cfg_index.json / slice_index.json pair is not a startup dependency.
  • Header-only analysis metadata: cfg_meta.json and slice_meta.json carry detail_mode and record-pack paths, so selecting CFG/PDG does not fetch the full 67 MB indexes. cfg_meta.json is ~219 bytes and slice_meta.json ~178 bytes on metasfresh.
  1. Serve Never Auto-Runs Full Discover: rgctl serve is strictly a fast read/query server over .rgctl/ (plus optional incremental --watch). It never blocks startup with an implicit whole-repo discover.
  2. In-Memory DashboardExportContext Reuse: When rgctl discover --with-universe runs, export_dashboard_bundle consumes the in-memory AnalysisResults and CodeGraph directly via DashboardExportContext without reloading snapshots per export stage.

Verification Commands

# Build frontend assets and verify Rust dashboard bundle integration tests
./scripts/build-dashboard.sh
cargo test -p rgctl-dashboard
cargo test --test dashboard_harness

# Run frontend unit tests
cd dashboard && npm run test:unit

6. Known Limitations & By-Design Boundaries

  1. Focus Keys Across Symbol Renames: A URL Focus key (path\x1fname) survives re-indexing when line numbers or node indices shift, but if a function is renamed, old URL links render an explicit "Focus does not resolve against this bundle" banner rather than guessing.
  2. Static File Hosting vs. rgctl serve: While static bundle JSON files (metagraph.json, migration_graph.json) can be inspected offline, interactive /api/query, /api/cpg, and /api/semantic/query endpoints require running rgctl serve.