-
-
Notifications
You must be signed in to change notification settings - Fork 863
Refactor/pure rust #406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Refactor/pure rust #406
Conversation
…, prosody engine, privacy guard, and learning engine
- Updated the `detect_and_clean` method to prioritize emotions based on intensity, allowing for multiple emotion tags in a message. - Improved regex patterns for better matching of emotion tags and markdown links. - Added tests to validate emotion priority handling and cleaning functionality. - Introduced a new `debug_prosody.rs` file for debugging purposes. Refactor Recovery Journal to Limit Snapshot Size - Implemented a maximum file size limit for snapshots in the `RecoveryJournal` to prevent excessive disk usage. - Added tests to ensure that large files are correctly rejected during snapshot attempts. Expand Skill Metadata Structure - Enhanced `SkillMetadata` to include version and author fields, along with science implementation details. - Updated the skill scanning logic to parse and store these new metadata fields. - Added tests to verify the correct parsing of skill metadata. Improve Skill Matching Logic - Refactored the `find_matching_skills` method to return a score based on the relevance of the match, allowing for better ranking of results. - Added tests to ensure the matching logic works as expected. Integration Tests Enhancements - Added various integration tests to validate the functionality of the prosody engine, recovery journal, and skill registry. - Ensured comprehensive coverage of new features and edge cases.
…ality with YAML loading and retrieval methods
…ine, ensuring cleaner output generation
…ding SSRF prevention, command whitelisting, and data leakage protection
…cy using OnceLock in multiple components
…rmance and readability
- Implement async I/O using tokio::fs for all persistence modules - Add domain-specific error handling with thiserror - Implement Black Swan protections: file size limits, path sanitization, recursion checks - Harden VerificationOracle against command injection and SSRF - Enhance PrivacyGuard with content redaction for API keys - Optimize regex usage with OnceLock pre-compilation - Fix all failing integration tests (81 passing)
|
Why refactor in rust? Don't get me wrong, I prefer Rust too, but is this an important refactor for now? The stuff works, many other things to work on that are more important imo. |
|
you could literally just have your preferred language be rust, and then all your core apps would run it.... No? |
It fit my needs, and I'm open to sharing what works for me, in case others need it too. Also, its importance is irrelevant against the fact that it's already been accomplished non-destructively. This code does no harm to the main branch, notice it's only additions. |
I don't understand this question, could you elaborate? |
https://github.com/prodbybuddha/agency is why I refactored to rust, fyi. |
in the core pai, system core skill defines your preferred languages, etc. Then, all of the apps can be built in your preferred language. You just tell your PAI to do so right? |
Ah, thank you for clarifying. Yes, I suppose that's an option. However, that's not my reasoning behind this refactor. It has everything to do with leveraging memory safety benefits, concurrency and the other tropes that come along with utilizing Rust, toward the semi-autonomous agent I've been building, which is native to this programming language. In effect, if I defined Rust to be my preferred skill to PAI, it simply would honor that preference, only running on Rust in this instance. https://github.com/prodbybuddha/agency |
PR Description: Personal AI Infrastructure (PAI) Core - Rust Implementation
🎯 Overview
This PR introduces the pai-core crate, a high-performance, security-hardened Rust implementation of the Personal AI Infrastructure.
It transitions the core "Agency" logic into an adversarial-grade intelligence fabric, focusing on deterministic state management,
rigorous security validation, and modular "intelligence threads."
🏗️ Architectural Pillars
1. Deterministic Intelligence (algorithm.rs)
The heart of the crate is the Algorithm Engine, a deterministic state machine that drives the PAI lifecycle through 7 distinct
phases:
Done).
2. Adversarial-Grade Security (safety.rs, oracle.rs, privacy.rs)
SecurityValidator: A PAIHook that intercepts tool usage to block catastrophic commands (rm -rf /), reverse shells, and dataexfiltration patterns.
VerificationOracle: Restricts execution to a strict whitelist and implements SSRF Protection by enforcing HTTPS for externallookups and blocking internal IP probing.
PrivacyGuard: Automated PII redaction for API keys, Bearer tokens, and internal IPs using pre-compiled regex patterns.3. Modular Intelligence Fabric
prosody.rs: A linguistic cleaning engine that detects emotional markers (e.g., [🚨 urgent], [✨ success]) to adjust speechsynthesis parameters while stripping markdown for high-fidelity audio output.
telos.rs: Deep context management that aligns agent actions with core user values, missions, and beliefs.swarm.rs: Aggregation logic for multi-agent consensus, utilizing Pareto-optimal selection to maximize quality while minimizingrisk.
4. Memory & Observability (memory.rs, learning.rs, observability.rs)
for future tasks.
⚡ Technical Highlights
cloning.
🧪 Testing State
📦 Dependencies
Part of the Personal AI Infrastructure (PAI) Project.