Skip to main content

feagi_evolutionary/
lib.rs

1// Copyright 2025 Neuraville Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4/*!
5# FEAGI Evolution & Genome Management
6
7Handles all **genotype** operations for FEAGI:
8
9- Genome I/O (JSON ↔ Rust structs)
10- Genome validation
11- Evolution operators (mutation, crossover)
12- Fitness evaluation
13- Population management
14
15## Architecture
16
17This crate manages the **genetic blueprint** (genotype) of FEAGI brains.
18The actual instantiated brain structure (phenotype) is handled by `feagi-bdu`.
19
20## Separation of Concerns
21
22```text
23feagi-evo (Genotype)        feagi-bdu (Phenotype)
24─────────────────────       ─────────────────────
25│ Genome JSON I/O    │  →   │ Neuroembryogenesis │
26│ Genome Validation  │      │ Connectome I/O      │
27│ Evolution Ops      │      │ Synaptogenesis      │
28│ Fitness Eval       │      │ NPU Integration     │
29└────────────────────┘      └─────────────────────┘
30```
31
32## Modules
33
34- `genome` - Genome I/O and validation
35- `evaluation` - `GenomeEvaluation` records: fitness + genome-only lineage (ADR-016)
36- `evolution` - Evolution operators (future)
37- `fitness` - Fitness evaluation (future)
38- `population` - Population management (future)
39
40Copyright 2025 Neuraville Inc.
41Licensed under the Apache License, Version 2.0
42*/
43
44/// Crate version from Cargo.toml
45pub const VERSION: &str = env!("CARGO_PKG_VERSION");
46
47// Core modules
48mod amalgamation_remap;
49pub mod converter_flat;
50pub mod converter_flat_full;
51pub mod converter_hierarchical_to_flat;
52pub mod cortical_type_parser;
53pub mod evaluation;
54pub mod genome;
55pub mod plasticity_detector;
56pub mod random;
57pub mod runtime;
58pub mod storage;
59pub mod templates;
60pub mod types;
61pub mod validator;
62
63// Re-export commonly used types
64pub use amalgamation_remap::{
65    designated_io_lists_for_cloned_circuit, remap_guest_custom_memory_cortical_ids_for_amalgamation,
66};
67pub use converter_flat::convert_flat_to_hierarchical;
68pub use converter_flat_full::convert_flat_to_hierarchical_full;
69pub use converter_hierarchical_to_flat::convert_hierarchical_to_flat;
70pub use cortical_type_parser::{parse_cortical_type, validate_cortical_type};
71pub use evaluation::{
72    ComparabilityKey, ConfidenceInterval, EvaluationError, EvaluationId, ExperimentId,
73    FitnessEstimate, FitnessObjective, FitnessOutcome, FitnessSpec, GenomeEvaluation, GenomeOrigin,
74    Lineage,
75};
76pub use genome::parser::string_to_cortical_id;
77pub use genome::{
78    apply_genome_title_to_unique_top_circuit, decode_genome_artifact, encode_genome_artifact,
79    load_genome_artifact_with_report, load_genome_from_artifact, load_genome_from_file,
80    load_genome_from_json, load_genome_value_with_report, load_genome_with_report,
81    load_genome_with_report_from_file, migrate_genome, migrate_genome_json_to_current,
82    migrate_genome_value_to_current, peek_quantization_precision, save_genome_to_file,
83    save_genome_to_json, subset_runtime_genome_for_region_branch,
84    validate_genome_artifact_file_name, wrap_parentless_regions_under_named_root, ChainResult,
85    GenomeArtifactCodec, GenomeArtifactEncoding, GenomeParser, GenomeSaver,
86    JsonGenomeArtifactCodec, MigrationResult, ParsedGenome, GENOME_ARTIFACT_EXTENSION,
87    GENOME_ARTIFACT_MEDIA_TYPE,
88};
89pub use plasticity_detector::{
90    extract_memory_properties, genome_has_plasticity, MemoryAreaProperties,
91};
92pub use runtime::{
93    GenomeMetadata, GenomeSignatures, GenomeStats, Morphology, MorphologyParameters,
94    MorphologyRegistry, MorphologyType, PatternElement, PhysiologyConfig, RuntimeGenome,
95};
96#[cfg(feature = "async-tokio")]
97pub use storage::fs_storage::FileSystemStorage;
98pub use storage::{GenomeStorage, StorageError};
99pub use templates::{
100    add_core_morphologies, create_death_area, create_fatigue_area, create_fear_area,
101    create_genome_with_core_areas, create_genome_with_core_morphologies, create_hope_area,
102    create_minimal_genome, create_pain_area, create_pleasure_area, create_power_area,
103    ensure_core_components, get_default_neural_properties, load_barebones_genome,
104    load_essential_genome, load_test_genome, load_vision_genome, BAREBONES_GENOME_JSON,
105    ESSENTIAL_GENOME_JSON, TEST_GENOME_JSON, VISION_GENOME_JSON,
106};
107pub use types::{EvoError, EvoResult};
108pub use validator::{validate_genome, ValidationResult};