diff --git a/elements/neuron/appunti/old/2026-06-06-tripartite_synapse_v4.md b/elements/neuron/appunti/old/2026-06-06-tripartite_synapse_v4.md new file mode 100644 index 0000000..5a35bca --- /dev/null +++ b/elements/neuron/appunti/old/2026-06-06-tripartite_synapse_v4.md @@ -0,0 +1,792 @@ +--- +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. + +--- +--- + +# Tripartite Synapse — Pseudocode v4 + +--- + +## Conventions + +``` +SCOPE = { DAY, NIGHT } +CONTEXT = { AP, NOT_AP, bAP, NOT_bAP, CONTINUOUS } + +Variable types: + FIXED = imposed externally — does not change during simulation + VAR = changes dynamically + FAST_TRACE = accumulates and decays within DAY scope only + lifetime: ms to minutes + role: biases the next behavior within the same context + cleared: automatically by decay, never persists to NIGHT + + TAG = set during DAY, persists into NIGHT scope + lifetime: hours — survives the full DAY scope + role: gates structural commit in NIGHT + cleared: explicitly at end of NIGHT after commit or expiry + requires: explicit SET and CLEAR operations + + BUDGET = single energy variable per compartment + all costs deducted here regardless of molecular source + + STRUCTURE = slow architectural variable + READ during DAY, WRITTEN only during NIGHT +``` + +--- + +## Fixed Parameters + +``` +FIXED input_freq // driving spike frequency +FIXED dopamine_level // reward/save signal from VTA +FIXED NE_level // arousal signal from locus coeruleus +FIXED ACh_level // attention signal from basal forebrain +FIXED vascular_glucose_supply // hard energy ceiling +FIXED branch_geometry // dendritic topology — affects bAP decay +FIXED Ca_HIGH // LTP-triggering Ca²⁺ threshold +FIXED Ca_LOW // LTD-triggering Ca²⁺ threshold +FIXED Ca_TAG_threshold // Ca²⁺ level sufficient to set a tag +FIXED spillover_threshold // cleft saturation threshold for mGluR activation +FIXED homeostatic_ceiling // max firing rate before global downscale +FIXED disuse_threshold // silence duration before passive LTD +FIXED recycling_fraction // fraction of ECM proteins recovered after MMP cleavage +FIXED tag_expiry_threshold // minimum tag strength to survive to NIGHT commit +``` + +--- + +## Budgets — One Per Compartment + +``` +VAR pre_budget // bouton ATP + // costs: VGCC opening, vesicle fusion, VATPase refill, AZ maintenance + // (simplifies: axon_mitochondria_capacity + vesicle_protein_pool) + +VAR post_budget // spine ATP + // costs: NMDA current, NaK reset, AMPA trafficking, actin remodeling + // (simplifies: spine_actin_machinery + receptor_reserve) + +VAR dend_budget // branch ATP + // costs: bAP propagation, local translation, branch Ca²⁺ handling + // (simplifies: dend_mitochondria_capacity + local_protein_flux) + +VAR soma_budget // somatic ATP + // costs: AP generation, CREB transcription, protein synthesis, shipping + // (simplifies: soma_ATP + synthesis_rate + organelle_pool) + +VAR astro_budget // astrocyte ATP + // costs: glutamate clearance, D-serine synthesis, ECM secretion, + // process motility, lactate production + // (simplifies: astro_ATP + racemase_cap + ECM_pool + process_extensions) + +VAR astro_lactate // fuel exported to pre, post, dend budgets + // hard cap: vascular_glucose_supply (FIXED) +``` + +--- + +## Traces — Split Into FAST_TRACE and TAG Per Compartment + +``` +// ── PRE ─────────────────────────────────────────────────────────────── + +FAST_TRACE pre_fast_trace // residual Ca²⁺ in bouton + // SET: += spike_Ca_influx() on each AP + // DECAY: *= exp(-Δt / 100ms) continuously + // ROLE: biases vesicle_release_prob in next AP context + // CLEAR: decays automatically — never reaches NIGHT + // (covers: pre_Ca_residual, short-term facilitation) + +TAG pre_tag // commitment candidacy of this bouton + // SET: when dopamine_level > D1_threshold in NOT_AP context + // ROLE: grants priority access to axonal protein pool in NIGHT + // marks bouton as validated for structural expansion + // CLEAR: explicitly at end of NIGHT after commit or expiry + // (covers: axon_tagged_boutons, PKA-driven bouton marking) + +// ── POST ────────────────────────────────────────────────────────────── + +FAST_TRACE post_fast_trace // Ca²⁺ dynamics in spine + // SET: += NMDA_Ca_influx × rise_speed() in NOT_bAP context + // SET: += bAP_Ca_boost() if pre_tag confirmed in bAP context + // DECAY: *= exp(-Δt / τ_Ca) — faster for LTP, slower for LTD + // ROLE: encodes LTP vs LTD instruction via amplitude + speed + // gates whether post_tag is set + // CLEAR: decays automatically — never reaches NIGHT + // (covers: post_Ca_amplitude, post_Ca_rise_speed, CaMKII vs PP1) + +TAG post_tag // commitment candidacy of this spine + // SET: when post_fast_trace > Ca_TAG_threshold in NOT_bAP + // AND confirmed by bAP in bAP context + // ROLE: grants priority access to dend receptor reserve in NIGHT + // gates structural commit of AMPA insertion + spine growth + // CLEAR: explicitly at end of NIGHT after commit or expiry + // (covers: dend_tagged_spines, synaptic tag-and-capture) + +// ── DEND ────────────────────────────────────────────────────────────── + +FAST_TRACE dend_fast_trace // branch Ca²⁺ integration + // SET: += bAP_Ca_influx() + spine_spillover_Ca() + // DECAY: *= exp(-Δt / 300ms) — slower than spine Ca²⁺ + // ROLE: integrates co-active spine count + // gates whether dend_tag is set + // CLEAR: decays automatically — never reaches NIGHT + // (covers: branch_Ca, local NMDA spillover integration) + +TAG dend_tag // commitment candidacy of this branch + // SET: when co_active_spines > branch_tag_threshold + // AND dend_fast_trace > dend_tag_threshold + // ROLE: activates local mRNA translation during DAY + // gates branch structural expansion in NIGHT + // triggers BDNF release to soma + // CLEAR: explicitly at end of NIGHT after commit or expiry + // (covers: branch_tag, BDNF-TrkB branch survival signal) + +// ── SOMA ────────────────────────────────────────────────────────────── + +FAST_TRACE soma_fast_trace // nuclear Ca²⁺ accumulation + // SET: += nuclear_Ca_influx() on each somatic AP + // DECAY: *= exp(-Δt / τ_nuclear) — seconds timescale + // ROLE: gates CREB phosphorylation when combined with PKA + // gates soma_tag when threshold crossed + // CLEAR: decays automatically — never reaches NIGHT + // (covers: nuclear_Ca, AP-driven Ca²⁺ accumulation) + +TAG soma_tag // gene expression mandate + // SET: when soma_fast_trace > CREB_threshold + // AND dopamine_level > D1_threshold (PKA coincidence) + // ROLE: drives protein synthesis rate in NIGHT scope + // determines how much structural protein is available + // for all compartment commits + // CLEAR: explicitly at end of NIGHT after synthesis executed + // (covers: CREB_phospho, Arc_mRNA, BDNF_production mandate) + +// ── ASTRO ───────────────────────────────────────────────────────────── + +FAST_TRACE astro_fast_trace // local Ca²⁺ in perisynaptic process + // SET: += mGluR5_Ca_influx() when glutamate > spillover_threshold + // DECAY: *= exp(-Δt / τ_astro_Ca) — seconds timescale + // ROLE: drives D-serine release proportional to magnitude + // gates astro_tag when overload threshold crossed + // CLEAR: decays automatically — never reaches NIGHT + // (covers: astro_Ca_local, IP3-driven Ca²⁺) + +TAG astro_tag // territory-level activity record + // SET: when astro_fast_trace > astro_tag_threshold + // integrates overflow events across territory + // ROLE: confirms overflow_sensed condition in NIGHT commit + // gates ECM sealing and process remodeling in NIGHT + // CLEAR: explicitly at end of NIGHT after structural commit + // (covers: mGluR5_activation record, overflow validation) +``` + +--- + +## Structural Variables — Written Only in NIGHT + +``` +VAR pre_structure // active zone capacity + // (covers: active_zone_size + VGCC_clustering + RRP_pool_capacity) + +VAR post_structure // spine sensitivity + // (covers: AMPA_count + spine_volume) + +VAR dend_structure // branch capacity + // (covers: mitochondria_density + local_protein_flux_ceiling) + +VAR soma_structure // somatic output capacity + // (covers: protein_synthesis_rate + organelle_pool) + +VAR astro_structure // synaptic environment geometry + // (covers: perisynaptic_distance + ECM_integrity + // + D_serine_tonic_level + glutamate_clearance_rate) +``` + +--- +--- + +# SCOPE: DAY +# FAST_TRACEs written and decay. TAGs set but not cleared. STRUCTUREs read only. + +--- + +## PRE | CONTEXT: AP + +``` +scope DAY | context AP: + + if pre_budget < release_cost: + suppress(release) + exit context + + // Fast trace: deposit and decay + pre_fast_trace += spike_Ca_influx(input_freq) + pre_fast_trace *= decay(τ = 100ms) // FAST_TRACE — will not reach NIGHT + + // Release gated by fast trace (residual Ca²⁺ from recent APs) + release_prob = pre_structure.base_prob × facilitation(pre_fast_trace) + released = binomial(RRP_pool, release_prob) + glutamate = released × quantal_content + pre_budget -= release_cost + + // Overflow: autoinhibitory brake + astro notification + if glutamate > spillover_threshold: + release_prob *= mGluR_brake_factor // Gi arm — no budget cost on PRE + + // Refuel + pre_budget += astro_lactate × pre_fraction +``` + +## PRE | CONTEXT: NOT_AP + +``` +scope DAY | context NOT_AP: + + // Fast trace decays passively + pre_fast_trace *= decay(τ = 100ms) + + // Intermediate tuning from fast trace history + if pre_fast_trace > high_threshold: + mobilize(reserve → RRP) // pool-limited + elif pre_fast_trace < low_threshold: + release_prob *= depression_factor + + // Tag: set when neuromodulator context validates this bouton + if dopamine_level > D1_threshold or NE_level > β_threshold: + pre_tag = SET // TAG — persists to NIGHT + // pre_fast_trace NOT modified + // two variables, two lifetimes +``` + +--- + +## POST | CONTEXT: NOT_bAP + +``` +scope DAY | context NOT_bAP: + + // AMPA current — gated by post_structure (READ) + Vm += glutamate × post_structure.sensitivity + post_budget -= AMPA_cost + + // NMDA gate: depolarization + D-serine coincidence + if Vm > Mg_eject_threshold and astro_D_serine > D_serine_threshold: + Ca_influx = NMDA_influx(glutamate) + post_fast_trace += Ca_influx × rise_speed(Ca_influx) // FAST_TRACE — will not reach NIGHT + post_budget -= NMDA_cost + + // Tag: set when fast trace crosses tagging threshold + // This is the Hebbian anticipation window — before bAP confirms + if post_fast_trace > Ca_TAG_threshold: + post_tag = SET // TAG — persists to NIGHT + // post_fast_trace NOT modified + // tag is a separate variable, separate lifetime +``` + +## POST | CONTEXT: bAP + +``` +scope DAY | context bAP: + + // bAP arrives — confirms or rejects the tag set in NOT_bAP + Vm += bAP_depolarization(dend_structure.geometry) + + if post_tag == SET and post_fast_trace > Ca_TAG_threshold: + post_fast_trace += bAP_Ca_boost() // FAST_TRACE amplified — confirms coincidence + // post_tag remains SET — bAP confirms but does not set the tag + // else: bAP without prior tag — no amplification, no tag set + + post_budget -= bAP_reset_cost + dend_budget -= bAP_prop_cost +``` + +--- + +## DEND | CONTEXT: CONTINUOUS + +``` +scope DAY | context CONTINUOUS: + + // Integrate and propagate + branch_Vm = integrate(POST.Vm, all_spines) + bAP_local = propagate_bAP(SOMA.AP_fired, dend_structure.geometry) + + // Fast trace: branch Ca²⁺ + dend_fast_trace += bAP_Ca_influx(bAP_local) + dend_fast_trace *= decay(τ = 300ms) // FAST_TRACE — will not reach NIGHT + + // Tag: set when branch co-activity crosses threshold + if co_active_spines(branch) > branch_tag_threshold: + dend_tag = SET // TAG — persists to NIGHT + BDNF_signal → soma // signals branch recruitment to soma + + // Local translation: only runs if tag set and budget allows + // Uses dend_fast_trace magnitude to scale translation rate + if dend_tag == SET and dend_budget > translation_cost: + local_proteins = translate(mRNA_pool, dend_fast_trace) + dend_structure.protein_flux += local_proteins // immediate local supply + dend_budget -= translation_cost + + dend_budget -= branch_maintenance_cost + dend_budget += astro_lactate × dend_fraction +``` + +--- + +## SOMA | CONTEXT: AP + +``` +scope DAY | context AP: + + if branch_Vm > AP_threshold: + AP_fired = True + + // Fast trace: nuclear Ca²⁺ + soma_fast_trace += nuclear_Ca_influx() // FAST_TRACE — will not reach NIGHT + soma_fast_trace *= decay(τ = seconds) + + // Tag: set when fast trace AND neuromodulator context coincide + if soma_fast_trace > CREB_threshold and dopamine_level > D1_threshold: + soma_tag = SET // TAG — persists to NIGHT + // soma_fast_trace NOT modified + // two variables, two lifetimes + + soma_budget -= AP_generation_cost +``` + +## SOMA | CONTEXT: NOT_AP + +``` +scope DAY | context NOT_AP: + + branch_Vm = integrate(DEND.branch_Vm, all_branches) + + // Ship resources to tagged branches — tag status determines priority + for branch in branches_ranked_by(dend_tag == SET): + dend_budget[branch] += soma_budget × shipping_fraction + soma_budget -= shipping_cost + + // Neuromodulator broadcast: amplifies post_fast_trace at tagged spines + // Does NOT set tags — that requires the Ca²⁺ coincidence in POST + if dopamine_level > D1_threshold or NE_level > β_threshold: + for spine where post_tag == SET: + post_fast_trace *= PKA_amplifier // FAST_TRACE boosted — lowers commit threshold +``` + +--- + +## ASTRO | CONTEXT: CONTINUOUS + +``` +scope DAY | context CONTINUOUS: + + // Clearance — rate set by astro_structure (READ) + glutamate -= astro_structure.clearance_rate × Δt + astro_budget -= clearance_cost + + // Fast trace: local Ca²⁺ from overflow + if glutamate > spillover_threshold: + astro_fast_trace += mGluR5_Ca_influx() // FAST_TRACE — will not reach NIGHT + astro_fast_trace *= decay(τ = astro_Ca_τ) + + // D-serine proportional to fast trace — budget-limited + D_serine = min(proportional_to(astro_fast_trace), astro_budget × Ds_fraction) + astro_budget -= D_serine_cost + + // Tag: set when overflow is sustained above territory threshold + if astro_fast_trace > astro_tag_threshold: + astro_tag = SET // TAG — persists to NIGHT + // astro_fast_trace NOT modified + + // Global overload: fast trace spike triggers lockdown + if astro_fast_trace > OVERLOAD_threshold: + trigger(shockwave_lockdown) // uses astro_fast_trace, not astro_tag + + // Fuel pipeline — capped at vascular_glucose_supply (FIXED) + astro_lactate = min(glycolysis(vascular_glucose_supply), astro_budget × lactate_fraction) + astro_budget += glycolysis(vascular_glucose_supply) × Δt + deliver(astro_lactate → pre_budget, post_budget, dend_budget) +``` + +--- +--- + +# SCOPE: NIGHT +# TAGs evaluated. STRUCTUREs written. Budgets replenished. All traces cleared. + +--- + +## Step 1 — Replenish Budgets + +``` +scope NIGHT | step 1: + + // soma_tag magnitude determines how much synthesis runs + soma_structure.synthesis_rate = CREB_expression(soma_tag) // TAG READ here + astro_budget += overnight_synthesis() × Δt_night + soma_budget += overnight_mitochondria() × Δt_night + dend_budget += soma_budget × dend_replenish_fraction + post_budget += soma_budget × post_replenish_fraction + pre_budget += soma_budget × pre_replenish_fraction +``` + +--- + +## Step 2 — Structural Commit + +``` +scope NIGHT | step 2: + + // Three-layer filter — uses TAGs, not FAST_TRACEs + event_strong = post_tag == SET // TAG evaluated + overflow_seen = astro_tag == SET // TAG evaluated + context_valid = pre_tag == SET // TAG evaluated + and soma_tag == SET // TAG evaluated + + if event_strong and overflow_seen and context_valid: + + // All four compartments commit simultaneously — budget-gated + ΔAZ = min(AZ_cost, pre_budget × pre_structural_fraction) + ΔAMPA = min(AMPA_cost, post_budget × post_structural_fraction) + ΔDEND = min(dend_cost, dend_budget × dend_structural_fraction) + ΔASTRO = min(astro_cost, astro_budget × astro_structural_fraction) + + pre_structure += ΔAZ // STRUCTURE WRITTEN — larger active zone + post_structure += ΔAMPA // STRUCTURE WRITTEN — more receptors, larger spine + dend_structure += ΔDEND // STRUCTURE WRITTEN — denser mitochondria, more flux + astro_structure -= ΔASTRO // STRUCTURE WRITTEN — walls IN, ECM sealed, D-serine tonic ↑ + + pre_budget -= ΔAZ × structural_cost + post_budget -= ΔAMPA × structural_cost + dend_budget -= ΔDEND × structural_cost + astro_budget -= ΔASTRO × structural_cost + + // Partial grants: deficit queued for next NIGHT + if ΔAZ < AZ_cost: queue(pre_deficit → next NIGHT) + if ΔAMPA < AMPA_cost: queue(post_deficit → next NIGHT) + + return "potentiated" + + elif event_strong and not context_valid: + return "temporary — no commit" // tags expire without structural write + + elif post_tag == SET and post_fast_trace < Ca_LOW: + // LTD: resources returned to budgets + pre_structure -= LTD_pre_amount + post_structure -= LTD_post_amount + astro_structure += LTD_astro_amount // walls OUT, ECM dissolved + pre_budget += recovered_AZ_cost + post_budget += recovered_AMPA_cost + astro_budget += recovered_process_cost × recycling_fraction + return "depressed" + + else: + return "baseline — no change" +``` + +--- + +## Step 3 — Homeostatic Scaling + +``` +scope NIGHT | step 3: + + if soma_tag.magnitude > homeostatic_ceiling: + for each synapse: + post_structure *= homeostatic_scale_down // STRUCTURE WRITTEN + pre_structure *= homeostatic_scale_down // STRUCTURE WRITTEN + + for each branch where dend_tag == CLEAR and disuse_duration > disuse_threshold: + dend_structure -= pruning_rate × Δt_night // STRUCTURE WRITTEN + dend_budget += recovered_branch_cost +``` + +--- + +## Step 4 — Clear All Traces + +``` +scope NIGHT | step 4: + + // FAST_TRACEs: already decayed during DAY — confirm zero + pre_fast_trace = 0 + post_fast_trace = 0 + dend_fast_trace = 0 + soma_fast_trace = 0 + astro_fast_trace = 0 + + // TAGs: explicitly cleared after commit or expiry + if pre_tag < tag_expiry_threshold: pre_tag = CLEAR + if post_tag < tag_expiry_threshold: post_tag = CLEAR + if dend_tag < tag_expiry_threshold: dend_tag = CLEAR + if soma_tag < tag_expiry_threshold: soma_tag = CLEAR + if astro_tag < tag_expiry_threshold: astro_tag = CLEAR + // Tags above threshold: persist to next NIGHT (multi-night consolidation) +``` + +--- + +## Key Structural Asymmetry + +``` +// astro_structure controls both diffusion geometry and D-serine tonic simultaneously: +// LTP commit → astro_structure decreases (walls IN) +// → clearance_rate ↓ + D_serine_tonic ↑ +// → every future DAY event easier to potentiate +// LTD commit → astro_structure increases (walls OUT) +// → clearance_rate ↑ + D_serine_tonic = 0 +// → every future DAY event easier to depress +// Self-reinforcing in both directions. + +// Budget conservation: +// LTP draws from shared budgets → neighbors passively impoverished +// LTD returns resources to budgets → neighbors passively enriched +// Hard ceiling: vascular_glucose_supply (FIXED) — cannot be exceeded + +// The FAST_TRACE / TAG split enforces the core loop precisely: +// FAST_TRACE: behavior leaves a trace that biases the next behavior (within DAY) +// TAG: behavior leaves a trace that gates resource allocation (DAY → NIGHT) +// STRUCTURE: resource allocation produces permanent change (written in NIGHT) +// BUDGET: all of the above is constrained by available energy +``` + + +--- +--- + + +# Additions + +## Neuromodulators + +These are produced by small, anatomically concentrated nuclei that broadcast widely across the brain: + +- dopamine_level // "save button" — validates LTP +- norepinephrine_level // arousal / signal-to-noise gain +- acetylcholine_level // attention — lowers LTP threshold + +### Dopamine + +Dopamine is produced primarily by neurons in the Substantia Nigra pars compacta (projecting to the striatum, relevant for motor learning and habit formation) and the Ventral Tegmental Area (VTA) (projecting to the prefrontal cortex and limbic system via the mesolimbic and mesocortical pathways, relevant for reward, motivation, and the "save button" function in your model). + +### Norepinephrine +Norepinephrine is produced almost exclusively by the Locus Coeruleus, a tiny nucleus in the brainstem pons. Despite its small size it projects diffusely across virtually the entire brain — cortex, hippocampus, cerebellum, spinal cord. It's essentially the brain's arousal and signal-to-noise broadcaster, firing tonically at low rates during calm wakefulness and phasically during novel or stressful events. + +### Acetylcholine +Acetylcholine has two main sources: the basal forebrain nuclei (including the nucleus basalis of Meynert) projecting to the cortex and hippocampus — relevant for attention and learning gating — and the medial septum projecting specifically to the hippocampus, where it strongly modulates theta rhythms and memory encoding. + +What's striking in the context of your model is that all three systems share the same architectural logic: a tiny, localized cell population broadcasts a global contextual signal that shifts the operational threshold of millions of synapses simultaneously — none of them carrying specific content, all of them modulating how content gets written. + +### Simple organisms + +Excellent point. The hippocampal replay model is a vertebrate solution to a specific problem — how to consolidate many parallel experiences quickly without catastrophic interference. But the underlying molecular logic of the commit function is far more ancient and appears in organisms that have no hippocampus, no sleep architecture in the vertebrate sense, and sometimes no centralized nervous system at all. + +**In invertebrates with simple ganglia** — *Aplysia*, *C. elegans*, *Drosophila* — the slow-scale consolidation still requires protein synthesis and still uses CREB as the nuclear transcription factor. The same PKA→CREB axis that validates LTP in the mammalian hippocampus was actually first characterized in *Aplysia* gill-withdrawal reflex studies by Kandel. What differs is the trigger and the timing. Without a hippocampus to compress and replay experiences during a rest phase, consolidation in these organisms appears to depend simply on **repetition and spacing of the stimulus itself**. A single strong shock to the siphon produces short-term sensitization lasting minutes — the intermediate scale running without commitment. Four or five spaced shocks over hours produce long-term sensitization lasting days — the slow-scale commit running because repeated PKA activation eventually crosses the threshold needed to drive CREB-dependent gene expression. The spacing matters because cAMP degrades between stimuli, and spaced repetition keeps re-elevating it above the threshold for nuclear translocation, whereas massed repetition saturates and desensitizes the cascade. + +**In *C. elegans***, which has exactly 302 neurons and no sleep in any recognizable sense, consolidation-like phenomena still occur through the same molecular logic. What substitutes for the validation signal is less clear, but there is evidence that **neuromodulatory interneurons releasing serotonin and dopamine** gate whether a repeated experience gets written into long-term behavioral change — functionally identical to the save button role, just implemented in a three-neuron circuit rather than a diffuse broadcast system. + +**In organisms without a nervous system at all** — *Physarum polycephalum*, the slime mould — something that looks functionally like consolidation occurs through purely biochemical means. Repeated exposure to a stimulus that causes contraction leaves a persistent change in the cytoskeletal and biochemical state of the organism that biases future responses. There is no synapse, no calcium influx through NMDA receptors, no PKA — but the logic of the three-layer filter is still present in a stripped-down form: the organism detects that something happened, detects that it was significant enough to exceed a threshold, and commits a physical change to its internal architecture that persists. The molecular substrate is different but the computational structure is the same. + +**What this suggests about consolidation in general** is that the slow-scale commit function does not require sleep or replay — those are vertebrate optimizations on top of a more primitive mechanism. The core requirements appear to be just three things that evolution has solved repeatedly with different molecular tools: + +The first is a **threshold mechanism** that prevents every transient event from being written permanently — in neurons this is the calcium amplitude and rise-speed filter, in slime moulds it is a chemical concentration threshold, but the logic is the same. + +The second is a **context validation signal** that asks whether the event was behaviorally meaningful — in vertebrates this is the neuromodulatory broadcast from VTA and locus coeruleus, in *Aplysia* it is facilitatory interneurons releasing serotonin, in slime moulds it may simply be the magnitude of the perturbation itself serving as its own validation. + +The third is a **protein synthesis requirement** that enforces a time cost on permanent storage — in all organisms where long-term behavioral change has been studied, blocking protein synthesis blocks consolidation, suggesting that the metabolic cost of building new structural proteins is a universal gate that prevents trivial events from consuming permanent resources. + +Sleep and hippocampal replay are therefore best understood not as the mechanism of consolidation but as a **vertebrate solution to the scaling problem** — how to consolidate thousands of experiences per day across billions of synapses without running the protein synthesis machinery continuously at full cost during waking. Simpler organisms consolidate fewer experiences, face less interference, and can afford to let repetition and spacing do the work that sleep does in more complex nervous systems. + +## Calcium in pre, post, astro + +**In the postsynapse**, the calcium amplitude and rise-speed filter works because CaMKII and the phosphatases PP1/PP2B have different sensitivities to calcium-bound calmodulin, and calmodulin itself has different binding kinetics depending on how fast calcium rises. + +Calmodulin has four calcium binding sites and its activation is highly cooperative — it does not activate linearly with calcium concentration but switches sharply above a threshold. When calcium rises fast and high, as during a strong high-frequency burst, calmodulin saturates quickly and activates CaMKII. CaMKII then autophosphorylates at Thr286, which is the critical step — once autophosphorylated it remains active even after calcium falls back to baseline, effectively converting a transient calcium event into a sustained kinase signal that outlasts the trigger. This persistence is what gives CaMKII its memory-like property and is what drives AMPA receptor insertion. + +When calcium rises slowly and to a lower amplitude, as during weak low-frequency input, calmodulin activates preferentially the phosphatases PP2B (calcineurin) and downstream PP1 instead, because these enzymes have higher affinity for calcium-calmodulin complexes at lower occupancy. PP1 then dephosphorylates AMPA receptors, triggering their internalization and driving LTD. + +So the filter is not a simple threshold — it is a **kinetic competition** between two enzyme systems with different calcium-calmodulin affinities. Fast large rise activates the low-affinity high-gain system (CaMKII). Slow small rise activates the high-affinity low-gain system (PP2B/PP1). The same calcium messenger routes to opposite outcomes depending purely on its dynamics. + +**In the presynapse**, the calcium filter is structurally simpler but operates on a different principle — **proximity and timing** rather than kinetic competition. Calcium enters through VGCCs clustered directly beneath the active zone, and the vesicles docked at that zone sit within nanometers of the channel mouth. The local calcium concentration at the release site reaches extremely high values — estimated at hundreds of micromolar — for a very brief window of microseconds before diffusing away. Synaptotagmin, the calcium sensor on the vesicle membrane, has a low affinity but fast on-rate, meaning it only fires in response to this extremely high local transient, not to the diffuse residual calcium that lingers afterward. + +The residual calcium that accumulates with repeated spikes — the pre_Ca_residual in the pseudocode — acts on a completely different target: Munc13 and RIM proteins at the active zone, which have higher affinity for calcium but slower kinetics. These proteins respond to the sustained low-level residual and increase the size of the readily-releasable pool and the probability of release — this is facilitation. So the presynaptic filter distinguishes between the sharp local transient (triggers release via synaptotagmin) and the slow diffuse residual (modulates future release probability via Munc13/RIM). Two calcium signals, two sensors, two time scales, within the same compartment. + +**In the astrocyte**, the calcium filter is the least understood of the three but operates through IP3 receptor gating. IP3 receptors on the endoplasmic reticulum have a bell-shaped calcium dependence — they open in response to rising calcium but are inhibited at very high calcium concentrations. This means the astrocyte's internal calcium release is self-limiting: a moderate IP3 signal produces a local calcium rise that drives D-serine release, but an excessive signal triggers the global soma wave that activates the circuit-breaker response instead. + +The key filter here is therefore the **spatial containment of the IP3 signal**. Under normal high-frequency activity, IP3 production is local to the perisynaptic process and the calcium rise stays local — driving D-serine release proportionally. Only when multiple neighboring synapses fire simultaneously does IP3 accumulate enough to propagate as a regenerative wave across the entire astrocyte via gap junctions to adjacent astrocytes, triggering the global alarm. The astrocyte is therefore filtering not just amplitude but **spatial coherence** — a single strong synapse produces a local response, but coordinated overactivity across a territory produces a qualitatively different global response. + +The common thread across all three compartments is that none of them use a simple concentration threshold. Each uses a molecular mechanism that is sensitive to the **dynamics** of the calcium signal — its speed, its spatial spread, its duration, or its subcellular location — rather than just its peak value. This is what allows the same ion to encode fundamentally different instructions depending on the context in which it arrives. + +## Resource budget + +Exactly right. This is a resource allocation problem, and it is one of the most important constraints the system operates under. Each compartment has a finite physical budget, and potentiation at one synapse necessarily draws from a shared pool that serves many others. + +**In the presynapse**, the axon has many en passant boutons — synaptic release sites distributed along its length, sometimes hundreds of them. The total vesicle pool, the mitochondrial capacity to run the VATPase pumps that refill vesicles, and the cytoskeletal machinery that mobilizes reserve pools are all shared across the entire axonal arbor. When one bouton undergoes LTP and expands its active zone and increases its RRP capacity, it is drawing on the same pool of synaptic proteins — RIM, Munc13, VGCC subunits — that all other boutons on that axon compete for. There is evidence for a **synaptic tagging and capture** mechanism here: a potentiated bouton plants a molecular tag that allows it to capture plasticity-related proteins drifting along the axon, effectively pulling resources away from untagged boutons. This means strong potentiation at one site can passively deplete neighboring sites — a form of competitive resource allocation baked into the axonal architecture. + +**In the postsynapse**, the dendrite hosts thousands of spines, and the situation is even more constrained. The soma produces plasticity-related proteins — new AMPA receptor subunits, CaMKII, scaffolding proteins like PSD-95 — at a rate determined by CREB-driven gene expression, and these proteins must be shipped out along the dendritic arbor to wherever they are needed. The same synaptic tagging logic applies on the postsynaptic side: a spine that has been tagged by early LTP can capture these drifting proteins when they pass, but the total production rate is finite. There is also a **spine morphology budget** — actin polymerization drives spine head enlargement, but the actin machinery and the small GTPases (Rac1, RhoA) that regulate it are shared across the dendritic segment. Potentiating many spines simultaneously on the same dendritic branch would require more actin remodeling machinery than is locally available, meaning strong potentiation at a cluster of nearby spines may physically constrain how much each individual spine can grow. + +Additionally, the postsynapse has a **receptor recycling pool** — a finite intracellular reserve of AMPA receptors held in endosomes near the spine that can be rapidly inserted during early LTP. This pool is local to a dendritic segment and is not immediately replenished. If multiple nearby spines are potentiated in rapid succession, they compete for the same local receptor reserve before new receptors synthesized in the soma can arrive. + +**In the astrocyte**, the budget constraint is the most spatially explicit of the three because a single astrocyte wraps somewhere between 100,000 and 2,000,000 synapses in humans — an enormous territory. Its finite resources include the total EAAT transporter protein available for glutamate clearance, the D-serine synthesis capacity which depends on serine racemase enzyme levels, the ECM protein production capacity for Glypicans and Thrombospondins, and critically the ATP budget for running all of these simultaneously. When many synapses in its territory are active simultaneously, the astrocyte faces a genuine allocation problem: it cannot maximally support all of them at once. There is evidence that the perisynaptic process — the fine astrocytic extension that wraps individual synapses — is itself a dynamic structure that the astrocyte extends and retracts selectively, suggesting it physically prioritizes which synapses receive close wrapping and therefore which ones benefit from tighter D-serine delivery and glutamate containment. + +**The deeper implication** is that potentiation is not just a local bilateral negotiation between one presynapse and one postsynapse. It is a **network-level resource competition** in which: + +A strongly potentiated synapse draws proteins and structural resources away from its neighbors on the same axon and dendrite. The astrocyte must allocate its clearance, co-agonist, and structural support capacity across its entire territory. The metabolic pipeline — glucose from blood vessels, lactate to neurons — has a ceiling determined by capillary supply, meaning a highly active region of the astrocyte territory can become fuel-limited if demand outpaces vascular supply. + +This is probably why **heterosynaptic LTD** exists — the observation that strong LTP at one synapse is often accompanied by spontaneous depression at neighboring synapses on the same dendrite even without those synapses being directly stimulated. It may be less a deliberate regulatory mechanism and more a direct consequence of resource depletion: the potentiated synapse captured the available receptors, actin machinery, and astrocytic support, leaving neighboring synapses passively impoverished. + +The pseudocode should therefore include a budget layer that sits above the individual synapse functions — something like a shared resource pool per axonal arbor, per dendritic segment, and per astrocyte territory, from which each commit function draws and against which each structural expansion is checked. Potentiation that would exceed the available budget either fails to consolidate fully, triggers compensatory depression at neighboring synapses, or waits for new protein synthesis to replenish the pool before completing. diff --git a/elements/neuron/appunti/old/2026-06-11-tripartite_synapse_v5.md b/elements/neuron/appunti/old/2026-06-11-tripartite_synapse_v5.md new file mode 100644 index 0000000..2e2ea72 --- /dev/null +++ b/elements/neuron/appunti/old/2026-06-11-tripartite_synapse_v5.md @@ -0,0 +1,1125 @@ +# Tripartite Synapse — Pseudocode v5 +Energy and material flows explicit. Variables aggregated to minimum set. + +--- + +## Part 1 — Conventions + +``` +SCOPE = { DAY, NIGHT } +CONTEXT = { AP, NOT_AP, bAP, NOT_bAP, CONTINUOUS } + +Variable types: + FIXED = externally imposed — does not change during simulation + VAR = changes dynamically + FAST_TRACE = accumulates and decays within DAY — never reaches NIGHT + role: biases next behavior within same context + TAG = set during DAY, decays slowly, survives to NIGHT + role: gates structural commit in NIGHT + for POST only: two phases — CANDIDATE (DAY) → STABLE (DAY) → NIGHT + BUDGET = single energy variable per compartment + all costs deducted here + MATERIAL = single structural resource variable per compartment + all material draws and returns here + STRUCTURE = slow architectural variable + READ during DAY, WRITTEN only in NIGHT +``` + +--- + +## Part 2 — Fixed Parameters + +``` +// Thresholds +FIXED Ca_TAG_threshold // Ca²⁺ level sufficient to set post CANDIDATE tag +FIXED Ca_HIGH // LTP-driving Ca²⁺ amplitude +FIXED Ca_LOW // LTD-driving Ca²⁺ amplitude +FIXED spillover_threshold // cleft saturation threshold for mGluR activation +FIXED eligibility_threshold // minimum fast_trace to be taggable (all components) +FIXED dopamine_threshold // minimum dopamine for tag stabilization +FIXED tagging_threshold // minimum possible_tagging for tag accumulation +FIXED tag_expiry_threshold // minimum tag to survive to NIGHT commit +FIXED homeostatic_ceiling // max soma firing rate before global downscale +FIXED disuse_threshold // silence duration before passive depotentiation +FIXED recycling_fraction // fraction of material recovered after LTD dismantling + +// External signals — organism level +FIXED dopamine_level // VTA broadcast — reward/save signal +FIXED NE_level // locus coeruleus — arousal/gain +FIXED ACh_level // basal forebrain — attention/threshold + +// Physical constraints +FIXED vascular_glucose_supply // hard energy ceiling — astrocyte root +FIXED branch_geometry // dendritic topology — affects bAP decay +FIXED Ca_cooperativity_n // Hill coefficient for Ca²⁺-driven NT release (~3-4) +FIXED Ca_half_max_K // half-maximal Ca²⁺ for NT release +``` + +--- + +## Part 3 — Energy and Material Declarations + +``` +// ── ENERGY: one budget per compartment ──────────────────────────────── + +VAR astro_budget // ROOT energy variable for synaptic operations + // SOURCE: vascular_glucose_supply → glycolysis + // COSTS: glutamate clearance (EAAT transport) + // D-serine synthesis (serine racemase) + // ECM secretion (Glypicans, Thrombospondins) + // process motility (cytoskeletal remodeling) + // lactate production (exported to pre, post, dend) + // (simplifies: astro_ATP_budget + all enzyme running costs) + +VAR astro_lactate // fuel exported by astrocyte → feeds pre, post, dend + // = min(glycolysis(vascular_glucose_supply), astro_budget × export_fraction) + // hard cap: vascular_glucose_supply (FIXED) + +VAR pre_budget // bouton energy + // SOURCE: astro_lactate (primary) — via perisynaptic delivery + // COSTS: VGCC opening + vesicle fusion + VATPase refill + // active zone maintenance + // (simplifies: bouton_ATP + VATPase_running_cost) + +VAR post_budget // spine energy + // SOURCE: astro_lactate (primary) — via perisynaptic delivery + // COSTS: NaK pump membrane reset + // AMPA receptor lateral diffusion + recycling + // actin remodeling for transient spine changes + // NMDA current handling + // (simplifies: spine_ATP + NaK_ATPase_cost + actin_cycling_cost) + +VAR dend_budget // branch energy + // SOURCE: astro_lactate (primary) + soma organelle delivery (minor) + // COSTS: bAP propagation along branch + // local mRNA translation + // protein and organelle transport to spines + // branch calcium handling + // (simplifies: dend_mitochondria_ATP + local_translation_cost) + +VAR soma_budget // somatic energy + // SOURCE: own mitochondria (self-fueled — not from astrocyte) + // COSTS: AP generation (Na⁺/K⁺ currents) + // CREB transcription + // protein synthesis machinery + // organelle biogenesis + // shipping to dend and axon + // (simplifies: soma_ATP + synthesis_running_cost) + +VAR axon_budget // axonal energy + // SOURCE: soma_budget (primary) + astro_lactate along shaft (minor) + // COSTS: AP propagation at each node of Ranvier + // anterograde motor protein transport + // myelin maintenance + // (simplifies: axon_ATP + transport_running_cost) + +// ── MATERIAL: one material variable per compartment ─────────────────── + +VAR astro_material // astrosynaptic structural components + // SOURCE: astrocyte cell body synthesis + // CONTAINS: EAAT transporter proteins + // serine racemase enzyme + // ECM proteins (Glypicans, Thrombospondins) + // process cytoskeleton components + // D-serine precursor (serine) + // COSTS: drawn by DAY D-serine release (serine consumed) + // drawn by NIGHT ECM secretion and process remodeling + // (simplifies: astro_ECM_pool + racemase_cap + EAAT_pool + // + process_extensions + D_serine_precursor) + +VAR pre_material // presynaptic bouton structural components + // SOURCE: soma_material via axon transport (anterograde) + // CONTAINS: RIM, Munc13 (AZ scaffold) + // VGCC subunits + // vesicle membrane proteins + // synaptotagmin, SNARE proteins + // COSTS: drawn by NIGHT active zone expansion + // RETURNS: to shared axonal pool after LTD dismantling + // (simplifies: axon_vesicle_protein_pool + AZ_scaffold_proteins) + +VAR post_material // postsynaptic spine structural components + // SOURCE: dend_material (branch local pool + soma delivery) + // CONTAINS: AMPA receptor subunits (GluA1, GluA2) + // PSD scaffold proteins (PSD-95, SHANK) + // actin monomers + polymerization machinery + // CaMKII + // COSTS: drawn by NIGHT receptor anchoring + spine enlargement + // RETURNS: to branch pool after LTD internalization + // (simplifies: dend_receptor_reserve + dend_actin_machinery + // + PSD_scaffold_pool) + +VAR dend_material // dendritic branch structural and supply components + // SOURCE: soma_material (shipped during DAY NOT_AP + NIGHT) + // CONTAINS: plasticity proteins (Arc, Homer) + // mRNA pool (Arc mRNA, BDNF mRNA) + // AMPA receptor subunits (in transit to spines) + // organelles (mitochondria for local energy) + // COSTS: drawn by local translation (mRNA consumed) + // drawn by spine delivery (post_material replenishment) + // drawn by NIGHT branch structural expansion + // (simplifies: dend_protein_flux + dend_mRNA_pool + // + dend_organelle_store) + +VAR soma_material // somatic production output + // SOURCE: CREB-driven synthesis (own ribosomes + nucleus) + // CONTAINS: all structural proteins for downstream compartments + // mRNA transcripts (Arc, BDNF, receptor subunits) + // organelles (mitochondria, ribosomes) + // COSTS: shipped to dend_material during DAY NOT_AP + NIGHT + // shipped to axon for pre_material replenishment + // depleted by soma's own NIGHT structural commit + // (simplifies: soma_protein_synthesis_rate + soma_organelle_pool + // + soma_receptor_synthesis_rate + mRNA_transcription) + +VAR axon_material // axonal transport and structural components + // SOURCE: soma_material (motor proteins, myelin components) + // CONTAINS: kinesin/dynein motor proteins + // microtubule components + // myelin maintenance proteins + // COSTS: drawn by NIGHT axon structural expansion + // consumed continuously by anterograde transport + // (simplifies: transport_machinery + myelination_proteins) +``` + +--- + +## Part 4 — Structural Variables (Written Only in NIGHT) + +``` +VAR pre_structure // active zone capacity + // RRP_capacity ∝ pre_structure + // VGCC_coupling ∝ pre_structure + // refill_ceiling ∝ pre_structure + // (simplifies: active_zone_size + VGCC_clustering + RRP_pool_capacity) + +VAR post_structure // spine sensitivity capacity + // anchoring_slots ∝ post_structure + // spine_volume ∝ post_structure + // local_reserve ∝ post_structure + // (simplifies: AMPA_count_ceiling + spine_volume + receptor_reserve_ceiling) + +VAR dend_structure // branch transmission and supply capacity + // bAP_fidelity ∝ dend_structure × attenuation(position) + // translation_ceiling ∝ dend_structure + // transport_speed ∝ dend_structure + // (simplifies: mitochondria_density + cytoskeletal_integrity + // + mRNA_pool_ceiling) + +VAR soma_structure // somatic output and production capacity + // baseline_threshold ∝ 1/soma_structure + // AP_reliability ∝ soma_structure + // synthesis_ceiling ∝ soma_structure + // (simplifies: ion_channel_density + ribosome_density + // + CREB_machinery) + +VAR axon_structure // axonal transmission and transport capacity + // propagation_reliability ∝ axon_structure + // transport_rate ∝ axon_structure + // (simplifies: myelination_density + transport_machinery_capacity + // + axonal_mitochondria_density) + +VAR astro_structure // astrosynaptic environmental capacity + // perisynaptic_distance ∝ 1/astro_structure + // EAAT_density ∝ astro_structure + // D_serine_tonic ∝ astro_structure + // ECM_integrity ∝ astro_structure + // SELF-REINFORCING in both directions: + // LTP → astro_structure ↑ → signal more contained, + // D-serine tonic ↑ → future LTP easier + // LTD → astro_structure ↓ → signal dilutes, + // D-serine tonic = 0 → future LTD easier + // (simplifies: perisynaptic_distance + ECM_integrity + // + D_serine_tonic_level + EAAT_density) +``` + +--- + +## Part 5 — Trace Variables + +``` +// ── Fast traces: DAY only, decay automatically ──────────────────────── + +FAST_TRACE pre_fast_trace + // += spike_Ca_influx() on each AP + // *= decay(τ ≈ 100ms) + // role: (1) biases NT flux in next AP context (residual Ca²⁺) + // (2) eligibility condition for pre_possible_tagging + // energy: no direct cost — Ca²⁺ dynamics are passive + // material: no direct cost + +FAST_TRACE post_fast_trace + // += NMDA_Ca_influx × rise_speed() in NOT_bAP context + // += bAP_Ca_boost() if CANDIDATE tag confirmed in bAP context + // *= decay(τ ≈ tens of ms) + // role: (1) encodes LTP vs LTD instruction (amplitude × speed) + // (2) eligibility condition for post CANDIDATE tag + // energy cost: post_budget -= NMDA_current_cost + // material: no direct cost + +FAST_TRACE dend_fast_trace + // += bAP_Ca_influx() + spine_Ca_spillover() + // *= decay(τ ≈ 300ms) + // role: (1) integrates branch co-activity + // (2) eligibility for dend_possible_tagging + // (3) gates local translation rate when dend_tag set + // energy cost: dend_budget -= branch_Ca_handling_cost + // material: no direct cost + +FAST_TRACE soma_fast_trace + // += nuclear_Ca_influx() on each somatic AP + // *= decay(τ ≈ seconds) + // role: (1) adaptation — raises AP_threshold with recent firing + // (2) eligibility condition for soma CREB gate + // energy cost: soma_budget -= AP_generation_cost + // material: no direct cost + +FAST_TRACE axon_fast_trace + // += AP_propagation_load(input_freq) on each AP + // *= decay(τ ≈ seconds) + // role: (1) drives propagation failure at branch points under high freq + // (2) eligibility for axon_possible_tagging + // energy cost: axon_budget -= AP_propagation_cost + // material: no direct cost + +FAST_TRACE astro_fast_trace + // += mGluR5_Ca_influx() when glutamate > spillover_threshold + // *= decay(τ ≈ seconds) + // role: (1) drives D-serine release proportional to magnitude + // (2) eligibility for astro_possible_tagging + // (3) triggers global lockdown when > OVERLOAD_threshold + // energy cost: astro_budget -= D_serine_synthesis_cost + // material cost: astro_material -= D_serine_precursor_cost + +// ── Possible tagging: intermediate, decays over seconds–minutes ─────── + +VAR pre_possible_tagging // += pre_fast_trace when > eligibility_threshold + // *= decay(τ ≈ seconds) +VAR post_possible_tagging // += post_fast_trace when > Ca_TAG_threshold (bAP confirmed) + // *= decay(τ ≈ minutes) — CANDIDATE lifetime +VAR dend_possible_tagging // += dend_fast_trace when > eligibility_threshold + // *= decay(τ ≈ seconds–minutes) +VAR soma_possible_tagging // += soma_fast_trace when > eligibility_threshold + // *= decay(τ ≈ seconds–minutes) +VAR axon_possible_tagging // += axon_fast_trace when > eligibility_threshold + // *= decay(τ ≈ seconds–minutes) +VAR astro_possible_tagging // += astro_fast_trace when > eligibility_threshold + // *= decay(τ ≈ seconds–minutes) + +// ── Tags: slow, DAY→NIGHT bridge ────────────────────────────────────── + +TAG pre_tag // += dopamine × pre_possible_tagging when both > threshold + // *= decay(τ ≈ hours) — survives to NIGHT + // gates: pre_structure expansion in NIGHT + // energy cost: none — tag is a molecular state, not a process + +TAG post_tag // TWO-PHASE for POST only: + // CANDIDATE phase: + // set when post_fast_trace > Ca_TAG_threshold AND bAP confirmed + // decays within minutes if dopamine does not arrive + // STABLE phase: + // += dopamine × post_possible_tagging when both > threshold + // *= decay(τ ≈ hours) — survives to NIGHT + // gates: post_structure expansion in NIGHT + // energy cost: post_budget -= PKA_phosphorylation_cost (minor) + // material cost: none + +TAG dend_tag // += dopamine × dend_possible_tagging when both > threshold + // *= decay(τ ≈ hours) + // gates: dend_structure expansion + local translation activation in NIGHT + // energy cost: none + +TAG soma_tag // += dopamine × soma_possible_tagging when both > threshold + // *= decay(τ ≈ hours) + // gates: soma_structure expansion + protein synthesis peak in NIGHT + // energy cost: soma_budget -= CREB_phosphorylation_cost (minor) + // material cost: none + +TAG axon_tag // += dopamine × axon_possible_tagging when both > threshold + // *= decay(τ ≈ hours) + // gates: axon_structure expansion in NIGHT + // energy cost: none + +TAG astro_tag // += dopamine × astro_possible_tagging when both > threshold + // *= decay(τ ≈ hours) + // gates: astro_structure expansion (process retraction + ECM sealing) in NIGHT + // energy cost: none +``` + +--- +--- + +# SCOPE: DAY +Budgets consumed. Fast traces written and decay. Tags set but not cleared. +Structures READ only. + +--- + +## PRE | CONTEXT: AP + +``` +scope DAY | context AP: + + // Energy gate — release requires ATP + if pre_budget < AP_release_cost: + suppress(NT_flux) + exit context + // biological basis: ATP depletion → VGCC cannot open reliably + + // Fast trace: residual Ca²⁺ deposit + pre_fast_trace += spike_Ca_influx(input_freq) + pre_fast_trace *= decay(τ = 100ms) + pre_budget -= Ca_handling_cost + // biological basis: Ca²⁺ enters via VGCCs, pumped out by PMCA/NCX + + // NT flux: continuous release while RRP has content + // Ca_drive: Hill function — cooperative Ca²⁺ dependence of synaptotagmin + 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 // proportional to pool × Ca²⁺ + glutamate += NT_flux × Δt // cleft concentration rises + RRP_level -= NT_flux × Δt // pool depletes + pre_budget -= NT_flux × vesicle_fusion_cost // ATP per vesicle equivalent + // biological basis: SNARE-mediated vesicle fusion, each event costs ATP + + // RRP refill from reserve — rate limited by pre_budget and pre_structure + 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 + // biological basis: VATPase pumps refill vesicles with NT, costs ATP + + // Overflow brake — mGluR2/3 Gi-mediated autoinhibition + if glutamate > spillover_threshold: + Ca_drive *= mGluR_brake_factor + // biological basis: extrasynaptic glu activates mGluR2/3 → Gi → + // adenylyl cyclase ↓ → cAMP ↓ → VGCC opening ↓ + + // Refuel from astrocyte lactate + pre_budget += astro_lactate × pre_fraction + // biological basis: lactate → pyruvate → TCA → ATP via bouton mitochondria +``` + +## PRE | 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 + + // 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) + // biological basis: dopamine reuptake by DAT, enzymatic degradation (MAO, COMT) + + // Tag: set only when BOTH 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) + // biological basis: PKA phosphorylation of AZ proteins stabilizes tag + // requires both residual Ca²⁺ eligibility AND dopamine-driven PKA +``` + +--- + +## POST | CONTEXT: NOT_bAP + +``` +scope DAY | context NOT_bAP: + + // AMPA current — gated by post_structure (READ) + // Occupancy: transient receptor insertion/removal from existing slots + AMPA_current = glutamate × post_structure.sensitivity + Vm += AMPA_current + post_budget -= AMPA_current_cost + // biological basis: AMPA receptor opening → Na⁺ influx → NaK pump cost + + // NMDA gate: three-way coincidence + // (1) sufficient depolarization (Mg²⁺ block ejected) + // (2) D-serine from astrosynapse (co-agonist present) + // (3) glutamate bound + 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 + // biological basis: NMDA Ca²⁺ influx → CaMKII vs PP1 competition + // fast rise → CaMKII wins → LTP instruction + // slow rise → PP1 wins → LTD instruction + + // CANDIDATE tag: set when Ca²⁺ crossed tagging threshold + // This is the Hebbian anticipation — before bAP confirms + if post_fast_trace > Ca_TAG_threshold: + post_possible_tagging += post_fast_trace // graded — higher Ca²⁺ → more contribution + post_possible_tagging *= decay(τ = minutes) // CANDIDATE lifetime — minutes + // biological basis: early CaMKII activation creates labile tag + // decays via phosphatase activity if not stabilized + + // Fast trace decays + post_fast_trace *= decay(τ = tens_of_ms) + + // Refuel + post_budget += astro_lactate × post_fraction +``` + +## POST | 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 + // biological basis: bAP Ca²⁺ entry via VDCCs in spine, NaK reset costs ATP + + // Coincidence confirmation: bAP finds CANDIDATE already set + if post_possible_tagging > Ca_TAG_threshold: + post_fast_trace += bAP_Ca_boost() // trace amplified above Ca_HIGH + // biological basis: bAP + prior NMDA Ca²⁺ → supralinear Ca²⁺ summation + // this is the Hebbian coincidence — forward + backward signals + + // else: bAP arrives but spine was not active — no amplification, no tag + + // Dopamine decays locally + dopamine_local *= decay(τ = hundreds_of_ms) + + // STABLE tag: CANDIDATE stabilized by dopamine within window + if dopamine_local > dopamine_threshold and + post_possible_tagging > tagging_threshold: + post_tag += dopamine_local × post_possible_tagging + post_tag *= decay(τ = hours) + post_budget -= PKA_phosphorylation_cost // minor ATP cost for PKA activity + // biological basis: dopamine → D1R → PKA → GluA1-Ser845 phosphorylation + // PKA also phosphorylates DARPP-32 → inhibits PP1 + // stabilizes tag against phosphatase-driven decay +``` + +--- + +## DEND | CONTEXT: CONTINUOUS + +``` +scope DAY | context CONTINUOUS: + + // Integrate spines upward toward soma + branch_Vm = integrate(POST.Vm, all_spines_on_branch) + + // Propagate bAP downward — fidelity set by dend_structure (READ) + bAP_local = propagate_bAP(SOMA.AP_fired, + dend_structure.bAP_fidelity, + branch_geometry) + dend_budget -= bAP_propagation_cost + // biological basis: bAP propagation requires Na⁺ channel re-activation + // costs ATP via NaK reset along branch length + + // Fast trace: branch Ca²⁺ from bAP + spine spillover + 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 + // biological basis: Ca²⁺ enters via VDCCs along branch, + // SERCA pump re-sequestration costs ATP + + // Possible tagging: branch co-activity threshold + 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_material.mRNA_pool, + dend_fast_trace) // rate ∝ fast trace + dend_material.mRNA_pool -= local_proteins × mRNA_cost + post_material += local_proteins × delivery_fraction + dend_budget -= translation_cost + // biological basis: Arc mRNA + polyribosomes at branch + // fast local protein supply for early structural changes + // no soma wait required + + // ACh modulates commit threshold globally + commit_threshold *= (1 / (1 + ACh_level × ACh_gain)) + + // Branch maintenance cost + dend_budget -= branch_maintenance_cost + dend_budget += astro_lactate × dend_fraction + // material: replenished by soma shipping during NOT_AP +``` + +--- + +## SOMA | CONTEXT: AP + +``` +scope DAY | context AP: + + // Integrate — fires when branch inputs cross threshold + // Threshold modulated by fast trace (adaptation) and neuromodulators + AP_threshold = soma_structure.baseline_threshold + × (1 + adaptation_factor(soma_fast_trace)) // rises with recent firing + × neuromod_factor(NE_level, ACh_level) // NE lowers, ACh sharpens + × refractory_factor(time_since_last_AP) // hard block then graded recovery + + if branch_Vm > AP_threshold: + AP_fired = True + soma_budget -= AP_generation_cost + // biological basis: Na⁺/K⁺ currents for AP, NaK pump reset + + // Fast trace: nuclear Ca²⁺ accumulation + soma_fast_trace += nuclear_Ca_influx() + soma_fast_trace *= decay(τ = seconds) + // biological basis: L-type VGCC → nuclear Ca²⁺ → CaM kinase nuclear activation + + // Refractory period + refractory_timer = absolute_refractory_duration // ~2ms hard block + + // 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 + // biological basis: nuclear Ca²⁺ + PKA → CREB phosphorylation + // requires both activity (Ca²⁺) AND reward (dopamine/PKA) +``` + +## SOMA | CONTEXT: NOT_AP + +``` +scope DAY | context NOT_AP: + + // Integrate dendritic inputs + branch_Vm = integrate(DEND.branch_Vm, all_branches) + + // Refractory timer counts down + refractory_timer = max(0, refractory_timer - Δt) + + // Fast trace decays — threshold returning to baseline + soma_fast_trace *= decay(τ = seconds) + + // Ship material to tagged branches — priority by tag magnitude + for branch in branches_ranked_by(dend_tag): + delivery = min(shipping_fraction × soma_material, + soma_budget × shipping_cost_fraction) + dend_material[branch] += delivery + soma_material -= delivery + soma_budget -= shipping_cost + // biological basis: kinesin-driven anterograde transport of mRNA + proteins + // tagged branches receive priority allocation + + // Ship material to axon for bouton replenishment + axon_delivery = min(axon_shipping_fraction × soma_material, + soma_budget × axon_shipping_cost_fraction) + axon_material += axon_delivery + soma_material -= axon_delivery + soma_budget -= axon_shipping_cost + // biological basis: slow axonal transport — days to reach distal boutons + + // Neuromodulator context: PKA broadcast amplifies all tagged component traces + if dopamine_level > dopamine_threshold or NE_level > NE_threshold: + for each component where possible_tagging > tagging_threshold: + tag += dopamine_level × possible_tagging × PKA_amplifier + // biological basis: dopamine → cAMP → PKA → phosphorylates targets + // throughout neuron simultaneously +``` + +--- + +## AXON | CONTEXT: CONTINUOUS + +``` +scope DAY | context CONTINUOUS: + + // AP propagation — reliability set by axon_structure (READ) + propagation_reliability = axon_structure.myelination + × (1 - failure_rate(axon_fast_trace)) + // biological basis: high axon_fast_trace → Na⁺ channel inactivation at branch points + // → some APs fail to reach distal boutons + // → this is axonal STD (frequency-dependent filtering) + + APs_delivered = AP_fired × propagation_reliability + axon_budget -= AP_propagation_cost × APs_delivered + + // Fast trace: propagation load + axon_fast_trace += APs_delivered + axon_fast_trace *= decay(τ = seconds) + + // Anterograde transport — delivers pre_material to boutons + transport_rate = min(axon_structure.transport_capacity, + axon_budget × transport_fraction) + pre_material += transport_rate × Δt // boutons receive material + axon_material -= transport_rate × Δt // axon pool depletes + axon_budget -= transport_cost × transport_rate × Δt + // biological basis: kinesin moves cargo at ~1μm/s along microtubules + // costs ATP per step (kinesin ATPase) + + // Possible tagging + if axon_fast_trace > eligibility_threshold: + axon_possible_tagging += axon_fast_trace + axon_possible_tagging *= decay(τ = seconds) + + // Dopamine decays + dopamine_local *= decay(τ = hundreds_of_ms) + + // Tag + if dopamine_local > dopamine_threshold and + axon_possible_tagging > tagging_threshold: + axon_tag += dopamine_local × axon_possible_tagging + axon_tag *= decay(τ = hours) + + // Refuel from soma budget + local astrocyte + axon_budget += soma_budget × axon_fuel_fraction + axon_budget += astro_lactate × axon_astro_fraction + // biological basis: soma mitochondria supply axon proximally + // local astrocytes supply along shaft distally +``` + +--- + +## ASTRO | CONTEXT: CONTINUOUS + +``` +scope DAY | context CONTINUOUS: + + // ROOT energy production: glycolysis from vascular glucose + astro_budget += glycolysis(vascular_glucose_supply) × Δt + // hard cap: vascular_glucose_supply (FIXED) — cannot be exceeded + // biological basis: glucose → lactate via glycolysis in astrocyte cytoplasm + + // Lactate export to neuronal compartments + astro_lactate = min(astro_budget × lactate_export_fraction, + vascular_glucose_supply × max_export_fraction) + astro_budget -= astro_lactate + deliver(astro_lactate → pre_budget × pre_fraction, + post_budget × post_fraction, + dend_budget × dend_fraction, + axon_budget × axon_fraction) + // biological basis: lactate released into ECS → absorbed by MCT2 on neurons + // neurons convert lactate → pyruvate → TCA → ATP + + // Glutamate clearance — rate set by astro_structure (READ) + clearance = astro_structure.EAAT_density × glutamate × Δt + glutamate -= clearance + astro_budget -= clearance × EAAT_ATP_cost + // biological basis: EAAT cotransports 3 Na⁺ per glutamate → NaK pump cost + + // Overflow detection and D-serine release + if glutamate > spillover_threshold: + astro_fast_trace += mGluR5_Ca_influx() + // biological basis: spillover activates mGluR5 → Gq → PLC → IP3 + // → Ca²⁺ release from ER → Ca²⁺-dependent exocytosis + + // D-serine release: proportional to fast trace, material + budget limited + D_serine_released = min(proportional_to(astro_fast_trace), + astro_material.D_serine_precursor, + astro_budget × Ds_fraction) + astro_material -= D_serine_released × precursor_cost + astro_budget -= D_serine_released × synthesis_cost + astro_D_serine += D_serine_released + // biological basis: serine racemase converts L-serine → D-serine + // costs ATP, consumes serine from astro_material + + // Simultaneous presynaptic brake (cross-compartment, no astro budget cost) + Ca_drive_pre *= mGluR_brake_factor + // biological basis: spillover also activates mGluR2/3 on PRE → Gi → + // suppresses VGCC — brakes release at source + + // 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) + + astro_fast_trace *= decay(τ = seconds) + + // Global overload: circuit breaker + if astro_fast_trace > OVERLOAD_threshold: + trigger(shockwave_lockdown) + // biological basis: global Ca²⁺ wave → GABA + ATP release + // mass AMPA internalization, hyperpolarization + + // Tonic D-serine baseline — set by astro_structure (READ) + astro_D_serine += astro_structure.D_serine_tonic × Δt + astro_budget -= astro_structure.D_serine_tonic × tonic_synthesis_cost + astro_material -= astro_structure.D_serine_tonic × tonic_precursor_cost + // biological basis: constitutive racemase activity maintains baseline + // D-serine availability independent of overflow events +``` + +--- + +## Special Case — Shockwave Lockdown (any scope) + +``` +scope DAY or NIGHT | context OVERLOAD: + + // Emergency — bypasses budget gates + // Biological basis: global astrocytic Ca²⁺ wave → + // GABA release → hyperpolarization + // ATP release → purinergic inhibition + post_fast_trace = 0 + Vm = HYPERPOLARIZED + AMPA_occupancy = mass_internalization() // returned to post_material reserve + post_material += recovered_AMPA + axon_fast_trace += overdrive_cluster() // VGCC clustering beneath AZ + astro_budget -= emergency_cost // large deduction — territory depleted +``` + +--- +--- + +# SCOPE: NIGHT +Structural variables WRITTEN. Budgets replenished. Tags evaluated and cleared. + +--- + +## Step 1 — Replenish Budgets and Material + +``` +scope NIGHT | step 1: + + // Astrocyte replenishes first — it fuels everything + astro_budget += overnight_glycolysis(vascular_glucose_supply) × Δt_night + astro_material += astrocyte_cellbody_synthesis() × Δt_night + // biological basis: astrocyte protein synthesis overnight + // replenishes EAAT, racemase, ECM proteins, process cytoskeleton + + // Soma replenishes from own mitochondria — self-fueled + soma_budget += overnight_mitochondria_output() × Δt_night + + // Soma material production peaks in NIGHT — driven by soma_tag magnitude + soma_material += CREB_driven_synthesis(soma_tag) × Δt_night + // biological basis: CREB → Arc, BDNF, GluA1, scaffold proteins + // peaks during slow-wave sleep replay + + // Soma ships material to downstream compartments + dend_material += soma_material × dend_delivery_fraction + axon_material += soma_material × axon_delivery_fraction + soma_material -= (dend_delivery_fraction + axon_delivery_fraction) × soma_material + + // Downstream budgets refilled from soma and astrocyte + dend_budget += astro_lactate × dend_fraction + + soma_budget × soma_to_dend_fraction + pre_budget += astro_lactate × pre_fraction + post_budget += astro_lactate × post_fraction + axon_budget += soma_budget × soma_to_axon_fraction + + astro_lactate × axon_fraction +``` + +--- + +## Step 2 — Structural Commits (Parallel, Independent per Compartment) + +``` +scope NIGHT | step 2: + + // Each compartment commits independently based on its own tag + // No global AND gate — coherence emerges from shared DAY events + // COHERENCE BONUS: if all tags SET simultaneously → amplified commit + all_aligned = (pre_tag > tag_expiry_threshold and + post_tag > tag_expiry_threshold and + astro_tag > tag_expiry_threshold) + coherence_bonus = all_aligned ? coherence_factor : 1.0 + + // ── PRE COMMIT ────────────────────────────────────────────────────── + if pre_tag > tag_expiry_threshold: + Δpre = min(AZ_expansion_cost, + pre_material, + pre_budget × pre_structural_fraction) + pre_structure += Δpre × coherence_bonus // STRUCTURE WRITTEN + pre_material -= Δpre // material consumed + pre_budget -= Δpre × structural_ATP_cost + if Δpre < AZ_expansion_cost: + queue(pre_deficit → next NIGHT) // deficit deferred + // biological basis: RIM + Munc13 incorporation → new docking slots + // VGCC clustering → tighter Ca²⁺-release coupling + // LTD: passive decay if maintenance not met (see step 3) + + // ── POST COMMIT ───────────────────────────────────────────────────── + if post_tag > tag_expiry_threshold: + Δpost = min(AMPA_insertion_cost, + post_material, + post_budget × post_structural_fraction) + post_structure += Δpost × coherence_bonus // STRUCTURE WRITTEN + post_material -= Δpost // material consumed + post_budget -= Δpost × structural_ATP_cost + if Δpost < AMPA_insertion_cost: + queue(post_deficit → next NIGHT) + // biological basis: CaMKII anchors AMPA receptors into PSD scaffold + // actin polymerization enlarges spine head + // new anchoring slots created — not just slots filled + + // ── DEND COMMIT ───────────────────────────────────────────────────── + if dend_tag > tag_expiry_threshold: + Δdend = min(branch_expansion_cost, + dend_material, + dend_budget × dend_structural_fraction) + dend_structure += Δdend × coherence_bonus // STRUCTURE WRITTEN + dend_material -= Δdend + dend_budget -= Δdend × structural_ATP_cost + if Δdend < branch_expansion_cost: + queue(dend_deficit → next NIGHT) + // biological basis: mitochondria incorporation → local ATP ceiling raised + // cytoskeletal reinforcement → better bAP propagation + // mRNA pool expanded → more local translation capacity + + // ── SOMA COMMIT ───────────────────────────────────────────────────── + if soma_tag > tag_expiry_threshold: + Δsoma = min(soma_expansion_cost, + soma_material, + soma_budget × soma_structural_fraction) + soma_structure += Δsoma // STRUCTURE WRITTEN + soma_material -= Δsoma + soma_budget -= Δsoma × structural_ATP_cost + // biological basis: ion channel density increase at axon initial segment + // ribosome biogenesis → synthesis ceiling raised + // CREB machinery expansion + + // ── AXON COMMIT ───────────────────────────────────────────────────── + if axon_tag > tag_expiry_threshold: + Δaxon = min(axon_expansion_cost, + axon_material, + axon_budget × axon_structural_fraction) + axon_structure += Δaxon // STRUCTURE WRITTEN + axon_material -= Δaxon + axon_budget -= Δaxon × structural_ATP_cost + if Δaxon < axon_expansion_cost: + queue(axon_deficit → next NIGHT) + // biological basis: myelination density increase + // motor protein pool expansion + // microtubule stabilization + + // ── ASTRO COMMIT ──────────────────────────────────────────────────── + if astro_tag > tag_expiry_threshold: + Δastro = min(process_retraction_cost, + astro_material, + astro_budget × astro_structural_fraction) + astro_structure += Δastro × coherence_bonus // STRUCTURE WRITTEN + astro_material -= Δastro // ECM proteins + cytoskeleton consumed + astro_budget -= Δastro × structural_ATP_cost + if Δastro < process_retraction_cost: + queue(astro_deficit → next NIGHT) + // biological basis: process retraction → perisynaptic_distance ↓ + // ECM secretion (Glypicans, Thrombospondins) → cleft sealed + // racemase upregulation → D_serine_tonic ↑ + // EAAT density increase → clearance ceiling ↑ + // SELF-REINFORCING: astro_structure ↑ → future signals more contained + // → future D-serine higher + // → future LTP easier +``` + +--- + +## Step 3 — Passive Depotentiation (Resource Conservation) + +``` +scope NIGHT | step 3: + + // Potentiation is the primary drive. + // Depotentiation is its shadow — a consequence of finite resources. + // Structures decay at a baseline rate. + // Decay is overcome only if maintenance allocation is sufficient. + // Maintenance draws from what remains AFTER potentiation has taken its share. + + remaining_material = total_material - material_consumed_by_potentiation + remaining_budget = total_budget - budget_consumed_by_potentiation + + maintenance_per_synapse = remaining_material / total_synapse_count + + for each synapse: + // Structural decay — passive, continuous + pre_structure -= structural_decay_rate × Δt_night + post_structure -= structural_decay_rate × Δt_night + dend_structure -= structural_decay_rate × Δt_night + astro_structure -= structural_decay_rate × Δt_night + + // Maintenance allocation — overcomes decay if resources available + if maintenance_per_synapse >= maintenance_cost: + pre_structure += maintenance_pre + post_structure += maintenance_post + dend_structure += maintenance_dend + astro_structure += maintenance_astro + // decay fully compensated — structure stable + + else: + // maintenance_per_synapse < maintenance_cost + // partial compensation only — structure drifts downward + // THIS IS DEPOTENTIATION BY NEGLECT — no active signal required + // the synapse is not told to weaken + // it simply does not receive enough to stay where it is + pre_structure += maintenance_per_synapse × pre_fraction + post_structure += maintenance_per_synapse × post_fraction + // net: structure slowly declines toward lower baseline + + // LTD material recovery: dismantled proteins returned to pools + // This enriches the remaining pool and partially benefits other synapses + for each synapse where net_structure_change < 0: + recovered = structure_loss × recycling_fraction + pre_material += recovered × pre_fraction + post_material += recovered × post_fraction + astro_material += recovered × astro_fraction × recycling_fraction + // biological basis: ubiquitin-proteasome degradation → amino acids recycled + // internalized receptors → endosomal reserve + // dismantled AZ proteins → axonal pool +``` + +--- + +## Step 4 — Homeostatic Scaling + +``` +scope NIGHT | step 4: + + // If soma fired too much overall during DAY — global downscale + 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 + // biological basis: global AMPA downscaling during sleep + // relative differences preserved — absolute excitability restored + // material recovery: scaled-down proteins returned to soma_material + soma_material += sum(structure_reduction) × recycling_fraction +``` + +--- + +## Step 5 — Clear All Traces + +``` +scope NIGHT | step 5: + + // FAST_TRACEs: already decayed during DAY — confirm zero + pre_fast_trace = 0 + post_fast_trace = 0 + dend_fast_trace = 0 + soma_fast_trace = 0 + axon_fast_trace = 0 + astro_fast_trace = 0 + + // POSSIBLE_TAGGING: decayed during DAY — confirm zero + pre_possible_tagging = 0 + post_possible_tagging = 0 + dend_possible_tagging = 0 + soma_possible_tagging = 0 + axon_possible_tagging = 0 + astro_possible_tagging = 0 + + // TAGS: explicitly cleared after commit + // Tags above expiry threshold carry forward to next NIGHT (multi-night consolidation) + 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 + // Tags above threshold: partial commit ran, deficit queued, + // remaining tag persists to next NIGHT for completion +``` + +--- + +## Summary of Energy and Material Relations + +``` +ENERGY FLOW: + vascular_glucose_supply (FIXED) + → astro_budget (glycolysis) + → astro_lactate → pre_budget, post_budget, dend_budget, axon_budget + → soma_budget (own mitochondria — independent of astrocyte) + → axon_budget (partial) + → dend_budget (partial, via organelle delivery) + +MATERIAL FLOW: + soma (CREB synthesis) + → soma_material + → dend_material (shipping during DAY NOT_AP + NIGHT) + → post_material (local delivery to spines) + → axon_material (shipping during DAY NOT_AP + NIGHT) + → pre_material (anterograde transport to boutons) + astrocyte cell body (local synthesis) + → astro_material + → D-serine (consumed in DAY) + → ECM proteins (consumed in NIGHT) + → process cytoskeleton (consumed in NIGHT) + +RECOVERY FLOWS (LTD → returns material to pools): + post LTD → AMPA receptors → post_material (local reserve) + pre LTD → AZ proteins → pre_material (axonal pool) + astro LTD → ECM fragments → astro_material (partial, recycling_fraction) +``` + +# Flows + +## 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) +``` diff --git a/elements/neuron/appunti/old/2026-06-11-tripartite_synapse_v6.md b/elements/neuron/appunti/old/2026-06-11-tripartite_synapse_v6.md new file mode 100644 index 0000000..5f474b4 --- /dev/null +++ b/elements/neuron/appunti/old/2026-06-11-tripartite_synapse_v6.md @@ -0,0 +1,1036 @@ +--- +include_toc: true +--- + +# Tripartite Synapse — Pseudocode v6 +Naming convention: + DAY: {component}_budget = combined fast energy + fast consumable materials + NIGHT: {component}_energy = ATP for structural assembly + {component}_material = slow structural proteins (recoverable after LTD) + +## Part 1 — Conventions + +``` +SCOPE = { DAY, NIGHT } +CONTEXT = { AP, NOT_AP, bAP, NOT_bAP, CONTINUOUS } + +Variable types: + FIXED = externally imposed — does not change during simulation + VAR = changes dynamically + FAST_TRACE = accumulates and decays within DAY — never reaches NIGHT + role: biases next behavior within same context + TAG = set during DAY, decays slowly, survives to NIGHT + POST only: CANDIDATE (DAY) → STABLE (DAY) → commit (NIGHT) + BUDGET = DAY only: combined fast energy + fast consumable materials + one variable per component + replenished continuously during DAY + ENERGY = NIGHT only: ATP cost of structural assembly + replenished overnight + NOT recoverable after LTD + MATERIAL = NIGHT only: slow structural proteins + replenished by CREB synthesis + transport (hours–days) + RECOVERABLE after LTD — returns to shared pools + STRUCTURE = slow architectural variable + READ during DAY, WRITTEN only in NIGHT +``` + +## Part 2 — Fixed Parameters + +``` +// Thresholds +FIXED Ca_TAG_threshold // Ca²⁺ sufficient to set post CANDIDATE tag +FIXED Ca_HIGH // LTP-driving Ca²⁺ amplitude +FIXED Ca_LOW // LTD-driving Ca²⁺ amplitude +FIXED spillover_threshold // cleft saturation for mGluR activation +FIXED eligibility_threshold // minimum fast_trace to be taggable +FIXED dopamine_threshold // minimum dopamine for tag stabilization +FIXED tagging_threshold // minimum possible_tagging for tag accumulation +FIXED tag_expiry_threshold // minimum tag to survive to NIGHT commit +FIXED homeostatic_ceiling // max soma firing before global downscale +FIXED disuse_threshold // silence duration before passive depotentiation +FIXED recycling_fraction // fraction of material recovered after LTD + +// Organism-level signals +FIXED dopamine_level // VTA broadcast — reward/save signal +FIXED NE_level // locus coeruleus — arousal/gain +FIXED ACh_level // basal forebrain — attention/threshold + +// Physical constraints +FIXED vascular_glucose_supply // hard energy ceiling — astrocyte root +FIXED branch_geometry // dendritic topology — affects bAP decay +FIXED Ca_cooperativity_n // Hill coefficient for Ca²⁺-driven NT release +FIXED Ca_half_max_K // half-maximal Ca²⁺ for NT release +``` + +## Part 3 — DAY Budget Declarations + +``` +// One budget variable per component — covers fast energy AND fast consumables +// Replenished continuously. Consumed by all DAY behaviors. + +VAR astro_budget + // SOURCE: vascular_glucose_supply → glycolysis (ROOT of all synaptic energy) + // COVERS: ATP for EAAT glutamate clearance + // serine → D-serine synthesis (serine racemase running cost) + // lactate production and export to all neuronal components + // fast process motility adjustments + // (combines: astro_ATP + serine_precursor_fast_pool + EAAT_running_cost) + +VAR astro_lactate + // Fuel exported by astrocyte → feeds pre, post, dend, axon budgets + // = min(glycolysis(vascular_glucose_supply), astro_budget × export_fraction) + // Hard cap: vascular_glucose_supply (FIXED) + +VAR pre_budget + // SOURCE: astro_lactate × pre_fraction (primary) + // COVERS: ATP for VGCC opening + // vesicle fusion (SNARE-mediated) + // VATPase refill of vesicles + // fast vesicle membrane lipid turnover + // synaptotagmin recycling + // (combines: bouton_ATP + fast_vesicle_consumables) + +VAR post_budget + // SOURCE: astro_lactate × post_fraction (primary) + // COVERS: ATP for NaK pump membrane reset + // NMDA current handling + // AMPA receptor lateral diffusion + rapid recycling + // actin monomers for transient spine changes + // PKA phosphorylation (minor) + // (combines: spine_ATP + fast_actin_pool + receptor_recycling_lipids) + +VAR dend_budget + // SOURCE: astro_lactate × dend_fraction (primary) + // soma organelle delivery (minor) + // COVERS: ATP for bAP propagation along branch + // local mRNA translation (ribosome running cost) + // fast protein + organelle transport to spines + // branch Ca²⁺ handling (SERCA pump) + // mRNA consumed by local translation + // (combines: dend_ATP + fast_mRNA_consumables + local_translation_running_cost) + +VAR soma_budget + // SOURCE: own mitochondria (self-fueled — independent of astrocyte) + // COVERS: ATP for AP generation (Na⁺/K⁺ currents + NaK reset) + // CREB phosphorylation (minor) + // nuclear Ca²⁺ handling + // fast signaling molecule turnover + // shipping costs for organelle delivery to branches + axon + // (combines: soma_ATP + fast_signaling_consumables + shipping_running_cost) + +VAR axon_budget + // SOURCE: soma_budget × axon_fraction (primary) + // astro_lactate × axon_astro_fraction (minor, along shaft) + // COVERS: ATP for AP propagation at each node of Ranvier + // kinesin/dynein motor running cost (anterograde transport) + // myelin maintenance fast costs + // (combines: axon_ATP + transport_running_cost) +``` + +## Part 4 — NIGHT Energy and Material Declarations + +``` +// ENERGY: ATP cost of structural assembly — replenished overnight, NOT recoverable +// MATERIAL: slow structural proteins — replenished by CREB + transport, RECOVERABLE + +VAR astro_energy // NIGHT ATP for process retraction, ECM secretion, racemase upregulation + // SOURCE: overnight glycolysis replenishment + // NOT recovered after LTD structural reversal + // (covers: process_motility_ATP + ECM_secretion_ATP) + +VAR astro_material // NIGHT slow structural components + // SOURCE: astrocyte cell body synthesis (overnight) + // CONTAINS: EAAT transporter proteins + // serine racemase enzyme (upregulation) + // ECM proteins (Glypicans, Thrombospondins) + // process cytoskeleton components + // RECOVERABLE: partially after LTD (recycling_fraction) + // (combines: astro_ECM_pool + racemase_upregulation_proteins + // + EAAT_new_proteins + process_cytoskeleton) + +VAR pre_energy // NIGHT ATP for active zone scaffold incorporation + // SOURCE: replenished from soma overnight delivery + // NOT recovered after LTD + // (covers: RIM/Munc13_incorporation_ATP + VGCC_clustering_ATP) + +VAR pre_material // NIGHT slow structural components for bouton + // SOURCE: soma_material via axon transport (anterograde) + // CONTAINS: RIM, Munc13 (AZ scaffold) + // VGCC subunits + // vesicle membrane proteins (structural pool) + // SNARE proteins (structural pool) + // RECOVERABLE: significantly after LTD — proteins return to axonal pool + // (combines: AZ_scaffold_proteins + VGCC_subunit_pool) + +VAR post_energy // NIGHT ATP for CaMKII anchoring, actin polymerization, PSD remodeling + // SOURCE: replenished from soma overnight delivery + // NOT recovered after LTD + // (covers: CaMKII_anchoring_ATP + actin_polymerization_ATP + // + PSD_scaffold_remodeling_ATP) + +VAR post_material // NIGHT slow structural components for spine + // SOURCE: dend_material (branch pool + soma delivery) + // CONTAINS: AMPA receptor subunits (GluA1, GluA2) + // PSD scaffold proteins (PSD-95, SHANK, Homer) + // structural actin pool + // CaMKII (structural pool) + // RECOVERABLE: significantly — internalized receptors return to + // dendritic reserve pool after LTD + // (combines: receptor_reserve + PSD_scaffold_pool + structural_actin) + +VAR dend_energy // NIGHT ATP for mitochondria incorporation, cytoskeletal reinforcement + // SOURCE: soma overnight delivery + // NOT recovered after LTD + // (covers: mitochondria_incorporation_ATP + cytoskeletal_remodeling_ATP) + +VAR dend_material // NIGHT slow structural components for branch + // SOURCE: soma_material (shipped during DAY NOT_AP + NIGHT) + // CONTAINS: Arc mRNA + plasticity mRNAs (structural pool) + // mitochondria (for local energy capacity) + // cytoskeletal proteins (MAP2, tau) + // AMPA subunits in transit to spines + // RECOVERABLE: partially — organelles redistributed after branch pruning + // (combines: dend_mRNA_structural_pool + organelle_store + // + cytoskeletal_proteins) + +VAR soma_energy // NIGHT ATP for ribosome biogenesis, ion channel incorporation + // SOURCE: own mitochondria overnight + // NOT recovered + // (covers: ribosome_biogenesis_ATP + channel_incorporation_ATP) + +VAR soma_material // NIGHT slow structural components produced by soma + // SOURCE: CREB-driven synthesis (peaks in NIGHT) + // CONTAINS: all structural proteins for downstream components + // mRNA transcripts (Arc, BDNF, receptor subunits) + // organelles (mitochondria, ribosomes) + // DISTRIBUTES TO: dend_material + pre_material (via axon) + // (combines: CREB_synthesis_output + organelle_biogenesis_output) + +VAR axon_energy // NIGHT ATP for myelination, microtubule stabilization + // SOURCE: soma overnight delivery + // NOT recovered + // (covers: myelination_ATP + microtubule_stabilization_ATP) + +VAR axon_material // NIGHT slow structural components for axon + // SOURCE: soma_material (motor proteins, myelin components) + // CONTAINS: kinesin/dynein motor proteins (structural pool) + // microtubule components + // myelin maintenance proteins + // RECOVERABLE: partially after axon structural reduction + // (combines: transport_machinery + myelination_proteins) +``` + +## Part 5 — Structural Variables (Written Only in NIGHT) + +``` +VAR pre_structure // active zone capacity + // RRP_capacity ∝ pre_structure + // VGCC_coupling ∝ pre_structure + // refill_ceiling ∝ pre_structure + +VAR post_structure // spine sensitivity capacity + // anchoring_slots ∝ post_structure + // spine_volume ∝ post_structure + // local_reserve_ceiling ∝ post_structure + +VAR dend_structure // branch transmission and supply capacity + // bAP_fidelity ∝ dend_structure × attenuation(position) + // translation_ceiling ∝ dend_structure + // transport_speed ∝ dend_structure + +VAR soma_structure // somatic output and production capacity + // baseline_threshold ∝ 1/soma_structure + // AP_reliability ∝ soma_structure + // synthesis_ceiling ∝ soma_structure + +VAR axon_structure // axonal transmission and transport capacity + // propagation_reliability ∝ axon_structure + // transport_rate_ceiling ∝ axon_structure + +VAR astro_structure // astrosynaptic environmental capacity — SELF-REINFORCING + // perisynaptic_distance ∝ 1/astro_structure + // EAAT_density ∝ astro_structure + // D_serine_tonic ∝ astro_structure + // ECM_integrity ∝ astro_structure +``` + +## Part 6 — Trace Variables + +``` +// Fast traces: DAY only +FAST_TRACE pre_fast_trace // residual Ca²⁺ — τ ≈ 100ms +FAST_TRACE post_fast_trace // spine Ca²⁺ amplitude × rise_speed — τ ≈ tens of ms +FAST_TRACE dend_fast_trace // branch Ca²⁺ integration — τ ≈ 300ms +FAST_TRACE soma_fast_trace // nuclear Ca²⁺ — τ ≈ seconds +FAST_TRACE axon_fast_trace // AP propagation load — τ ≈ seconds +FAST_TRACE astro_fast_trace // perisynaptic Ca²⁺ from mGluR5 — τ ≈ seconds + +// Possible tagging: intermediate — τ ≈ seconds to minutes +VAR pre_possible_tagging +VAR post_possible_tagging // POST: CANDIDATE lifetime +VAR dend_possible_tagging +VAR soma_possible_tagging +VAR axon_possible_tagging +VAR astro_possible_tagging + +// Tags: slow, DAY→NIGHT bridge — τ ≈ hours +TAG pre_tag +TAG post_tag // POST only: CANDIDATE→STABLE before surviving to NIGHT +TAG dend_tag +TAG soma_tag +TAG axon_tag +TAG astro_tag +``` + +# SCOPE: DAY + {component}_budget consumed. Traces written and decay. Structures READ only. + No {component}_energy or {component}_material used in DAY. + +## PRE | CONTEXT: AP + +``` +scope DAY | context AP: + + // Budget gate + if pre_budget < AP_release_cost: + suppress(NT_flux) + exit context + // covers: VGCC_ATP + fusion_ATP + fast_vesicle_consumables + + // Fast trace: residual Ca²⁺ + pre_fast_trace += spike_Ca_influx(input_freq) + pre_fast_trace *= decay(τ = 100ms) + pre_budget -= Ca_handling_cost + + // NT flux: Hill function Ca²⁺ drive × RRP level + Ca_drive = pre_fast_trace^Ca_cooperativity_n / + (Ca_half_max_K^Ca_cooperativity_n + pre_fast_trace^Ca_cooperativity_n) + + if RRP_level > 0: + NT_flux = RRP_level × Ca_drive + glutamate += NT_flux × Δt + RRP_level -= NT_flux × Δt + pre_budget -= NT_flux × vesicle_fusion_cost + // covers: SNARE_ATP + fast_membrane_lipid_turnover + + // RRP refill — rate limited by pre_budget and pre_structure (READ) + RRP_refill = min(refill_rate_constant, pre_structure.refill_ceiling) + RRP_level += RRP_refill × Δt + RRP_level = clamp(RRP_level, 0, pre_structure.RRP_capacity) + pre_budget -= RRP_refill × VATPase_cost + + // Overflow brake: mGluR2/3 → Gi → VGCC suppression + if glutamate > spillover_threshold: + Ca_drive *= mGluR_brake_factor + + // Refuel from astrocyte lactate + pre_budget += astro_lactate × pre_fraction +``` + +## PRE | CONTEXT: NOT_AP + +``` +scope DAY | context NOT_AP: + + // Fast trace decays + pre_fast_trace *= decay(τ = 100ms) + + // RRP refills during silence + RRP_refill = min(refill_rate_constant, pre_structure.refill_ceiling) + RRP_level += RRP_refill × Δt + RRP_level = clamp(RRP_level, 0, pre_structure.RRP_capacity) + pre_budget -= RRP_refill × VATPase_cost + + // Possible tagging: graded, decays + if pre_fast_trace > eligibility_threshold: + pre_possible_tagging += pre_fast_trace + pre_possible_tagging *= decay(τ = seconds) + + // Dopamine decays locally + dopamine_local *= decay(τ = hundreds_of_ms) + + // Tag: local eligibility AND global validation must coincide + if dopamine_local > dopamine_threshold and + pre_possible_tagging > tagging_threshold: + pre_tag += dopamine_local × pre_possible_tagging + pre_tag *= decay(τ = hours) + // pre_budget cost: negligible (PKA is already running from dopamine broadcast) +``` + +## POST | CONTEXT: NOT_bAP + +``` +scope DAY | context NOT_bAP: + + // AMPA current — occupancy of existing slots, gated by post_structure (READ) + AMPA_current = glutamate × post_structure.sensitivity + Vm += AMPA_current + post_budget -= AMPA_current_cost + // covers: NaK_reset_ATP + fast_receptor_recycling_cost + + // NMDA gate: depolarization + D-serine + glutamate coincidence + if Vm > Mg_eject_threshold and + astro_D_serine > D_serine_threshold: + Ca_influx = NMDA_Ca_influx(glutamate) + post_fast_trace += Ca_influx × rise_speed(Ca_influx) + post_budget -= NMDA_current_cost + // covers: NMDA_handling_ATP + fast_actin_transient_cost + + // Fast trace decays + post_fast_trace *= decay(τ = tens_of_ms) + + // CANDIDATE tag: Ca²⁺ crossed tagging threshold — Hebbian anticipation + if post_fast_trace > Ca_TAG_threshold: + post_possible_tagging += post_fast_trace + post_possible_tagging *= decay(τ = minutes) // CANDIDATE lifetime + post_budget -= PKA_phosphorylation_cost // minor — PKA priming of GluA1-Ser845 + + // Refuel + post_budget += astro_lactate × post_fraction +``` + +## POST | CONTEXT: bAP + +``` +scope DAY | context bAP: + + // bAP arrives — strength set by dend_structure (READ) + Vm += bAP_depolarization × dend_structure.bAP_fidelity + post_budget -= bAP_reset_cost + // covers: NaK_reset_ATP for bAP depolarization + + // Coincidence confirmation: bAP finds CANDIDATE already set + if post_possible_tagging > Ca_TAG_threshold: + post_fast_trace += bAP_Ca_boost() + // supralinear Ca²⁺ summation — trace amplified above Ca_HIGH + + // Dopamine decays locally + dopamine_local *= decay(τ = hundreds_of_ms) + + // STABLE tag: CANDIDATE stabilized by dopamine within window + if dopamine_local > dopamine_threshold and + post_possible_tagging > tagging_threshold: + post_tag += dopamine_local × post_possible_tagging + post_tag *= decay(τ = hours) + // post_budget cost: already covered by PKA_phosphorylation_cost in NOT_bAP +``` + +## DEND | CONTEXT: CONTINUOUS + +``` +scope DAY | context CONTINUOUS: + + // Integrate spines upward + branch_Vm = integrate(POST.Vm, all_spines_on_branch) + + // Propagate bAP downward — fidelity from dend_structure (READ) + bAP_local = propagate_bAP(SOMA.AP_fired, + dend_structure.bAP_fidelity, + branch_geometry) + dend_budget -= bAP_propagation_cost + // covers: NaK_reset_ATP along branch + fast_Ca_handling + + // Fast trace: branch Ca²⁺ + dend_fast_trace += bAP_Ca_influx(bAP_local) + dend_fast_trace += spine_Ca_spillover(active_spines) + dend_fast_trace *= decay(τ = 300ms) + dend_budget -= branch_Ca_handling_cost + + // Possible tagging + if dend_fast_trace > eligibility_threshold: + dend_possible_tagging += dend_fast_trace + dend_possible_tagging *= decay(τ = seconds) + + // Dopamine decays + dopamine_local *= decay(τ = hundreds_of_ms) + + // Tag + if dopamine_local > dopamine_threshold and + dend_possible_tagging > tagging_threshold: + dend_tag += dopamine_local × dend_possible_tagging + dend_tag *= decay(τ = hours) + + // Local translation: runs when tag set, gated by dend_budget + // uses fast mRNA consumables from dend_budget + if dend_tag > tag_expiry_threshold and dend_budget > translation_cost: + local_proteins = translate(dend_fast_trace) + dend_budget -= translation_cost + // covers: ribosome_running_cost + fast_mRNA_consumed + // Note: this uses fast mRNA pool (in dend_budget), NOT dend_material + // dend_material mRNA is the slow structural pool consumed only in NIGHT + + // ACh modulates commit threshold + commit_threshold *= (1 / (1 + ACh_level × ACh_gain)) + + dend_budget -= branch_maintenance_cost + dend_budget += astro_lactate × dend_fraction +``` + +## SOMA | CONTEXT: AP + +``` +scope DAY | context AP: + + // Firing threshold: structure baseline × adaptation × neuromodulators × refractory + AP_threshold = soma_structure.baseline_threshold + × (1 + adaptation_factor(soma_fast_trace)) + × neuromod_factor(NE_level, ACh_level) + × refractory_factor(time_since_last_AP) + + if branch_Vm > AP_threshold: + AP_fired = True + soma_budget -= AP_generation_cost + // covers: Na⁺/K⁺ current ATP + NaK_reset + fast_signaling_consumables + + // Fast trace: nuclear Ca²⁺ + soma_fast_trace += nuclear_Ca_influx() + soma_fast_trace *= decay(τ = seconds) + + // Refractory period + refractory_timer = absolute_refractory_duration + + // Possible tagging + if soma_fast_trace > eligibility_threshold: + soma_possible_tagging += soma_fast_trace + soma_possible_tagging *= decay(τ = seconds) + + // Dopamine decays + dopamine_local *= decay(τ = hundreds_of_ms) + + // Tag: nuclear Ca²⁺ AND dopamine coincidence + if dopamine_local > dopamine_threshold and + soma_possible_tagging > tagging_threshold: + soma_tag += dopamine_local × soma_possible_tagging + soma_tag *= decay(τ = hours) + soma_budget -= CREB_phosphorylation_cost + // covers: CREB_phospho_ATP (minor fast cost) + // Note: full CREB-driven synthesis is a NIGHT operation consuming soma_energy +``` + +## SOMA | CONTEXT: NOT_AP + +``` +scope DAY | context NOT_AP: + + // Integrate dendritic inputs + branch_Vm = integrate(DEND.branch_Vm, all_branches) + refractory_timer = max(0, refractory_timer - Δt) + soma_fast_trace *= decay(τ = seconds) + + // Ship to tagged branches — priority by tag magnitude + for branch in branches_ranked_by(dend_tag): + delivery = min(shipping_fraction × soma_budget, + branch_demand(dend_tag)) + dend_budget[branch] += delivery × fuel_fraction + soma_budget -= delivery × shipping_cost + // covers: kinesin_running_cost for fast organelle delivery + // Note: structural protein shipping (soma_material → dend_material) + // happens in NIGHT, not here + + // Ship to axon for bouton running costs + axon_budget += soma_budget × axon_fuel_fraction + soma_budget -= soma_budget × axon_fuel_fraction +``` + +## AXON | CONTEXT: CONTINUOUS + +``` +scope DAY | context CONTINUOUS: + + // AP propagation reliability — set by axon_structure (READ) + propagation_reliability = axon_structure.myelination + × (1 - failure_rate(axon_fast_trace)) + APs_delivered = AP_fired × propagation_reliability + axon_budget -= AP_propagation_cost × APs_delivered + // covers: NaK_reset_ATP at nodes + fast_myelin_maintenance + + // Fast trace: propagation load + axon_fast_trace += APs_delivered + axon_fast_trace *= decay(τ = seconds) + + // Anterograde transport — delivers running supplies to boutons + transport_rate = min(axon_structure.transport_ceiling, + axon_budget × transport_fraction) + pre_budget += transport_rate × Δt // boutons receive running fuel + axon_budget -= transport_cost × transport_rate × Δt + // covers: kinesin_ATPase running cost + // Note: structural pre_material transport (soma_material → pre_material) + // happens in NIGHT, not here + + // Possible tagging + if axon_fast_trace > eligibility_threshold: + axon_possible_tagging += axon_fast_trace + axon_possible_tagging *= decay(τ = seconds) + + // Dopamine decays + dopamine_local *= decay(τ = hundreds_of_ms) + + // Tag + if dopamine_local > dopamine_threshold and + axon_possible_tagging > tagging_threshold: + axon_tag += dopamine_local × axon_possible_tagging + axon_tag *= decay(τ = hours) + + // Refuel + axon_budget += soma_budget × axon_fuel_fraction + axon_budget += astro_lactate × axon_astro_fraction +``` + +## ASTRO | CONTEXT: CONTINUOUS + +``` +scope DAY | context CONTINUOUS: + + // ROOT energy production + astro_budget += glycolysis(vascular_glucose_supply) × Δt + // hard cap: vascular_glucose_supply (FIXED) + // covers: all fast astrocyte operations + lactate export + + // Lactate export to all neuronal components + astro_lactate = min(astro_budget × lactate_export_fraction, + vascular_glucose_supply × max_export_fraction) + astro_budget -= astro_lactate + deliver(astro_lactate → pre_budget × pre_fraction, + post_budget × post_fraction, + dend_budget × dend_fraction, + axon_budget × axon_fraction) + + // Glutamate clearance — rate from astro_structure (READ) + clearance = astro_structure.EAAT_density × glutamate × Δt + glutamate -= clearance + astro_budget -= clearance × EAAT_ATP_cost + // covers: EAAT_cotransport_ATP + NaK_secondary_cost + + // Overflow detection and D-serine release + if glutamate > spillover_threshold: + astro_fast_trace += mGluR5_Ca_influx() + astro_fast_trace *= decay(τ = seconds) + + // D-serine release: budget-limited (serine + synthesis ATP both in budget) + D_serine_released = min(proportional_to(astro_fast_trace), + astro_budget × Ds_fraction) + astro_budget -= D_serine_released × Ds_synthesis_cost + // covers: serine_racemase_ATP + serine_precursor_fast_cost + astro_D_serine += D_serine_released + + // Simultaneous presynaptic brake — cross-compartment, no astro budget cost + Ca_drive_pre *= mGluR_brake_factor + + // Possible tagging + if astro_fast_trace > eligibility_threshold: + astro_possible_tagging += astro_fast_trace + astro_possible_tagging *= decay(τ = seconds) + + // Dopamine decays + dopamine_local *= decay(τ = hundreds_of_ms) + + // Tag + if dopamine_local > dopamine_threshold and + astro_possible_tagging > tagging_threshold: + astro_tag += dopamine_local × astro_possible_tagging + astro_tag *= decay(τ = hours) + + // Tonic D-serine from astro_structure (READ) — baseline supply + astro_D_serine += astro_structure.D_serine_tonic × Δt + astro_budget -= astro_structure.D_serine_tonic × tonic_synthesis_cost + // covers: constitutive_racemase_ATP + baseline_serine_fast_cost + + // Global overload + if astro_fast_trace > OVERLOAD_threshold: + trigger(shockwave_lockdown) +``` + +## Special Case — Shockwave Lockdown + +``` +scope DAY or NIGHT | context OVERLOAD: + + // Emergency — bypasses budget gates + Vm = HYPERPOLARIZED + AMPA_occupancy = mass_internalization() + post_budget -= emergency_reset_cost // DAY: uses post_budget + axon_fast_trace += overdrive_cluster() + astro_budget -= emergency_cost + // Note: in NIGHT, uses post_energy if structural receptors affected +``` + +# SCOPE: NIGHT + {component}_energy and {component}_material used — NOT {component}_budget + Structural variables WRITTEN. Tags evaluated and cleared. + +## Step 1 — Replenish Energy, Material, and Budgets + +``` +scope NIGHT | step 1: + + // Astrocyte: replenishes first — fuels everything + astro_budget += overnight_glycolysis(vascular_glucose_supply) × Δt_night + // covers: fast running costs for next DAY + astro_energy += overnight_astro_synthesis() × Δt_night + // covers: process_motility_ATP + ECM_secretion_ATP for structural work + astro_material += astrocyte_cellbody_synthesis() × Δt_night + // covers: EAAT proteins + racemase upregulation + ECM proteins + process cytoskeleton + + // Soma: self-fueled, replenishes own energy + produces all structural material + soma_budget += overnight_mitochondria_output() × Δt_night + soma_energy += overnight_soma_energy_reserve() × Δt_night + // covers: ribosome_biogenesis_ATP + ion_channel_incorporation_ATP + soma_material += CREB_driven_synthesis(soma_tag) × Δt_night + // peaks based on soma_tag magnitude — this is the production bottleneck + // covers: all structural proteins + mRNA + organelles for downstream components + + // Distribute soma_material to downstream components + dend_material += soma_material × dend_delivery_fraction + // mRNA + plasticity proteins + organelles shipped to branches + axon_material += soma_material × axon_delivery_fraction + // AZ scaffold proteins + VGCC subunits shipped via anterograde transport + soma_material -= (dend_delivery_fraction + axon_delivery_fraction) × soma_material + + // Branch delivers to spines + post_material += dend_material × spine_delivery_fraction + dend_material -= spine_delivery_fraction × dend_material + // AMPA subunits + PSD scaffold proteins delivered to spine reserve + + // Axon delivers to boutons + pre_material += axon_material × bouton_delivery_fraction + axon_material -= bouton_delivery_fraction × axon_material + + // Downstream energy replenishment + pre_energy += overnight_pre_energy_replenishment() + post_energy += overnight_post_energy_replenishment() + dend_energy += overnight_dend_energy_replenishment() + axon_energy += overnight_axon_energy_replenishment() + // all sourced from soma overnight mitochondrial output +``` + +## Step 2 — Structural Commits (Parallel, Independent) + +``` +scope NIGHT | step 2: + + // Coherence bonus: if pre, post, astro all tagged → amplified commit + all_aligned = (pre_tag > tag_expiry_threshold and + post_tag > tag_expiry_threshold and + astro_tag > tag_expiry_threshold) + coherence_bonus = all_aligned ? coherence_factor : 1.0 + + // ── PRE COMMIT ────────────────────────────────────────────────── + if pre_tag > tag_expiry_threshold: + Δpre = min(AZ_expansion_cost, + pre_material, // material gate + pre_energy × pre_fraction) // energy gate + pre_structure += Δpre × coherence_bonus // STRUCTURE WRITTEN + pre_material -= Δpre // material consumed (RECOVERABLE) + pre_energy -= Δpre × assembly_ATP_cost // energy consumed (NOT recoverable) + if Δpre < AZ_expansion_cost: + queue(pre_deficit → next NIGHT) + + // ── POST COMMIT ───────────────────────────────────────────────── + if post_tag > tag_expiry_threshold: + Δpost = min(AMPA_insertion_cost, + post_material, + post_energy × post_fraction) + post_structure += Δpost × coherence_bonus // STRUCTURE WRITTEN + post_material -= Δpost // RECOVERABLE + post_energy -= Δpost × assembly_ATP_cost // NOT recoverable + if Δpost < AMPA_insertion_cost: + queue(post_deficit → next NIGHT) + + // ── DEND COMMIT ───────────────────────────────────────────────── + if dend_tag > tag_expiry_threshold: + Δdend = min(branch_expansion_cost, + dend_material, + dend_energy × dend_fraction) + dend_structure += Δdend × coherence_bonus // STRUCTURE WRITTEN + dend_material -= Δdend // RECOVERABLE (partially) + dend_energy -= Δdend × assembly_ATP_cost + if Δdend < branch_expansion_cost: + queue(dend_deficit → next NIGHT) + + // ── SOMA COMMIT ───────────────────────────────────────────────── + if soma_tag > tag_expiry_threshold: + Δsoma = min(soma_expansion_cost, + soma_material, + soma_energy × soma_fraction) + soma_structure += Δsoma // STRUCTURE WRITTEN + soma_material -= Δsoma // RECOVERABLE (partially) + soma_energy -= Δsoma × assembly_ATP_cost + + // ── AXON COMMIT ───────────────────────────────────────────────── + if axon_tag > tag_expiry_threshold: + Δaxon = min(axon_expansion_cost, + axon_material, + axon_energy × axon_fraction) + axon_structure += Δaxon // STRUCTURE WRITTEN + axon_material -= Δaxon // RECOVERABLE (partially) + axon_energy -= Δaxon × assembly_ATP_cost + if Δaxon < axon_expansion_cost: + queue(axon_deficit → next NIGHT) + + // ── ASTRO COMMIT ──────────────────────────────────────────────── + if astro_tag > tag_expiry_threshold: + Δastro = min(process_retraction_cost, + astro_material, // ECM proteins + process cytoskeleton + astro_energy × astro_fraction) + astro_structure += Δastro × coherence_bonus // STRUCTURE WRITTEN — SELF-REINFORCING + astro_material -= Δastro // RECOVERABLE (recycling_fraction) + astro_energy -= Δastro × assembly_ATP_cost + if Δastro < process_retraction_cost: + queue(astro_deficit → next NIGHT) +``` + +## Step 3 — Passive Depotentiation + +``` +scope NIGHT | step 3: + + // Potentiation draws material first. + // Remaining material distributed as maintenance. + // What cannot be maintained decays passively. + // No active LTD signal required — depotentiation is resource neglect. + + remaining_material = total_material_pool - material_consumed_by_potentiation + maintenance_per_synapse = remaining_material × maintenance_fraction + / total_synapse_count + + for each synapse: + // Structural decay — passive, continuous + pre_structure -= structural_decay_rate × Δt_night + post_structure -= structural_decay_rate × Δt_night + dend_structure -= structural_decay_rate × Δt_night + astro_structure -= structural_decay_rate × Δt_night + + // Maintenance allocation from remaining material + if maintenance_per_synapse >= maintenance_cost: + // full maintenance — structure stable + pre_structure += maintenance_pre + post_structure += maintenance_post + dend_structure += maintenance_dend + astro_structure += maintenance_astro + else: + // partial maintenance — structure drifts downward + // DEPOTENTIATION BY NEGLECT — no signal, no active process + pre_structure += maintenance_per_synapse × pre_fraction + post_structure += maintenance_per_synapse × post_fraction + dend_structure += maintenance_per_synapse × dend_fraction + astro_structure += maintenance_per_synapse × astro_fraction + + // LTD material recovery: returned to pools, enriches remaining material + for each synapse where net_structure_change < 0: + recovered_material = structure_loss × recycling_fraction + pre_material += recovered_material × pre_fraction // AZ proteins recovered + post_material += recovered_material × post_fraction // receptors to reserve + astro_material += recovered_material × astro_fraction × recycling_fraction + // energy is NOT recovered — assembly ATP is gone + // this asymmetry is why material and energy must stay separate in NIGHT +``` + +## Step 4 — Homeostatic Scaling + +``` +scope NIGHT | step 4: + + if soma_tag > homeostatic_ceiling: + scale_factor = homeostatic_ceiling / soma_tag + for each synapse: + post_structure *= scale_factor // STRUCTURE WRITTEN + pre_structure *= scale_factor // STRUCTURE WRITTEN + // scaled-down material returned to pools + soma_material += sum(structure_reduction) × recycling_fraction + // energy NOT recovered +``` + +## Step 5 — Clear All Traces + +``` +scope NIGHT | step 5: + + // Fast traces: confirmed zero (decayed during DAY) + pre_fast_trace = post_fast_trace = dend_fast_trace = 0 + soma_fast_trace = axon_fast_trace = astro_fast_trace = 0 + + // Possible tagging: confirmed zero (decayed during DAY) + pre_possible_tagging = post_possible_tagging = dend_possible_tagging = 0 + soma_possible_tagging = axon_possible_tagging = astro_possible_tagging = 0 + + // Tags: cleared after commit, carried forward if above expiry threshold + if pre_tag < tag_expiry_threshold: pre_tag = 0 + if post_tag < tag_expiry_threshold: post_tag = 0 + if dend_tag < tag_expiry_threshold: dend_tag = 0 + if soma_tag < tag_expiry_threshold: soma_tag = 0 + if axon_tag < tag_expiry_threshold: axon_tag = 0 + if astro_tag < tag_expiry_threshold: astro_tag = 0 +``` + +## Summary: Energy and Material Flow + +``` +DAY — {component}_budget (combined fast energy + fast consumables): + + vascular_glucose_supply (FIXED) + → astro_budget (glycolysis ROOT) + → astro_lactate → pre_budget, post_budget, dend_budget, axon_budget + → soma_budget (own mitochondria — independent root) + → axon_budget (partial) + → dend_budget (partial) + +NIGHT — {component}_energy (structural assembly ATP, NOT recoverable): + + vascular_glucose_supply (FIXED) + → astro_energy (overnight glycolysis) + → soma_energy (overnight mitochondria) → pre_energy, post_energy, + dend_energy, axon_energy + +NIGHT — {component}_material (slow structural proteins, RECOVERABLE): + + soma (CREB synthesis — soma_tag driven) + → soma_material + → dend_material → post_material (spine delivery) + → axon_material → pre_material (bouton delivery) + astrocyte cell body (overnight synthesis) + → astro_material (EAAT + racemase + ECM + process cytoskeleton) + + LTD recovery flows (material only — not energy): + post LTD → post_material (receptors to dendritic reserve) + pre LTD → pre_material (AZ proteins to axonal pool) + astro LTD → astro_material (ECM fragments, recycling_fraction) +``` + +# Flows + +Per ora abbiamo in DAY il {component}_budget che raggruppa energy e material, e in NIGHT {component}_energy e {component}_material. + +This maps onto a real biological distinction. The astrocyte's lactate and the soma's ATP fund the running costs of the cell — everything that needs to happen just to keep the system operating from moment to moment. CREB-driven protein synthesis funds the capital investment — the slow, expensive structural changes that modify what the running system is capable of. These are two different budgets in the biological sense: operating expenditure versus capital expenditure. Combining them within DAY is correct because DAY is entirely operating expenditure. Keeping them separate in NIGHT is correct because NIGHT mixes operating expenditure with capital expenditure, and only the capital component is recoverable. + +Combining {component}_energy e {component}_material would hide the fact that dismantling a structure recovers biological building blocks but not the work that was done to assemble them — which is the thermodynamic reality of any construction and deconstruction process. + + +## Energy flow + +``` +VASCULAR SUPPLY + → ASTROCYTE CELL BODY + glucose → lactate (glycolysis) + → astro_budget (local ATP for clearance, D-serine, ECM, process motility) + → lactate exported to: + → pre_budget (ATP for VGCC, vesicle fusion, VATPase) + → post_budget (ATP for NaK pump, AMPA trafficking, actin) + → dend_budget (ATP for bAP propagation, local translation) + + → SOMA + soma has own mitochondria — partly self-fueled + soma_budget (ATP for AP generation, CREB, protein synthesis, shipping) + → dend_budget top-up (organelle delivery) + → axon_budget top-up (transport machinery) +``` + +## Material flow + +``` +SOMA + protein synthesis (CREB-driven, peaks in NIGHT) + → soma_material (receptors, scaffold proteins, organelles, mRNA) + → dend_material (branch receives proteins + mRNA from soma) + → post_material (spine receives receptors + actin from branch) + → axon_material (boutons receive AZ proteins + VGCCs from soma via axon) + → pre_material (bouton active zone proteins) + +ASTROSYNAPSE + ECM proteins synthesized in astrocyte cell body + → astro_material (Glypicans, Thrombospondins, serine for D-serine) + → cleft environment (ECM sealing, D-serine availability) +``` + +Yes, exactly. This is the essential abstract pattern. Let me state it precisely. + +# The Abstract Pattern + +A component operates within a structure set by the previous NIGHT. During DAY, in each context, it executes behaviors that cost budget and deposit fast traces. Fast traces are local records of recent activity that bias the next behavior and open an eligibility window for tagging. A tag forms when a local eligibility signal coincides with one or more non-local validation signals within the decay window of the trace — the number of required coincidences reflecting the spatial scale at which that component sits in the system. In contexts without triggering input, all traces decay, closing the windows they opened. At NIGHT, the tag magnitude drives a structural commit proportional to available material and energy — material being recoverable and energy not — with the structural change becoming the new ceiling within which the next DAY's behaviors will operate. What is not committed decays for lack of maintenance, and the resources freed by that decay partially fund the potentiation of what was. + +## DAY — The General Form + +Every DAY behavior follows this template: + +``` +given: STRUCTURE // the architectural ceiling left by NIGHT +in: CONTEXT // local or global triggering condition +if: BUDGET > cost // operational resources available +then: behavior executes + BUDGET -= cost // resources consumed + FAST_TRACE += f(behavior) // local record deposited +``` + +The fast trace then drives two parallel processes: + +**Within the same context** — the trace biases the next execution of the same behavior. This is the short-term modulation loop. It is entirely local and requires no external signal. + +**Across contexts** — the trace accumulates into `possible_tagging` when it exceeds the eligibility threshold. This is the bridge toward long-term change. It requires the trace to be sustained enough to survive into the NOT_AP or CONTINUOUS context. + +### The Tag Formation — Where Non-Locality Enters + +The abstract pattern for tag formation generalizes across all components but with different **coincidence requirements**: + +**PRE, DEND, SOMA, AXON, ASTRO — one non-local coincidence:** +``` +if FAST_TRACE > eligibility // local: this bouton was recently active + AND dopamine > threshold // non-local: organism-level reward signal +then: TAG += dopamine × possible_tagging +``` +One spatial scale beyond the local component is required. The organism must confirm that the recent activity was worth saving. + +**POST — two non-local coincidences:** +``` +// First coincidence (NOT_bAP context): +if FAST_TRACE > Ca_TAG_threshold // local: spine Ca²⁺ was high + AND D-serine > threshold // non-local 1: astrosynapse co-agonist +then: post_possible_tagging += FAST_TRACE // CANDIDATE + +// Second coincidence (bAP context): +if post_possible_tagging > threshold // local: CANDIDATE still present + AND bAP arrives // non-local 2: soma fired +then: FAST_TRACE amplified above Ca_HIGH + +// Tag stabilization (any context): +if post_possible_tagging > threshold // local: confirmed coincidence + AND dopamine > threshold // non-local 3: organism validation +then: TAG += dopamine × post_possible_tagging // STABLE +``` +Three spatial scales must align: astrosynapse, soma, organism. The postsynapse is the most constrained component — it requires the most non-local validation before committing. + +### Trace Recession — The Temporal Behavior + +In every NOT_AP or CONTINUOUS context, all traces decay: + +``` +FAST_TRACE *= decay(τ_fast) // ms to seconds — closes eligibility window +possible_tagging *= decay(τ_mid) // seconds to minutes — closes tagging window +TAG *= decay(τ_slow) // hours — closes commitment window +``` + +The decay is not a separate behavior — it is the passive consequence of molecular processes. But its effect is behavioral: it enforces that coincidences must happen within specific time windows. The system does not check timing explicitly — timing is enforced by the competition between accumulation and decay. + +## NIGHT — The General Form + +``` +given: TAG // strength of DAY evidence for this component + STRUCTURE // current architectural state +if: TAG > threshold // evidence strong enough to justify investment +then: + Δstructure = min(expansion_cost, + MATERIAL, // slow structural resources available + ENERGY × fraction) // assembly ATP available + STRUCTURE += Δstructure × coherence_bonus + MATERIAL -= Δstructure // RECOVERABLE after LTD + ENERGY -= Δstructure × ATP_cost // NOT recoverable +``` + +The coherence bonus appears when pre, post, and astro tags are all SET simultaneously — the three components of the synapse have all independently gathered evidence for the same structural change, which amplifies the commit beyond what any single tag would produce alone. + +What is not potentiated passively decays: + +``` +STRUCTURE -= decay_rate × Δt_night +STRUCTURE += min(maintenance_allocation, maintenance_cost) +// if maintenance_allocation < decay_rate × Δt_night: +// structure drifts down — depotentiation by neglect +```