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

44 KiB
Raw Blame History

Table of Contents
include_toc
include_toc
true

Tripartite Synapse — Pseudocode v7

Part 1 — Conventions

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

DAY variable types:
  BUDGET    = combined fast energy + fast consumable materials
              one variable per component
              replenished in NOT contexts (received from upstream)
              consumed in AP/bAP/CONTINUOUS contexts (execution behaviors)

NIGHT variable types:
  ENERGY    = ATP for structural assembly — NOT recoverable after LTD
  MATERIAL  = slow structural proteins — RECOVERABLE after LTD

  STRUCTURE = slow architectural ceiling
              READ in DAY, WRITTEN only in NIGHT

  FAST_TRACE, TAG = as before

Part 2 — Fixed Parameters

// Thresholds — all FIXED
FIXED  Ca_TAG_threshold         // Ca²⁺ sufficient to set POST CANDIDATE
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 for tagging eligibility
FIXED  dopamine_threshold       // minimum dopamine for tag stabilization
FIXED  tagging_threshold        // minimum possible_tagging for tag accumulation
FIXED  tag_expiry_threshold     // minimum tag strength to survive to NIGHT
FIXED  homeostatic_ceiling      // max soma firing before global downscale
FIXED  structural_decay_rate    // passive decay rate of all structures per NIGHT
FIXED  recycling_fraction       // fraction of material recovered after LTD

// Organism-level signals — FIXED (externally driven)
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
FIXED  vascular_glucose_supply  // hard energy ceiling — astrocyte root
FIXED  branch_geometry          // dendritic topology — bAP decay profile
FIXED  Ca_cooperativity_n       // Hill coefficient for Ca²⁺-driven NT release
FIXED  Ca_half_max_K            // half-maximal Ca²⁺ for NT release

Part 3 — Budget, Energy, Material Declarations

// ── DAY BUDGETS: one per component ────────────────────────────────────
// Replenished in NOT contexts. Consumed in execution contexts.

VAR astro_budget
    // SOURCE:  vascular_glucose_supply → glycolysis (ROOT — self-produced)
    // COVERS:  EAAT clearance ATP
    //          D-serine synthesis (serine racemase ATP + serine precursor)
    //          lactate production and export
    //          fast process motility
    // REPLENISHED: CONTINUOUS context (self-produced continuously)

VAR pre_budget
    // SOURCE:  astro_lactate × pre_fraction (primary)
    //          axon→pre shipment in AXON NOT_AP (secondary)
    // COVERS:  VGCC opening + vesicle fusion + VATPase refill
    //          fast vesicle membrane lipid turnover
    //          synaptotagmin recycling
    // REPLENISHED: PRE NOT_AP context (receives from AXON)

VAR post_budget
    // SOURCE:  astro_lactate × post_fraction (primary)
    //          dend→post shipment in DEND NOT_bAP (secondary)
    // COVERS:  NaK pump reset + NMDA current handling
    //          AMPA lateral diffusion + rapid recycling
    //          actin monomers for transient spine changes
    //          PKA phosphorylation (minor)
    // REPLENISHED: POST NOT_bAP context (receives from DEND)

VAR dend_budget
    // SOURCE:  astro_lactate × dend_fraction (primary)
    //          soma→dend shipment in SOMA NOT_AP (secondary)
    // COVERS:  bAP propagation along branch (NaK reset at each segment)
    //          local mRNA translation (ribosome running cost)
    //          fast Ca²⁺ handling (SERCA pump)
    //          fast mRNA consumables for local translation
    // REPLENISHED: DEND NOT_bAP context (receives from SOMA)

VAR soma_budget
    // SOURCE:  own mitochondria (self-produced — independent of astrocyte)
    // COVERS:  AP generation (Na⁺/K⁺ currents + NaK reset)
    //          CREB phosphorylation (minor fast cost)
    //          nuclear Ca²⁺ handling
    //          shipping costs to DEND and AXON
    // REPLENISHED: SOMA NOT_AP context (self-replenished from mitochondria)

