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- `circuit` - `CircuitObjectiveSpec`: circuit-level objectives and boundary resolution
37- `evolution` - Evolution operators (future)
38- `fitness` - Fitness evaluation (future)
39- `population` - Population management (future)
40
41Copyright 2025 Neuraville Inc.
42Licensed under the Apache License, Version 2.0
43*/
44
45/// Crate version from Cargo.toml
46pub const VERSION: &str = env!("CARGO_PKG_VERSION");
47
48// Core modules
49mod amalgamation_remap;
50pub mod circuit;
51pub mod converter_flat;
52pub mod converter_flat_full;
53pub mod converter_hierarchical_to_flat;
54pub mod cortical_type_parser;
55pub mod evaluation;
56pub mod genome;
57pub mod modulators;
58pub mod plasticity_detector;
59pub mod random;
60pub mod runtime;
61pub mod storage;
62pub mod templates;
63pub mod types;
64pub mod validator;
65
66// Re-export commonly used types
67pub use amalgamation_remap::{
68    designated_io_lists_for_cloned_circuit, remap_guest_custom_memory_cortical_ids_for_amalgamation,
69};
70pub use converter_flat::convert_flat_to_hierarchical;
71pub use converter_flat_full::convert_flat_to_hierarchical_full;
72pub use converter_hierarchical_to_flat::convert_hierarchical_to_flat;
73pub use cortical_type_parser::{parse_cortical_type, validate_cortical_type};
74pub use evaluation::{
75    ComparabilityKey, ConfidenceInterval, EvaluationError, EvaluationId, ExperimentId,
76    FitnessEstimate, FitnessObjective, FitnessOutcome, FitnessSpec, GenomeEvaluation, GenomeOrigin,
77    Lineage,
78};
79pub use genome::parser::string_to_cortical_id;
80pub use genome::{
81    apply_genome_title_to_unique_top_circuit, decode_genome_artifact, encode_genome_artifact,
82    load_genome_artifact_with_report, load_genome_from_artifact, load_genome_from_file,
83    load_genome_from_json, load_genome_value_with_report, load_genome_with_report,
84    load_genome_with_report_from_file, migrate_genome, migrate_genome_json_to_current,
85    migrate_genome_value_to_current, peek_quantization_precision, save_genome_to_file,
86    save_genome_to_json, subset_runtime_genome_for_region_branch,
87    validate_genome_artifact_file_name, wrap_parentless_regions_under_named_root, ChainResult,
88    GenomeArtifactCodec, GenomeArtifactEncoding, GenomeParser, GenomeSaver,
89    JsonGenomeArtifactCodec, MigrationResult, ParsedGenome, GENOME_ARTIFACT_EXTENSION,
90    GENOME_ARTIFACT_MEDIA_TYPE,
91};
92pub use modulators::{
93    driver_locked_properties, driver_locked_property_names, parse_modulator_registry,
94    ModulatorInstance, ModulatorRegistry, ModulatorWrite,
95};
96pub use plasticity_detector::{
97    extract_memory_properties, genome_has_plasticity, validate_memory_mp_properties,
98    LtmEvictionMode, MemoryAreaProperties, MpChangeMode, LTM_EVICTION_KEY, MEMORY_NEURON_CAP_KEY,
99    MP_CHANGE_MODE_KEY, MP_DELTA_QUANTIZATION_KEY, MP_LEARNING_ENABLED_KEY,
100    MP_RATIO_QUANTIZATION_KEY,
101};
102pub use runtime::{
103    GenomeMetadata, GenomeSignatures, GenomeStats, Morphology, MorphologyParameters,
104    MorphologyRegistry, MorphologyType, PatternElement, PhysiologyConfig, RuntimeGenome,
105};
106#[cfg(feature = "async-tokio")]
107pub use storage::fs_storage::FileSystemStorage;
108pub use storage::{GenomeStorage, StorageError};
109pub use templates::{
110    add_core_morphologies, create_death_area, create_fatigue_area, create_fear_area,
111    create_genome_with_core_areas, create_genome_with_core_morphologies, create_hope_area,
112    create_minimal_genome, create_pain_area, create_pleasure_area, create_power_area,
113    ensure_core_components, get_default_neural_properties, load_barebones_genome,
114    load_essential_genome, load_test_genome, load_vision_genome, BAREBONES_GENOME_JSON,
115    ESSENTIAL_GENOME_JSON, TEST_GENOME_JSON, VISION_GENOME_JSON,
116};
117pub use types::{EvoError, EvoResult};
118pub use validator::{validate_genome, ValidationResult};