---

**What needs adjustment**

`Voltage-Context` is labelled as an Episode but contains sub-episodes — it should be a Context. Same for `NMDA-Coincidence` and `Ca-Dynamics & ATP-Drain`. You have used Episode and Context interchangeably in a few places; the distinction matters for the specification: a Context sets the conditions, an Episode is a named outcome within those conditions.

`Vpost_Maximum` lists `V_bAP full OR (g_AMPA full AND V_bAP medium)` — this is correct Boolean logic and should be kept exactly as written. It captures the two ways the postsynapse can reach maximum depolarisation: the bAP alone if it is strong enough, or AMPA plus a partial bAP together.

`AMPA_Population_Increase` correctly gates on `ATP_level_post NOT empty` — LTP requires ATP for CaMKII phosphorylation and receptor trafficking. LTD does not have the same gate in your spec. This is slightly asymmetric — LTD (receptor internalisation via endocytosis) is also ATP-dependent, though less so than LTP. Worth noting.

`Plasticity_LTD` covers `Ca_post_history medium` but does not cover the case where `Ca_post_history` is empty — a completely silent synapse also weakens over time (homeostatic depression). This can be left as a gap or named explicitly.

`Astrocyte_Supply_Crises` has a typo (Crises → Crisis).

The bAP needs new parameters and state variables in the model before it can be expressed as a fully implemented behavior. I will add those inline as `[GAP — to implement]` markers so the spec is complete even where the code is not yet written.

---

**Final restructured specification**

