# sentient-os-labs/sentient-os architecture

> Architecture diagram of the GitHub repository sentient-os-labs/sentient-os, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sentient-os-labs/sentient-os
- Repository: https://github.com/sentient-os-labs/sentient-os

## Overview

#### Purpose and entry points
Sentient OS is a native macOS 15+/Apple Silicon personal-intelligence app. It ingests local personal data nightly, filters/summarizes it on-device, builds a local Markdown knowledge vault through the user’s Codex/OpenAI subscription, and presents proactive work plus an interactive “Sidekick” computer-use interface. App startup and shared UI state originate in:
- `Sentient OS macOS/App/main.swift`
- `Sentient OS macOS/App/Sentient_OS_macOSApp.swift`
- `Sentient OS macOS/App/AppState.swift`

#### Application shell and user surfaces
The SwiftUI application is organized around a root/home experience, menu-bar presence, onboarding, settings, and a Knowledge viewer. `AppState` is the central coordination boundary for UI-visible lifecycle and feature state; views should not directly own pipeline infrastructure.
- `Sentient OS macOS/Views/RootView.swift`
- `Sentient OS macOS/Views/HomeView.swift`
- `Sentient OS macOS/Views/MenuBarView.swift`
- `Sentient OS macOS/Views/Onboarding/OnboardingView.swift`
- `Sentient OS macOS/Views/Knowledge/KnowledgeView.swift`

#### Local ingestion and incremental processing
Sources abstract local and connected data; ingestion connectors convert source records into pipeline items, while cycle/run stores support incremental, resumable processing and lifetime activity tracking. Local sources include files, Notes, iMessage, WhatsApp, plus Gmail/Calendar through Codex/OpenAI connectors. Full Disk Access and source permissions form a hard OS boundary.
- `Sentient OS macOS/Sources/DataSource.swift`
- `Sentient OS macOS/Sources/iMessageSource.swift`
- `Sentient OS macOS/Sources/WhatsAppSource.swift`
- `Sentient OS macOS/Ingestion/Connector.swift`
- `Sentient OS macOS/Ingestion/IterativeRun.swift`
- `Sentient OS macOS/Ingestion/CycleStore.swift`

Primary flow: selected sources → connectors/items → iterative run/cycle persistence → local model triage → retained summaries for vault generation. Factory reset is explicitly part of the ingestion-domain lifecycle.

#### Privacy-preserving inference pipeline
The local Engine is the privacy gate and compute spine. A downloadable/located on-device model performs triage; sensitive or junk content is dropped, and retained material receives PII screening before it can reach cloud-backed Codex processing. This is the primary raw-data boundary: raw source content stays local, while only approved, PII-stripped summaries are eligible for frontier processing.
- `Sentient OS macOS/Engine/Engine.swift`
- `Sentient OS macOS/Engine/Triage.swift`
- `Sentient OS macOS/Engine/PIIScan.swift`
- `Sentient OS macOS/Engine/ModelDownload.swift`
- `Sentient OS macOS/Engine/ModelLocator.swift`

Runtime is native Swift/macOS with LiteRT-LM/Gemma local inference, optimized for constrained Apple Silicon machines.

#### Vault generation and knowledge presentation
Approved summaries are distilled into an editable, local Obsidian-style Markdown corpus. Vault generation, slicing, activity, and cloud-sharing concerns are separated from ingestion and UI. The Knowledge UI renders Markdown/tree structure and a graph/constellation visualization.
- `Sentient OS macOS/Vault/VaultGenerator.swift`
- `Sentient OS macOS/Vault/CorpusSlicer.swift`
- `Sentient OS macOS/Vault/VaultCloud.swift`
- `Sentient OS macOS/Views/Knowledge/VaultTree.swift`
- `Sentient OS macOS/Views/Knowledge/Graph/SkyGraph.swift`