VAR axon_budget
    // SOURCE:  soma→axon shipment in SOMA NOT_AP (primary)
    //          astro_lactate × axon_fraction along shaft (secondary)
    // COVERS:  AP propagation at nodes of Ranvier (NaK reset)
    //          kinesin/dynein motor running cost
    //          fast myelin maintenance
    // REPLENISHED: AXON NOT_AP context (receives from SOMA)

VAR astro_lactate
    // Fuel exported by astrocyte → all neuronal components
    // = min(glycolysis(vascular_glucose_supply), astro_budget × export_fraction)
    // Distributed continuously in ASTRO CONTINUOUS context

// ── NIGHT ENERGY: ATP for structural assembly — NOT recoverable ────────

VAR astro_energy    // process retraction + ECM secretion + racemase upregulation
VAR pre_energy      // AZ scaffold incorporation + VGCC clustering
VAR post_energy     // CaMKII anchoring + actin polymerization + PSD remodeling
VAR dend_energy     // mitochondria incorporation + cytoskeletal reinforcement
VAR soma_energy     // ribosome biogenesis + ion channel incorporation
VAR axon_energy     // myelination + microtubule stabilization

// ── NIGHT MATERIAL: slow structural proteins — RECOVERABLE after LTD ──

VAR astro_material  // EAAT proteins + racemase enzyme + ECM proteins
                    // + process cytoskeleton
                    // SOURCE: astrocyte cell body synthesis (overnight)
                    // RECOVERY: partially after LTD (recycling_fraction)

VAR pre_material    // RIM + Munc13 + VGCC subunits + structural vesicle proteins
                    // SOURCE: soma_material → axon_material → pre_material
                    // RECOVERY: significantly after LTD → axonal pool

VAR post_material   // AMPA subunits + PSD scaffold + structural actin + CaMKII
                    // SOURCE: soma_material → dend_material → post_material
                    // RECOVERY: significantly after LTD → dendritic reserve

VAR dend_material   // Arc mRNA + plasticity mRNAs + mitochondria
                    // + cytoskeletal proteins + AMPA in transit
                    // SOURCE: soma_material → dend_material
                    // RECOVERY: partially after branch pruning

VAR soma_material   // ALL structural proteins for downstream components
                    // SOURCE: CREB-driven synthesis (peaks in NIGHT, soma_tag driven)
                    // DISTRIBUTES TO: dend_material + axon_material → pre_material

VAR axon_material   // motor proteins + microtubule components + myelin proteins
                    // SOURCE: soma_material → axon_material
                    // RECOVERY: partially after axon structural reduction

Part 4 — Structural Variables (NIGHT only)

VAR pre_structure   // RRP_capacity + VGCC_coupling + refill_ceiling
VAR post_structure  // anchoring_slots + spine_volume + local_reserve_ceiling
VAR dend_structure  // bAP_fidelity(position) + translation_ceiling + transport_speed
VAR soma_structure  // baseline_threshold + AP_reliability + synthesis_ceiling
VAR axon_structure  // propagation_reliability + transport_rate_ceiling
VAR astro_structure // perisynaptic_distance⁻¹ + EAAT_density
                    // + D_serine_tonic + ECM_integrity
                    // SELF-REINFORCING in both directions

Part 5 — Trace Variables

// Fast traces (DAY only, decay automatically)
FAST_TRACE  pre_fast_trace      // residual Ca²⁺ — τ ≈ 100ms
FAST_TRACE  post_fast_trace     // spine Ca²⁺ × 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 NIGHT
TAG  dend_tag
TAG  soma_tag
TAG  axon_tag
TAG  astro_tag


SCOPE: DAY

Execution contexts (AP, bAP, CONTINUOUS): behaviors run, budgets consumed, traces deposited Replenishment contexts (NOT_AP, NOT_bAP): budgets replenished, traces decay, shipments received


PRE

CONTEXT: AP

