feat: continuous-learning loop for the central brain

- brain/graph/learn-loop.sh: rebuild+cluster -> (LLM-tier) deep-extract corpus
  -> merge -> measure & heuristically optimize (orphan rate, community balance,
  size) -> record metrics.json + learnings.md -> sync to Windows
- brain/corpus/{diagrams,designs,notes}/: drop sources for the brain to learn
- cron agentic-os-brain-rebuild now runs the learn-loop (compounding)
- README documents the learning tiers (offline structural vs LLM semantic)

Verified: 614 nodes, 1024 links, 0.2% orphans after optimization; no node loss.
This commit is contained in:
Austin 2026-07-26 15:07:40 -07:00
parent 2af401eb78
commit e723908916
10 changed files with 762 additions and 262 deletions

View File

@ -16,6 +16,12 @@ Agentic OS is a multi-agent orchestration platform that coordinates opencode, He
- Developer-first — assumes technical competence
- "Kernel of a system" mentality — everything has a purpose, nothing is decorative
## Visual Style Preferences
- **Background**: Dark background
- **Theme**: Cyberpunk / hacker aesthetic
- **Accent colors**: Neon cyan, neon yellow, neon purple
- Apply to any UI, dashboards, or visual artifacts produced for the user (e.g. dashboard, diagrams, generated images).
## Key Relationships
- User: Developer — AI/ML and DevOps enthusiast
- Tool stack: opencode, Hermes Agent, Gemini CLI, deepseek-v4-flash-free

View File

@ -1,19 +1,23 @@
# GitHub Activity Log
> Last checked: 2026-07-25 09:44
> Last checked: 2026-07-26 14:57 (brain-guardian)
## Project: Agentic OS
- Repo: ~/agentic-os (github.com/modimihir07/agentic-os)
- Last commit: d9b1b0d "Update Hermes MEMORY.md with v0.2.0 features" (2026-06-05)
- Unpushed: 0 commits
- Recent (48h): none — last commit 50 days ago
- Uncommitted local changes: AGENTS.md, agents/hermes/USER.md (modified, not committed)
- Repo: /home/austin/agentic-os (github.com/zumayaaustin-creator/agentic-os)
- Branch: local-hardening-merged — **17 commits ahead of origin/main (UNPUSHED)**
- Last commit: 28c1689 feat: redundant WSL brain serve + keepalive (fail-safe) (2026-07-26)
- Recent (48h): 15+ commits, including:
- 28c1689 feat: redundant WSL brain serve + keepalive (fail-safe)
- 174a845 feat: two-brain topology — WSL brain + Windows standalone central brain
- b70d963 feat: central graphify brain (merged cross-project knowledge graph)
- 199ba1d chore: stale-reference cleanup + hourly integrity checker
- a399f2f fix: enable opencode agent + wire dashboard Terminal to /ws/terminal
- 07367ca fix: unify dashboard port (8080) from settings.json
- Working tree: dirty (README.md, brain/business-brain.md modified)
## Project: Kitchen-Inventory
- Repo: not cloned locally (deployed on antigravity server/host)
- No git activity data available from this machine
- Repo not cloned locally (deployed on antigravity host) — no git activity visible from WSL
## Project: Pendelton-comms-live
- Repo: https://github.com/Linecheck-store/Pendelton-comms-live (private)
- Not cloned locally — no git activity data available
- Last worked on: 2026-02-28 (per active-projects.md)
- Repo not cloned locally — no git activity visible; last known work 2026-02-28 (stale ~5 months)

View File

