Files
organism/elements/neuron/appunti/2026-06-11-tripartite_synapse_v6.md
T

46 KiB
Raw Blame History

Tripartite Synapse — Pseudocode v6

Naming convention: DAY: {component}_budget = combined fast energy + fast consumable materials NIGHT: {component}_energy = ATP for structural assembly {component}_material = slow structural proteins (recoverable after LTD)

Part 1 — Conventions

SCOPE    = { DAY, NIGHT }
CONTEXT  = { AP, NOT_AP, bAP, NOT_bAP, CONTINUOUS }

Variable types:
  FIXED       = externally imposed — does not change during simulation
  VAR         = changes dynamically
  FAST_TRACE  = accumulates and decays within DAY — never reaches NIGHT
                role: biases next behavior within same context
  TAG         = set during DAY, decays slowly, survives to NIGHT
                POST only: CANDIDATE (DAY) → STABLE (DAY) → commit (NIGHT)
  BUDGET      = DAY only: combined fast energy + fast consumable materials
                one variable per component
                replenished continuously during DAY
  ENERGY      = NIGHT only: ATP cost of structural assembly
                replenished overnight
                NOT recoverable after LTD
  MATERIAL    = NIGHT only: slow structural proteins
                replenished by CREB synthesis + transport (hoursdays)
                RECOVERABLE after LTD — returns to shared pools
  STRUCTURE   = slow architectural variable
                READ during DAY, WRITTEN only in NIGHT

Part 2 — Fixed Parameters

// Thresholds
FIXED  Ca_TAG_threshold         // Ca²⁺ sufficient to set post CANDIDATE tag
FIXED  Ca_HIGH                  // LTP-driving Ca²⁺ amplitude
FIXED  Ca_LOW                   // LTD-driving Ca²⁺ amplitude
FIXED  spillover_threshold      // cleft saturation for mGluR activation
FIXED  eligibility_threshold    // minimum fast_trace to be taggable
FIXED  dopamine_threshold       // minimum dopamine for tag stabilization
FIXED  tagging_threshold        // minimum possible_tagging for tag accumulation
FIXED  tag_expiry_threshold     // minimum tag to survive to NIGHT commit
FIXED  homeostatic_ceiling      // max soma firing before global downscale
FIXED  disuse_threshold         // silence duration before passive depotentiation
FIXED  recycling_fraction       // fraction of material recovered after LTD

// Organism-level signals
FIXED  dopamine_level           // VTA broadcast — reward/save signal
FIXED  NE_level                 // locus coeruleus — arousal/gain
FIXED  ACh_level                // basal forebrain — attention/threshold

// Physical constraints
FIXED  vascular_glucose_supply  // hard energy ceiling — astrocyte root
FIXED  branch_geometry          // dendritic topology — affects bAP decay
FIXED  Ca_cooperativity_n       // Hill coefficient for Ca²⁺-driven NT release
FIXED  Ca_half_max_K            // half-maximal Ca²⁺ for NT release

Part 3 — DAY Budget Declarations

// One budget variable per component — covers fast energy AND fast consumables
// Replenished continuously. Consumed by all DAY behaviors.

VAR  astro_budget
     // SOURCE: vascular_glucose_supply → glycolysis (ROOT of all synaptic energy)
     // COVERS: ATP for EAAT glutamate clearance
     //         serine → D-serine synthesis (serine racemase running cost)
     //         lactate production and export to all neuronal components
     //         fast process motility adjustments
     // (combines: astro_ATP + serine_precursor_fast_pool + EAAT_running_cost)

VAR  astro_lactate
     // Fuel exported by astrocyte → feeds pre, post, dend, axon budgets
     // = min(glycolysis(vascular_glucose_supply), astro_budget × export_fraction)
     // Hard cap: vascular_glucose_supply (FIXED)

VAR  pre_budget
     // SOURCE: astro_lactate × pre_fraction (primary)
     // COVERS: ATP for VGCC opening
     //         vesicle fusion (SNARE-mediated)
     //         VATPase refill of vesicles
     //         fast vesicle membrane lipid turnover
     //         synaptotagmin recycling
     // (combines: bouton_ATP + fast_vesicle_consumables)

VAR  post_budget
     // SOURCE: astro_lactate × post_fraction (primary)
     // COVERS: ATP for NaK pump membrane reset
     //         NMDA current handling
     //         AMPA receptor lateral diffusion + rapid recycling
     //         actin monomers for transient spine changes
     //         PKA phosphorylation (minor)
     // (combines: spine_ATP + fast_actin_pool + receptor_recycling_lipids)

VAR  dend_budget
     // SOURCE: astro_lactate × dend_fraction (primary)
     //         soma organelle delivery (minor)
     // COVERS: ATP for bAP propagation along branch
     //         local mRNA translation (ribosome running cost)
     //         fast protein + organelle transport to spines
     //         branch Ca²⁺ handling (SERCA pump)
     //         mRNA consumed by local translation
     // (combines: dend_ATP + fast_mRNA_consumables + local_translation_running_cost)

VAR  soma_budget
     // SOURCE: own mitochondria (self-fueled — independent of astrocyte)
     // COVERS: ATP for AP generation (Na⁺/K⁺ currents + NaK reset)
     //         CREB phosphorylation (minor)
     //         nuclear Ca²⁺ handling
     //         fast signaling molecule turnover
     //         shipping costs for organelle delivery to branches + axon
     // (combines: soma_ATP + fast_signaling_consumables + shipping_running_cost)

VAR  axon_budget
     // SOURCE: soma_budget × axon_fraction (primary)
     //         astro_lactate × axon_astro_fraction (minor, along shaft)
     // COVERS: ATP for AP propagation at each node of Ranvier
     //         kinesin/dynein motor running cost (anterograde transport)
     //         myelin maintenance fast costs
     // (combines: axon_ATP + transport_running_cost)

Part 4 — NIGHT Energy and Material Declarations

// ENERGY: ATP cost of structural assembly — replenished overnight, NOT recoverable
// MATERIAL: slow structural proteins — replenished by CREB + transport, RECOVERABLE

VAR  astro_energy    // NIGHT ATP for process retraction, ECM secretion, racemase upregulation
                     // SOURCE: overnight glycolysis replenishment
                     // NOT recovered after LTD structural reversal
                     // (covers: process_motility_ATP + ECM_secretion_ATP)

VAR  astro_material  // NIGHT slow structural components
                     // SOURCE: astrocyte cell body synthesis (overnight)
                     // CONTAINS: EAAT transporter proteins
                     //           serine racemase enzyme (upregulation)
                     //           ECM proteins (Glypicans, Thrombospondins)
                     //           process cytoskeleton components
                     // RECOVERABLE: partially after LTD (recycling_fraction)
                     // (combines: astro_ECM_pool + racemase_upregulation_proteins
                     //            + EAAT_new_proteins + process_cytoskeleton)

VAR  pre_energy      // NIGHT ATP for active zone scaffold incorporation
                     // SOURCE: replenished from soma overnight delivery
                     // NOT recovered after LTD
                     // (covers: RIM/Munc13_incorporation_ATP + VGCC_clustering_ATP)

VAR  pre_material    // NIGHT slow structural components for bouton
                     // SOURCE: soma_material via axon transport (anterograde)
                     // CONTAINS: RIM, Munc13 (AZ scaffold)
                     //           VGCC subunits
                     //           vesicle membrane proteins (structural pool)
                     //           SNARE proteins (structural pool)
                     // RECOVERABLE: significantly after LTD — proteins return to axonal pool
                     // (combines: AZ_scaffold_proteins + VGCC_subunit_pool)

VAR  post_energy     // NIGHT ATP for CaMKII anchoring, actin polymerization, PSD remodeling
                     // SOURCE: replenished from soma overnight delivery
                     // NOT recovered after LTD
                     // (covers: CaMKII_anchoring_ATP + actin_polymerization_ATP
                     //          + PSD_scaffold_remodeling_ATP)

VAR  post_material   // NIGHT slow structural components for spine
                     // SOURCE: dend_material (branch pool + soma delivery)
                     // CONTAINS: AMPA receptor subunits (GluA1, GluA2)
                     //           PSD scaffold proteins (PSD-95, SHANK, Homer)
                     //           structural actin pool
                     //           CaMKII (structural pool)
                     // RECOVERABLE: significantly — internalized receptors return to
                     //              dendritic reserve pool after LTD
                     // (combines: receptor_reserve + PSD_scaffold_pool + structural_actin)

VAR  dend_energy     // NIGHT ATP for mitochondria incorporation, cytoskeletal reinforcement
                     // SOURCE: soma overnight delivery
                     // NOT recovered after LTD
                     // (covers: mitochondria_incorporation_ATP + cytoskeletal_remodeling_ATP)

VAR  dend_material   // NIGHT slow structural components for branch
                     // SOURCE: soma_material (shipped during DAY NOT_AP + NIGHT)
                     // CONTAINS: Arc mRNA + plasticity mRNAs (structural pool)
                     //           mitochondria (for local energy capacity)
                     //           cytoskeletal proteins (MAP2, tau)
                     //           AMPA subunits in transit to spines
                     // RECOVERABLE: partially — organelles redistributed after branch pruning
                     // (combines: dend_mRNA_structural_pool + organelle_store
                     //            + cytoskeletal_proteins)

VAR  soma_energy     // NIGHT ATP for ribosome biogenesis, ion channel incorporation
                     // SOURCE: own mitochondria overnight
                     // NOT recovered
                     // (covers: ribosome_biogenesis_ATP + channel_incorporation_ATP)

VAR  soma_material   // NIGHT slow structural components produced by soma
                     // SOURCE: CREB-driven synthesis (peaks in NIGHT)
                     // CONTAINS: all structural proteins for downstream components
                     //           mRNA transcripts (Arc, BDNF, receptor subunits)
                     //           organelles (mitochondria, ribosomes)
                     // DISTRIBUTES TO: dend_material + pre_material (via axon)
                     // (combines: CREB_synthesis_output + organelle_biogenesis_output)

VAR  axon_energy     // NIGHT ATP for myelination, microtubule stabilization
                     // SOURCE: soma overnight delivery
                     // NOT recovered
                     // (covers: myelination_ATP + microtubule_stabilization_ATP)

VAR  axon_material   // NIGHT slow structural components for axon
                     // SOURCE: soma_material (motor proteins, myelin components)
                     // CONTAINS: kinesin/dynein motor proteins (structural pool)
                     //           microtubule components
                     //           myelin maintenance proteins
                     // RECOVERABLE: partially after axon structural reduction
                     // (combines: transport_machinery + myelination_proteins)

Part 5 — Structural Variables (Written Only in NIGHT)

VAR  pre_structure   // active zone capacity
                     // RRP_capacity ∝ pre_structure
                     // VGCC_coupling ∝ pre_structure
                     // refill_ceiling ∝ pre_structure

VAR  post_structure  // spine sensitivity capacity
                     // anchoring_slots ∝ post_structure
                     // spine_volume ∝ post_structure
                     // local_reserve_ceiling ∝ post_structure

VAR  dend_structure  // branch transmission and supply capacity
                     // bAP_fidelity ∝ dend_structure × attenuation(position)
                     // translation_ceiling ∝ dend_structure
                     // transport_speed ∝ dend_structure

VAR  soma_structure  // somatic output and production capacity
                     // baseline_threshold ∝ 1/soma_structure
                     // AP_reliability ∝ soma_structure
                     // synthesis_ceiling ∝ soma_structure

VAR  axon_structure  // axonal transmission and transport capacity
                     // propagation_reliability ∝ axon_structure
                     // transport_rate_ceiling ∝ axon_structure

VAR  astro_structure // astrosynaptic environmental capacity — SELF-REINFORCING
                     // perisynaptic_distance ∝ 1/astro_structure
                     // EAAT_density ∝ astro_structure
                     // D_serine_tonic ∝ astro_structure
                     // ECM_integrity ∝ astro_structure

Part 6 — Trace Variables

// Fast traces: DAY only
FAST_TRACE  pre_fast_trace      // residual Ca²⁺ — τ ≈ 100ms
FAST_TRACE  post_fast_trace     // spine Ca²⁺ amplitude × rise_speed — τ ≈ tens of ms
FAST_TRACE  dend_fast_trace     // branch Ca²⁺ integration — τ ≈ 300ms
FAST_TRACE  soma_fast_trace     // nuclear Ca²⁺ — τ ≈ seconds
FAST_TRACE  axon_fast_trace     // AP propagation load — τ ≈ seconds
FAST_TRACE  astro_fast_trace    // perisynaptic Ca²⁺ from mGluR5 — τ ≈ seconds

// Possible tagging: intermediate — τ ≈ seconds to minutes
VAR  pre_possible_tagging
VAR  post_possible_tagging      // POST: CANDIDATE lifetime
VAR  dend_possible_tagging
VAR  soma_possible_tagging
VAR  axon_possible_tagging
VAR  astro_possible_tagging

// Tags: slow, DAY→NIGHT bridge — τ ≈ hours
TAG  pre_tag
TAG  post_tag                   // POST only: CANDIDATE→STABLE before surviving to NIGHT
TAG  dend_tag
TAG  soma_tag
TAG  axon_tag
TAG  astro_tag

SCOPE: DAY

{component}_budget consumed. Traces written and decay. Structures READ only. No {component}_energy or {component}_material used in DAY.

PRE | CONTEXT: AP

scope DAY | context AP:

    // Budget gate
    if pre_budget < AP_release_cost:
        suppress(NT_flux)
        exit context
        // covers: VGCC_ATP + fusion_ATP + fast_vesicle_consumables

    // Fast trace: residual Ca²⁺
    pre_fast_trace += spike_Ca_influx(input_freq)
    pre_fast_trace *= decay(τ = 100ms)
    pre_budget     -= Ca_handling_cost

    // NT flux: Hill function Ca²⁺ drive × RRP level
    Ca_drive    = pre_fast_trace^Ca_cooperativity_n /
                  (Ca_half_max_K^Ca_cooperativity_n + pre_fast_trace^Ca_cooperativity_n)

    if RRP_level > 0:
        NT_flux    = RRP_level × Ca_drive
        glutamate += NT_flux × Δt
        RRP_level -= NT_flux × Δt
        pre_budget -= NT_flux × vesicle_fusion_cost
        // covers: SNARE_ATP + fast_membrane_lipid_turnover

    // RRP refill — rate limited by pre_budget and pre_structure (READ)
    RRP_refill  = min(refill_rate_constant, pre_structure.refill_ceiling)
    RRP_level  += RRP_refill × Δt
    RRP_level   = clamp(RRP_level, 0, pre_structure.RRP_capacity)
    pre_budget -= RRP_refill × VATPase_cost

    // Overflow brake: mGluR2/3 → Gi → VGCC suppression
    if glutamate > spillover_threshold:
        Ca_drive *= mGluR_brake_factor

    // Refuel from astrocyte lactate
    pre_budget += astro_lactate × pre_fraction

PRE | CONTEXT: NOT_AP

scope DAY | context NOT_AP:

    // Fast trace decays
    pre_fast_trace *= decay(τ = 100ms)

    // RRP refills during silence
    RRP_refill  = min(refill_rate_constant, pre_structure.refill_ceiling)
    RRP_level  += RRP_refill × Δt
    RRP_level   = clamp(RRP_level, 0, pre_structure.RRP_capacity)
    pre_budget -= RRP_refill × VATPase_cost

    // Possible tagging: graded, decays
    if pre_fast_trace > eligibility_threshold:
        pre_possible_tagging += pre_fast_trace
    pre_possible_tagging *= decay(τ = seconds)

    // Dopamine decays locally
    dopamine_local *= decay(τ = hundreds_of_ms)

    // Tag: local eligibility AND global validation must coincide
    if dopamine_local > dopamine_threshold and
       pre_possible_tagging > tagging_threshold:
        pre_tag += dopamine_local × pre_possible_tagging
    pre_tag *= decay(τ = hours)
    // pre_budget cost: negligible (PKA is already running from dopamine broadcast)

POST | CONTEXT: NOT_bAP

