Skip to main content

proof_stream/
blueprint.rs

1//! Blueprint sender for the proof-stream visualization.
2//!
3//! Builds a declarative Rerun 0.29 blueprint with a 3-panel layout:
4//!
5//! ```text
6//! ┌──────────────────────────┬───────────────────────────┐
7//! │                          │  GKR Claim Descent        │
8//! │  ZK Proof Walk (3D)      │  gkr/claim                │
9//! │  circuit/** gkr/walk/**  │  gkr/walk/**/claim        │
10//! │  gpu/cluster             │  proof/progress           │
11//! │                          ├───────────────────────────┤
12//! │                          │  Layer Stats & GPU        │
13//! │                          │  inference/stats/**       │
14//! │                          │  gpu/device_*/**          │
15//! │                          │  proof/binding_ms         │
16//! └──────────────────────────┴───────────────────────────┘
17//! ```
18//!
19//! The blueprint is sent once at connection time before any proof events.
20
21/// Send a structured blueprint to the Rerun viewer.
22///
23/// Creates a 2-column layout: the 3D GKR walk takes the left 60%, and two
24/// stacked time-series charts (claim descent + layer stats) fill the right 40%.
25/// Auto-layout and auto-views are disabled so Rerun doesn't create extra panels.
26#[cfg(feature = "rerun")]
27pub fn send_blueprint(rec: &rerun::RecordingStream) {
28    use rerun::blueprint::{
29        Blueprint, BlueprintActivation, ContainerLike, Horizontal, Spatial3DView, TimeSeriesView,
30        Vertical,
31    };
32
33    // ── Right column: two stacked time-series charts ──────────────────────────
34
35    // Top-right: GKR claim descending output→input as layers are proved
36    let claim_chart: ContainerLike = TimeSeriesView::new("GKR Claim Descent")
37        .with_origin("/")
38        .with_contents([
39            "gkr/claim",
40            "gkr/walk/**/claim",
41            "proof/progress",
42        ])
43        .into();
44
45    // Bottom-right: per-layer stats, GPU utilisation, binding overhead
46    let stats_chart: ContainerLike = TimeSeriesView::new("Layer Stats & GPU")
47        .with_origin("/")
48        .with_contents([
49            "inference/stats/**",
50            "gpu/device_*/**",
51            "proof/binding_ms",
52        ])
53        .into();
54
55    let right_col: ContainerLike = Vertical::new([claim_chart, stats_chart])
56        .with_row_shares(vec![1.0_f32, 1.0_f32])
57        .into();
58
59    // ── Left: 3D GKR walk + circuit DAG + GPU cluster ────────────────────────
60
61    let walk_3d: ContainerLike = Spatial3DView::new("ZK Proof Walk")
62        .with_origin("/")
63        .with_contents([
64            "circuit/**",          // pre-layout nodes, backbone rail, DAG edges
65            "gkr/walk/**",         // per-layer nodes, cursor, progress trail
66            "gpu/cluster",         // GPU devices (when CUDA enabled)
67        ])
68        .into();
69
70    // ── Root: horizontal split 60/40 ─────────────────────────────────────────
71
72    let root = Horizontal::new([walk_3d, right_col])
73        .with_column_shares(vec![3.0_f32, 2.0_f32]);
74
75    let blueprint = Blueprint::new(root)
76        .with_auto_layout(false)
77        .with_auto_views(false);
78
79    let _ = blueprint.send(
80        rec,
81        BlueprintActivation {
82            make_active: true,
83            make_default: false,
84        },
85    );
86
87    // Emit a welcome TextDocument at the entity root so the user sees it in
88    // the entity tree before any proof events arrive.
89    let _ = rec.log_static(
90        "logs/proof",
91        &rerun::TextLog::new(
92            "ZK Proof Stream ready — waiting for proof events.\n\
93             \n\
94             Entity layout:\n\
95             • circuit/**          — 3D circuit DAG (color = layer kind)\n\
96             • gkr/walk/**         — GKR layer nodes (green when proved)\n\
97             • gkr/claim           — claim descending output→input\n\
98             • gkr/walk/**/poly    — round polynomial [c0, c1, c2]\n\
99             • inference/stats/**  — per-layer activation mean/std\n\
100             • gpu/cluster         — GPU devices (color = utilisation)\n\
101             • proof/progress      — overall proof progress 0→1",
102        ),
103    );
104}
105
106/// No-op stub when the `rerun` feature is disabled.
107#[cfg(not(feature = "rerun"))]
108pub fn send_blueprint(_rec: &()) {}