Files
organism/elements/neuron/appunti/2026-06-15-tripartite_synapse_v8.md
T
2026-06-15 12:32:57 +02:00

52 KiB
Raw Blame History

Table of Contents
include_toc
include_toc
true

Tripartite Synapse — Pseudocode v8

Unifying principles

1. CAPACITY vs OCCUPANCY
   NIGHT builds containers (raises structural ceilings).
   DAY fills containers (occupancy driven by calcium / activity).
   Short-term potentiation = filling containers (fast, reversible, no dopamine).
   Short-term depression    = containers emptying when the driving signal decays
                              (passive consequence — never explicit).

2. TWO PLASTICITY CASES (applies to every component)
   Ca²⁺ high            → short-term potentiation (fill slots, DAY, local)
   Ca²⁺ high + dopamine → set tag → NIGHT raises the slot ceiling (long-term)

3. THREE COMPETITIVE ECONOMIES, all capped by vascular_glucose_supply
   Energy economy:    astrocyte cell body → astrosynapses → synaptic budgets (DAY + NIGHT)
   Material economy:  soma → branches/axon → spines/boutons (NIGHT)
   Each: central producer, capped output, demand/tag-weighted distribution.

4. ABSTRACT BEHAVIORAL PATTERN (every component, every context)
   given STRUCTURE (ceiling from last NIGHT)
   in CONTEXT (local/global trigger)
   if BUDGET sufficient → behavior runs, consumes budget, deposits FAST_TRACE
   FAST_TRACE biases next behavior + creates tagging eligibility
   eligibility + non-local coincidence → TAG (survives to NIGHT)
   traces decay in NOT contexts (depotentiation by neglect, never explicit)

5. SATURATING RESPONSE FORM (used everywhere a graded signal drives output)
   response = signal / (K + signal)
   little output at low signal, proportional in middle, saturates when high.

6. DAY vs NIGHT variable naming
   DAY:   {component}_budget   (fast energy + fast consumables, one variable)
   NIGHT: {component}_energy   (assembly ATP, NOT recoverable)
          {component}_material (structural proteins, RECOVERABLE after LTD)

Part 1 — Conventions

SCOPE   = { DAY, NIGHT }
CONTEXT = { AP, NOT_AP, bAP, NOT_bAP, CONTINUOUS }
COMPONENTS = { PRE, POST, DEND, SOMA, AXON, ASTRO }

FIXED       = imposed externally — constant during run
VAR         = changes dynamically
FAST_TRACE  = DAY only, decays automatically, biases next behavior
TAG         = DAY→NIGHT bridge, decays slowly, gates structural commit
              POST: CANDIDATE → STABLE phases
BUDGET      = DAY operational resource (energy + consumables)
ENERGY      = NIGHT assembly ATP (not recoverable)
MATERIAL    = NIGHT structural proteins (recoverable after LTD)
STRUCTURE   = capacity ceiling; READ in DAY, WRITTEN in NIGHT

Part 2 — Fixed Parameters

// Saturation half-points (Option 2 form: x/(K+x))
FIXED  K_Ca_release        // half-max Ca²⁺ for NT release
FIXED  K_glu_AMPA          // half-max glutamate for AMPA current
FIXED  K_Ca_Dserine        // half-max astro Ca²⁺ for D-serine release

// Thresholds
FIXED  Mg_eject_threshold  // Vm to eject NMDA Mg²⁺ block
FIXED  Ca_STP_threshold    // Ca²⁺ for short-term potentiation (fill slots)
FIXED  Ca_TAG_threshold    // Ca²⁺ for tagging eligibility
FIXED  eligibility_threshold
FIXED  dopamine_threshold
FIXED  tagging_threshold
FIXED  tag_expiry_threshold
FIXED  spillover_threshold
FIXED  inactivation_threshold  // soma Na⁺ inactivation gating refractory
FIXED  homeostatic_ceiling
FIXED  structural_decay_rate
FIXED  recycling_fraction

// Organism-level signals (externally driven)
FIXED  dopamine_level
FIXED  NE_level
FIXED  ACh_level

// Physical
FIXED  vascular_glucose_supply  // hard ceiling — root of energy economy
FIXED  branch_geometry          // bAP attenuation profile

Part 3 — Resource Variables

// ── DAY BUDGETS (energy + fast consumables) ───────────────────────────
VAR astro_budget   // ROOT: glycolysis from vascular_glucose_supply (self-produced)
VAR pre_budget     // from astro_lactate (primary) + axon shipment (secondary)
VAR post_budget    // from astro_lactate (primary) + dend shipment (secondary)
VAR dend_budget    // from astro_lactate (primary) + soma shipment (secondary)
VAR soma_budget    // ROOT: own mitochondria (self-produced)
VAR axon_budget    // from soma shipment (primary) + astro_lactate (secondary)

// ── ENERGY ECONOMY: astrocyte central → astrosynapses ─────────────────
VAR astro_central_budget   // cell body lactate production (DAY)
VAR astro_central_energy   // cell body assembly ATP (NIGHT)
VAR astro_central_material // cell body structural proteins (NIGHT)
VAR astro_lactate[i]       // demand-weighted export to synapse i (DAY)

// ── NIGHT ENERGY (assembly ATP, not recoverable) ──────────────────────
VAR pre_energy, post_energy, dend_energy, soma_energy, axon_energy, astro_energy

