Skip to content

Yield Framework Audit: v0.33.0 findings and action plan #355

@jkbennitt

Description

@jkbennitt

Yield Framework Audit — Mnemonic v0.33.0

Full codebase audit through the Yield framework lens, covering compounding assets, cleverness debt, leverage inventory, iteration friction, hardcoded judgment, and scaling ceilings.


Previous Findings (from v0.24.0 audit)

# Finding Status
1 Encoding finalization duplication (~140 lines) Still exists
2 store.Store god interface (now 102 methods) Still exists, worse
3 cmd/mnemonic/main.go monolith (3341 lines) Still exists
4 FTS5 column mismatch in CLAUDE.md RESOLVED — code fixed, docs stale
5 Config fallback helpers duplicated 3 ways Improved but still 3 patterns
6 O(n²) embedding search RESOLVED — proper in-memory index
7 MCP server monolith (internal/mcp/server.go) Still exists
8 HeuristicFilter goroutine leak (no cancellation) Still exists
9 Consolidation magic numbers Improved — 33 named config fields
10 ctx/cancel struct field anti-pattern in agents Still exists

New Findings

1. CosineSimilarity duplicated across 4 files

Identical function copy-pasted in multiple packages. Any fix or optimization must be applied 4 times. Highest priority DELETE — extract to a shared internal/mathutil or similar.

2. Hardcoded CORS origins in ws.go

Not derived from config. Should be configurable.

3. Encoding agent constructor leaks a context

Creates a context in the constructor that gets replaced in Start() — the original is never cancelled.

4. 90+ entries in hardcoded heuristic filter lists

internal/agent/perception/heuristic.go has static keyword/path lists that should be in config or learned from feedback data.

5. Stale FTS5 Known Issue in CLAUDE.md

The FTS5 column mismatch is fixed in code but still listed as a known issue. Misleads future sessions.

6. SearchByConcepts uses LIKE '%concept%' with OR

Scaling ceiling at ~5K memories. Should use proper FTS or a concept index.


Compounding Assets (invest further)

  • Event bus architecture — clean, minimal, agents genuinely decoupled
  • Feedback-driven association tuning — user ratings adjust retrieval quality over time
  • Spread activation retrieval — 11-step pipeline, core value proposition
  • Multi-resolution memory model — salience decay, Hebbian strengthening, consolidation cycles
  • Embedding index — now properly indexed, scales with data

Cleverness Debt (highest risk)

  • Encoding finalization duplication: encodeMemory() and finalizeEncodedMemory() implement the same ~140-line finalization path independently. Changes to one won't propagate to the other.
  • Store god interface at 102 methods: Every new feature, every test mock, every agent must satisfy the full interface. Adding one method forces changes in 3+ files.
  • HeuristicFilter goroutine leak: cleanupLoop() goroutine has no cancellation mechanism — runs forever even if the filter is GC'd.

Scaling Ceilings

If the system gets 100x more usage/data:

  1. SearchByConcepts with LIKE queries breaks first (~5K memories)
  2. Single SQLite write connection (SetMaxOpenConns(1)) serializes all reads too
  3. In-memory embedding index — loads all embeddings at startup, fine to ~100K but memory-bound beyond that
  4. Consolidation pairwise clustering — O(n²) cluster detection

Action Plan

AMPLIFY

  • Event bus, feedback loop, spread activation, embedding index

DELETE (quick wins)

  • Delete 3 duplicate CosineSimilarity implementations (~15 min)
  • Remove stale FTS5 Known Issue from CLAUDE.md (~2 min)
  • Fix HeuristicFilter goroutine leak — add done channel (~30 min)

REPLACE (structural improvements)

  • Extract shared persistEncodedMemory() to eliminate encoding duplication (~1 hour)
  • Decompose store.Store into composable sub-interfaces (MemoryReader, MemoryWriter, AssociationStore, PatternStore, etc.)
  • Consolidate 3 different config fallback helper patterns into single shared utility
  • Replace LIKE '%concept%' concept search with proper FTS or concept index
  • Move hardcoded heuristic lists (90+ entries) to config

DEFER (fine for now)

  • main.go monolith — annoying but functional
  • MCP server monolith — same
  • Consolidation tunables — configurable now, learn from data later
  • ctx/cancel struct field anti-pattern — works, not idiomatic

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions