From 6e0a586f519342107850757fb5788ef0b60501d6 Mon Sep 17 00:00:00 2001 From: GlyphRunner System Date: Thu, 21 May 2026 01:27:49 -0400 Subject: [PATCH] Implement XIC v1.5: Symbolic Pipeline Abstraction with Glyph-Aware Transformations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- XIC_SEMANTICS_v1_5.md | 411 ++++++++++++++++++ XIC_SYMBOLIC_PIPELINE_REPORT.md | 381 ++++++++++++++++ __pycache__/xic_ops.cpython-314.pyc | Bin 10027 -> 11749 bytes glyphos/__init__.py | 9 + glyphos/__pycache__/__init__.cpython-314.pyc | Bin 807 -> 949 bytes .../cognitive_kernel.cpython-314.pyc | Bin 15079 -> 13975 bytes .../symbolic_pipeline.cpython-314.pyc | Bin 0 -> 5163 bytes glyphos/cognitive_kernel.py | 39 +- glyphos/symbolic_pipeline.py | 127 ++++++ programs/demo_symbolic_pipeline.gx.json | 18 + xic_ops.py | 75 +++- 11 files changed, 1010 insertions(+), 50 deletions(-) create mode 100644 XIC_SEMANTICS_v1_5.md create mode 100644 XIC_SYMBOLIC_PIPELINE_REPORT.md create mode 100644 glyphos/__pycache__/symbolic_pipeline.cpython-314.pyc create mode 100644 glyphos/symbolic_pipeline.py create mode 100644 programs/demo_symbolic_pipeline.gx.json diff --git a/XIC_SEMANTICS_v1_5.md b/XIC_SEMANTICS_v1_5.md new file mode 100644 index 0000000..dc13830 --- /dev/null +++ b/XIC_SEMANTICS_v1_5.md @@ -0,0 +1,411 @@ +# XIC Instruction Semantics v1.5 + +**Version**: 1.5 +**Date**: 2026-05-21 +**Status**: Formal Specification + +--- + +## Overview + +XIC v1.5 is a symbolic and compressed execution virtual machine. It provides: + +1. **Dual execution modes**: Compressed (via execute_gx) and symbolic (via symbolic pipeline) +2. **Explicit instruction set semantics**: Formal definitions of preconditions, postconditions, and side effects +3. **Glyph-aware symbolic processing**: Integration with LAIN 8-lane cognition and glyph metadata +4. **Context propagation**: Symbolic context flows through chains of operations + +### Architecture + +``` +XICContext (model_path, mode, params, context, symbolic_mode, _state) + ↓ +XIC Instructions (9 ops in OP_TABLE) + ↓ +Dual paths: + - Compressed: execute_gx() → decompresses .gx → execs Python + - Symbolic: run_symbolic_pipeline() → LAIN 8 lanes → fused_symbol +``` + +--- + +## XICContext Model + +### Fields + +| Field | Type | Meaning | +|-------|------|---------| +| `model_path` | Optional[str] | Path to .gx model file. Set by LOAD_MODEL. | +| `mode` | str | Execution mode: "chat", "eval", "benchmark", "symbolic". Default: "chat". | +| `params` | Dict[str, Any] | Execution parameters (temperature, trace, profile, use_gpu, etc.). | +| `context` | Dict[str, Any] | (In params["context"]) Symbolic/cognitive context metadata (domain, style, glyph_id, etc.). | +| `symbolic_mode` | bool | True if mode == "symbolic". Controls routing in RUN_PROMPT/STREAM/CALL_GLYPH. | +| `_state` | Dict[str, Any] | Internal state: last_result, last_symbolic_result, last_symbolic_pipeline, glyph_* keys. | + +### Context Propagation + +- `SET_CONTEXT ` adds/updates keys in `ctx.params["context"]`. +- Context is passed to `run_symbolic_pipeline(context=...)` in symbolic operations. +- Glyph operations add `glyph_id` to context automatically. + +--- + +## Instruction Semantics + +### 1. LOAD_MODEL + +**Signature** +```json +{ "op": "LOAD_MODEL", "args": [""] } +``` + +**Preconditions** +- Argument must be a valid string (path). + +**Postconditions** +- `ctx.model_path = path` + +**Side effects** +- Prints `[XIC] Model loaded: ` + +**Symbolic behavior** +- No effect on `ctx.symbolic_mode`. + +**Compressed behavior** +- `ctx.model_path` is used by RUN_PROMPT/STREAM to load the .gx file. + +--- + +### 2. SET_MODE + +**Signature** +```json +{ "op": "SET_MODE", "args": [""] } +``` + +**Preconditions** +- `mode` ∈ {"chat", "eval", "benchmark", "symbolic", ...} + +**Postconditions** +- `ctx.mode = mode` +- If `mode == "symbolic"`: `ctx.symbolic_mode = True` +- If `mode != "symbolic"`: `ctx.symbolic_mode = False` + +**Side effects** +- Prints `[XIC] Mode set to: ` + +**Remarks** +- Setting mode to "symbolic" enables routing through symbolic pipeline (run_symbolic_pipeline). +- All other modes use compressed execution (execute_gx). + +--- + +### 3. SET_PARAM + +**Signature** +```json +{ "op": "SET_PARAM", "args": ["", ] } +``` + +**Preconditions** +- Arguments: key (str), value (any). + +**Postconditions** +- `ctx.params[key] = value` + +**Side effects** +- Prints `[XIC] Parameter = ` + +**Remarks** +- `use_gpu`, `trace`, `profile` are reserved parameter names. +- Parameters are passed to execute_gx (if used). + +--- + +### 4. SET_CONTEXT + +**Signature** +```json +{ "op": "SET_CONTEXT", "args": ["", ] } +``` + +**Preconditions** +- Arguments: key (str), value (any). + +**Postconditions** +- `ctx.params["context"][key] = value` +- If `ctx.params["context"]` doesn't exist, it is created. + +**Side effects** +- Prints `[XIC] Context = ` + +**Usage** +- Build symbolic context metadata: `SET_CONTEXT "domain" "ai"`, `SET_CONTEXT "style" "analytic"`. +- Context is passed to symbolic operations (RUN_PROMPT, STREAM, CALL_GLYPH). + +--- + +### 5. RUN_PROMPT + +**Signature** +```json +{ "op": "RUN_PROMPT", "args": [""] } +``` + +**Preconditions** +- Argument: prompt (str). + +**Postconditions** +- If `ctx.symbolic_mode == True`: + - `ctx._state["last_symbolic_result"] = output_text` + - `ctx._state["last_symbolic_pipeline"] = SymbolicPipelineResult` +- If `ctx.symbolic_mode == False`: + - Requires `ctx.model_path` to be set (LOAD_MODEL must be called first). + - `ctx._state["last_result"] = ExecutionContext` + +**Symbolic behavior** (ctx.symbolic_mode=True) +- Calls `run_symbolic_pipeline(prompt, context=ctx.params.get("context"))`. +- Routes through LAIN 8-lane cognition kernel. +- Prints `[XIC-SYMBOLIC] ` +- Stores full SymbolicPipelineResult for inspection (steps, fused_symbol). + +**Compressed behavior** (ctx.symbolic_mode=False) +- Calls `execute_gx(ctx.model_path, trace=ctx.params.get("trace"), profile=ctx.params.get("profile"))`. +- Decompresses .gx binary and executes Python code. +- Prints `[XIC] Execution complete` and result. + +**Remarks** +- The prompt argument is informational in compressed mode (not used). +- In symbolic mode, the prompt is the primary input to LAIN cognition. + +--- + +### 6. STREAM + +**Signature** +```json +{ "op": "STREAM", "args": [""] } +``` + +**Preconditions** +- Argument: prompt (str). + +**Postconditions** +- Same as RUN_PROMPT, but output is streamed line-by-line. + +**Symbolic behavior** +- Calls `run_symbolic_pipeline(prompt, context=...)`. +- Streams output_text line-by-line with `[XIC-STREAM]` prefix. +- Stores pipeline result in `ctx._state["last_symbolic_pipeline"]`. + +**Compressed behavior** +- Calls `execute_gx(...)`. +- Streams result line-by-line with `[XIC-STREAM]` prefix. + +**Side effects** +- Multiple print statements (one per line). + +--- + +### 7. CHAIN + +**Signature** +```json +{ "op": "CHAIN", "args": ["