// ── NIGHT MATERIAL (structural proteins, recoverable) ─────────────────
VAR soma_material   // ROOT: CREB-driven synthesis (soma_tag gated)
VAR dend_material   // from soma_material
VAR post_material   // from dend_material
VAR axon_material   // from soma_material
VAR pre_material    // from axon_material
VAR astro_material  // from astro_central_material

Part 4 — Structural Variables (capacity ceilings, WRITTEN in NIGHT)

VAR pre_structure   // docking_slot_ceiling + VGCC_coupling + refill_ceiling
VAR post_structure  // anchoring_slot_ceiling + spine_volume + reserve_ceiling
VAR dend_structure  // bAP_fidelity(position) + translation_ceiling
VAR soma_structure  // baseline_threshold⁻¹ + AP_reliability + synthesis_ceiling
VAR axon_structure  // propagation_reliability + transport_ceiling
VAR astro_structure // perisynaptic_distance⁻¹ + EAAT_density + D_serine_tonic
                    // + ECM_integrity   (SELF-REINFORCING both directions)

Part 5 — Trace Variables

FAST_TRACE  pre_fast_trace     // residual Ca²⁺          τ≈100ms
FAST_TRACE  post_fast_trace    // spine Ca²⁺ × rise_speed τ≈tens ms
FAST_TRACE  dend_fast_trace    // branch Ca²⁺            τ≈300ms
FAST_TRACE  soma_fast_trace    // nuclear Ca²⁺           τ≈seconds
FAST_TRACE  axon_fast_trace    // propagation load       τ≈seconds
FAST_TRACE  astro_fast_trace   // perisynaptic Ca²⁺      τ≈seconds

// soma timing traces (emergent refractory + adaptation)
FAST_TRACE  soma_Na_inactivation        // fast — gates refractory   τ≈ms
FAST_TRACE  soma_adaptation             // slow — spike-train threshold τ≈100s of ms
FAST_TRACE  soma_refractory_alignment   // bottom-up input-alignment trace

VAR  {component}_possible_tagging   // intermediate τ≈secondsminutes
TAG  {component}_tag                 // slow τ≈hours; POST has CANDIDATE→STABLE


SCOPE: DAY

Execution contexts consume budget, deposit traces, fill slots (occupancy). NOT contexts replenish budget, ship downstream, decay traces, set tags. STRUCTURE is READ only.


PRE

CONTEXT: AP

scope DAY | context AP:

    if pre_budget < AP_release_cost:
        suppress(NT_flux); exit context        // depleted bouton silent

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

    // NT flux — saturating Ca²⁺ drive (Option 2) × current vesicle occupancy
    Ca_drive = pre_fast_trace / (K_Ca_release + pre_fast_trace)
    if RRP_level > 0:
        NT_flux    = RRP_level × Ca_drive
        glutamate += NT_flux × Δt
        RRP_level -= NT_flux × Δt              // occupancy falls (STD consequence)
        pre_budget -= NT_flux × fusion_cost

    // Refill docking slots — bounded by pre_structure ceiling (DAY fills NIGHT's container)
    RRP_refill = min(refill_rate_constant, pre_structure.refill_ceiling)
    RRP_level += RRP_refill × Δt
    RRP_level  = clamp(RRP_level, 0, pre_structure.docking_slot_ceiling)
    pre_budget -= RRP_refill × VATPase_cost    // throttled if budget low → STD deepens

    // Overflow brake (mGluR2/3 Gi) — cross-compartment, no pre cost
    if glutamate > spillover_threshold:
        Ca_drive *= mGluR_brake_factor

CONTEXT: NOT_AP

scope DAY | context NOT_AP:

    pre_fast_trace *= decay(τ=100ms)

    // Budget replenishment — two sources
    pre_budget += astro_lactate[this_synapse] × pre_fraction   // primary, fast, local
    pre_budget += axon_shipment_to_pre                          // secondary, from soma via axon

    // Docking slots refill toward ceiling (STP recovery)
    RRP_refill = min(refill_rate_constant, pre_structure.refill_ceiling)
    RRP_level += RRP_refill × Δt
    RRP_level  = clamp(RRP_level, 0, pre_structure.docking_slot_ceiling)
    pre_budget -= RRP_refill × VATPase_cost

    // Tagging: eligibility (local) + dopamine (non-local) coincide
    if pre_fast_trace > eligibility_threshold:
        pre_possible_tagging += pre_fast_trace
    pre_possible_tagging *= decay(τ=seconds)
    dopamine_local *= decay(τ=hundreds_ms)
    if dopamine_local > dopamine_threshold and pre_possible_tagging > tagging_threshold:
        pre_tag += dopamine_local × pre_possible_tagging
    pre_tag *= decay(τ=hours)

POST

Three calcium sources, two plasticity cases

// Ca²⁺ sources (all feed post_fast_trace):
//   1. AMPA opens  → small Ca²⁺ + depolarization (begins ejecting Mg²⁺)
//   2. NMDA opens  → large Ca²⁺   (needs: NT bound + D-serine + Mg²⁺ ejected)
//   3. bAP arrives → Ca²⁺ via VDCC + further depolarization
//
// Case 1 (DAY, local):       Ca²⁺ high            → fill anchoring slots (STP)
// Case 2 (DAY→NIGHT):        Ca²⁺ high + dopamine → tag → NIGHT raises slot ceiling
// Depression: surface AMPA drift back to reserve when Ca²⁺ decays (consequence)

CONTEXT: NOT_bAP

