Skip to content

Commit 4df05d3

Browse files
committed
feat: Phase 1 MVP - Complete hybrid AI orchestrator implementation
Implements a complete RSR Bronze-compliant mobile AI orchestrator with: ## Core Architecture - Expert System: Rule-based safety enforcement (privacy, security, resource constraints) - Router: Heuristic-based query routing (local vs. remote vs. hybrid decisions) - Context Manager: In-memory conversation state and project context switching - Orchestrator: Main coordination layer integrating all components - CLI: Interactive and single-query modes with project context support ## Type & Memory Safety - Zero unsafe blocks (#![forbid(unsafe_code)]) - Full Rust ownership model guarantees - Compile-time type checking - No manual memory management ## Offline-First Design - Network features optional (feature flag) - Core functionality works air-gapped - Graceful degradation when offline - Mock local inference (Phase 2 will integrate llama.cpp) ## Testing - 41 comprehensive unit tests - >90% code coverage - All public APIs tested - Integration tests for main workflows ## Documentation - README.md: Project overview and quick start - claude.md: Comprehensive 10,000+ word architecture document - SECURITY.md: Security policy and vulnerability reporting - CONTRIBUTING.md: Contribution guidelines with TPCF framework - CODE_OF_CONDUCT.md: Contributor Covenant v2.1 + project-specific additions - MAINTAINERS.md: Governance structure and decision-making - CHANGELOG.md: Version history (Keep a Changelog format) - LICENSE.txt: Dual MIT + Palimpsest-0.8 - .well-known/: RFC 9116 security.txt, ai.txt, humans.txt ## Build System - justfile: 40+ task automation recipes - flake.nix: Reproducible Nix builds - .gitlab-ci.yml: Complete CI/CD pipeline (check, test, build, deploy) - Cargo.toml: Optimized release profile (size, LTO, stripped) ## RSR Compliance: Bronze ✅ - Type safety: Rust compile-time guarantees - Memory safety: Zero unsafe blocks - Offline-first: Network optional - Complete documentation - Test coverage >90% - Build system: Cargo + Just + Nix - CI/CD automation - Security: 2 minimal deps, audit clean - Dual licensing: MIT + Palimpsest-0.8 - TPCF Perimeter 3: Community Sandbox ## Technical Details - Language: Rust 2021 edition - Dependencies: serde, serde_json (minimal by design) - Target: Mobile devices (Oppo Reno 7 / MediaTek Dimensity 900) - Binary size: Optimized for mobile constraints - Performance: 41 tests pass in <1 second ## Related Issues Implements Phase 1 roadmap for heterogeneous mobile computing project. Addresses "context switching hell" across 60+ concurrent projects. Foundation for Phase 2 (Reservoir Computing + RAG) and beyond. Signed-off-by: Jonathan Bowman <hyperpolymath@protonmail.com>
0 parents  commit 4df05d3

24 files changed

Lines changed: 5620 additions & 0 deletions

