Implement XIC v1.5: Symbolic Pipeline Abstraction with Glyph-Aware Transformations

Implements all phases of the symbolic pipeline extension:

**Phase 1: Symbolic Pipeline Abstraction**
- Created glyphos/symbolic_pipeline.py with:
  - SymbolicStep: tracks individual pipeline steps (name, kind, payload, context)
  - SymbolicPipelineResult: complete pipeline execution result (steps, output_text, fused_symbol)
  - run_symbolic_pipeline(prompt, context, glyph_id): high-level pipeline entrypoint
- Integrated with glyphos/__init__.py exports

**Phase 2: Glyph-Aware Transformations**
- Updated glyphos/cognitive_kernel.py:
  - run_symbolic_prompt() now thin wrapper around pipeline
  - Maintains backward compatibility
- Updated xic_ops.py operations:
  - op_RUN_PROMPT: uses pipeline in symbolic mode
  - op_STREAM: uses pipeline with line-by-line output
  - op_CALL_GLYPH: routes through pipeline with explicit glyph_id parameter
- Context propagation: glyph_id automatically injected into LAIN context

**Phase 3: XIC Instruction Semantics v1.5**
- Created XIC_SEMANTICS_v1_5.md:
  - Formal specification of all 9 XIC instructions
  - Complete semantics: preconditions, postconditions, side effects
  - Symbolic vs compressed behavior for each op
  - Context model and pipeline semantics
  - Execution paths (compressed vs symbolic)
  - Backward compatibility guarantees

**Phase 4: Demo Program & Validation**
- Created programs/demo_symbolic_pipeline.gx.json
  - Demonstrates symbolic pipeline with glyph-aware cognition
  - Uses CALL_GLYPH, RUN_PROMPT, SET_CONTEXT, CHAIN, LOG
- All 7 validation tests pass:
   Pipeline module imports
   Pipeline execution
   Glyph-aware transformations
   Demo program
   CALL_GLYPH result storage
   Backward compatibility
   run_symbolic_prompt() wrapper

**Phase 5: Final Report**
- Created XIC_SYMBOLIC_PIPELINE_REPORT.md
  - Architecture and module hierarchy
  - Integration points and data flow
  - Design decisions and rationale
  - Usage examples

Key Features:
- Step-level introspection: full SymbolicPipelineResult with step history
- Glyph-aware: explicit glyph_id routing through LAIN kernel
- Formal semantics: complete specification for tool builders
- Backward compatible: all v1 programs work unchanged
- No breaking changes: compressed execution path untouched

Constraints Met:
 No GPU code
 No XIC v2 binary container
 No .gx format changes
 Full backward compatibility
