Implement LAIN ↔ Supercharged Glyph Bridge

New module:
- gx_lain/lain_glyph_bridge.py: Bridge connecting LedoGlyph600 to LAIN cognition

Functions:
- load_glyph_context(manifest, context): Load relevant glyph from registry
- inject_glyph_metadata_into_lane(lane_result, glyph_context): Add glyph fields to lane
- compute_glyph_resonance(glyph_context): Calculate glyph resonance metrics
- augment_fused_symbol_with_glyphs(fused_symbol, glyph_context): Add glyph to final output

Modified:
- gx_lain/runtime.py: Integrate glyph bridge into execute_with_lain()
  * Load glyph context as step 1 of cognition
  * Inject glyph metadata into each lane result
  * Augment fused symbol with glyph context
  * Add glyph_resonance to diagnostics
  * Track glyph loading in cognition_trace

Tests:
- tests/test_lain_glyph_bridge.py: 10 comprehensive tests
  * Context loading (with/without glyph)
  * Metadata injection (preserves existing fields)
  * Resonance computation (4-component metric)
  * Symbol augmentation
  * Full integration test

Features:
- Glyph metadata: id, name, category, score, period, band
- Frequency signatures: praw (P, R, A, W)
- Activation envelopes: mode, score
- Lineage: signature, inheritance weight
- Symbolic anatomy: power, complexity, resonance, stability, connectivity, affinity
- Resonance profile: activation + frequency + symbolic metrics (0.0-1.0)

All 18 integration tests still passing (no regressions).
This commit is contained in:
GlyphRunner System
2026-05-20 17:41:47 -04:00
parent f5dba41cf2
commit 4bc49c90b3
3 changed files with 697 additions and 3 deletions
+36 -3
View File
@@ -376,7 +376,7 @@ def execute_with_lain(envelope: dict) -> dict:
"""Execute ExecutionEnvelope through LAIN cognition engine.
Real implementation: iterate through lanes, process each via lane processors,
fuse results, and return full ExecutionResult.
fuse results, integrate glyph metadata, and return full ExecutionResult.
Contract:
- Does not mutate input envelope
@@ -390,6 +390,12 @@ def execute_with_lain(envelope: dict) -> dict:
ExecutionResult dict with cognition_trace, fused_symbol, output_text, diagnostics
"""
from .lane_processors import process_lane
from .lain_glyph_bridge import (
load_glyph_context,
inject_glyph_metadata_into_lane,
compute_glyph_resonance,
augment_fused_symbol_with_glyphs,
)
start_time = time.time()
@@ -419,8 +425,24 @@ def execute_with_lain(envelope: dict) -> dict:
"note": "Loaded ExecutionEnvelope into LAIN cognition engine.",
})
# Step 1: Load glyph context
glyph_context = load_glyph_context(manifest, context)
cognition_trace.append({
"step": 1,
"lane": -1,
"segment_id": None,
"operation": "glyph_context_loaded",
"input": {"glyph_found": glyph_context.get("found", False)},
"output": {
"glyph_id": glyph_context.get("id"),
"glyph_name": glyph_context.get("name"),
"glyph_score": glyph_context.get("score"),
},
"note": f"Loaded glyph context: {glyph_context.get('name')}",
})
# Process each lane
step_num = 1
step_num = 2
for lane_id in sorted(lanes.keys()):
lane_start = time.time()
lane_segments = lanes.get(lane_id, [])
@@ -433,6 +455,10 @@ def execute_with_lain(envelope: dict) -> dict:
context,
manifest,
)
# Inject glyph metadata into lane result
lane_result = inject_glyph_metadata_into_lane(lane_result, glyph_context)
lane_results[lane_id] = lane_result
# Record timing
@@ -487,9 +513,15 @@ def execute_with_lain(envelope: dict) -> dict:
# Fuse lane results
fused_symbol = fuse_lanes(lane_results)
# Compute resonance
# Augment fused symbol with glyph metadata
fused_symbol = augment_fused_symbol_with_glyphs(fused_symbol, glyph_context)
# Compute lane resonance
resonance = compute_resonance(lane_results, context)
# Compute glyph resonance
glyph_resonance = compute_glyph_resonance(glyph_context)
# Render output text
output_text = render_output_text(fused_symbol, context)
@@ -500,6 +532,7 @@ def execute_with_lain(envelope: dict) -> dict:
"lane_timings": lane_timings,
"errors": errors,
"resonance": resonance,
"glyph_resonance": glyph_resonance,
"interface_version": INTERFACE_VERSION,
"elapsed": elapsed,
}