Files
organism/elements/neuron/appunti/2026-06-22-tripartite-synapse_v12.md
T
2026-06-22 11:56:47 +02:00

21 KiB
Raw Blame History

Tripartite Synapse — Pseudocode v12

Companion: tripartite_synapse_v12_biology.md. Changes from v11: SENSE renamed TRACE; new ADJUST group (compute local operating parameters from structure + traces + modulators); reference order puts EVALUATE before ADJUST and DECAY; NIGHT labeled with the same group grammar; all // GROUP headers sit at one indentation column so they stand out.


Functional groups (uniform grammar, applied within each context)

RECEIVE   take in resources + signals that arrived from outside
EVALUATE  judge behavior — strength (needs dopamine) + endurance (interrupted success)
ADJUST    compute local operating parameters from structure + traces + modulators
BEHAVE    the component's defining action, using the adjusted parameters
EMIT      send out — signals (messages) and resources (shipments) across the boundary
TRACE     deposit the fast trace that records the behavior
RECOVER   refill own private pools consumed by behaving
DECAY     let traces recede, closing their windows

Groups sit inside the DAY contexts (Option A). Execution contexts (AP/bAP/CONTINUOUS) carry ADJUST/BEHAVE/EMIT/TRACE and endurance-EVALUATE; replenishment contexts (NOT_AP/NOT_bAP) carry RECEIVE/strength-EVALUATE/RECOVER/DECAY. Not every component uses every group. Group order within a context follows data dependencies (e.g. where a fast trace both drives a behavior and records it, TRACE precedes ADJUST). NIGHT runs the same grammar on ceilings.


Conventions

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

DAY      budget · fast_trace · possible_tag · endurance_need
BRIDGE   tag (POST: CANDIDATE→STABLE)
NIGHT    energy (not recoverable) · material (recoverable) · structure · budget_ceiling

LOCALITY only local state + arrived signals; no component reads another's internal state.

CLEFT MESSAGE CHANNELS              SHIPMENT CHANNELS
  glutamate     PRE → POST, ASTRO     soma_ship_dend SOMA→DEND
  astro_Dserine ASTRO → POST          soma_ship_axon SOMA→AXON
  retro_NO      POST → PRE (+)        dend_ship_post DEND→POST
  retro_eCB     POST → PRE ()        axon_ship_pre  AXON→PRE

Primitives (return the increment; caller applies it)

sat(x, K) = x / (K + x)

fill(pool, ceiling, rate, cost, budget) -> amount:        // PRIVATE reserve
    amount = min(rate, ceiling - pool)·Δt;  budget -= amount·cost;  return amount

refill(c from supply S) -> amount:                         // CONTESTED supply
    demand = c.budget_ceiling - c.budget
    factor = min(1, S / (Σ demand over components on S + ε));  S -= demand·factor
    return demand·factor

ship(from_budget, demand_sig, frac, cost) -> amount:       // DIRECTED transfer
    amount = min(from_budget·frac, demand_sig);  from_budget -= amount·(1+cost);  return amount

SHARED parameters

dopamine  NE  ACh                         // organism broadcasts (external)
glucose  geometry                         // physical (external)
elig  dop_thr  tag_thr  tag_expiry        // strength gates (universal)
traj_thr  endur_thr                       // endurance gates (universal)
decay_rate  capacity_decay_rate  recycle  homeostatic_ceiling
coherence_factor  assembly_cost  biogenesis_cost  maint_cost


DAY


PRE

// PARAMETERS  K_release · release_cost · fusion_cost · vatpase_cost · spillover · brake
// INTERFACE
//   EMIT      glutamate → POST, ASTRO
//   RECEIVE   astro_lactate[syn] ← ASTRO ; axon_ship_pre ← AXON ; retro_NO, retro_eCB ← POST
//             pre_material ← AXON(NIGHT) ; pre_energy ← SOMA(NIGHT)
//   READ      glutamate (own cleft, autobrake) ; dopamine (gates tag)
//   OWN       pre_structure{slot_ceiling, VGCC_coupling, refill_ceiling} ; pre_budget_ceiling
//   EMERGENCY shockwave_lockdown ← ASTRO

DAY | AP:
    // TRACE     (residual Ca²⁺ from this spike — also drives release)
    pre_fast_trace += spike_Ca(input_freq)
    // ADJUST    (release drive from trace + received DSE brake)
    drive = sat(pre_fast_trace, K_release) × (1 - retro_eCB_local)
    // BEHAVE    (release or fail)
    if pre_budget < release_cost:
        suppress(NT_flux)
        if pre_fast_trace > traj_thr:                      // EVALUATE (endurance): retro_NO-confirmed
            pre_endurance_need += pre_fast_trace × (1 + retro_NO_local)
        exit
    if RRP > 0:
        NT_flux = RRP × drive;  RRP -= NT_flux·Δt;  pre_budget -= NT_flux·fusion_cost
        // EMIT
        glutamate += NT_flux·Δt
    if glutamate > spillover: drive *= brake               // own-cleft autobrake

DAY | NOT_AP:
    // RECEIVE
    retro_NO_local = retro_NO;  retro_eCB_local = retro_eCB
    pre_budget += refill(pre from astro_lactate[syn] + axon_ship_pre)
    // EVALUATE  (strength)
    if pre_fast_trace > elig: pre_possible_tag += pre_fast_trace
    if dopamine > dop_thr and pre_possible_tag > tag_thr:
        pre_tag += dopamine × pre_possible_tag
    // RECOVER   (RRP from private reserve)
    RRP += fill(RRP, pre_structure.slot_ceiling, pre_structure.refill_ceiling, vatpase_cost, pre_budget)
    // DECAY
    pre_fast_trace *= decay(100ms);  pre_possible_tag *= decay(s)
    pre_endurance_need *= decay(min);  pre_tag *= decay(hr)
    dopamine *= decay(ms);  retro_NO *= decay(s);  retro_eCB *= decay(s)

POST

// PARAMETERS  K_AMPA · AMPA_Ca · AMPA_cost · NMDA_cost · bAP_cost · pka_cost · traffic_cost
//             req_cost · Mg_eject · Dserine_thr · Ca_STP · Ca_TAG · eCB_thr · drift · baseline
//             NO_synth_cost · eCB_synth_cost
// INTERFACE
//   EMIT      retro_NO (+), retro_eCB () → PRE
//   RECEIVE   astro_lactate[syn] ← ASTRO ; dend_ship_post ← DEND
//             post_material ← DEND(NIGHT) ; post_energy ← SOMA(NIGHT)
//   READ      glutamate ← PRE ; astro_Dserine ← ASTRO ; bAP (dend_structure.bAP_fidelity) ; dopamine
//   OWN       post_structure{slot_ceiling, spine_volume, reserve_ceiling} ; post_budget_ceiling
//   EMERGENCY shockwave_lockdown ← ASTRO

DAY | NOT_bAP:
    // RECEIVE
    post_budget += refill(post from astro_lactate[syn] + dend_ship_post)
    // ADJUST    (AMPA drive from arrived glutamate)
    a = sat(glutamate, K_AMPA)
    // BEHAVE    (SOURCE 1 AMPA: current + small Ca + begins Mg ejection)
    AMPA_current = a × AMPA_surface;  Vm += AMPA_current;  post_budget -= AMPA_cost
    // TRACE     (Ca deposited by AMPA)
    post_fast_trace += AMPA_Ca·AMPA_current
    // BEHAVE    (SOURCE 2 NMDA: large Ca on local coincidence)
    if Vm > Mg_eject and astro_Dserine > Dserine_thr and glutamate > 0:
        post_fast_trace += NMDA_Ca(glutamate)·rise_speed();  post_budget -= NMDA_cost
        // EMIT  (+) NO/BDNF: "release reached a responsive target"
        retro_NO += NO_emit(post_fast_trace);  post_budget -= NO_synth_cost
    // EMIT      () endocannabinoid (DSE) when over-driven
    if Vm > eCB_thr: retro_eCB += eCB_emit(Vm);  post_budget -= eCB_synth_cost
    post_fast_trace *= decay(ms)
    // BEHAVE    (STP: fill slots from private reserve ; else STD drift = consequence)
    if post_fast_trace > Ca_STP:
        AMPA_surface = min(AMPA_surface + Ca_insert(post_fast_trace), post_structure.slot_ceiling)
        post_budget -= traffic_cost
    else:
        AMPA_surface = max(AMPA_surface - drift·Δt, baseline)
    // EVALUATE  (endurance: own Ca was climbing toward a tag when fuel failed)
    if post_budget < req_cost and post_fast_trace > traj_thr and post_fast_trace_rising:
        post_endurance_need += post_fast_trace
    // EVALUATE  (strength: CANDIDATE then STABLE via dopamine)
    if post_fast_trace > Ca_TAG: post_possible_tag += post_fast_trace;  post_budget -= pka_cost
    if dopamine > dop_thr and post_possible_tag > tag_thr:
        post_tag += dopamine × post_possible_tag
    // DECAY
    post_possible_tag *= decay(min);  post_endurance_need *= decay(min)
    post_tag *= decay(hr);  dopamine *= decay(ms)

