# Commenti

Endurance need is deposited only on interrupted success, not on bare depletion. Each component's DAY block now has a two-condition test: budget gated a behavior AND that behavior was on a successful trajectory (the local definition you specified — rising postsynaptic engagement for pre, climbing calcium for post, active distal spines for dend, and so on). Depletion during useless activity deposits nothing.

Endurance bypasses dopamine. The endurance_need trace gates the NIGHT budget-ceiling adaptation directly, with no neuromodulatory coincidence. This is the homeostatic-versus-associative distinction: strength requires significance, endurance only requires that fuel was the binding constraint on a forming success.
Budget capacity is now fully parallel to structure. Fast budget (occupancy, filled in DAY) versus slow budget_ceiling (capacity, built in NIGHT) mirrors exactly the occupancy-versus-structure distinction. The budget is clamped by its ceiling during DAY.

The two drives compete for one pool. Step 2b draws from the same material and energy as the structural commits in step 2, so building endurance somewhere prevents building strength elsewhere. A connection that is both significant and fuel-limited is the strongest competitor, drawing on both — which can force depotentiation of others.

Decay is by neglect, consistently. Budget ceilings decay when endurance need is not renewed (mitophagy removing idle mitochondria), exactly as structures decay when not maintained.

One thing worth your scrutiny: I kept the endurance need decaying over minutes (intermediate timescale) and cleared at NIGHT, while the budget_ceiling persists like structure. Check whether that split feels right, or whether endurance need should itself persist partially across nights for multi-night metabolic conditioning, the way tags can carry forward.

# Tripartite Synapse — Pseudocode v9
New in v9: BUDGET CAPACITY as an adaptive quantity (endurance), parallel to STRUCTURE (strength)
   - budget_ceiling: slow capacity on the fast budget (like structure is on occupancy)
   - endurance_need trace: deposited when depletion INTERRUPTS A SUCCESSFUL TRAJECTORY
       (not mere depletion — depletion that cut short something on its way to success)
   - NIGHT builds budget_ceiling where fuel was the binding constraint on a valuable outcome
   - structure (strength) ← validated coincidence ; budget_ceiling (endurance) ← interrupted success

---

## Two NIGHT-built capacities, two different drives

```
STRENGTH  = structure ceiling
            driven by: coincidence (2 or 3, per component) + dopamine validation
            answers:   "did a valuable coincidence COMPLETE and get validated?"
            builds:    bigger containers (more slots) → stronger per-event behavior

ENDURANCE = budget ceiling
            driven by: depletion that INTERRUPTED a successful trajectory
            answers:   "did fuel run out exactly when a valuable outcome was forming?"
            builds:    bigger fuel capacity → longer-sustainable behavior
            NO dopamine required — this is metabolic/homeostatic, not associative

Diagnostic combinations:
   high structure tag, low endurance need  → significant + sustainable  → strengthen
   low structure tag, high endurance need  → fuel-limited at verge      → fund endurance
   high both                                → significant + fuel-limited → strengthen + fund
   low both                                 → idle, or failing for non-fuel reasons → let decay
```

---

## Part 1 — Conventions (additions to v8)

```
NEW VARIABLE TYPES:
  ENDURANCE_TRACE = deposited when budget depletion interrupts a SUCCESSFUL trajectory
                    decays over minutes
                    NO dopamine gate (metabolic, not associative)
                    gates NIGHT budget_ceiling adaptation
  BUDGET_CEILING  = slow capacity on the fast budget
                    READ in DAY (clamps how high budget can be / how long behavior sustains)
                    WRITTEN in NIGHT (raised by endurance need, decays when unused)

KEY DISTINCTION:
  budget        = fast occupancy (current fuel level) — consumed/refilled in DAY
  budget_ceiling = slow capacity (max fuel / endurance) — adapted in NIGHT
  (exactly parallel to: occupancy filled in DAY vs structure ceiling built in NIGHT)
```

---

## Part 2 — New Trace and Capacity Variables (per component)

```
// Endurance traces — deposited only on INTERRUPTED SUCCESS
ENDURANCE_TRACE  pre_endurance_need
ENDURANCE_TRACE  post_endurance_need
ENDURANCE_TRACE  dend_endurance_need
ENDURANCE_TRACE  soma_endurance_need
ENDURANCE_TRACE  axon_endurance_need
ENDURANCE_TRACE  astro_endurance_need

// Budget ceilings — slow endurance capacity, WRITTEN in NIGHT
BUDGET_CEILING   pre_budget_ceiling
BUDGET_CEILING   post_budget_ceiling
BUDGET_CEILING   dend_budget_ceiling
BUDGET_CEILING   soma_budget_ceiling
BUDGET_CEILING   axon_budget_ceiling
BUDGET_CEILING   astro_budget_ceiling

// Each DAY budget is now clamped by its ceiling:
//   {c}_budget = clamp({c}_budget, 0, {c}_budget_ceiling)

// New fixed params
FIXED  endurance_threshold      // min endurance_need to trigger ceiling growth
FIXED  capacity_decay_rate      // budget_ceiling decay when unused
FIXED  trajectory_threshold     // min "success trajectory" to count an interruption as costly
```

---

## Part 3 — How Each Component Detects "Interrupted Success"

