Files
organism/elements/astrocyte/appunti/2026-06-06-tripartite_synapse_v2.md
T

54 KiB
Raw Blame History

Table of Contents
include_toc
include_toc
true

Neuron, budget, traces and behaviours


Conventions: The Language of the System

The system operates across two scopes and multiple contexts. The DAY scope is the organism's active period — all fast and intermediate behaviors run here, structural variables are read but never permanently written, and every action leaves a trace that may or may not survive to the NIGHT. The NIGHT scope is when structural commits execute, budgets replenish, and all DAY traces are either converted into permanent architecture or cleared. Within each scope, each compartment operates in a specific context — AP or NOT_AP for the presynapse, bAP or NOT_bAP for the postsynapse, and CONTINUOUS for the astrocyte and dendritic branch — that determines which behaviors are permitted to run.

Every variable in the system is either a state variable, a trace, or a budget. State variables describe the current condition of a compartment. Traces are modifications deposited by a behavior that persist beyond the moment and bias future behaviors — they are the system's memory between contexts. Budgets are shared resource pools that constrain how much of any behavior can actually execute, and they ensure that nothing in the system is free.


Shared Resource Pools: The Economy Before Any Behavior Runs

Before any spike fires or any receptor moves, the system's capacity for change is already determined by the state of its shared resource pools. These pools exist at four nested territorial levels, and they are the reason that what happens at one synapse has consequences for all its neighbors.

The axonal arbor maintains a shared pool of vesicle scaffold proteins — RIM, Munc13, and VGCC subunits — that every bouton on that axon must draw from when it wants to expand its active zone. It also maintains a mitochondrial ATP capacity that sets the ceiling on how many release events can occur before the energy supply is exhausted and boutons begin going silent. A set of tagged boutons tracks which sites are currently in competition for proteins drifting along the axon.

The dendritic branch maintains its own receptor reserve — a local endosomal pool of AMPA receptors held near the spines that can be rapidly inserted without waiting for the soma — alongside actin machinery for spine enlargement, a protein flux arriving from the soma, a local pool of stored mRNAs that branch ribosomes can translate immediately, and its own mitochondrial ATP budget. The set of tagged spines on the branch tracks which sites are competing for these local resources.

The astrocyte territory — which in humans wraps hundreds of thousands of synapses — maintains pools of serine racemase enzyme for D-serine synthesis, glutamate transporter proteins for clearance, extracellular matrix proteins for structural sealing, and a finite number of perisynaptic process extensions that it can selectively allocate to different synapses. All of these draw from a single ATP budget that is itself ultimately capped by the glucose supply from the nearest blood capillary — a hard vascular ceiling that cannot be exceeded regardless of demand.

The soma maintains its own pools of synthesis capacity, receptor production rate, organelles for shipping to branches, and mRNA transcription rate. These are the upstream sources that replenish the branch-level pools, and their rate is set by the CREB transcription state left over from DAY activity — meaning the soma's production capacity during NIGHT is determined by how the DAY went.


Budget Allocation: Constraint Before Commitment

When any compartment wants to draw structural resources, it does not simply take them. It calls a budget allocation function that checks what is available, applies a priority weighting based on whether that site has planted a synaptic tag, grants only what can be afforded, and decrements the pool accordingly. If the grant is smaller than the request — because the pool is partially depleted by competing synapses — the deficit is queued for the next NIGHT cycle and heterosynaptic depression is triggered in untagged neighbors. The neighbors lose resources not because any signal told them to weaken, but because the pool was exhausted before reaching them.

The astrocyte allocation has an additional layer: all three of its resource draws — D-serine, ECM proteins, and process extensions — are individually capped by their specific pools, and then the combined ATP cost of all three is checked against the total ATP budget. If the ATP cost would exceed the budget, all three grants are scaled down proportionally. This means a heavily loaded astrocyte serving many simultaneously active synapses delivers partial support to each rather than full support to a few.

Budget replenishment runs continuously but peaks during the NIGHT scope. The soma's protein synthesis rate, driven by CREB activation accumulated during DAY, determines how fast the dendritic branch pools refill. The astrocyte's pools recover at rates set by enzyme synthesis and ECM production machinery, with process extensions recovering the slowest — on a timescale of hours — which is why a fully deployed astrocyte cannot immediately reallocate its walls to a new synapse. The vascular glucose ceiling is the one parameter in the entire system that cannot be increased by any molecular mechanism — it is set by blood flow and capillary density, and it sets the absolute limit on how much simultaneous structural change the system can support.


DAY Scope — Presynaptic Bouton

Context: AP

When an action potential arrives, the first check is not biological but economic: does this bouton's local mitochondrial capacity have enough ATP to afford the release? If not, the bouton goes silent regardless of the electrical input. This is the energy gate that prevents a depleted axon from continuing to operate at full output — it is not a regulatory decision but a resource constraint.

If the budget permits, calcium floods in through voltage-gated channels. The key quantity is not the peak calcium but the residual: the calcium left over from previous spikes that has not yet decayed. This residual is the presynaptic memory of recent activity — a trace that accumulates with repeated firing and fades with silence on a timescale of roughly 100 milliseconds. The current release probability is biased by this residual, meaning a bouton that has been firing recently is primed to release more than one that has been silent. Vesicles are released probabilistically from the readily-releasable pool, glutamate fills the cleft, and the pool shrinks by exactly the number released. The mitochondrial budget decrements.

If enough glutamate escapes the cleft to reach the low-affinity mGluR2/3 receptors on the presynaptic membrane, an autoinhibitory brake engages. The Gi-coupled cascade suppresses adenylyl cyclase, reducing cAMP and directly dampening voltage-gated calcium channel opening. This is a negative feedback loop entirely within the presynaptic compartment: excess output detected, output probability reduced, without any postsynaptic input. The RRP is then partially refilled by the astrocyte's lactate supply, but only to the extent that lactate is available — another resource gate.

Context: NOT_AP

Between spikes, the presynapse is not idle. The residual calcium trace continues to decay passively — if spikes do not keep arriving, the facilitation advantage erodes. If recent firing history has been consistently above 20 Hz, the reserve pool is mobilized toward the readily-releasable pool, making more vesicles available for the next burst — but only if the reserve is non-empty, meaning this mobilization is itself budgeted by whatever was stored during prior quiescence. If firing history has been sparse, release probability drifts downward.

The more important event in the NOT_AP context is the neuromodulatory broadcast. When dopamine or norepinephrine arrives above threshold, PKA activity rises and a synaptic tag is planted — the bouton is added to the set of axon-tagged boutons competing for drifting structural proteins. This tag is a trace of the neuromodulatory context that will persist into the NIGHT scope: if a structural commit runs before the tag expires, this bouton gets priority access to the axonal protein pool.


DAY Scope — Dendritic Spine

Context: NOT_bAP

The NOT_bAP context is where the Hebbian anticipation window opens. Glutamate arriving from the presynapse activates AMPA receptors, depolarizing the spine membrane. If this depolarization is sufficient — and crucially if D-serine supplied by the astrocyte is present as a co-agonist — the NMDA receptor's magnesium block is ejected and calcium begins to enter. The amplitude and speed of this calcium rise are recorded as traces: amplitude encodes whether the event was strong enough for LTP, speed distinguishes LTP-driving fast rises from LTD-driving slow ones.

The synaptic tag is planted here, in this context, before the back-propagating AP arrives to confirm coincidence. The trigger for tag planting is the calcium rise combined with NMDA opening — the system is tagging the moment it detects an incoming signal strong enough to potentially be worth encoding, before it knows whether the postsynaptic cell actually fired. This is the Hebbian anticipation: the forward glutamate signal is the candidate event, and the tag is the molecular record of that candidacy. The spine is simultaneously added to the dendritic branch's pool of tagged spines, entering competition for local protein resources. If the neuromodulator context gate has already been set by PKA, the AMPA insertion threshold is lowered, making the eventual structural commit easier.

Context: bAP

When the back-propagating action potential arrives from the soma down the dendritic tree, it depolarizes the spine further. This is the confirmation signal. If a tag was planted just before the bAP — meaning the forward glutamate signal and the retrograde AP signal coincide in time — the calcium rise is amplified beyond the LTP threshold, confirming genuine Hebbian coincidence. The bAP did not cause the calcium rise; it amplified one that was already in progress, retroactively validating the tag that was planted in anticipation.

If no tag was present — if the bAP arrives at a spine that received no glutamate signal — the membrane depolarizes transiently but no calcium amplification occurs and no trace is deposited. The spine passes through the bAP context without consequence. This asymmetry is the core of spike-timing-dependent plasticity: the order matters, and the tag mechanism enforces the order by requiring the forward signal to precede the backward one by enough time to plant the tag before the bAP confirms it. At the end of the bAP context, the sodium-potassium pump resets the membrane, drawing on the astrocyte's lactate supply, and the soma ATP budget decrements to pay for the propagation cost of the bAP itself.


DAY Scope — Dendritic Branch

Context: CONTINUOUS

The dendritic branch runs continuously as an integrator and distributor, operating in both directions simultaneously. Upward, it integrates the membrane potentials of all spines on its length into a branch voltage that propagates toward the soma and contributes to whether a somatic action potential fires. It also propagates the back-propagating AP downward from the soma toward the spines, but its geometry matters: bAP amplitude decays with distance from the soma, meaning spines at the distal end of a long branch receive a weaker confirmation signal than proximal spines. This geometry is itself a slow structural trace — branches that have grown longer or lost mitochondrial density will propagate bAPs less faithfully.

The branch accumulates its own calcium signal driven by the bAP and by spillover from active spines, but this calcium decays more slowly than spine calcium — it integrates across multiple spines and persists for hundreds of milliseconds. When enough spines on the same branch are co-active, a branch-level tag is planted. This is the branch's version of the synaptic tag: a marker that this branch as a whole has been meaningfully recruited, which triggers local BDNF release — a trace that signals branch-level survival and growth pressure to the soma.

When a branch tag is set and the local mRNA pool is non-empty, the branch ribosomes begin translating stored mRNAs into structural proteins locally, without waiting for the soma. This local translation provides a fast protein supply that can support early structural changes within minutes rather than hours. The translation itself draws from the branch mitochondrial budget, so a branch that is energetically depleted cannot translate even if its mRNA pool is full. The acetylcholine broadcast modulates the global LTP threshold continuously in this context — during periods of high attentional drive, the threshold lowers across all branches simultaneously.


DAY Scope — Soma

Context: AP

The soma fires an action potential when integrated dendritic input crosses the firing threshold — itself a variable that is modulated by the neuromodulatory state. When it fires, calcium enters the nucleus — a trace that accumulates with firing rate and decays over seconds. This nuclear calcium is the signal that gates CREB phosphorylation in the soma, and CREB phosphorylation is the trace that determines how much protein synthesis runs during the subsequent NIGHT scope. But CREB phosphorylation requires both nuclear calcium above threshold AND PKA activity above threshold — it is a coincidence gate at the somatic level, just as NMDA opening is a coincidence gate at the spine level. Both the activity pattern (nuclear calcium) and the neuromodulatory context (PKA) must align for the gene expression program to activate. When they do, Arc mRNA and BDNF production begin — both traces that will be shipped to active dendritic branches during the NOT_AP context.

Context: NOT_AP

Between somatic spikes, the soma integrates dendritic inputs and manages the distribution of resources to branches. It ships Arc mRNA preferentially to tagged branches, whose tags were planted during the DAY based on spine-level calcium events. It queues organelle deliveries to branches ranked by their branch calcium levels — the most active branches receive mitochondria first. This shipping process is itself budgeted: the organelle pool is finite, and a soma that has been heavily depleting its pool during a period of high activity will have fewer organelles to ship until NIGHT replenishment runs.

The neuromodulatory broadcast in the NOT_AP context sets the PKA gate simultaneously across all compartments: GluA1-Ser845 priming lowers the AMPA insertion threshold at all tagged spines, DARPP-32 phosphorylation silences the LTD phosphatase globally, and CREB activation opens the gene expression gate. None of these actions write any structural variable — they are traces that bias what the NIGHT scope will commit.


DAY Scope — Astrocyte

Context: CONTINUOUS

The astrocyte operates without discrete contexts — it monitors its entire territory continuously. Glutamate clearance runs at all times at a rate set by the density of transporter proteins currently deployed, drawing from the ATP budget with every cycle. When spillover crosses the low-affinity mGluR5 threshold — signaling that the cleft is genuinely saturated rather than merely active — the astrocyte's internal calcium rises proportionally to the spillover level. This local calcium rise drives D-serine secretion, but the amount secreted is capped by the current serine racemase enzyme capacity, which may be partially depleted if many neighboring synapses are simultaneously demanding co-agonist support. A busy astrocyte territory delivers partial D-serine to many synapses rather than full D-serine to a few — the support is rationed automatically by the enzyme pool.

The same spillover simultaneously activates the presynaptic mGluR2/3 brake through a completely different receptor arm, reducing vesicle release probability at the source of the overflow. This push-pull is not coordinated by any signal — it is a structural consequence of the two receptor types sitting on different cells with different G-protein couplings, activated by the same diffusing ligand at the same moment.

The astrocyte checks continuously whether its local calcium has exceeded the global overload threshold. If it has, a soma-wide calcium wave fires and the shockwave lockdown executes — a circuit-breaker that mass-internalizes postsynaptic AMPA receptors, hyperpolarizes the membrane, and clusters presynaptic calcium channels for maximum signal preservation, all while rapidly depleting the astrocyte's ATP budget. The lactate pipeline runs in parallel at all times, converting glucose to lactate up to the vascular ceiling and distributing it in fractions to the presynapse, postsynapse, and dendritic branch — the fractionation determining which compartment gets refueled first under high demand.


Special Case: Shockwave Lockdown

The shockwave lockdown can trigger in either scope. It bypasses all budget gates — it is an emergency override that executes regardless of resource availability — but it pays a large ATP cost that leaves the astrocyte depleted and slower to support normal plasticity events for some time afterward. AMPA receptors are mass-internalized and returned to the dendritic reserve pool rather than destroyed, meaning they are recoverable when the emergency passes.


NIGHT Scope — All Compartments

The NIGHT scope opens with budget replenishment. Soma protein synthesis rate, which peaked because CREB was activated during DAY, now drives the highest protein production of the cycle. Branch-level pools refill from this production — receptor reserves, actin machinery, mRNA pools, and mitochondrial capacity all recover at rates proportional to how much CREB-driven expression ran. The astrocyte's pools replenish on their own schedules, with process extensions recovering the most slowly.

The soma then processes its shipping queue: organelles deferred during DAY are delivered to the branches that ranked highest by calcium activity. Once the queues are resolved, the structural commit function runs for every synapse that carries a tag.

PRE — Structural Commit

The presynapse draws from the axonal protein pool to expand its active zone. What it receives is proportional to how much remains in the pool after competing tagged boutons have drawn their shares. The expansion commits permanently: the active zone grows, more docking slots are installed, calcium channels cluster more tightly beneath the zone, and baseline release probability rises. These are slow traces that will read by every AP context in every subsequent DAY scope. If the pool was insufficient for the full requested expansion, the deficit is queued for the next NIGHT and the partial expansion is committed immediately. In the LTD branch, the process runs in reverse and the proteins dismantled from the active zone are returned to the shared pool, where they become available to other boutons.

POST — Structural Commit

The postsynapse draws from the branch receptor reserve and actin machinery. CaMKII, activated by the calcium trace deposited during DAY, anchors new AMPA receptors into the membrane surface — the number anchored determined by how many receptors the budget granted. The spine head physically enlarges in proportion to the actin machinery available. Both changes are slow traces that will be read by every NOT_bAP context in every subsequent DAY. Deficits are queued. In the LTD branch, phosphatase PP1 drives receptor internalization, and the internalized receptors are returned to the branch reserve pool — again conserving the total receptor count across the segment rather than destroying it.

DEND — Structural Commit

The dendritic branch receives the organelles shipped from the soma, permanently increasing its local mitochondrial density — a slow trace that will improve bAP propagation fidelity and local translation capacity in future DAY scopes. Arc mRNA stored in the branch pool is translated into structural proteins that expand the local protein flux, making the branch more self-sufficient for future plasticity demands. If BDNF-TrkB signaling crossed its survival threshold during DAY — meaning the branch was genuinely and collectively active — mitochondrial density is further reinforced, stabilizing the branch architecture. If it did not cross the threshold, mitochondrial density declines slightly, making the branch progressively less capable of supporting future plasticity. This is the branch-level version of the use-it-or-lose-it logic: not a binary decision but a continuous drift in one direction or the other depending on whether BDNF traces accumulated during DAY.

SOMA — Structural Commit

The soma's NIGHT work is primarily generative rather than structural in the local sense. CREB-driven transcription produces new proteins, receptors, and mRNAs at the highest rate of the cycle, replenishing all downstream pools. Organelle biogenesis runs — new mitochondria are produced and added to the organelle pool for shipping in future NIGHT cycles. If the overall somatic firing rate during DAY exceeded the homeostatic ceiling — meaning the entire neuron was over-recruited — a global downscaling factor is applied to all synapses simultaneously, reducing AMPA counts and release probabilities network-wide. This homeostatic correction is not targeted to any specific synapse; it is a blanket adjustment that restores the neuron's mean excitability without erasing the relative differences between strong and weak synapses. When all queues are empty and all tags are cleared, CREB phosphorylation and CREB activation are reset to false, closing the gene expression program until the next DAY's activity reactivates it.

ASTRO — Structural Commit

The astrocyte's NIGHT work centers on remodeling its physical relationship to each synapse it wraps. For synapses that were validated for LTP during DAY, the astrocyte draws from its ECM protein pool to secrete Glypicans and Thrombospondins, sealing and structurally reinforcing the synaptic environment. It draws from its process extension budget to retract its walls inward — physically tightening the wrap around the synapse. This tightening is itself a slow trace with two consequences: it reduces the rate at which glutamate diffuses away from the cleft, and it raises the tonic D-serine level available to the NMDA receptor. Both changes make the synapse more sensitive to future events, making LTP self-reinforcing. For synapses committed to LTD, the reverse occurs: MMP enzymes dissolve the ECM, D-serine supply is cut to zero, and the astrocyte's process walls extend outward, loosening the diffusion geometry and making future signals less concentrated and less likely to trigger NMDA opening. The freed process extensions are returned to the pool and become available for reallocation to LTP synapses.


Key Asymmetries and the Closure Summary

The perisynaptic distance variable is the one slow trace that amplifies rather than merely reflects the outcome. Because it controls both glutamate diffusion geometry and tonic D-serine availability simultaneously, a synapse that has been potentiated becomes progressively easier to potentiate further, and one that has been depressed becomes progressively harder to rescue — not because of any new signal but because the physical environment was remodeled to favor the existing direction.

The synaptic tag is the bridge that closes the loop between DAY and NIGHT. It is planted in the NOT_bAP context of DAY when a calcium event meets the tagging threshold, and it is consumed in the NIGHT scope when structural resources are available to fulfill the commit. If the neuromodulatory save signal never arrived during DAY — if dopamine or norepinephrine never validated the event as worth storing — the tag expires at the end of NIGHT without triggering a commit, and the DAY's traces are cleared without structural consequence.

The budget conservation law closes the entire system: LTP draws from shared pools and passively impoverishes untagged neighbors; LTD returns resources to shared pools and passively enriches them. The total resources in the system do not grow through activity — they are redistributed. The only way to increase total capacity is through NIGHT-scope CREB-driven synthesis and organelle biogenesis, and even that is bounded by the vascular glucose ceiling that the astrocyte cannot exceed regardless of demand. Every behavior in the system therefore occurs within a context that permits it, consumes from a budget that constrains it, and leaves a trace that shifts the probability of the next behavior — and the entire architecture is designed so that no single event, however strong, can permanently commit the system without the conjunction of the right context, the right energy state, and the right neuromodulatory validation.



Pseudocode: Tripartite Synapse — Scope & Context Aware Pseudocode v2


Conventions

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

Compartments:
  PRE    = presynaptic bouton
  POST   = dendritic spine (postsynapse)
  ASTRO  = astrocyte
  DEND   = dendritic branch (segment between soma and spines)
  SOMA   = cell body / nucleus

Budget pools:
  BUD    = shared resource pool (one per territory)

Trace:
  A variable modified by a behavior that persists beyond
  the current context and biases future behaviors.

Shared Resource Pools

// ── Axonal arbor ──────────────────────────────────────────────────────
BUD axon_vesicle_protein_pool   // RIM, Munc13, VGCC subunits for AZ expansion
BUD axon_mitochondria_capacity  // ATP ceiling for vesicle release + refill
BUD axon_tagged_boutons         // boutons in competition for drifting proteins

// ── Dendritic branch ──────────────────────────────────────────────────
BUD dend_receptor_reserve       // local endosomal AMPA pool per branch
BUD dend_actin_machinery        // Rac1/RhoA + actin monomers per branch
BUD dend_protein_flux           // plasticity proteins flowing from soma
BUD dend_tagged_spines          // spines competing for protein flux
BUD dend_mitochondria_capacity  // local ATP budget for branch-level operations
BUD dend_mRNA_pool              // locally stored mRNAs for rapid translation

// ── Astrocyte territory ───────────────────────────────────────────────
BUD astro_serine_racemase_cap   // enzyme ceiling for D-serine synthesis
BUD astro_EAAT_pool             // transporter protein for glutamate clearance
BUD astro_ECM_protein_pool      // Glypicans, Thrombospondins for sealing
BUD astro_process_extensions    // finite perisynaptic processes
BUD astro_ATP_budget            // total ATP: clearance + synthesis + motility
BUD astro_lactate_ceiling       // hard cap from capillary glucose supply

// ── Soma ──────────────────────────────────────────────────────────────
BUD soma_ATP_budget             // mitochondrial capacity of cell body
BUD soma_protein_synthesis_rate // CREB-driven — peaks in NIGHT scope
BUD soma_receptor_synthesis_rate// new AMPA/NMDA subunits per hour
BUD soma_organelle_pool         // mitochondria + ribosomes available for shipping
BUD soma_mRNA_transcription_rate// rate of new mRNA production (Arc, BDNF, etc.)

Global State Variables

// ── PRE: presynaptic bouton ───────────────────────────────────────────
PRE pre_Ca_residual             // TRACE: leftover Ca²⁺ between spikes
PRE vesicle_release_prob        // P(0.11.0) per docking slot
PRE RRP_pool                    // readily-releasable vesicle pool
PRE reserve_pool                // chained vesicles in deep storage
PRE active_zone_size            // SLOW TRACE: docking slot count
PRE RRP_pool_capacity           // SLOW TRACE: max RRP
PRE VGCC_clustering             // SLOW TRACE: Ca²⁺ channels beneath AZ

// ── POST: dendritic spine ─────────────────────────────────────────────
POST membrane_potential         // Vm — local depolarization state
POST NMDA_Mg_block              // bool — mechanical clamp on/off
POST post_Ca_amplitude          // TRACE: peak [Ca²⁺] rise in spine
POST post_Ca_rise_speed         // TRACE: d(Ca)/dt — fast=LTP, slow=LTD
POST spine_tag                  // TRACE: bool — synaptic tag planted
POST AMPA_count                 // SLOW TRACE: surface receptors
POST spine_volume               // SLOW TRACE: physical spine size

// ── DEND: dendritic branch ────────────────────────────────────────────
DEND branch_voltage             // local depolarization propagating from spines
DEND bAP_amplitude              // strength of back-propagating AP at this branch
DEND branch_Ca                  // TRACE: Ca²⁺ in branch shaft (from bAP + spines)
DEND branch_tag                 // TRACE: bool — branch-level plasticity tag
DEND local_protein_translation  // rate of mRNA→protein at branch ribosomes
DEND mitochondria_density       // SLOW TRACE: local energy capacity
DEND branch_BDNF_level          // TRACE: local BDNF secreted by active spines

// ── SOMA: cell body ───────────────────────────────────────────────────
SOMA membrane_potential         // somatic Vm — integrates all dendritic input
SOMA AP_threshold               // firing threshold — modulated by neuromodulators
SOMA CREB_phospho               // TRACE: bool — transcription factor active
SOMA Arc_mRNA_level             // TRACE: activity-regulated mRNA — ships to branches
SOMA BDNF_production_rate       // TRACE: neurotrophin synthesis rate
SOMA nuclear_Ca                 // TRACE: Ca²⁺ in nucleus — gates CREB
SOMA organelle_shipping_queue   // queue of mitochondria/ribosomes being sent out

// ── ASTRO: astrocyte ──────────────────────────────────────────────────
ASTRO glutamate_cleft           // [glu] in synaptic cleft
ASTRO glutamate_spillover       // extrasynaptic [glu] — saturates mGluRs
ASTRO astro_Ca_local            // TRACE: IP3-triggered local rise
ASTRO astro_Ca_global           // TRACE: soma-wide wave — overload flag
ASTRO D_serine_release          // gliotransmitter pulse — NMDA co-agonist
ASTRO D_serine_tonic_level      // SLOW TRACE: baseline co-agonist supply
ASTRO perisynaptic_distance     // SLOW TRACE: wall distance from synapse
ASTRO ECM_integrity             // SLOW TRACE: extracellular matrix density
ASTRO glutamate_clearance_rate  // SLOW TRACE: EAAT transporter density
ASTRO lactate_out               // fuel export to pre + post + dend

// ── SIG: signaling intermediates ─────────────────────────────────────
SIG mGluR2_3_activation         // presynaptic Gi — autoinhibitory brake
SIG mGluR5_activation           // astrocytic Gq — IP3→Ca²⁺→D-serine
SIG cAMP_level                  // TRACE: set by dopamine/NE via Gs
SIG PKA_activity                // downstream of cAMP
SIG GluA1_Ser845_primed         // TRACE: bool — AMPA insertion primed
SIG DARPP32_phospho             // TRACE: bool — LTD phosphatase silenced
SIG CREB_active                 // TRACE: bool — gene expression enabled
SIG dopamine_level              // broadcast: "save" context signal
SIG NE_level                    // broadcast: arousal / gain signal
SIG ACh_level                   // broadcast: attention / threshold signal
SIG BDNF_TrkB_signaling         // local: branch survival + growth signal

Budget Allocation Functions

function request_axon_resources(bouton_id, req_AZ):
    available = axon_vesicle_protein_pool × tag_priority(bouton_id, axon_tagged_boutons)
    granted   = min(req_AZ, available)
    axon_vesicle_protein_pool -= granted
    if granted < req_AZ:
        trigger(heterosynaptic_depression, neighbors(bouton_id))
    return granted

function request_dend_resources(spine_id, req_AMPA, req_actin):
    priority = tag_priority(spine_id, dend_tagged_spines)
    g_AMPA   = min(req_AMPA,  dend_receptor_reserve  × priority)
    g_actin  = min(req_actin, dend_actin_machinery   × priority)
    dend_receptor_reserve -= g_AMPA
    dend_actin_machinery  -= g_actin
    if g_AMPA < req_AMPA:
        queue(spine_id, deficit, dend_protein_flux)  // wait for soma delivery
        trigger(heterosynaptic_depression, neighbors(spine_id))
    return (g_AMPA, g_actin)

function request_astro_resources(syn_id, req_Ds, req_ECM, req_proc):
    g_Ds   = min(req_Ds,   astro_serine_racemase_cap)
    g_ECM  = min(req_ECM,  astro_ECM_protein_pool)
    g_proc = min(req_proc, astro_process_extensions)
    ATP_cost = compute_ATP(g_Ds, g_ECM, g_proc)
    if ATP_cost > astro_ATP_budget: scale_down(g_Ds, g_ECM, g_proc)
    astro_serine_racemase_cap -= g_Ds
    astro_ECM_protein_pool    -= g_ECM
    astro_process_extensions  -= g_proc
    astro_ATP_budget          -= ATP_cost
    return (g_Ds, g_ECM, g_proc)

function request_soma_resources(req_proteins, req_receptors, req_organelles):
    g_prot  = min(req_proteins,   soma_protein_synthesis_rate)
    g_rec   = min(req_receptors,  soma_receptor_synthesis_rate)
    g_org   = min(req_organelles, soma_organelle_pool)
    ATP_cost = compute_ATP(g_prot, g_rec, g_org)
    if ATP_cost > soma_ATP_budget: scale_down(g_prot, g_rec, g_org)
    soma_protein_synthesis_rate  -= g_prot
    soma_receptor_synthesis_rate -= g_rec
    soma_organelle_pool          -= g_org
    soma_ATP_budget              -= ATP_cost
    return (g_prot, g_rec, g_org)

function replenish_budgets(Δt):
    // Axon
    axon_vesicle_protein_pool  += protein_transport_rate(axon) × Δt
    // Dendritic branch
    dend_receptor_reserve      += soma_receptor_synthesis_rate × delivery_fraction() × Δt
    dend_actin_machinery       += actin_recovery_rate() × Δt
    dend_protein_flux           = soma_protein_synthesis_rate
    dend_mRNA_pool             += soma_mRNA_transcription_rate × Δt
    dend_mitochondria_capacity += organelle_delivery_rate() × Δt
    // Astrocyte
    astro_serine_racemase_cap  += enzyme_synthesis_rate() × Δt
    astro_ECM_protein_pool     += ECM_synthesis_rate() × Δt
    astro_process_extensions   += process_recovery_rate() × Δt   // slow: hours
    astro_ATP_budget           += glycolysis(astro_lactate_ceiling) × Δt
    astro_lactate_ceiling       = capillary_glucose_supply()      // vascular ceiling
    // Soma
    soma_protein_synthesis_rate = CREB_driven_expression()        // peaks in NIGHT
    soma_receptor_synthesis_rate += ribosome_activity() × Δt
    soma_organelle_pool        += biogenesis_rate() × Δt
    soma_ATP_budget            += mitochondria_output() × Δt
    soma_mRNA_transcription_rate = AP_history_driven(SOMA.AP_rate) // scales with use


SCOPE: DAY

All fast and intermediate behaviors. Structural variables only READ, not written.


PRE — Presynaptic Bouton

CONTEXT: AP (action potential arriving)

scope DAY | context AP:

    // Gate 1: energy budget
    if axon_mitochondria_capacity < release_ATP_cost:
        suppress(release)                    // silent bouton — budget exhausted
        exit context

    // Ca²⁺ dynamics — primary fast trace
    pre_Ca_residual += spike_influx(input_freq)
    pre_Ca_residual *= decay(τ ≈ 100ms)     // TRACE: fades unless spikes keep arriving

    // Release — gated by residual trace from prior APs
    vesicle_release_prob  *= facilitation(pre_Ca_residual)
    released               = binomial(RRP_pool, vesicle_release_prob)
    glutamate_cleft        = released × quantal_content
    RRP_pool              -= released
    axon_mitochondria_capacity -= release_ATP_cost

    // Overflow sensing — activates mGluR brake (cross-compartment)
    glutamate_spillover = extrasynaptic_diffusion(glutamate_cleft)
    if glutamate_spillover > spillover_threshold:
        mGluR2_3_activation  = True
        cAMP_level          -= Gi_inhibition(adenylyl_cyclase)
        vesicle_release_prob -= VGCC_suppression()  // autoinhibitory brake

    // Fuel consumed — refill gated by lactate supply
    RRP_pool refilled by VATPase(astro.lactate_out)

