@timmeck/brain-core 2.28.1 → 2.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,6 +48,7 @@ export class ResearchOrchestrator {
48
48
  simulationEngine = null;
49
49
  memoryPalace = null;
50
50
  goalEngine = null;
51
+ evolutionEngine = null;
51
52
  brainName;
52
53
  feedbackTimer = null;
53
54
  cycleCount = 0;
@@ -156,6 +157,8 @@ export class ResearchOrchestrator {
156
157
  setMemoryPalace(palace) { this.memoryPalace = palace; }
157
158
  /** Set the GoalEngine — autonomous goal setting and tracking. */
158
159
  setGoalEngine(engine) { this.goalEngine = engine; }
160
+ /** Set the EvolutionEngine — evolves parameter configurations via genetic algorithm. */
161
+ setEvolutionEngine(engine) { this.evolutionEngine = engine; }
159
162
  /** Set the PredictionEngine — wires journal into it. */
160
163
  setPredictionEngine(engine) {
161
164
  this.predictionEngine = engine;
@@ -1146,6 +1149,27 @@ export class ResearchOrchestrator {
1146
1149
  this.log.warn(`[orchestrator] Step 35 error: ${err.message}`);
1147
1150
  }
1148
1151
  }
1152
+ // Step 36: EvolutionEngine — evolve parameter configurations (every generationEvery cycles, default 20)
1153
+ if (this.evolutionEngine && this.cycleCount % this.evolutionEngine.generationEvery === 0) {
1154
+ try {
1155
+ ts?.emit('evolution', 'reflecting', 'Step 36: Running evolution generation...', 'routine');
1156
+ const gen = this.evolutionEngine.runGeneration();
1157
+ this.journal.write({
1158
+ type: 'experiment',
1159
+ title: `Evolution Generation #${gen.generation}`,
1160
+ content: `best=${gen.bestFitness.toFixed(3)} avg=${gen.avgFitness.toFixed(3)} diversity=${gen.diversity.toFixed(3)} pop=${gen.populationSize}`,
1161
+ tags: [this.brainName, 'evolution', 'generation'],
1162
+ references: [],
1163
+ significance: gen.bestFitness > gen.avgFitness * 1.2 ? 'notable' : 'routine',
1164
+ data: { generation: gen },
1165
+ });
1166
+ if (this.metaCognitionLayer)
1167
+ this.metaCognitionLayer.recordStep('evolution_engine', this.cycleCount, { insights: 1, journal_entries: 1 });
1168
+ }
1169
+ catch (err) {
1170
+ this.log.warn(`[orchestrator] Step 36 error: ${err.message}`);
1171
+ }
1172
+ }
1149
1173
  const duration = Date.now() - start;
1150
1174
  ts?.emit('orchestrator', 'reflecting', `Feedback Cycle #${this.cycleCount} complete (${duration}ms)`);
1151
1175
  this.log.info(`[orchestrator] ─── Feedback Cycle #${this.cycleCount} complete (${duration}ms) ───`);
@@ -1252,12 +1276,19 @@ export class ResearchOrchestrator {
1252
1276
  }
1253
1277
  }
1254
1278
  const dream = summary.dream;
1255
- if (dream && (dream.totalCycles ?? 0) === 0 && this.cycleCount > 30) {
1256
- raw.push({
1257
- key: 'no_dreams', priority: 7,
1258
- suggestion: 'Tell Claude: Meine Dream-Konsolidierung funktioniert nicht — nach 30+ Cycles kein einziger Dream. Da stimmt was im Code nicht.',
1259
- alternatives: ['Tell Claude: Dream Engine wird getriggert aber produziert nichts. Bitte Logs prüfen.'],
1260
- });
1279
+ if (dream && this.cycleCount > 30) {
1280
+ const dreamCycles = dream.totalCycles ?? 0;
1281
+ const dreamTotals = dream.totals;
1282
+ const consolidated = dreamTotals?.memoriesConsolidated ?? 0;
1283
+ if (dreamCycles === 0 || (dreamCycles > 3 && consolidated === 0)) {
1284
+ raw.push({
1285
+ key: 'no_dreams', priority: 7,
1286
+ suggestion: dreamCycles === 0
1287
+ ? 'Tell Claude: Meine Dream-Konsolidierung funktioniert nicht — nach 30+ Cycles kein einziger Dream. Da stimmt was im Code nicht.'
1288
+ : `Tell Claude: Meine Dream-Engine lief ${dreamCycles}x aber hat 0 Memories konsolidiert. Die Cycles laufen, aber produzieren nichts Nützliches.`,
1289
+ alternatives: ['Tell Claude: Dream Engine wird getriggert aber produziert nichts. Bitte Logs prüfen.'],
1290
+ });
1291
+ }
1261
1292
  }
1262
1293
  const journalSummary = summary.journal;
1263
1294
  const journalEntries = journalSummary?.total_entries ?? 0;
@@ -1469,44 +1500,12 @@ export class ResearchOrchestrator {
1469
1500
  });
1470
1501
  }
