Skip to main content

aion_context/
lib.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! AION v2: Versioned Truth Infrastructure for AI Systems
3//!
4//! AION v2 provides cryptographically-signed, versioned business context that AI systems
5//! can consume and prove they used. This solves the AI compliance crisis by providing
6//! mathematical proof instead of expensive retraining.
7//!
8//! # Features
9//!
10//! - **Local-first**: Zero server dependency, works offline
11//! - **Cryptographically-signed**: Ed25519 signatures for tamper-proof versioning
12//! - **Embedded audit trails**: Complete history of all changes
13//! - **OS keyring integration**: Secure key storage using platform keychains
14//! - **Zero panics**: Tiger Style implementation with explicit error handling
15//!
16//! # Architecture
17//!
18//! - **Core Types**: Type-safe domain identifiers (`FileId`, `AuthorId`, `VersionNumber`)
19//! - **Cryptography**: Ed25519, ChaCha20-Poly1305, Blake3, HKDF
20//! - **File Format**: Binary format with zero-copy parsing
21//! - **Operations**: init, commit, verify, show
22//! - **CLI**: Command-line interface for all operations
23//!
24//! # Example
25//!
26//! ```rust,no_run
27//! # use aion_context::Result;
28//! # fn example() -> Result<()> {
29//! // Future API example - not yet implemented
30//! // let file_id = aion_context::init_file("policy.aion", &rules)?;
31//! // let version = aion_context::commit_version("policy.aion", &updated_rules)?;
32//! // let verification = aion_context::verify_file("policy.aion")?;
33//! # Ok(())
34//! # }
35//! ```
36//!
37//! # Safety and Security
38//!
39//! This library follows NASA Power of 10 rules and Tiger Style:
40//! - No `unwrap()`, `expect()`, or `panic!()` in production code
41//! - All errors explicit with context
42//! - Constant-time cryptographic operations
43//! - Zeroization of sensitive data
44//! - Maximum function size: 60 lines
45//! - Maximum cyclomatic complexity: 15
46//!
47//! # Performance Targets
48//!
49//! - File creation: <10ms for 1MB rules
50//! - Version commit: <5ms for 1MB rules
51//! - Signature verification: <1ms per version
52//! - File parsing: <3ms for 100-version file
53
54// Enforce Tiger Style at the crate level
55// Note: unwrap_used, expect_used, panic, etc. are enforced via Cargo.toml clippy lints
56#![warn(missing_docs, unsafe_code, unused_must_use)]
57
58// Module structure (to be implemented in future issues)
59pub mod aibom; // RFC-0029: AI Bill of Materials
60pub mod audit; // Issue #7: Audit trail
61pub mod compliance; // Issue #33: Compliance reporting
62pub mod conflict; // Issue #30: Conflict resolution
63pub mod crypto; // Issue #4: Cryptography
64pub mod dsse; // RFC-0023: DSSE envelope support
65pub mod error; // Issue #3: Error handling
66pub mod export; // Issue #31: Export/Import formats
67pub mod hw_attestation; // RFC-0026: Hardware attestation binding
68pub mod hybrid_sig; // RFC-0027: Post-quantum hybrid signatures
69pub mod jcs; // RFC-0031: RFC 8785 JSON canonicalization
70pub mod key_registry; // RFC-0028: Key rotation and revocation
71pub mod keystore; // Issue #12: Key generation and storage
72pub mod manifest; // RFC-0022: External artifact manifest
73pub mod multisig; // Issue #29: Multi-signature support
74pub mod oci; // RFC-0030: OCI artifact packaging
75pub mod operations; // Issue #15: Version commit operation
76pub mod parser; // Issue #9: Zero-copy parser
77pub mod release; // RFC-0032: Release orchestration
78pub mod serializer; // Issue #10: Deterministic Serializer
79pub mod signature_chain; // Issue #14: Version signing protocol
80pub mod slsa; // RFC-0024: SLSA v1.1 provenance emitter
81pub mod string_table; // Issue #8: String table
82pub mod transparency_log; // RFC-0025: Aion-native transparency log
83pub mod types; // Issue #2: Core types
84
85// Internal helpers for tracing field formatting (issue #57). Not part
86// of the public API — see `.claude/rules/observability.md` for the
87// field-naming and cardinality discipline these helpers enforce.
88mod obs;
89// pub mod cli;          // CLI interface
90
91// Test helpers (only available during testing)
92#[cfg(any(test, feature = "test-helpers"))]
93pub mod test_helpers; // Issue #5: Testing Infrastructure
94
95// Public exports
96pub use error::{AionError, Result};
97
98#[cfg(test)]
99mod tests {
100    #[test]
101    fn test_crate_compiles() {
102        // Basic smoke test to ensure crate structure is valid
103        // This test passes if the crate compiles successfully
104    }
105}