@timmeck/brain-core 2.36.63 → 2.36.65
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/command-center.html +59 -2
- package/dist/action/handlers/index.d.ts +2 -0
- package/dist/action/handlers/index.js +1 -0
- package/dist/action/handlers/index.js.map +1 -1
- package/dist/action/handlers/mission-handler.d.ts +17 -0
- package/dist/action/handlers/mission-handler.js +49 -0
- package/dist/action/handlers/mission-handler.js.map +1 -0
- package/dist/action/index.d.ts +2 -2
- package/dist/action/index.js +1 -1
- package/dist/action/index.js.map +1 -1
- package/dist/dashboard/command-center-server.d.ts +1 -0
- package/dist/dashboard/command-center-server.js +13 -1
- package/dist/dashboard/command-center-server.js.map +1 -1
- package/dist/governance/engine-registry.d.ts +61 -0
- package/dist/governance/engine-registry.js +301 -0
- package/dist/governance/engine-registry.js.map +1 -0
- package/dist/governance/governance-layer.d.ts +75 -0
- package/dist/governance/governance-layer.js +231 -0
- package/dist/governance/governance-layer.js.map +1 -0
- package/dist/governance/index.d.ts +8 -0
- package/dist/governance/index.js +5 -0
- package/dist/governance/index.js.map +1 -0
- package/dist/governance/loop-detector.d.ts +46 -0
- package/dist/governance/loop-detector.js +266 -0
- package/dist/governance/loop-detector.js.map +1 -0
- package/dist/governance/runtime-influence-tracker.d.ts +50 -0
- package/dist/governance/runtime-influence-tracker.js +163 -0
- package/dist/governance/runtime-influence-tracker.js.map +1 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/metacognition/evolution-engine.d.ts +3 -0
- package/dist/metacognition/evolution-engine.js +25 -1
- package/dist/metacognition/evolution-engine.js.map +1 -1
- package/dist/narrative/narrative-engine.d.ts +4 -0
- package/dist/narrative/narrative-engine.js +17 -0
- package/dist/narrative/narrative-engine.js.map +1 -1
- package/dist/research/research-orchestrator.d.ts +12 -0
- package/dist/research/research-orchestrator.js +124 -5
- package/dist/research/research-orchestrator.js.map +1 -1
- package/package.json +1 -1
|
@@ -85,6 +85,10 @@ export class ResearchOrchestrator {
|
|
|
85
85
|
contentForge = null;
|
|
86
86
|
codeForge = null;
|
|
87
87
|
strategyForge = null;
|
|
88
|
+
engineRegistry = null;
|
|
89
|
+
runtimeInfluenceTracker = null;
|
|
90
|
+
loopDetector = null;
|
|
91
|
+
governanceLayer = null;
|
|
88
92
|
lastAutoMissionTime = 0;
|
|
89
93
|
lastGoalMissionTime = 0;
|
|
90
94
|
roadmapBootstrapped = false;
|
|
@@ -294,6 +298,14 @@ export class ResearchOrchestrator {
|
|
|
294
298
|
setCodeForge(forge) { this.codeForge = forge; }
|
|
295
299
|
/** Set the StrategyForge — autonomous strategy execution. */
|
|
296
300
|
setStrategyForge(forge) { this.strategyForge = forge; }
|
|
301
|
+
/** Set the EngineRegistry — formal engine profiles for governance. */
|
|
302
|
+
setEngineRegistry(registry) { this.engineRegistry = registry; }
|
|
303
|
+
/** Set the RuntimeInfluenceTracker — before/after snapshots for influence tracking. */
|
|
304
|
+
setRuntimeInfluenceTracker(tracker) { this.runtimeInfluenceTracker = tracker; }
|
|
305
|
+
/** Set the LoopDetector — anti-pattern detection. */
|
|
306
|
+
setLoopDetector(detector) { this.loopDetector = detector; }
|
|
307
|
+
/** Set the GovernanceLayer — active engine control. */
|
|
308
|
+
setGovernanceLayer(layer) { this.governanceLayer = layer; }
|
|
297
309
|
/** Set the LLMService — propagates to all engines that can use LLM. */
|
|
298
310
|
setLLMService(llm) {
|
|
299
311
|
this.llmService = llm;
|
|
@@ -637,6 +649,16 @@ export class ResearchOrchestrator {
|
|
|
637
649
|
}
|
|
638
650
|
ts?.emit('hypothesis', 'analyzing', 'Testing pending hypotheses...');
|
|
639
651
|
const testResults = this.hypothesisEngine.testAll();
|
|
652
|
+
// Quality filter: auto-reject weak hypotheses (confidence < 0.3 after testing)
|
|
653
|
+
const weak = testResults.filter(r => r.newStatus === 'testing' && r.confidence < 0.3 && (r.evidenceFor + r.evidenceAgainst) >= 3);
|
|
654
|
+
for (const w of weak) {
|
|
655
|
+
try {
|
|
656
|
+
this.db.prepare("UPDATE hypotheses SET status = 'rejected' WHERE id = ?").run(w.hypothesisId);
|
|
657
|
+
}
|
|
658
|
+
catch { /* best effort */ }
|
|
659
|
+
}
|
|
660
|
+
if (weak.length > 0)
|
|
661
|
+
this.log.debug(`[orchestrator] Rejected ${weak.length} weak hypotheses (confidence < 0.3)`);
|
|
640
662
|
const confirmed = testResults.filter(r => r.newStatus === 'confirmed');
|
|
641
663
|
const rejected = testResults.filter(r => r.newStatus === 'rejected');
|
|
642
664
|
if (confirmed.length > 0 || rejected.length > 0) {
|
|
@@ -821,6 +843,12 @@ export class ResearchOrchestrator {
|
|
|
821
843
|
catch { /* goal recording non-critical */ }
|
|
822
844
|
}
|
|
823
845
|
}
|
|
846
|
+
// Diagnostics: log prediction stats for debugging stale accuracy
|
|
847
|
+
try {
|
|
848
|
+
const summary = this.predictionEngine.getSummary();
|
|
849
|
+
this.log.debug(`[orchestrator] Prediction stats: total=${summary.total_predictions}, resolved=${summary.resolved ?? 'N/A'}, pending=${summary.pending ?? 'N/A'}, accuracy=${(summary.accuracy_rate * 100).toFixed(1)}%`);
|
|
850
|
+
}
|
|
851
|
+
catch { /* non-critical */ }
|
|
824
852
|
ts?.emit('prediction', 'predicting', 'Generating new predictions...');
|
|
825
853
|
const newPredictions = this.predictionEngine.autoPredictAll();
|
|
826
854
|
if (newPredictions.length > 0) {
|
|
@@ -1244,6 +1272,26 @@ export class ResearchOrchestrator {
|
|
|
1244
1272
|
this.log.debug(`[orchestrator] Auto-mission check error: ${err.message}`);
|
|
1245
1273
|
}
|
|
1246
1274
|
}
|
|
1275
|
+
// 18c. Curiosity Auto-Answer: periodically answer unanswered questions via NarrativeEngine
|
|
1276
|
+
if (this.curiosityEngine && this.narrativeEngine && this.cycleCount % (this.reflectEvery * 5) === 0) {
|
|
1277
|
+
try {
|
|
1278
|
+
const questions = this.curiosityEngine.getQuestions(10);
|
|
1279
|
+
const unanswered = questions.filter(q => !q.answered).slice(0, 2);
|
|
1280
|
+
for (const q of unanswered) {
|
|
1281
|
+
const answer = this.narrativeEngine.ask(q.question);
|
|
1282
|
+
if (answer.sources.length > 0 && q.id) {
|
|
1283
|
+
this.curiosityEngine.answerQuestion(q.id, answer.answer);
|
|
1284
|
+
this.log.debug(`[orchestrator] Auto-answered curiosity question #${q.id}: "${q.question.substring(0, 60)}"`);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
if (unanswered.length > 0) {
|
|
1288
|
+
ts?.emit('curiosity', 'exploring', `Auto-answered ${unanswered.length} curiosity question(s)`, 'routine');
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
catch (err) {
|
|
1292
|
+
this.log.debug(`[orchestrator] Curiosity auto-answer error: ${err.message}`);
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1247
1295
|
// 19. Emergence Tracking: detect emergent patterns + record complexity metrics
|
|
1248
1296
|
if (this.emergenceEngine && this.cycleCount % this.reflectEvery === 0) {
|
|
1249
1297
|
ts?.emit('emergence', 'exploring', 'Scanning for emergent behaviors...');
|
|
@@ -2442,8 +2490,8 @@ export class ResearchOrchestrator {
|
|
|
2442
2490
|
this.log.warn(`[orchestrator] Step 57 (roadmap) error: ${err.message}`);
|
|
2443
2491
|
}
|
|
2444
2492
|
}
|
|
2445
|
-
// Step 58: CreativeEngine — cross-pollination (every
|
|
2446
|
-
if (this.creativeEngine && this.cycleCount %
|
|
2493
|
+
// Step 58: CreativeEngine — cross-pollination (every reflectEvery cycles)
|
|
2494
|
+
if (this.creativeEngine && this.cycleCount % this.reflectEvery === 0) {
|
|
2447
2495
|
try {
|
|
2448
2496
|
const debugInfo = this.creativeEngine.getDebugInfo();
|
|
2449
2497
|
this.log.debug(`[orchestrator] Step 58: ${debugInfo.principlesCount} principles, domains: ${JSON.stringify(debugInfo.domains)}`);
|
|
@@ -2463,8 +2511,12 @@ export class ResearchOrchestrator {
|
|
|
2463
2511
|
});
|
|
2464
2512
|
}
|
|
2465
2513
|
else {
|
|
2466
|
-
|
|
2514
|
+
const domainCount = Object.keys(debugInfo.domains).length;
|
|
2515
|
+
this.log.debug(`[orchestrator] Step 58: 0 insights — ${domainCount} domain(s) (need 2+), ${debugInfo.principlesCount} principles`);
|
|
2516
|
+
ts?.emit('creative', 'reflecting', `Step 58: 0 insights (${debugInfo.principlesCount} principles, ${domainCount} domains)`, 'notable');
|
|
2467
2517
|
}
|
|
2518
|
+
if (this.metaCognitionLayer)
|
|
2519
|
+
this.metaCognitionLayer.recordStep('creative_engine', this.cycleCount, { insights: insights.length });
|
|
2468
2520
|
}
|
|
2469
2521
|
catch (err) {
|
|
2470
2522
|
this.log.warn(`[orchestrator] Step 58 (creative) error: ${err.message}`);
|
|
@@ -2701,6 +2753,62 @@ export class ResearchOrchestrator {
|
|
|
2701
2753
|
this.log.warn(`[orchestrator] Step 65 (outcome review) error: ${err.message}`);
|
|
2702
2754
|
}
|
|
2703
2755
|
}
|
|
2756
|
+
// Step 66: RuntimeInfluenceTracker — feed into CausalGraph (every 10 cycles)
|
|
2757
|
+
if (this.runtimeInfluenceTracker && this.causalGraph && this.cycleCount % 10 === 0) {
|
|
2758
|
+
try {
|
|
2759
|
+
ts?.emit('governance', 'analyzing', 'Step 66: Feeding engine influences into CausalGraph...', 'routine');
|
|
2760
|
+
this.runtimeInfluenceTracker.feedIntoCausalGraph(this.causalGraph);
|
|
2761
|
+
if (this.metaCognitionLayer)
|
|
2762
|
+
this.metaCognitionLayer.recordStep('influence_tracker', this.cycleCount, { insights: 0 });
|
|
2763
|
+
}
|
|
2764
|
+
catch (err) {
|
|
2765
|
+
this.log.warn(`[orchestrator] Step 66 (influence tracker) error: ${err.message}`);
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
// Step 67: LoopDetector — detect anti-patterns (every 10 cycles)
|
|
2769
|
+
if (this.loopDetector && this.cycleCount % 10 === 0) {
|
|
2770
|
+
try {
|
|
2771
|
+
ts?.emit('governance', 'analyzing', 'Step 67: Scanning for anti-patterns...', 'routine');
|
|
2772
|
+
const loopDetections = this.loopDetector.detect(this.cycleCount);
|
|
2773
|
+
if (loopDetections.length > 0) {
|
|
2774
|
+
ts?.emit('governance', 'discovering', `Step 67: ${loopDetections.length} anti-pattern(s) detected`, 'notable');
|
|
2775
|
+
this.journal.write({
|
|
2776
|
+
type: 'insight', title: `Loop Detector: ${loopDetections.length} anti-pattern(s)`,
|
|
2777
|
+
content: loopDetections.map(d => `${d.loopType}: ${d.description}`).join('\n'),
|
|
2778
|
+
tags: [this.brainName, 'governance', 'loop-detector'],
|
|
2779
|
+
references: [], significance: 'notable',
|
|
2780
|
+
data: { detections: loopDetections.length },
|
|
2781
|
+
});
|
|
2782
|
+
}
|
|
2783
|
+
if (this.metaCognitionLayer)
|
|
2784
|
+
this.metaCognitionLayer.recordStep('loop_detector', this.cycleCount, { insights: loopDetections.length });
|
|
2785
|
+
}
|
|
2786
|
+
catch (err) {
|
|
2787
|
+
this.log.warn(`[orchestrator] Step 67 (loop detector) error: ${err.message}`);
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
// Step 68: GovernanceLayer — auto-governance review (every 10 cycles)
|
|
2791
|
+
if (this.governanceLayer && this.cycleCount % 10 === 0) {
|
|
2792
|
+
try {
|
|
2793
|
+
ts?.emit('governance', 'analyzing', 'Step 68: Governance review...', 'routine');
|
|
2794
|
+
const decisions = this.governanceLayer.review(this.cycleCount);
|
|
2795
|
+
if (decisions.length > 0) {
|
|
2796
|
+
ts?.emit('governance', 'responding', `Step 68: ${decisions.length} governance decision(s)`, 'notable');
|
|
2797
|
+
this.journal.write({
|
|
2798
|
+
type: 'insight', title: `Governance: ${decisions.length} decision(s)`,
|
|
2799
|
+
content: decisions.map(d => `${d.action} → ${d.engine}: ${d.reason}`).join('\n'),
|
|
2800
|
+
tags: [this.brainName, 'governance', 'decisions'],
|
|
2801
|
+
references: [], significance: 'notable',
|
|
2802
|
+
data: { decisions: decisions.length },
|
|
2803
|
+
});
|
|
2804
|
+
}
|
|
2805
|
+
if (this.metaCognitionLayer)
|
|
2806
|
+
this.metaCognitionLayer.recordStep('governance_layer', this.cycleCount, { insights: decisions.length });
|
|
2807
|
+
}
|
|
2808
|
+
catch (err) {
|
|
2809
|
+
this.log.warn(`[orchestrator] Step 68 (governance) error: ${err.message}`);
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2704
2812
|
const duration = Date.now() - start;
|
|
2705
2813
|
ts?.emit('orchestrator', 'reflecting', `Feedback Cycle #${this.cycleCount} complete (${duration}ms)`);
|
|
2706
2814
|
this.log.info(`[orchestrator] ─── Feedback Cycle #${this.cycleCount} complete (${duration}ms) ───`);
|
|
@@ -3548,6 +3656,7 @@ export class ResearchOrchestrator {
|
|
|
3548
3656
|
if (this.featureRecommender) {
|
|
3549
3657
|
try {
|
|
3550
3658
|
const wishes = this.featureRecommender.getWishlist('matched');
|
|
3659
|
+
this.log.debug(`[selfmod] Source A: ${wishes.length} matched wishes`);
|
|
3551
3660
|
const actionable = wishes.find(w => w.priority >= 0.5 && w.matchScore >= 0.3);
|
|
3552
3661
|
if (actionable) {
|
|
3553
3662
|
// Try to get reference code from matched feature
|
|
@@ -3569,6 +3678,9 @@ export class ResearchOrchestrator {
|
|
|
3569
3678
|
}
|
|
3570
3679
|
catch { /* featureRecommender not ready */ }
|
|
3571
3680
|
}
|
|
3681
|
+
else {
|
|
3682
|
+
this.log.debug('[selfmod] Source A skipped: no featureRecommender');
|
|
3683
|
+
}
|
|
3572
3684
|
// ── Source B: CodeHealth issues → SelfMod suggestions ──
|
|
3573
3685
|
if (this.codeHealthMonitor) {
|
|
3574
3686
|
try {
|
|
@@ -3593,12 +3705,19 @@ export class ResearchOrchestrator {
|
|
|
3593
3705
|
}
|
|
3594
3706
|
catch { /* code health not ready */ }
|
|
3595
3707
|
}
|
|
3708
|
+
else {
|
|
3709
|
+
this.log.debug('[selfmod] Source B skipped: no codeHealthMonitor');
|
|
3710
|
+
}
|
|
3596
3711
|
// ── Source C: Existing suggestions (filtered — skip AutoResponder noise) ──
|
|
3597
|
-
if (!this.selfScanner)
|
|
3712
|
+
if (!this.selfScanner) {
|
|
3713
|
+
this.log.debug('[selfmod] Source C skipped: no selfScanner');
|
|
3598
3714
|
return null;
|
|
3715
|
+
}
|
|
3599
3716
|
const suggestions = this.generateSelfImprovementSuggestions();
|
|
3600
|
-
if (suggestions.length === 0)
|
|
3717
|
+
if (suggestions.length === 0) {
|
|
3718
|
+
this.log.debug('[selfmod] Source C: 0 suggestions from generateSelfImprovementSuggestions()');
|
|
3601
3719
|
return null;
|
|
3720
|
+
}
|
|
3602
3721
|
// Engine name → module file mapping heuristics
|
|
3603
3722
|
const engineMap = {
|
|
3604
3723
|
SelfObserver: ['research/self-observer'],
|