CONTEXT: NOT_AP (between spikes)

scope DAY | context NOT_AP:

    // Residual Ca²⁺ decays — trace erodes passively
    pre_Ca_residual *= decay(τ ≈ 100ms)

    // Reserve pool mobilization — intermediate tuning, pool-limited
    if input_freq_history > 20Hz:
        mobilize(reserve_pool → RRP_pool)   // only if reserve_pool > 0
                                             // TRACE: RRP_pool now larger
    elif input_freq_history < 5Hz:
        vesicle_release_prob *= 0.7         // TRACE: depression accumulates

    // Neuromodulator context gate — sets axonal tag if save signal present
    if dopamine_level > D1_threshold or NE_level > β_threshold:
        cAMP_level  += Gs_activation(adenylyl_cyclase)
        PKA_activity = proportional_to(cAMP_level)
        axon_tagged_boutons.add(bouton_id)  // TRACE: tag — competes for axonal proteins

POST — Dendritic Spine

CONTEXT: NOT_bAP (before back-propagating AP — Hebbian anticipation window)

scope DAY | context NOT_bAP:

    // AMPA current from incoming glutamate
    AMPA_current        = glutamate_cleft × AMPA_count
    membrane_potential += AMPA_current

    // NMDA gate: coincidence check with D-serine from astrocyte
    if membrane_potential > -40mV and D_serine_release > threshold:
        NMDA_Mg_block      = False
        post_Ca_amplitude += NMDA_influx(glutamate_cleft)
        post_Ca_rise_speed = d(post_Ca_amplitude) / dt  // TRACE: encodes LTP vs LTD

    // TAG PLANTED HERE — before bAP confirms coincidence
    // Condition: Ca²⁺ rising, NMDA open, ion channels activated
    if post_Ca_amplitude > Ca_TAG_threshold and NMDA_Mg_block == False:
        spine_tag = True                    // TRACE: tag planted in anticipation window
        dend_tagged_spines.add(spine_id)    // enters competition for drifting proteins

    // PKA priming — if neuromodulator context already set
    if GluA1_Ser845_primed:
        AMPA_insertion_threshold *= 0.7     // easier to anchor receptors later

CONTEXT: bAP (back-propagating action potential arriving)

scope DAY | context bAP:

    // bAP depolarizes spine — confirms or rejects the tag planted in NOT_bAP
    membrane_potential += bAP_depolarization(dend.bAP_amplitude)

    // Coincidence validation: was the tag planted just before bAP?
    if spine_tag == True and post_Ca_amplitude > Ca_TAG_threshold:
        // Confirmed Hebbian coincidence — escalate Ca²⁺
        post_Ca_amplitude  += bAP_Ca_boost()  // TRACE: amplitude now crosses LTP threshold
        post_Ca_rise_speed  = d(post_Ca_amplitude) / dt

    elif spine_tag == False:
        // bAP arrived but no prior glutamate signal — no coincidence
        // membrane_potential rises transiently but no Ca²⁺ amplification
        pass

    // Fuel: NaK pump resets membrane — gated by lactate from astrocyte
    membrane_potential restored by NaK_ATPase(astro.lactate_out)
    soma_ATP_budget   -= bAP_propagation_cost

DEND — Dendritic Branch

CONTEXT: CONTINUOUS (branch is always active as integrator)

scope DAY | context CONTINUOUS:

    // Branch integrates spine activity and propagates bAP
    branch_voltage     = integrate(POST.membrane_potential, all_spines_on_branch)
    bAP_amplitude      = propagate_bAP(SOMA.AP_fired, branch_geometry)
                                         // TRACE: bAP_amplitude decays with distance from soma

    // Branch Ca²⁺ — driven by bAP and local NMDA spillover
    branch_Ca         += bAP_Ca_influx(bAP_amplitude)
    branch_Ca         *= decay(τ ≈ 300ms)  // TRACE: slower than spine Ca²⁺

    // Branch tag — planted when multiple co-active spines detected
    if co_active_spines(branch) > branch_tag_threshold:
        branch_tag = True               // TRACE: branch-level tag for coordinated plasticity
        BDNF_TrkB_signaling += local_BDNF_release(branch_Ca)  // TRACE: survival signal

    // Local translation — mRNA → protein at branch ribosomes
    // Only runs if branch_tag is set and mRNA pool available
    if branch_tag and dend_mRNA_pool > 0:
        local_protein_translation = translate(dend_mRNA_pool, dend_mitochondria_capacity)
        dend_mRNA_pool           -= local_protein_translation × cost
        dend_protein_flux        += local_protein_translation  // TRACE: locally produced proteins

    // Branch energy budget
    dend_mitochondria_capacity -= branch_ATP_cost(branch_voltage, local_protein_translation)

    // Intermediate tuning: ACh modulates branch excitability globally
    LTP_threshold *= (1 / (1 + ACh_level × mAChR_gain))

SOMA — Cell Body

CONTEXT: AP (somatic action potential fired)

scope DAY | context AP:

    // Somatic AP triggered when branch_voltage integration crosses threshold
    if SOMA.membrane_potential > AP_threshold:
        AP_fired = True

        // Nuclear Ca²⁺ — key trace for slow-scale gene expression
        nuclear_Ca += Ca_influx_from_AP()   // TRACE: accumulates with firing rate
        nuclear_Ca *= decay(τ ≈ seconds)

        // CREB phosphorylation — gated by nuclear Ca²⁺ AND PKA
        if nuclear_Ca > Ca_CREB_threshold and PKA_activity > PKA_threshold:
            CREB_phospho = True             // TRACE: enables gene expression in NIGHT scope
            SOMA.Arc_mRNA_level    += transcribe(Arc_gene)   // TRACE: ships to active branches
            SOMA.BDNF_production_rate += transcribe(BDNF_gene)

        soma_ATP_budget -= AP_generation_cost

CONTEXT: NOT_AP (between somatic spikes)

