Commit 908a57e
omc-fibtier: Fibonacci-tier memory primitive
User's idea: context grows linearly in time but its IMPORTANCE is
power-law. Recent matters at full detail; older matters as abstraction.
Encode both axes by structuring the context buffer as Fibonacci-sized
tiers that fold upward.
Tier 1: 1 slot (current focus)
Tier 2: 2 slots (active sub-themes)
Tier 3: 3 slots (recent decisions)
Tier 4: 5 slots (session arc)
Tier 5: 8 slots (session history)
Tier 6: 13 slots (multi-session themes)
Tier 7: 21 slots (long-term patterns)
...
When tier N exceeds cap, its oldest TWO entries fold together into
one (concatenation + new canonical hash), the folded entry promotes
upward to tier N+1, and the cascade continues recursively.
API:
fibtier_new(max_tiers)
fibtier_push(mem, content) add a new entry, cascade folds
fibtier_query(mem, query, top_k) substrate-distance-ranked search
fibtier_stats(mem) occupancy / pushes / folds / evicted
fibtier_render(mem) LLM-readable prompt string
fibtier_fold_default(a, b) the fold rule (concat + new hash)
Composes with everything OMC already shipped:
- fnv1a_hash identity per entry (kernel-compatible)
- attractor_distance substrate distance metric
- Fibonacci attractor table the tier sizes themselves
Demo (examples/fibtier_conversation.omc, 100 synthetic turns):
Pushes 100 conversation turns into a 7-tier memory.
Result after 100 turns:
Occupancy: [1, 1, 3, 5, 7, 1, 0]
Total stored: 18 entries (representing 100 turns of content)
Folds: 82 (entries collapsed upward)
Evicted: 0
Memory stays bounded at 18 entries regardless of conversation length.
Each fold's content traces lineage back to source canonical hashes.
Query demo:
query "fibonacci tiers" → top 3 substrate-distance matches across
tiers 2, 3, 4 (most recent + folded-historical entries).
Tests (examples/tests/test_fibtier.omc): 8/8 pass:
- tier sizes are Fibonacci
- capacity lookup
- push-one lands in tier 1
- push-two promotes (no fold yet)
- push-three fills tier 2 to cap (still no fold)
- push-four triggers first fold (cascade to tier 3)
- render produces nonempty string
- capacity growth is geometric (sum check)
Honest scope:
- Fold = concatenation (not LLM summarization). Entry size grows
linearly with fold-count. For real use, swap default fold for an
LLM-summarize fold via py_callback — substrate captures structure;
LLM captures meaning.
- Single-process in-memory. Persistent fibtier (back-by-kernel) is
a natural extension — each entry becomes a kernel store entry,
folds become kernel writes.
- No eviction-by-similarity yet; folds always pick oldest-two. A
smarter fold would pick closest-pair (by substrate distance) to
consolidate semantically-related entries before age-based pairs.
This is the substrate-native memory primitive the project's been
building toward. Composes naturally with omc-kernel + codec + OMC-
PROTOCOL. The "context window as Fibonacci-tiered DAG" architecture.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent ea251f4 commit 908a57e
3 files changed
Lines changed: 548 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
0 commit comments