Skip to content

Koro/lightbringer config integration & tui ux#229

Open
NeerajGodiyal wants to merge 17 commits intodevfrom
koro/lightbringer-config-integration
Open

Koro/lightbringer config integration & tui ux#229
NeerajGodiyal wants to merge 17 commits intodevfrom
koro/lightbringer-config-integration

Conversation

@NeerajGodiyal
Copy link
Copy Markdown
Collaborator

Lightbringer can now be managed directly from Mithril. Instead of running and configuring
Lightbringer separately, operators just add a [lightbringer] section to their config.toml and Mithril
handles the rest — starting the process, capturing logs, restarting on crash with backoff, and clean
shutdown when Mithril stops. On Linux, orphan prevention is handled via Pdeathsig.

Added an interactive dashboard (mithril dashboard) that gives a live view of the node — health
checks, service status, config viewer with inline editing, side-by-side mithril and lightbringer
logs, and disk usage. Config editing supports both menu selections for fixed options and text input
with validation for paths, ports, and addresses.

Also added a setup (mithril setup) for better ux that walks through config generation step by step, a doctor
command for health checks, and a shared theme package for consistent styling across all TUI
commands. All config writes use atomic temp-file-then-rename to prevent corruption.

…og viewing

Add [lightbringer] section to Mithril's config.toml so users can manage
both Mithril and Lightbringer from a single config file. When enabled,
Mithril automatically generates Lightbringer.toml, spawns the process,
captures logs, and shuts it down on exit.

Config integration:
- LightbringerConfig struct in pkg/config/config.go
- Auto-sync lightbringer.grpc_addr to block.lightbringer_endpoint
- Validation for all edge cases (no gossip, no RPC, conflicting endpoints)
- config.example.toml with full documentation

Subprocess management (pkg/lightbringer/):
- Spawn Lightbringer with Pdeathsig (Linux) for kernel-enforced cleanup
- LockOSThread per Go issue #27505 to prevent premature death signal
- Log capture with [lightbringer] prefix on stderr
- WaitReady health check via TCP dial with timeout
- Graceful SIGTERM -> SIGKILL shutdown escalation
- RPC fallback if Lightbringer fails to start or isn't ready
- Atomic config file write with 0600 permissions

TUI extension:
- Mithril Logs and Lightbringer Logs tabs via bubbles/viewport
- Tab cycles through metrics views and log views
- Reads from per-run log directory via --log-dir flag

Signal handling:
- Added SIGTERM to main.go signal.NotifyContext for graceful kill response
- Startup banner shows "managed sidecar" or "external" mode
Interactive setup wizard (mithril setup):
- Quick Start: 3-4 questions with sensible defaults
- Full Config: all settings with descriptions and validation
- Manual: generates template for manual editing
- Custom Bubbletea TUI with Mithril teal theme
- Back navigation (Esc) on every screen
- Input validation with inline error messages
- Disk auto-detection on Linux
- RPC endpoint pre-filled per cluster selection

Health check (mithril doctor):
- Validates config file, cluster, RPC, storage, lightbringer binary,
  gossip entrypoint, gRPC port, and log directory
- Config migration (--migrate) adds missing [lightbringer] and
  [consensus] sections independently

Node status (mithril status):
- Shows state file info (last slot, bankhash, shutdown reason)
- Probes Mithril RPC, Lightbringer gRPC, and HTTP ports

Interactive config editor (mithril config edit):
- Section-based editing with looping menu
- Back option on every section
- Reads current values, writes back preserving TOML structure

Lightbringer auto-restart:
- MonitorAndRestart with exponential backoff (2s → 60s cap)
- Stopping flag prevents false restart after deliberate Stop
- Returns on Start failure (prevents stale channel spin)

Signal handling:
- Added SIGTERM to main.go signal.NotifyContext

