The synapse uses three interlocking signal systems to translate present activity into future behavioral bias. Ca²⁺ is the universal event recorder — each compartment reads its concentration dynamics differently (amplitude and speed of rise in the postsynapse, residual accumulation in the presynapse, IP3-triggered waves in the astrocyte), so the same ion encodes distinct instructions depending on where and how it appears. cAMP/PKA is the contextual gate: driven by neuromodulatory broadcast (dopamine, norepinephrine), it doesn't write changes itself but determines whether the Ca²⁺ signal gets committed to permanent structure — by priming AMPA receptor insertion, silencing the LTD phosphatase machinery via DARPP-32, and activating CREB-driven gene expression for structural proteins. mGluRs provide the overflow sensing layer: when glutamate spills beyond the cleft, group II/III mGluRs on the presynapse activate a Gi-mediated autoinhibitory brake, while group I mGluRs on the astrocyte trigger the IP3→Ca²⁺→D-serine cascade that amplifies NMDA coincidence detection — a push-pull architecture that simultaneously throttles excessive release and widens the postsynaptic learning window.
Together these three systems form a hierarchical filter: Ca²⁺ asks did something happen?, mGluRs ask was it excessive?, and cAMP/PKA asks was it worth saving? — and only when all three align does the synapse commit to rewriting its future response.
The key architectural decision in this pseudocode is the separation into three explicit layers that feed into a single commit_to_structural_change function. Each layer answers one question independently before the final AND-gate runs — Ca²⁺ detects the event, mGluRs assess its magnitude, and cAMP/PKA validates its context. Notice also that mGluR layer has a push-pull side effect that feeds back into the Ca²⁺ layer (astro_Ca_local is updated by mGluR5_activation), making the system not a strict pipeline but a loop — the overflow sensor actively reshapes what the event recorder sees next.