scope DAY | context NOT_bAP:

    post_budget += astro_lactate[this_synapse] × post_fraction
    post_budget += dend_shipment_to_post

    // SOURCE 1: AMPA opens — current + small Ca²⁺ + starts Mg²⁺ ejection
    // current saturates with glutamate (Option 2), scaled by surface AMPA occupancy
    AMPA_drive       = glutamate / (K_glu_AMPA + glutamate)
    AMPA_current     = AMPA_drive × AMPA_surface          // AMPA_surface = current occupancy
    Vm              += AMPA_current
    post_fast_trace += AMPA_Ca_fraction × AMPA_current
    post_budget     -= AMPA_current_cost

    // SOURCE 2: NMDA opens — large Ca²⁺ if coincidence holds
    if Vm > Mg_eject_threshold and astro_D_serine > D_serine_threshold and glutamate > 0:
        Ca_influx        = NMDA_Ca_influx(glutamate)
        post_fast_trace += Ca_influx × rise_speed(Ca_influx)
        post_budget     -= NMDA_current_cost

    post_fast_trace *= decay(τ=tens_ms)

    // CASE 1 — SHORT-TERM POTENTIATION (no dopamine needed)
    // Ca²⁺ high → pull AMPA from reserve to surface, bounded by slot ceiling
    if post_fast_trace > Ca_STP_threshold:
        AMPA_surface = min(AMPA_surface + Ca_driven_insertion(post_fast_trace),
                           post_structure.anchoring_slot_ceiling)  // DAY fills NIGHT's container
        post_budget -= AMPA_trafficking_cost
    else:
        // CONSEQUENCE — depression: receptors drift back to reserve as Ca²⁺ low
        AMPA_surface = max(AMPA_surface - passive_drift_rate × Δt, baseline_surface)
        // not explicit, not signaled — pure relaxation toward baseline occupancy

    // CASE 2 — tagging for long-term (CANDIDATE)
    if post_fast_trace > Ca_TAG_threshold:
        post_possible_tagging += post_fast_trace
    post_possible_tagging *= decay(τ=minutes)             // CANDIDATE lifetime
    post_budget -= PKA_priming_cost

    dopamine_local *= decay(τ=hundreds_ms)
    if dopamine_local > dopamine_threshold and post_possible_tagging > tagging_threshold:
        post_tag += dopamine_local × post_possible_tagging    // STABLE
    post_tag *= decay(τ=hours)

CONTEXT: bAP

scope DAY | context bAP:

    // SOURCE 3: bAP — depolarization + Ca²⁺, amplifies existing signal
    Vm              += bAP_depolarization × dend_structure.bAP_fidelity
    post_budget     -= bAP_reset_cost
    if post_possible_tagging > Ca_TAG_threshold:           // coincidence: bAP finds CANDIDATE
        post_fast_trace += bAP_Ca_boost()                  // supralinear summation > Ca_HIGH
    // bAP alone with no prior Ca²⁺ → no boost, no tag (timing enforced by trace decay)

DEND

CONTEXT: bAP

scope DAY | context bAP:

    bAP_local        = propagate_bAP(SOMA.AP_fired, dend_structure.bAP_fidelity, branch_geometry)
    dend_budget     -= bAP_propagation_cost
    dend_fast_trace += bAP_Ca_influx(bAP_local) + spine_Ca_spillover(active_spines)
    dend_fast_trace *= decay(τ=300ms)
    dend_budget     -= branch_Ca_handling_cost
    branch_Vm        = integrate(POST.Vm, all_spines)
    dend_budget     -= integration_cost

CONTEXT: NOT_bAP

scope DAY | context NOT_bAP:

    dend_fast_trace *= decay(τ=300ms)

    // Replenish (from soma + astrocyte), then ship to spines
    dend_budget += soma_shipment_to_dend + astro_lactate[this_branch] × dend_fraction
    dend_shipment_to_post = min(dend_budget × post_delivery_fraction, post_demand)
    post_budget += dend_shipment_to_post
    dend_budget -= dend_shipment_to_post

    // Tagging
    if dend_fast_trace > eligibility_threshold:
        dend_possible_tagging += dend_fast_trace
    dend_possible_tagging *= decay(τ=seconds)
    dopamine_local *= decay(τ=hundreds_ms)
    if dopamine_local > dopamine_threshold and dend_possible_tagging > tagging_threshold:
        dend_tag += dopamine_local × dend_possible_tagging
    dend_tag *= decay(τ=hours)

    // Local translation (fills dend capacity faster) if tagged + budget
    if dend_tag > tag_expiry_threshold and dend_budget > translation_cost:
        dend_budget -= translation_cost      // uses fast mRNA consumables in budget

    commit_threshold *= 1 / (1 + ACh_level × ACh_gain)

SOMA

Emergent refractory + adaptation + bottom-up input alignment

CONTEXT: AP

scope DAY | context AP:

    // Threshold = baseline(structure) raised by adaptation + neuromodulators
    effective_threshold = soma_structure.baseline_threshold
                          × (1 + soma_adaptation)
                          × neuromod_factor(NE_level, ACh_level)
    can_fire = (soma_Na_inactivation < inactivation_threshold)   // refractory = emergent

    if branch_Vm > effective_threshold and can_fire:
        AP_fired = True
        soma_budget -= AP_generation_cost

        // Deposit three traces from one AP:
        soma_Na_inactivation += AP_amplitude        // fast → refractory gating
        soma_adaptation      += AP_contribution      // slow → spike-train threshold rise
        soma_fast_trace      += nuclear_Ca_influx()  // slow → plasticity tagging
        soma_budget -= nuclear_Ca_handling_cost

        if soma_fast_trace > eligibility_threshold:
            soma_possible_tagging += soma_fast_trace
        soma_possible_tagging *= decay(τ=seconds)
        dopamine_local *= decay(τ=hundreds_ms)
        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