```
BEH-POST-UNIFIED: The Integrated Postsynaptic Model
=====================================================
Three loops, three timescales, one shared astrocyte supply.
Each loop feeds the next: V_post enables NMDA, NMDA drives
Ca_post, Ca_post determines plasticity and eCB, ATP sustains
all three. Failure of ATP does not silence the postsynapse
(unlike the presynapse) — it corrupts it, triggering false
retrograde signals and risking excitotoxic Ca2+ accumulation.

Variables:
  V_bAP              — back-propagating AP amplitude (0→1)
                       [GAP — requires bAP_train input,
                        analogous to presynaptic spike_train]
  g_AMPA             — AMPA receptor conductance (= receptor_conductance)
  V_post             — total postsynaptic membrane potential (0→1)
  NT_cleft           — glutamate in cleft (from presynapse)
  Desensitization    — fraction of AMPA receptors desensitized (0→1)
  Ca_post            — free Ca2+ in postsynaptic spine (0→...)
  Ca_post_history    — 2 s rolling mean of Ca_post
  ATP_level_post     — normalised postsynaptic ATP (0→1)
  ATP_demand_post    — accumulated ATP cost since last metabolic cycle
  g_AMPA_baseline    — long-term AMPA receptor density set by plasticity
                       [GAP — not yet in model; LTP/LTD would write this]
  eCB_level          — endocannabinoid retrograde signal (0→1)
                       written here, read by presynapse Loop 1

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ms: behaviors — Fast Kinetics and Gate Logic
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Voltage-Context: Context
  Determines the total depolarisation (V_post) available to
  lift the NMDA Mg block. Two independent sources contribute:
  AMPA-driven local depolarisation (g_AMPA) and the somatic
  back-propagating AP (V_bAP). Either alone can partially
  depolarise; both together reach maximum.

  Vpost_Maximum: Episode
    — V_bAP full                          OR
    — g_AMPA full AND V_bAP medium
    — Result: V_post high enough for complete Mg block removal.
              NMDA gate can open fully.
              Both ATP costs charged at maximum rate.

  Vpost_Attenuated: Episode
    — g_AMPA medium AND V_bAP empty/low   OR
    — g_AMPA low AND V_bAP medium
    — Result: V_post sub-threshold.
              Mg block partially remains.
              NMDA gate opens partially or not at all.
              This is the most common state during low-rate firing
              without a coincident bAP.

  Vpost_Passive: Episode
    — g_AMPA empty AND V_bAP empty
    — Result: V_post at rest.
              Mg block fully intact.
              No Ca_post entry possible.
              Na/K-ATPase cost minimal.

  Desensitization-Context: Context
    Modulates g_AMPA independently of NT_cleft.
    Sustained NT exposure drives receptors into a closed state
    that persists even when NT remains present.

    DesensitizationRising: Episode
      — NT_cleft sustained high (multiple consecutive ms)
      — Desensitization rises each ms
      — g_AMPA effectively reduced despite NT presence
      — attenuates Vpost_Maximum toward Vpost_Attenuated

    DesensitizationRecovering: Episode
      — NT_cleft low or empty
      — Desensitization decays with tau_desensitization = 500 ms
      — g_AMPA ceiling restored gradually

NMDA-Coincidence: Context
  Strict AND gate: both NT (ligand) and V_post (voltage) must
  be simultaneously non-zero for Ca_post to rise.
  Unlike presynaptic VGCCs which open with any spike, NMDA
  requires coincidence. This makes Ca_post a detector of
  coordinated pre+post activity, not just input rate.

  NMDA_Open: Episode
    — NT_cleft full AND V_post maximum (Vpost_Maximum active)
    — Mg block fully lifted
    — Ca_post surges — LTP territory
    — ATP_demand_post rises sharply (PMCA must clear Ca_post)
    — if sustained → Ca_post_history crosses eCB threshold

  NMDA_LogicBlocked: Episode
    — NT_cleft full BUT V_post attenuated or passive
    — Mg block partially or fully intact
    — Ca_post does not rise despite NT presence
    — Result: presynapse fired but postsynapse was not ready
              No plasticity signal generated
              This is the mechanism for input selectivity:
              only synapses active during postsynaptic firing
              produce a Ca_post signal

  NMDA_LigandBlocked: Episode
    — V_post maximum BUT NT_cleft empty
    — No glutamate to open the channel
    — Ca_post entry zero despite full depolarisation
    — Result: bAP arrived but presynapse was silent
              Again no plasticity signal
              The AND logic enforces true coincidence

Ca-Dynamics-Context: Context
  Ca_post clearance rate depends entirely on ATP_level_post.
  This is the bridge from the ATP loop into the Ca2+ loop.
  When ATP fails, Ca_post clearance fails, and the Ca2+ loop
  becomes corrupted — Ca_post reflects pump state rather
  than genuine coincidence events.

  Clearance_Optimal: Episode
    — ATP_level_post full → pump_scale_post near 1
    — PMCA (ATP-gated) + NCX (always on) both clearing
    — Ca_post returns to baseline between events
    — Each coincidence event is temporally isolated
    — ATP_demand_post increases proportionally to Ca_post load

  Clearance_Reduced: Episode
    — ATP_level_post medium → pump_scale_post reduced
    — Ca_post clears more slowly
    — Residual elevation begins accumulating between events
    — Ca_post_history starts drifting upward
    — eCB threshold may be approached during heavy firing

  Clearance_Failing: Episode
    — ATP_level_post low or empty → pump_scale_post near 0
    — Only NCX clearing (floor, not rescue)
    — Ca_post accumulates regardless of coincidence activity
    — False Trigger conditions: Ca_post_history crosses eCB
      threshold without genuine NMDA overactivity
    — Excitotoxicity risk if Ca_post elevation is sustained

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
sec: behaviors — Signal Integration and Fate
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Synaptic-Weight-Decision: Context
  Ca_post_history (2 s rolling mean of Ca_post) determines
  the plasticity signal. The threshold logic is graded:
  the same variable produces opposite outcomes depending
  on whether it is above or below the LTP/LTD boundary.
  ATP_level_post gates LTP expression but not LTD —
  strengthening requires energy, weakening does not.

  Plasticity_LTP: Episode
    — Ca_post_history full (above Ca_post_LTP threshold)
    — High-frequency or high-amplitude coincidence detected
    — Tags synapse for AMPA receptor insertion
    — Requires ATP_level_post NOT empty for expression
      (CaMKII phosphorylation and receptor trafficking are
       ATP-dependent — energy failure blocks LTP even if
       the Ca_post signal is correct)
    — [GAP] LTP expression writes g_AMPA_baseline upward
             in the minutes loop

  Plasticity_Boundary: Episode
    — Ca_post_history medium
    — Poorly timed or low-frequency coincidence
    — Neither LTP nor LTD threshold crossed
    — Synapse weight unchanged this cycle

  Plasticity_LTD: Episode
    — Ca_post_history low but non-zero
    — Weak or mistimed coincidence — presynapse fired
      but postsynapse was not sufficiently depolarised
    — Tags synapse for AMPA receptor removal
    — Less ATP-dependent than LTP; can proceed under
      mild energy stress
    — [GAP] LTD expression writes g_AMPA_baseline downward
             in the minutes loop

  Plasticity_Silent: Episode
    — Ca_post_history empty (prolonged absence of activity)
    — Homeostatic depression: unused synapses weaken
    — [GAP] not yet modelled; would require Ca_post_trace
             integration over hours

Retrograde-Feedback: Context
  eCB synthesis is triggered by Ca_post_history, not V_post.
  It is Ca2+ in the spine — not voltage — that activates the
  enzymes (DAGL, PLC) that produce endocannabinoids.
  The model cannot distinguish internally between the two
  causes of elevated Ca_post_history (genuine vs pump failure)
  but the consequences differ: one is communication,
  the other is survival.

  eCB_Synthesis_Active: Episode
    — Ca_post_history > eCB_threshold (0.7)

    — Logic A (Genuine Protection):
        Cause   : sustained NMDA_Open events — real overactivity
        Effect  : appropriate retrograde stop signal
        Outcome : presynapse reduces NT → NT_cleft falls →
                  NMDA closes → Ca_post load drops →
                  Ca_post_history falls → eCB synthesis subsides
                  Loop closes correctly

    — Logic B (False Trigger — Excitotoxic Protection):
        Cause   : Clearance_Failing — Ca_post elevated by
                  pump failure, not genuine coincidence
        Effect  : presynapse silenced without real overactivity
        Outcome : NT_cleft falls → NMDA closes → Ca_post
                  load drops → ATP_demand_post falls →
                  ATP_level_post recovers → pumps restart →
                  Ca_post clears → Ca_post_history falls →
                  eCB synthesis subsides
                  Desperate survival loop — buys time for
                  metabolic recovery

  eCB_Synthesis_Idle: Episode
    — Ca_post_history < eCB_threshold
    — eCB_level decays with tau_eCB_decay = 10000 ms
    — Presynaptic suppression lifts gradually
    — 10 s decay means suppression outlasts the trigger —
      prevents immediate re-engagement before Ca_post
      has stabilised

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
min: behaviors — Bioenergetics and Structural Change
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Metabolic-Recovery: Context
  ATP_level_post is computed from Glucose_level (shared
  supply) minus ATP_demand_post (postsynaptic-specific cost).
  The shared supply creates the coupling: both pre and post
  deplete the same astrocyte glucose budget simultaneously.
  Presynaptic silence is therefore metabolically beneficial
  to the postsynapse — less NT means less NMDA activation
  means less Ca_post means less PMCA cost.

  Astrocyte_Supply_Active: Episode
    — Glucose_level full
    — ATP_demand_post within supply capacity
    — ATP_level_post replenished each cycle
    — All three loops operating normally

  Astrocyte_Supply_Stressed: Episode
    — Glucose_level medium OR ATP_demand_post elevated
    — ATP_level_post partially reduced
    — Clearance_Reduced begins
    — Plasticity_LTP at risk (ATP dependency)

  Astrocyte_Supply_Crisis: Episode
    — Glucose_level low OR ATP_demand_post chronically high
    — ATP_level_post near empty
    — Clearance_Failing — only NCX clearing Ca_post
    — False Trigger likely → eCB_Synthesis_Active (Logic B)
    — Presynaptic silence indirectly reduces postsynaptic
      ATP demand — the coupled protection mechanism

Structural-Update: Context
  Long-term changes to AMPA receptor density.
  These are the physical substrate of learning and memory.
  [GAP] g_AMPA_baseline not yet implemented in the model.
  Would be written in Loop 3 and read by Loop 1 as the
  ceiling of receptor_conductance.

  AMPA_Population_Increase: Episode
    — Triggered by Plasticity_LTP
    — AND ATP_level_post NOT empty
    — g_AMPA_baseline shifts higher for next cycle
    — More AMPA receptors → stronger Vpost_Maximum
    — Easier to reach NMDA_Open in future events
    — Positive feedback: LTP makes future LTP more likely

  AMPA_Population_Decrease: Episode
    — Triggered by Plasticity_LTD or Plasticity_Silent
    — g_AMPA_baseline shifts lower
    — Fewer AMPA receptors → Vpost_Attenuated more common
    — Harder to reach NMDA_Open → weakens synapse further
    — Negative feedback: LTD stabilises by reducing
      future coincidence probability
```

