fetch_ml/cmd/tui
Jeremie Fraeys 7efe8bbfbf
native: security hardening, research trustworthiness, and CVE mitigations
Security Fixes:
- CVE-2024-45339: Add O_EXCL flag to temp file creation in storage_write_entries()
  Prevents symlink attacks on predictable .tmp file paths
- CVE-2025-47290: Use openat_nofollow() in storage_open()
  Closes TOCTOU race condition via path_sanitizer infrastructure
- CVE-2025-0838: Add MAX_BATCH_SIZE=10000 to add_tasks()
  Prevents integer overflow in batch operations

Research Trustworthiness (dataset_hash):
- Deterministic file ordering: std::sort after collect_files()
- Recursive directory traversal: depth-limited with cycle detection
- Documented exclusions: hidden files and special files noted in API

Bug Fixes:
- R1: storage_init path validation for non-existent directories
- R2: safe_strncpy return value check before strcat
- R3: parallel_hash 256-file cap replaced with std::vector
- R4: wire qi_compact_index/qi_rebuild_index stubs
- R5: CompletionLatch race condition fix (hold mutex during decrement)
- R6: ARMv8 SHA256 transform fix (save abcd_pre before vsha256hq_u32)
- R7: fuzz_index_storage header format fix
- R8: enforce null termination in add_tasks/update_tasks
- R9: use 64 bytes (not 65) in combined hash to exclude null terminator
- R10: status field persistence in save()

New Tests:
- test_recursive_dataset.cpp: Verify deterministic recursive hashing
- test_storage_symlink_resistance.cpp: Verify CVE-2024-45339 fix
- test_queue_index_batch_limit.cpp: Verify CVE-2025-0838 fix
- test_sha256_arm_kat.cpp: ARMv8 known-answer tests
- test_storage_init_new_dir.cpp: F1 verification
- test_parallel_hash_large_dir.cpp: F3 verification
- test_queue_index_compact.cpp: F4 verification

All 8 native tests passing. Library ready for research lab deployment.
2026-02-21 13:33:45 -05:00
..
internal native: security hardening, research trustworthiness, and CVE mitigations 2026-02-21 13:33:45 -05:00
main.go feat: update CLI, TUI, and security documentation 2026-02-19 15:35:05 -05:00
README.md feat: implement Go backend with comprehensive API and internal packages 2025-12-04 16:53:53 -05:00

FetchML TUI - Terminal User Interface

An interactive terminal dashboard for managing ML experiments, monitoring system resources, and controlling job execution.

Features

📊 Real-time Monitoring

  • Job Status - Track pending, running, finished, and failed jobs
  • GPU Metrics - Monitor GPU utilization, memory, and temperature
  • Container Status - View running Podman/Docker containers
  • Task Queue - See queued tasks with priorities and status

🎮 Interactive Controls

  • Queue Jobs - Submit jobs with custom arguments and priorities
  • View Logs - Real-time log viewing for running jobs
  • Cancel Tasks - Stop running tasks
  • Delete Jobs - Remove pending jobs
  • Mark Failed - Manually mark stuck jobs as failed

⚙️ Settings Management

  • API Key Configuration - Set and update API keys on the fly
  • In-memory Storage - Settings persist for the session

🎨 Modern UI

  • Clean Design - Dark-mode friendly with adaptive colors
  • Responsive Layout - Adjusts to terminal size
  • Context-aware Help - Shows relevant shortcuts for each view
  • Mouse Support - Optional mouse navigation

Quick Start

Running the TUI

# Using make (recommended)
make tui-dev          # Dev mode (remote server)
make tui              # Local mode

# Direct execution with CLI config (TOML)
./bin/tui --config ~/.ml/config.toml

# With custom TOML config
./bin/tui --config path/to/config.toml

First Time Setup

  1. Build the binary

    make build
    
  2. Get your API key

    ./bin/user_manager --config configs/config_dev.yaml --cmd generate-key --username your_name
    
  3. Launch the TUI

    make tui-dev
    