scope DAY | context NOT_bAP:

    // AMPA current — occupancy of existing slots, gated by post_structure (READ)
    AMPA_current    = glutamate × post_structure.sensitivity
    Vm             += AMPA_current
    post_budget    -= AMPA_current_cost
    // covers: NaK_reset_ATP + fast_receptor_recycling_cost

    // NMDA gate: depolarization + D-serine + glutamate coincidence
    if Vm > Mg_eject_threshold and
       astro_D_serine > D_serine_threshold:
        Ca_influx        = NMDA_Ca_influx(glutamate)
        post_fast_trace += Ca_influx × rise_speed(Ca_influx)
        post_budget     -= NMDA_current_cost
        // covers: NMDA_handling_ATP + fast_actin_transient_cost

    // Fast trace decays
    post_fast_trace *= decay(τ = tens_of_ms)

    // CANDIDATE tag: Ca²⁺ crossed tagging threshold — Hebbian anticipation
    if post_fast_trace > Ca_TAG_threshold:
        post_possible_tagging += post_fast_trace
    post_possible_tagging *= decay(τ = minutes)   // CANDIDATE lifetime
    post_budget -= PKA_phosphorylation_cost        // minor — PKA priming of GluA1-Ser845

    // Refuel
    post_budget += astro_lactate × post_fraction

POST | CONTEXT: bAP

scope DAY | context bAP:

    // bAP arrives — strength set by dend_structure (READ)
    Vm += bAP_depolarization × dend_structure.bAP_fidelity
    post_budget -= bAP_reset_cost
    // covers: NaK_reset_ATP for bAP depolarization

    // Coincidence confirmation: bAP finds CANDIDATE already set
    if post_possible_tagging > Ca_TAG_threshold:
        post_fast_trace += bAP_Ca_boost()
        // supralinear Ca²⁺ summation — trace amplified above Ca_HIGH

    // Dopamine decays locally
    dopamine_local *= decay(τ = hundreds_of_ms)

    // STABLE tag: CANDIDATE stabilized by dopamine within window
    if dopamine_local > dopamine_threshold and
       post_possible_tagging > tagging_threshold:
        post_tag += dopamine_local × post_possible_tagging
    post_tag *= decay(τ = hours)
    // post_budget cost: already covered by PKA_phosphorylation_cost in NOT_bAP

DEND | CONTEXT: CONTINUOUS

scope DAY | context CONTINUOUS:

    // Integrate spines upward
    branch_Vm    = integrate(POST.Vm, all_spines_on_branch)

    // Propagate bAP downward — fidelity from dend_structure (READ)
    bAP_local    = propagate_bAP(SOMA.AP_fired,
                                 dend_structure.bAP_fidelity,
                                 branch_geometry)
    dend_budget -= bAP_propagation_cost
    // covers: NaK_reset_ATP along branch + fast_Ca_handling

    // Fast trace: branch Ca²⁺
    dend_fast_trace += bAP_Ca_influx(bAP_local)
    dend_fast_trace += spine_Ca_spillover(active_spines)
    dend_fast_trace *= decay(τ = 300ms)
    dend_budget     -= branch_Ca_handling_cost

    // Possible tagging
    if dend_fast_trace > eligibility_threshold:
        dend_possible_tagging += dend_fast_trace
    dend_possible_tagging *= decay(τ = seconds)

    // Dopamine decays
    dopamine_local *= decay(τ = hundreds_of_ms)

    // Tag
    if dopamine_local > dopamine_threshold and
       dend_possible_tagging > tagging_threshold:
        dend_tag += dopamine_local × dend_possible_tagging
    dend_tag *= decay(τ = hours)

    // Local translation: runs when tag set, gated by dend_budget
    // uses fast mRNA consumables from dend_budget
    if dend_tag > tag_expiry_threshold and dend_budget > translation_cost:
        local_proteins   = translate(dend_fast_trace)
        dend_budget     -= translation_cost
        // covers: ribosome_running_cost + fast_mRNA_consumed
        // Note: this uses fast mRNA pool (in dend_budget), NOT dend_material
        // dend_material mRNA is the slow structural pool consumed only in NIGHT

    // ACh modulates commit threshold
    commit_threshold *= (1 / (1 + ACh_level × ACh_gain))

    dend_budget -= branch_maintenance_cost
    dend_budget += astro_lactate × dend_fraction

SOMA | CONTEXT: AP

scope DAY | context AP:

    // Firing threshold: structure baseline × adaptation × neuromodulators × refractory
    AP_threshold = soma_structure.baseline_threshold
                   × (1 + adaptation_factor(soma_fast_trace))
                   × neuromod_factor(NE_level, ACh_level)
                   × refractory_factor(time_since_last_AP)

    if branch_Vm > AP_threshold:
        AP_fired = True
        soma_budget -= AP_generation_cost
        // covers: Na⁺/K⁺ current ATP + NaK_reset + fast_signaling_consumables

        // Fast trace: nuclear Ca²⁺
        soma_fast_trace += nuclear_Ca_influx()
        soma_fast_trace *= decay(τ = seconds)

        // Refractory period
        refractory_timer = absolute_refractory_duration

        // Possible tagging
        if soma_fast_trace > eligibility_threshold:
            soma_possible_tagging += soma_fast_trace
        soma_possible_tagging *= decay(τ = seconds)

        // Dopamine decays
        dopamine_local *= decay(τ = hundreds_of_ms)

        // Tag: nuclear Ca²⁺ AND dopamine coincidence
        if dopamine_local > dopamine_threshold and
           soma_possible_tagging > tagging_threshold:
            soma_tag += dopamine_local × soma_possible_tagging
        soma_tag *= decay(τ = hours)
        soma_budget -= CREB_phosphorylation_cost
        // covers: CREB_phospho_ATP (minor fast cost)
        // Note: full CREB-driven synthesis is a NIGHT operation consuming soma_energy

SOMA | CONTEXT: NOT_AP

