SPB Git

Repository Public License

ARCHITECTURE.md 5.7 KB 67 lines markdown

1# Architecture23## Principles4- **Native.** SwiftUI, with AppKit on the Mac and UIKit on iOS where needed. Web content is rendered by `WKWebView`.5  No Electron, no HTML main interface, no private API.6- **One core, platform adapters.** Shared logic and shared SwiftUI live in the package; platform differences sit behind7  `#if os(...)` adapters, not in divergent copies.8- **One-way dependencies.** A module only imports modules below it. Engines never import WebKit or SwiftUI: everything9  that touches a page or the screen goes through a protocol implemented higher up.10- **Concurrency.** Swift 6 strict concurrency. Storage and orchestration are actors or private serial queues; UI types11  are `@MainActor`. No disk or network work on the main actor.12- **No third-party dependency** (ADR 0002). SQLite, cryptography, networking and embeddings come from the system.1314## Modules (`Packages/NavigatorKit`)1516```17                         Apps/Mac        Apps/iOS18                              \            /19                               NavigatorUI                     shared SwiftUI, app model, glue20        ┌──────────┬───────────┬─────┴─────┬───────────┬──────────┬──────────┬─────────┐21   WebRuntime  OrbitEngine PrivacyEngine DownloadEngine MemoryEngine AgentRuntime FlowEngine CanvasEngine SyncEngine22        │          └───────────┴─────┬─────┴───────────┘           │23        │                       Persistence                    ProviderKit24        └──────────────┬─────────────┴──────────────────────────────┘25                 NavigatorCore        Diagnostics        LunarDesign (imports nothing of ours)26```2728| Module | Role |29|---|---|30| `NavigatorCore` | Value models with typed identifiers (`BrowserWindow`, `Tab`, `OrbitSpace`, `Profile`, `NavigationEntry`, `Bookmark`, `Download`, `PermissionDecision`, `Archive`, `Note`, `CanvasDocument`, `AgentRun`, `Workflow`, `SyncRecord`), the omnibox URL/search classifier, search engines, and the service protocols the web layer calls (`PermissionProvider`, `HistoryRecorder`, `DownloadSink`, `SecretStore`) |31| `Diagnostics` | Local logging (`os.Logger`, private by default), signposts, credential redaction. No telemetry |32| `LunarDesign` | Lunar Glass: tokens, 12 themes × light/dark, materials (Liquid Glass with fallback), components, 20 module glyphs, the mark |33| `Persistence` | System SQLite (WAL), versioned migrations, one store per model, crash-safe session journal, FTS5 history search with frecency suggestions, bookmark HTML import/export, data lifecycle and export, Keychain secret store |34| `WebRuntime` | `WebEngine` (one per tab) around `WKWebView`: navigation policy, TLS and authentication challenges, downloads hand-off, isolated script worlds with validated messages, per-profile data stores, content rule lists, `orix://` internal pages, suspend/resume |35| `OrbitEngine` | Spaces and profiles service, orbital layout maths, the five tab layouts, Split geometry, Blink suspension policy, Focus sessions, session batching and restoration model |36| `PrivacyEngine` | Shield rule generation (`WKContentRuleList` JSON), per-site permissions with expiry, Ghost sessions, data controls, tracking-parameter stripping, homograph detection |37| `DownloadEngine` | Download manager (destination, safe file names, risk classification, progress, pause/resume/cancel, recovery) |38| `ProviderKit` | AI providers behind one protocol: Anthropic, OpenAI, OpenRouter, any compatible endpoint, local on-device. Streaming, tools, bounded retries, usage and cost estimates |39| `AgentRuntime` | Browsing agent: typed tools, budgets, confirmations, citations, prompt-injection and exfiltration defences |40| `FlowEngine` | Declarative workflow language: parser, validator, interpreter, dry run, logs, resume |41| `CanvasEngine` | Canvas document editing model with undo, geometry, attachments, export |42| `SyncEngine` | Capsule export format, encrypted local transfer, merge logic; CloudKit adapter off by default |43| `MemoryEngine` | Opt-in local index: full text and on-device sentence embeddings |44| `TestSupport` | Local HTTP fixture server (redirects, forms, downloads, auth, adversarial pages), test helpers |45| `NavigatorUI` | App environment, browser store, windows, omnibox, panels, native pages and error states, onboarding |4647## Data48- One SQLite database per installation under Application Support; identifiers are UUID strings; schema version is49  recorded and a database newer than the code is refused, never downgraded. A corrupt file is moved aside, not deleted.50- Each profile owns a WebKit data store (`WKWebsiteDataStore(forIdentifier:)`); a Ghost session uses a fresh51  non-persistent store and is rejected by every write API of the database.52- Secrets (AI provider keys) live only in the Keychain.53- Window and tab state is journalled incrementally; a clean-shutdown flag tells a crash from a normal quit.5455## Compatibility matrix5657| | Minimum | Notes |58|---|---|---|59| macOS | 15.0 | Sandboxed, hardened runtime, Developer ID distribution |60| iOS / iPadOS | 18.0 | iPhone and iPad, multiple scenes |61| Liquid Glass | OS 26+ | Material fallback below |62| Profiles | all supported systems | `WKWebsiteDataStore(forIdentifier:)` (iOS 17 / macOS 14) |63| Default browser | not available | Needs the `com.apple.developer.web-browser` entitlement granted by Apple |6465Limits of WebKit as an embedded engine (extensions, DRM, passkeys, Web Push…) are listed in66`docs/WEBKIT_LIMITATIONS.md` with the fallback chosen for each.67
Files main
Menu

Theme