DAY | bAP:
    // BEHAVE    (SOURCE 3 bAP: depolarization + Ca, amplifies existing signal)
    Vm += bAP_depol × dend_structure.bAP_fidelity;  post_budget -= bAP_cost
    // TRACE     (supralinear boost only if a CANDIDATE is present)
    if post_possible_tag > Ca_TAG: post_fast_trace += bAP_Ca_boost()

DEND

// PARAMETERS  prop_cost · branch_Ca_cost · integrate_cost · translate_cost
// INTERFACE
//   EMIT      bAP_local → POST ; branch_Vm → SOMA ; dend_ship_post → POST
//   RECEIVE   astro_lactate[branch] ← ASTRO ; soma_ship_dend ← SOMA ; dend_material, dend_energy ← SOMA(NIGHT)
//   READ      SOMA.fired ; POST.Vm + spine spillover ; dopamine ; ACh
//   OWN       dend_structure{bAP_fidelity(pos), translation_ceiling, transport_speed} ; dend_budget_ceiling

DAY | bAP:
    // ADJUST    (propagation strength from structure)  -> inside propagate()
    // BEHAVE    (propagate bAP; may fall short if depleted)
    bAP_local, reached = propagate(SOMA.fired, dend_structure.bAP_fidelity, dend_budget, geometry)
    dend_budget -= prop_cost × reached
    // EVALUATE  (endurance: propagation cut short while branch strongly active)
    if reached < full and dend_fast_trace > traj_thr:
        dend_endurance_need += dend_fast_trace
    // TRACE
    dend_fast_trace += bAP_Ca(bAP_local) + spine_spillover();  dend_budget -= branch_Ca_cost
    // EMIT      (integrated voltage to soma ; propagated bAP already reached spines)
    branch_Vm = integrate(POST.Vm, spines);  dend_budget -= integrate_cost

DAY | NOT_bAP:
    // RECEIVE
    dend_budget += refill(dend from astro_lactate[branch] + soma_ship_dend)
    // EVALUATE  (strength)
    if dend_fast_trace > elig: dend_possible_tag += dend_fast_trace
    if dopamine > dop_thr and dend_possible_tag > tag_thr:
        dend_tag += dopamine × dend_possible_tag
    // ADJUST    (commit threshold lowered by attention)
    commit_threshold *= 1/(1 + ACh·gain)
    // EMIT      (ship budget to spines; demand = post tag)
    dend_ship_post = ship(dend_budget, post_demand, post_ship_frac, ship_cost)
    // BEHAVE    (local translation if tagged — fills dend capacity faster)
    if dend_tag > tag_expiry and dend_budget > translate_cost: dend_budget -= translate_cost
    // DECAY
    dend_fast_trace *= decay(300ms);  dend_possible_tag *= decay(s)
    dend_endurance_need *= decay(min);  dend_tag *= decay(hr)

SOMA

