libertaria-stack/capsule-core/src/tui
Markus Maiwald 0a86a93cf5
refactor: complete repository restructure with tiered licensing
BREAKING CHANGE: Repository restructured from flat layout to tiered:

FOLDER REORGANIZATION:
- core/          - L0-L3 layers (Commonwealth LCL-1.0)
  - l0-transport/   - Transport with MIMIC, Noise, PNG
  - l1-identity/    - Identity, QVL, Crypto
  - l2_session/     - Session management
  - l2-federation/  - Cross-chain bridging
  - l2-membrane/    - Policy enforcement
- sdk/           - L4+ and bindings (Sovereign LSL-1.0)
  - janus-sdk/
  - l4-feed/
- apps/          - Examples (Unbound LUL-1.0)
  - examples/
- legal/         - All license texts
  - LICENSE_COMMONWEALTH.md
  - LICENSE_SOVEREIGN.md
  - LICENSE_UNBOUND.md

IMPORT FIXES (All Layers):
- L0: 13 files fixed - all relative imports corrected
- L1: 14 files fixed - module imports for cross-layer dependencies
- L2: 6 files fixed - session, membrane, federation
- Capsule: 9 files fixed - TUI, node, main, control
- Examples: 2 files fixed - lwf, crypto

LICENSES ADDED:
- LCL-1.0: Viral reciprocity for Core (SaaS-proof)
- LSL-1.0: Business-friendly for SDK
- LUL-1.0: Maximum freedom for docs/apps

NO CLA REQUIRED - contributors keep copyright

README.md REWRITTEN:
- Documents new folder structure
- Explains tiered licensing strategy
- Clear SPDX identifiers per component

TODO:
- Fix remaining test module configuration issues
- Full green build in follow-up

Refs: 4 sub-agents parallel execution
2026-02-05 21:50:54 +01:00
..
README.md feat(capsule): stabilize TUI monitor, implement control IPC, and fix leaks (Zig 0.15.2) 2026-02-01 10:35:35 +01:00
app.zig refactor: complete repository restructure with tiered licensing 2026-02-05 21:50:54 +01:00
client.zig refactor: complete repository restructure with tiered licensing 2026-02-05 21:50:54 +01:00
view.zig feat(capsule): stabilize TUI monitor, implement control IPC, and fix leaks (Zig 0.15.2) 2026-02-01 10:35:35 +01:00

README.md

Capsule TUI & Control Protocol Documentation

Overview

The Capsule TUI Monitor (The "Luxury Deck") provides a real-time visualization of the node's internal state, network topology, and security events. It communicates with the Capsule daemon via a Unix Domain Socket using a custom JSON-based control protocol.

Architecture

1. Control Protocol (control.zig)

A unified command/response schema shared between the daemon and any management client.

  • Commands: Status, Peers, Sessions, Topology, SlashLog, Shutdown, Lockdown, Unlock.
  • Responses: Tagged unions containing specific telemetry data.

2. TUI Engine (tui/)

  • app.zig: Orchestrates the Vaxis event loop. Spawns a dedicated background thread for non-blocking I/O with the daemon.
  • client.zig: Implements the IPC client with mandatory deep-copying and explicit memory management to ensure a zero-leak footprint.
  • view.zig: Renders the stateful UI components:
    • Dashboard: Core node stats (ID, Version, State, Uptime).
    • Slash Log: Real-time list of network security interventions.
    • Trust Graph: Circular topology visualization using f64 polar coordinates mapped to terminal cells.

Memory Governance

In accordance with high-stakes SysOps standards:

  • Zero-Leak Polling: Every data refresh explicitly frees the previously "duped" strings and slices.
  • Thread Safety: AppState uses an internal Mutex to synchronize the rendering path with the background polling path.
  • Unmanaged Design: Alignment with Zig 0.15.2 architecture by using explicit allocators for all dynamic structures.

Usage

  1. Daemon: Start the node using ./zig-out/bin/capsule start.
  2. Monitor: Connect the monitor using ./zig-out/bin/capsule monitor.
  3. Navigation:
    • Tab: Cycle between Dashboard, Slash Log, and Trust Graph.
    • Ctrl+C or Q: Exit monitor.

Current Technical Debt

  • Implement uptime_seconds tracking in node.zig.
  • Implement dht_node_id extraction for IdentityInfo.
  • Add interactive node inspection in the Trust Graph view.