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;
40#[cfg(feature = "plasticity")]
41pub mod memory_mp_mode;
42pub mod neuroembryogenesis;
43pub mod region_io_designation;
44mod rng;
45pub mod spatial;
46pub mod types;
47
48// Note: models/ and genome/ have been moved to feagi-types and feagi-evo respectively
49
50// Re-export NPU-native synaptogenesis functions (primary API)
51pub use connectivity::{
52    apply_block_connection_morphology, apply_expander_morphology, apply_patterns_morphology,
53    apply_projector_morphology, apply_vectors_morphology,
54};
55
56pub use spatial::{morton_decode_3d, morton_encode_3d, MortonSpatialHash, SpatialHashStats};
57
58// Re-export local BDU types
59pub use region_io_designation::{
60    merged_designated_lists, parse_designated_id_list, validate_cross_region_mapping_proposal,
61    validate_merged_designations_against_connectivity, DESIGNATED_INPUTS_KEY,
62    DESIGNATED_OUTPUTS_KEY,
63};
64pub use types::{AreaId, BduError, BduResult, Weight};
65
66// Re-export core types from feagi_data_structures (single source of truth)
67pub use feagi_structures::genomic::cortical_area::{
68    CorticalArea, CorticalAreaDimensions as Dimensions, CorticalID,
69};
70pub use feagi_structures::genomic::{BrainRegion, RegionType};
71pub mod models;
72pub use models::{BrainRegionHierarchy, CorticalAreaExt};
73
74// Re-export Position from local types
75pub use types::Position;
76
77// Re-export genome operations from feagi-evo
78pub use feagi_evolutionary::{GenomeParser, GenomeSaver, ParsedGenome};
79
80// Re-export connectome manager
81pub use connectome_manager::{BrainRegionIoRegistry, ConnectomeConfig, ConnectomeManager};
82
83// Re-export neuroembryogenesis
84pub use neuroembryogenesis::{DevelopmentProgress, DevelopmentStage, Neuroembryogenesis};
85
86#[cfg(feature = "plasticity")]
87pub use memory_mp_mode::{memory_lifecycle_config, memory_mp_mode};
88
89// Re-export cortical type utilities (Phase 3)
90pub use cortical_type_utils::{
91    describe_cortical_type, get_io_data_type, uses_absolute_frames, uses_cartesian_encoding,
92    uses_incremental_frames, uses_percentage_encoding, validate_connectivity,
93};
94
95#[cfg(test)]
96mod tests {
97    use super::*;
98
99    #[test]
100    fn test_basic_projection() {
101        // Smoke test to ensure modules compile
102        let result = connectivity::rules::syn_projector(
103            "src_area",
104            "dst_area",
105            42,
106            (128, 128, 3),
107            (128, 128, 1),
108            (0, 0, 0),
109            None,
110            None,
111        );
112        assert!(result.is_ok());
113    }
114}