Skip to content

feat(forget): capacity-aware adaptive threshold for forget_weak_memories (SCM-style) #90

@Dewinator

Description

@Dewinator

Why

The 2026-04-28 reflection-tick (mandate e830dcf0-fb19-4655-97a1-f05289068f3f) looked outward after the prior two structural concerns (anemic consolidation → closed #80; cross-project trait leakage → open #84) had been addressed. The next layer of the brain-core roadmap that has a concrete, well-cited, low-risk borrowable pattern is capacity-aware forgetting.

mycelium today uses a fixed threshold for forget_weak_memories(0.05, 7) (supabase/migrations/014_fix_forgotten_inserts.sql, called from scripts/nightly-sleep.mjs:127 and cron 009_cognitive_cron.sql:33). The docstring on the sleep step says "synaptic downscaling (Tononi SHY)", but the implementation only archives below a static cutoff — it does not raise pressure as the graph grows, and it does not proportionally rescale the population. With memory count drifting upward (167 in the mycelium project, ~710 globally) and the #80 admission gate now making lessons rarer (good for lessons, but the raw memory layer underneath keeps accumulating), a fixed cutoff drifts out of calibration.

The SCM (Sleep-Consolidated Memory) paper formalizes this as an adaptive retention threshold that rises as graph size exceeds a target capacity:

S(c) = 0.8·I(c) + 0.2·(1 − exp(−0.01·Δt)), with an adaptive threshold rising as |graph| > target_capacity, increasing pruning pressure proportionally. (SCM §3.6, Eq. 9, Algorithm 1 lines 18-25)

The same paper documents a calibration bug worth borrowing as a regression test: with β₂ = 0.4 the new-concept boost prevented forgetting; correcting to β₂ = 0.2 yielded 90.9 % noise reduction (§4.3, Fig. 5). That kind of weight-coefficient sanity check belongs in the test fixture.

What

Replace the two fixed parameters of forget_weak_memories(strength_threshold, min_age_days) with a capacity-aware adaptive threshold, scoped per project so one project's bloat does not suppress another project's pruning pressure (this dovetails with #84 without depending on it).

Scope:

  1. New SQL function forget_weak_memories_adaptive(target_capacity_per_project INT DEFAULT 500, base_threshold FLOAT DEFAULT 0.05, min_age_days INT DEFAULT 7) that:
    • Computes per-project memory counts (excluding pinned and archived).
    • For each project where count > target_capacity, raises the effective threshold as base_threshold · (count / target_capacity) (linear; SCM-equivalent).
    • Applies the existing soft-archive logic (audit trail via forgotten_memories is preserved — mycelium stays ahead of SCM here).
  2. Cron entry in a new migration calls the adaptive variant; the old forget_weak_memories(0.05, 7) stays for compatibility but is no longer scheduled.
  3. One regression test that (a) seeds 600 memories in a single project with target=500, (b) asserts the effective threshold rose, (c) asserts a non-trivial number was archived, (d) asserts pinned and recent (<7d) memories are untouched. Borrow the SCM β₂ sanity-check pattern: assert that the importance-weighted boost does not suppress forgetting at the configured ratio.

Out of scope (future, separate issues):

  • Proportional Tononi SHY downscaling of memory_relations.weight (NREM stage) — still the right next step, but a bigger change to a different table.
  • FAMA-style benchmark for forgetting correctness (arxiv 2604.20006) — also worthwhile, separate issue.

Sources

Memory references

  • Reflection mandate: e830dcf0-fb19-4655-97a1-f05289068f3f
  • Brain-Core Phase-1-bis-5 Roadmap (Vergessen / Schlafen sub-phase): 9cd76e25-10bf-4216-b629-c2363d211b8d
  • mycelium Refokussierung 2026-04-26 (mycelium = ein Gehirn, brain-core focus): b21bdbd3-1b96-494c-9b72-552b8e25ff32
  • Verfassung (3 pillars): 57388366-4807-47d8-aed3-819ac21b1722
  • Roadmap-deviation hard-rule (proposals must stay inside Phase 1-5): d9d264fd-a819-4059-9b74-a3d2a41927c4

Verfassung check

  • Souveränitätneutral / mildly strengthened. Forgetting happens locally; no data crosses node boundaries. A node drowning in unbounded local memory cannot exercise sovereignty efficiently, so capacity-aware pruning is sovereignty-friendly.
  • Generalisierung-vor-sharingneutral. This change operates strictly below the lesson layer; lesson distillation, the sharing currency, is untouched. Lessons are explicitly never archived by forget_weak_memories (their kind is not in scope of the function).
  • Diversitätstrengthened. Per-project capacity scoping prevents one heavy project (e.g. vectorworks product-data) from monopolizing the forget-pressure budget and starving another project's pruning. Diverse contexts stay diverse.

No pillar is weakened.

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposed-by-agentIssue suggested by the autonomous agent — needs user upgrade to agent-eligible

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions