summaryrefslogtreecommitdiff
path: root/internal/tui
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-12 23:16:46 +0300
committerPaul Buetow <paul@buetow.org>2026-05-12 23:16:46 +0300
commit119c679dd16d6a3c89b9d37665c44815956b6f82 (patch)
treecdff21d863f689b7fb0b350d448021fd3a2481be /internal/tui
parent0a342e08ebcc475524582260ab05841adf111596 (diff)
add compile-time interface satisfaction assertions for public types
Add var _ Interface = (*ConcreteType)(nil) assertions for: - *flamegraph.LiveTrie → runtime.{Snapshotter,Configurator,LiveTrieSource} and tui/flamegraph.{Snapshotter,Configurator,LiveTrieSource} - *probemanager.Manager → runtime.ProbeManager - *statsengine.Engine → runtime.SnapshotSource - *streamrow.RingBuffer → runtime.EventSink - *runtimeBindings (tui) → runtime.TraceRuntimeBindings - *lateBoundDashboardSource → dashboard.SnapshotSource - libbpfTracepointProgram/Module → probemanager.{Program,Attacher} Assertions are grouped close to their interface definitions to avoid introducing new import cycles (runtime already imports all affected packages; tui/flamegraph already imports coreflamegraph). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/tui')
-rw-r--r--internal/tui/flamegraph/model.go13
-rw-r--r--internal/tui/tui.go17
2 files changed, 30 insertions, 0 deletions
diff --git a/internal/tui/flamegraph/model.go b/internal/tui/flamegraph/model.go
index 68ce7fd..73285f9 100644
--- a/internal/tui/flamegraph/model.go
+++ b/internal/tui/flamegraph/model.go
@@ -113,6 +113,19 @@ type LiveTrieSource interface {
Configurator
}
+// --- compile-time interface satisfaction assertions ---
+//
+// *coreflamegraph.LiveTrie is the sole production implementation of all three
+// trie interfaces. The assertions are placed here rather than in the
+// flamegraph package itself to avoid an import cycle: runtime imports
+// flamegraph, so flamegraph cannot import runtime. The tui/flamegraph package
+// already imports coreflamegraph, making it the natural home.
+var (
+ _ Snapshotter = (*coreflamegraph.LiveTrie)(nil)
+ _ Configurator = (*coreflamegraph.LiveTrie)(nil)
+ _ LiveTrieSource = (*coreflamegraph.LiveTrie)(nil)
+)
+
type zoomState struct {
path string
previousSelectedIdx int
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index 6124fcd..eee4252 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -1247,6 +1247,23 @@ func placeToViewport(width, height int, content string) string {
return lipgloss.Place(width, height, lipgloss.Left, lipgloss.Top, content)
}
+// --- compile-time interface satisfaction assertions ---
+//
+// These blank-identifier assignments cause a build error if any concrete type
+// drifts out of sync with the interface it claims to satisfy.
+
+var (
+ // *runtimeBindings must satisfy the full TUI runtime contract, which
+ // composes RuntimePublisher (write side) and RuntimeState (read side).
+ _ runtime.TraceRuntimeBindings = (*runtimeBindings)(nil)
+
+ // lateBoundDashboardSource must satisfy the SnapshotSource contract used
+ // by the dashboard model. It wraps the injected stats engine and forwards
+ // calls through runtimeBindings so the dashboard source can be wired
+ // before the actual engine is available.
+ _ dashboardui.SnapshotSource = (*lateBoundDashboardSource)(nil)
+)
+
func altScreenView(content, title string) tea.View {
view := tea.NewView(content)
view.AltScreen = true