CONTEXT: NOT_AP

scope DAY | context NOT_AP:

    // BOTTOM-UP ALIGNMENT: suprathreshold input during refractory = missed coincidence
    // leaves a trace that speeds future recovery (potentiation of recovery, DAY)
    if branch_Vm > effective_threshold and soma_Na_inactivation > inactivation_threshold:
        soma_refractory_alignment += (branch_Vm - effective_threshold) × soma_Na_inactivation

    // Recovery biased by alignment trace; alignment decays (depotentiation by neglect)
    recovery_rate          = base_recovery_rate × (1 + soma_refractory_alignment)
    soma_Na_inactivation  *= decay(τ_Na / recovery_rate)
    soma_adaptation       *= decay(τ_adaptation)
    soma_fast_trace       *= decay(τ_nuclear)
    soma_refractory_alignment *= decay(τ_alignment)   // self-limiting equilibrium

    // Self-replenish (own mitochondria) — soma is a root
    soma_budget += mitochondria_output_rate × Δt
    branch_Vm    = integrate(DEND.branch_Vm, all_branches)

    // Ship budget downstream
    soma_shipment_to_dend = min(soma_budget × dend_delivery_fraction, dend_demand(dend_tag))
    dend_budget += soma_shipment_to_dend; soma_budget -= soma_shipment_to_dend + shipping_cost
    soma_shipment_to_axon = min(soma_budget × axon_delivery_fraction, axon_demand(axon_tag))
    axon_budget += soma_shipment_to_axon; soma_budget -= soma_shipment_to_axon + shipping_cost

AXON

CONTEXT: AP

scope DAY | context AP:

    propagation_reliability = axon_structure.propagation × (1 - failure_rate(axon_fast_trace))
    APs_delivered  = AP_fired × propagation_reliability
    axon_budget   -= AP_propagation_cost × APs_delivered
    axon_fast_trace += APs_delivered
    axon_fast_trace *= decay(τ=seconds)      // high load → failure → axonal STD

CONTEXT: NOT_AP

scope DAY | context NOT_AP:

    axon_fast_trace *= decay(τ=seconds)
    axon_budget += soma_shipment_to_axon + astro_lactate[shaft] × axon_fraction

    // Ship to boutons
    axon_shipment_to_pre = min(axon_budget × pre_delivery_fraction, pre_demand(pre_tag))
    pre_budget += axon_shipment_to_pre; axon_budget -= axon_shipment_to_pre + axon_shipping_cost

    if axon_fast_trace > eligibility_threshold:
        axon_possible_tagging += axon_fast_trace
    axon_possible_tagging *= decay(τ=seconds)
    dopamine_local *= decay(τ=hundreds_ms)
    if dopamine_local > dopamine_threshold and axon_possible_tagging > tagging_threshold:
        axon_tag += dopamine_local × axon_possible_tagging
    axon_tag *= decay(τ=hours)

ASTRO

Demand-weighted energy distribution across the territory

CONTEXT: CONTINUOUS

scope DAY | context CONTINUOUS:

    // ROOT production at cell body — capped by vasculature
    astro_central_budget += glycolysis(vascular_glucose_supply) × Δt

    // DEMAND-WEIGHTED LACTATE ALLOCATION across all astrosynapses i
    //   demand rises with clearance load (activity) AND delivery efficiency (structure)
    for each astrosynapse i in territory:
        demand[i] = clearance_load[i] × astro_structure[i].delivery_efficiency
    total_demand     = sum(demand)
    allocation_factor = min(1, astro_central_budget / (total_demand × lactate_cost + ε))
    for each astrosynapse i:
        astro_lactate[i]      = demand[i] × allocation_factor      // slow synapse → low demand → little fuel
        astro_central_budget -= astro_lactate[i] × lactate_cost
        // delivered to that synapse's pre/post/dend budgets in their NOT contexts

    // Per-astrosynapse fast operation (one synapse i shown)
    glutamate[i]            -= astro_structure[i].EAAT_density × glutamate[i] × Δt   // clearance
    astro_central_budget    -= clearance × EAAT_ATP_cost
    astro_D_serine[i]       += astro_structure[i].D_serine_tonic × Δt                // tonic baseline

    if glutamate[i] > spillover_threshold:
        astro_fast_trace[i] += mGluR5_Ca_influx()
        astro_fast_trace[i] *= decay(τ=seconds)
        // D-serine pulse — saturating in astro Ca²⁺ (Option 2), budget-limited
        Ds_drive = astro_fast_trace[i] / (K_Ca_Dserine + astro_fast_trace[i])
        D_serine_pulse = min(Ds_drive × Ds_max, astro_central_budget × Ds_fraction)
        astro_D_serine[i]    += D_serine_pulse
        astro_central_budget -= D_serine_pulse × Ds_synthesis_cost
        Ca_drive_pre[i]      *= mGluR_brake_factor          // simultaneous PRE brake

        if astro_fast_trace[i] > eligibility_threshold:
            astro_possible_tagging[i] += astro_fast_trace[i]
        astro_possible_tagging[i] *= decay(τ=seconds)
        dopamine_local *= decay(τ=hundreds_ms)
        if dopamine_local > dopamine_threshold and astro_possible_tagging[i] > tagging_threshold:
            astro_tag[i] += dopamine_local × astro_possible_tagging[i]
        astro_tag[i] *= decay(τ=hours)

    if astro_fast_trace[i] > OVERLOAD_threshold:
        trigger(shockwave_lockdown)


