@timmeck/brain-core 2.36.64 → 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.
@@ -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;
@@ -2741,6 +2753,62 @@ export class ResearchOrchestrator {
2741
2753
  this.log.warn(`[orchestrator] Step 65 (outcome review) error: ${err.message}`);
2742
2754
  }
2743
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
+ }
2744
2812
  const duration = Date.now() - start;
2745
2813
  ts?.emit('orchestrator', 'reflecting', `Feedback Cycle #${this.cycleCount} complete (${duration}ms)`);
2746
2814
  this.log.info(`[orchestrator] ─── Feedback Cycle #${this.cycleCount} complete (${duration}ms) ───`);