This commit is contained in:
GlyphRunner System
2026-05-21 01:27:49 -04:00
parent b4ba84c1d2
commit 6e0a586f51
11 changed files with 1010 additions and 50 deletions
+59 -16
View File
@@ -44,8 +44,15 @@ def op_SET_PARAM(ctx: XICContext, *args):
def op_RUN_PROMPT(ctx: XICContext, *args):
"""RUN_PROMPT <prompt>: Execute prompt against loaded model or symbolic cognition.
If ctx.symbolic_mode is True, routes through glyphos/cognitive_kernel.py.
Otherwise, routes to execute_gx() for compressed execution.
Symbolic behavior (ctx.symbolic_mode=True):
- Routes through symbolic pipeline (run_symbolic_pipeline).
- Uses ctx.params["context"] for execution context.
- Stores full pipeline result in ctx._state["last_symbolic_pipeline"].
Compressed behavior (ctx.symbolic_mode=False):
- Requires model_path to be set via LOAD_MODEL.
- Routes to execute_gx() for compressed execution.
- Stores result in ctx._state["last_result"].
"""
if not args:
raise ValueError("RUN_PROMPT requires a prompt argument")
@@ -53,10 +60,14 @@ def op_RUN_PROMPT(ctx: XICContext, *args):
prompt = str(args[0])
if ctx.symbolic_mode:
from glyphos.cognitive_kernel import run_symbolic_prompt
result = run_symbolic_prompt(prompt, context=ctx.params.get("context"))
print(f"[XIC-SYMBOLIC] {result}")
ctx._state["last_symbolic_result"] = result
from glyphos.symbolic_pipeline import run_symbolic_pipeline
pipeline_result = run_symbolic_pipeline(
prompt=prompt,
context=ctx.params.get("context")
)
print(f"[XIC-SYMBOLIC] {pipeline_result.output_text}")
ctx._state["last_symbolic_result"] = pipeline_result.output_text
ctx._state["last_symbolic_pipeline"] = pipeline_result
return
if not ctx.model_path:
@@ -84,19 +95,31 @@ def op_RUN_PROMPT(ctx: XICContext, *args):
def op_STREAM(ctx: XICContext, *args):
"""STREAM <prompt>: Execute and stream output line by line.
In symbolic mode, stream symbolic result. In compressed mode, stream compressed output.
Symbolic behavior (ctx.symbolic_mode=True):
- Routes through symbolic pipeline.
- Streams output_text line by line with [XIC-STREAM] prefix.
- Stores pipeline result in ctx._state["last_symbolic_pipeline"].
Compressed behavior (ctx.symbolic_mode=False):
- Routes to execute_gx().
- Streams result line by line with [XIC-STREAM] prefix.
- Stores result in ctx._state["last_result"].
"""
if not args:
raise ValueError("STREAM requires a prompt argument")
prompt = str(args[0])
if ctx.symbolic_mode:
from glyphos.cognitive_kernel import run_symbolic_prompt
result = run_symbolic_prompt(prompt, context=ctx.params.get("context"))
for chunk in str(result).split("\n"):
from glyphos.symbolic_pipeline import run_symbolic_pipeline
pipeline_result = run_symbolic_pipeline(
prompt=prompt,
context=ctx.params.get("context")
)
for chunk in str(pipeline_result.output_text).split("\n"):
if chunk.strip():
print(f"[XIC-STREAM] {chunk}")
ctx._state["last_symbolic_result"] = result
ctx._state["last_symbolic_result"] = pipeline_result.output_text
ctx._state["last_symbolic_pipeline"] = pipeline_result
return
if not ctx.model_path:
@@ -131,18 +154,38 @@ def op_CHAIN(ctx: XICContext, *args):
def op_CALL_GLYPH(ctx: XICContext, *args):
"""CALL_GLYPH <glyph_id> <payload>: Invoke cognition with a glyph context."""
"""CALL_GLYPH <glyph_id> <payload>: Invoke glyph-aware cognition.
Routes through symbolic pipeline with explicit glyph_id parameter.
The glyph_id is propagated into the pipeline context and used for
glyph-aware symbolic transformations in the LAIN layer.
Stores result with key "glyph_{glyph_id}" containing:
- output_text: Final text from cognition
- fused_symbol: Fused symbolic representation (if produced)
- steps: List of symbolic pipeline steps
"""
if not args:
raise ValueError("CALL_GLYPH requires glyph_id argument")
glyph_id = str(args[0])
payload = str(args[1]) if len(args) > 1 else ""
from glyphos.cognitive_kernel import run_symbolic_prompt
from glyphos.symbolic_pipeline import run_symbolic_pipeline
glyph_context = dict(ctx.params.get("context", {}))
glyph_context["glyph_id"] = glyph_id
result = run_symbolic_prompt(payload, context=glyph_context)
print(f"[XIC-GLYPH] {result}")
ctx._state[f"glyph_{glyph_id}"] = result
pipeline_result = run_symbolic_pipeline(
prompt=payload,
context=glyph_context,
glyph_id=glyph_id,
)
print(f"[XIC-GLYPH] {pipeline_result.output_text}")
ctx._state[f"glyph_{glyph_id}"] = {
"output_text": pipeline_result.output_text,
"fused_symbol": pipeline_result.fused_symbol,
"steps": [{"name": s.name, "kind": s.kind, "payload": str(s.payload)[:100]}
for s in pipeline_result.steps],
}
def op_SET_CONTEXT(ctx: XICContext, *args):