// PARAMETERS  ap_cost · nuclear_cost · creb_cost · mito_output · inactivation · ap_amp · ap_contrib
//             base_recovery · τ_Na · τ_adapt · τ_nuclear · τ_align
// INTERFACE
//   EMIT      fired → AXON (propagate) + DEND (bAP) ; soma_ship_dend → DEND ; soma_ship_axon → AXON
//   RECEIVE   self (mitochondria, ROOT) ; branch_Vm ← DEND
//   READ      dopamine ; NE ; ACh
//   OWN       soma_structure{baseline_threshold, AP_reliability, synthesis_ceiling} ; soma_budget_ceiling

DAY | AP:
    // ADJUST    (threshold from structure + adaptation + neuromodulators ; refractory gate)
    threshold = soma_structure.baseline_threshold × (1 + soma_adaptation) × neuromod(NE, ACh)
    can_fire  = soma_Na_inactivation < inactivation
    // BEHAVE    (fire if able)
    if branch_Vm > threshold and can_fire:
        if soma_budget < ap_cost:
            if soma_fast_trace > traj_thr and soma_fast_trace_rising:    // EVALUATE (endurance)
                soma_endurance_need += soma_fast_trace
            exit
        fired = True;  soma_budget -= ap_cost              // EMIT: fired → AXON, DEND
        // TRACE     (three traces from one AP)
        soma_Na_inactivation += ap_amp                     // → refractory (emergent)
        soma_adaptation      += ap_contrib                 // → threshold rise
        soma_fast_trace      += nuclear_Ca();  soma_budget -= nuclear_cost
        // EVALUATE  (strength)
        if soma_fast_trace > elig: soma_possible_tag += soma_fast_trace
        if dopamine > dop_thr and soma_possible_tag > tag_thr:
            soma_tag += dopamine × soma_possible_tag
        soma_budget -= creb_cost

DAY | NOT_AP:
    // RECEIVE   (self-replenish from private root ; integrate input)
    soma_budget += fill(soma_budget, soma_budget_ceiling, mito_output, 0, soma_budget)
    branch_Vm = integrate(DEND.branch_Vm, branches)
    // BEHAVE    (bottom-up refractory alignment: suprathreshold input during refractory)
    if branch_Vm > threshold and soma_Na_inactivation > inactivation:
        soma_refractory_alignment += (branch_Vm - threshold) × soma_Na_inactivation
    // EMIT      (ship downstream; demand = propagated tags)
    soma_ship_dend = ship(soma_budget, dend_demand, dend_ship_frac, ship_cost)
    soma_ship_axon = ship(soma_budget, axon_demand, axon_ship_frac, ship_cost)
    // RECOVER   (inactivation recovery sped by alignment trace → emergent refractory)
    recovery = base_recovery × (1 + soma_refractory_alignment)
    soma_Na_inactivation *= decay(τ_Na / recovery)
    // DECAY
    soma_adaptation *= decay(τ_adapt);  soma_fast_trace *= decay(τ_nuclear)
    soma_refractory_alignment *= decay(τ_align)            // self-limiting
    soma_possible_tag *= decay(s);  soma_endurance_need *= decay(min)
    soma_tag *= decay(hr);  dopamine *= decay(ms)

AXON

// PARAMETERS  prop_cost · budget_factor
// INTERFACE
//   EMIT      APs_delivered → PRE (propagation) ; axon_ship_pre → PRE
//   RECEIVE   soma_ship_axon ← SOMA ; astro_lactate[shaft] ← ASTRO ; axon_material, axon_energy ← SOMA(NIGHT)
//   READ      SOMA.fired ; dopamine
//   OWN       axon_structure{propagation, transport_ceiling, mito_density} ; axon_budget_ceiling

DAY | AP:
    // ADJUST    (reliability from structure  load-driven failure)
    reliability = axon_structure.propagation × (1 - fail(axon_fast_trace))
    // BEHAVE    (propagate; degraded if depleted)
    if axon_budget < prop_cost:
        reliability *= budget_factor
        if axon_fast_trace > traj_thr:                     // EVALUATE (endurance)
            axon_endurance_need += axon_fast_trace
    delivered = fired × reliability;  axon_budget -= prop_cost × delivered   // EMIT → boutons
    // TRACE
    axon_fast_trace += delivered;  axon_fast_trace *= decay(s)

