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