SCOPE: NIGHT

NIGHT builds containers (raises ceilings). Budgets/energy/material replenished. Tags evaluated and cleared. Depotentiation = unmaintained decay (never explicit).


Step 1 — Replenish & Distribute (two economies)

scope NIGHT | step 1:

    // ── ENERGY ECONOMY: astrocyte cell body → astrosynapses ─────────────
    astro_central_budget   += overnight_glycolysis(vascular_glucose_supply) × Δt_night
    astro_central_energy   += overnight_astro_energy_synthesis() × Δt_night
    astro_central_material += astrocyte_cellbody_synthesis() × Δt_night

    // distribute to tagged astrosynapses by astro_tag-weighted competition
    total_w = sum(astro_tag[i] for taggable i)
    for each astrosynapse i with astro_tag[i] > tag_expiry_threshold:
        w = astro_tag[i] / total_w
        astro_energy[i]   += astro_central_energy   × w
        astro_material[i] += astro_central_material × w
        astro_central_energy   -= astro_energy[i];  astro_central_material -= astro_material[i]

    // ── MATERIAL ECONOMY: soma → branches/axon → spines/boutons ─────────
    soma_budget   += overnight_mitochondria_output() × Δt_night
    soma_energy   += overnight_soma_energy_reserve() × Δt_night
    soma_material += CREB_driven_synthesis(soma_tag) × Δt_night   // bottleneck, soma_tag gated

    dend_material += soma_material × dend_material_fraction
    axon_material += soma_material × axon_material_fraction
    soma_material -= (dend_material_fraction + axon_material_fraction) × soma_material
    post_material += dend_material × spine_material_fraction;  dend_material -= ...
    pre_material  += axon_material × bouton_material_fraction;  axon_material -= ...

    // downstream assembly energy from soma; next-DAY budgets pre-loaded from astrocyte
    {pre,post,dend,axon}_energy += soma_energy × {..}_energy_fraction
    {pre,post,dend,axon}_budget += astro_lactate_reserve × {..}_fraction × Δt_night

Step 2 — Structural Commits (build containers; parallel, independent)

scope NIGHT | step 2:

    coherence_bonus = (pre_tag, post_tag, astro_tag all > tag_expiry_threshold)
                      ? coherence_factor : 1.0

    // each commit RAISES A CEILING (capacity), gated by tag, material, energy
    // DAY then fills the raised ceiling via calcium-driven occupancy

    if pre_tag > tag_expiry_threshold:
        Δ = min(slot_cost, pre_material, pre_energy × pre_fraction)
        pre_structure.docking_slot_ceiling += Δ × coherence_bonus    // MORE slots, not more vesicles
        pre_material -= Δ; pre_energy -= Δ × assembly_cost
        if Δ < slot_cost: queue(pre_deficit → next NIGHT)

    if post_tag > tag_expiry_threshold:
        Δ = min(slot_cost, post_material, post_energy × post_fraction)
        post_structure.anchoring_slot_ceiling += Δ × coherence_bonus // MORE slots for DAY to fill
        post_material -= Δ; post_energy -= Δ × assembly_cost
        if Δ < slot_cost: queue(post_deficit → next NIGHT)

    if dend_tag > tag_expiry_threshold:
        Δ = min(branch_cost, dend_material, dend_energy × dend_fraction)
        dend_structure += Δ × coherence_bonus
        dend_material -= Δ; dend_energy -= Δ × assembly_cost

    if soma_tag > tag_expiry_threshold:
        Δ = min(soma_cost, soma_material, soma_energy × soma_fraction)
        soma_structure += Δ
        soma_material -= Δ; soma_energy -= Δ × assembly_cost

    if axon_tag > tag_expiry_threshold:
        Δ = min(axon_cost, axon_material, axon_energy × axon_fraction)
        axon_structure += Δ
        axon_material -= Δ; axon_energy -= Δ × assembly_cost

    if astro_tag[i] > tag_expiry_threshold:
        Δ = min(process_cost, astro_material[i], astro_energy[i] × astro_fraction)
        astro_structure[i] += Δ × coherence_bonus     // walls IN, ECM, D-serine tonic ↑
        astro_material[i] -= Δ; astro_energy[i] -= Δ × assembly_cost
        // SELF-REINFORCING: higher astro_structure → future LTP easier

Step 3 — Passive Depotentiation (unmaintained decay)

scope NIGHT | step 3:

    remaining_material   = total_material_pool - material_consumed_by_commits
    maintenance_per_syn  = remaining_material × maintenance_fraction / synapse_count

    for each synapse:
        // all ceilings decay
        {pre,post,dend,astro}_structure -= structural_decay_rate × Δt_night
        // maintenance counters decay only where resources suffice
        if maintenance_per_syn >= maintenance_cost:
            {pre,post,dend,astro}_structure += full_maintenance   // stable
        else:
            {pre,post,dend,astro}_structure += maintenance_per_syn × fractions
            // shortfall → ceilings drift down → DEPOTENTIATION BY NEGLECT

    // material (not energy) recovered from shrinking structures → back to pools
    for each synapse with net_structure_change < 0:
        recovered = |net_structure_change| × recycling_fraction
        {pre,post,astro}_material += recovered × fractions

