chronogrid/docs/ARCHITECTURE/04-master-user-story.md

104 lines
6.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Master User Story: Distributed, Local-First Productivity Engine
**Story Title:** Unified Automated Workflow Execution across Distributed Local-First Nodes
**Target Platform Scope:** Windows Desktop, Linux Desktop, Android Mobile, Headless Server Nodes
**Core Framework Architecture:** Local-First P2P (Flutter / C-FFI / Rust Core / CRDT Engine)
---
## 1. User Story Statement
**As a** multi-context professional managing multiple enterprise, operational, and commercial streams (Engineering, Custom Crafts/POD, and Personal Operations),
**I want** an integrated, automated, local-first system that ingests unstructured communications and quick jots across multiple distinct email domains, local files, and voice inputs—processing and auto-categorizing them via local AI rules into prioritized tasks, scheduled calendar blocks, and structured notes across my Windows, Linux, and Android devices,
**So that** I can achieve zero-friction time, project, and note management without manual data entry, without central cloud server dependencies or SaaS subscription locks, and with end-to-end cryptographic control over my data.
---
## 2. Ingestion & Input Processing Workflows (Discrete Input Architecture)
The system must automatically capture inputs from multiple distinct channels without requiring manual task entry, normalizing all inputs into raw CRDT entities within the local encrypted store (SQLCipher):
* **Direct IMAP / Email Ingestion (Multi-Domain):**
* The background daemon automatically polls external IMAP/TLS mail servers for personal, engineering, and commercial storefront accounts.
* *Workflow:* When an incoming email is flagged or sent to an internal parse address (e.g., `task@domain.com`), the engine extracts the thread body as Markdown, saves attachments as encrypted assets, preserves the deep-link URI to the original thread, and parses explicit deadlines.
* **Global Desktop & Mobile Jots (Scratchpad Capture):**
* *Windows / Linux:* Global system hotkeys invoke a lightweight command palette for instant plain-text jots or direct file drop attachments.
* *Android:* Quick-settings tiles, home-screen widget scratchpads, and intent-sharing (Share-to-App) forward text, web URLs, or quick voice notes directly into the native processing pipeline.
* **Local Workspace Watchers:**
* Background filesystem watchers monitor dedicated local folders (e.g., Markdown notes, local PDFs, design briefs). File modifications automatically sync into the note engine and parse for actionable embedded to-dos (e.g., `- [ ]` markdown items).
* **Automated AI Processing & Classification Pipeline:**
* Raw jots and incoming items pass through an embedded local processing engine (ONNX Runtime / Ollama) that executes four automated transformations:
1. **Context & Namespace Routing:** Maps items to the correct project hierarchy (e.g., *Personal*, *Kell Engineering*, *KellCreations / Tee Time Prints*).
2. **Note-to-Task Extraction:** Separates contextual reference material (stored as linked project notes) from actionable items (extracted as tasks).
3. **Eisenhower Priority Vector Calculation:** Evaluates urgency, importance, time decay, and age to compute a Priority Vector ($S$) and assign the item to Quadrants I–IV.
4. **Timestamp & Duration Allocation:** Extracts natural language dates/times (e.g., *"Review design layout by Thursday 2 PM"*) and sets `due_date` and `estimated_duration` parameters.
---
## 3. Storage & Synchronization Mechanics (Distributed State Architecture)
Data storage and sync must operate entirely on local-first, zero-trust principles:
* **Local Encrypted Storage:**
* All notes, project trees, and time blocks are stored in an encrypted local database (SQLCipher, AES-256-GCM) authenticated via hardware-backed platform key stores (Windows DPAPI, Linux SecretService, Android KeyStore).
* **Serverless Peer-to-Peer Synchronization (CRDTs):**
* Data state changes are tracked via Hybrid Logical Clocks (HLC) and append-only CRDT deltas (Automerge engine).
* Nodes discover each other on local networks via mDNS and across WAN via libp2p QUIC transport, direct NAT hole-punching, and Noise XK protocol handshakes using a private 256-bit Swarm Key.
* Reconnection triggers automatic, background, deterministic delta merges across all personal nodes (Windows, Android, Headless Server) without central server coordination or merge conflicts.
---
## 4. Visualization & Display Mechanisms (Multi-View Execution Shell)
The Flutter presentation layer dynamically renders local database state into specialized execution environments tailored to distinct planning frameworks:
* **Integrated Time-Blocking Calendar Grid:**
* Displays scheduled tasks alongside external Google and Outlook calendar overlays via local CalDAV sync feeds (`127.0.0.1`).
* Tasks can be dragged directly onto calendar slots to reserve dedicated focus blocks, with real-time dynamic duration adjustments.
* **Automated Eisenhower Priority Matrix View:**
* Dynamic four-quadrant board auto-populates tasks based on their calculated Urgency-Importance score.
* Eliminates manual sorting by surfacing Quadrant I (Do First) and Quadrant II (Schedule) items prominently based on approaching deadlines.
* **Multi-Level Project & Kanban Views:**
* Displays nested folder structures, namespaces, and project trees.
* Toggles instantly between hierarchical list views, interactive Kanban status boards (*Backlog*, *In Progress*, *Review*, *Done*), and interactive Gantt milestone timelines.
* **Unified Note & Knowledge Workspace:**
* Rich Markdown document editor supporting bi-directional task linking, embedded media attachments, and infinite sub-project documentation trees.
* Daily Jots view automatically aggregates unformed ideas into structured project wikis over time.
---
## 5. Detailed Acceptance Criteria
| Area | Functional Requirement | Technical Acceptance Pass Criteria |
| --- | --- | --- |
| **Ingestion** | Multi-Source Auto Parsing | IMAP polling, global hotkeys, and Android widgets create structured tasks in SQLCipher without manual UI entry within 2 seconds of receipt. |
| **Storage** | Zero-Trust Encryption | Database is unreadable on disk without the Master Key derived via Argon2id; key storage uses native OS platform keychains. |
| **Sync** | Serverless P2P Convergence | Offline modifications on Windows and Android automatically converge via QUIC/libp2p CRDT delta streams upon network reconnection without data loss or duplicate entries. |
| **Display** | Time Blocking & Multi-View | The UI renders Kanban, Eisenhower Matrix, Gantt, and Calendar views from the same CRDT state store, updating in real time across all active views. |
| **Headless** | Always-On Relay Node | The headless CLI daemon builds for Linux/systemd, maintains the CRDT state, runs local IMAP background polling, and facilitates WAN NAT hole-punching. |