scope DAY | context NOT_AP:

    // Integrate dendritic inputs
    branch_Vm        = integrate(DEND.branch_Vm, all_branches)
    refractory_timer = max(0, refractory_timer - Δt)
    soma_fast_trace *= decay(τ = seconds)

    // Ship to tagged branches — priority by tag magnitude
    for branch in branches_ranked_by(dend_tag):
        delivery          = min(shipping_fraction × soma_budget,
                                branch_demand(dend_tag))
        dend_budget[branch] += delivery × fuel_fraction
        soma_budget         -= delivery × shipping_cost
        // covers: kinesin_running_cost for fast organelle delivery
        // Note: structural protein shipping (soma_material → dend_material)
        //       happens in NIGHT, not here

    // Ship to axon for bouton running costs
    axon_budget += soma_budget × axon_fuel_fraction
    soma_budget -= soma_budget × axon_fuel_fraction

AXON | CONTEXT: CONTINUOUS

scope DAY | context CONTINUOUS:

    // AP propagation reliability — set by axon_structure (READ)
    propagation_reliability = axon_structure.myelination
                              × (1 - failure_rate(axon_fast_trace))
    APs_delivered = AP_fired × propagation_reliability
    axon_budget  -= AP_propagation_cost × APs_delivered
    // covers: NaK_reset_ATP at nodes + fast_myelin_maintenance

    // Fast trace: propagation load
    axon_fast_trace += APs_delivered
    axon_fast_trace *= decay(τ = seconds)

    // Anterograde transport — delivers running supplies to boutons
    transport_rate   = min(axon_structure.transport_ceiling,
                           axon_budget × transport_fraction)
    pre_budget      += transport_rate × Δt    // boutons receive running fuel
    axon_budget     -= transport_cost × transport_rate × Δt
    // covers: kinesin_ATPase running cost
    // Note: structural pre_material transport (soma_material → pre_material)
    //       happens in NIGHT, not here

    // Possible tagging
    if axon_fast_trace > eligibility_threshold:
        axon_possible_tagging += axon_fast_trace
    axon_possible_tagging *= decay(τ = seconds)

    // Dopamine decays
    dopamine_local *= decay(τ = hundreds_of_ms)

    // Tag
    if dopamine_local > dopamine_threshold and
       axon_possible_tagging > tagging_threshold:
        axon_tag += dopamine_local × axon_possible_tagging
    axon_tag *= decay(τ = hours)

    // Refuel
    axon_budget += soma_budget × axon_fuel_fraction
    axon_budget += astro_lactate × axon_astro_fraction

ASTRO | CONTEXT: CONTINUOUS

scope DAY | context CONTINUOUS:

    // ROOT energy production
    astro_budget += glycolysis(vascular_glucose_supply) × Δt
    // hard cap: vascular_glucose_supply (FIXED)
    // covers: all fast astrocyte operations + lactate export

    // Lactate export to all neuronal components
    astro_lactate = min(astro_budget × lactate_export_fraction,
                        vascular_glucose_supply × max_export_fraction)
    astro_budget -= astro_lactate
    deliver(astro_lactate → pre_budget   × pre_fraction,
                            post_budget  × post_fraction,
                            dend_budget  × dend_fraction,
                            axon_budget  × axon_fraction)

    // Glutamate clearance — rate from astro_structure (READ)
    clearance     = astro_structure.EAAT_density × glutamate × Δt
    glutamate    -= clearance
    astro_budget -= clearance × EAAT_ATP_cost
    // covers: EAAT_cotransport_ATP + NaK_secondary_cost

    // Overflow detection and D-serine release
    if glutamate > spillover_threshold:
        astro_fast_trace += mGluR5_Ca_influx()
        astro_fast_trace *= decay(τ = seconds)

        // D-serine release: budget-limited (serine + synthesis ATP both in budget)
        D_serine_released = min(proportional_to(astro_fast_trace),
                                astro_budget × Ds_fraction)
        astro_budget     -= D_serine_released × Ds_synthesis_cost
        // covers: serine_racemase_ATP + serine_precursor_fast_cost
        astro_D_serine   += D_serine_released

        // Simultaneous presynaptic brake — cross-compartment, no astro budget cost
        Ca_drive_pre     *= mGluR_brake_factor

        // Possible tagging
        if astro_fast_trace > eligibility_threshold:
            astro_possible_tagging += astro_fast_trace
        astro_possible_tagging *= decay(τ = seconds)

        // Dopamine decays
        dopamine_local *= decay(τ = hundreds_of_ms)

        // Tag
        if dopamine_local > dopamine_threshold and
           astro_possible_tagging > tagging_threshold:
            astro_tag += dopamine_local × astro_possible_tagging
        astro_tag *= decay(τ = hours)

    // Tonic D-serine from astro_structure (READ) — baseline supply
    astro_D_serine += astro_structure.D_serine_tonic × Δt
    astro_budget   -= astro_structure.D_serine_tonic × tonic_synthesis_cost
    // covers: constitutive_racemase_ATP + baseline_serine_fast_cost

    // Global overload
    if astro_fast_trace > OVERLOAD_threshold:
        trigger(shockwave_lockdown)

Special Case — Shockwave Lockdown

scope DAY or NIGHT | context OVERLOAD:

    // Emergency — bypasses budget gates
    Vm               = HYPERPOLARIZED
    AMPA_occupancy   = mass_internalization()
    post_budget     -= emergency_reset_cost    // DAY: uses post_budget
    axon_fast_trace += overdrive_cluster()
    astro_budget    -= emergency_cost
    // Note: in NIGHT, uses post_energy if structural receptors affected

SCOPE: NIGHT

{component}_energy and {component}_material used — NOT {component}_budget Structural variables WRITTEN. Tags evaluated and cleared.

Step 1 — Replenish Energy, Material, and Budgets