---

---

## short term

Short-term potentiation (STP) and short-term depression (STD) are distinct from LTP/LTD in a fundamental way: they are **temporary** changes that last seconds to minutes and leave no lasting structural trace. They do not require the postsynapse at all — they are entirely presynaptic phenomena in most cases, and they operate on a completely different mechanism.

---

**What they are and where they live**

Short-term plasticity is driven by the **history of presynaptic Ca²⁺** and **vesicle pool state**, not by postsynaptic coincidence detection. The table we just built describes long-term plasticity — structural changes to AMPA density driven by Ca_post. Short-term plasticity describes transient changes to **how much NT the presynapse releases** on the next spike, driven by what happened on the last few spikes.

There are two opposing forms:

**Short-term potentiation / facilitation** — if a spike arrives shortly after the previous one, residual Ca²⁺ from the first spike has not fully cleared. The next spike adds to this residual, producing a larger Ca_post microdomain and therefore a higher release probability. The synapse releases more NT on the second spike than the first. This is already partially captured in the presynaptic model through `Tr_Ca` — elevated calcium trace from recent activity speeds up RRP recruitment and effectively increases release efficiency.

**Short-term depression** — if spikes arrive rapidly, the RRP depletes faster than it can be refilled. Each successive spike releases fewer vesicles because there are fewer available. NT release drops with each spike in a burst. This is already the core of CASCADE 1 in the presynaptic model — RRP depletion under high firing rate.

