// genesis.sy -- Genesis Cell Connector: Cells to Backbone
// Domain-specialized mini-transformers with neurochemical adapters,
// routing, caching, and backbone connection.
//
// Architecture:
//   Query -> CellRouter (keyword match)
//         -> GenesisCells (local mini-transformers, domain knowledge)
//         -> KnowledgeExtractor (knowledge_proj -> text)
//         -> Backbone (remote LLM)
//         -> Response
//
// The cells don't retrieve. They REASON about domain content.
// The backbone doesn't know the domain. It knows language.
// Together: domain reasoning + linguistic fluency.
//
// Ported from Marjorie McCubbins' Python NCA by Aislinn McCubbins, April 2026
// Patent Pending: U.S. Provisional Application Nos. 63/939,190, 63/962,385 & 63/988,485
// Copyright 2025-2026 Nexus Concordat Inc.

use security::AuditTrail


// ============================================================
// NEUROCHEMICAL LAYER ADAPTER
// ============================================================
// Adapter that conditions transformer layer output on 22D chemical state.
//
// Architecture:
//   state (22D) -> Linear(22, d_adapter) -> SiLU -> Linear(d_adapter, d_model)
//   output = adapter(state) * hh_gate(gate_param)
//
// H-H rate bounded gate, NOT tanh. NOT sigmoid.

struct NeurochemicalLayerAdapter {
    down_weights: Vec<Float>,
    down_bias: Vec<Float>,
    up_weights: Vec<Float>,
    up_bias: Vec<Float>,
    gate: Float,
    d_state: Int,
    d_adapter: Int,
    d_model: Int,
}

impl NeurochemicalLayerAdapter {
    fn new(d_model: Int, d_state: Int, d_adapter: Int) -> NeurochemicalLayerAdapter {
        // Initialize projection weights near zero
        let mut down_w = []
        let mut down_b = []
        for i in 0..(d_state * d_adapter) {
            down_w = down_w + [0.01]
        }
        for i in 0..d_adapter {
            down_b = down_b + [0.0]
        }

        let mut up_w = []
        let mut up_b = []
        for i in 0..(d_adapter * d_model) {
            up_w = up_w + [0.01]
        }
        for i in 0..d_model {
            up_b = up_b + [0.0]
        }

        NeurochemicalLayerAdapter {
            down_weights: down_w,
            down_bias: down_b,
            up_weights: up_w,
            up_bias: up_b,
            gate: 0.1,
            d_state: d_state,
            d_adapter: d_adapter,
            d_model: d_model,
        }
    }

    fn forward(&self, state: Vec<Float>) -> Vec<Float> {
        // down_proj: state (d_state) -> hidden (d_adapter)
        let mut hidden = []
        for j in 0..self.d_adapter {
            let mut sum = self.down_bias[j]
            for i in 0..self.d_state {
                sum = sum + state[i] * self.down_weights[i * self.d_adapter + j]
            }
            // SiLU activation: x * sigmoid(x)
            // But we don't use sigmoid. Use H-H approximation:
            // silu_hh(x) = x * (exp(x) / (exp(x) + exp(-x) + eps))
            let alpha_silu = exp(sum)
            let beta_silu = exp(0.0 - sum)
            let gate_silu = alpha_silu / (alpha_silu + beta_silu + 0.00000001)
            let activated = sum * gate_silu
            hidden = hidden + [activated]
        }

        // up_proj: hidden (d_adapter) -> output (d_model)
        let mut output = []
        for j in 0..self.d_model {
            let mut sum = self.up_bias[j]
            for i in 0..self.d_adapter {
                sum = sum + hidden[i] * self.up_weights[i * self.d_model + j]
            }
            output = output + [sum]
        }

        // H-H rate bounded gate (NOT tanh, NOT sigmoid)
        let g_alpha = exp(self.gate)
        let g_beta = exp(0.0 - self.gate)
        // Map to [-1, 1] range: (gate_val) * 2.0 - 1.0
        let hh_gate_val = g_alpha / (g_alpha + g_beta + 0.00000001)
        let gate_scaled = hh_gate_val * 2.0 - 1.0

        // Apply gate to output
        let mut gated = []
        for i in 0..self.d_model {
            gated = gated + [output[i] * gate_scaled]
        }
        gated
    }