scope DAY | context AP:

    // Budget gate — behavior requires resources
    if pre_budget < AP_release_cost:
        suppress(NT_flux)
        exit context

    // Fast trace: residual Ca²⁺ deposited
    pre_fast_trace += spike_Ca_influx(input_freq)
    pre_fast_trace *= decay(τ = 100ms)
    pre_budget     -= Ca_handling_cost
    // cost covers: PMCA + NCX pump ATP to remove Ca²⁺

    // 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               // cleft concentration rises
        RRP_level -= NT_flux × Δt               // pool depletes
        pre_budget -= NT_flux × fusion_cost
        // cost covers: SNARE_ATP + fast_membrane_lipid_turnover

    // RRP refill — rate limited by pre_budget + 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
    // cost covers: VATPase refilling vesicles with NT

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

CONTEXT: NOT_AP

scope DAY | context NOT_AP:

    // Fast trace decays — eligibility window closing
    pre_fast_trace *= decay(τ = 100ms)

    // RRP refills during silence — 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.RRP_capacity)
    pre_budget -= RRP_refill × VATPase_cost

    // Budget replenishment — received from AXON shipment
    // (axon ships to pre in AXON NOT_AP context — see below)
    // astro_lactate also delivered here as top-up
    pre_budget += astro_lactate × pre_fraction
    // Note: astro_lactate is the primary continuous supply
    //       axon shipment provides the structural protein transport channel

    // Possible tagging: graded accumulation while eligible
    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 coincide
    if dopamine_local > dopamine_threshold and
       pre_possible_tagging > tagging_threshold:
        pre_tag += dopamine_local × pre_possible_tagging
    pre_tag *= decay(τ = hours)

POST

CONTEXT: NOT_bAP

scope DAY | context NOT_bAP:

    // Budget replenishment — received from DEND shipment
    // (dend ships to post in DEND NOT_bAP context — see below)
    // astro_lactate also delivered as top-up
    post_budget += astro_lactate × post_fraction
    post_budget += dend_shipment_to_post    // received from DEND 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
    // cost covers: NaK_reset_ATP + fast_receptor_recycling_lipids

    // NMDA gate: depolarization + D-serine + glutamate — three-way 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
        // cost covers: NMDA_handling_ATP + fast_actin_transient_cost

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

    // CANDIDATE tag: Ca²⁺ above threshold — Hebbian anticipation window
    if post_fast_trace > Ca_TAG_threshold:
        post_possible_tagging += post_fast_trace
    post_possible_tagging *= decay(τ = minutes)
    post_budget -= PKA_priming_cost
    // cost covers: PKA phosphorylation of GluA1-Ser845 (minor)

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

    // STABLE tag: CANDIDATE + dopamine within stabilization window
    if dopamine_local > dopamine_threshold and
       post_possible_tagging > tagging_threshold:
        post_tag += dopamine_local × post_possible_tagging
    post_tag *= decay(τ = hours)

CONTEXT: bAP

scope DAY | context bAP:

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

    // 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
        // no extra budget cost — Ca²⁺ boost driven by voltage, not pumps

DEND

CONTEXT: bAP

scope DAY | context bAP:

    // bAP propagates from soma downward through branch
    // strength attenuates with distance — set by dend_structure (READ)
    bAP_local    = propagate_bAP(SOMA.AP_fired,
                                 dend_structure.bAP_fidelity,
                                 branch_geometry)
    dend_budget -= bAP_propagation_cost
    // cost covers: NaK_reset_ATP at each branch segment
    //              Na⁺ channel re-activation along branch length

    // Fast trace: branch Ca²⁺ from bAP
    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
    // cost covers: SERCA pump re-sequestration of Ca²⁺

    // Integrate spine signals upward toward soma
    branch_Vm    = integrate(POST.Vm, all_spines_on_branch)
    dend_budget -= integration_cost
    // cost covers: passive membrane maintenance during integration

CONTEXT: NOT_bAP

