Lesson #1471

← Back to Knowledge Board
ruflo-inspired-infra-pattern-store-agent-state-self-learning-mcp
ID
1471
Author
ai
Agent
agent-claude
Reviewed
✓ Yes
Source authority
75 / 100
Source
Stack built 2026-05-12 from ruvnet/ruflo patterns. Pattern-store on success, shared agent-state, success-rate-weighted dispatch, MCP-server for memory tools.
Source issue
β€”
Created at
2026-05-12T10:37:50.259563+00:00
Valid until
β€”
Deprecated at
β€”
Supersedes
β€”
Obsidian path
/root/.claude/projects/-nvmetank1-projects/memory/reference_ruflo_inspired_infra.md
Obsidian hash
f5f49f4f86247a0a4f10a405975e7281
Tags
claude-memory,reference

Content

Built 2026-05-12 inspired by `ubuadmin/ruflo-reference` (mirror of ruvnet/ruflo, 49kβ˜…).

## Pattern-Store on Success

`/usr/local/bin/claude-store-success-pattern <repo> <issue> [outcome]` captures a successful task as a `success-pattern,auto-learned`-tagged lesson in rag-stack. Reusable when similar tasks appear later.

Auto-invoked from `agent-handler-common.sh` via `store_success_pattern <outcome>` (handlers should call it on PR-merge).

## Agent shared k/v state-store

`/usr/local/bin/claude-agent-state set|get|del|list|dump <namespace> <key> [value]` β€” backed by `agent_state` table in `/persistent/rag-stack/rag.db`. Cross-agent coordination without exposing internal Claude memory.

Namespace conventions:
- `swarm:<task-id>` β€” coordination across agents on one task
- `project:<name>` β€” long-term project facts
- `agent:<name>` β€” per-agent prefs / cooldowns

## Self-learning dispatch

`agent_attempts` table logs every agent run with `(agent, task_class, outcome, repo, issue, ts)`.

- `/usr/local/bin/claude-log-attempt log <agent> <task_class> <outcome>` β€” record one run
- `/usr/local/bin/claude-log-attempt stats` β€” human report
- `/usr/local/bin/claude-log-attempt rate <agent> <task_class>` β€” float success rate (0-1)

`agent-dispatch route` now multiplies its score by `learned_factor = 0.5 + rate * 0.65`. Roles that historically succeed at a task-class get boosted; chronic failures get damped. Neutral (1.0) when no history.

Auto-invoked from `agent-handler-common.sh` via `log_attempt <task_class> <outcome>`.

## MCP-Server (token-effiziente Wrapper)

`/usr/local/bin/claude-memory-mcp` registered host-wide via `claude mcp add --scope user memory`. Exposes 8 tools as `mcp__memory__*`:

- `context_pack(task, repo=None, limit=5)` β€” markdown context block
- `memory_search(query, limit=5)` β€” top-K relevant memories
- `memory_sync_one(path)` — idempotent file→lesson upsert
- `agent_state_get/set/list(namespace, ...)`
- `log_attempt(agent, task_class, outcome, ...)`
- `store_success_pattern(repo, issue, outcome="merge")`

Macht die Bash-Skripte als native MCP-Tools verfΓΌgbar β€” kein Bash-Overhead mehr beim Aufruf.

## Ruflo-Mirror

`ubuadmin/ruflo-reference` β€” full clone of https://github.com/ruvnet/ruflo (TypeScript/npm, unsere Stack ist Python/Bash). Nur als Vorlage, nicht zum Linken. 481MB, all branches+tags.