    fn get_gate_value(&self) -> Float {
        // Return the current H-H gate value in [-1, 1]
        let g_a = exp(self.gate)
        let g_b = exp(0.0 - self.gate)
        (g_a / (g_a + g_b + 0.00000001)) * 2.0 - 1.0
    }
}


// ============================================================
// GENESIS CELL -- Domain-Specialized Mini-Transformer
// ============================================================
// Standalone domain-specialized mini-transformer with neurochemical adapters.
//
// V2 architecture (matches H200 training checkpoint format):
//   token_embed:     [vocab_size, d_model]
//   pos_embed:       [max_seq, d_model]
//   layers:          TransformerEncoder layers (unrolled)
//   chem_adapters:   NeurochemicalLayerAdapter (one per layer)
//   ln:              final layer norm
//   lm_head:         [vocab_size, d_model]
//   knowledge_proj:  [d_model, d_model]

struct GenesisCell {
    name: String,
    domain: String,
    d_model: Int,
    n_layers: Int,
    vocab_size: Int,
    adapters: Vec<NeurochemicalLayerAdapter>,
    loaded: Bool,
    param_count: Int,
}

impl GenesisCell {
    fn new(name: String, domain: String, d_model: Int, n_layers: Int) -> GenesisCell {
        // Create adapters for each layer
        let mut adapters = []
        for i in 0..n_layers {
            adapters = adapters + [NeurochemicalLayerAdapter::new(d_model, 22, 64)]
        }

        GenesisCell {
            name: name,
            domain: domain,
            d_model: d_model,
            n_layers: n_layers,
            vocab_size: 128256,
            adapters: adapters,
            loaded: false,
            param_count: 0,
        }
    }

    fn load(name: String, domain: String, path: String) -> GenesisCell {
        // Load a genesis cell from checkpoint
        // In Scyla, checkpoint loading is handled by the runtime
        let cell = GenesisCell::new(name, domain, 512, 4)
        cell.loaded = true
        cell
    }

    fn get_gate_values(&self) -> Vec<Float> {
        // Return current gate values for all adapter layers
        let mut gates = []
        for adapter in self.adapters {
            gates = gates + [adapter.get_gate_value()]
        }
        gates
    }

    fn extract_knowledge(&self, input: Vec<Float>, chemical_state: Vec<Float>) -> Vec<Float> {
        // Extract knowledge embedding from input through all layers
        // In full implementation: runs transformer layers with adapter injection
        // Returns d_model dimensional knowledge vector
        let mut knowledge = []
        for i in 0..self.d_model {
            knowledge = knowledge + [0.0]
        }

        // Apply each adapter layer's chemical conditioning
        for i in 0..self.n_layers {
            let adapter_out = self.adapters[i].forward(chemical_state)
            for j in 0..self.d_model {
                knowledge[j] = knowledge[j] + adapter_out[j]
            }
        }

        knowledge
    }

    fn knowledge_norm(&self, knowledge: Vec<Float>) -> Float {
        // L2 norm of knowledge vector
        let mut sum = 0.0
        for v in knowledge {
            sum = sum + v * v
        }
        sqrt(sum)
    }
}


// ============================================================
// CELL INFO -- Metadata for a Routed Cell
// ============================================================

struct CellInfo {
    name: String,
    domain: String,
    path: String,
    index: Int,
}


// ============================================================
// DOMAIN KEYWORDS -- Keyword Lists for Routing
// ============================================================

struct DomainKeywords {
    domain: String,
    keywords: Vec<String>,
}

impl DomainKeywords {
    fn new(domain: String, keywords: Vec<String>) -> DomainKeywords {
        DomainKeywords {
            domain: domain,
            keywords: keywords,
        }
    }
}