```
// The endurance signal requires TWO things at the moment of depletion:
//   1. budget gated a behavior (depletion occurred)
//   2. that behavior was on a SUCCESSFUL TRAJECTORY (local definition per component)
// Only their conjunction deposits endurance_need.

PRE   success trajectory = postsynaptic engagement was RISING
                           (release was building a coincidence)
POST  success trajectory = post_fast_trace was APPROACHING Ca_TAG_threshold
                           (calcium was building toward a tag)
DEND  success trajectory = active spines existed DISTAL to the propagation failure point
                           (bAP was needed downstream and got cut off)
SOMA  success trajectory = nuclear Ca was APPROACHING CREB threshold, or
                           firing was successfully recruiting downstream
AXON  success trajectory = propagation failed to ENGAGED boutons (driving active synapses)
ASTRO success trajectory = postsynapse was DEPOLARIZED and WAITING for D-serine
                           (gate needed exactly when synthesis ran out)
```

---
---
# SCOPE: DAY
 Additions shown per component. Existing v8 behavior assumed unless noted.
 Budget is now clamped by budget_ceiling. Endurance need deposited on interrupted success.

---

## PRE | CONTEXT: AP  (additions)
```
scope DAY | context AP:

    // Budget now clamped by its ceiling
    pre_budget = clamp(pre_budget, 0, pre_budget_ceiling)

    // Depletion gate — now also tests success trajectory
    if pre_budget < AP_release_cost:
        suppress(NT_flux)
        // INTERRUPTED SUCCESS? was release building a coincidence downstream?
        if postsynaptic_engagement_rising:    // e.g. post_fast_trace was climbing
            pre_endurance_need += postsynaptic_engagement   // graded by how close to success
            // fuel was the binding constraint on a forming coincidence
        // else: depletion during ineffective firing → NO endurance need (let it fail)
        exit context

    // ... rest of v8 PRE AP behavior unchanged ...
    pre_fast_trace += spike_Ca_influx(input_freq); pre_fast_trace *= decay(τ=100ms)
    Ca_drive = pre_fast_trace / (K_Ca_release + pre_fast_trace)
    if RRP_level > 0:
        NT_flux = RRP_level × Ca_drive
        glutamate += NT_flux × Δt; RRP_level -= NT_flux × Δt
        pre_budget -= NT_flux × fusion_cost
    // ... refill, brake ...
```

## PRE | CONTEXT: NOT_AP  (additions)
```
scope DAY | context NOT_AP:

    // endurance trace decays like other intermediate traces
    pre_endurance_need *= decay(τ=minutes)

    // ... rest of v8 PRE NOT_AP unchanged: budget replenish, refill, tagging ...
    pre_budget += astro_lactate[syn] × pre_fraction + axon_shipment_to_pre
    pre_budget  = clamp(pre_budget, 0, pre_budget_ceiling)
    // ... possible_tagging, tag ...
```

---

## POST | CONTEXT: NOT_bAP  (additions)
```
scope DAY | context NOT_bAP:

    post_budget = clamp(post_budget, 0, post_budget_ceiling)

    // Depletion during receptor trafficking or membrane reset
    if post_budget < required_cost:
        // INTERRUPTED SUCCESS? was calcium climbing toward a tag?
        if post_fast_trace > trajectory_threshold and post_fast_trace_rising:
            post_endurance_need += post_fast_trace    // collapse of a building tag-trajectory
            // fuel (trafficking/reset) was the limit on completing a coincidence
        // truncate the behavior
        // else: depletion during low-calcium activity → no endurance need

    post_endurance_need *= decay(τ=minutes)
    // ... rest of v8 POST NOT_bAP: AMPA, NMDA, STP slot-fill, tagging ...
```

---

## DEND | CONTEXT: bAP  (additions)
```
scope DAY | context bAP:

    dend_budget = clamp(dend_budget, 0, dend_budget_ceiling)

    // bAP propagation may fail partway if budget insufficient
    bAP_local, propagation_reached = propagate_bAP(SOMA.AP_fired, dend_structure, dend_budget)
    dend_budget -= bAP_propagation_cost × propagation_reached

    // INTERRUPTED SUCCESS? were there active spines BEYOND where propagation died?
    if propagation_failed_early and active_spines_distal_to(propagation_reached) > 0:
        dend_endurance_need += active_spines_distal_to(propagation_reached)
        // distal active spines were cut off from the retrograde signal by lack of fuel
    // else: propagation failure with no distal active spines → no endurance need

    // ... rest of v8 DEND bAP: branch Ca trace, integration ...
```

## DEND | CONTEXT: NOT_bAP  (additions)
```
scope DAY | context NOT_bAP:
    dend_endurance_need *= decay(τ=minutes)
    // ... v8 replenish, ship to post, tagging, local translation ...
```

---

## SOMA | CONTEXT: AP  (additions)
```
scope DAY | context AP:

    soma_budget = clamp(soma_budget, 0, soma_budget_ceiling)

    // If budget can't sustain firing during a recruiting train
    if soma_budget < AP_generation_cost:
        // INTERRUPTED SUCCESS? was nuclear Ca climbing toward CREB,
        //                      or was firing recruiting downstream activity?
        if soma_fast_trace > trajectory_threshold and soma_fast_trace_rising:
            soma_endurance_need += soma_fast_trace
            // fuel cut a firing pattern that was achieving integration/CREB approach
        // suppress firing this step
    else:
        // ... normal v8 SOMA AP: fire, deposit 3 traces, tagging ...

    soma_endurance_need *= decay(τ=minutes)
```

---

## AXON | CONTEXT: AP  (additions)
```
scope DAY | context AP:

    axon_budget = clamp(axon_budget, 0, axon_budget_ceiling)

    propagation_reliability = axon_structure.propagation × (1 - failure_rate(axon_fast_trace))
    // budget can further reduce reliability if depleted
    if axon_budget < AP_propagation_cost:
        propagation_reliability *= budget_limited_factor
        // INTERRUPTED SUCCESS? did failure hit ENGAGED boutons (driving active synapses)?
        if failed_boutons_engaged > 0:
            axon_endurance_need += failed_boutons_engaged
            // fuel cut propagation to terminals that were successfully driving synapses
        // else: failure to idle boutons → no endurance need

    axon_endurance_need *= decay(τ=minutes)
    // ... rest of v8 AXON AP ...
```

---

## ASTRO | CONTEXT: CONTINUOUS  (additions)
```
scope DAY | context CONTINUOUS:

    astro_central_budget = clamp(astro_central_budget, 0, astro_budget_ceiling)

    // D-serine release is budget-limited (v8). Now detect interrupted success:
    if glutamate[i] > spillover_threshold:
        Ds_drive = astro_fast_trace[i] / (K_Ca_Dserine + astro_fast_trace[i])
        Ds_wanted = Ds_drive × Ds_max
        Ds_supplied = min(Ds_wanted, astro_central_budget × Ds_fraction)

        if Ds_supplied < Ds_wanted:
            // INTERRUPTED SUCCESS? was postsynapse DEPOLARIZED and waiting for the gate?
            if post_depolarized[i] and post_fast_trace[i] approaching Ca_TAG_threshold:
                astro_endurance_need[i] += (Ds_wanted - Ds_supplied)
                // ran out of synthesis capacity exactly when the gate was needed
            // else: insufficient D-serine but no waiting coincidence → no endurance need

        astro_D_serine[i] += Ds_supplied
        // ... rest of v8 astro overflow handling, tagging ...

    astro_endurance_need[i] *= decay(τ=minutes)
```

---
---
# SCOPE: NIGHT
 v8 steps unchanged EXCEPT: add Step 2b (budget capacity adaptation).
 Budget capacity competes for the SAME material + energy as structure.

---

## Step 1 — Replenish & Distribute  (unchanged from v8)
```
// energy economy: astrocyte → astrosynapses
// material economy: soma → branches/axon → spines/boutons
// next-DAY budgets pre-loaded
```

## Step 2 — Structural Commits (strength)  (unchanged from v8)
```
// each commit raises a STRUCTURE ceiling, gated by tag + material + energy
// driven by COMPLETED VALIDATED COINCIDENCE
```

## Step 2b — Budget Capacity Adaptation (endurance)  ★ NEW
```
scope NIGHT | step 2b:

    // Driven by endurance_need (interrupted success), NOT by tags, NOT by dopamine.
    // Competes for the SAME material + energy pools as structural commits (step 2).
    // → endurance and strength trade off under scarcity.

    for each component c:

        if c_endurance_need > endurance_threshold:
            // fuel was the binding constraint on a valuable outcome → build endurance
            Δcap = min(capacity_expansion_cost,
                       c_material × cap_material_fraction,   // mitochondria need proteins
                       c_energy   × cap_energy_fraction)     // biogenesis needs ATP
            c_budget_ceiling += Δcap
            c_material -= Δcap
            c_energy   -= Δcap × biogenesis_cost
            if Δcap < capacity_expansion_cost:
                queue(c_endurance_deficit → next NIGHT)
            // biological basis: activity-driven mitochondrial biogenesis,
            //                   local fuel-storage expansion

        else:
            // endurance exceeded demand (or failures weren't costly) → let ceiling decay
            c_budget_ceiling -= capacity_decay_rate × Δt_night
            c_material += released_mitochondria(c) × recycling_fraction
            // biological basis: mitophagy — unused metabolic capacity removed,
            //                   proteins returned to pool for components that need them

    // NOTE on competition with strength (step 2):
    //   material/energy spent here cannot fund structural growth there.
    //   a component that is significant (high tag) AND fuel-limited (high endurance_need)
    //   demands both → highest total resource draw → strongest competitor for the pool
    //   → may force heterosynaptic depression / depotentiation elsewhere
```

## Step 3 — Passive Depotentiation  (extended)
```
scope NIGHT | step 3:

    // structures decay unless maintained (v8) ...
    // ALSO: budget_ceilings decay if not reinforced by endurance_need (handled in 2b else-branch)

    // maintenance now must cover BOTH structure and budget_ceiling:
    //   a component maintains its endurance only while it keeps earning endurance_need
    //   unused endurance capacity is the first thing sacrificed under scarcity
    //   (mitochondria are expensive to keep — mitophagy removes idle ones)
```

