9.4 KiB
9.4 KiB
Comprehensive Implementation Gap Analysis: Sovereign Browser (Rust vs. C)
This document provides a detailed breakdown of all components, subsystems, internal pages, and features comparing the original C implementation (/home/user/lt/sovereign_browser) to the current Rust implementation (/home/user/lt/sovereign_browser_rust).
1. Executive Summary & Parity Matrix
| Subsystem / Feature | C Implementation Status | Rust Implementation Status | Parity % | Priority |
|---|---|---|---|---|
| Core GTK & Multi-Tab Window | Complete (tabs, toolbars, shortcuts, theme, context menus) | Complete (tabs, per-tab toolbars, theme, webview & tab context menus) | 95% | Low |
NIP-07 JS Extension Injection (window.nostr) |
Complete (Sync XHR, Security Manager, NIP-04/44, named constructor) | Complete (Sync XHR, Security Manager, NIP-04/44, named constructor) | 100% | Done |
| MCP Automation Server | Complete (Streamable HTTP, Tools on port 17777) | Complete (Streamable HTTP, cross-thread GTK scheduling) | 100% | Done |
| Login Dialog & CLI Auth | Complete (5 tabs, No Login, CLI auto-login for local/seed/pubkey) | Complete (5 tabs, No Login, CLI auto-login for local/seed/pubkey) | 95% | Low |
Settings (sovereign://settings) |
Complete (Embedded HTML/JS, Live toggles, relays, shortcuts, save) | Complete (Dynamic HTML, XHR endpoint handling, SQLite persistence) | 90% | Low |
Embedded Internal Pages (sovereign://) |
Complete (Profile, Bookmarks, FIPS, Processes, Agents) | Partial (Basic static HTML/JS stubs, missing rich JS apps) | 30% | High |
| Agent Loop & Provider Management | Complete (OpenAI/Anthropic/Ollama, tool calling, chat store) | Partial (Async loop structure exists, missing UI hooks & prompt wiring) | 50% | High |
| Agent Chat Sidebar | Complete (Collapsible left sidebar webview running sovereign://agents/chat) |
Incomplete (Shortcut mapped, sidebar container not fully attached to tabs) | 20% | Medium |
| URL Autocomplete / Search Dropdown | Complete (GtkEntryCompletion for bookmarks & history) | Incomplete (URL entry exists, completion model not wired) | 20% | Medium |
Per-Tab Performance Probe (sovereign://processes) |
Complete (perf-probe.js injection, CPU/FPS/DOM stats, probe-report endpoint) |
Incomplete (Skeleton probe struct, probe injection & report collection missing) | 15% | Medium |
| NIP-78 Settings & Bookmark Sync | Complete (Kind 30078 / 30003 NIP-44 encrypted sync to bootstrap relays) | Partial (Library functions exist, automatic background publish not wired) | 40% | Medium |
| Tor & FIPS Service Controllers | Complete (Tor control protocol, FIPS Unix IPC / daemon management) | Stubs (Module placeholders returning mock/default status) | 15% | Low |
| Offline Site Downloader | Complete (Headless webview rendering & asset bundling) | Stubs (Log message placeholder) | 10% | Low |
2. Detailed Gap Breakdown by Subsystem
2.1 Internal Pages & Embedded Assets (src/embedded_web_content.rs, src/nostr_bridge.rs)
In the original C version, the www/ directory contains complete single-page web applications for browser management:
sovereign://profile(www/profile.html,profile.js,profile.css):- C: Queries cached Kind 0 (metadata) and Kind 3 (contacts) events from SQLite, displays avatar, banner, bio, NIP-05 verification, QR code generation (
sovereign://qr), and contact list. - Rust: Only returns a minimal static HTML template;
handle_profile_data_jsonendpoint is stubbed.
- C: Queries cached Kind 0 (metadata) and Kind 3 (contacts) events from SQLite, displays avatar, banner, bio, NIP-05 verification, QR code generation (
sovereign://bookmarks(www/bookmarks.html,bookmarks.js,bookmarks.css):- C: Nested folder tree view with drag-and-drop hierarchy, tag filters, live editing, and REST endpoints (
/bookmarks/list,/add,/delete,/createdir,/deletedir,/move,/rename,/renamedir). - Rust: Embedded HTML is a simple flat list; directory tree endpoints need full implementation in
nostr_bridge.rs.
- C: Nested folder tree view with drag-and-drop hierarchy, tag filters, live editing, and REST endpoints (
sovereign://agents&sovereign://agents/chat(www/agents/):- C: Complete chat client supporting markdown rendering (
marked.min.js), HTML sanitization (purify.min.js), conversation branching, model selection, skill management (/agents/skills/*), and live polling of agent messages. - Rust: Static placeholder forms without full web client assets and conversation endpoints.
- C: Complete chat client supporting markdown rendering (
sovereign://processes(www/processes.html,processes.js):- C: Two-layer diagnostics dashboard: Layer 1 lists OS processes/WebProcesses (PID, CPU, Memory); Layer 2 lists per-tab performance metrics collected via
perf-probe.js. - Rust: HTML skeleton with no real process tracking or probe integration.
- C: Two-layer diagnostics dashboard: Layer 1 lists OS processes/WebProcesses (PID, CPU, Memory); Layer 2 lists per-tab performance metrics collected via
sovereign://fips(www/fips.html,fips.js):- C: Mesh management UI showing status cards, active peers, spanning tree graph, node directory (Kind 37195), and manual connection controls.
- Rust: Static placeholder form.
2.2 Tab Management & UI Features (src/tab_manager.rs)
- Agent Chat Sidebar (
tab_manager_toggle_sidebar):- C: Creates a persistent GtkPaned container with a collapsible 280px left sidebar hosting a dedicated WebKitWebView loaded with
sovereign://agents/chat. - Rust:
tab_manager_toggle_sidebar()function stub exists, but webview/sidebar layout is not packed into the tab container.
- C: Creates a persistent GtkPaned container with a collapsible 280px left sidebar hosting a dedicated WebKitWebView loaded with
- URL Entry Completion (
GtkEntryCompletion):- C: As the user types in the URL bar, an async completion popup searches SQLite history and bookmarks, showing favicon/title/URL.
- Rust:
GtkEntryhandles Enter and Esc, but has no attachedGtkEntryCompletionmodel.
- Popup & New Window Handling (
on_create_webview/target="_blank"):- C: Intercepts WebKit
createsignal on webviews to enforce tab policy (converting popup windows into new tabs or respected multi-window popups based on settings). - Rust: Navigation policy decision is handled for URLs, but the WebKit
createsignal is not hooked.
- C: Intercepts WebKit
- Favicon Display:
- C: Captures
favicon-databaseupdates and renders 16x16 pixbufs in tab labels. - Rust: Omitted due to Cairo surface conversion differences; uses a generic globe icon.
- C: Captures
2.3 Agent System & Tool Catalog (src/agent_*.rs)
- Interactive Tool Execution:
browser_clickandbrowser_type: Currently stubs inagent_tools.rs. C injects DOM query selector JS to synthesize click and keyboard input events.browser_screenshot: C captures the WebKit webview surface to PNG bytes; Rust returns a stub message.
- Skill Management (
src/agent_skills.rs):- C publishes and queries NIP-51/NIP-78 Kind 31123 skill definitions to Nostr relays. Rust has internal structs but lacks relay publishing integration.
- Conversation Persistence (
src/agent_conversations.rs):- C encrypts chat sessions using NIP-44 and persists them to Nostr relays (Kind 30078) and local SQLite. Rust has SQLite tables but lacks relay publishing.
2.4 Performance Probe Subsystem (src/perf_probe.rs)
js/perf-probe.jsScript Injection:- C: Injected via
UserContentManagerinto non-internal pages; measures CPU busy percentage (Long Tasks API), FPS (requestAnimationFrame loop), DOM node count, Heap used, in-flight fetch requests, and sends periodic reports tosovereign://processes/probe-report. - Rust: Not yet injected;
/processes/probe-reportendpoint is unhandled.
- C: Injected via
2.5 Network Services & System daemons (src/net_services.rs, src/tor_control.rs, src/fips_control.rs)
- Tor Control:
- C: Connects to Tor ControlPort (default 9051), authenticates, checks circuit status, and requests new identity (
SIGNAL NEWNYM). - Rust: Simulated in memory.
- C: Connects to Tor ControlPort (default 9051), authenticates, checks circuit status, and requests new identity (
- FIPS Mesh Control:
- C: Connects via Unix domain socket to the local FIPS daemon, queries peer tables, resolves
.fipsand npub overlay addresses. - Rust: Stubs returning default status.
- C: Connects via Unix domain socket to the local FIPS daemon, queries peer tables, resolves
3. Recommended Roadmap for Full Parity
flowchart TD
A[Phase 1: Rich Embedded Pages & Assets] --> B[Phase 2: UI Enhancements & Sidebar]
B --> C[Phase 3: Agent Tool Execution & Automation]
C --> D[Phase 4: Diagnostics & Settings/Bookmark Sync]
D --> E[Phase 5: Network Services Tor/FIPS]
Phase 1: Rich Internal Pages (sovereign://)
- Migrate embedded web assets from
www/intoembedded_web_content.rsor asset files. - Implement full REST JSON route dispatchers in
nostr_bridge.rsfor Bookmarks (/bookmarks/*), Profile (/profile/data), and Agents (/agents/*).
Phase 2: Tab Manager & UI Features
- Wire collapsible Agent Chat sidebar into
tab_manager.rs. - Connect
GtkEntryCompletionfor URL autocomplete from SQLite history and bookmarks. - Handle WebKit
createsignal fortarget="_blank"popups.
Phase 3: Agent Automation & Tool Execution
- Implement DOM automation tools (
browser_click,browser_type) viarun_javascript. - Implement
browser_screenshotvia WebKitGTK snapshot API.
Phase 4: Performance Probe & Sync
- Wire
perf-probe.jsinjection into all page views and connectsovereign://processes/probe-report. - Wire automatic background sync for Kind 30078 settings and Kind 30003 bookmarks.
Phase 5: Network Daemon Controls
- Implement Tor ControlPort protocol client in
tor_control.rs. - Implement FIPS daemon Unix socket IPC in
fips_control.rs.