12 KiB
12 KiB
Phase 5: Headless Node, Integration Testing & Release
Status: Pending Phase 4 Completion
Phase Goal: Complete the chronogrid_daemon headless binary with all background services, perform comprehensive multi-device integration testing, finalize cross-platform build pipelines, and produce release artifacts for Windows (.msi), Linux (.AppImage/.deb), and Android (.apk).
Prerequisites: Phase 4 complete ✅
Estimated Complexity: High
Blocking: None — this is the final phase
Task 5.1 — Complete chronogrid_daemon Headless Binary
- Task 5.1: Complete the
chronogrid_daemonheadless binary with all background services:- Implement full daemon startup sequence in
apps/chronogrid_daemon/src/main.rs:- Parse CLI args and load TOML config
- Initialize
tracingstructured logging (JSON format for production, pretty for dev) - Load or generate
NodeIdentityfrom config path - Retrieve master key from keychain (or encrypted keyfile for headless)
- Initialize
chronogrid_core::Database - Start
chronogrid_net::SwarmManager(P2P mesh) - Start IMAP polling tasks for all configured accounts
- Start filesystem watchers for all configured watch paths
- Start CalDAV embedded server on
127.0.0.1:4242 - Start Eisenhower score recomputation timer (every 15 minutes)
- Start automation rules engine event loop
- Block on shutdown signal (SIGTERM/SIGINT/SIGHUP)
- Graceful shutdown: stop all background tasks, flush database, close P2P swarm
- Implement
apps/chronogrid_daemon/src/config.rs:DaemonConfigstruct with full TOML deserialization- Sections:
[node],[database],[network],[imap](array),[watchers](array),[caldav],[logging]
- Implement
apps/chronogrid_daemon/src/web_gui.rs:- Lightweight HTTPS web interface on
127.0.0.1:8443usingaxum - Self-signed TLS certificate generated on first run
- REST API endpoints:
GET /api/tasks,GET /api/notes,POST /api/tasks,GET /api/sync/status - Minimal HTML/JS dashboard for browser-based task management
- Lightweight HTTPS web interface on
- Create
apps/chronogrid_daemon/config.example.tomlwith all options documented - Run
cargo build --release --package chronogrid_daemon
- Implement full daemon startup sequence in
Task 5.2 — Headless Keyfile Credential Store
- Task 5.2: Implement encrypted keyfile credential storage for headless/server deployments:
- Create
crates/chronogrid_crypto/src/keyfile.rs:KeyFilestruct: stores encrypted master key + salt in a file- Encryption: AES-256-GCM with a key derived from a server-specific secret (environment variable or systemd credential)
KeyFile::create(path: &Path, master_key: &[u8], server_secret: &[u8]) -> Result<()>KeyFile::load(path: &Path, server_secret: &[u8]) -> Result<Vec<u8>>
- Implement
chronogrid_crypto::resolve_key(config: &KeyConfig) -> Result<Vec<u8>>:- Tries OS keychain first (desktop mode)
- Falls back to keyfile (headless mode)
- Falls back to environment variable
CHRONOGRID_MASTER_KEY(CI/container mode)
- Update
chronogrid_daemonto useresolve_keyfor flexible credential resolution - Unit tests: keyfile create/load round-trip, wrong server secret rejection, env var fallback
- Run
cargo test --package chronogrid_crypto
- Create
Task 5.3 — Multi-Device Integration Test Suite
- Task 5.3: Create a comprehensive multi-device integration test suite:
- Create
tests/integration/directory at workspace root - Add
integration_testsas a workspace member with[[test]]targets - Implement
tests/integration/sync_convergence.rs:- Spawn two in-process
SwarmManagerinstances on loopback - Create a task on Node A while Node B is offline
- Reconnect nodes and verify task appears on Node B within 5 seconds
- Verify CRDT merge: concurrent title edits on both nodes converge to a single value
- Spawn two in-process
- Implement
tests/integration/crypto_pipeline.rs:- Full pipeline: passphrase → Argon2id → SQLCipher open → CRDT write → read back
- Verify wrong passphrase cannot open database
- Verify keychain store/retrieve round-trip
- Implement
tests/integration/ingestion_pipeline.rs:- Mock IMAP server → IMAP poller → AI processing → task created in DB
- File watcher → Markdown file drop → note + tasks created in DB
- Jot text → NLP pipeline → task with correct namespace, due date, duration
- Implement
tests/integration/caldav_sync.rs:- CalDAV server starts →
curlPROPFIND → verify calendar collection response - Create time block → verify iCalendar VEVENT in REPORT response
- CalDAV server starts →
- Run
cargo test --test sync_convergence --test crypto_pipeline --test ingestion_pipeline --test caldav_sync
- Create
Task 5.4 — Performance & Stress Testing
- Task 5.4: Perform performance and stress testing:
- Implement
tests/perf/crdt_merge_stress.rs:- Generate 10,000 concurrent task mutations across 3 simulated peers
- Verify all peers converge to identical state within 30 seconds
- Measure merge throughput: target > 1,000 merges/second
- Implement
tests/perf/db_query_perf.rs:- Insert 50,000 tasks across 10 namespaces
- Measure query time for: list by namespace, filter by quadrant, filter by due date range
- Target: all queries < 50ms on standard hardware
- Implement
tests/perf/p2p_latency.rs:- Measure round-trip sync latency between two local peers
- Target: < 500ms for a single task delta sync on LAN
- Document performance results in
docs/ARCHITECTURE/06-performance-benchmarks.md - Run
cargo test --test crdt_merge_stress --test db_query_perf --test p2p_latency -- --nocapture
- Implement
Task 5.5 — Android Platform Integration
- Task 5.5: Complete Android platform integration:
- Configure Android NDK cross-compilation in
scripts/build_android_libs.sh:- Targets:
aarch64-linux-android(ARM64),armv7-linux-androideabi(ARM32),x86_64-linux-android(emulator) - Set
ANDROID_NDK_HOMEandCARGO_TARGET_*_LINKERenvironment variables - Build
chronogrid_ffifor all three targets - Copy
.sofiles to correctjniLibssubdirectories
- Targets:
- Implement Android KeyStore bridge in Flutter:
lib/src/core/android_keystore.dart— usesflutter_secure_storagefor Android KeyStore-backed key storage- Override
store_credential/retrieve_credentialFFI calls on Android with Dart-side KeyStore implementation
- Implement Android-specific features:
QuickJotWidget— home screen widget usinghome_widgetpackage- Share Intent receiver —
AndroidManifest.xmlintent filter forACTION_SENDtext/URL sharing - Background sync service —
WorkManagerperiodic task for P2P sync when app is backgrounded
- Test on Android emulator:
flutter run -d emulator-5554 - Test on physical Android device:
flutter run -d <device_id> - Run
flutter test— all tests pass on Android target
- Configure Android NDK cross-compilation in
Task 5.6 — Linux Platform Integration & AppImage Build
- Task 5.6: Complete Linux platform integration and AppImage packaging:
- Configure GTK3 dependencies in
apps/chronogrid_flutter/linux/CMakeLists.txt - Link
libchronogrid_ffi.soin Linux CMake build - Implement Linux-specific features:
- SecretService D-Bus integration (already in
chronogrid_cryptoviakeyringcrate) - Global hotkey via
global-hotkeycrate on Linux (X11/Wayland) - System tray icon using
tray_managerFlutter package
- SecretService D-Bus integration (already in
- Create
scripts/package_linux.sh:- Build Flutter Linux release:
flutter build linux --release - Package as AppImage using
appimagetool - Package as
.debusingdpkg-deb
- Build Flutter Linux release:
- Create
docs/DEPLOYMENT/02-linux-installation.md - Cross-compile from Windows using WSL2 or Docker:
docker run --rm -v $(pwd):/workspace rust:latest cargo build --release --target x86_64-unknown-linux-gnu --package chronogrid_ffi
- Configure GTK3 dependencies in
Task 5.7 — Windows MSI Installer
- Task 5.7: Create the Windows MSI installer:
- Add
wixtoolset configuration:apps/chronogrid_flutter/windows/installer/ - Create
Product.wxsWiX source file:- Application name, version, manufacturer metadata
- Install
chronogrid_flutter.exeandchronogrid_ffi.dlltoProgram Files\ChronoGrid\ - Install
chronogrid-daemon.exeas an optional Windows Service component - Desktop shortcut and Start Menu entry
- Uninstaller registration
- Create
scripts/build_windows_installer.ps1:flutter build windows --releasecargo build --release --package chronogrid_daemon- Run WiX toolset:
candle.exe Product.wxs && light.exe Product.wixobj -o ChronoGrid-Setup.msi
- Create
docs/DEPLOYMENT/03-windows-installation.md - Test installer on clean Windows VM
- Add
Task 5.8 — Systemd Service & Server Deployment Guide
- Task 5.8: Finalize systemd service configuration and server deployment documentation:
- Create
apps/chronogrid_daemon/deploy/chronogrid.service(systemd unit file):[Unit] Description=ChronoGrid Headless Peer Node After=network-online.target Wants=network-online.target [Service] Type=simple User=chronogrid Group=chronogrid WorkingDirectory=/var/lib/chronogrid ExecStart=/usr/local/bin/chronogrid-daemon --config /etc/chronogrid/config.toml Restart=on-failure RestartSec=10 StandardOutput=journal StandardError=journal SyslogIdentifier=chronogrid NoNewPrivileges=yes ProtectSystem=strict ProtectHome=yes ReadWritePaths=/var/lib/chronogrid [Install] WantedBy=multi-user.target - Create
apps/chronogrid_daemon/deploy/install.sh— automated server installation script - Update
docs/DEPLOYMENT/01-headless-daemon-setup.mdwith complete setup guide:- Prerequisites, binary installation, config file setup, keyfile credential setup, systemd enable/start, firewall rules, log monitoring
- Create
docs/DEPLOYMENT/04-multi-device-pairing.md— guide for pairing desktop + mobile + headless nodes using Swarm Key
- Create
Task 5.9 — Final Verification & Release Checklist
- Task 5.9: Execute final verification and prepare release:
- Run full test suite:
cargo test --workspace— zero failures - Run
scripts/verify_agent_work.ps1— exits with code 0 - Run integration tests: all convergence, crypto, ingestion, and CalDAV tests pass
- Run performance tests: all targets met (< 50ms queries, > 1,000 merges/sec, < 500ms P2P latency)
- Manual acceptance testing against all criteria in
docs/ARCHITECTURE/04-master-user-story.md:- IMAP polling creates tasks within 2 seconds of receipt
- Database is unreadable without master key
- Offline edits on two devices converge after reconnection without data loss
- All four UI views render from same CRDT state store
- Headless daemon builds for Linux/systemd and maintains CRDT state
- Update
docs/ARCHITECTURE/01-OSAD-system-architecture.mdSection 8 roadmap to mark all phases complete - Create
CHANGELOG.mdwith v1.0.0 release notes - Tag release:
git tag -a v1.0.0 -m "ChronoGrid P2P v1.0.0 — Initial Release" - Push tag:
git push origin v1.0.0
- Run full test suite:
Phase 5 Completion Criteria
- All 9 tasks above marked
[x] cargo test --workspacepasses with zero failures- All integration tests pass
- All performance targets met
- All 5 acceptance criteria from master user story verified manually
- Windows
.msiinstaller produced and tested - Linux
.AppImageand.debpackages produced - Android
.apkproduced and tested on physical device chronogrid-daemonbinary deployed and running on headless Linux serverv1.0.0git tag pushed togit.kellsupport.comDECISION_LOG.mdupdated with Phase 5 decisions- All ADRs up to date