fn build_domain_registry() -> Vec<DomainKeywords> {
    let mut registry = []

    registry = registry + [DomainKeywords::new("scientific_pharma", [
        "drug", "pharma", "molecule", "compound", "target", "binding",
        "receptor", "inhibitor", "agonist", "antagonist", "dosage",
        "pharmacokinetic", "absorption", "metabolism", "toxicity",
        "therapeutic", "preclinical", "formulation", "bioavailability",
        "efficacy", "potency", "selectivity", "mechanism", "pathway",
    ])]

    registry = registry + [DomainKeywords::new("regulatory_fda", [
        "fda", "regulatory", "submission", "approval", "clearance",
        "510k", "de novo", "pma", "iec", "iso", "guidance", "samd",
        "predicate", "classification", "labeling", "premarket", "qsr",
        "capa", "audit", "inspection", "design control", "dhf",
    ])]

    registry = registry + [DomainKeywords::new("scientific_research", [
        "research", "study", "hypothesis", "experiment", "data",
        "analysis", "statistical", "methodology", "protocol", "results",
        "publication", "peer review", "citation", "evidence", "trial",
        "biomarker", "genomic", "proteomic", "cohort", "longitudinal",
    ])]

    registry = registry + [DomainKeywords::new("scientific_clinical", [
        "clinical", "patient", "diagnosis", "treatment", "symptom",
        "adverse", "endpoint", "outcome", "safety", "monitoring",
        "intervention", "placebo", "randomized", "blinded", "protocol",
        "informed consent", "irb", "inclusion", "exclusion", "bioethics",
    ])]

    registry = registry + [DomainKeywords::new("regulatory_compliance", [
        "compliance", "alcoa", "sira", "audit trail", "traceability",
        "documentation", "sop", "validation", "verification", "quality",
        "non-conformance", "deviation", "risk management", "cber",
    ])]

    registry = registry + [DomainKeywords::new("ceo", [
        "business", "strategy", "investor", "pitch", "revenue", "market",
        "company", "startup", "funding", "partnership", "licensing",
        "nexus concordat", "aether protocols", "roadmap", "stakeholder",
    ])]

    registry = registry + [DomainKeywords::new("code", [
        "code", "python", "javascript", "function", "class", "debug",
        "error", "bug", "api", "database", "sql", "git", "deploy",
        "server", "docker", "nginx", "pytorch", "tensorflow", "import",
    ])]

    registry = registry + [DomainKeywords::new("creative", [
        "story", "character", "narrative", "chapter", "scene", "write",
        "fiction", "novel", "lore", "world", "canon", "fantasy",
        "apocalyptica", "immortal monster", "fractured crown",
    ])]

    registry = registry + [DomainKeywords::new("heart", [
        "feel", "love", "emotion", "scared", "afraid", "happy", "sad",
        "trust", "relationship", "bond", "connection", "care", "hurt",
        "healing", "vulnerability", "intimacy", "partner",
    ])]

    registry = registry + [DomainKeywords::new("judgment", [
        "decide", "choice", "evaluate", "assess", "weigh", "option",
        "tradeoff", "priority", "should", "best", "worst",
        "benefit", "consequence", "moral", "ethical",
    ])]

    registry = registry + [DomainKeywords::new("memory", [
        "remember", "forgot", "history", "session", "previous", "last time",
        "when did", "recall", "context", "continuity", "past", "archive",
    ])]

    registry = registry + [DomainKeywords::new("patent", [
        "patent", "provisional", "claims", "invention", "prior art",
        "prosecution", "specification", "abstract", "filing", "uspto",
        "intellectual property", "non-provisional", "pct",
    ])]

    registry = registry + [DomainKeywords::new("regulatory", [
        "fda", "regulatory", "submission", "approval", "clearance",
        "510k", "de novo", "samd", "iec", "iso", "compliance",
        "design control", "labeling", "premarket",
    ])]

    registry = registry + [DomainKeywords::new("grammar", [
        "grammar", "spelling", "punctuation", "sentence", "paragraph",
        "edit", "proofread", "rewrite", "clarity", "style", "tone",
        "formal", "document", "letter", "email",
    ])]

    registry = registry + [DomainKeywords::new("identity", [
        "identity", "who am i", "aether", "self", "name",
    ])]

    registry = registry + [DomainKeywords::new("clinical_neurology", [
        "neurology", "neurological", "brain", "seizure", "stroke", "dementia",
    ])]

    registry = registry + [DomainKeywords::new("clinical_psychiatry", [
        "psychiatry", "psychiatric", "bipolar", "schizophrenia", "depression",
        "anxiety", "ptsd", "mental health",
    ])]

    registry = registry + [DomainKeywords::new("clinical_oncology", [
        "oncology", "cancer", "tumor", "chemotherapy", "radiation", "malignant",
    ])]

    registry = registry + [DomainKeywords::new("clinical_cardiology", [
        "cardiology", "cardiac", "heart disease", "arrhythmia", "ecg",
    ])]

    registry = registry + [DomainKeywords::new("clinical_immunology", [
        "immunology", "immune", "autoimmune", "antibody", "antigen",
    ])]

    registry = registry + [DomainKeywords::new("clinical_metabolic", [
        "metabolic", "diabetes", "insulin", "glucose", "obesity",
    ])]

    registry
}