scope DAY | context NOT_AP:

    // Integrate dendritic input — build toward next AP or not
    SOMA.membrane_potential = integrate(DEND.branch_voltage, all_branches)

    // Ship mRNA to active dendritic branches — tagged branches receive priority
    for branch in dend_tagged_spines:
        Arc_mRNA_level  → ship_to(branch, priority_fraction)  // TRACE: Arc arrives at branch
        BDNF_production_rate → modulate(branch_BDNF_level)

    // Ship organelles to high-demand branches
    if soma_organelle_pool > 0:
        soma_organelle_queue.add(branches_ranked_by(branch_Ca))
        dend_mitochondria_capacity[top_branch] += deliver_organelle()
        soma_organelle_pool -= delivery_cost

    // Neuromodulator context received — PKA gate set for all compartments
    if dopamine_level > D1_threshold or NE_level > β_threshold:
        PKA_activity    = proportional_to(cAMP_level)
        GluA1_Ser845_primed = True          // TRACE: primes all tagged spines
        DARPP32_phospho     = True          // TRACE: silences LTD phosphatase
        CREB_active         = True          // TRACE: gene expression gate open

ASTRO — Astrocyte

CONTEXT: CONTINUOUS (astrocyte monitors territory at all times)

scope DAY | context CONTINUOUS:

    // Clearance — always running, rate limited by EAAT pool and ATP budget
    glutamate_cleft     -= glutamate_clearance_rate × Δt
    astro_ATP_budget    -= clearance_ATP_cost(glutamate_clearance_rate)

    // Overflow detection — gated by spillover threshold (low-affinity mGluR5)
    glutamate_spillover  = extrasynaptic_diffusion(glutamate_cleft)
    if glutamate_spillover > spillover_threshold:
        mGluR5_activation  = True
        astro_Ca_local    += IP3_cascade(PLC)    // TRACE: local Ca²⁺ rises
        (g_Ds, _, _)       = request_astro_resources(syn_id, proportional_to(astro_Ca_local), 0, 0)
        D_serine_release  += g_Ds                // NMDA co-agonist — may be budget-limited
        mGluR2_3_activation = True               // simultaneously brakes PRE

    // Global overload check
    astro_Ca_global = soma_wave(astro_Ca_local > OVERLOAD_threshold)
    if astro_Ca_global: trigger(shockwave_lockdown)

    // Fuel pipeline — hard-capped at vascular ceiling
    lactate_out = min(glycolysis_rate(glutamate_clearance_rate), astro_lactate_ceiling)
    deliver(lactate_out → PRE, POST, DEND)      // all three compartments draw from this
    astro_ATP_budget += glycolysis(lactate_out) × Δt

Special Case — Shockwave Lockdown (>100Hz, uncoordinated, any scope)

scope DAY or NIGHT | context OVERLOAD:

    astro_Ca_global     = GLOBAL_WAVE
    release(GABA, ATP)                          // emergency — bypasses budget gate
    rec_AMPA            = POST.mass_internalization()
    POST.AMPA_count    -= rec_AMPA
    dend_receptor_reserve += rec_AMPA           // returned to branch reserve
    POST.membrane_potential = HYPERPOLARIZED
    cluster(PRE.VGCC → beneath_active_zone)     // overdrive — signal preserved in chaos
    astro_ATP_budget   -= emergency_response_cost()


SCOPE: NIGHT

Structural commit, resource replenishment, consolidation. All compartments are modulated. Slow variables now WRITTEN.


ALL COMPARTMENTS — Structural Commit

scope NIGHT:

    // Step 1: replenish all budgets — soma protein synthesis peaks here
    replenish_budgets(Δt_night)

    // Step 2: process somatic shipping queue — fulfill deferred organelle deliveries
    for branch in soma_organelle_queue:
        dend_mitochondria_capacity[branch] += deliver_organelle()
        soma_organelle_pool -= delivery_cost

    // Step 3: evaluate structural commit for each tagged synapse
    for each (bouton_id, spine_id, syn_id) where spine_tag == True:
        commit_to_structural_change(bouton_id, spine_id, syn_id)

    // Step 4: homeostatic downscaling — prune unvalidated potentiations
    for each synapse where spine_tag == False and disuse_duration > disuse_threshold:
        passive_LTD(synapse)

    // Step 5: clear all DAY-scope traces that were not committed
    for each expired_tag in dend_tagged_spines + axon_tagged_boutons:
        expire_tag(expired_tag)

PRE — Structural Commit (NIGHT)

scope NIGHT | PRE:

    g_AZ = request_axon_resources(bouton_id, AZ_expansion_cost)

    // Commit proportional to granted budget
    active_zone_size     += g_AZ                    // SLOW TRACE: permanent AZ expansion
    RRP_pool_capacity    += pool_expansion(active_zone_size)
    VGCC_clustering      += cluster_beneath_AZ(g_AZ)
    vesicle_release_prob += scale_with(g_AZ)

    // If partial grant: deficit queued for next NIGHT cycle
    if g_AZ < AZ_expansion_cost:
        queue(bouton_id, deficit, axon_vesicle_protein_pool)

    axon_tagged_boutons.remove(bouton_id)

    // LTD branch: resources returned to pool
    if LTD_signal:
        rec_AZ = docking_slot_removal()
        active_zone_size          -= rec_AZ
        axon_vesicle_protein_pool += rec_AZ         // returned for reuse
        RRP_pool_capacity         -= pool_contraction()
        VGCC_clustering           -= scatter_VGCCs()
        vesicle_release_prob      *= 0.6

POST — Structural Commit (NIGHT)

scope NIGHT | POST:

    (g_AMPA, g_actin) = request_dend_resources(spine_id, AMPA_cost, actin_cost)

    // Commit proportional to granted budget
    activate(CaMKII)
    AMPA_count   += receptor_insertion(CaMKII, g_AMPA)  // SLOW TRACE: permanent receptor gain
    spine_volume *= (1 + spine_scale(g_actin))           // SLOW TRACE: spine head enlarged

    // Deficit queued for next NIGHT cycle
    if g_AMPA < AMPA_cost:
        queue(spine_id, deficit, dend_protein_flux)

    dend_tagged_spines.remove(spine_id)
    spine_tag = False                                    // tag cleared after commit

    // LTD branch: resources returned to branch pool
    if LTD_signal:
        activate(PP1)
        rec_AMPA              = receptor_internalization(PP1)
        AMPA_count           -= rec_AMPA
        dend_receptor_reserve += rec_AMPA               // returned to branch pool
        spine_volume         *= 0.7
        dend_actin_machinery += actin_depolymerization()