#### Codex/OpenAI and optional encrypted mirror
Codex CLI is the external frontier-compute and computer-use integration, authenticated using the user’s ChatGPT account; Sentient does not proxy this workload through its own API. Optional MCP mirror sharing is isolated behind `MirrorClient`/vault cloud functionality and is off by default; the README specifies AES-256-GCM ciphertext-only relay storage.
- `Sentient OS macOS/Cloud/CodexCLI.swift`
- `Sentient OS macOS/Cloud/CodexAuth.swift`
- `Sentient OS macOS/Cloud/ComputerUseSetup.swift`
- `Sentient OS macOS/Cloud/MirrorClient.swift`
- `Sentient OS macOS/Vault/VaultCloud.swift`

#### Proactive and Sidekick execution
Proactive processing turns vault context into morning cards/research and requires an explicit user action to execute. Sidekick is a separate interactive path: notch window/hotkey → voice or typed command → Codex-backed computer use, optionally enhanced by Screen Recording. UI capture and action execution are therefore permission-gated boundaries.
- `Sentient OS macOS/Proactive/ProactiveCycle.swift`
- `Sentient OS macOS/Proactive/ProactiveExecutor.swift`
- `Sentient OS macOS/Notch Magic/CommandCoordinator.swift`
- `Sentient OS macOS/Notch Magic/VoiceCapture.swift`
- `Sentient OS macOS/Notch Magic/ScreenCapture.swift`

#### Scheduled operation, system integration, and observability
The overnight scheduler targets the 3 AM processing cycle, with power/thermal caution and a wake-helper client/protocol for sleeping or lid-closed Macs. System permission management, notifications, and app-support storage sit at the macOS boundary. Diagnostics use optional Sentry crash reporting and TelemetryDeck-style analytics, designed to avoid content telemetry. Sparkle-based update control is another app lifecycle boundary.
- `Sentient OS macOS/Scheduling/OvernightScheduler.swift`
- `Sentient OS macOS/Scheduling/WakeHelperClient.swift`
- `Sentient OS macOS/System/Permissions.swift`
- `Sentient OS macOS/Diagnostics/CrashReporting.swift`
- `Sentient OS macOS/Updates/UpdateController.swift`

