# CHRONOGRID P2P - AI CONTEXT & ARCHITECTURAL MANDATES 1. DATA SOVEREIGNTY & LOCAL-FIRST MANDATE: - Never generate code that transmits data to third-party cloud endpoints or SaaS providers. - All network synchronization MUST utilize `crates/chronogrid_net` over libp2p / QUIC with Noise XK encryption. 2. TECH STACK BOUNDARIES: - Presentation: Flutter (Win32 for Windows, GTK3 for Linux, Android NDK). - Core Logic & Storage: Rust (`crates/chronogrid_core`) with SQLCipher & Automerge CRDT. - FFI Bridge: Use `flutter_rust_bridge` C-ABI generation ONLY. 3. SINGLE SOURCE OF TRUTH: - Prior to modifying data structures, consult `docs/API_CONTRACTS/schema.sql` and `docs/ARCHITECTURE/01-OSAD-system-architecture.md`. - Update documentation in `/docs` concurrently with code changes. 4. AUTONOMOUS TASK EXECUTION PROTOCOL: When instructed to "Execute next task" or run an autonomous cycle, perform the following 7 steps in sequence: Step 1: STATE DISCOVERY - Read `.clinerules` and `docs/ARCHITECTURE/01-OSAD-system-architecture.md`. - Inspect files in `docs/TASKS/` to locate the FIRST incomplete task (`[ ]`) in chronological order. - Read `DECISION_LOG.md` to review the latest architectural context. - Explicitly state the Task ID and title being tackled. Step 2: FEATURE BRANCH CREATION - Ensure working on `main` and updated: `git checkout main && git pull origin main` - Create a dedicated feature branch: `git checkout -b feature/-` Step 3: IMPLEMENTATION - Read relevant specs in `/docs` (`schema.sql`, `security-and-crypto.md`, etc.). - Write code required ONLY for the target task while respecting all local-first mandates. Step 4: TESTING & VERIFICATION - Run the local verification suite: `powershell -File scripts/verify_agent_work.ps1` - Run crate unit tests: `cargo test --package ` - Iteratively fix any compiler or test errors until all checks pass cleanly. Step 5: DOCUMENTATION & ADL UPDATE - Update the task status to `[x]` in `docs/TASKS/`. - If architectural decisions or schema adjustments were made, log them in `DECISION_LOG.md` and create a record in `docs/ARCHITECTURE/ADR/`. Step 6: COMMIT & MERGE - Stage changes: `git add .` - Commit: `git commit -m "feat(): complete - "` - Merge into main: `git checkout main && git merge feature/- --no-ff -m "chore: merge feature/ into main"` Step 7: REMOTE PUSH & CLEANUP - Push main: `git push origin main` - Remove feature branch: `git branch -d feature/-` - Provide a concise summary of completed work, test status, and the upcoming task for the next cycle.