DEND — Structural Commit (NIGHT)

scope NIGHT | DEND:

    // Branch receives organelles shipped from soma during NIGHT
    dend_mitochondria_capacity += soma_organelle_delivery(branch_id)  // SLOW TRACE

    // Arc mRNA translated into structural proteins at branch ribosomes
    if dend_mRNA_pool > Arc_threshold:
        new_proteins = translate(dend_mRNA_pool, dend_mitochondria_capacity)
        dend_protein_flux     += new_proteins            // SLOW TRACE: local supply expanded
        dend_mRNA_pool        -= translation_cost

    // Branch BDNF consolidates active branch architecture
    if branch_BDNF_level > BDNF_survival_threshold:
        dend_mitochondria_density += BDNF_TrkB_signaling × Δt  // SLOW TRACE: branch reinforced
    else:
        dend_mitochondria_density -= pruning_rate() × Δt       // SLOW TRACE: branch weakened

    // Branch tag cleared
    branch_tag = False

SOMA — Structural Commit (NIGHT)

scope NIGHT | SOMA:

    // CREB drives transcription — highest rate during NIGHT (slow-wave sleep replay)
    if CREB_phospho:
        soma_protein_synthesis_rate  += CREB_driven_expression()  // SLOW TRACE
        soma_receptor_synthesis_rate += CREB_driven_expression()
        soma_mRNA_transcription_rate += transcription_burst()

    // Replenish organelle pool — biogenesis peaks during rest
    soma_organelle_pool += mitochondria_biogenesis() × Δt         // SLOW TRACE
    soma_ATP_budget     += overnight_mitochondria_recovery() × Δt

    // Homeostatic scaling: if overall firing was too high, scale down all synapses
    if soma_AP_rate_history > homeostatic_ceiling:
        for each synapse:
            AMPA_count[synapse]          *= homeostatic_scale_down_factor
            vesicle_release_prob[synapse] *= homeostatic_scale_down_factor

    // Clear CREB trace if no further consolidation needed
    if soma_organelle_queue.empty() and dend_tagged_spines.empty():
        CREB_phospho = False
        CREB_active  = False

ASTRO — Structural Commit (NIGHT)

scope NIGHT | ASTRO:

    // Perisynaptic process remodeling — most expensive astrocyte operation
    // LTP: walls move IN — seals and insulates the channel
    if LTP_signal:
        (g_Ds, g_ECM, g_pr) = request_astro_resources(syn_id, Ds_cost, ECM_cost, proc_cost)
        perisynaptic_distance    -= g_pr      // SLOW TRACE: tighter wrap
        ECM_integrity            += g_ECM    // SLOW TRACE: matrix sealed
        D_serine_tonic_level     += g_Ds     // SLOW TRACE: sustained co-agonist
        glutamate_clearance_rate *= (1 - clearance_scale(g_pr))  // SLOW TRACE

    // LTD: walls move OUT — loosens diffusion barrier, dissolves matrix
    if LTD_signal:
        rec_ECM = secrete(MMPs)
        ECM_integrity            -= rec_ECM
        astro_ECM_protein_pool   += rec_ECM × recycling_fraction  // partial recovery
        D_serine_tonic_level      = 0                              // SLOW TRACE: starved
        perisynaptic_distance    += process_extension()
        astro_process_extensions += freed_process                  // freed for reallocation
        glutamate_clearance_rate *= 1.2                            // SLOW TRACE

    // Replenish astrocyte pools overnight
    replenish_budgets(Δt_night)

Heterosynaptic Depression — Passive Resource Depletion (any scope)

scope DAY or NIGHT | triggered by budget exhaustion:

    function heterosynaptic_depression(neighbor_ids):
        // No active signal — purely consequence of pool depletion
        for n in neighbor_ids:
            if n not in dend_tagged_spines and n not in axon_tagged_boutons:
                POST.AMPA_count[n]           -= passive_depletion_rate()
                PRE.vesicle_release_prob[n]  -= passive_depletion_rate()

Energy Supply Chain — Metabolic Gating (DAY scope, CONTINUOUS)

scope DAY | context CONTINUOUS:

    function metabolic_loop(Δt):
        glucose_uptake = blood_capillary_supply()          // vascular hard ceiling
        lactate_out    = min(glycolysis(glucose_uptake, glutamate_clearance_rate),
                             astro_lactate_ceiling)
        lactate_out   *= load_factor(glutamate_clearance_rate)

        // Distribute fuel to all three consumer compartments
        PRE.RRP_pool       refilled by VATPase(lactate_out × pre_fraction)
        POST.membrane_potential reset by NaK_ATPase(lactate_out × post_fraction)
        DEND.branch_ops    powered by lactate_out × dend_fraction

        astro_ATP_budget  += glycolysis(lactate_out) × Δt

Key Asymmetries and Closure Summary

// PERISYNAPTIC DISTANCE — amplifies both directions
// LTP: walls IN  → clearance_rate ↓, D_serine_tonic ↑  → self-reinforcing
// LTD: walls OUT → clearance_rate ↑, D_serine_tonic = 0 → self-reinforcing
// Cost: astro_process_extensions budget — slow to recover (hours)

// SYNAPTIC TAG — the bridge between DAY and NIGHT
// Planted in DAY (NOT_bAP context) when Ca²⁺ rises before bAP confirms coincidence
// Consumed in NIGHT when structural commit runs and budget is available
// Expires in NIGHT if no save signal arrived during DAY — no structural trace left

// BUDGET CONSERVATION — the system is closed
// LTP draws from shared pools → neighbors passively depressed (heterosynaptic LTD)
// LTD returns resources to pools → neighbors passively enriched
// Net: one synapse's gain is its neighbors' loss, bounded by vascular glucose ceiling

// SLEEP (NIGHT scope) — not passive recovery but active execution
// soma_protein_synthesis_rate peaks → queued deficits fulfilled
// CREB_driven_expression peaks → new structural proteins shipped to tagged branches
// Homeostatic downscaling runs → unvalidated potentiations pruned
// All DAY traces either committed to structure or cleared