## Step 4 — Homeostatic Scaling  (unchanged from v8)
## Step 5 — Clear Traces  (extended)
```
scope NIGHT | step 5:
    // v8 clears: fast_traces, possible_tagging, soma timing traces, tags
    // ALSO clear endurance traces (they have served their purpose this cycle):
    all endurance_need = 0
    // budget_ceilings PERSIST (they are slow capacity, like structure)
```

---

## Summary — Two Capacities, Two Drives, One Resource Pool

```
                STRENGTH (structure)            ENDURANCE (budget_ceiling)
DAY signal      coincidence completed +         depletion INTERRUPTED a
                validated (tag set)             successful trajectory (endurance_need)
gate            dopamine required              NO dopamine (homeostatic)
NIGHT builds    bigger slots (per-event power) bigger fuel cap (sustain duration)
competes for    shared material + energy       SAME shared material + energy
decays when     unmaintained (neglect)         unused / failures not costly (mitophagy)

JOINT LOGIC:
   to be remembered AND sustainable, a connection must
     - complete validated coincidences (→ strength), AND
     - either not be fuel-limited, or earn endurance by failing-at-the-verge (→ endurance)
   under scarcity the two drives compete:
     building endurance somewhere spends material that can't strengthen elsewhere
   the system invests endurance specifically where FUEL,
     not structure or significance, was what stood between activity and success.
```

# 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.

Here is the revised abstract pattern, integrating the endurance/budget dimension throughout.

---

Here is the updated abstract pattern, with both ceilings now correctly bounding competitive DAY processes.

---

# The Abstract Pattern

A component operates within two ceilings set by the previous NIGHT: a **structure** that bounds how strongly each behavior can act, and a **budget capacity** that bounds how much fuel the component can hold. Both ceilings bound an active, competitive DAY process — structure bounds how far behavior strength can be filled toward its maximum, budget capacity bounds how far fuel can be replenished toward its maximum — and in both cases the filling competes against other components for a shared resource. During DAY, in each context, the component executes behaviors that draw on budget and deposit fast traces. Two kinds of evidence accumulate: a **tag**, when a local eligibility signal coincides with non-local validation, driving *strength*; and an **endurance need**, when budget depletion interrupts a behavior on a successful trajectory, driving *endurance*. At NIGHT, tags raise structure and endurance needs raise budget capacity, both proportional to available material and energy, both drawing from the same finite pool, so that strength and endurance compete. What is not committed decays for lack of maintenance, and the resources freed partially fund what was.

---

## DAY — The General Form

Every DAY behavior runs within two ceilings and competes for two shared resources.

```
given:   STRUCTURE         // bounds behavior strength (ceiling from NIGHT)
         BUDGET_CEILING    // bounds fuel capacity (ceiling from NIGHT)
in:      CONTEXT           // local or global triggering condition
if:      BUDGET >= cost    // operational fuel available
then:    behavior executes, strength bounded by STRUCTURE
         BUDGET     -= cost
         FAST_TRACE += f(behavior)               // local record deposited
else:    behavior suppressed                     // fuel was the limit
         if behavior was ON A SUCCESSFUL TRAJECTORY:
             ENDURANCE_NEED += g(trajectory)      // fuel interrupted a forming success
```

Two competitive DAY processes fill the two ceilings:

**Strength filling (bounded by STRUCTURE).** Behavior strength rises toward the structural ceiling by competing for local occupancy resources — receptors at the postsynapse, vesicles at the presynapse. A behavior cannot act more strongly than its structure permits, because the occupancy it draws on is itself bounded by the structure.

**Fuel replenishment (bounded by BUDGET_CEILING).** Fuel rises toward the budget ceiling by competing for shared upstream supply — astrocyte lactate, soma shipment. Each component's claim is the gap between its current budget and its ceiling; the shared supply is rationed by these claims:

```
// competitive replenishment — the ceiling bounds the process via the demand
c_demand          = BUDGET_CEILING - BUDGET           // gap below ceiling = claim on supply
total_demand      = sum(c_demand for components on shared supply S)
allocation_factor = min(1, S / (total_demand + ε))
replenishment     = c_demand × allocation_factor      // rationed share
BUDGET           += replenishment                      // never exceeds ceiling (demand was the gap)
S                -= replenishment
```

Neither ceiling is applied as a clamp. Each bounds its process from within: structure is the thing being filled with occupancy, budget_ceiling is the target the replenishment demand reaches toward. A high budget_ceiling is not free even during DAY — it makes a large standing claim on shared fuel, and the component reaches it only if the supply can satisfy that claim against competing claims.

The fast trace drives two parallel processes; depletion drives a third.

**Within the same context** — the fast trace biases the next execution of the same behavior. Short-term modulation. Local, no external signal.

**Across contexts** — the fast trace accumulates into `possible_tagging` above the eligibility threshold. The bridge toward strength. Requires the trace to survive into a NOT/CONTINUOUS context.

**On depletion** — when budget gates a behavior that was succeeding, `endurance_need` accumulates. The bridge toward endurance. Requires the depletion to have interrupted something valuable, not merely to have occurred.

---

### Tag Formation — Non-Local Coincidence (drives STRENGTH)

Strength is associative. The tag requires local eligibility plus non-local validation, the number of coincidences set by the component's spatial scale.

**PRE, DEND, SOMA, AXON, ASTRO — one non-local coincidence:**
```
if FAST_TRACE > eligibility and dopamine > threshold:
    TAG += dopamine × possible_tagging
```

**POST — three coincidences (astrosynapse, soma, organism):**
```
// 1. NOT_bAP: local Ca²⁺ + astrosynapse D-serine → CANDIDATE
if FAST_TRACE > Ca_TAG_threshold and D-serine > threshold:
    post_possible_tagging += FAST_TRACE
// 2. bAP: CANDIDATE + soma fired → amplified above Ca_HIGH
if post_possible_tagging > threshold and bAP arrives:
    FAST_TRACE += bAP_boost
// 3. any context: CANDIDATE + dopamine → STABLE
if post_possible_tagging > threshold and dopamine > threshold:
    TAG += dopamine × post_possible_tagging
```

---

### Endurance Formation — Interrupted Success (drives ENDURANCE)

Endurance is homeostatic, not associative. It requires depletion plus a successful trajectory, the meaning of "successful" set by the component's local function. **No dopamine.**

```
if BUDGET < cost and trajectory_was_succeeding:
    ENDURANCE_NEED += g(trajectory)    // graded by closeness to success
```

Per-component definition of *succeeding*:
- **PRE** — release was driving rising postsynaptic engagement
- **POST** — calcium was climbing toward the tagging threshold
- **DEND** — active spines existed distal to where propagation died
- **SOMA** — nuclear calcium was approaching CREB, or firing was recruiting downstream
- **AXON** — propagation failed to engaged boutons, not idle ones
- **ASTRO** — the postsynapse was depolarized and waiting for D-serine when synthesis ran out

The signal shape is identical everywhere — fuel ran out at the verge of a valuable outcome — only the local definition of "verge" varies.

---

### Trace Recession — The Temporal Behavior

In every NOT/CONTINUOUS context, all traces decay:

```
FAST_TRACE       *= decay(τ_fast)      // ms–s   — closes eligibility window
possible_tagging *= decay(τ_mid)       // s–min  — closes tagging window
ENDURANCE_NEED   *= decay(τ_mid)       // s–min  — closes endurance window
TAG              *= decay(τ_slow)      // hours  — closes commitment window
```

Decay is not a separate behavior — it is the passive consequence of molecular processes. It enforces time windows without any clock: a coincidence must complete, and a depletion must interrupt a success, while the relevant trace is still elevated. Timing is the competition between accumulation and decay.

---

## NIGHT — The General Form

NIGHT raises two ceilings from two kinds of evidence, both drawing on the same finite material and energy.

**Strength commit — driven by tag (validated coincidence):**
```
if TAG > threshold:
    Δstructure = min(expansion_cost, MATERIAL, ENERGY × fraction)
    STRUCTURE += Δstructure × coherence_bonus    // raises the strength ceiling
    MATERIAL  -= Δstructure                       // RECOVERABLE
    ENERGY    -= Δstructure × ATP_cost             // NOT recoverable
```
Coherence bonus when pre, post, and astro tags are all set together — the three synaptic components independently gathered evidence for the same change.

**Endurance commit — driven by endurance need (interrupted success):**
```
if ENDURANCE_NEED > threshold:
    Δcap = min(capacity_cost, MATERIAL, ENERGY × fraction)
    BUDGET_CEILING += Δcap                         // raises the endurance ceiling
    MATERIAL       -= Δcap                          // RECOVERABLE (mitochondria recyclable)
    ENERGY         -= Δcap × biogenesis_cost         // NOT recoverable
// no coherence bonus, no dopamine — endurance is per-component homeostatic
```

The two commits compete for the same material and energy: building endurance somewhere cannot strengthen elsewhere. A component both significant and fuel-limited demands both and is the strongest claimant, potentially forcing decay elsewhere.

**What is not committed decays — by neglect, for both ceilings:**
```
STRUCTURE      -= decay_rate × Δt_night
STRUCTURE      += min(structure_maintenance, maintenance_cost)
BUDGET_CEILING -= capacity_decay_rate × Δt_night
BUDGET_CEILING += min(capacity_maintenance, capacity_cost)
// if maintenance < decay: the ceiling drifts down
//   structure → depotentiation by neglect
//   budget_ceiling → loss of endurance (mitophagy of idle capacity)
// recovered material partially funds the commits above
```

---

## The Pattern in One View

```
TWO CEILINGS, each bounding a competitive DAY process and raised by NIGHT evidence:

  STRUCTURE (strength)         bounds behavior strength;
                               filled in DAY by competing for occupancy;
                               raised in NIGHT by TAG (validated coincidence)

  BUDGET_CEILING (endurance)   bounds fuel capacity;
                               filled in DAY by competing for shared supply;
                               raised in NIGHT by ENDURANCE_NEED (interrupted success)

DAY   behavior runs within both ceilings, both filled competitively
      consumes budget, deposits fast trace
      fast trace + non-local coincidence → TAG            (evidence for strength)
      depletion + interrupted success    → ENDURANCE_NEED  (evidence for endurance)
      traces decay in NOT/CONTINUOUS contexts — windows close

NIGHT TAG            → raise STRUCTURE       (per-event power)
      ENDURANCE_NEED → raise BUDGET_CEILING  (sustainable duration)
      both draw the SAME material + energy → strength and endurance compete
      unmaintained ceilings of either kind decay → freed material funds the rest

A high ceiling of either kind is never free: structure must be filled by winning
occupancy, budget capacity must be filled by winning shared fuel — both against
competing components, every DAY. The system invests STRENGTH where a valuable
coincidence completed and was validated, and ENDURANCE where fuel — not structure,
not significance — was what stood between activity and success. To be both effective
and sustainable, a connection must win on both, at both timescales, against all
others drawing from the same finite pools.
```
# More details

## SOMA

### The Abstract Pattern Applied to Soma Timing

The abstract pattern says: a behavior deposits a trace, the trace decays, and the trace biases the next behavior. For the soma, the AP is the behavior, and **the refractory period and threshold elevation should both be consequences of a single trace deposited by the AP, decaying back toward baseline**. Neither should be a hardcoded duration — both should emerge from the return of the trace to resting conditions.

---

Yes, this is much more consistent with the rest of the architecture. The soma should not compute an explicit rhythm estimate and predict the next input — that is top-down. Instead, the **mismatch itself leaves a trace**, and that trace adjusts the refractory dynamics. Let me think through this carefully.

---

### The Bottom-Up Mechanism

The key event is: **a dendritic input arrives strong enough to fire the soma, but the soma is still refractory.** This is a missed opportunity — the input wanted to fire the cell, but the cell was not ready. This mismatch is the signal.

Each time this happens, it should leave a trace that biases the refractory dynamics toward recovering faster in that timing window — so that next time an input arrives at that phase, the soma is ready. This is potentiation of the refractory recovery, occurring within DAY, driven entirely by the local coincidence of "input wanted to fire" and "soma was not ready."

```
scope DAY | context NOT_AP (within refractory):

    // Detect the mismatch: suprathreshold input during refractory
    if branch_Vm > effective_threshold and soma_Na_inactivation > inactivation_threshold:
        // Input arrived but soma could not fire — missed coincidence
        refractory_alignment_trace += (branch_Vm - effective_threshold)
                                       × soma_Na_inactivation
        // graded: stronger input + deeper refractory → larger trace
        // this is the "potentiation" signal for faster recovery
```

The `refractory_alignment_trace` then biases the recovery rate of the inactivation trace:

```
    // Recovery rate biased by accumulated alignment trace
    recovery_rate = base_recovery_rate × (1 + refractory_alignment_trace)
    soma_Na_inactivation *= decay(τ_Na / recovery_rate)
    // more alignment trace → faster recovery → soma ready sooner next time
```

---

### Why This Is Bottom-Up

There is no rhythm estimation, no prediction of the next input time, no computed inter-input interval. The soma does not model its input. It simply notices, locally and reactively, that an input arrived when it was not ready, and leaves a trace that makes it recover faster. Over many such mismatches at the same phase, the recovery speeds up at that phase specifically — and the soma ends up aligned with its input rhythm **without ever representing that rhythm**.

The alignment is an emergent statistical consequence of many local mismatch events, exactly as a potentiated synapse becomes tuned to its input without representing what it is tuned to. The phase-coupling appears, but nothing in the soma computed it.

---

### Depotentiation as Neglect — Not Explicit

Now the crucial part you raised: the depotentiation of refractory alignment must occur as a **consequence of not potentiating**, not as an explicit opposing mechanism.

The `refractory_alignment_trace` decays continuously. If mismatches keep happening at a particular phase, the trace is continuously replenished and the fast recovery is maintained. If mismatches stop happening — because the input rhythm changed, or because the alignment succeeded and inputs now arrive when the soma is ready — then the trace is no longer replenished and **decays back toward baseline on its own**.

```
    // No explicit depotentiation — just decay when not reinforced
    refractory_alignment_trace *= decay(τ_alignment)
    // if mismatches continue → trace replenished → fast recovery maintained
    // if mismatches stop → trace decays → recovery returns to baseline
```

This is exactly parallel to synaptic depotentiation by neglect. The soma does not actively slow its recovery when alignment is no longer needed. It simply stops receiving the mismatch signal that was keeping the recovery fast, and the recovery drifts back to baseline because the trace that accelerated it is no longer reinforced.

There is an elegant self-limiting property here. Once the soma is well-aligned, inputs arrive when it is ready, so there are no more mismatches, so the alignment trace stops being replenished and begins to decay. This would slowly de-align the soma — until inputs start arriving during refractory again, regenerating the mismatch and re-potentiating the alignment. The system settles into a dynamic equilibrium where just enough mismatch occurs to maintain just enough alignment. The soma hovers at the edge of alignment, continuously corrected by the residual mismatches that its imperfect alignment produces.

---

### The Full Bottom-Up Soma Timing

```
scope DAY | context AP:

    effective_threshold = soma_structure.baseline_threshold
                          × (1 + soma_adaptation)
                          × neuromod_factor(NE_level, ACh_level)

    can_fire = (soma_Na_inactivation < inactivation_threshold)

    if branch_Vm > effective_threshold and can_fire:
        AP_fired = True
        soma_budget -= AP_generation_cost

        // Deposit traces from the AP
        soma_Na_inactivation += AP_amplitude       // fast — refractory
        soma_adaptation      += AP_contribution     // slow — spike train threshold
        soma_fast_trace      += nuclear_Ca_influx() // slow — plasticity tagging

scope DAY | context NOT_AP:

    // MISMATCH DETECTION — bottom-up alignment signal
    if branch_Vm > effective_threshold and soma_Na_inactivation > inactivation_threshold:
        // input wanted to fire but soma was refractory — missed coincidence
        refractory_alignment_trace += (branch_Vm - effective_threshold)
                                       × soma_Na_inactivation
        // local potentiation of recovery — no prediction, no rhythm model

    // Recovery biased by alignment trace
    recovery_rate = base_recovery_rate × (1 + refractory_alignment_trace)
    soma_Na_inactivation *= decay(τ_Na / recovery_rate)    // faster if aligned
    soma_adaptation      *= decay(τ_adaptation)
    soma_fast_trace      *= decay(τ_nuclear)

    // Alignment trace decays — depotentiation by neglect, not explicit
    refractory_alignment_trace *= decay(τ_alignment)
    // maintained only while mismatches continue
    // self-limiting: good alignment → fewer mismatches → trace decays →
    //                slight de-alignment → mismatches return → re-potentiation

    // ... budget replenishment, shipments, tagging as before ...
```

---

### The Conceptual Payoff

This makes the soma's temporal alignment obey exactly the same principles as everything else in the system:

A behavior leaves a trace — here the missed coincidence leaves the alignment trace.

The trace biases future behavior — here it accelerates recovery so the next input at that phase succeeds.

Potentiation is the active drive — the soma actively speeds up recovery in response to mismatch.

Depotentiation is neglect — the alignment trace decays when mismatches stop, with no explicit opposing process.

The system finds equilibrium through the residual of its own imperfection — just enough mismatch persists to maintain just enough alignment.

And critically, the soma achieves temporal prediction — firing in phase with its input rhythm — **without ever representing the rhythm**. The prediction is implicit in the structure of the recovery dynamics, built up from purely local, reactive, bottom-up trace deposits. This is the same way a potentiated synapse "predicts" that its input will be significant without representing the prediction: the prediction is the physical bias left by past experience, not a computed expectation. The soma's phase-coupling is the temporal version of the synapse's weight — both are implicit predictions encoded as physical bias, both built bottom-up from local coincidence, both maintained by reinforcement and lost by neglect.

## Energy depletion in Presynapse

how does the budget and energy influence the model. If for example a presynapse has no more energy variuos times during day, what happens?

Good question. Let me trace through exactly what happens when energy is repeatedly depleted, following the mechanics already in the pseudocode.

---

### The Immediate Effect — Behavior Suppression

When `pre_budget < AP_release_cost`, the pseudocode does:

```
if pre_budget < AP_release_cost:
    suppress(NT_flux)
    exit context
```

So the immediate consequence of an energy-depleted bouton is **silence** — it does not release neurotransmitter for that AP, regardless of how strong the incoming spike was. The AP arrives, but nothing comes out the other side. This is biologically real: ATP-depleted boutons fail to release because the VATPase cannot refill vesicles and the calcium pumps cannot maintain the gradients that drive release.

---

### The Cascade of Consequences Within DAY

A single depletion is recoverable — the bouton refuels from astrocyte lactate in the next NOT_AP context and resumes. But **repeated depletion during DAY** sets off a cascade that runs through the entire trace and tagging machinery.

**No release means no glutamate means no downstream trace.** When the bouton is silent, no glutamate reaches the cleft. The postsynapse receives no AMPA current, its NMDA channels do not open, and `post_fast_trace` does not rise. The astrosynapse detects no spillover, so `astro_fast_trace` does not rise and no D-serine pulse is released. The entire synaptic event simply does not happen. A bouton that is energy-depleted at the moment a significant pattern arrives causes that pattern to be invisible to the postsynapse — the synapse fails to participate in whatever the network is doing.

**No participation means no eligibility.** Because the bouton did not release, `pre_fast_trace` is not elevated by a release event (it still rises from calcium influx, but without the reinforcing facilitation of successful release). More importantly, the postsynapse, having received no input, accumulates no `post_possible_tagging`. When dopamine arrives to validate the moment, there is nothing to validate at this synapse — the eligibility window is empty. The synapse misses the tagging opportunity entirely.

**Missing the tag means missing the NIGHT commit.** Since no tag was set during DAY, the synapse has nothing to draw structural resources with during NIGHT. It does not potentiate. And because the system's depotentiation is by neglect, **a synapse that fails to potentiate is automatically on the path to depotentiation** — it receives only maintenance allocation, and if other synapses potentiated and drew down the shared pool, even maintenance may be insufficient.

---

### The Deeper Consequence — Energy Depletion Becomes Structural Depression

Here is the important emergent property: **repeated energy depletion at a bouton during DAY leads to its structural depression during NIGHT, even though no depression signal was ever sent.**

The chain is entirely passive:

```
repeated pre_budget depletion in DAY
    → bouton silent during significant events
    → no glutamate release
    → no post_fast_trace, no post_possible_tagging
    → no tag set (pre or post)
    → no NIGHT structural commit at this synapse
    → only maintenance allocation received
    → if pool depleted by other synapses' potentiation:
        maintenance insufficient
    → pre_structure and post_structure decay
    → DEPOTENTIATION
```

The energy-starved synapse is outcompeted not because it was marked for depression but because it could not generate the activity needed to claim resources. Energy availability during DAY therefore directly determines which synapses can even enter the competition for NIGHT potentiation.

---

### The Feedback Loop — Depression Reduces Future Energy Demand

There is a stabilizing feedback here. A depotentiated synapse has smaller `pre_structure` — a smaller active zone, fewer docking slots, lower release probability. This means it costs **less energy to operate**. So a synapse that was energy-starved and consequently depotentiated now has lower energy demands, making it less likely to be energy-starved in the future.

```
energy depletion → depotentiation → smaller structure → lower energy demand
    → less likely to deplete → stabilizes at a low-activity equilibrium
```

The synapse settles into a low-energy, low-structure, low-activity state. It is not dead — it still operates at baseline — but it has been demoted from the pool of synapses competing for potentiation. Energy scarcity has selected it out.

---

### Why This Is Functionally Important

This is not a bug — it is a resource-allocation mechanism with real computational value.

**Energy availability acts as a second gate on plasticity, parallel to the neuromodulatory gate.** Dopamine asks "was this worth saving?" Energy asks "can this synapse afford to participate?" A synapse must pass both gates to be potentiated. This means the system preferentially potentiates synapses that are both behaviorally significant AND metabolically sustainable. A synapse that cannot sustain its own activity is not a good candidate for strengthening, because strengthening it would only increase its energy demand and make it fail more often.

**Local energy competition implements a form of spatial sparsification.** Boutons on the same axon share `axon_budget` and ultimately the same astrocytic lactate supply. When many boutons are active simultaneously, the shared energy is divided among them, and the weakest — those with the least efficient structure or the least reliable input — deplete first and fall silent. This automatically sparsifies activity: under energy pressure, only the most robust synapses keep firing, and they are the ones that get potentiated. The system concentrates its limited resources on its strongest connections.

**The astrocyte's energy delivery becomes a control signal.** Because the astrocyte controls lactate distribution across its territory, it has indirect control over which synapses can sustain activity and therefore which can be potentiated. A region of the astrocyte territory that is well-perfused and well-fueled supports vigorous plasticity. A region that is metabolically stressed — perhaps because of high overall demand or reduced vascular supply — suppresses plasticity in its synapses regardless of their activity. This couples the metabolic state of the tissue directly to its capacity to learn.

---

### What Repeated Depletion Looks Like Over Days

If a bouton is chronically energy-starved across multiple DAY cycles — perhaps because it is in a metabolically compromised region, or because it is competing with many highly active neighbors — the trajectory is:

```
Day 1: depletes occasionally → misses some events → weak tag → partial commit
Day 2: smaller structure → still depletes under load → weaker tag → less commit
Day 3: structure decaying → maintenance insufficient → depotentiation accelerates
...
Equilibrium: minimal structure, minimal energy demand, minimal participation
             synapse survives but is functionally silent
             resources it would have consumed now available to neighbors
```

This is a reasonable model of what happens to synapses in metabolically stressed tissue — they do not die immediately, but they are progressively silenced and depotentiated, freeing their resources for synapses in healthier regions. It is also a model of how chronic metabolic limitation — aging, vascular disease, mitochondrial dysfunction — would manifest as a gradual loss of plasticity capacity: not through any depression signal, but through the simple inability of energy-starved synapses to participate in the activity that would let them claim resources.

The energy budget is therefore not just a constraint that occasionally blocks behavior — it is a continuous selective pressure that shapes which synapses thrive and which fade, operating silently in parallel with the explicit activity-and-reward-driven plasticity, and ultimately determining the metabolic sustainability of whatever the system chooses to remember.

## Three parallel competitive resource economies
The neuronal structural economy — soma produces material, distributed through dendrite to spines and through axon to boutons, competed for by tagged synapses during NIGHT.
The astrocytic energy economy — astrocyte cell body produces lactate, distributed to perisynaptic processes, competed for by active synapses during DAY in proportion to their clearance demand.
The soma's own energy economy — soma mitochondria fuel AP generation and shipping, competed for by the soma's own functions.
All three share the same logic: a central producer with a capped output, distribution to peripheral consumers, demand-weighted allocation, and a self-reinforcing coupling where stronger consumers both demand and receive more. And all three ultimately bottom out at the same vascular glucose ceiling — the astrocyte directly, the soma through its own glucose uptake.
The deep consequence is that a synapse must win on both economies to be potentiated. It must generate enough activity to pull lactate from the astrocyte (energy economy) AND accumulate enough tag to draw material during NIGHT (structural economy). A synapse that wins the structural competition but cannot pull energy will be unable to sustain the activity that justified its potentiation — it will be a large, expensive structure that keeps going silent. A synapse that pulls energy but never accumulates a tag stays metabolically supported but structurally weak. Only synapses that win both — active enough to be fueled, significant enough to be tagged — achieve and maintain full potentiation. The two economies together implement a stringent joint criterion: persistent significant activity that the metabolic infrastructure can sustain.