DAY | NOT_AP:
    // RECEIVE
    axon_budget += refill(axon from soma_ship_axon + astro_lactate[shaft])
    // EVALUATE  (strength)
    if axon_fast_trace > elig: axon_possible_tag += axon_fast_trace
    if dopamine > dop_thr and axon_possible_tag > tag_thr:
        axon_tag += dopamine × axon_possible_tag
    // EMIT      (ship to boutons; demand = pre tag)
    axon_ship_pre = ship(axon_budget, pre_demand, pre_ship_frac, ship_cost)
    // DECAY
    axon_fast_trace *= decay(s);  axon_possible_tag *= decay(s)
    axon_endurance_need *= decay(min);  axon_tag *= decay(hr)

ASTRO

// PARAMETERS  K_Dserine · Ds_max · Ds_frac · Ds_cost · EAAT_cost · lactate_cost · spillover · overload
// INTERFACE
//   EMIT      astro_lactate[i] → pre/post/dend budgets ; astro_Dserine[i] → POST (gate)
//   RECEIVE   glucose (ROOT) ; astro_material, astro_energy ← cell body (NIGHT)
//   READ      glutamate ← PRE (clearance + spillover) ; dopamine
//   OWN       astro_structure{perisynaptic_distance⁻¹, EAAT, Dserine_tonic, ECM} ; astro_budget_ceiling
//   EMERGENCY emits shockwave_lockdown on overload

DAY | CONTINUOUS:                                          // per astrosynapse i
    // RECEIVE   (root production, capped by glucose)
    astro_central_budget += glycolysis(glucose)·Δt
    // ADJUST    (demand weights across territory)
    for each i: demand[i] = clearance_load[i] × astro_structure[i].delivery_eff
    factor = min(1, astro_central_budget / (Σ demand·lactate_cost + ε))
    // EMIT      (demand-weighted lactate to all components)
    for each i:
        astro_lactate[i] = demand[i] × factor;  astro_central_budget -= astro_lactate[i]·lactate_cost
    // BEHAVE    (clear glutamate ; supply tonic D-serine)
    glutamate[i] -= astro_structure[i].EAAT × glutamate[i]·Δt;  astro_central_budget -= clearance·EAAT_cost
    astro_Dserine[i] += astro_structure[i].Dserine_tonic·Δt
    if glutamate[i] > spillover:
        // TRACE
        astro_fast_trace[i] += mGluR_Ca();  astro_fast_trace[i] *= decay(s)
        // BEHAVE + EMIT  (D-serine pulse: demand-driven, budget-limited)
        want = sat(astro_fast_trace[i], K_Dserine) × Ds_max
        got  = min(want, astro_central_budget × Ds_frac)
        astro_Dserine[i] += got;  astro_central_budget -= got·Ds_cost
        // EVALUATE  (endurance: ran out of synthesis under high own demand)
        if got < want and astro_fast_trace[i] > traj_thr:
            astro_endurance_need[i] += (want - got)
        // EVALUATE  (strength)
        if astro_fast_trace[i] > elig: astro_possible_tag[i] += astro_fast_trace[i]
        if dopamine > dop_thr and astro_possible_tag[i] > tag_thr:
            astro_tag[i] += dopamine × astro_possible_tag[i]
    // DECAY
    astro_possible_tag[i] *= decay(s);  astro_endurance_need[i] *= decay(min);  astro_tag[i] *= decay(hr)
    // EMERGENCY
    if astro_fast_trace[i] > overload: emit(shockwave_lockdown)

Special — Shockwave Lockdown

DAY or NIGHT | OVERLOAD:
    Vm = HYPERPOLARIZED;  AMPA_surface = mass_internalize() → post reserve
    axon_fast_trace += overdrive();  astro_central_budget -= emergency_cost


NIGHT

The same grammar on ceilings: RECEIVE production, EVALUATE/ADJUST the commits, BEHAVE (build ceilings), DECAY (unmaintained ceilings recede). Runs once per cycle, not per spike.