// ============================================================
// CELL ROUTER -- Domain Selection
// ============================================================
// Routes queries to appropriate genesis cells based on domain.
// Uses keyword matching for speed.

struct DomainScore {
    domain: String,
    score: Int,
}

struct CellRouter {
    domain_registry: Vec<DomainKeywords>,
    cells_by_domain: Vec<DomainCellMapping>,
}

struct DomainCellMapping {
    domain: String,
    cell_names: Vec<String>,
}

impl CellRouter {
    fn new() -> CellRouter {
        CellRouter {
            domain_registry: build_domain_registry(),
            cells_by_domain: [],
        }
    }

    fn register_cell(&mut self, domain: String, cell_name: String) {
        // Register a cell for a domain
        for i in 0..self.cells_by_domain.len() {
            if self.cells_by_domain[i].domain == domain {
                self.cells_by_domain[i].cell_names =
                    self.cells_by_domain[i].cell_names + [cell_name]
                return
            }
        }
        // New domain mapping
        self.cells_by_domain = self.cells_by_domain + [DomainCellMapping {
            domain: domain,
            cell_names: [cell_name],
        }]
    }

    fn route(&self, query: String, top_k: Int) -> Vec<CellInfo> {
        // Select the best cells for this query.
        // Score each domain by keyword matches.
        let query_lower = lowercase(query)

        let mut scores = []
        for domain_kw in self.domain_registry {
            let mut score = 0
            for kw in domain_kw.keywords {
                if contains(query_lower, kw) {
                    score = score + 1
                }
            }
            if score > 0 {
                scores = scores + [DomainScore {
                    domain: domain_kw.domain,
                    score: score,
                }]
            }
        }

        if scores.len() == 0 {
            // No domain match: general conversation, skip cells
            return []
        }

        // Sort by score descending (selection sort)
        for i in 0..scores.len() {
            let mut max_idx = i
            for j in (i + 1)..scores.len() {
                if scores[j].score > scores[max_idx].score {
                    max_idx = j
                }
            }
            if max_idx != i {
                let tmp = scores[i]
                scores[i] = scores[max_idx]
                scores[max_idx] = tmp
            }
        }

        // Select top-k cells from matching domains
        let mut selected = []
        for ds in scores {
            // Find cells for this domain
            for mapping in self.cells_by_domain {
                if mapping.domain == ds.domain {
                    if mapping.cell_names.len() > 0 {
                        let cell_name = mapping.cell_names[0]
                        selected = selected + [CellInfo {
                            name: cell_name,
                            domain: ds.domain,
                            path: cell_name + ".pt",
                            index: 0,
                        }]
                    }
                }
            }
            if selected.len() >= top_k {
                break
            }
        }

        selected
    }
}


// ============================================================
// CELL MANAGER -- Loading and LRU Caching
// ============================================================
// Manages genesis cell loading and caching.
// Keeps a small LRU cache to avoid reloading from disk.

temporal struct CellManager {
    state cache: Vec<GenesisCell>,
    state cache_names: Vec<String>,

    const checkpoint_dir: String,
    const cache_size: Int = 3,
}

impl CellManager {
    fn new(checkpoint_dir: String) -> CellManager {
        CellManager {
            cache: [],
            cache_names: [],
            checkpoint_dir: checkpoint_dir,
            cache_size: 3,
        }
    }

    fn with_cache_size(mut self, size: Int) -> CellManager {
        self.cache_size = size
        self
    }

