Skip to content

Commit c70952b

Browse files
committed
feat: Add learning cycle and validation tracking
Priority 2 & 3 Implementation: - Learning cycle tracking: Wrap run_learning_cycle() with track_task_execution() - Validation tracking: Wrap ValidationEngine.run() with track_task_execution() - Both use silent tracking (communicate_estimate=False) for internal data collection - Builds historical data for future time estimation improvements This completes the minimal viable self-tracking implementation: 1. Chat response integration (user-facing) 2. Learning cycle tracking (build data) 3. Validation tracking (build data)
1 parent f34b20a commit c70952b

2 files changed

Lines changed: 47 additions & 13 deletions

File tree

stillme_core/learning/scheduler.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,28 @@ async def run_learning_cycle(self) -> Dict[str, Any]:
119119
Returns:
120120
Dict with cycle results: cycle_number, entries_fetched, entries_added_to_rag, etc.
121121
"""
122-
start_time = datetime.now()
123122
cycle_number = self.cycle_count + 1
124123

125-
logger.info(f"🔄 Starting learning cycle #{cycle_number}...")
124+
# Track learning cycle execution time
125+
from stillme_core.monitoring import track_task_execution
126126

127-
try:
127+
# Determine complexity and size (will be updated after fetch)
128+
complexity = "moderate"
129+
size = 50 # Default estimate
130+
131+
with track_task_execution(
132+
task_description=f"Learning cycle #{cycle_number}",
133+
task_type="learning",
134+
complexity=complexity,
135+
size=size,
136+
metadata={"cycle_number": cycle_number},
137+
communicate_estimate=False # Internal tracking only
138+
):
139+
start_time = datetime.now()
140+
141+
logger.info(f"🔄 Starting learning cycle #{cycle_number}...")
142+
143+
try:
128144
# Step 1: Fetch from all sources
129145
all_entries = self.source_integration.fetch_all_sources(
130146
max_items_per_source=5,
@@ -234,11 +250,11 @@ async def run_learning_cycle(self) -> Dict[str, Any]:
234250
"status": "success"
235251
}
236252

237-
logger.info(f"✅ Learning cycle #{cycle_number} completed: {entries_added_to_rag} entries added to RAG in {processing_time:.2f}s")
238-
239-
return result
240-
241-
except Exception as e:
253+
logger.info(f"✅ Learning cycle #{cycle_number} completed: {entries_added_to_rag} entries added to RAG in {processing_time:.2f}s")
254+
255+
return result
256+
257+
except Exception as e:
242258
logger.error(f"❌ Error in learning cycle #{cycle_number}: {e}", exc_info=True)
243259

244260
# Record error in unified metrics

stillme_core/validation/chain.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,29 @@ def run(self, answer: str, ctx_docs: List[str], context_quality: Optional[str] =
107107
Returns:
108108
ValidationResult with overall status
109109
"""
110-
reasons: List[str] = []
111-
patched = answer
112-
has_citation = False
113-
low_overlap_only = False
114-
has_critical_failure = False # Track if any critical validator failed without patch
110+
# Track validation execution time (internal tracking)
111+
from stillme_core.monitoring import track_task_execution
112+
113+
num_validators = len(self.validators)
114+
response_length = len(answer)
115+
116+
with track_task_execution(
117+
task_description=f"Validation: {num_validators} validators",
118+
task_type="validation",
119+
complexity="moderate",
120+
size=response_length,
121+
metadata={
122+
"num_validators": num_validators,
123+
"num_context_docs": len(ctx_docs),
124+
"is_philosophical": is_philosophical
125+
},
126+
communicate_estimate=False # Internal tracking only
127+
):
128+
reasons: List[str] = []
129+
patched = answer
130+
has_citation = False
131+
low_overlap_only = False
132+
has_critical_failure = False # Track if any critical validator failed without patch
115133

116134
# Group validators into sequential and parallel groups
117135
sequential_validators = []

0 commit comments

Comments
 (0)