Step 4 — Homeostatic Scaling

scope NIGHT | step 4:

    if soma_tag > homeostatic_ceiling:
        s = homeostatic_ceiling / soma_tag
        for each synapse:
            post_structure.anchoring_slot_ceiling *= s
            pre_structure.docking_slot_ceiling    *= s
        soma_material += sum(ceiling_reduction) × recycling_fraction

Step 5 — Clear Traces

scope NIGHT | step 5:

    all fast_traces = 0
    all possible_tagging = 0
    soma_Na_inactivation = soma_adaptation = soma_refractory_alignment = 0
    for each tag: if tag < tag_expiry_threshold: tag = 0   // else carry to next NIGHT

Summary — the model in one view

DAY  fills containers (occupancy ↑ with Ca²⁺, ↓ when Ca²⁺ decays = STP/STD)
     consumes budget; budget from astrocyte (demand-weighted) + soma shipments
     deposits fast traces; eligibility + dopamine coincidence → tags
NIGHT builds containers (ceilings ↑) for tagged synapses, by two competing economies:
     energy (astrocyte→astrosynapse) and material (soma→spine/bouton)
     unmaintained ceilings decay → depotentiation by neglect
     recovered material funds neighbors → conservation across the territory

Joint criterion to be remembered:
   active enough to be FUELED (win energy economy, generate Ca²⁺ + clearance demand)
   + significant enough to be TAGGED (Ca²⁺ + dopamine coincidence)
   → container built in NIGHT, filled in DAY, maintained while still earning resources



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

More details

SOMA

The Abstract Pattern Applied to Soma Timing

The abstract pattern says: a behavior deposits a trace, the trace decays, and the trace biases the next behavior. For the soma, the AP is the behavior, and the refractory period and threshold elevation should both be consequences of a single trace deposited by the AP, decaying back toward baseline. Neither should be a hardcoded duration — both should emerge from the return of the trace to resting conditions.


Yes, this is much more consistent with the rest of the architecture. The soma should not compute an explicit rhythm estimate and predict the next input — that is top-down. Instead, the mismatch itself leaves a trace, and that trace adjusts the refractory dynamics. Let me think through this carefully.


The Bottom-Up Mechanism

The key event is: a dendritic input arrives strong enough to fire the soma, but the soma is still refractory. This is a missed opportunity — the input wanted to fire the cell, but the cell was not ready. This mismatch is the signal.

Each time this happens, it should leave a trace that biases the refractory dynamics toward recovering faster in that timing window — so that next time an input arrives at that phase, the soma is ready. This is potentiation of the refractory recovery, occurring within DAY, driven entirely by the local coincidence of "input wanted to fire" and "soma was not ready."

scope DAY | context NOT_AP (within refractory):

    // Detect the mismatch: suprathreshold input during refractory
    if branch_Vm > effective_threshold and soma_Na_inactivation > inactivation_threshold:
        // Input arrived but soma could not fire — missed coincidence
        refractory_alignment_trace += (branch_Vm - effective_threshold)
                                       × soma_Na_inactivation
        // graded: stronger input + deeper refractory → larger trace
        // this is the "potentiation" signal for faster recovery

The refractory_alignment_trace then biases the recovery rate of the inactivation trace:

    // Recovery rate biased by accumulated alignment trace
    recovery_rate = base_recovery_rate × (1 + refractory_alignment_trace)
    soma_Na_inactivation *= decay(τ_Na / recovery_rate)
    // more alignment trace → faster recovery → soma ready sooner next time

Why This Is Bottom-Up

There is no rhythm estimation, no prediction of the next input time, no computed inter-input interval. The soma does not model its input. It simply notices, locally and reactively, that an input arrived when it was not ready, and leaves a trace that makes it recover faster. Over many such mismatches at the same phase, the recovery speeds up at that phase specifically — and the soma ends up aligned with its input rhythm without ever representing that rhythm.

The alignment is an emergent statistical consequence of many local mismatch events, exactly as a potentiated synapse becomes tuned to its input without representing what it is tuned to. The phase-coupling appears, but nothing in the soma computed it.


Depotentiation as Neglect — Not Explicit

Now the crucial part you raised: the depotentiation of refractory alignment must occur as a consequence of not potentiating, not as an explicit opposing mechanism.

The refractory_alignment_trace decays continuously. If mismatches keep happening at a particular phase, the trace is continuously replenished and the fast recovery is maintained. If mismatches stop happening — because the input rhythm changed, or because the alignment succeeded and inputs now arrive when the soma is ready — then the trace is no longer replenished and decays back toward baseline on its own.

    // No explicit depotentiation — just decay when not reinforced
    refractory_alignment_trace *= decay(τ_alignment)
    // if mismatches continue → trace replenished → fast recovery maintained
    // if mismatches stop → trace decays → recovery returns to baseline

This is exactly parallel to synaptic depotentiation by neglect. The soma does not actively slow its recovery when alignment is no longer needed. It simply stops receiving the mismatch signal that was keeping the recovery fast, and the recovery drifts back to baseline because the trace that accelerated it is no longer reinforced.

There is an elegant self-limiting property here. Once the soma is well-aligned, inputs arrive when it is ready, so there are no more mismatches, so the alignment trace stops being replenished and begins to decay. This would slowly de-align the soma — until inputs start arriving during refractory again, regenerating the mismatch and re-potentiating the alignment. The system settles into a dynamic equilibrium where just enough mismatch occurs to maintain just enough alignment. The soma hovers at the edge of alignment, continuously corrected by the residual mismatches that its imperfect alignment produces.