Security:
- Config dir created with 0700 (was 0755)
- All generated configs written 0600
- TOML injection prevented (newline stripping, %q, Atoi validation)
- Rename storage.blockstore → storage.shredstore
- Move replay.txpar → tuning.txpar
- Remove lightbringer.storage (use storage.shredstore)
- Add backwards-compatible fallbacks with deprecation warnings
- Quick Start skips Lightbringer (disabled by default)
- Lightbringer defaults to Disable in Full Config menu
- Add Mithril ASCII art logo on setup welcome screen
- Remove CPU cores display and direct mode reference
- Update config.example.toml descriptions (sidecar, not edge node)
- Add mutex to Pid() to prevent data race on m.cmd
- Reset stopping flag in Start() so manager is reusable after Stop()
- Change config init/set file permissions from 0644 to 0600 (security)
- Fix TOML injection in formatTOMLValue: use %q instead of raw %s
- Fix lightbringerStorage to respect --ledger-path CLI flag (getString)
- Replace misleading UDP gossip "reachable" check with format validation
- Fix [replay] → [tuning] in config init template (missed in prior commit)
- Add storage.logs to config init template for consistency
- Replace real IP placeholder with RFC 5737 documentation IP
- Remove duplicate comment in components.go
…anner

- Rebuild config edit using raw Bubbletea (replaces huh library)
  Same teal theme, cursor navigation, ESC back as setup wizard
- Add persistent ASCII logo banner on all TUI screens
  Full logo on setup welcome, same logo on all other screens
- Fix status.go color inconsistencies (teal 86→85, success 42→85, dim 241→#6c6c6c)
- Add renderBanner() compact variant to components.go
- New `mithril dashboard` command with split-view TUI
- Overview with health checks, services, node state, next steps
- Full config view (two-column auto-layout, reads raw TOML)
- Inline config editing with menu selections and text input
- Doctor, Logs, Disk views with live data refresh
- Embedded setup (Create Config) in dashboard right pane
- Shared theme package (pkg/tui) for consistent styling
- AtomicWriteFile helper for crash-safe config writes
- Fix: mithril-tui log reading (64KB tail, symlink validation)
- Fix: setup wizard overwrite confirmation instead of silent fail
- Fix: 'q' key doesn't quit during text editing
- Fix: parallel service probing (6s -> 2s)
- Fix: proper child TUI quit interception via message type
LOG* pattern in .gitignore was matching logo.go on case-insensitive
filesystems. Changed to explicit LOG and LOG.* patterns.
- Replace magic logPane 0/1 with logPaneMithril/logPaneLightbringer
- Extract configFileName constant for Lightbringer.toml
- Add defaultRPCPort/defaultLBGRPC/defaultLBHTTP constants
- Make ColorSuccess/ColorBorderActive explicitly reference MithrilTeal
- Remove internal project references from comments
@NeerajGodiyal NeerajGodiyal requested a review from rupansh April 10, 2026 11:29
@NeerajGodiyal NeerajGodiyal requested a review from smcio April 10, 2026 14:07
- Resolve relative binary_path to absolute before subprocess exec
- Preserve RPC failover endpoints when saving from editor and dashboard
- Sync block.source and lightbringer.enabled with external mode awareness
- Fix txpar display to match runtime semantics (sequential when unset)
- Only probe Lightbringer services when block delivery uses Lightbringer
- Validate Lightbringer config against runtime mode rules in doctor
- Handle config parse errors in status and doctor commands
- Skip RPC probe when port is disabled (rpc.port=0)
@NeerajGodiyal NeerajGodiyal force-pushed the koro/lightbringer-config-integration branch from 6b6adaa to 960d0f1 Compare April 10, 2026 18:16
@NeerajGodiyal NeerajGodiyal changed the title Koro/lightbringer config integration [wip] Koro/lightbringer config integration & tui ux Apr 11, 2026
@rupansh
Copy link
Copy Markdown
Collaborator

rupansh commented Apr 11, 2026

LGTM

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.

2 participants