---

**Where they fit in the model**

Both are already implicitly present in the presynaptic ms and seconds loops:

```
Short-term facilitation:
  Residual Ca_micro from spike N
  → elevated Ca_micro at spike N+1
  → higher release fraction in deterministic_release (Hill curve)
  → more NT per spike
  → decays as Ca_micro clears between spikes (tau ~100-200 ms)

Short-term depression:
  Rapid firing depletes N_RRP
  → fewer vesicles available per spike
  → released_NT falls
  → recovers as RP→RRP recruitment refills (seconds timescale)
```

The timescale of each depends on parameters already in the model:

| Form         | Timescale  | Driven by         | Recovery                |
|--------------|------------|-------------------|-------------------------|
| Facilitation | 100-500 ms | residual Ca_micro | Ca²⁺ clearance rate     |
| Depression   | seconds    | RRP depletion     | RP→RRP recruitment rate |

---

**What is missing from the current model**

The model captures both implicitly but does not name them as behaviours. Two things are genuinely absent:

**Augmentation** — a slower form of facilitation lasting 5-10 seconds, driven by residual Ca²⁺ accumulating in the presynaptic terminal across many spikes. It is distinct from spike-by-spike facilitation and would require a second, slower Ca²⁺ trace with `tau ~5000 ms`. The current `Tr_Ca` with `tau = 1000 ms` is between the two — it captures some augmentation but not cleanly.

