Skip to main content

feagi_brain_development/
lib.rs

1// Copyright 2025 Neuraville Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4/*!
5# FEAGI BDU (Brain Development Utilities)
6
7This crate implements high-performance brain development operations including:
8- Synaptogenesis (synapse creation based on morphology rules)
9- Connectivity rules (projection, topology, patterns)
10- Spatial hashing and coordinate transformations
11
12## Architecture
13
14Mirrors the Python structure:
15- `feagi/bdu/connectivity/` → `feagi_brain_development::connectivity`
16- `feagi/bdu/morton_spatial_hash.py` → `feagi_brain_development::spatial`
17
18## Performance Goals
19
20- 40x-100x faster than Python implementation
21- Sub-second projection mappings for 128×128×20 areas
22- SIMD-optimized coordinate transformations
23- Parallel processing for large mappings
24
25## Python Integration
26
27NPU-native synaptogenesis functions are exposed via PyO3 bindings in `feagi-rust-py-libs`.
28Python code calls these functions directly with area IDs - no FFI overhead.
29
30Copyright 2025 Neuraville Inc.
31Licensed under the Apache License, Version 2.0
32*/
33
34/// Crate version from Cargo.toml
35pub const VERSION: &str = env!("CARGO_PKG_VERSION");
36
37pub mod connectivity;
38pub mod connectome_manager;
39pub mod cortical_type_utils;
40pub mod neuroembryogenesis;
41mod rng;
42pub mod spatial;
43pub mod types;
44
45// Note: models/ and genome/ have been moved to feagi-types and feagi-evo respectively
46
47// Re-export NPU-native synaptogenesis functions (primary API)
48pub use connectivity::{
49    apply_block_connection_morphology, apply_expander_morphology, apply_patterns_morphology,
50    apply_projector_morphology, apply_vectors_morphology,
51};
52
53pub use spatial::{morton_decode_3d, morton_encode_3d, MortonSpatialHash, SpatialHashStats};
54
55// Re-export local BDU types
56pub use types::{AreaId, BduError, BduResult, Weight};
57
58// Re-export core types from feagi_data_structures (single source of truth)
59pub use feagi_structures::genomic::cortical_area::{
60    CorticalArea, CorticalAreaDimensions as Dimensions, CorticalID,
61};
62pub use feagi_structures::genomic::{BrainRegion, RegionType};
63pub mod models;
64pub use models::{BrainRegionHierarchy, CorticalAreaExt};
65
66// Re-export Position from local types
67pub use types::Position;
68
69// Re-export genome operations from feagi-evo
70pub use feagi_evolutionary::{GenomeParser, GenomeSaver, ParsedGenome};
71
72// Re-export connectome manager
73pub use connectome_manager::{ConnectomeConfig, ConnectomeManager};
74
75// Re-export neuroembryogenesis
76pub use neuroembryogenesis::{DevelopmentProgress, DevelopmentStage, Neuroembryogenesis};
77
78// Re-export cortical type utilities (Phase 3)
79pub use cortical_type_utils::{
80    describe_cortical_type, get_io_data_type, uses_absolute_frames, uses_cartesian_encoding,
81    uses_incremental_frames, uses_percentage_encoding, validate_connectivity,
82};
83
84#[cfg(test)]
85mod tests {
86    use super::*;
87
88    #[test]
89    fn test_basic_projection() {
90        // Smoke test to ensure modules compile
91        let result = connectivity::rules::syn_projector(
92            "src_area",
93            "dst_area",
94            42,
95            (128, 128, 3),
96            (128, 128, 1),
97            (0, 0, 0),
98            None,
99            None,
100        );
101        assert!(result.is_ok());
102    }
103}