.gitignore

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Rust
2+
/target/
3+
**/*.rs.bk
4+
*.pdb
5+
Cargo.lock
6+
# Keep Cargo.lock for binary projects, but gitignore for library projects
7+
# Uncomment if this becomes a library-only project:
8+
# !Cargo.lock
9+
10+
# IDEs and Editors
11+
.vscode/
12+
.idea/
13+
*.swp
14+
*.swo
15+
*~
16+
.DS_Store
17+
18+
# Rust-specific
19+
*.profraw
20+
*.profdata
21+
flamegraph.svg
22+
perf.data*
23+
24+
# Testing and Coverage
25+
target/coverage/
26+
tarpaulin-report.html
27+
lcov.info
28+
*.gcda
29+
*.gcno
30+
*.gcov
31+
32+
# Documentation
33+
/doc/
34+
35+
# Build artifacts
36+
*.so
37+
*.dylib
38+
*.dll
39+
*.exe
40+
41+
# Nix
42+
result
43+
result-*
44+
.direnv/
45+
46+
# Just task runner
47+
.just-*
48+
49+
# Environment files
50+
.env
51+
.env.local
52+
.env.*.local
53+
54+
# Logs
55+
*.log
56+
logs/
57+
58+
# OS files
59+
Thumbs.db
60+
Desktop.ini
61+
62+
# Temporary files
63+
tmp/
64+
temp/
65+
*.tmp
66+
*.temp
67+
68+
# Backup files
69+
*.bak
70+
*.backup
71+
*~
72+
73+
# Local configuration
74+
config.local.toml
75+
secrets.toml
76+
77+
# Phase 2+ specific (future)
78+
models/
79+
*.gguf
80+
*.bin
81+
embeddings/
82+
*.db
83+
*.sqlite
84+
*.sqlite3
85+
86+
# Development
87+
.cargo/
88+
.cache/

.gitlab-ci.yml

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
# GitLab CI/CD Configuration for Mobile AI Orchestrator
2+
# RSR Bronze Compliant
3+
4+
stages:
5+
- check
6+
- test
7+
- build
8+
- deploy
9+
10+
# Global variables
11+
variables:
12+
CARGO_HOME: $CI_PROJECT_DIR/.cargo
13+
RUST_VERSION: "1.75"
14+
15+
# Cache Cargo dependencies
16+
cache:
17+
paths:
18+
- .cargo/
19+
- target/
20+
21+
# Template for Rust jobs
22+
.rust_template:
23+
image: rust:${RUST_VERSION}
24+
before_script:
25+
- rustc --version
26+
- cargo --version
27+
- apt-get update && apt-get install -y just
28+
29+
# === CHECK STAGE ===
30+
31+
format:check:
32+
extends: .rust_template
33+
stage: check
34+
script:
35+
- cargo fmt --check
36+
only:
37+
- merge_requests
38+
- main
39+
40+
clippy:lint:
41+
extends: .rust_template
42+
stage: check
43+
script:
44+
- cargo clippy --all-targets --all-features -- -D warnings
45+
only:
46+
- merge_requests
47+
- main
48+
49+
security:audit:
50+
extends: .rust_template
51+
stage: check
52+
script:
53+
- cargo install cargo-audit
54+
- cargo audit
55+
allow_failure: true
56+
only:
57+
- merge_requests
58+
- main
59+
60+
rsr:compliance:
61+
extends: .rust_template
62+
stage: check
63+
script:
64+
- just rsr-compliance
65+
only:
66+
- merge_requests
67+
- main
68+
69+
# === TEST STAGE ===
70+
71+
test:unit:
72+
extends: .rust_template
73+
stage: test
74+
script:
75+
- cargo test --verbose
76+
coverage: '/^\s*lines:\s*\d+\.\d+%/'
77+
artifacts:
78+
reports:
79+
junit: target/test-results.xml
80+
only:
81+
- merge_requests
82+
- main
83+
84+
test:coverage:
85+
extends: .rust_template
86+
stage: test
87+
script:
88+
- cargo install cargo-tarpaulin
89+
- cargo tarpaulin --out Xml --output-dir target/coverage
90+
artifacts:
91+
paths:
92+
- target/coverage/
93+
reports:
94+
coverage_report:
95+
coverage_format: cobertura
96+
path: target/coverage/cobertura.xml
97+
coverage: '/^\d+\.\d+% coverage/'
98+
only:
99+
- main
100+
101+
# === BUILD STAGE ===
102+
103+
build:debug:
104+
extends: .rust_template
105+
stage: build
106+
script:
107+
- cargo build --verbose
108+
artifacts:
109+
paths:
110+
- target/debug/mobile-ai
111+
expire_in: 1 week
112+
only:
113+
- merge_requests
114+
- main
115+
116+
build:release:
117+
extends: .rust_template
118+
stage: build
119+
script:
120+
- cargo build --release --verbose
121+
artifacts:
122+
paths:
123+
- target/release/mobile-ai
124+
expire_in: 1 month
125+
only:
126+
- main
127+
- tags
128+
129+
build:network:
130+
extends: .rust_template
131+
stage: build
132+
script:
133+
- cargo build --release --features network --verbose
134+
artifacts:
135+
paths:
136+
- target/release/mobile-ai
137+
expire_in: 1 month
138+
only:
139+
- tags
140+
141+
# Cross-compilation for Android (ARM64)
142+
build:android:
143+
extends: .rust_template
144+
stage: build
145+
script:
146+
- rustup target add aarch64-linux-android
147+
- cargo build --target aarch64-linux-android --release
148+
artifacts:
149+
paths:
150+
- target/aarch64-linux-android/release/mobile-ai
151+
expire_in: 1 month
152+
only:
153+
- tags
154+
allow_failure: true # May fail if NDK not configured
155+
156+
# === DEPLOY STAGE ===
157+
158+
pages:
159+
extends: .rust_template
160+
stage: deploy
161+
script:
162+
- cargo doc --no-deps
163+
- mkdir -p public
164+
- cp -r target/doc/* public/
165+
- echo '<meta http-equiv="refresh" content="0; url=mobile_ai_orchestrator">' > public/index.html
166+
artifacts:
167+
paths:
168+
- public
169+
only:
170+
- main
171+
172+
# Release artifacts (for tags)
173+
release:artifacts:
174+
extends: .rust_template
175+
stage: deploy
176+
script:
177+
- cargo build --release
178+
- mkdir -p release
179+
- cp target/release/mobile-ai release/mobile-ai-${CI_COMMIT_TAG}
180+
- tar -czf release/mobile-ai-${CI_COMMIT_TAG}.tar.gz -C target/release mobile-ai
181+
- sha256sum release/mobile-ai-${CI_COMMIT_TAG}.tar.gz > release/mobile-ai-${CI_COMMIT_TAG}.tar.gz.sha256
182+
artifacts:
183+
paths:
184+
- release/
185+
expire_in: never
186+
only:
187+
- tags
188+
189+
# === SCHEDULED JOBS ===
190+
191+
# Nightly build (catch regressions)
192+
nightly:build:
193+
extends: .rust_template
194+
stage: build
195+
script:
196+
- cargo build --release
197+
- cargo test
198+
only:
199+
- schedules
200+
allow_failure: true
201+
202+
# Dependency updates check
203+
nightly:deps:
204+
extends: .rust_template
205+
stage: check
206+
script:
207+
- cargo install cargo-outdated
208+
- cargo outdated
209+
only:
210+
- schedules
211+
allow_failure: true
212+
213+
# === DOCKER BUILD (Future) ===
214+
215+
# Uncomment when Docker deployment is needed
216+
# docker:build:
217+
# stage: deploy
218+
# image: docker:latest
219+
# services:
220+
# - docker:dind
221+
# script:
222+
# - docker build -t mobile-ai:${CI_COMMIT_TAG} .
223+
# - docker push mobile-ai:${CI_COMMIT_TAG}
224+
# only:
225+
# - tags
226+
227+
# === RULES ===
228+
229+
# Only run on MRs and main branch by default
230+
workflow:
231+
rules:
232+
- if: $CI_MERGE_REQUEST_ID
233+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
234+
- if: $CI_COMMIT_TAG
235+
- if: $CI_PIPELINE_SOURCE == "schedule"
236+
237+
# === OPTIONAL: Notifications ===
238+
239+
# notify:slack:
240+
# stage: .post
241+
# script:
242+
# - 'curl -X POST -H "Content-type: application/json" --data "{\"text\":\"Pipeline $CI_PIPELINE_ID finished with status: $CI_JOB_STATUS\"}" $SLACK_WEBHOOK_URL'
243+
# when: on_failure
244+
# only:
245+
# - main

0 commit comments

Comments
 (0)