Keyboard Shortcuts

Navigation

Key Action
1 Switch to Job List view
g Switch to GPU Status view
l View logs for selected job
v Switch to Task Queue view
o Switch to Container Status view
s Open Settings
h or ? Toggle help screen

Job Management

Key Action
t Queue selected job (default args)
a Queue job with custom arguments
c Cancel running task
d Delete pending job
f Mark running job as failed

System

Key Action
r Refresh all data
G Refresh GPU status only
q or Ctrl+C Quit

Settings View

Key Action
/ or j/k Navigate options
Enter Select/Save
Esc Exit settings

Views

Job List (Default)

  • Shows all jobs across all statuses
  • Filter with / key
  • Navigate with arrow keys or j/k
  • Select and press l to view logs

GPU Status

  • Real-time GPU metrics (nvidia-smi)
  • macOS GPU info (system_profiler)
  • Utilization, memory, temperature

Container Status

  • Running Podman/Docker containers
  • Container health and status
  • System info (Podman/Docker version)

Task Queue

  • All queued tasks with priorities
  • Task status and creation time
  • Running duration for active tasks

Logs

  • Last 200 lines of job output
  • Auto-scroll to bottom
  • Refreshes with job status

Settings

  • View current API key status
  • Update API key
  • Save configuration (in-memory)

Terminal Compatibility

The TUI is built with Bubble Tea and works on all modern terminals:

Fully Supported

  • WezTerm (recommended)
  • Alacritty
  • Kitty
  • iTerm2 (macOS)
  • Terminal.app (macOS)
  • Windows Terminal
  • GNOME Terminal
  • Konsole

Multiplexers

  • tmux
  • screen

Features

  • 256 colors
  • True color (24-bit)
  • Mouse support
  • Alt screen buffer
  • Adaptive colors (light/dark themes)

Key Components

  • Model - Pure data structures (State, Job, Task)
  • View - Rendering functions (no business logic)
  • Controller - Message handling and state updates
  • Services - SSH/Redis communication

Configuration

The TUI uses TOML configuration format for CLI settings:

# ~/.ml/config.toml
worker_host = "localhost"
worker_user = "your_user"
worker_base = "~/ml_jobs"
worker_port = 22
api_key = "your_api_key_here"

For CLI usage, run ml init to create a default configuration file.

See Configuration Documentation for details.

Troubleshooting

TUI doesn't start

# Check if binary exists
ls -la bin/tui

# Rebuild if needed
make build

# Check CLI config
cat ~/.ml/config.toml

Authentication errors

# Verify CLI config exists
ls -la ~/.ml/config.toml

# Initialize CLI config if needed
ml init

# Test connection
./bin/tui --config ~/.ml/config.toml

Display issues

# Check terminal type
echo $TERM

# Should be xterm-256color or similar
# If not, set it:
export TERM=xterm-256color

Connection issues

# Test SSH connection
ssh your_user@your_server

# Test Redis connection
redis-cli ping

Development

Building

# Build TUI only
go build -o bin/tui ./cmd/tui

# Build all binaries
make build

Testing

# Run with verbose logging
./bin/tui --config ~/.ml/config.toml 2>tui.log

# Check logs
tail -f tui.log

Code Organization

  • Keep files under 300 lines
  • Separate concerns (MVC pattern)
  • Use descriptive function names
  • Add comments for complex logic

Tips & Tricks

Efficient Workflow

  1. Keep TUI open in one terminal
  2. Edit code in another terminal
  3. Use r to refresh after changes
  4. Use h to quickly reference shortcuts

Custom Arguments

When queuing jobs with a:

--epochs 100 --lr 0.001 --priority 5

Monitoring

  • Use G for quick GPU refresh (faster than r)
  • Check queue with v before queuing new jobs
  • Use l to debug failed jobs

Settings

  • Update API key without restarting
  • Changes are in-memory only
  • Restart TUI to reset

See Also