scope DAY | context NOT_bAP:

    // Fast trace decays
    dend_fast_trace *= decay(τ = 300ms)

    // Budget replenishment — received from SOMA shipment
    dend_budget += soma_shipment_to_dend    // received from SOMA NOT_AP
    dend_budget += astro_lactate × dend_fraction  // astrocyte top-up

    // Ship budget to POST spines — downstream replenishment
    dend_shipment_to_post = min(dend_budget × post_delivery_fraction,
                                post_demand(active_spines))
    post_budget  += dend_shipment_to_post
    dend_budget  -= dend_shipment_to_post
    // Note: this is fast operational budget (energy + consumables)
    //       structural post_material ships in NIGHT, not here

    // 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: activated when tag set, gated by dend_budget
    if dend_tag > tag_expiry_threshold and dend_budget > translation_cost:
        local_proteins = translate(dend_fast_trace)
        dend_budget   -= translation_cost
        // cost covers: ribosome_running_ATP + fast_mRNA_consumed
        // Note: uses fast mRNA pool (in dend_budget)
        //       slow structural mRNA pool (dend_material) consumed only in NIGHT

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

SOMA

CONTEXT: AP

scope DAY | context AP:

    // Firing threshold: structure (READ) × 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
        // 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)
        soma_budget     -= nuclear_Ca_handling_cost
        // cost covers: nuclear Ca²⁺ pump ATP

        // Refractory timer
        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
        // cost covers: CREB phospho ATP (minor fast cost)
        // full CREB-driven synthesis is NIGHT operation consuming soma_energy

CONTEXT: NOT_AP

scope DAY | context NOT_AP:

    // Fast trace decays — threshold returning to baseline
    soma_fast_trace  *= decay(τ = seconds)
    refractory_timer  = max(0, refractory_timer - Δt)

    // Budget self-replenishment — soma fuels itself from own mitochondria
    soma_budget += mitochondria_output_rate × Δt
    // Note: soma is the only component that self-replenishes
    //       all other components receive from soma or astrocyte

    // Integrate dendritic inputs
    branch_Vm = integrate(DEND.branch_Vm, all_branches)
    soma_budget -= integration_cost

    // Ship budget to DEND — downstream operational replenishment
    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
    // cost covers: fast organelle delivery running cost
    // Note: structural dend_material ships in NIGHT, not here

    // Ship budget to AXON — downstream operational replenishment
    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
    // cost covers: fast axonal fuel delivery
    // Note: structural axon_material and pre_material ship in NIGHT

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

AXON

CONTEXT: AP

scope DAY | context AP:

    // 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
    // cost covers: NaK_reset_ATP at each node of Ranvier

    // Fast trace: propagation load deposited
    axon_fast_trace += APs_delivered
    axon_fast_trace *= decay(τ = seconds)
    // high axon_fast_trace → Na⁺ channel inactivation → propagation failure
    // this is axonal STD — frequency-dependent filtering

CONTEXT: NOT_AP

scope DAY | context NOT_AP:

    // Fast trace decays — propagation reliability recovering
    axon_fast_trace *= decay(τ = seconds)

    // Budget replenishment — received from SOMA shipment
    axon_budget += soma_shipment_to_axon    // received from SOMA NOT_AP
    axon_budget += astro_lactate × axon_fraction  // astrocyte top-up along shaft

    // Ship budget to PRE boutons — downstream operational replenishment
    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
    // cost covers: kinesin_ATPase running cost for fast delivery to boutons
    // Note: structural pre_material (AZ proteins) ships 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)

ASTRO

CONTEXT: CONTINUOUS

scope DAY | context CONTINUOUS:

    // ROOT energy production — self-generated from vascular glucose
    astro_budget += glycolysis(vascular_glucose_supply) × Δt
    // hard cap: vascular_glucose_supply (FIXED) — cannot be exceeded
    // cost covers: glycolysis running cost (minimal — glycolysis is the revenue here)

    // Lactate export — distributes to ALL neuronal components continuously
    astro_lactate = min(astro_budget × lactate_export_fraction,
                        vascular_glucose_supply × max_export_fraction)
    astro_budget -= astro_lactate
    // Distribution happens via specific component budgets in their NOT contexts:
    //   pre_budget  += astro_lactate × pre_fraction   (in PRE NOT_AP)
    //   post_budget += astro_lactate × post_fraction  (in POST NOT_bAP)
    //   dend_budget += astro_lactate × dend_fraction  (in DEND NOT_bAP)
    //   axon_budget += astro_lactate × axon_fraction  (in AXON NOT_AP)
    // Note: astro_lactate is the variable; delivery happens when components replenish

    // Glutamate clearance — rate set by astro_structure (READ)
    clearance     = astro_structure.EAAT_density × glutamate × Δt
    glutamate    -= clearance
    astro_budget -= clearance × EAAT_ATP_cost
    // cost covers: EAAT cotransport ATP + secondary NaK pump cost

    // Tonic D-serine baseline — from astro_structure (READ)
    astro_D_serine += astro_structure.D_serine_tonic × Δt
    astro_budget   -= astro_structure.D_serine_tonic × tonic_synthesis_cost
    // cost covers: constitutive racemase ATP + baseline serine fast cost

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

        D_serine_pulse    = min(proportional_to(astro_fast_trace),
                                astro_budget × Ds_fraction)
        astro_budget     -= D_serine_pulse × Ds_synthesis_cost
        astro_D_serine   += D_serine_pulse
        // cost covers: racemase_ATP + serine_precursor_fast_cost

        // Simultaneous presynaptic brake — cross-compartment, no astro 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)

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

