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