The Full Bottom-Up Soma Timing

scope DAY | context AP:

    effective_threshold = soma_structure.baseline_threshold
                          × (1 + soma_adaptation)
                          × neuromod_factor(NE_level, ACh_level)

    can_fire = (soma_Na_inactivation < inactivation_threshold)

    if branch_Vm > effective_threshold and can_fire:
        AP_fired = True
        soma_budget -= AP_generation_cost

        // Deposit traces from the AP
        soma_Na_inactivation += AP_amplitude       // fast — refractory
        soma_adaptation      += AP_contribution     // slow — spike train threshold
        soma_fast_trace      += nuclear_Ca_influx() // slow — plasticity tagging

scope DAY | context NOT_AP:

    // MISMATCH DETECTION — bottom-up alignment signal
    if branch_Vm > effective_threshold and soma_Na_inactivation > inactivation_threshold:
        // input wanted to fire but soma was refractory — missed coincidence
        refractory_alignment_trace += (branch_Vm - effective_threshold)
                                       × soma_Na_inactivation
        // local potentiation of recovery — no prediction, no rhythm model

    // Recovery biased by alignment trace
    recovery_rate = base_recovery_rate × (1 + refractory_alignment_trace)
    soma_Na_inactivation *= decay(τ_Na / recovery_rate)    // faster if aligned
    soma_adaptation      *= decay(τ_adaptation)
    soma_fast_trace      *= decay(τ_nuclear)

    // Alignment trace decays — depotentiation by neglect, not explicit
    refractory_alignment_trace *= decay(τ_alignment)
    // maintained only while mismatches continue
    // self-limiting: good alignment → fewer mismatches → trace decays →
    //                slight de-alignment → mismatches return → re-potentiation

    // ... budget replenishment, shipments, tagging as before ...

The Conceptual Payoff

This makes the soma's temporal alignment obey exactly the same principles as everything else in the system:

A behavior leaves a trace — here the missed coincidence leaves the alignment trace.

The trace biases future behavior — here it accelerates recovery so the next input at that phase succeeds.

Potentiation is the active drive — the soma actively speeds up recovery in response to mismatch.

Depotentiation is neglect — the alignment trace decays when mismatches stop, with no explicit opposing process.

The system finds equilibrium through the residual of its own imperfection — just enough mismatch persists to maintain just enough alignment.

And critically, the soma achieves temporal prediction — firing in phase with its input rhythm — without ever representing the rhythm. The prediction is implicit in the structure of the recovery dynamics, built up from purely local, reactive, bottom-up trace deposits. This is the same way a potentiated synapse "predicts" that its input will be significant without representing the prediction: the prediction is the physical bias left by past experience, not a computed expectation. The soma's phase-coupling is the temporal version of the synapse's weight — both are implicit predictions encoded as physical bias, both built bottom-up from local coincidence, both maintained by reinforcement and lost by neglect.

Energy depletion in Presynapse

how does the budget and energy influence the model. If for example a presynapse has no more energy variuos times during day, what happens?

Good question. Let me trace through exactly what happens when energy is repeatedly depleted, following the mechanics already in the pseudocode.


The Immediate Effect — Behavior Suppression

When pre_budget < AP_release_cost, the pseudocode does:

if pre_budget < AP_release_cost:
    suppress(NT_flux)
    exit context

So the immediate consequence of an energy-depleted bouton is silence — it does not release neurotransmitter for that AP, regardless of how strong the incoming spike was. The AP arrives, but nothing comes out the other side. This is biologically real: ATP-depleted boutons fail to release because the VATPase cannot refill vesicles and the calcium pumps cannot maintain the gradients that drive release.


The Cascade of Consequences Within DAY

A single depletion is recoverable — the bouton refuels from astrocyte lactate in the next NOT_AP context and resumes. But repeated depletion during DAY sets off a cascade that runs through the entire trace and tagging machinery.

No release means no glutamate means no downstream trace. When the bouton is silent, no glutamate reaches the cleft. The postsynapse receives no AMPA current, its NMDA channels do not open, and post_fast_trace does not rise. The astrosynapse detects no spillover, so astro_fast_trace does not rise and no D-serine pulse is released. The entire synaptic event simply does not happen. A bouton that is energy-depleted at the moment a significant pattern arrives causes that pattern to be invisible to the postsynapse — the synapse fails to participate in whatever the network is doing.

No participation means no eligibility. Because the bouton did not release, pre_fast_trace is not elevated by a release event (it still rises from calcium influx, but without the reinforcing facilitation of successful release). More importantly, the postsynapse, having received no input, accumulates no post_possible_tagging. When dopamine arrives to validate the moment, there is nothing to validate at this synapse — the eligibility window is empty. The synapse misses the tagging opportunity entirely.

Missing the tag means missing the NIGHT commit. Since no tag was set during DAY, the synapse has nothing to draw structural resources with during NIGHT. It does not potentiate. And because the system's depotentiation is by neglect, a synapse that fails to potentiate is automatically on the path to depotentiation — it receives only maintenance allocation, and if other synapses potentiated and drew down the shared pool, even maintenance may be insufficient.


The Deeper Consequence — Energy Depletion Becomes Structural Depression