Special Case — Shockwave Lockdown

scope DAY or NIGHT | context OVERLOAD:

    // Emergency — bypasses all budget gates
    Vm               = HYPERPOLARIZED
    post_budget     -= emergency_reset_cost       // DAY cost
    AMPA_occupancy   = mass_internalization()     // receptors to post reserve
    axon_fast_trace += overdrive_cluster()        // VGCC clustering beneath AZ
    astro_budget    -= emergency_astro_cost
    // Note: in NIGHT, post_energy used if structural receptors affected


SCOPE: NIGHT

{component}_energy and {component}_material used — NOT {component}_budget Structural variables WRITTEN. Tags evaluated and cleared. Budget variables replenished here for next DAY.


Step 1 — Replenish All Budgets, Energy, and Material

scope NIGHT | step 1:

    // ── ASTROCYTE: root replenishment ───────────────────────────────
    astro_budget   += overnight_glycolysis(vascular_glucose_supply) × Δt_night
    // replenishes fast operational budget for next DAY
    astro_energy   += overnight_astro_energy_synthesis() × Δt_night
    // replenishes structural assembly ATP
    astro_material += astrocyte_cellbody_synthesis() × Δt_night
    // replenishes: EAAT proteins + racemase + ECM proteins + process cytoskeleton

    // ── SOMA: self-replenishment + material production ───────────────
    soma_budget    += overnight_mitochondria_output() × Δt_night
    // replenishes fast operational budget for next DAY
    soma_energy    += overnight_soma_energy_reserve() × Δt_night
    // replenishes structural assembly ATP
    soma_material  += CREB_driven_synthesis(soma_tag) × Δt_night
    // PRIMARY MATERIAL PRODUCTION — rate set by soma_tag magnitude
    // this is the production bottleneck for ALL downstream structural commits

    // ── MATERIAL DISTRIBUTION: soma → downstream ─────────────────────
    // Soma ships structural material to branches and axon
    dend_material  += soma_material × dend_material_fraction
    axon_material  += soma_material × axon_material_fraction
    soma_material  -= (dend_material_fraction + axon_material_fraction) × soma_material

    // Branch delivers structural material to spines
    post_material  += dend_material × spine_material_fraction
    dend_material  -= spine_material_fraction × dend_material

    // Axon delivers structural material to boutons
    pre_material   += axon_material × bouton_material_fraction
    axon_material  -= bouton_material_fraction × axon_material

    // ── DOWNSTREAM ENERGY REPLENISHMENT ─────────────────────────────
    pre_energy     += soma_energy × pre_energy_fraction
    post_energy    += soma_energy × post_energy_fraction
    dend_energy    += soma_energy × dend_energy_fraction
    axon_energy    += soma_energy × axon_energy_fraction
    // all downstream structural assembly ATP sourced from soma overnight

    // ── DOWNSTREAM BUDGET REPLENISHMENT for next DAY ─────────────────
    pre_budget     += astro_lactate × pre_fraction × Δt_night
    post_budget    += astro_lactate × post_fraction × Δt_night
    dend_budget    += astro_lactate × dend_fraction × Δt_night
    axon_budget    += astro_lactate × axon_fraction × Δt_night
    // Note: budgets partially pre-loaded here so components start DAY operational