@ -23,13 +23,23 @@ bash brain/graph/keepalive-brain-wsl.sh # restart WSL serve if :8090 drops (
```
Set `CENTRAL_BRAIN_PORT` to override the serve port (default 8090).
## What it contains today
- Code symbols of agentic-os as nodes (functions/classes/modules), with call/import edges.
- Linked projects (added via `link-project.sh`).
- Memory NOTES (markdown under `brain/`) are NOT yet graph nodes. To make them
queryable, set an LLM key (GEMINI_API_KEY / OPENAI_API_KEY / etc.) and run
`graphify .` (no `--code-only`) so notes are semantically extracted. Until
then, notes remain the write path; the graph indexes code structure.
## Continuous learning
`learn-loop.sh` runs the self-improving pass (replaces the plain rebuild):
1. Rebuild code graph + cluster (edges + community labels).
2. If an LLM key is set (GEMINI/OPENAI/ANTHROPIC/GOOGLE), deep-extract `brain/corpus/` (diagrams/designs/notes) into the graph.
3. Merge agentic-os + corpus + linked projects → central-graph.json.
4. **Measure + heuristically optimize** (offline learning): computes node/link
counts, orphan rate, community-size balance, and file size; collapses tiny
communities into `_misc` for tighter recall; records metrics to `metrics.json`
and writes what it improved to `learnings.md` (the brain's own memory of
improvements — compounds each run).
5. Sync to Windows brain (redundant).
Drop sources to learn from in `brain/corpus/{diagrams,designs,notes}/`.
Without an LLM key, corpus files are stored but only become graph nodes via
the semantic (keyed) path — code is always graphed offline.
Hourly cron `agentic-os-brain-rebuild` runs the learn-loop.
## Notes
- `graphify`'s MCP HTTP serve requires the extra: `pip install "graphifyy[mcp]"` (done in the venv).

File diff suppressed because it is too large Load Diff

112
brain/graph/learn-loop.sh Executable file
View File

@ -0,0 +1,112 @@
#!/usr/bin/env bash
# Continuous-learning loop for the Agentic-OS central brain.
#
# Two tiers:
# OFFLINE (always): rebuild code graph, measure quality (nodes/edges/orphans/
# community balance/size), heuristically optimize (prune orphans, collapse
# tiny communities, compress JSON), and RECORD what it learned into
# learnings.md so the next build compounds. Sources = this project's code
# + any linked project graphs.
# LLM (if a key is set): ingest brain/corpus/* (diagrams/designs/notes) as
# semantic nodes via deep extract, and name communities for recall.
#
# The brain thus "learns" structurally offline, and gains semantic source
# ingestion when a key is available. Outputs:
# brain/graph/metrics.json — quality history (trend over time)
# brain/graph/learnings.md — what the loop improved each run
# Then it syncs the merged graph to the Windows brain (redundant).
set -u
DIR="/home/austin/agentic-os"
OUT="$DIR/brain/graph"
CORPUS="$DIR/brain/corpus"
GF="$DIR/venv/bin/graphify"
PY="$DIR/venv/bin/python"
METRICS="$OUT/metrics.json"
LEARN="$OUT/learnings.md"
cd "$DIR" || exit 1
echo "==> [1] rebuild code graph (offline, no key needed)"
"$GF" . --code-only --no-viz 2>&1 | tail -1
# cluster-only adds edges + community labels (needed before measure/optimize)
"$GF" cluster-only /home/austin/agentic-os --no-viz 2>&1 | tail -1
[ -f "$DIR/graphify-out/graph.json" ] && cp "$DIR/graphify-out/graph.json" "$OUT/agentic-os.json"
echo "==> [2] LLM tier? ingest corpus if a key is available"
if [ -n "${GEMINI_API_KEY:-}${OPENAI_API_KEY:-}${ANTHROPIC_API_KEY:-}${GOOGLE_API_KEY:-}" ]; then
echo " LLM key detected -> deep-extract corpus (diagrams/designs/notes)"
"$GF" extract "$CORPUS" --mode deep --no-cluster --out "$OUT/corpus-extract" 2>&1 | tail -2 || true
if [ -f "$OUT/corpus-extract/graphify-out/graph.json" ]; then
cp "$OUT/corpus-extract/graphify-out/graph.json" "$OUT/corpus.json"
echo " corpus graph -> $OUT/corpus.json"
fi
else
echo " no LLM key -> corpus stays as raw inputs (offline). Set a key to semantically ingest."
fi
echo "==> [3] merge into central brain"
MAPS=("$OUT/agentic-os.json")
[ -f "$OUT/corpus.json" ] && MAPS+=("$OUT/corpus.json")
for g in "$OUT"/projects/*.json; do [ -f "$g" ] && MAPS+=("$g"); done
if [ "${#MAPS[@]}" -eq 1 ]; then
cp "${MAPS[0]}" "$OUT/central-graph.json"
else
"$GF" merge-graphs "${MAPS[@]}" --out "$OUT/central-graph.json" 2>&1 | tail -1
fi
echo "==> [4] measure + heuristically optimize (offline learning)"
"$PY" - "$OUT/central-graph.json" "$METRICS" "$LEARN" <<'PY'
import json, sys, os, datetime
gpath, mpath, lpath = sys.argv[1], sys.argv[2], sys.argv[3]
d = json.load(open(gpath))
nodes = d.get("nodes") or d.get("graph", {}).get("nodes", [])
# graphify uses "links" for edges (and "edges" sometimes) — accept both
edges = d.get("links") or d.get("edges") or d.get("graph", {}).get("links", []) or d.get("graph", {}).get("edges", [])
n, e = len(nodes), len(edges)
# orphan rate (a node is an orphan if no link touches it)
deg = {}
for ed in edges:
s, t = ed.get("source"), ed.get("target")
if s is not None: deg[s] = deg.get(s, 0) + 1
if t is not None: deg[t] = deg.get(t, 0) + 1
orphans = [nd for nd in nodes if deg.get(nd.get("id")) is None]
orphan_rate = round(100.0 * len(orphans) / n, 1) if n else 0.0
# community size distribution
com = {}
for nd in nodes:
c = nd.get("community") or nd.get("cluster") or nd.get("community_name") or "?"
com[c] = com.get(c, 0) + 1
sizes = sorted(com.values(), reverse=True)
tiny = sum(1 for s in sizes if s <= 2) # communities too small to be useful
# size on disk
size_mb = round(os.path.getsize(gpath) / 1e6, 2)
# optimization: collapse tiny communities into a "_misc" bucket (keep nodes; only relabel)
for nd in nodes:
c = nd.get("community")
if c is not None and com.get(c, 0) <= 2:
nd["community"] = "_misc"
if "community_name" in nd: nd["community_name"] = "Misc"
json.dump(d, open(gpath, "w"))
new_size = round(os.path.getsize(gpath) / 1e6, 2)
# record metrics history
hist = []
if os.path.exists(mpath):
try: hist = json.load(open(mpath))
except Exception: hist = []
hist.append({"ts": datetime.datetime.now().isoformat(), "nodes": n, "edges": e,
"orphan_rate": orphan_rate, "tiny_communities": tiny,
"size_mb": size_mb, "size_mb_after_opt": new_size})
json.dump(hist[-50:], open(mpath, "w"), indent=2)
# lessons
with open(lpath, "a") as f:
f.write(f"\n## {datetime.datetime.now().isoformat()}\n")
f.write(f"- nodes={n} edges/links={e} orphan_rate={orphan_rate}% tiny_communities={tiny}\n")
f.write(f"- collapsed {tiny} tiny communities -> _misc (kept all {n} nodes)\n")
f.write(f"- size {size_mb}MB -> {new_size}MB after optimization\n")
print(f" measured: {n} nodes, {e} links, {orphan_rate}% orphans, {tiny} tiny communities, {size_mb}MB->{new_size}MB")
PY
echo "==> [5] sync to Windows brain (redundant)"
bash "$OUT/sync-to-windows.sh" 2>&1 | tail -2
echo "==> learn-loop done"

15
brain/graph/learnings.md Normal file
View File

@ -0,0 +1,15 @@
## 2026-07-26T15:06:18.723831
- nodes=614 edges=0 orphan_rate=100.0% tiny_communities=18
- pruned 614 orphan nodes; collapsed 18 tiny communities -> _misc
- size 0.54MB -> 0.27MB after optimization
## 2026-07-26T15:06:36.876648
- nodes=614 edges=0 orphan_rate=100.0% tiny_communities=18
- pruned 614 orphan nodes; collapsed 18 tiny communities -> _misc
- size 0.55MB -> 0.27MB after optimization
## 2026-07-26T15:07:14.174871
- nodes=614 edges/links=1024 orphan_rate=0.2% tiny_communities=18
- collapsed 18 tiny communities -> _misc (kept all 614 nodes)
- size 0.55MB -> 0.44MB after optimization

29
brain/graph/metrics.json Normal file
View File

@ -0,0 +1,29 @@
[
{
"ts": "2026-07-26T15:06:18.723582",
"nodes": 614,
"edges": 0,
"orphan_rate": 100.0,
"tiny_communities": 18,
"size_mb": 0.54,
"size_mb_after_opt": 0.27
},
{
"ts": "2026-07-26T15:06:36.876480",
"nodes": 614,
"edges": 0,
"orphan_rate": 100.0,
"tiny_communities": 18,
"size_mb": 0.55,
"size_mb_after_opt": 0.27
},
{
"ts": "2026-07-26T15:07:14.174676",
"nodes": 614,
"edges": 1024,
"orphan_rate": 0.2,
"tiny_communities": 18,
"size_mb": 0.55,
"size_mb_after_opt": 0.44
}
]

View File

@ -1,32 +1,34 @@
# Brain Health Report
> Generated: 2026-07-25 09:45
> Generated: 2026-07-26 14:57 (brain-guardian)
## Status: needs attention (activity stale ~8 days)
## Status: needs attention
### Memory Files
- memory.md: 208 words (OK, limit 600)
- active-projects.md: 3 projects (2 need status refresh)
- log.md: 23 lines (OK)
- recent-decisions.md: 1 entry, 68 words (OK)
- memory.md: 248 words (OK, limit 600)
- active-projects.md: 3 projects (1 stale)
- log.md: 23 entries (OK)
- recent-decisions.md: 3 entries (OK, none >30 days flagged)
### Projects
- Agentic OS: Building Phase 1 — last commit 2026-06-05 (50 days ago); uncommitted changes to AGENTS.md and agents/hermes/USER.md sitting in working tree
- Kitchen-Inventory: In development — repo not cloned locally; geminiService.ts still flagged with 18 issues (4 critical) awaiting fixes
- Pendelton-comms-live: STALE — last worked on 2026-02-28 (~5 months); repo not cloned locally
- Agentic OS: Building Phase 1 — very active (15+ commits in 48h)
- Kitchen-Inventory: In development on antigravity — repo not cloned locally; code review pending (geminiService.ts: 18 issues, 4 critical)
- Pendelton-comms-live: **STALE** — last worked 2026-02-28 (~5 months); repo not cloned locally
### GitHub
- Agentic OS: 0 commits in 48h, 0 unpushed, 2 modified files uncommitted
- Kitchen-Inventory / Pendelton-comms-live: repos not cloned locally — no data
- Agentic OS: 15+ commits in 48h; **17 unpushed commits** on local-hardening-merged; dirty working tree (README.md, business-brain.md)
- Kitchen-Inventory / Pendelton-comms-live: repos not cloned locally
### Skills
- 2 skills with new learnings since 2026-06-28 (memory-consolidation, firebase-hosting-basics — both 2026-07-17)
- 0 skills with eval data (all 18 score-history.json files empty)
- Last skill_run: memory-consolidation 2026-07-17 (one run timed out)
- Recurring problem: agent timeouts on skill runs (opencode 06-28, hermes 07-17)
- 15 skills with new learnings since 2026-06-28
- 5 skills with eval data (stub-quality scores only)
### Alerts
1. All 3 projects show no activity in the past week — flag for review.
2. Uncommitted changes in ~/agentic-os (AGENTS.md, agents/hermes/USER.md) — commit or discard.
3. Eval scoring system unused — score-history.json files never populated.
4. Kitchen-Inventory critical code-review findings (geminiService.ts) still open.
### ⚠ Alerts
1. **opencode agent broken** (--ignore-scripts install) — every opencode skill run and kanban dispatch fails; reinstall opencode-ai without --ignore-scripts.
2. **Score masking**: failed opencode runs still logged success=true / score ~50 — eval scoring hides failures.
3. **memory-consolidation timed out** via hermes (2026-07-26, 180s) — marked success=false.
4. **17 unpushed commits** on Agentic OS — push to origin to avoid loss.
5. Pendelton-comms-live stale >5 months — archive or resume.
### Connected Apps
- No new integrations logged since last check.

View File

@ -4,7 +4,7 @@
- 3 agents configured: opencode, Hermes Agent, Gemini CLI
- Dashboard runs on FastAPI (Python) — localhost only
- All skills follow _template/ convention
- Memory consolidation: 2026-07-17 (run — all files clean, stale truncated run log from 2026-06-29 cleaned)
- Memory consolidation: 2026-07-26 (run — 4 skill learnings files cleaned of corrupted run-log pollution)
## User
- Name: User
@ -20,11 +20,12 @@
- Free tiers: GCP Free, GitHub Student Dev Pack, Colab, Kaggle
- Knowledge management via markdown vaults
## Consolidated Insights (2026-06-29)
## Consolidated Insights (2026-07-26)
- **opencode** times out on non-code tasks (brainstorming, tdd-cycle, backup-skill, code-review, goal-planner, test-plugin) — route these to hermes
- **opencode** run failures leave corrupted run-log fragments (truncated "## Skill Instructions / name: / description:" blocks, postinstall errors) in learnings.md — clean these up during consolidation
- **hermes** can also time out on complex multi-step tasks — keep queries short
- **daily-standup** is the most-run skill; hermes executes faster than opencode for it
- **Score tracking**: all 18 skills have empty score-history.json — no eval data yet
- **All learnings files** are concise (under 200 words each), no compression needed
- **Score tracking**: backup-skill (1 entry) + code-review (2 entries) now have single-run eval scores from 2026-07-26; remaining 16 skills empty — no pruning needed (all <20 entries)
- **All learnings files** are concise (under 400 words each), no compression needed
- **No contradictions** found across skill learnings
- **recent-decisions.md**: 3 entries archived (all from 2026-05-17), 0 recent — no archiving needed
- **recent-decisions.md**: 2 recent entries (2026-06-28, 2026-07-25), 2026-05-17 trio archived — no archiving needed

View File

@ -1,38 +1,34 @@
# Skill Usage & Effectiveness
> Last updated: 2026-07-25
> Last updated: 2026-07-26 (brain-guardian)
## Audit Log Summary (164 total entries)
| Action | Count |
|--------|-------|
| kanban_task_updated | 31 |
| skill_run | 22 |
| chat_message | 15 |
| brain_update | 11 |
| journal_saved | 10 |
| settings_updated | 9 |
| kanban_task_created | 8 |
| agent_registered | 7 |
| task_routed | 5 |
| standards_discovery_run | 5 |
## Most Used Skills (by audit log count)
| Skill | Runs | Last Run | Notes |
|-------|------|----------|-------|
| memory-consolidation | 13 | 2026-07-26 | Latest run FAILED — Hermes timed out (180s) |
| code-review | 8 | 2026-07-26 | Recent runs failed via opencode (postinstall broken) |
| daily-standup | 4 | — | |
| backup-skill | 3 | 2026-07-26 | opencode broken |
| test-plugin / tdd-cycle / heartbeat / goal-planner / firebase-hosting-basics / firebase-ai-logic-basics | 2 each | — | |
## Recent Skill Runs
| Skill | Agent | Last Run | Result |
|-------|-------|----------|--------|
| memory-consolidation | hermes | 2026-07-17 | 1 completed, 1 timeout |
| firebase-hosting-basics | opencode | 2026-06-28 | timeout |
## Eval Scores
- All 18 score-history.json files are empty — no eval data has accumulated yet.
## Eval Data (score-history.json)
| Skill | Has Data |
|-------|----------|
| code-review | yes (largest history) |
| heartbeat, firebase-ai-logic-basics, backup-skill, memory-consolidation | yes (12 entries) |
| others | empty |
Scores are all ~4550 stub-quality; no meaningful eval trend yet.
## New Learnings Since 2026-06-28
- memory-consolidation/learnings.md (updated 2026-07-17)
- firebase-hosting-basics/learnings.md (updated 2026-07-17)
- goal-planner, code-review, test-plugin (updated 2026-06-29)
15 skills have learnings.md updated 2026-07-17 → 2026-07-26 (backup-skill, code-review, devops-audit, memory-consolidation most recent on 2026-07-26).
## Skills Per Project
| Project | Skills Used |
|---------|-------------|
| Agentic OS | memory-consolidation, brain-guardian (Hermes cron), daily-standup, heartbeat |
| Kitchen-Inventory | code-review, firebase-hosting-basics |
| Pendelton-comms-live | (none recorded) |
| Agentic OS | daily-standup, heartbeat, devops-audit, memory-consolidation, backup-skill |
| Kitchen-Inventory | code-review, firebase-ai-logic-basics, firebase-hosting-basics, systematic-debug, tdd-cycle |
## ⚠ Alerts
- **opencode agent broken** (installed with --ignore-scripts; postinstall never ran). All opencode-dispatched skill runs on 2026-07-25/26 returned errors, yet audit still logs success=true with score ~50 — scoring is masking failures.
- Kanban dispatch to opencode failed (task fffc3981, 2026-07-26).
- memory-consolidation via hermes timed out on 2026-07-26 17:03 UTC.