Here is the important emergent property: repeated energy depletion at a bouton during DAY leads to its structural depression during NIGHT, even though no depression signal was ever sent.

The chain is entirely passive:

repeated pre_budget depletion in DAY
    → bouton silent during significant events
    → no glutamate release
    → no post_fast_trace, no post_possible_tagging
    → no tag set (pre or post)
    → no NIGHT structural commit at this synapse
    → only maintenance allocation received
    → if pool depleted by other synapses' potentiation:
        maintenance insufficient
    → pre_structure and post_structure decay
    → DEPOTENTIATION

The energy-starved synapse is outcompeted not because it was marked for depression but because it could not generate the activity needed to claim resources. Energy availability during DAY therefore directly determines which synapses can even enter the competition for NIGHT potentiation.


The Feedback Loop — Depression Reduces Future Energy Demand

There is a stabilizing feedback here. A depotentiated synapse has smaller pre_structure — a smaller active zone, fewer docking slots, lower release probability. This means it costs less energy to operate. So a synapse that was energy-starved and consequently depotentiated now has lower energy demands, making it less likely to be energy-starved in the future.

energy depletion → depotentiation → smaller structure → lower energy demand
    → less likely to deplete → stabilizes at a low-activity equilibrium

The synapse settles into a low-energy, low-structure, low-activity state. It is not dead — it still operates at baseline — but it has been demoted from the pool of synapses competing for potentiation. Energy scarcity has selected it out.


Why This Is Functionally Important

This is not a bug — it is a resource-allocation mechanism with real computational value.

Energy availability acts as a second gate on plasticity, parallel to the neuromodulatory gate. Dopamine asks "was this worth saving?" Energy asks "can this synapse afford to participate?" A synapse must pass both gates to be potentiated. This means the system preferentially potentiates synapses that are both behaviorally significant AND metabolically sustainable. A synapse that cannot sustain its own activity is not a good candidate for strengthening, because strengthening it would only increase its energy demand and make it fail more often.

Local energy competition implements a form of spatial sparsification. Boutons on the same axon share axon_budget and ultimately the same astrocytic lactate supply. When many boutons are active simultaneously, the shared energy is divided among them, and the weakest — those with the least efficient structure or the least reliable input — deplete first and fall silent. This automatically sparsifies activity: under energy pressure, only the most robust synapses keep firing, and they are the ones that get potentiated. The system concentrates its limited resources on its strongest connections.

The astrocyte's energy delivery becomes a control signal. Because the astrocyte controls lactate distribution across its territory, it has indirect control over which synapses can sustain activity and therefore which can be potentiated. A region of the astrocyte territory that is well-perfused and well-fueled supports vigorous plasticity. A region that is metabolically stressed — perhaps because of high overall demand or reduced vascular supply — suppresses plasticity in its synapses regardless of their activity. This couples the metabolic state of the tissue directly to its capacity to learn.


What Repeated Depletion Looks Like Over Days

If a bouton is chronically energy-starved across multiple DAY cycles — perhaps because it is in a metabolically compromised region, or because it is competing with many highly active neighbors — the trajectory is:

Day 1: depletes occasionally → misses some events → weak tag → partial commit
Day 2: smaller structure → still depletes under load → weaker tag → less commit
Day 3: structure decaying → maintenance insufficient → depotentiation accelerates
...
Equilibrium: minimal structure, minimal energy demand, minimal participation
             synapse survives but is functionally silent
             resources it would have consumed now available to neighbors

This is a reasonable model of what happens to synapses in metabolically stressed tissue — they do not die immediately, but they are progressively silenced and depotentiated, freeing their resources for synapses in healthier regions. It is also a model of how chronic metabolic limitation — aging, vascular disease, mitochondrial dysfunction — would manifest as a gradual loss of plasticity capacity: not through any depression signal, but through the simple inability of energy-starved synapses to participate in the activity that would let them claim resources.

The energy budget is therefore not just a constraint that occasionally blocks behavior — it is a continuous selective pressure that shapes which synapses thrive and which fade, operating silently in parallel with the explicit activity-and-reward-driven plasticity, and ultimately determining the metabolic sustainability of whatever the system chooses to remember.

Three parallel competitive resource economies

The neuronal structural economy — soma produces material, distributed through dendrite to spines and through axon to boutons, competed for by tagged synapses during NIGHT. The astrocytic energy economy — astrocyte cell body produces lactate, distributed to perisynaptic processes, competed for by active synapses during DAY in proportion to their clearance demand. The soma's own energy economy — soma mitochondria fuel AP generation and shipping, competed for by the soma's own functions. All three share the same logic: a central producer with a capped output, distribution to peripheral consumers, demand-weighted allocation, and a self-reinforcing coupling where stronger consumers both demand and receive more. And all three ultimately bottom out at the same vascular glucose ceiling — the astrocyte directly, the soma through its own glucose uptake. The deep consequence is that a synapse must win on both economies to be potentiated. It must generate enough activity to pull lactate from the astrocyte (energy economy) AND accumulate enough tag to draw material during NIGHT (structural economy). A synapse that wins the structural competition but cannot pull energy will be unable to sustain the activity that justified its potentiation — it will be a large, expensive structure that keeps going silent. A synapse that pulls energy but never accumulates a tag stays metabolically supported but structurally weak. Only synapses that win both — active enough to be fueled, significant enough to be tagged — achieve and maintain full potentiation. The two economies together implement a stringent joint criterion: persistent significant activity that the metabolic infrastructure can sustain.