Integrate XIC telemetry with FedMart (Phase 1)
Implement telemetry schema, adapter, and pipeline integration for FedMart real-time monitoring of XIC symbolic pipeline execution. ## Components ### Telemetry Schema (integrations/fedmart/telemetry_schema.json) - JSON schema defining XIC telemetry event structure - Required fields: event_type, timestamp, run_id, glyph_count, etc. - Optional: metadata, raw_payload for detailed analysis - Supports multi-glyph resonance summaries and guardrail events ### FedMart Adapter (integrations/fedmart/xic_adapter.py) - FedMartAdapter class for telemetry emission and spec registration - emit_telemetry(): normalize and forward telemetry events - register_spec_map(): push XIC specification status - Control hooks: pause_run(), throttle_run() for guardrail actions - Local mode (buffering) and remote mode (HTTP POST) - Global singleton instance via get_adapter() ### Pipeline Integration (glyphos/symbolic_pipeline.py) - Emit telemetry at end of run_symbolic_pipeline() - Captures: glyph_ids, resonance scores, execution steps, guardrails - Builds resonance_map_summary with top glyphs and averages - Optional import (graceful degradation if FedMart not available) ### Validation Suite (tests/validate_fedmart_integration.py) - 12 comprehensive tests covering all adapter functions - Tests: telemetry emission, normalization, spec registration - Tests: control actions, buffer operations, schema compliance - Tests: multi-glyph resonance tracking, guardrail event capture - All 12 tests passing ✅ ## Key Features ✅ Telemetry normalization (timestamp ISO 8601, run_id generation) ✅ Multi-glyph resonance summaries (top 5 glyphs, average resonance) ✅ Guardrail event tracking (truncation, max steps, etc.) ✅ Spec map registration for specification tracking ✅ Control actions (pause/throttle for guardrail responses) ✅ Local mode for testing, remote mode for production ✅ Schema compliance validation ✅ Graceful degradation if FedMart not available ## Testing All 12 validation tests passing: ✅ Schema validation ✅ Adapter initialization ✅ Telemetry emission (local mode) ✅ Normalization with defaults ✅ Spec map registration ✅ Control actions ✅ Pipeline telemetry integration ✅ Guardrail event capture ✅ Multi-glyph resonance tracking ✅ Buffer operations ✅ Schema compliance ✅ Empty buffer handling ## Next Steps Phase 2: UI Visualization - real-time dashboard for FedMart Phase 3: XIC v2 Control Flow - IF, MATCH, LOOP operations Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -303,6 +303,53 @@ def run_symbolic_pipeline(
|
||||
context={}
|
||||
))
|
||||
|
||||
# Build telemetry for FedMart integration
|
||||
try:
|
||||
from integrations.fedmart.xic_adapter import emit_telemetry
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
top_glyphs = []
|
||||
avg_resonance = 0.0
|
||||
|
||||
if fused_symbol and fused_symbol.resonance_map:
|
||||
top_glyphs = [
|
||||
{"glyph_id": glyph_id, "weight": metrics.weight}
|
||||
for glyph_id, metrics in fused_symbol.resonance_map.get_top_glyphs(5)
|
||||
]
|
||||
avg_resonance = fused_symbol.resonance_map.get_average_resonance()
|
||||
|
||||
telemetry = {
|
||||
"event_type": "symbolic_pipeline_run",
|
||||
"timestamp": datetime.utcnow().isoformat() + "Z",
|
||||
"program": exec_context.get("program", "<unknown>"),
|
||||
"chain_label": exec_context.get("chain_label"),
|
||||
"glyph_ids": fused_symbol.glyph_ids if fused_symbol else [],
|
||||
"glyph_count": len(fused_symbol.glyph_ids) if fused_symbol else 0,
|
||||
"global_resonance_score": fused_symbol.resonance_map.global_resonance_score
|
||||
if (fused_symbol and fused_symbol.resonance_map)
|
||||
else 0.0,
|
||||
"steps_executed": len(steps),
|
||||
"guardrails_triggered": guardrails_triggered,
|
||||
"resonance_map_summary": {
|
||||
"top_glyphs": top_glyphs,
|
||||
"average_resonance": avg_resonance,
|
||||
},
|
||||
"raw_payload": {
|
||||
"output_text": output_text,
|
||||
"fused_symbol_summary": (
|
||||
{"summary": fused_symbol.summary, "glyph_ids": fused_symbol.glyph_ids}
|
||||
if fused_symbol
|
||||
else None
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
emit_telemetry(telemetry)
|
||||
except ImportError:
|
||||
# FedMart integration optional
|
||||
pass
|
||||
|
||||
return SymbolicPipelineResult(
|
||||
steps=steps,
|
||||
output_text=output_text,
|
||||
|
||||
Reference in New Issue
Block a user