NIGHT | 1  RECEIVE + EMIT  (replenish and distribute)
    astro_central_{budget,energy,material} += overnight_*(glucose, …)·Δt        // RECEIVE
    soma_{budget,energy} += overnight_*()·Δt ; soma_material += CREB_synth(soma_tag)·Δt  // RECEIVE (bottleneck)
    for each i with astro_tag[i] > tag_expiry:  w = astro_tag[i]/Σastro_tag      // ADJUST (weights)
        astro_energy[i] += astro_central_energy·w;  astro_material[i] += astro_central_material·w  // EMIT
    dend_material += soma_material·f_dend ; axon_material += soma_material·f_axon ; soma_material -= … // EMIT
    post_material += dend_material·f_spine ; pre_material += axon_material·f_bouton                    // EMIT
    {pre,post,dend,axon}_energy += soma_energy·f[·] ; {…}_budget += astro_lactate_reserve·f[·]·Δt

NIGHT | 2  EVALUATE + BEHAVE  (strength commits → raise structure)
    coherence = (pre_tag, post_tag, astro_tag all > tag_expiry) ? coherence_factor : 1   // ADJUST
    for each c with c_tag > tag_expiry:                                                    // EVALUATE
        Δ = min(slot_cost, c_material, c_energy·f)                                          // BEHAVE
        c_structure += Δ × (coherence if c in {pre,post,astro} else 1)
        c_material -= Δ;  c_energy -= Δ·assembly_cost;  if Δ < slot_cost: queue(→ next NIGHT)

NIGHT | 2b EVALUATE + BEHAVE  (endurance commits → raise budget_ceiling ; no dopamine ; competes w/ 2)
    for each c with c_endurance_need > endur_thr:                                           // EVALUATE
        Δ = min(cap_cost, c_material·f_cap, c_energy·f_cap)                                 // BEHAVE
        c_budget_ceiling += Δ;  c_material -= Δ;  c_energy -= Δ·biogenesis_cost;  if Δ<cap_cost: queue

NIGHT | 3  DECAY + RECOVER  (both ceilings decay by neglect ; material recovered)
    maint = (total_material - consumed) × maint_frac / synapse_count
    for each synapse:                                                                       // DECAY
        {pre,post,dend,astro}_structure      -= decay_rate·Δt
        {pre,post,dend,astro}_budget_ceiling -= capacity_decay_rate·Δt
        if maint ≥ maint_cost: structure += full_maint ; budget_ceiling += full_cap_maint
        else:                  structure += maint·frac ; budget_ceiling += maint·cap_frac
    for each synapse with net_change < 0:                                                    // RECOVER
        {pre,post,astro}_material += |net_change|·recycle·frac          // material recovered, energy not

NIGHT | 4  BEHAVE  (homeostatic scaling)
    if soma_tag > homeostatic_ceiling:
        s = homeostatic_ceiling / soma_tag
        for each synapse: post_structure.slot_ceiling *= s ; pre_structure.slot_ceiling *= s
        soma_material += Σ reduction·recycle

NIGHT | 5  DECAY  (clear traces)
    all fast_trace, possible_tag, endurance_need = 0
    soma_Na_inactivation = soma_adaptation = soma_refractory_alignment = 0
    for each tag: if tag < tag_expiry: tag = 0             // else carry forward
    // structure and budget_ceiling PERSIST

One-view summary

DAY    per context: RECEIVE → EVALUATE → ADJUST → BEHAVE/EMIT/TRACE → RECOVER → DECAY
       behavior runs within structure (strength) and budget_ceiling (endurance),
       both filled competitively (refill = contested, fill = private, ship = directed)
       fast_trace + dopamine        → tag            (strength evidence)
       depletion + interrupted LOCAL success → endurance_need (endurance evidence)
NIGHT  same grammar on ceilings: tag → structure ; endurance_need → budget_ceiling
       both draw one pool (compete) ; unmaintained ceilings decay → freed material recycles
LOCAL  every evaluation uses only own state + arrived signals; coupling is via channels.