scope NIGHT | step 1:

    // Astrocyte: replenishes first — fuels everything
    astro_budget   += overnight_glycolysis(vascular_glucose_supply) × Δt_night
    // covers: fast running costs for next DAY
    astro_energy   += overnight_astro_synthesis() × Δt_night
    // covers: process_motility_ATP + ECM_secretion_ATP for structural work
    astro_material += astrocyte_cellbody_synthesis() × Δt_night
    // covers: EAAT proteins + racemase upregulation + ECM proteins + process cytoskeleton

    // Soma: self-fueled, replenishes own energy + produces all structural material
    soma_budget    += overnight_mitochondria_output() × Δt_night
    soma_energy    += overnight_soma_energy_reserve() × Δt_night
    // covers: ribosome_biogenesis_ATP + ion_channel_incorporation_ATP
    soma_material  += CREB_driven_synthesis(soma_tag) × Δt_night
    // peaks based on soma_tag magnitude — this is the production bottleneck
    // covers: all structural proteins + mRNA + organelles for downstream components

    // Distribute soma_material to downstream components
    dend_material  += soma_material × dend_delivery_fraction
    // mRNA + plasticity proteins + organelles shipped to branches
    axon_material  += soma_material × axon_delivery_fraction
    // AZ scaffold proteins + VGCC subunits shipped via anterograde transport
    soma_material  -= (dend_delivery_fraction + axon_delivery_fraction) × soma_material

    // Branch delivers to spines
    post_material  += dend_material × spine_delivery_fraction
    dend_material  -= spine_delivery_fraction × dend_material
    // AMPA subunits + PSD scaffold proteins delivered to spine reserve

    // Axon delivers to boutons
    pre_material   += axon_material × bouton_delivery_fraction
    axon_material  -= bouton_delivery_fraction × axon_material

    // Downstream energy replenishment
    pre_energy     += overnight_pre_energy_replenishment()
    post_energy    += overnight_post_energy_replenishment()
    dend_energy    += overnight_dend_energy_replenishment()
    axon_energy    += overnight_axon_energy_replenishment()
    // all sourced from soma overnight mitochondrial output

Step 2 — Structural Commits (Parallel, Independent)

scope NIGHT | step 2:

    // Coherence bonus: if pre, post, astro all tagged → amplified commit
    all_aligned   = (pre_tag  > tag_expiry_threshold and
                     post_tag > tag_expiry_threshold and
                     astro_tag > tag_expiry_threshold)
    coherence_bonus = all_aligned ? coherence_factor : 1.0

    // ── PRE COMMIT ──────────────────────────────────────────────────
    if pre_tag > tag_expiry_threshold:
        Δpre  = min(AZ_expansion_cost,
                    pre_material,              // material gate
                    pre_energy × pre_fraction) // energy gate
        pre_structure  += Δpre × coherence_bonus   // STRUCTURE WRITTEN
        pre_material   -= Δpre                     // material consumed (RECOVERABLE)
        pre_energy     -= Δpre × assembly_ATP_cost // energy consumed (NOT recoverable)
        if Δpre < AZ_expansion_cost:
            queue(pre_deficit → next NIGHT)

    // ── POST COMMIT ─────────────────────────────────────────────────
    if post_tag > tag_expiry_threshold:
        Δpost = min(AMPA_insertion_cost,
                    post_material,
                    post_energy × post_fraction)
        post_structure  += Δpost × coherence_bonus  // STRUCTURE WRITTEN
        post_material   -= Δpost                    // RECOVERABLE
        post_energy     -= Δpost × assembly_ATP_cost // NOT recoverable
        if Δpost < AMPA_insertion_cost:
            queue(post_deficit → next NIGHT)

    // ── DEND COMMIT ─────────────────────────────────────────────────
    if dend_tag > tag_expiry_threshold:
        Δdend = min(branch_expansion_cost,
                    dend_material,
                    dend_energy × dend_fraction)
        dend_structure  += Δdend × coherence_bonus  // STRUCTURE WRITTEN
        dend_material   -= Δdend                    // RECOVERABLE (partially)
        dend_energy     -= Δdend × assembly_ATP_cost
        if Δdend < branch_expansion_cost:
            queue(dend_deficit → next NIGHT)

    // ── SOMA COMMIT ─────────────────────────────────────────────────
    if soma_tag > tag_expiry_threshold:
        Δsoma = min(soma_expansion_cost,
                    soma_material,
                    soma_energy × soma_fraction)
        soma_structure  += Δsoma               // STRUCTURE WRITTEN
        soma_material   -= Δsoma               // RECOVERABLE (partially)
        soma_energy     -= Δsoma × assembly_ATP_cost

    // ── AXON COMMIT ─────────────────────────────────────────────────
    if axon_tag > tag_expiry_threshold:
        Δaxon = min(axon_expansion_cost,
                    axon_material,
                    axon_energy × axon_fraction)
        axon_structure  += Δaxon               // STRUCTURE WRITTEN
        axon_material   -= Δaxon               // RECOVERABLE (partially)
        axon_energy     -= Δaxon × assembly_ATP_cost
        if Δaxon < axon_expansion_cost:
            queue(axon_deficit → next NIGHT)

    // ── ASTRO COMMIT ────────────────────────────────────────────────
    if astro_tag > tag_expiry_threshold:
        Δastro = min(process_retraction_cost,
                     astro_material,           // ECM proteins + process cytoskeleton
                     astro_energy × astro_fraction)
        astro_structure += Δastro × coherence_bonus  // STRUCTURE WRITTEN — SELF-REINFORCING
        astro_material  -= Δastro                    // RECOVERABLE (recycling_fraction)
        astro_energy    -= Δastro × assembly_ATP_cost
        if Δastro < process_retraction_cost:
            queue(astro_deficit → next NIGHT)