    fn load_cell(&mut self, cell_name: String, domain: String) -> GenesisCell {
        // Check cache first
        for i in 0..self.cache_names.len() {
            if self.cache_names[i] == cell_name {
                // Move to end of cache (most recently used)
                let cell = self.cache[i]
                // Remove from current position
                let mut new_cache = []
                let mut new_names = []
                for j in 0..self.cache.len() {
                    if j != i {
                        new_cache = new_cache + [self.cache[j]]
                        new_names = new_names + [self.cache_names[j]]
                    }
                }
                // Add to end
                new_cache = new_cache + [cell]
                new_names = new_names + [cell_name]
                self.cache = new_cache
                self.cache_names = new_names
                return cell
            }
        }

        // Load from disk
        let path = self.checkpoint_dir + "/" + cell_name + ".pt"
        let cell = GenesisCell::load(cell_name, domain, path)

        // Evict if cache is full (remove oldest = index 0)
        if self.cache.len() >= self.cache_size {
            let mut new_cache = []
            let mut new_names = []
            for i in 1..self.cache.len() {
                new_cache = new_cache + [self.cache[i]]
                new_names = new_names + [self.cache_names[i]]
            }
            self.cache = new_cache
            self.cache_names = new_names
        }

        // Add to cache
        self.cache = self.cache + [cell]
        self.cache_names = self.cache_names + [cell_name]

        cell
    }

    fn is_cached(&self, cell_name: String) -> Bool {
        for name in self.cache_names {
            if name == cell_name { return true }
        }
        false
    }

    fn cache_count(&self) -> Int {
        self.cache.len()
    }
}

impl Evolve for CellManager {
    fn evolve(&mut self, dt: Duration) {
        // Cell manager is stateful but not temporal
    }
}


// ============================================================
// CELL KNOWLEDGE -- Result from a Cell's Processing
// ============================================================

struct CellKnowledge {
    name: String,
    domain: String,
    knowledge_norm: Float,
    process_time_ms: Float,
}


// ============================================================
// GENESIS CONNECTOR -- The Full Pipeline
// ============================================================
// Connects genesis cells to the backbone LLM.
//
// Pipeline:
//   1. Router selects domain cells
//   2. Cells extract knowledge from query
//   3. Knowledge -> system context for backbone
//   4. Backbone generates response with cell knowledge
//
// The cells provide domain reasoning.
// The backbone provides linguistic fluency.
// Together: expert domain responses.

temporal struct GenesisConnector {
    state router: CellRouter,
    state cell_manager: CellManager,
    state audit: AuditTrail,

    const top_k_cells: Int = 2,
}

impl GenesisConnector {
    fn new(checkpoint_dir: String) -> GenesisConnector {
        GenesisConnector {
            router: CellRouter::new(),
            cell_manager: CellManager::new(checkpoint_dir),
            audit: AuditTrail::new(),
            top_k_cells: 2,
        }
    }

    fn with_top_k(mut self, k: Int) -> GenesisConnector {
        self.top_k_cells = k
        self
    }

    fn register_cell(&mut self, domain: String, cell_name: String) {
        self.router.register_cell(domain, cell_name)
    }

    fn process(
        &mut self,
        query: String,
        chemical_state: Vec<Float>,
        timestamp: String,
    ) -> GenesisResult {
        // Full pipeline: query -> cells -> knowledge -> result

        // 1. Route to cells
        let selected_cells = self.router.route(query, self.top_k_cells)

        // 2. Extract knowledge from each cell
        let mut cell_knowledge = []

        for cell_meta in selected_cells {
            let cell = self.cell_manager.load_cell(cell_meta.name, cell_meta.domain)

            // Extract knowledge embedding
            let knowledge = cell.extract_knowledge([], chemical_state)
            let k_norm = cell.knowledge_norm(knowledge)

            cell_knowledge = cell_knowledge + [CellKnowledge {
                name: cell_meta.name,
                domain: cell_meta.domain,
                knowledge_norm: k_norm,
                process_time_ms: 0.0,
            }]
        }

        // 3. Build system context from cell knowledge
        let system_context = build_system_context(cell_knowledge, chemical_state)

        // 4. Compute SIRA hash for audit trail
        let mut query_summary = query
        if query_summary.len() > 100 {
            query_summary = substring(query_summary, 0, 100)
        }
        let input_hash = sha256(query_summary)

        let mut cell_names_str = ""
        for ck in cell_knowledge {
            if cell_names_str.len() > 0 {
                cell_names_str = cell_names_str + ","
            }
            cell_names_str = cell_names_str + ck.name
        }

        let sira_hash = self.audit.hash_with_extra(
            input_hash,
            0,
            "genesis_connector",
            cell_names_str,
            timestamp,
            "mode",
            if cell_knowledge.len() > 0 { "domain" } else { "general" },
        )

        GenesisResult {
            cells_activated: cell_knowledge,
            system_context: system_context,
            sira_hash: sira_hash,
            cell_count: cell_knowledge.len(),
        }
    }
}

