"""
helix_cdc/capsules - Four-Layer Capsule Schema

Layers:
1. Genotype - seed/architecture/topology/quant profile
2. BloodType - domain, safety_class, compat_class, rh_like_flags
3. InstanceResidual - optional clone-mode layer for exact instance regeneration
4. CryptoDNA - crypto-style regenerative substrate (WO#50)

v0.1: Initial implementation with naive XOR residuals for clone-mode proving.
v0.2: Added CryptoDNA layer for regenerative encoding via RSA-style padding + CRT.
"""

from .schema import (
    Genotype,
    BloodType,
    InstanceResidual,
    CryptoDNA,
    CapsuleManifest,
    attach_instance_residual,
)

from .instance_residual import (
    compute_xor_residual,
    reconstruct_regen_from_baseline_and_residual,
)

from .crypto_dna import (
    b64_to_bigint,
    bigint_to_b64,
    factorize_genome,
    genome_to_codon_streams,
    dna_to_codon_stream,
    codon_stream_to_growth_ops,
    full_genome_pipeline,
    CodonStream,
    GenomeFactors,
)

from .crypto_padding import (
    apply_crypto_padding,
    parse_padded_genome,
    build_full_padding,
    PaddingConfig,
    RegulatoryRegion,
    FibPi3DOffsets,
    GrowthSwitches,
    EpigeneticFlags,
)

from .crypto_crt import (
    crt_two,
    crt_multi,
    crt_recombine,
    crt_growth_pipeline,
    derive_crt_layout,
    CRTLayout,
)

from .crypto_regen import (
    map_to_fibpi3d,
    apply_cdc_growth,
    phenotype_to_tensor,
    phenotype_to_bytes,
    crypto_dna_to_cdc_ops,
    full_crypto_regen_pipeline,
    GrowthState,
    PhenotypeOutput,
)

__all__ = [
    # Schema classes
    'Genotype',
    'BloodType',
    'InstanceResidual',
    'CryptoDNA',
    'CapsuleManifest',
    'attach_instance_residual',
    # Clone mode
    'compute_xor_residual',
    'reconstruct_regen_from_baseline_and_residual',
    # Crypto-DNA
    'b64_to_bigint',
    'bigint_to_b64',
    'factorize_genome',
    'genome_to_codon_streams',
    'dna_to_codon_stream',
    'codon_stream_to_growth_ops',
    'full_genome_pipeline',
    'CodonStream',
    'GenomeFactors',
    # Padding
    'apply_crypto_padding',
    'parse_padded_genome',
    'build_full_padding',
    'PaddingConfig',
    'RegulatoryRegion',
    'FibPi3DOffsets',
    'GrowthSwitches',
    'EpigeneticFlags',
    # CRT
    'crt_two',
    'crt_multi',
    'crt_recombine',
    'crt_growth_pipeline',
    'derive_crt_layout',
    'CRTLayout',
    # Regen
    'map_to_fibpi3d',
    'apply_cdc_growth',
    'phenotype_to_tensor',
    'phenotype_to_bytes',
    'crypto_dna_to_cdc_ops',
    'full_crypto_regen_pipeline',
    'GrowthState',
    'PhenotypeOutput',
]