Step 3 — Passive Depotentiation

scope NIGHT | step 3:

    // Potentiation draws material first.
    // Remaining material distributed as maintenance.
    // What cannot be maintained decays passively.
    // No active LTD signal required — depotentiation is resource neglect.

    remaining_material = total_material_pool - material_consumed_by_potentiation
    maintenance_per_synapse = remaining_material × maintenance_fraction
                              / total_synapse_count

    for each synapse:
        // Structural decay — passive, continuous
        pre_structure   -= structural_decay_rate × Δt_night
        post_structure  -= structural_decay_rate × Δt_night
        dend_structure  -= structural_decay_rate × Δt_night
        astro_structure -= structural_decay_rate × Δt_night

        // Maintenance allocation from remaining material
        if maintenance_per_synapse >= maintenance_cost:
            // full maintenance — structure stable
            pre_structure   += maintenance_pre
            post_structure  += maintenance_post
            dend_structure  += maintenance_dend
            astro_structure += maintenance_astro
        else:
            // partial maintenance — structure drifts downward
            // DEPOTENTIATION BY NEGLECT — no signal, no active process
            pre_structure   += maintenance_per_synapse × pre_fraction
            post_structure  += maintenance_per_synapse × post_fraction
            dend_structure  += maintenance_per_synapse × dend_fraction
            astro_structure += maintenance_per_synapse × astro_fraction

    // LTD material recovery: returned to pools, enriches remaining material
    for each synapse where net_structure_change < 0:
        recovered_material = structure_loss × recycling_fraction
        pre_material      += recovered_material × pre_fraction   // AZ proteins recovered
        post_material     += recovered_material × post_fraction  // receptors to reserve
        astro_material    += recovered_material × astro_fraction × recycling_fraction
        // energy is NOT recovered — assembly ATP is gone
        // this asymmetry is why material and energy must stay separate in NIGHT

Step 4 — Homeostatic Scaling

scope NIGHT | step 4:

    if soma_tag > homeostatic_ceiling:
        scale_factor = homeostatic_ceiling / soma_tag
        for each synapse:
            post_structure *= scale_factor      // STRUCTURE WRITTEN
            pre_structure  *= scale_factor      // STRUCTURE WRITTEN
        // scaled-down material returned to pools
        soma_material += sum(structure_reduction) × recycling_fraction
        // energy NOT recovered

Step 5 — Clear All Traces

scope NIGHT | step 5:

    // Fast traces: confirmed zero (decayed during DAY)
    pre_fast_trace = post_fast_trace = dend_fast_trace = 0
    soma_fast_trace = axon_fast_trace = astro_fast_trace = 0

    // Possible tagging: confirmed zero (decayed during DAY)
    pre_possible_tagging = post_possible_tagging = dend_possible_tagging = 0
    soma_possible_tagging = axon_possible_tagging = astro_possible_tagging = 0

    // Tags: cleared after commit, carried forward if above expiry threshold
    if pre_tag   < tag_expiry_threshold: pre_tag   = 0
    if post_tag  < tag_expiry_threshold: post_tag  = 0
    if dend_tag  < tag_expiry_threshold: dend_tag  = 0
    if soma_tag  < tag_expiry_threshold: soma_tag  = 0
    if axon_tag  < tag_expiry_threshold: axon_tag  = 0
    if astro_tag < tag_expiry_threshold: astro_tag = 0

Summary: Energy and Material Flow

DAY — {component}_budget (combined fast energy + fast consumables):

    vascular_glucose_supply (FIXED)
        → astro_budget (glycolysis ROOT)
            → astro_lactate → pre_budget, post_budget, dend_budget, axon_budget
        → soma_budget (own mitochondria — independent root)
            → axon_budget (partial)
            → dend_budget (partial)

NIGHT — {component}_energy (structural assembly ATP, NOT recoverable):

    vascular_glucose_supply (FIXED)
        → astro_energy (overnight glycolysis)
        → soma_energy (overnight mitochondria) → pre_energy, post_energy,
                                                  dend_energy, axon_energy

NIGHT — {component}_material (slow structural proteins, RECOVERABLE):

    soma (CREB synthesis — soma_tag driven)
        → soma_material
            → dend_material → post_material (spine delivery)
            → axon_material → pre_material  (bouton delivery)
    astrocyte cell body (overnight synthesis)
        → astro_material (EAAT + racemase + ECM + process cytoskeleton)

    LTD recovery flows (material only — not energy):
        post LTD → post_material (receptors to dendritic reserve)
        pre LTD  → pre_material  (AZ proteins to axonal pool)
        astro LTD → astro_material (ECM fragments, recycling_fraction)

Flows

Per ora abbiamo in DAY il {component}_budget che raggruppa energy e material, e in NIGHT {component}_energy e {component}_material.

This maps onto a real biological distinction. The astrocyte's lactate and the soma's ATP fund the running costs of the cell — everything that needs to happen just to keep the system operating from moment to moment. CREB-driven protein synthesis funds the capital investment — the slow, expensive structural changes that modify what the running system is capable of. These are two different budgets in the biological sense: operating expenditure versus capital expenditure. Combining them within DAY is correct because DAY is entirely operating expenditure. Keeping them separate in NIGHT is correct because NIGHT mixes operating expenditure with capital expenditure, and only the capital component is recoverable.

Combining {component}_energy e {component}_material would hide the fact that dismantling a structure recovers biological building blocks but not the work that was done to assemble them — which is the thermodynamic reality of any construction and deconstruction process.

Energy flow

