Class: Assistant::BrainMaintenance
- Inherits:
-
Object
- Object
- Assistant::BrainMaintenance
- Defined in:
- app/services/assistant/brain_maintenance.rb
Overview
Daily autonomous pruning of the Sunny brain (driven by BrainMaintenanceWorker):
- Triage the pending queue — auto-REJECT ephemeral junk (BrainJunkClassifier).
Legit pending entries are left untouched for human approval — never auto-approved. - Compact the active global set — auto-apply BrainCompactor's archive / tighten /
consolidate recommendations. Safe to overwrite rule text because
AssistantBrainEntry is versioned (has_paper_trail) — every edit is reify-able.
Returns a Summary the worker emails as a digest. Bounded per run.
Defined Under Namespace
Constant Summary collapse
- MAX_REJECTIONS =
25- MAX_COMPACTIONS =
15
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.run! ⇒ Object
33 34 35 |
# File 'app/services/assistant/brain_maintenance.rb', line 33 def self.run! new.run! end |
Instance Method Details
#run! ⇒ Summary
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/services/assistant/brain_maintenance.rb', line 38 def run! before = always_on_weight rejected = triage_pending applied = compact_active Summary.new( rejected: rejected, applied: applied, pending_for_review: AssistantBrainEntry.pending.count, weight_before: before, weight_after: always_on_weight ) rescue StandardError => e Rails.logger.error("[BrainMaintenance] #{e.class}: #{e.}") Summary.new(error: e.) end |