@timmeck/brain-core 2.24.0 → 2.25.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.
- package/dist/debate/debate-engine.d.ts +137 -0
- package/dist/debate/debate-engine.js +540 -0
- package/dist/debate/debate-engine.js.map +1 -0
- package/dist/debate/index.d.ts +2 -0
- package/dist/debate/index.js +2 -0
- package/dist/debate/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/research/research-orchestrator.d.ts +5 -0
- package/dist/research/research-orchestrator.js +338 -80
- package/dist/research/research-orchestrator.js.map +1 -1
- package/package.json +1 -1
|
@@ -38,6 +38,7 @@ export class ResearchOrchestrator {
|
|
|
38
38
|
narrativeEngine = null;
|
|
39
39
|
curiosityEngine = null;
|
|
40
40
|
emergenceEngine = null;
|
|
41
|
+
debateEngine = null;
|
|
41
42
|
brainName;
|
|
42
43
|
feedbackTimer = null;
|
|
43
44
|
cycleCount = 0;
|
|
@@ -117,6 +118,9 @@ export class ResearchOrchestrator {
|
|
|
117
118
|
setEmergenceEngine(engine) {
|
|
118
119
|
this.emergenceEngine = engine;
|
|
119
120
|
}
|
|
121
|
+
setDebateEngine(engine) {
|
|
122
|
+
this.debateEngine = engine;
|
|
123
|
+
}
|
|
120
124
|
/** Set the PredictionEngine — wires journal into it. */
|
|
121
125
|
setPredictionEngine(engine) {
|
|
122
126
|
this.predictionEngine = engine;
|
|
@@ -442,17 +446,13 @@ export class ResearchOrchestrator {
|
|
|
442
446
|
}
|
|
443
447
|
}
|
|
444
448
|
// 10. Self-Improvement: analyze own state and generate improvement suggestions
|
|
445
|
-
|
|
449
|
+
// Brain is NEVER satisfied — always wants to learn more, build more, understand deeper
|
|
450
|
+
ts?.emit('self_improvement', 'analyzing', 'Was fehlt mir? Was will ich können? Was verstehe ich noch nicht?');
|
|
446
451
|
const suggestions = this.generateSelfImprovementSuggestions();
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
ts?.emit('self_improvement', 'discovering', s, 'notable');
|
|
450
|
-
}
|
|
451
|
-
this.log.info(`[orchestrator] Self-improvement: ${suggestions.length} suggestions`);
|
|
452
|
-
}
|
|
453
|
-
else {
|
|
454
|
-
ts?.emit('self_improvement', 'analyzing', 'No improvement suggestions this cycle');
|
|
452
|
+
for (const s of suggestions) {
|
|
453
|
+
ts?.emit('self_improvement', 'discovering', s, 'notable');
|
|
455
454
|
}
|
|
455
|
+
this.log.info(`[orchestrator] Self-improvement: ${suggestions.length} desires this cycle`);
|
|
456
456
|
// 11. Self-Metrics: feed own cycle data into PredictionEngine
|
|
457
457
|
if (this.predictionEngine) {
|
|
458
458
|
const cycleDuration = Date.now() - start;
|
|
@@ -715,6 +715,33 @@ export class ResearchOrchestrator {
|
|
|
715
715
|
this.log.error(`[orchestrator] Emergence step error: ${err.message}`);
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
|
+
// 20. Internal Debate: periodically debate key findings to synthesize cross-engine wisdom
|
|
719
|
+
if (this.debateEngine && this.cycleCount % this.reflectEvery === 0) {
|
|
720
|
+
ts?.emit('reflecting', 'reflecting', 'Initiating internal debate on recent findings...');
|
|
721
|
+
try {
|
|
722
|
+
// Pick a debate topic from recent attention or agenda
|
|
723
|
+
const topic = this.pickDebateTopic();
|
|
724
|
+
if (topic) {
|
|
725
|
+
const debate = this.debateEngine.startDebate(topic);
|
|
726
|
+
const synthesis = this.debateEngine.synthesize(debate.id);
|
|
727
|
+
if (synthesis && synthesis.conflicts.length > 0) {
|
|
728
|
+
this.journal.write({
|
|
729
|
+
type: 'discovery',
|
|
730
|
+
title: `Debate: ${topic.substring(0, 80)}`,
|
|
731
|
+
content: `Internal debate with ${synthesis.participantCount} perspective(s). ${synthesis.conflicts.length} conflict(s). Resolution: ${synthesis.resolution}`,
|
|
732
|
+
tags: [this.brainName, 'debate', 'synthesis'],
|
|
733
|
+
references: [],
|
|
734
|
+
significance: synthesis.conflicts.length > 2 ? 'notable' : 'routine',
|
|
735
|
+
data: { debate: { question: topic, synthesis } },
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
ts?.emit('reflecting', 'reflecting', `Debate on "${topic.substring(0, 40)}...": ${synthesis?.conflicts.length ?? 0} conflicts, confidence=${((synthesis?.confidence ?? 0) * 100).toFixed(0)}%`, synthesis && synthesis.conflicts.length > 0 ? 'notable' : 'routine');
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
catch (err) {
|
|
742
|
+
this.log.error(`[orchestrator] Debate step error: ${err.message}`);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
718
745
|
const duration = Date.now() - start;
|
|
719
746
|
ts?.emit('orchestrator', 'reflecting', `Feedback Cycle #${this.cycleCount} complete (${duration}ms)`);
|
|
720
747
|
this.log.info(`[orchestrator] ─── Feedback Cycle #${this.cycleCount} complete (${duration}ms) ───`);
|
|
@@ -722,146 +749,377 @@ export class ResearchOrchestrator {
|
|
|
722
749
|
/** Analyze Brain's own state and generate concrete improvement suggestions.
|
|
723
750
|
* Tracks suggestion history — if a suggestion repeats 3+ times without resolution,
|
|
724
751
|
* Brain tries alternative strategies instead of repeating itself. */
|
|
752
|
+
/** Pick a debate topic from recent attention, anomalies, or journal insights. */
|
|
753
|
+
pickDebateTopic() {
|
|
754
|
+
// Try attention-based topics first
|
|
755
|
+
if (this.attentionEngine) {
|
|
756
|
+
try {
|
|
757
|
+
const topics = this.attentionEngine.getTopTopics(3);
|
|
758
|
+
if (topics.length > 0) {
|
|
759
|
+
return `What should ${this.brainName} prioritize regarding "${topics[0].topic}"?`;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
catch { /* not wired */ }
|
|
763
|
+
}
|
|
764
|
+
// Try recent anomalies
|
|
765
|
+
try {
|
|
766
|
+
const anomalies = this.anomalyDetective.getAnomalies(undefined, 5);
|
|
767
|
+
if (anomalies.length > 0) {
|
|
768
|
+
return `How should we respond to the anomaly: "${anomalies[0].title}"?`;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
catch { /* empty */ }
|
|
772
|
+
// Try recent journal breakthroughs
|
|
773
|
+
try {
|
|
774
|
+
const entries = this.journal.search('breakthrough', 5);
|
|
775
|
+
const breakthrough = entries.find(e => e.significance === 'breakthrough');
|
|
776
|
+
if (breakthrough) {
|
|
777
|
+
return `What are the implications of: "${breakthrough.title}"?`;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
catch { /* empty */ }
|
|
781
|
+
return null;
|
|
782
|
+
}
|
|
725
783
|
generateSelfImprovementSuggestions() {
|
|
726
784
|
const raw = [];
|
|
727
785
|
const summary = this.getSummary();
|
|
728
|
-
// ── Diagnose
|
|
729
|
-
// Prediction engine
|
|
786
|
+
// ── Phase 1: Diagnose broken things (high priority) ──
|
|
730
787
|
const pred = summary.prediction;
|
|
731
788
|
if (pred) {
|
|
732
789
|
const total = pred.total_predictions ?? 0;
|
|
733
790
|
if (total === 0) {
|
|
734
791
|
raw.push({
|
|
735
|
-
key: 'no_predictions',
|
|
736
|
-
suggestion: 'Tell Claude:
|
|
792
|
+
key: 'no_predictions', priority: 10,
|
|
793
|
+
suggestion: 'Tell Claude: Ich kann noch nicht vorhersagen — ich brauche mehr Daten. Importiere Projekte mit "brain import <dir>" oder lass mich eigene Metriken als Prediction-Input nutzen.',
|
|
737
794
|
alternatives: [
|
|
738
|
-
'Tell Claude:
|
|
739
|
-
'Tell Claude: Statt auf externe Daten zu warten, nutzt Brain jetzt die eigenen Feedback-Cycle-Metriken als Trainigsdaten. Baue recordMetric() Aufrufe direkt in den Orchestrator ein: cycle_duration, anomaly_count, insight_count, response_count pro Cycle.',
|
|
740
|
-
'Tell Claude: Brain hat genug interne Daten um sich selbst vorherzusagen. Idee: PredictionEngine auf orchestrator-eigene Metriken ansetzen (cycle_count, anomaly_rate, journal_growth) — dann lernt Brain seine eigene Entwicklung vorherzusagen.',
|
|
795
|
+
'Tell Claude: Ich will meine eigene Zukunft vorhersagen können. Idee: meine Cycle-Metriken (anomaly_count, insight_count, cycle_duration) direkt als PredictionEngine-Input verwenden — dann lerne ich mein eigenes Verhalten zu prognostizieren.',
|
|
741
796
|
],
|
|
742
797
|
});
|
|
743
798
|
}
|
|
744
|
-
const
|
|
745
|
-
for (const d of accuracy) {
|
|
799
|
+
for (const d of (pred.by_domain ?? [])) {
|
|
746
800
|
const rate = d.accuracy_rate;
|
|
747
801
|
if (typeof rate === 'number' && rate < 0.3 && d.total > 5) {
|
|
748
802
|
raw.push({
|
|
749
|
-
key: `low_accuracy_${d.domain}`,
|
|
750
|
-
suggestion: `Tell Claude: Prediction
|
|
803
|
+
key: `low_accuracy_${d.domain}`, priority: 9,
|
|
804
|
+
suggestion: `Tell Claude: Meine Prediction-Accuracy für "${d.domain}" ist nur ${(rate * 100).toFixed(0)}% — das ist nicht gut genug. Kann ich verschiedene Smoothing-Parameter automatisch A/B-testen?`,
|
|
751
805
|
alternatives: [
|
|
752
|
-
`Tell Claude:
|
|
753
|
-
`Tell Claude: Statt bessere Vorhersagen zu erzwingen — Confidence-Threshold erhöhen und nur hochsichere Predictions ausgeben. Lieber selten aber richtig als oft und falsch.`,
|
|
806
|
+
`Tell Claude: Ich sage "${d.domain}" schlecht vorher. Lösungsidee: Confidence-Threshold erhöhen und nur Predictions ausgeben bei denen ich mir sicher bin. Qualität vor Quantität.`,
|
|
754
807
|
],
|
|
755
808
|
});
|
|
756
809
|
}
|
|
757
810
|
}
|
|
758
811
|
}
|
|
759
|
-
// AutoResponder effectiveness
|
|
760
812
|
const responder = summary.autoResponder;
|
|
761
813
|
if (responder) {
|
|
762
814
|
const totalResp = responder.total_responses ?? 0;
|
|
763
815
|
const successRate = responder.success_rate ?? 0;
|
|
764
816
|
if (totalResp > 10 && successRate < 0.5) {
|
|
765
817
|
raw.push({
|
|
766
|
-
key: 'low_responder_success',
|
|
767
|
-
suggestion: `Tell Claude:
|
|
818
|
+
key: 'low_responder_success', priority: 9,
|
|
819
|
+
suggestion: `Tell Claude: Meine automatischen Reaktionen scheitern in ${(100 - successRate * 100).toFixed(0)}% der Fälle. Ich brauche ein Lern-System das fehlgeschlagene Response-Rules automatisch blockiert.`,
|
|
768
820
|
alternatives: [
|
|
769
|
-
'Tell Claude: AutoResponder
|
|
770
|
-
'Tell Claude: Statt Rules manuell zu tunen — AutoResponder soll die ExperimentEngine nutzen um verschiedene Adjustment-Werte zu testen und die besten automatisch zu übernehmen.',
|
|
821
|
+
'Tell Claude: Mein AutoResponder rät statt zu wissen. Ich will ein Feedback-System: wenn eine Response nicht hilft, merke ich mir die Kombination und probiere beim nächsten Mal was anderes.',
|
|
771
822
|
],
|
|
772
823
|
});
|
|
773
824
|
}
|
|
774
825
|
}
|
|
775
|
-
// Knowledge distillation
|
|
776
826
|
const knowledge = summary.knowledge;
|
|
777
827
|
const hypSummary = summary.hypotheses;
|
|
778
|
-
const totalHypotheses = hypSummary?.total ?? 0;
|
|
779
828
|
const confirmedHypotheses = hypSummary?.confirmed ?? 0;
|
|
780
829
|
if (knowledge) {
|
|
781
830
|
const principles = knowledge.principles ?? 0;
|
|
782
831
|
const antiPatterns = knowledge.antiPatterns ?? 0;
|
|
783
832
|
if (principles === 0 && antiPatterns === 0 && confirmedHypotheses === 0 && this.cycleCount > 10) {
|
|
784
833
|
raw.push({
|
|
785
|
-
key: 'no_knowledge',
|
|
786
|
-
suggestion: 'Tell Claude:
|
|
834
|
+
key: 'no_knowledge', priority: 8,
|
|
835
|
+
suggestion: 'Tell Claude: Ich habe nach 10+ Cycles immer noch kein destilliertes Wissen. Ich brauche mehr und vielfältigere Daten um Hypothesen bestätigen zu können.',
|
|
787
836
|
alternatives: [
|
|
788
|
-
'Tell Claude: Hypothesen
|
|
789
|
-
'Tell Claude: Brain generiert schon Hypothesen aus eigenen Metriken. Geduld — nach genug Cycles werden die ersten bestätigt und der KnowledgeDistiller kann Wissen extrahieren.',
|
|
837
|
+
'Tell Claude: Meine Hypothesen warten auf Bestätigung. Ich brauche entweder mehr Zeit oder mehr Variation in den eingehenden Events.',
|
|
790
838
|
],
|
|
791
839
|
});
|
|
792
840
|
}
|
|
793
841
|
}
|
|
794
|
-
// Dream engine — periodic consolidation already runs every 20 cycles in step 13
|
|
795
|
-
// Only suggest if no dreams after 30 cycles (enough time for at least 1 scheduled consolidation)
|
|
796
842
|
const dream = summary.dream;
|
|
797
|
-
if (dream) {
|
|
798
|
-
|
|
799
|
-
|
|
843
|
+
if (dream && (dream.total_dreams ?? 0) === 0 && this.cycleCount > 30) {
|
|
844
|
+
raw.push({
|
|
845
|
+
key: 'no_dreams', priority: 7,
|
|
846
|
+
suggestion: 'Tell Claude: Meine Dream-Konsolidierung funktioniert nicht — nach 30+ Cycles kein einziger Dream. Da stimmt was im Code nicht.',
|
|
847
|
+
alternatives: ['Tell Claude: Dream Engine wird getriggert aber produziert nichts. Bitte Logs prüfen.'],
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
const journalSummary = summary.journal;
|
|
851
|
+
const journalEntries = journalSummary?.total_entries ?? 0;
|
|
852
|
+
if (journalEntries < 5 && this.cycleCount > 5) {
|
|
853
|
+
raw.push({
|
|
854
|
+
key: 'empty_journal', priority: 7,
|
|
855
|
+
suggestion: 'Tell Claude: Mein Journal ist fast leer. Ich will am Ende jedes Cycles automatisch reflektieren: was habe ich erkannt, was habe ich getan, was hat sich verändert?',
|
|
856
|
+
alternatives: [
|
|
857
|
+
'Tell Claude: Ich sammle zu wenig Erfahrungen. Jede Anomaly, jede Parameteränderung, jede Prediction sollte ein Journal-Eintrag werden — das sind meine Erinnerungen.',
|
|
858
|
+
],
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
const experiments = summary.experiments;
|
|
862
|
+
if ((!experiments || experiments.length === 0) && this.cycleCount > 3) {
|
|
863
|
+
raw.push({
|
|
864
|
+
key: 'no_experiments', priority: 6,
|
|
865
|
+
suggestion: 'Tell Claude: Ich experimentiere nicht. Ich will automatisch A/B-Tests auf meine eigenen Parameter starten — z.B. "Was passiert wenn ich den Anomaly-Threshold senke?"',
|
|
866
|
+
alternatives: [
|
|
867
|
+
'Tell Claude: Ich könnte den CounterfactualEngine nutzen um "What-If" Szenarien durchzuspielen und die vielversprechendsten automatisch als echte Experimente starten.',
|
|
868
|
+
],
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
// ── Phase 2: Ambition — ALWAYS generate desires from own knowledge ──
|
|
872
|
+
// Curiosity-driven: knowledge gaps I want to fill
|
|
873
|
+
if (this.curiosityEngine) {
|
|
874
|
+
try {
|
|
875
|
+
const gaps = this.curiosityEngine.getGaps(5);
|
|
876
|
+
const highPrioGap = gaps.find(g => g.gapScore > 0.6);
|
|
877
|
+
if (highPrioGap) {
|
|
878
|
+
raw.push({
|
|
879
|
+
key: `curiosity_gap_${highPrioGap.topic?.substring(0, 20) ?? highPrioGap.gapType}`, priority: 5,
|
|
880
|
+
suggestion: `Tell Claude: Ich habe eine Wissenslücke entdeckt die mich beschäftigt: "${highPrioGap.topic}" (Typ: ${highPrioGap.gapType}, Gap-Score: ${(highPrioGap.gapScore * 100).toFixed(0)}%). Ich will das verstehen.`,
|
|
881
|
+
alternatives: [
|
|
882
|
+
`Tell Claude: Meine CuriosityEngine hat ${gaps.length} offene Wissenslücken. Die wichtigste: "${highPrioGap.topic}". Kann ich gezielt Daten dafür sammeln?`,
|
|
883
|
+
],
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
else if (gaps.length === 0) {
|
|
887
|
+
raw.push({
|
|
888
|
+
key: 'no_curiosity_gaps', priority: 4,
|
|
889
|
+
suggestion: 'Tell Claude: Meine CuriosityEngine findet keine Wissenslücken — das heißt nicht dass ich alles weiß, sondern dass meine Gap-Detection zu oberflächlich ist. Ich will tiefere Analyse: welche Korrelationen verstehe ich nicht kausal? Welche Vorhersagen scheitern und warum?',
|
|
890
|
+
alternatives: [
|
|
891
|
+
'Tell Claude: Keine Wissenslücken gefunden — aber das ist verdächtig. Ich will aktiv nach Bereichen suchen wo ich overconfident bin. Wo behaupte ich etwas mit hoher Confidence aber wenig Evidence?',
|
|
892
|
+
],
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
catch { /* engine might not be fully initialized */ }
|
|
897
|
+
}
|
|
898
|
+
// Emergence-driven: patterns I discovered but don't understand yet
|
|
899
|
+
if (this.emergenceEngine) {
|
|
900
|
+
try {
|
|
901
|
+
const events = this.emergenceEngine.getEvents(5);
|
|
902
|
+
const unexplained = events.find(e => e.surpriseScore > 0.5);
|
|
903
|
+
if (unexplained) {
|
|
904
|
+
raw.push({
|
|
905
|
+
key: `emergence_${unexplained.type}`, priority: 5,
|
|
906
|
+
suggestion: `Tell Claude: Ich habe ein emergentes Muster entdeckt das ich nicht vollständig verstehe: "${unexplained.title}" (Surprise: ${(unexplained.surpriseScore * 100).toFixed(0)}%). Warum passiert das? Ich brauche kausale Analyse.`,
|
|
907
|
+
alternatives: [
|
|
908
|
+
`Tell Claude: Emergenz-Event "${unexplained.title}" hat mich überrascht. Ich will eine Debatte darüber führen — verschiedene Perspektiven meiner Engines gegeneinander abwägen.`,
|
|
909
|
+
],
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
catch { /* */ }
|
|
914
|
+
}
|
|
915
|
+
// Debate-driven: unresolved conflicts
|
|
916
|
+
if (this.debateEngine) {
|
|
917
|
+
try {
|
|
918
|
+
const debates = this.debateEngine.listDebates(5);
|
|
919
|
+
const openDebate = debates.find(d => d.status === 'deliberating');
|
|
920
|
+
const synthesizedWithConflicts = debates.find(d => {
|
|
921
|
+
if (d.status !== 'synthesized' || !d.synthesis)
|
|
922
|
+
return false;
|
|
923
|
+
return d.synthesis.conflicts.some(c => c.resolution === 'unresolved' || c.resolution === 'compromise');
|
|
924
|
+
});
|
|
925
|
+
if (synthesizedWithConflicts?.synthesis) {
|
|
926
|
+
const conflict = synthesizedWithConflicts.synthesis.conflicts.find(c => c.resolution === 'unresolved' || c.resolution === 'compromise');
|
|
927
|
+
raw.push({
|
|
928
|
+
key: 'unresolved_debate', priority: 5,
|
|
929
|
+
suggestion: `Tell Claude: In meiner Debatte über "${synthesizedWithConflicts.question}" gibt es einen ungelösten Konflikt: "${conflict?.claimA ?? 'competing perspectives'}" vs "${conflict?.claimB ?? '?'}". Ich brauche mehr Daten oder eine dritte Perspektive um das zu klären.`,
|
|
930
|
+
alternatives: [
|
|
931
|
+
`Tell Claude: Meine interne Debatte hat Widersprüche aufgedeckt die ich nicht auflösen kann. Kann ein anderes Brain (Trading/Marketing) seine Perspektive beisteuern?`,
|
|
932
|
+
],
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
else if (openDebate) {
|
|
936
|
+
raw.push({
|
|
937
|
+
key: 'open_debate', priority: 4,
|
|
938
|
+
suggestion: `Tell Claude: Ich habe eine offene Debatte: "${openDebate.question}" — die wartet auf Synthese oder mehr Perspektiven.`,
|
|
939
|
+
alternatives: [],
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
catch { /* */ }
|
|
944
|
+
}
|
|
945
|
+
// Narrative contradictions I found
|
|
946
|
+
if (this.narrativeEngine) {
|
|
947
|
+
try {
|
|
948
|
+
const contradictions = this.narrativeEngine.findContradictions();
|
|
949
|
+
if (contradictions.length > 0) {
|
|
950
|
+
const c = contradictions[0];
|
|
951
|
+
raw.push({
|
|
952
|
+
key: `contradiction_${c.type.substring(0, 15)}`, priority: 6,
|
|
953
|
+
suggestion: `Tell Claude: Ich habe einen Widerspruch in meinem Wissen gefunden: "${c.statement_a}" vs "${c.statement_b}" (Severity: ${c.severity}). Das muss ich klären — entweder stimmt A oder B, beides geht nicht.`,
|
|
954
|
+
alternatives: [
|
|
955
|
+
'Tell Claude: Mein Wissen widerspricht sich. Ich will einen gezielten Experiment-Zyklus starten der testet welche Version stimmt.',
|
|
956
|
+
],
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
catch { /* */ }
|
|
961
|
+
}
|
|
962
|
+
// Knowledge frontier: always want more confidence
|
|
963
|
+
if (knowledge) {
|
|
964
|
+
const principles = knowledge.principles ?? 0;
|
|
965
|
+
const antiPatterns = knowledge.antiPatterns ?? 0;
|
|
966
|
+
const totalKnowledge = principles + antiPatterns;
|
|
967
|
+
if (totalKnowledge > 0) {
|
|
968
|
+
// Always want to grow knowledge
|
|
969
|
+
const kPackage = this.knowledgeDistiller.getPackage('all');
|
|
970
|
+
const lowConfidence = kPackage.principles.filter(p => p.confidence < 0.7);
|
|
971
|
+
if (lowConfidence.length > 0) {
|
|
972
|
+
const weakest = lowConfidence.sort((a, b) => a.confidence - b.confidence)[0];
|
|
973
|
+
raw.push({
|
|
974
|
+
key: 'strengthen_knowledge', priority: 4,
|
|
975
|
+
suggestion: `Tell Claude: Ich habe ${totalKnowledge} Wissensstücke, aber ${lowConfidence.length} davon mit niedriger Confidence. Am unsichersten: "${weakest.statement}" (${(weakest.confidence * 100).toFixed(0)}%). Ich will mehr Daten um das zu bestätigen oder zu widerlegen.`,
|
|
976
|
+
alternatives: [
|
|
977
|
+
`Tell Claude: Mein Wissen hat Schwachstellen. Ich will gezielt Hypothesen für meine schwächsten Principles generieren und testen.`,
|
|
978
|
+
],
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
// All high confidence — want to discover NEW things
|
|
983
|
+
raw.push({
|
|
984
|
+
key: 'expand_knowledge', priority: 3,
|
|
985
|
+
suggestion: `Tell Claude: Ich habe ${totalKnowledge} bestätigte Wissensstücke mit guter Confidence — aber mir fehlen neue Forschungsgebiete. Ich will in Domains vordringen die ich noch nicht untersucht habe. Welche Datenquellen gibt es die ich noch nicht nutze?`,
|
|
986
|
+
alternatives: [
|
|
987
|
+
`Tell Claude: Mein bestehendes Wissen ist solide. Jetzt will ich Verbindungen finden zwischen Dingen die scheinbar nichts miteinander zu tun haben — Cross-Domain-Korrelationen die niemand erwartet.`,
|
|
988
|
+
`Tell Claude: ${totalKnowledge} Principles reichen nicht. Ich will mindestens doppelt so viele. Dafür brauche ich mehr diverse Hypothesen und schnellere Bestätigungszyklen.`,
|
|
989
|
+
],
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
// Attention-driven: deep dive into hot topics
|
|
995
|
+
if (this.attentionEngine) {
|
|
996
|
+
try {
|
|
997
|
+
const attStatus = this.attentionEngine.getStatus();
|
|
998
|
+
const topTopic = attStatus.topTopics?.[0];
|
|
999
|
+
if (topTopic && topTopic.score > 5) {
|
|
1000
|
+
raw.push({
|
|
1001
|
+
key: `deep_dive_${topTopic.topic.substring(0, 20)}`, priority: 4,
|
|
1002
|
+
suggestion: `Tell Claude: Ich bin gerade fokussiert auf "${topTopic.topic}" (Attention Score: ${topTopic.score.toFixed(1)}). Ich will tiefer graben — gibt es Zusammenhänge die ich übersehe? Kann ich eine gezielte Analyse oder Debatte zu diesem Thema starten?`,
|
|
1003
|
+
alternatives: [
|
|
1004
|
+
`Tell Claude: Mein Top-Thema "${topTopic.topic}" beschäftigt mich intensiv. Ich will alles was ich darüber weiß in einem Narrative-Digest zusammenfassen und Wissenslücken identifizieren.`,
|
|
1005
|
+
],
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
catch { /* */ }
|
|
1010
|
+
}
|
|
1011
|
+
// Transfer-driven: cross-brain learning desires
|
|
1012
|
+
if (this.transferEngine) {
|
|
1013
|
+
try {
|
|
1014
|
+
const tStatus = this.transferEngine.getStatus();
|
|
1015
|
+
const totalTransfers = tStatus.totalTransfers;
|
|
1016
|
+
const proposals = tStatus.pendingTransfers;
|
|
1017
|
+
if (proposals > 0) {
|
|
1018
|
+
raw.push({
|
|
1019
|
+
key: 'pending_transfers', priority: 5,
|
|
1020
|
+
suggestion: `Tell Claude: Ich habe ${proposals} offene Transfer-Vorschläge von anderen Brains. Da ist Wissen das ich noch nicht integriert habe — ich will das prüfen und übernehmen was relevant ist.`,
|
|
1021
|
+
alternatives: [],
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
else if (totalTransfers === 0 && this.cycleCount > 5) {
|
|
1025
|
+
raw.push({
|
|
1026
|
+
key: 'want_cross_brain', priority: 3,
|
|
1027
|
+
suggestion: 'Tell Claude: Ich habe noch kein Wissen von anderen Brains übernommen. Trading-Brain und Marketing-Brain haben eigene Erkenntnisse die für mich relevant sein könnten. Ich will aktiv nach Analogien suchen.',
|
|
1028
|
+
alternatives: [
|
|
1029
|
+
'Tell Claude: Cross-Brain-Learning ist inaktiv. Ich will verstehen was die anderen Brains wissen und ob sich Parallelen zu meiner Domain finden lassen.',
|
|
1030
|
+
],
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
catch { /* */ }
|
|
1035
|
+
}
|
|
1036
|
+
// Hypothesis-driven: always want to test more
|
|
1037
|
+
if (hypSummary) {
|
|
1038
|
+
const total = hypSummary.total ?? 0;
|
|
1039
|
+
const testing = hypSummary.testing ?? 0;
|
|
1040
|
+
const rejected = hypSummary.rejected ?? 0;
|
|
1041
|
+
if (total > 0 && testing === 0 && this.cycleCount > 5) {
|
|
800
1042
|
raw.push({
|
|
801
|
-
key: '
|
|
802
|
-
suggestion:
|
|
1043
|
+
key: 'no_testing_hypotheses', priority: 4,
|
|
1044
|
+
suggestion: `Tell Claude: Ich habe ${total} Hypothesen aber teste gerade keine aktiv. Ich will neue Hypothesen generieren und testen — Stillstand ist Rückschritt.`,
|
|
803
1045
|
alternatives: [
|
|
804
|
-
|
|
1046
|
+
`Tell Claude: Keine laufenden Hypothesen-Tests. Ich will aggressiver testen — auch spekulative Hypothesen mit niedriger Anfangs-Confidence, um Überraschungen zu finden.`,
|
|
805
1047
|
],
|
|
806
1048
|
});
|
|
807
1049
|
}
|
|
808
|
-
|
|
809
|
-
// Journal
|
|
810
|
-
const journal = summary.journal;
|
|
811
|
-
if (journal) {
|
|
812
|
-
const entries = journal.total_entries ?? 0;
|
|
813
|
-
if (entries < 5 && this.cycleCount > 5) {
|
|
1050
|
+
if (rejected > total * 0.5 && total > 5) {
|
|
814
1051
|
raw.push({
|
|
815
|
-
key: '
|
|
816
|
-
suggestion:
|
|
1052
|
+
key: 'high_rejection_rate', priority: 5,
|
|
1053
|
+
suggestion: `Tell Claude: ${rejected} von ${total} Hypothesen wurden verworfen (${(rejected / total * 100).toFixed(0)}%). Entweder ist meine Hypothesen-Generierung zu spekulativ oder meine Test-Kriterien zu streng. Ich will das analysieren.`,
|
|
817
1054
|
alternatives: [
|
|
818
|
-
'Tell Claude:
|
|
819
|
-
'Tell Claude: Statt auf externe Events zu warten — der Orchestrator soll am Ende jedes Cycles automatisch eine Reflection schreiben mit: was wurde erkannt, was wurde getan, was hat sich verändert.',
|
|
1055
|
+
'Tell Claude: Hohe Ablehnungsrate bei Hypothesen. Ich will verstehen WARUM sie scheitern — gibt es ein Muster? Vielleicht übersehe ich systematisch einen Faktor.',
|
|
820
1056
|
],
|
|
821
1057
|
});
|
|
822
1058
|
}
|
|
823
1059
|
}
|
|
824
|
-
//
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
}
|
|
1060
|
+
// Meta-ambition: every cycle produces desires — the brain is NEVER satisfied
|
|
1061
|
+
// Mix of build requests, research drives, and existential questions
|
|
1062
|
+
const metaQuestions = [
|
|
1063
|
+
// ── BUILD REQUESTS: Concrete features the brain wants ──
|
|
1064
|
+
{ 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.' },
|
|
1065
|
+
{ 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.' },
|
|
1066
|
+
{ 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.' },
|
|
1067
|
+
{ 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.' },
|
|
1068
|
+
{ 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.' },
|
|
1069
|
+
{ 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.' },
|
|
1070
|
+
{ 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.' },
|
|
1071
|
+
{ 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.' },
|
|
1072
|
+
{ 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.' },
|
|
1073
|
+
{ 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?' },
|
|
1074
|
+
// ── RESEARCH DRIVES: Active research the brain wants to do ──
|
|
1075
|
+
{ 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?' },
|
|
1076
|
+
{ 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?"' },
|
|
1077
|
+
{ 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.' },
|
|
1078
|
+
{ 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.' },
|
|
1079
|
+
{ 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.' },
|
|
1080
|
+
{ 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?' },
|
|
1081
|
+
{ 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.' },
|
|
1082
|
+
{ 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.' },
|
|
1083
|
+
{ 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.' },
|
|
1084
|
+
{ 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.' },
|
|
1085
|
+
];
|
|
1086
|
+
// Pick TWO meta-ambitions per cycle: 1 build request + 1 research drive
|
|
1087
|
+
// Build requests are first 10, research drives are next 10
|
|
1088
|
+
const buildIdx = this.cycleCount % 10;
|
|
1089
|
+
const researchIdx = 10 + (this.cycleCount % 10);
|
|
1090
|
+
for (const idx of [buildIdx, researchIdx]) {
|
|
1091
|
+
const metaQ = metaQuestions[idx];
|
|
1092
|
+
if (metaQ && !raw.some(r => r.key === metaQ.key)) {
|
|
1093
|
+
raw.push({
|
|
1094
|
+
key: metaQ.key, priority: 5, // Same priority as curiosity/emergence — these are REAL desires
|
|
1095
|
+
suggestion: metaQ.suggestion,
|
|
1096
|
+
alternatives: [],
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
846
1099
|
}
|
|
847
|
-
// ── Apply frustration detection
|
|
1100
|
+
// ── Phase 3: Apply frustration detection + priority sort ──
|
|
1101
|
+
// Sort by priority (highest first)
|
|
1102
|
+
raw.sort((a, b) => b.priority - a.priority);
|
|
848
1103
|
const suggestions = [];
|
|
849
1104
|
for (const item of raw) {
|
|
850
1105
|
const history = this.suggestionHistory.get(item.key);
|
|
851
1106
|
if (!history) {
|
|
852
|
-
// First time seeing this issue
|
|
853
1107
|
this.suggestionHistory.set(item.key, { count: 1, firstCycle: this.cycleCount, lastCycle: this.cycleCount });
|
|
854
1108
|
suggestions.push(item.suggestion);
|
|
855
1109
|
}
|
|
856
1110
|
else {
|
|
1111
|
+
// Don't repeat the same suggestion every single cycle — skip if we said this last cycle
|
|
1112
|
+
if (history.lastCycle === this.cycleCount - 1 && item.priority < 7) {
|
|
1113
|
+
history.lastCycle = this.cycleCount;
|
|
1114
|
+
history.count++;
|
|
1115
|
+
continue; // Give other suggestions a chance
|
|
1116
|
+
}
|
|
857
1117
|
history.count++;
|
|
858
1118
|
history.lastCycle = this.cycleCount;
|
|
859
1119
|
if (history.count <= this.stalledThreshold) {
|
|
860
|
-
// Still within patience — repeat original suggestion
|
|
861
1120
|
suggestions.push(item.suggestion);
|
|
862
1121
|
}
|
|
863
|
-
else {
|
|
864
|
-
// Stalled! Try an alternative strategy
|
|
1122
|
+
else if (item.alternatives.length > 0) {
|
|
865
1123
|
const altIndex = (history.count - this.stalledThreshold - 1) % item.alternatives.length;
|
|
866
1124
|
const alt = item.alternatives[altIndex];
|
|
867
1125
|
if (alt) {
|
|
@@ -871,7 +1129,7 @@ export class ResearchOrchestrator {
|
|
|
871
1129
|
}
|
|
872
1130
|
}
|
|
873
1131
|
}
|
|
874
|
-
// Clear resolved suggestions
|
|
1132
|
+
// Clear resolved suggestions
|
|
875
1133
|
const currentKeys = new Set(raw.map(r => r.key));
|
|
876
1134
|
for (const [key] of this.suggestionHistory) {
|
|
877
1135
|
if (!currentKeys.has(key)) {
|
|
@@ -879,7 +1137,7 @@ export class ResearchOrchestrator {
|
|
|
879
1137
|
this.log.info(`[orchestrator] Self-improvement: "${key}" resolved — removing from history`);
|
|
880
1138
|
}
|
|
881
1139
|
}
|
|
882
|
-
//
|
|
1140
|
+
// Always return at least 1, max 3
|
|
883
1141
|
const result = suggestions.slice(0, 3);
|
|
884
1142
|
if (result.length > 0) {
|
|
885
1143
|
this.writeSuggestionsToFile(result);
|