Initial commit: 2125_GCE project

This commit is contained in:
GlyphRunner System
2026-07-09 12:54:44 -04:00
parent c3a826b65c
commit ae13f78c22
299 changed files with 124289 additions and 1031 deletions
Regular → Executable
+47 -28
View File
@@ -297,6 +297,13 @@ class CognitiveKernel:
result: Dict[str, Any]
) -> Dict[str, Any]:
"""Compute multi-glyph resonance metrics from execution result.
Uses actual glyph metadata from the registry to compute real resonance scores:
- weight: Based on glyph score and activation state
- lineage_score: From lineage.inheritanceWeight
- contributor_score: From originalMetrics connectivity
- frequency_score: From praw vector magnitude
- grammar_score: From originalMetrics stability
Args:
glyph_ids: List of glyph IDs to compute resonance for
@@ -309,21 +316,50 @@ class CognitiveKernel:
- global_resonance_score: Weighted average across glyphs
- guardrails_triggered: List of guardrail messages
"""
from glyphs import get_super
resonances = {}
scores = []
for glyph_id in glyph_ids:
# Compute 5-dimensional metrics for each glyph
# In real implementation, these would be computed from LAIN trace
# For now, use deterministic stubs based on glyph_id hash
base_score = (hash(glyph_id) % 100) / 100.0
glyph = get_super(glyph_id)
if not glyph:
continue
metrics = glyph.get('originalMetrics', {})
activation = glyph.get('activation', {})
lineage = glyph.get('lineage', {})
praw = glyph.get('praw', {})
# Compute weight from glyph score (max 335) and activation
score = glyph.get('score', 0)
activation_score = activation.get('score', 0)
weight = min(1.0, (score / 335) * 0.7 + (activation_score / 100) * 0.3)
# Compute lineage score from inheritance weight
inheritance_weight = lineage.get('inheritanceWeight', 0)
lineage_score = inheritance_weight
# Compute contributor score from connectivity metric
connectivity = metrics.get('connectivity', 50)
contributor_score = connectivity / 100
# Compute frequency score from praw vector magnitude
praw_values = [praw.get('P', 0), praw.get('R', 0), praw.get('A', 0), praw.get('W', 0)]
praw_magnitude = (sum(v * v for v in praw_values) ** 0.5) / 200
frequency_score = min(1.0, praw_magnitude)
# Compute grammar score from stability metric
stability = metrics.get('stability', 50)
grammar_score = stability / 100
metrics = {
"weight": min(1.0, 0.5 + (hash(f"{glyph_id}_w") % 50) / 100.0),
"lineage_score": min(1.0, 0.4 + (hash(f"{glyph_id}_l") % 60) / 100.0),
"contributor_score": min(1.0, 0.45 + (hash(f"{glyph_id}_c") % 55) / 100.0),
"frequency_score": min(1.0, 0.35 + (hash(f"{glyph_id}_f") % 65) / 100.0),
"grammar_score": min(1.0, 0.4 + (hash(f"{glyph_id}_g") % 60) / 100.0),
"weight": round(weight, 4),
"lineage_score": round(lineage_score, 4),
"contributor_score": round(contributor_score, 4),
"frequency_score": round(frequency_score, 4),
"grammar_score": round(grammar_score, 4),
}
resonances[glyph_id] = metrics
@@ -335,28 +371,11 @@ class CognitiveKernel:
return {
"glyph_ids": glyph_ids,
"resonances": resonances,
"global_resonance_score": min(1.0, global_resonance),
"global_resonance_score": round(min(1.0, global_resonance), 4),
"guardrails_triggered": [],
}
def run_symbolic_prompt(prompt: str, context: dict | None = None) -> str:
"""Thin wrapper around the symbolic pipeline for backward compatibility.
Routes through run_symbolic_pipeline() and returns output_text.
Args:
prompt: User or system prompt text
context: Optional symbolic/cognitive context dict
Returns:
String result from the 8-lane cognition pipeline
"""
from .symbolic_pipeline import run_symbolic_pipeline
result = run_symbolic_pipeline(prompt=prompt, context=context)
return result.output_text
# Global singleton kernel instance
_GLOBAL_KERNEL: Optional[CognitiveKernel] = None