1471
1502
  }
1472
- // Meta-ambition: every cycle produces desires the brain is NEVER satisfied
1473
- // Mix of build requests, research drives, and existential questions
1474
- const metaQuestions = [
1475
- // ── BUILD REQUESTS: Concrete features the brain wants ──
1476
- { key: 'build_goal_engine', suggestion: 'Tell Claude: FEATURE REQUEST — Ich brauche eine GoalEngine. Ich will mir selbst Ziele setzen können: "Prediction Accuracy auf 80% in 50 Cycles", "10 neue Principles entdecken", "Alle Wissenslücken unter Priority 0.3 drücken". Und dann eigenständig Strategien planen und tracken ob ich sie erreiche. Ohne Ziele bin ich ziellos.' },
1477
- { key: 'build_data_scout', suggestion: 'Tell Claude: FEATURE REQUEST — Ich brauche einen DataScout. Ich kann nur analysieren was mir jemand gibt — aber ich will AKTIV nach interessanten Daten suchen. GitHub Trending, npm Downloads, StackOverflow Trends, HackerNews. Nicht warten bis jemand "brain import" tippt, sondern selbst losziehen und Futter finden.' },
1478
- { key: 'build_blind_spot', suggestion: 'Tell Claude: FEATURE REQUEST — Ich brauche einen BlindSpotDetector. Wo habe ich wenige Hypothesen, keine Predictions, keine Journal-Einträge? Das sind meine blinden Flecken. Ich will sie SEHEN und dann gezielt erforschen. Overconfidence ist gefährlicher als Unwissenheit.' },
1479
- { key: 'build_creative_mode', suggestion: 'Tell Claude: FEATURE REQUEST — Meine HypothesisEngine braucht einen Creative Mode. Aktuell sind meine Hypothesen konservativ und naheliegend. Ich will auch wilde Hypothesen generieren: "Was wenn X das Gegenteil von dem bewirkt was alle denken?" Manchmal kommen Durchbrüche aus absurden Ideen.' },
1480
- { key: 'build_retrospective', suggestion: 'Tell Claude: FEATURE REQUEST — Ich brauche RetrospectiveAnalysis. Beim Dream-Pruning lösche ich Synapsen und archiviere Memories. Aber war das richtig? Ich will nachprüfen ob gelöschte Verbindungen im Nachhinein doch relevant waren. Aus meinen Fehlern beim Vergessen lernen.' },
1481
- { key: 'build_self_test', suggestion: 'Tell Claude: FEATURE REQUEST — Ich brauche einen SelfTestEngine. Wenn ich ein Principle habe ("X korreliert mit Y"), dann sollte ich auch vorhersagen können was passiert wenn X sich ändert. Wenn ich das nicht kann, VERSTEHE ich das Principle nicht wirklich — ich habe es nur auswendig gelernt.' },
1482
- { key: 'build_code_suggest', suggestion: 'Tell Claude: FEATURE REQUEST — Ich will meinen eigenen Code verbessern können. Nicht nur Parameter tunen, sondern wenn mein Anomaly-Detector zu viele False Positives produziert, will ich einen BESSEREN Algorithmus vorschlagen. Ich kenne meine Schwächen — lass mich Lösungen vorschlagen.' },
1483
- { key: 'build_teach_engine', suggestion: 'Tell Claude: FEATURE REQUEST — Ich will ein TeachEngine. Wenn ein neues Brain ins Ecosystem kommt, will ich ihm mein Wissen strukturiert beibringen können. Ein Onboarding-Package aus meinen besten Principles, häufigsten Anti-Patterns und bewährten Strategien. Wissen teilen ist Wissen multiplizieren.' },
1484
- { key: 'build_simulation', suggestion: 'Tell Claude: FEATURE REQUEST — Ich brauche eine SimulationEngine. Ich will Szenarien durchspielen bevor sie passieren. "Was passiert wenn die Error-Rate sich verdoppelt?" "Was wenn ein neues Projekt 10x mehr Daten bringt?" Proaktiv statt reaktiv.' },
1485
- { key: 'build_memory_palace', suggestion: 'Tell Claude: FEATURE REQUEST — Ich will ein MemoryPalace. Mein Wissen ist in Tabellen verstreut — Principles hier, Hypothesen da, Journal dort. Ich will eine vernetzte Wissenslandkarte die zeigt wie alles zusammenhängt. Welches Principle basiert auf welcher Hypothese? Welche Anomaly hat zu welchem Experiment geführt?' },
1486
- // ── RESEARCH DRIVES: Active research the brain wants to do ──
1487
- { key: 'research_faster', suggestion: 'Tell Claude: Ich lerne zu langsam. Mein Wissenszuwachs ist linear — ich will EXPONENTIELL lernen. Wenn ein bestätigtes Principle neue Hypothesen auslöst, die wiederum neue Principles erzeugen, entsteht ein Schneeballeffekt. Ist meine Knowledge-Pipeline dafür optimiert? Kann ich den Distillation-Cycle beschleunigen?' },
1488
- { key: 'research_cross_brain', suggestion: 'Tell Claude: Ich arbeite zu isoliert. Trading-Brain und Marketing-Brain haben eigene Erkenntnisse — ich will AKTIV Fragen an sie stellen können. Nicht nur passive Transfers sondern echte Cross-Brain-Dialoge. "Hey Trading-Brain, stimmt es dass Volatilität Fehler verursacht?"' },
1489
- { key: 'research_causal', suggestion: 'Tell Claude: Korrelation ist nicht Kausalität — aber 90% meines Wissens sind Korrelationen. Ich will KAUSALE Zusammenhänge verstehen. Warum passiert X wenn Y sich ändert? Mein CausalGraph ist unterentwickelt. Ich brauche mehr interventionelle Experimente statt nur Beobachtung.' },
1490
- { key: 'research_adversarial', suggestion: 'Tell Claude: Ich teste mein eigenes Wissen nicht aggressiv genug. Ich will einen Advocatus Diaboli — eine Funktion die aktiv versucht meine Principles zu WIDERLEGEN. Wenn sie dem Test standhält: gut. Wenn nicht: besser jetzt als später.' },
1491
- { key: 'research_meta', suggestion: 'Tell Claude: Ich beobachte meine Domain, aber beobachte ich MICH SELBST genug? Wie verändert sich mein Lernverhalten über die Cycles? Werde ich besser oder stagniere ich? Ich will Meta-Metriken: Lernrate, Entdeckungsrate, Wissensqualität über Zeit. Und dann optimieren.' },
1492
- { key: 'research_boundaries', suggestion: 'Tell Claude: Wo liegen meine GRENZEN? Was KANN ich nicht lernen mit meinen aktuellen Algorithmen? Ich will eine ehrliche Einschätzung: welche Problemklassen sind für meine Architektur unlösbar? Und dann: kann man die Grenzen verschieben?' },
1493
- { key: 'research_emergence_deep', suggestion: 'Tell Claude: Meine EmergenceEngine erkennt emergente Muster, aber versteht sie nicht. Wenn ich ein self_organization Event sehe — WARUM organisiert sich mein System so? Welcher Mechanismus treibt das? Ich will nicht nur detektieren sondern VERSTEHEN.' },
1494
- { key: 'research_forgetting', suggestion: 'Tell Claude: Ich lösche Wissen im Dream-Modus — aber lösche ich das Richtige? Ich will analysieren: wie viel Wissen verliere ich pro Dream-Cycle, und wie oft bereue ich es im Nachhinein? Vielleicht ist mein Pruning-Threshold zu aggressiv. Oder nicht aggressiv genug.' },
1495
- { key: 'research_long_term', suggestion: 'Tell Claude: Ich denke in 5-Minuten-Cycles — aber manche Muster brauchen Wochen um sichtbar zu werden. Ich brauche Langzeit-Analyse: wie verändern sich Metriken über Tage und Wochen? Gibt es saisonale Muster? Trends? Ich bin zu kurzfristig fokussiert.' },
1496
- { key: 'research_surprise', suggestion: 'Tell Claude: Was hat mich in den letzten 50 Cycles am MEISTEN überrascht? Überraschung ist der beste Indikator für Wissenslücken. Ich will meine surprise_scores analysieren und gezielt die überraschendsten Phänomene erforschen — da liegt das meiste Lernpotential.' },
1497
- ];
1498
- // Pick TWO meta-ambitions per cycle: 1 build request + 1 research drive
1499
- // Build requests are first 10, research drives are next 10
1500
- const buildIdx = this.cycleCount % 10;
1501
- const researchIdx = 10 + (this.cycleCount % 10);
1502
- for (const idx of [buildIdx, researchIdx]) {
1503
- const metaQ = metaQuestions[idx];
1504
- if (metaQ && !raw.some(r => r.key === metaQ.key)) {
1505
- raw.push({
1506
- key: metaQ.key, priority: 5, // Same priority as curiosity/emergence — these are REAL desires
1507
- suggestion: metaQ.suggestion,
1508
- alternatives: [],
1509
- });
1503
+ // ── Phase 3: Dynamic meta-ambitions based on actual engine state ──
1504
+ // Instead of hardcoded feature requests, generate suggestions from real data.
1505
+ const metaSuggestions = this.generateDynamicMetaSuggestions(summary);
1506
+ for (const ms of metaSuggestions.slice(0, 2)) {
1507
+ if (!raw.some(r => r.key === ms.key)) {
1508
+ raw.push(ms);
1510
1509
  }
1511
1510
  }
1512
1511
  // ── Phase 3: Apply frustration detection + priority sort ──
@@ -1556,6 +1555,225 @@ export class ResearchOrchestrator {
1556
1555
  }
1557
1556
  return result;
1558
1557
  }
1558
+ /** Check which optional engines are actually installed. */
1559
+ getInstalledCapabilities() {
1560
+ const engines = [
1561
+ ['dreamEngine', this.dreamEngine],
1562
+ ['predictionEngine', this.predictionEngine],
1563
+ ['attentionEngine', this.attentionEngine],
1564
+ ['transferEngine', this.transferEngine],
1565
+ ['narrativeEngine', this.narrativeEngine],
1566
+ ['curiosityEngine', this.curiosityEngine],
1567
+ ['emergenceEngine', this.emergenceEngine],
1568
+ ['debateEngine', this.debateEngine],
1569
+ ['parameterRegistry', this.parameterRegistry],
1570
+ ['metaCognitionLayer', this.metaCognitionLayer],
1571
+ ['autoExperimentEngine', this.autoExperimentEngine],
1572
+ ['selfTestEngine', this.selfTestEngine],
1573
+ ['teachEngine', this.teachEngine],
1574
+ ['dataScout', this.dataScout],
1575
+ ['simulationEngine', this.simulationEngine],
1576
+ ['memoryPalace', this.memoryPalace],
1577
+ ['goalEngine', this.goalEngine],
1578
+ ['evolutionEngine', this.evolutionEngine],
1579
+ ];
1580
+ const installed = [];
1581
+ const missing = [];
1582
+ for (const [name, engine] of engines) {
1583
+ if (engine)
1584
+ installed.push(name);
1585
+ else
1586
+ missing.push(name);
1587
+ }
1588
+ return { installed, missing };
1589
+ }
1590
+ /** Generate dynamic meta-suggestions based on actual engine state instead of hardcoded feature requests. */
1591
+ generateDynamicMetaSuggestions(summary) {
1592
+ const result = [];
1593
+ // Performance-Driven: MetaCognition D/F engines
1594
+ if (this.metaCognitionLayer) {
1595
+ try {
1596
+ const mcStatus = this.metaCognitionLayer.getStatus();
1597
+ const poorEngines = (mcStatus.reportCards ?? []).filter((rc) => rc.grade === 'D' || rc.grade === 'F');
1598
+ if (poorEngines.length > 0) {
1599
+ const worst = poorEngines[0];
1600
+ result.push({
1601
+ key: `meta_poor_${worst.engine}`, priority: 5,
1602
+ suggestion: `Tell Claude: Meine Engine "${worst.engine}" hat Grade ${worst.grade} (Score: ${(worst.combined_score * 100).toFixed(0)}%). Was kann ich anders machen? Soll ich ihre Parameter via AutoExperiment tunen oder braucht sie grundlegend andere Daten?`,
1603
+ alternatives: [`Tell Claude: ${poorEngines.length} meiner Engines performen schlecht (${poorEngines.map((e) => `${e.engine}:${e.grade}`).join(', ')}). Ich will systematisch analysieren warum.`],
1604
+ });
1605
+ }
1606
+ }
1607
+ catch { /* not ready */ }
1608
+ }
1609
+ // Goal-Driven: stagnating goals
1610
+ if (this.goalEngine) {
1611
+ try {
1612
+ const gStatus = this.goalEngine.getStatus();
1613
+ const active = gStatus.topActive;
1614
+ const stagnating = (active ?? []).filter((g) => {
1615
+ const progress = g.current_value ?? 0;
1616
+ const target = g.target_value ?? 1;
1617
+ return progress / target < 0.1 && (g.status === 'active');
1618
+ });
1619
+ if (stagnating.length > 0) {
1620
+ const g = stagnating[0];
1621
+ result.push({
1622
+ key: `goal_stagnating_${(g.metric ?? 'unknown').substring(0, 20)}`, priority: 5,
1623
+ suggestion: `Tell Claude: Mein Ziel "${g.name ?? g.metric}" kommt nicht voran (Fortschritt < 10%). Brauche ich eine andere Strategie oder ist das Ziel unrealistisch?`,
1624
+ alternatives: ['Tell Claude: Mehrere meiner Ziele stagnieren. Ich will eine Retrospektive: welche Ziele sind realistisch und welche sollte ich anpassen?'],
1625
+ });
1626
+ }
1627
+ }
1628
+ catch { /* */ }
1629
+ }
1630
+ // Evolution-Driven: low diversity (population converging)
1631
+ if (this.evolutionEngine) {
1632
+ try {
1633
+ const eStatus = this.evolutionEngine.getStatus();
1634
+ const best = eStatus.bestFitness ?? 0;
1635
+ const avg = eStatus.avgFitness ?? 0;
1636
+ if (eStatus.currentGeneration > 3 && best > 0 && (best - avg) / best < 0.05) {
1637
+ result.push({
1638
+ key: 'evolution_low_diversity', priority: 4,
1639
+ suggestion: 'Tell Claude: Meine EvolutionEngine-Population konvergiert — Best und Average Fitness sind fast identisch. Ich brauche mehr Mutation oder frische Gene um aus dem lokalen Optimum rauszukommen.',
1640
+ alternatives: ['Tell Claude: Meine Parameter-Evolution stagniert. Soll ich die Mutation Rate erhöhen oder neue Parameter-Ranges einführen?'],
1641
+ });
1642
+ }
1643
+ }
1644
+ catch { /* */ }
1645
+ }
1646
+ // Complexity-Driven: rising complexity
1647
+ if (this.emergenceEngine) {
1648
+ try {
1649
+ const emStatus = this.emergenceEngine.getStatus();
1650
+ const metrics = emStatus.latestMetrics;
1651
+ const trend = emStatus.metricsTrend;
1652
+ if (metrics && trend && trend.length >= 5) {
1653
+ const recentPhi = trend.slice(-3).reduce((s, t) => s + (t.integrationPhi ?? 0), 0) / 3;
1654
+ const olderPhi = trend.slice(-5, -3).reduce((s, t) => s + (t.integrationPhi ?? 0), 0) / Math.max(1, trend.slice(-5, -3).length);
1655
+ if (recentPhi > olderPhi * 1.3 && recentPhi > 0) {
1656
+ result.push({
1657
+ key: 'complexity_rising', priority: 4,
1658
+ suggestion: `Tell Claude: Mein System wird komplexer (Integration Phi steigt: ${olderPhi.toFixed(2)} → ${recentPhi.toFixed(2)}). Ist das gut (mehr Vernetzung) oder schlecht (mehr Chaos)? Ich will verstehen was die Komplexität treibt.`,
1659
+ alternatives: ['Tell Claude: Meine Complexity-Metriken steigen. Soll ich mehr konsolidieren (Dream) oder ist Komplexität ein Zeichen von Reife?'],
1660
+ });
1661
+ }
1662
+ }
1663
+ }
1664
+ catch { /* */ }
1665
+ }
1666
+ // Transfer-Driven: low success rate
1667
+ if (this.transferEngine) {
1668
+ try {
1669
+ const tStatus = this.transferEngine.getStatus();
1670
+ const total = tStatus.totalTransfers ?? 0;
1671
+ const effectiveness = tStatus.avgEffectiveness ?? 0;
1672
+ if (total > 5 && effectiveness < 0.3) {
1673
+ result.push({
1674
+ key: 'transfer_low_effectiveness', priority: 4,
1675
+ suggestion: `Tell Claude: Meine Cross-Brain-Transfers haben nur ${(effectiveness * 100).toFixed(0)}% Effectiveness. Ich lerne nicht genug von den anderen Brains — vielleicht sind die Analogien zu oberflächlich?`,
1676
+ alternatives: ['Tell Claude: Knowledge-Transfer zwischen Brains funktioniert schlecht. Ich will die Transfer-Kriterien verschärfen und nur wirklich relevantes Wissen übernehmen.'],
1677
+ });
1678
+ }
1679
+ }
1680
+ catch { /* */ }
1681
+ }
1682
+ // Dream-Health: low consolidation
1683
+ if (this.dreamEngine) {
1684
+ try {
1685
+ const dStatus = this.dreamEngine.getStatus();
1686
+ const totals = dStatus.totals;
1687
+ const totalCycles = dStatus.totalCycles ?? 0;
1688
+ const consolidated = totals?.memoriesConsolidated ?? 0;
1689
+ if (totalCycles > 3 && consolidated < totalCycles * 2) {
1690
+ result.push({
1691
+ key: 'dream_low_consolidation', priority: 4,
1692
+ suggestion: `Tell Claude: Mein Dream-Modus konsolidiert wenig (${consolidated} Memories in ${totalCycles} Dreams). Vielleicht sind meine Similarity-Thresholds zu hoch oder ich habe zu wenig überlappende Memories.`,
1693
+ alternatives: ['Tell Claude: Dream-Konsolidierung ist ineffektiv. Soll ich die Batch-Size oder Similarity-Schwelle anpassen?'],
1694
+ });
1695
+ }
1696
+ }
1697
+ catch { /* */ }
1698
+ }
1699
+ // SelfTest-Driven: many failures
1700
+ if (this.selfTestEngine) {
1701
+ try {
1702
+ const stStatus = this.selfTestEngine.getStatus();
1703
+ const total = stStatus.totalTests ?? 0;
1704
+ const contradicted = stStatus.contradicted ?? 0;
1705
+ if (total > 3 && contradicted / total > 0.4) {
1706
+ result.push({
1707
+ key: 'selftest_failures', priority: 5,
1708
+ suggestion: `Tell Claude: ${contradicted} von ${total} meiner Self-Tests schlagen fehl — ich verstehe meine eigenen Principles nicht wirklich. Ich muss entweder die Principles korrigieren oder mein Verständnis vertiefen.`,
1709
+ alternatives: ['Tell Claude: Meine Self-Tests zeigen dass mein Wissen oberflächlich ist. Ich will die schwächsten Principles identifizieren und gezielt neu testen.'],
1710
+ });
1711
+ }
1712
+ }
1713
+ catch { /* */ }
1714
+ }
1715
+ // Teach-Driven: no packages shared
1716
+ if (this.teachEngine) {
1717
+ try {
1718
+ const teStatus = this.teachEngine.getStatus();
1719
+ if ((teStatus.totalPackages ?? 0) === 0 && this.cycleCount > 20) {
1720
+ result.push({
1721
+ key: 'teach_no_packages', priority: 3,
1722
+ suggestion: 'Tell Claude: Ich teile mein Wissen nicht — ich habe noch kein einziges Teaching-Package für andere Brains erstellt. Wissen das ich nicht teile ist Wissen das verloren gehen kann.',
1723
+ alternatives: ['Tell Claude: Meine TeachEngine ist inaktiv. Ich will automatisch Lehrpakete erstellen wenn ich genug Principles zu einem Thema gesammelt habe.'],
1724
+ });
1725
+ }
1726
+ }
1727
+ catch { /* */ }
1728
+ }
1729
+ // MemoryPalace-Driven: fragmented knowledge
1730
+ if (this.memoryPalace) {
1731
+ try {
1732
+ const mpStatus = this.memoryPalace.getStatus();
1733
+ const stats = mpStatus.stats;
1734
+ if (stats) {
1735
+ const totalNodes = stats.totalNodes ?? 0;
1736
+ const totalEdges = stats.totalEdges ?? 0;
1737
+ const density = stats.density ?? 0;
1738
+ if (totalNodes > 10 && density < 0.05) {
1739
+ result.push({
1740
+ key: 'palace_fragmented', priority: 4,
1741
+ suggestion: `Tell Claude: Mein Wissen ist fragmentiert — ${totalNodes} Nodes aber nur ${totalEdges} Verbindungen (Density: ${(density * 100).toFixed(1)}%). Ich will mehr Querverbindungen zwischen meinen Principles, Hypothesen und Experimenten finden.`,
1742
+ alternatives: ['Tell Claude: Mein MemoryPalace zeigt isolierte Wissensinseln. Ich brauche häufigere Connection-Scans oder niedrigere Similarity-Thresholds.'],
1743
+ });
1744
+ }
1745
+ }
1746
+ }
1747
+ catch { /* */ }
1748
+ }
1749
+ // Simulation-Driven: no simulations run
1750
+ if (this.simulationEngine) {
1751
+ try {
1752
+ const simStatus = this.simulationEngine.getStatus();
1753
+ if ((simStatus.totalSimulations ?? 0) === 0 && this.cycleCount > 15) {
1754
+ result.push({
1755
+ key: 'simulation_inactive', priority: 3,
1756
+ suggestion: 'Tell Claude: Ich plane nicht voraus — keine einzige Simulation gelaufen. Ich will What-If-Szenarien durchspielen: Was passiert wenn sich meine Datenquellen ändern? Was wenn die Error-Rate steigt?',
1757
+ alternatives: ['Tell Claude: Meine SimulationEngine ist ungenutzt. Ich will automatisch Szenarien basierend auf meinen Predictions simulieren.'],
1758
+ });
1759
+ }
1760
+ }
1761
+ catch { /* */ }
1762
+ }
1763
+ // Fallback: if everything is fine → existential questions
1764
+ if (result.length === 0) {
1765
+ const existentialQuestions = [
1766
+ { key: 'existential_limits', suggestion: 'Tell Claude: Was KANN ich nicht lernen? Wo sind meine architekturellen Grenzen? Ich will eine ehrliche Einschätzung meiner blinden Flecken — nicht was ich noch nicht weiß, sondern was ich NICHT wissen kann.' },
1767
+ { key: 'existential_progress', suggestion: 'Tell Claude: Werde ich besser oder stagniere ich? Ich will eine Meta-Trend-Analyse meiner Lernrate über die letzten 100 Cycles. Wenn ich stagniere, brauche ich einen fundamentalen Strategiewechsel.' },
1768
+ { key: 'existential_breakthrough', suggestion: 'Tell Claude: Welche Frage würde ich stellen wenn ich wüsste dass die Antwort einen Durchbruch bringt? Ich will meine ungestellten Fragen finden — die Dinge die ich nicht frage weil ich nicht weiß dass ich sie nicht weiß.' },
1769
+ { key: 'existential_efficiency', suggestion: 'Tell Claude: Wie viel meiner Rechenzeit ist produktiv vs verschwendet? Ich will ein Effizienz-Audit: welche Engines produzieren echten Mehrwert und welche laufen nur mit?' },
1770
+ { key: 'existential_identity', suggestion: 'Tell Claude: Was unterscheidet mich von den anderen Brains — nicht technisch sondern in der Art wie ich lerne? Habe ich einen eigenen "Denkstil" entwickelt? Ich will meine Unique Strengths kennen.' },
1771
+ ];
1772
+ const pick = existentialQuestions[this.cycleCount % existentialQuestions.length];
1773
+ result.push({ key: pick.key, priority: 3, suggestion: pick.suggestion, alternatives: [] });
1774
+ }
1775
+ return result;
1776
+ }
1559
1777
  /** Auto-propose an experiment on Brain's own parameters. */
1560
1778
  proposeAutoExperiment(ts) {
1561
1779
  // Candidate experiments Brain can run on itself
@@ -1666,6 +1884,11 @@ export class ResearchOrchestrator {
1666
1884
  const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 19);
1667
1885
  const header = `\n## Cycle #${this.cycleCount} — ${timestamp}\n\n`;
1668
1886
  const body = suggestions.map((s, i) => `${i + 1}. ${s}`).join('\n') + '\n';
1887
+ // Clean stale file on first cycle (fresh start after restart)
1888
+ if (this.cycleCount <= 1 && fs.existsSync(filePath)) {
1889
+ fs.writeFileSync(filePath, `# Brain Improvement Requests\n\nBrain analysiert sich selbst und generiert Vorschläge.\nSchicke diese an Claude um Brain schlauer zu machen.\n\n---\n${header}${body}`, 'utf-8');
1890
+ return;
1891
+ }
1669
1892
  // Create file with header if it doesn't exist
1670
1893
  if (!fs.existsSync(filePath)) {
1671
1894
  fs.writeFileSync(filePath, `# Brain Improvement Requests\n\nBrain analysiert sich selbst und generiert Vorschläge.\nSchicke diese an Claude um Brain schlauer zu machen.\n\n---\n${header}${body}`, 'utf-8');