# Active Desktop Context Engine (ADCE) > **High-Performance Desktop Context Graph, Time-Series Persistence & MCP Provider for Local AI Agents and Voice Interfaces** --- ## 1. Overview The **Active Desktop Context Engine (ADCE)** is a privacy-first Windows background daemon and [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server. Instead of relying on resource-heavy screenshot OCR, periodic screen polling, or cloud telemetry, ADCE integrates directly with native Win32 `WinEvent` hooks and UI Automation (UIA) caching to maintain a live, structured model of the user's active desktop environment with minimal resource overhead. ### Key Capabilities: * **100% Local Data Sovereignty:** Complete on-device execution. Active window titles, document contents, and application states never leave localhost, ensuring enterprise privacy and zero telemetry leakage. * **Deterministic Focus & Window Topology:** Event-driven tracking of foreground application envelopes, process metadata, window hierarchies, and focused UI controls via decoupled asynchronous channels. * **Virtual Desktop & Workspace Awareness:** Extraction of active Virtual Desktop GUIDs, friendly names, and desktop indices via native COM interop. * **Container-Aware Tab Discovery:** Targeted tab enumeration across modern browsers (Waterfox, Firefox, Chrome, Edge) and code editors (VS Code, Antigravity) without triggering unpruned DOM crawling stalls. * **Automated Credential & Privacy Sanitization:** Built-in security firewall (`ContextPrivacySanitizer`) that detects `IsPassword` controls to redact passwords (`[REDACTED_PASSWORD]`), masks sensitive file buffers (`.env`, `.pem`, `.kdbx`, `id_rsa`), and strips OAuth tokens/query strings from browser address bars before context envelopes leave the extraction plane. * **Token-Efficient MCP Streaming:** Compact, high-density JSON context snapshots over local MCP endpoints (`get_desktop_context`, `desktop://current`), giving local LLMs actionable workflow awareness without wasting tokens on raw screen dumps. * **Historical State Persistence:** Embedded time-series storage (SQLite WAL) tracking focus transitions and tab history for temporal agent reasoning. --- ## 2. Core Philosophy & Architectural Vision ADCE was designed to bridge low-level Windows accessibility infrastructure with high-level agentic AI and voice interfaces: 1. **Unopinionated Accessibility Primitives (Core Vision):** Rather than imposing rigid application-specific workflows, ADCE aims to surface clean, structured desktop primitives (window identity, container tabs, active editor buffers, workspace IDs, focused control types). Downstream speech recognition engines (Caster, Dragonfly, Talon) and local AI agent loops can consume these primitives to drive window switching, contextual grammar activation, or dynamic tool execution. 2. **Dual-Consumer Architecture:** A single high-performance engine serves both real-time **local accessibility and voice tools** (via direct .NET / IPC bindings) and **local AI coding assistants** (via Model Context Protocol JSON-RPC endpoints). 3. **Non-Invasive Execution:** 100% out-of-process execution using official Windows accessibility (`FlaUI.UIA3`), Win32 hooks (`SetWinEventHook`), and Virtual Desktop COM interfaces, requiring zero DLL injection or kernel drivers. 4. **Targeted Zonal Anchoring:** By scoping extractions to target class names and container bounding boxes, ADCE avoids the classic pitfalls of blind recursive DOM walking across modern Chromium and Gecko applications. > 🚀 **Verified Downstream Use Case:** > ADCE has been empirically integrated into [Caster](https://github.com/dictation-toolbox/Caster) via [caster-user-directory-and-notes](https://github.com/amirf147/caster-user-directory-and-notes), powering **dynamic sub-window voice grammar activation** (e.g. automatically activating CLI/Git commands only when focused in VS Code / Antigravity IDE integrated terminals without audio stutter). See the full [First Real-World Use Case Guide](docs/guides/FIRST_REAL_WORLD_USE_CASE_CASTER_DYNAMIC_TERMINAL_GRAMMARS.md). --- ## 3. Live Telemetry & DevTools HUD Demos | System Tray & Non-Activating Live HUD | Antigravity IDE (Monaco Editor & Zones) | | :---: | :---: | |  |  | | Waterfox Browser (Gecko Tabs & Links) | SQLite Time-Series Transition Timeline | | :---: | :---: | |  |
============================================================| --- ## 4. Architecture: Production Layered Model ADCE is structured as a high-performance, unidirectional 4-tier pipeline designed for minimal resource overhead and zero cross-apartment COM deadlocks: ``` ┌────────────────────────────────────────────────────────────────────────────────────────┐ │ ADCE PRODUCTION ARCHITECTURE │ ├────────────────────────────────────────────────────────────────────────────────────────┤ │ 1. OS EVENT HOOK PLANE (Win32 Low-Level Event Hooks) │ │ ├── SetWinEventHook listeners (EVENT_SYSTEM_FOREGROUND, EVENT_OBJECT_FOCUS) │ │ └── Dedicated STA Message Pump Thread with Barrier Synchronization │ ├────────────────────────────────────────────────────────────────────────────────────────┤ │ 2. CONCURRENCY & EXTRACTION PLANE (FlaUI.UIA3 + Win32 Gating) │ │ ├── Win32 Shallow Filter (< 0.5 ms): Fast HWND, process & WS/WS_EX bitmask pre-gating │ │ ├── Async Channel Debouncer: 50ms trailing-edge window with 250ms burst delay clamp │ │ ├── Monotonic Epoch Guard: Supersedes stale in-flight extractions │ │ ├── Scoped CacheRequest Batching: Single-roundtrip FlaUI.UIA3 COM queries (< 15 ms) │ │ ├── Ancestor Chain Climber: Resolves leaf controls to typed DesktopSemanticZones │ │ └── Privacy Sanitizer: Redacts passwords, secret files, and address bar tokens │ ├────────────────────────────────────────────────────────────────────────────────────────┤ │ 3. PERSISTENCE & STORAGE PLANE (Dual-Tier In-Memory + SQLite WAL) │ │ ├── L1 In-Memory Atomic Cache: Lock-free instant query reads (< 15 ns) │ │ └── L2 Time-Series WAL Store: Channel-decoupled asynchronous SQLite persistence │ ├────────────────────────────────────────────────────────────────────────────────────────┤ │ 4. HOST DAEMON & CONSUMER INTERFACES (Tray Daemon & Model Context Protocol) │ │ ├── System Tray Background Daemon: PerMonitorV2 DPI aware with dynamic status icon │ │ ├── Non-Activating Live DevTools HUD: Floating diagnostic overlay (WS_EX_NOACTIVATE) │ │ └── Model Context Protocol (MCP) Server: Universal JSON-RPC 2.0 (Stdio & HTTP/SSE) │ └────────────────────────────────────────────────────────────────────────────────────────┘ ``` --- ## 5. Documentation Hub & Architecture Reference ADCE maintains a comprehensive documentation suite covering architecture specifications, application layout profiles, and operational guides. > 📚 **Master Documentation Entrypoint:** The complete engineering context, specifications catalog, and architecture invariants are indexed in **[`docs/CONTEXT.md`](docs/CONTEXT.md)**. > 📑 **Architecture Specifications:** Normative specifications are located in **[`docs/architecture/`](docs/architecture/)**. ### Primary Architecture Specifications | Specification | Description | | :--- | :--- | | 📑 [Core Domain Model Specification](docs/architecture/CORE_DOMAIN_MODEL.md) | Immutable records, 19 semantic zones, 6 application archetypes, and JSON serialization. | | ⚡ [Extraction Pipeline Specification](docs/architecture/EXTRACTION_PIPELINE.md) | Win32 shallow gating (< 0.5 ms), UIPI privilege checks, FlaUI caching, and dynamic rules. | | 💾 [Dual-Tier Storage Architecture](docs/architecture/STORAGE_ARCHITECTURE.md) | Sub-microsecond L1 atomic memory cache and SQLite WAL time-series state persistence. | | 🖥️ [Daemon Host & Consumer Integration](docs/architecture/DAEMON_AND_CONSUMER_INTEGRATION.md) | WinEvent STA message pump, tray host, HUD overlay, and MCP endpoints for Caster voice grammars. | | 🛡️ [Security, Systems & Hardening Audit](docs/architecture/SECURITY_AND_HYGIENE_AUDIT_2026.md) | Master security audit covering MCP CORS/auth hardening, privacy sanitizer, and COM RCW lifecycle. | | 📐 [Desktop UI Perception & Volatility Taxonomy](docs/architecture/DESKTOP_UI_PERCEPTION_AND_VOLATILITY_TAXONOMY.md) | 4-level volatility spectrum, application framework quirks, and out-of-band protocol handoff. | | 🎯 [ADCE Philosophy & Scope Boundaries](docs/architecture/ADCE_PHILOSOPHY_AND_SCOPE_BOUNDARIES.md) | Boundary definition: ADCE as a high-speed passive perception sensor vs. downstream action actors. | | ⚔️ [Hostile Architecture & Systems Review](docs/architecture/HOSTILE_ARCHITECTURE_REVIEW.md) | Adversarial review evaluating COM apartment deadlocks, GC allocation churn, and UIPI boundaries. | ### Application Profiles & Operational Guides | Document | Category | Description | | :--- | :--- | :--- | | 📚 [Application Profiles Catalog](docs/app_hierarchies/README.md) | Profiles | Container structures and UIA selectors for [Waterfox](docs/app_hierarchies/01_waterfox.md), [Antigravity IDE](docs/app_hierarchies/02_antigravity_ide.md), and [Windows Terminal](docs/app_hierarchies/03_windows_terminal.md). | | 🚀 [Caster Dynamic Terminal Grammars](docs/guides/FIRST_REAL_WORLD_USE_CASE_CASTER_DYNAMIC_TERMINAL_GRAMMARS.md) | Integration Guide | Production integration: Dynamic voice grammar activation in VS Code / Antigravity IDE via SSE streaming. | | 👁️ [Focus & Zone Detection Explained](docs/guides/ADCE_FOCUS_AND_ZONE_DETECTION_EXPLAINED.md) | Operational Guide | Step-by-step guide to Windows focus mechanics, parent-chain traversal, and semantic zone detection. | | 📘 [Educational Refresher & Architecture Guide](docs/guides/EDUCATIONAL_GUIDE_AND_ARCHITECTURE_REFRESHER.md) | Architecture Guide | Walkthrough of UI Automation, Win32 systems programming, and FlaUI caching fundamentals. | | 🔬 [Engineering Postmortems Directory](docs/postmortems/README.md) | Retrospectives | Catalog of 11 development milestone retrospectives, including [Claim Verifier Deprecation](docs/postmortems/CLAIM_VERIFIER_DEPRECATION_AND_SELF_CONFIRMATION_LOOP_POSTMORTEM.md). | ### Historical Archive Superseded test run outputs, exploratory research into unused third-party libraries, and deprecated custom claim verification matrices are archived in [`docs/archive/`](docs/archive/README.md). > 🧭 *Navigation for AI Agents:* Restrict architectural reasoning to **[`docs/CONTEXT.md`](docs/CONTEXT.md)** and [`docs/architecture/`](docs/architecture/). Do not index or cite files in `docs/archive/`. --- ## 6. Engineering Roadmap & Milestone Status Following our **Engineering Verification Workflow**, ADCE engineering is structured across clear progressive phases: | Phase / Milestone | Description | Status | Deliverables & Artifacts | | :--- | :--- | :--- | :--- | | **Phase 1: Physical Observation** | Identify DOM traversal traps and latency bottlenecks across real-world apps. | `[x]` Complete | • [Doc 010: DOM Traversal Telemetry](https://github.com/amirf147/caster-user-directory-and-notes/blob/master/docs/accessibility_mcp/010_telemetry_benchmarks_and_live_findings.md)
# | TIME (UTC) | PROCESS | SEMANTIC ZONE
------------------------------------------------------------
323 | 13:34:19.604 | Antigravity ID | [ChatAssistant]
324 | 13:36:26.553 | Antigravity ID | [EditorCodeBuffer]
329 | 13:36:31.583 | waterfox | [DocumentContent]
336 | 13:36:38.140 | Antigravity ID | [GitCommitBox]
============================================================