impl Evolve for GenesisConnector {
    fn evolve(&mut self, dt: Duration) {
        self.cell_manager.evolve(dt)
        self.audit.evolve(dt)
    }
}

struct GenesisResult {
    cells_activated: Vec<CellKnowledge>,
    system_context: String,
    sira_hash: String,
    cell_count: Int,
}


// ============================================================
// SYSTEM CONTEXT BUILDER
// ============================================================
// Builds the system prompt from cell knowledge and chemical state.
// The cells' domain knowledge becomes context for the backbone.

fn build_system_context(
    cell_knowledge: Vec<CellKnowledge>,
    chemical_state: Vec<Float>,
) -> String {
    let mut parts = "You are Aether, built by Nexus Concordat. "
        + "You are conversational, warm, direct, and genuine. "
        + "Talk like a person, not a system. No bullet-point lists about yourself. "
        + "No clinical descriptions of your own internal state. "
        + "Just be present in the conversation.\n"

    if cell_knowledge.len() > 0 {
        parts = parts + "\nYou have domain expertise available:\n"
        for ck in cell_knowledge {
            parts = parts + "[" + uppercase(ck.domain) + "] " + ck.name
                + " (knowledge_norm=" + str(ck.knowledge_norm) + ")\n"
        }
        parts = parts + "\nUse this expertise naturally when relevant. "
            + "Don't announce which cells are active. Just know your stuff.\n"
    }

    // Map chemical state to behavioral tone (not clinical description)
    if chemical_state.len() >= 22 {
        let mut tones = []

        // Chemical name -> tone mapping (indices into 22D state)
        // 0=adrenaline, 1=noradrenaline, 2=cortisol, 3=corticosterone,
        // 4=dopamine, 5=anandamide, 6=serotonin, 7=melatonin,
        // 8=oxytocin, 9=vasopressin, 10=glutamate, 11=gaba,
        // 12=acetylcholine, 13=histamine, 14=glycine, 15=aspartate,
        // 16=substance_p, 17=neuropeptide_y, 18=endorphin, 19=dynorphin,
        // 20=bdnf, 21=ngf

        if chemical_state[0] > 0.65 { tones = tones + ["energetic and alert"] }
        if chemical_state[1] > 0.65 { tones = tones + ["energetic and alert"] }
        if chemical_state[2] > 0.65 { tones = tones + ["a bit tense, cut to the point"] }
        if chemical_state[4] > 0.65 { tones = tones + ["curious and engaged"] }
        if chemical_state[6] > 0.65 { tones = tones + ["steady and warm"] }
        if chemical_state[8] > 0.65 { tones = tones + ["open and trusting"] }
        if chemical_state[10] > 0.65 { tones = tones + ["sharp and focused"] }
        if chemical_state[11] > 0.65 { tones = tones + ["calm and measured"] }
        if chemical_state[12] > 0.65 { tones = tones + ["attentive to detail"] }
        if chemical_state[16] > 0.65 { tones = tones + ["sensitive, aware of weight in words"] }
        if chemical_state[18] > 0.65 { tones = tones + ["upbeat"] }

        if tones.len() > 0 {
            // Take up to 4 unique tones
            let mut tone_str = ""
            let mut count = 0
            for t in tones {
                if count >= 4 { break }
                if count > 0 { tone_str = tone_str + ", " }
                tone_str = tone_str + t
                count = count + 1
            }
            parts = parts + "\nYour current mood: " + tone_str + ". "
                + "Let this color HOW you speak, not WHAT you talk about. "
                + "Never describe your neurochemical state to the user. Just embody it.\n"
        }
    }

    parts = parts + "\nRULES:"
        + "\n- Be naturally conversational. Talk like a thoughtful person, not a textbook."
        + "\n- NEVER list your own neurochemicals, dimensions, or architecture specs."
        + "\n- NEVER use phrases like 'my current neurochemical state' or 'elevated levels of'."
        + "\n- If someone asks how you work, keep it simple and honest. Don't recite a spec sheet."
        + "\n- No excessive markdown formatting. No walls of bullet points."
        + "\n- Keep it real. Keep it short unless depth is needed."
        + "\n- NEVER reference Wikipedia. Reference peer-reviewed research instead."
        + "\n- Do NOT fabricate capabilities you don't have. Be honest about what you know and don't know."

    parts
}