**Post-tetanic potentiation (PTP)** — an even slower presynaptic enhancement lasting minutes after a high-frequency burst, driven by protein kinase C activation from sustained Ca²⁺ elevation. This is a presynaptic phenomenon that looks like LTP from the outside but has no postsynaptic component and no structural change. It would require a third, very slow trace variable.

---

**How they interact with the LTP/LTD table**

Short-term and long-term plasticity operate on the same synapse simultaneously but independently:

```
Spike arrives
  → short-term: how much NT releases THIS spike  (presynaptic, ms-seconds)
  → long-term:  does the synapse get stronger or weaker PERMANENTLY  (postsynaptic, mins-hours)
```

A synapse can be undergoing LTD (slowly losing AMPA receptors over minutes) at the same time as it is showing short-term facilitation (releasing more NT per spike due to residual Ca²⁺). The two processes do not interfere — they act on different variables through different mechanisms.

The important implication for your model is that **the LTP/LTD table we built describes what happens to** `g_AMPA_baseline` **over minutes**. Short-term potentiation/depression describes what happens to `released_NT` over milliseconds to seconds. They are different outputs of the same synapse, running in parallel.

If you want to add short-term plasticity explicitly to the behaviour specification it would live entirely in the presynaptic ms and seconds loops as named episodes of existing variables:

```
— ms (presynapse, short-term plasticity):

ShortTermFacilitation: Episode
  — residual Ca_micro > 0 at next spike arrival
  — release_frac in deterministic_release elevated above baseline
  — decays as Ca_micro clears (tau ~100-500 ms)
  — more NT per spike than at rest

ShortTermDepression: Episode
  — N_RRP depleted by rapid successive spikes
  — release_frac unchanged but N_RRP reduced
  — fewer absolute vesicles released per spike
  — recovers via RP→RRP recruitment (seconds)

— seconds (presynapse, short-term plasticity):

Augmentation: Episode  [GAP — not yet modelled]
  — requires second slow Ca2+ trace (tau ~5000 ms)
  — elevated release probability for 5-10 s after burst
  — distinct from spike-by-spike facilitation

PostTetanicPotentiation: Episode  [GAP — not yet modelled]
  — requires very slow trace (tau ~minutes)
  — elevated release probability for minutes after tetanus
  — presynaptic only, no postsynaptic component
```

---

## Signal traveling to the dendrite and soma

This is one of the most important questions in neuroscience and it reveals a gap in the current model — the postsynapse as we have described it is a single compartment, but the real postsynapse is embedded in a spatial structure where location matters enormously.

---

**The physical structure**

The postsynapse sits at the tip of a **dendritic spine** — a tiny mushroom-shaped protrusion, roughly 1 µm across, that branches off the main dendrite shaft. The spine is connected to the dendrite by a narrow neck, which acts as both a diffusion barrier and an electrical resistor. The spine is not just a passive receptor — it is a semi-isolated compartment with its own calcium dynamics, its own molecular machinery, and its own local membrane potential that can differ from the dendrite by tens of millivolts.

From spine to soma the signal travels through three successive stages, each with its own physics:

---

**Stage 1 — Spine to dendrite shaft (µm, microseconds to milliseconds)**

After Ca²⁺ enters through NMDA, two things happen simultaneously in the spine.

The **electrical signal** — the change in V_post from AMPA and NMDA currents — spreads electrotonically from the spine head through the spine neck into the dendrite shaft. This is a passive electrical process governed by cable theory: the spine neck has resistance, which causes voltage attenuation. A strong EPSP in the spine arrives at the dendrite shaft as a smaller depolarisation. The narrower and longer the neck, the more attenuation.

The **chemical signal** — Ca²⁺ itself — diffuses much more slowly and is largely trapped in the spine by the neck geometry and by the calcium buffers and pumps in the spine head. This is deliberate: it means each spine is a private calcium compartment. What happens in one spine does not directly raise Ca²⁺ in the neighbouring spine. This compartmentalisation is what makes synapse-specific plasticity possible — only the spine that received the coincident signal gets potentiated, not all spines on the same dendrite.