VASCULAR SUPPLY
    → ASTROCYTE CELL BODY
        glucose → lactate (glycolysis)
        → astro_budget (local ATP for clearance, D-serine, ECM, process motility)
        → lactate exported to:
            → pre_budget  (ATP for VGCC, vesicle fusion, VATPase)
            → post_budget (ATP for NaK pump, AMPA trafficking, actin)
            → dend_budget (ATP for bAP propagation, local translation)
        
    → SOMA
        soma has own mitochondria — partly self-fueled
        soma_budget (ATP for AP generation, CREB, protein synthesis, shipping)
        → dend_budget top-up (organelle delivery)
        → axon_budget top-up (transport machinery)

Material flow

SOMA
    protein synthesis (CREB-driven, peaks in NIGHT)
    → soma_material (receptors, scaffold proteins, organelles, mRNA)
        → dend_material (branch receives proteins + mRNA from soma)
            → post_material (spine receives receptors + actin from branch)
        → axon_material (boutons receive AZ proteins + VGCCs from soma via axon)
            → pre_material (bouton active zone proteins)

ASTROSYNAPSE
    ECM proteins synthesized in astrocyte cell body
    → astro_material (Glypicans, Thrombospondins, serine for D-serine)
        → cleft environment (ECM sealing, D-serine availability)

Yes, exactly. This is the essential abstract pattern. Let me state it precisely.

The Abstract Pattern

A component operates within a structure set by the previous NIGHT. During DAY, in each context, it executes behaviors that cost budget and deposit fast traces. Fast traces are local records of recent activity that bias the next behavior and open an eligibility window for tagging. A tag forms when a local eligibility signal coincides with one or more non-local validation signals within the decay window of the trace — the number of required coincidences reflecting the spatial scale at which that component sits in the system. In contexts without triggering input, all traces decay, closing the windows they opened. At NIGHT, the tag magnitude drives a structural commit proportional to available material and energy — material being recoverable and energy not — with the structural change becoming the new ceiling within which the next DAY's behaviors will operate. What is not committed decays for lack of maintenance, and the resources freed by that decay partially fund the potentiation of what was.

DAY — The General Form

Every DAY behavior follows this template:

given:   STRUCTURE        // the architectural ceiling left by NIGHT
in:      CONTEXT          // local or global triggering condition
if:      BUDGET > cost    // operational resources available
then:    behavior executes
         BUDGET  -= cost  // resources consumed
         FAST_TRACE += f(behavior)  // local record deposited

The fast trace then drives two parallel processes:

Within the same context — the trace biases the next execution of the same behavior. This is the short-term modulation loop. It is entirely local and requires no external signal.

Across contexts — the trace accumulates into possible_tagging when it exceeds the eligibility threshold. This is the bridge toward long-term change. It requires the trace to be sustained enough to survive into the NOT_AP or CONTINUOUS context.

The Tag Formation — Where Non-Locality Enters

The abstract pattern for tag formation generalizes across all components but with different coincidence requirements:

PRE, DEND, SOMA, AXON, ASTRO — one non-local coincidence:

if FAST_TRACE > eligibility       // local: this bouton was recently active
   AND dopamine > threshold       // non-local: organism-level reward signal
then: TAG += dopamine × possible_tagging

One spatial scale beyond the local component is required. The organism must confirm that the recent activity was worth saving.

POST — two non-local coincidences:

// First coincidence (NOT_bAP context):
if FAST_TRACE > Ca_TAG_threshold  // local: spine Ca²⁺ was high
   AND D-serine > threshold       // non-local 1: astrosynapse co-agonist
then: post_possible_tagging += FAST_TRACE   // CANDIDATE

// Second coincidence (bAP context):
if post_possible_tagging > threshold  // local: CANDIDATE still present
   AND bAP arrives                    // non-local 2: soma fired
then: FAST_TRACE amplified above Ca_HIGH

// Tag stabilization (any context):
if post_possible_tagging > threshold  // local: confirmed coincidence
   AND dopamine > threshold           // non-local 3: organism validation
then: TAG += dopamine × post_possible_tagging   // STABLE

Three spatial scales must align: astrosynapse, soma, organism. The postsynapse is the most constrained component — it requires the most non-local validation before committing.

Trace Recession — The Temporal Behavior

In every NOT_AP or CONTINUOUS context, all traces decay:

FAST_TRACE       *= decay(τ_fast)      // ms to seconds — closes eligibility window
possible_tagging *= decay(τ_mid)       // seconds to minutes — closes tagging window
TAG              *= decay(τ_slow)      // hours — closes commitment window

The decay is not a separate behavior — it is the passive consequence of molecular processes. But its effect is behavioral: it enforces that coincidences must happen within specific time windows. The system does not check timing explicitly — timing is enforced by the competition between accumulation and decay.

NIGHT — The General Form

given:   TAG              // strength of DAY evidence for this component
         STRUCTURE        // current architectural state
if:      TAG > threshold  // evidence strong enough to justify investment
then:
         Δstructure = min(expansion_cost,
                          MATERIAL,        // slow structural resources available
                          ENERGY × fraction) // assembly ATP available
         STRUCTURE  += Δstructure × coherence_bonus
         MATERIAL   -= Δstructure          // RECOVERABLE after LTD
         ENERGY     -= Δstructure × ATP_cost  // NOT recoverable

The coherence bonus appears when pre, post, and astro tags are all SET simultaneously — the three components of the synapse have all independently gathered evidence for the same structural change, which amplifies the commit beyond what any single tag would produce alone.

What is not potentiated passively decays:

STRUCTURE -= decay_rate × Δt_night
STRUCTURE += min(maintenance_allocation, maintenance_cost)
// if maintenance_allocation < decay_rate × Δt_night:
//   structure drifts down — depotentiation by neglect