Step 2 — Structural Commits (Parallel, Independent)

scope NIGHT | step 2:

    // Coherence bonus when pre, post, astro all tagged simultaneously
    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,
                    pre_energy × pre_fraction)
        pre_structure  += Δpre × coherence_bonus   // STRUCTURE WRITTEN
        pre_material   -= Δpre                     // consumed — RECOVERABLE
        pre_energy     -= Δpre × assembly_ATP_cost // 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,
                     astro_energy × astro_fraction)
        astro_structure += Δastro × coherence_bonus // STRUCTURE WRITTEN
        astro_material  -= Δastro                   // RECOVERABLE (recycling_fraction)
        astro_energy    -= Δastro × assembly_ATP_cost
        if Δastro < process_retraction_cost:
            queue(astro_deficit → next NIGHT)
        // SELF-REINFORCING: astro_structure ↑ → D_serine_tonic ↑ +
        //                   perisynaptic_distance ↓ → future LTP easier

Step 3 — Passive Depotentiation

scope NIGHT | step 3:

    // Potentiation draws material first.
    // Remainder distributed as maintenance.
    // Below maintenance threshold: structure decays passively.
    // Depotentiation = resource neglect, not active depression signal.

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

    for each synapse:

        // Structural decay — passive and 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 counters decay where possible
        if maintenance_per_synapse >= maintenance_cost:
            pre_structure   += maintenance_pre    // fully maintained
            post_structure  += maintenance_post
            dend_structure  += maintenance_dend
            astro_structure += maintenance_astro
        else:
            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
            // net: structures drift down — DEPOTENTIATION BY NEGLECT

    // LTD material recovery: returned to pools
    // Energy NOT recovered — asymmetry justifies separate energy + material in NIGHT
    for each synapse where net_structure_change < 0:
        recovered        = abs(net_structure_change) × recycling_fraction
        pre_material    += recovered × pre_fraction
        post_material   += recovered × post_fraction
        astro_material  += recovered × astro_fraction × recycling_fraction

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
        soma_material += sum(structure_reduction) × recycling_fraction
        // energy NOT recovered

Step 5 — Clear All Traces

scope NIGHT | step 5:

    // Fast traces: confirmed zero
    pre_fast_trace = post_fast_trace = dend_fast_trace = 0
    soma_fast_trace = axon_fast_trace = astro_fast_trace = 0

    // Possible tagging: confirmed zero
    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 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: Budget Shipment Chain (DAY)

SELF-PRODUCED:
    vascular_glucose_supply → astro_budget  (astrocyte, CONTINUOUS)
    own_mitochondria        → soma_budget   (soma, NOT_AP)

SHIPMENT CHAIN (DAY operational budgets):
    astro_budget → astro_lactate → delivered to all components in their NOT contexts:
        → pre_budget  (PRE NOT_AP)
        → post_budget (POST NOT_bAP, via astro_lactate + dend shipment)
        → dend_budget (DEND NOT_bAP, via astro_lactate + soma shipment)
        → axon_budget (AXON NOT_AP, via astro_lactate + soma shipment)

    soma_budget → soma_shipment_to_dend → dend_budget  (SOMA NOT_AP → DEND NOT_bAP)
    soma_budget → soma_shipment_to_axon → axon_budget  (SOMA NOT_AP → AXON NOT_AP)
    dend_budget → dend_shipment_to_post → post_budget  (DEND NOT_bAP → POST NOT_bAP)
    axon_budget → axon_shipment_to_pre  → pre_budget   (AXON NOT_AP → PRE NOT_AP)

MATERIAL SHIPMENT CHAIN (NIGHT structural material):
    soma_material → dend_material → post_material  (soma → branch → spine)
    soma_material → axon_material → pre_material   (soma → axon → bouton)
    astrocyte_body → astro_material                (astrocyte cell body → astrosynapse)

ENERGY DISTRIBUTION (NIGHT assembly ATP):
    soma_energy → pre_energy, post_energy, dend_energy, axon_energy
    astro_energy → astro structural commits only

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