Main entry points: [`Sentient OS macOS/Vault/CorpusSlicer.swift`](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Vault/CorpusSlicer.swift) (Local knowledge vault), [`Sentient OS macOS/Cloud/CodexCLI.swift`](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Cloud/CodexCLI.swift) (Codex CLI), [`Sentient OS macOS/App/AppState.swift`](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/App/AppState.swift) (App state), [`Sentient OS macOS/Ingestion/Connector.swift`](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Ingestion/Connector.swift) (Ingestion connectors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["macOS App"]
  node_startup["App startup<br/>SwiftUI entry<br/>[main.swift]"]
  node_appstate["App state<br/>UI coordinator<br/>[AppState.swift]"]
  node_surfaces["App surfaces<br/>SwiftUI views<br/>[RootView.swift]"]
  node_knowledge_ui["Knowledge viewer<br/>Markdown and graph UI"]
end

subgraph group_ingestion["Local Processing"]
  node_sources[("Personal data sources<br/>source abstraction<br/>[DataSource.swift]")]
  node_connectors["Ingestion connectors<br/>record adapters<br/>[Connector.swift]"]
  node_run_store[("Incremental runs<br/>cycle persistence<br/>[IterativeRun.swift]")]
  node_engine{{"Local inference engine<br/>LiteRT-LM / Gemma<br/>[Engine.swift]"}}
  node_triage["Content triage<br/>local filtering<br/>[Triage.swift]"]
  node_pii_scan["PII screening<br/>local redaction gate<br/>[PIIScan.swift]"]
  node_model_setup["Local model setup<br/>model lifecycle"]
end

subgraph group_vault["Knowledge &amp; Cloud"]
  node_vault_generator["Vault generator<br/>Markdown corpus builder"]
  node_vault[("Local knowledge vault<br/>Markdown corpus<br/>[CorpusSlicer.swift]")]
  node_codex{{"Codex CLI<br/>external compute integration<br/>[CodexCLI.swift]"}}
  node_mirror["Optional encrypted mirror<br/>MCP relay client<br/>[MirrorClient.swift]"]
end

subgraph group_execution["Proactive &amp; Sidekick"]
  node_proactive["Proactive cycle<br/>morning work planner"]
  node_sidekick["Sidekick commands<br/>interactive coordinator"]
end

subgraph group_system["System Boundaries"]
  node_scheduler["Overnight scheduler<br/>3 AM scheduler"]
  node_permissions{{"macOS permissions<br/>OS privacy boundary<br/>[Permissions.swift]"}}
  node_operations["App operations<br/>diagnostics and updates"]
end

node_startup -->|"initializes"| node_appstate
node_appstate -->|"coordinates"| node_surfaces
node_surfaces -->|"opens"| node_knowledge_ui
node_scheduler -->|"starts nightly cycle"| node_connectors
node_permissions -->|"authorizes access"| node_sources
node_sources -->|"records"| node_connectors
node_connectors -->|"persists items and progress"| node_run_store
node_run_store -->|"supplies pending items"| node_engine
node_model_setup -->|"provides model"| node_engine
node_engine -->|"runs local inference"| node_triage
node_triage -->|"retained summaries"| node_pii_scan
node_pii_scan -->|"approved summaries only"| node_vault_generator
node_vault_generator -->|"requests distillation"| node_codex
node_codex -->|"generates Markdown"| node_vault
node_vault -->|"renders tree and graph"| node_knowledge_ui
node_vault -.->|"optional encrypted sharing"| node_mirror
node_vault -->|"provides context"| node_proactive
node_proactive -->|"executes after user action"| node_codex
node_permissions -->|"gates screen and voice capture"| node_sidekick
node_sidekick -->|"computer-use requests"| node_codex
node_appstate -->|"lifecycle control"| node_operations

click node_startup "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/App/main.swift"
click node_appstate "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/App/AppState.swift"
click node_surfaces "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Views/RootView.swift"
click node_knowledge_ui "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Views/Knowledge/KnowledgeView.swift"
click node_sources "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Sources/DataSource.swift"
click node_connectors "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Ingestion/Connector.swift"
click node_run_store "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Ingestion/IterativeRun.swift"
click node_engine "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Engine/Engine.swift"
click node_triage "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Engine/Triage.swift"
click node_pii_scan "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Engine/PIIScan.swift"
click node_model_setup "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Engine/ModelDownload.swift"
click node_vault_generator "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Vault/VaultGenerator.swift"
click node_vault "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Vault/CorpusSlicer.swift"
click node_codex "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Cloud/CodexCLI.swift"
click node_mirror "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Cloud/MirrorClient.swift"
click node_proactive "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Proactive/ProactiveCycle.swift"
click node_sidekick "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Notch%20Magic/CommandCoordinator.swift"
click node_scheduler "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Scheduling/OvernightScheduler.swift"
click node_permissions "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/System/Permissions.swift"
click node_operations "https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Diagnostics/CrashReporting.swift"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_startup,node_appstate,node_surfaces,node_knowledge_ui toneBlue
class node_sources,node_connectors,node_run_store,node_engine,node_triage,node_pii_scan,node_model_setup toneAmber
class node_vault_generator,node_vault,node_codex,node_mirror toneMint
class node_proactive,node_sidekick toneRose
class node_scheduler,node_permissions,node_operations toneIndigo
```

## Components

### macOS App

- [App startup](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/App/main.swift): SwiftUI entry · `Sentient OS macOS/App/main.swift`
- [App state](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/App/AppState.swift): UI coordinator · Owns UI-visible lifecycle and feature state. · `Sentient OS macOS/App/AppState.swift`
- [App surfaces](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Views/RootView.swift): SwiftUI views · Home, menu bar, onboarding, settings, and knowledge entry points. · `Sentient OS macOS/Views/RootView.swift`
- [Knowledge viewer](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Views/Knowledge/KnowledgeView.swift): Markdown and graph UI · `Sentient OS macOS/Views/Knowledge/KnowledgeView.swift`

### Local Processing

- [Personal data sources](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Sources/DataSource.swift): source abstraction · Files, Notes, messages, and connected Gmail/Calendar. · `Sentient OS macOS/Sources/DataSource.swift`
- [Ingestion connectors](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Ingestion/Connector.swift): record adapters · `Sentient OS macOS/Ingestion/Connector.swift`
- [Incremental runs](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Ingestion/IterativeRun.swift): cycle persistence · Supports resumable processing, activity tracking, and reset lifecycle. · `Sentient OS macOS/Ingestion/IterativeRun.swift`
- [Local inference engine](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Engine/Engine.swift): LiteRT-LM / Gemma · On-device privacy gate on Apple Silicon. · `Sentient OS macOS/Engine/Engine.swift`
- [Content triage](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Engine/Triage.swift): local filtering · Drops sensitive or junk source content locally. · `Sentient OS macOS/Engine/Triage.swift`
- [PII screening](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Engine/PIIScan.swift): local redaction gate · Only PII-stripped summaries may leave the device. · `Sentient OS macOS/Engine/PIIScan.swift`
- [Local model setup](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Engine/ModelDownload.swift): model lifecycle · Locates or downloads the on-device model. · `Sentient OS macOS/Engine/ModelDownload.swift`

### Knowledge & Cloud

- [Vault generator](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Vault/VaultGenerator.swift): Markdown corpus builder · Distills approved summaries into an editable local vault. · `Sentient OS macOS/Vault/VaultGenerator.swift`
- [Local knowledge vault](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Vault/CorpusSlicer.swift): Markdown corpus · Obsidian-style local knowledge base. · `Sentient OS macOS/Vault/CorpusSlicer.swift`
- [Codex CLI](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Cloud/CodexCLI.swift): external compute integration · Uses the user's ChatGPT account; no Sentient proxy API. · `Sentient OS macOS/Cloud/CodexCLI.swift`
- [Optional encrypted mirror](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Cloud/MirrorClient.swift): MCP relay client · Off by default; relay stores ciphertext only. · `Sentient OS macOS/Cloud/MirrorClient.swift`

### Proactive & Sidekick

- [Proactive cycle](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Proactive/ProactiveCycle.swift): morning work planner · Produces cards and research from vault context. · `Sentient OS macOS/Proactive/ProactiveCycle.swift`
- [Sidekick commands](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Notch%20Magic/CommandCoordinator.swift): interactive coordinator · Hotkey/notch commands route voice or typed requests to computer use. · `Sentient OS macOS/Notch Magic/CommandCoordinator.swift`

### System Boundaries

- [Overnight scheduler](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Scheduling/OvernightScheduler.swift): 3 AM scheduler · Uses wake support with power and thermal caution. · `Sentient OS macOS/Scheduling/OvernightScheduler.swift`
- [macOS permissions](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/System/Permissions.swift): OS privacy boundary · Gates Full Disk Access, source access, screen recording, and capture. · `Sentient OS macOS/System/Permissions.swift`
- [App operations](https://github.com/sentient-os-labs/sentient-os/blob/main/Sentient%20OS%20macOS/Diagnostics/CrashReporting.swift): diagnostics and updates · Content-avoiding telemetry, crash reporting, and Sparkle updates. · `Sentient OS macOS/Diagnostics/CrashReporting.swift`

## Connections

- App startup → App state: initializes
- App state → App surfaces: coordinates
- App surfaces → Knowledge viewer: opens
- Overnight scheduler → Ingestion connectors: starts nightly cycle
- macOS permissions → Personal data sources: authorizes access
- Personal data sources → Ingestion connectors: records
- Ingestion connectors → Incremental runs: persists items and progress
- Incremental runs → Local inference engine: supplies pending items
- Local model setup → Local inference engine: provides model
- Local inference engine → Content triage: runs local inference
- Content triage → PII screening: retained summaries
- PII screening → Vault generator: approved summaries only
- Vault generator → Codex CLI: requests distillation
- Codex CLI → Local knowledge vault: generates Markdown
- Local knowledge vault → Knowledge viewer: renders tree and graph
- Local knowledge vault → Optional encrypted mirror: optional encrypted sharing
- Local knowledge vault → Proactive cycle: provides context
- Proactive cycle → Codex CLI: executes after user action
- macOS permissions → Sidekick commands: gates screen and voice capture
- Sidekick commands → Codex CLI: computer-use requests
- App state → App operations: lifecycle control