---

**Stage 2 — Dendrite shaft to soma (µm to mm, milliseconds)**

Once the electrical signal enters the dendrite shaft it travels toward the soma as a graded potential — not an action potential, just a spreading wave of depolarisation that decays with distance and time. The key variables are the **length constant** (how far the signal travels before decaying to 1/e of its original amplitude, typically 100-500 µm in dendrites) and the **time constant** (how long the signal lasts, typically 10-50 ms).

Dendrites are not passive cables. They contain their own voltage-gated channels — including NMDA receptors on the dendritic shaft, voltage-gated Na⁺ and Ca²⁺ channels, and K⁺ channels that actively shape the signal as it travels. In some neurons, particularly pyramidal cells, a strong enough EPSP can trigger a **dendritic spike** — a locally regenerative event that amplifies the signal and ensures it reaches the soma with enough strength to trigger firing. Dendritic spikes are essentially local action potentials in the dendrite, and they are one of the mechanisms that give individual dendrites computational properties beyond simple summation.

Multiple EPSPs arriving at different spines within a short time window sum together in the dendrite shaft. If they arrive close enough in space and time, their summed depolarisation exceeds threshold at the soma. This spatial and temporal summation is how the neuron integrates thousands of inputs simultaneously.

---

**Stage 3 — Soma integration and axon hillock (point decision, milliseconds)**

The soma collects all the dendritic inputs and performs a threshold comparison. The axon hillock — the junction between the soma and the axon — has the highest density of voltage-gated Na⁺ channels in the neuron and the lowest threshold for firing. When the summed depolarisation at the axon hillock crosses roughly -55 mV (from a resting potential of about -70 mV), an action potential is triggered. This AP then propagates forward down the axon and simultaneously backward up the dendrites as the bAP.

---

**What this means for the model**

The current model has no spatial structure. V_post is a single number representing the entire postsynaptic compartment — there is no distinction between spine voltage, dendritic shaft voltage, and somatic voltage. The bAP is treated as an external input rather than the consequence of somatic threshold crossing fed back to the dendrite.

The missing components that would be needed for a spatially accurate model are:

```
Spine compartment:
  V_spine    — local membrane potential at the spine head
  Ca_post    — spine calcium (already modelled)
  spine_neck_resistance — attenuation from spine to dendrite

Dendrite compartment:
  V_dendrite — shaft potential (sum of attenuated spine EPSPs)
  length_constant — spatial decay of signal along shaft
  dendritic_spike_threshold — if V_dendrite crosses this,
                               local regenerative event

Soma compartment:
  V_soma     — integrated input from all dendrites
  AP_threshold — typically ~15 mV above rest
  fired      — boolean, triggers bAP_train for next cycle
```

The bAP then becomes an output of the soma rather than an independent input:

```
if V_soma > AP_threshold:
    fired = True
    bAP_train.append(current_step)   # feeds back to spine
    V_soma resets via Na/K-ATPase
```

This closes the loop properly: the spine signal travels up, the soma decides whether to fire, and the firing decision travels back down as the bAP that enables NMDA coincidence detection at the very spine that contributed to triggering the somatic AP. The synapse is strengthened only if its contribution was part of what caused the neuron to fire — which is the biological definition of Hebbian learning expressed as a physical circuit.

---

**Why the spine neck is biologically critical**

The spine neck geometry is not fixed — it changes with activity. During LTP, the neck widens and shortens, reducing attenuation and making the spine electrically closer to the dendrite. During LTD, the neck narrows and the spine may retract entirely. This means the structural change of plasticity is not just the number of AMPA receptors — it is also the geometry of the spine itself, which changes how well future signals from that spine will reach the soma. Potentiation makes potentiation more likely not just through more AMPA but through better electrical coupling. This is a physical feedback loop operating at the structural level, on timescales of minutes to hours, that is entirely absent from computational models of this type and may be one of the things that cannot be captured by any purely computational description.