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:
@@ -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 <key> <value>` 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": ["<path_to_gx_file>"] }
|
||||
```
|
||||
|
||||
**Preconditions**
|
||||
- Argument must be a valid string (path).
|
||||
|
||||
**Postconditions**
|
||||
- `ctx.model_path = path`
|
||||
|
||||
**Side effects**
|
||||
- Prints `[XIC] Model loaded: <path>`
|
||||
|
||||
**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": ["<mode>"] }
|
||||
```
|
||||
|
||||
**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: <mode>`
|
||||
|
||||
**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": ["<key>", <value>] }
|
||||
```
|
||||
|
||||
**Preconditions**
|
||||
- Arguments: key (str), value (any).
|
||||
|
||||
**Postconditions**
|
||||
- `ctx.params[key] = value`
|
||||
|
||||
**Side effects**
|
||||
- Prints `[XIC] Parameter <key> = <value>`
|
||||
|
||||
**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": ["<key>", <value>] }
|
||||
```
|
||||
|
||||
**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 <key> = <value>`
|
||||
|
||||
**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": ["<prompt>"] }
|
||||
```
|
||||
|
||||
**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] <output_text>`
|
||||
- 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": ["<prompt>"] }
|
||||
```
|
||||
|
||||
**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": ["<label>"] }
|
||||
```
|
||||
|
||||
**Preconditions**
|
||||
- Argument: label (str).
|
||||
|
||||
**Postconditions**
|
||||
- `ctx.params["chain_label"] = label`
|
||||
|
||||
**Side effects**
|
||||
- Prints `[XIC-CHAIN] Entering chain: <label>`
|
||||
|
||||
**Remarks**
|
||||
- CHAIN is a control marker for human readability and logging.
|
||||
- It does not affect execution but allows grouping operations into named chains.
|
||||
- Chain label is preserved in `ctx.params` for inspection.
|
||||
|
||||
---
|
||||
|
||||
### 8. CALL_GLYPH
|
||||
|
||||
**Signature**
|
||||
```json
|
||||
{ "op": "CALL_GLYPH", "args": ["<glyph_id>", "<payload>"] }
|
||||
```
|
||||
|
||||
**Preconditions**
|
||||
- Arguments: glyph_id (str), payload (str, optional).
|
||||
|
||||
**Postconditions**
|
||||
- Stores result in `ctx._state[f"glyph_{glyph_id}"]` with:
|
||||
- `output_text`: Final text from cognition
|
||||
- `fused_symbol`: Fused symbolic representation (if produced)
|
||||
- `steps`: List of pipeline steps taken
|
||||
|
||||
**Symbolic behavior**
|
||||
- Calls `run_symbolic_pipeline(prompt=payload, context=glyph_context, glyph_id=glyph_id)`.
|
||||
- `glyph_context = ctx.params.get("context", {}) | {"glyph_id": glyph_id}`
|
||||
- Routes through symbolic pipeline with explicit glyph_id parameter.
|
||||
- The glyph_id is injected into LAIN context for glyph-aware transformations.
|
||||
- Prints `[XIC-GLYPH] <output_text>`
|
||||
|
||||
**Compressed behavior**
|
||||
- Not applicable. CALL_GLYPH is only used in symbolic mode.
|
||||
- If called in compressed mode, raises error (or gracefully falls back to symbolic).
|
||||
|
||||
**Remarks**
|
||||
- CALL_GLYPH enables glyph-aware cognition: the symbolic pipeline explicitly marks the operation as glyph-driven.
|
||||
- The LAIN kernel can use glyph_id to apply glyph-specific transformations or select glyph metadata.
|
||||
|
||||
---
|
||||
|
||||
### 9. LOG
|
||||
|
||||
**Signature**
|
||||
```json
|
||||
{ "op": "LOG", "args": ["<message>"] }
|
||||
```
|
||||
|
||||
**Preconditions**
|
||||
- Argument: message (str, optional).
|
||||
|
||||
**Postconditions**
|
||||
- None (pure side effect).
|
||||
|
||||
**Side effects**
|
||||
- Prints `[XIC-LOG] <message>`
|
||||
|
||||
**Remarks**
|
||||
- LOG is a no-op from an execution standpoint; purely for instrumentation and debugging.
|
||||
|
||||
---
|
||||
|
||||
## Symbolic Pipeline Semantics
|
||||
|
||||
### run_symbolic_pipeline() Entrypoint
|
||||
|
||||
```python
|
||||
def run_symbolic_pipeline(
|
||||
prompt: str,
|
||||
context: Dict[str, Any] | None = None,
|
||||
glyph_id: str | None = None,
|
||||
) -> SymbolicPipelineResult
|
||||
```
|
||||
|
||||
**Behavior**:
|
||||
1. Creates SymbolicStep for initial_prompt.
|
||||
2. If glyph_id is provided:
|
||||
- Adds glyph_id to context.
|
||||
- Creates SymbolicStep for glyph_call.
|
||||
3. Compresses prompt via GXCompressor.compress().
|
||||
4. Builds minimal manifest/segments.
|
||||
5. Calls CognitiveKernel.execute_symbolic(manifest, segments, payload, mode="symbolic", context=context).
|
||||
6. Extracts output_text and fused_symbol from result.
|
||||
7. If fused_symbol is present:
|
||||
- Creates SymbolicStep for fusion.
|
||||
8. Returns SymbolicPipelineResult(steps, output_text, fused_symbol).
|
||||
|
||||
### SymbolicPipelineResult
|
||||
|
||||
```python
|
||||
@dataclass
|
||||
class SymbolicPipelineResult:
|
||||
steps: List[SymbolicStep] # Execution steps taken
|
||||
output_text: str # Final text output
|
||||
fused_symbol: Optional[Dict] # Fused symbolic representation
|
||||
```
|
||||
|
||||
### SymbolicStep
|
||||
|
||||
```python
|
||||
@dataclass
|
||||
class SymbolicStep:
|
||||
name: str # Step name (e.g., "initial_prompt", "glyph:xyz", "fusion")
|
||||
kind: str # Step kind ("prompt", "glyph_call", "fused_symbol")
|
||||
payload: Any # Step data (prompt text, fused_symbol dict, etc.)
|
||||
context: Dict[str, Any] # Context at this step
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Execution Paths
|
||||
|
||||
### Compressed Path (ctx.symbolic_mode=False)
|
||||
|
||||
```
|
||||
RUN_PROMPT or STREAM
|
||||
↓
|
||||
Check ctx.model_path
|
||||
↓
|
||||
execute_gx(path, trace=..., profile=...)
|
||||
↓
|
||||
Load .gx binary → decompress via GSZ3 → compile → exec Python
|
||||
↓
|
||||
Store result in ctx._state["last_result"]
|
||||
```
|
||||
|
||||
### Symbolic Path (ctx.symbolic_mode=True)
|
||||
|
||||
```
|
||||
RUN_PROMPT or STREAM or CALL_GLYPH
|
||||
↓
|
||||
run_symbolic_pipeline(prompt, context, glyph_id)
|
||||
↓
|
||||
Compress prompt → build manifest/segments
|
||||
↓
|
||||
CognitiveKernel.execute_symbolic()
|
||||
↓
|
||||
LAIN 8-lane cognition (structural, semantic, compression, metadata, hints, predictive, imprint, epoch)
|
||||
↓
|
||||
Fuse lanes → produce output_text and fused_symbol
|
||||
↓
|
||||
Store SymbolicPipelineResult in ctx._state["last_symbolic_pipeline"]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Context Flow
|
||||
|
||||
**Example: Glyph-Aware Cognition**
|
||||
|
||||
```
|
||||
SET_CONTEXT "domain" "ai"
|
||||
SET_CONTEXT "style" "analytical"
|
||||
CALL_GLYPH "glyph://knowledge_integration" "How do compression and knowledge integrate?"
|
||||
```
|
||||
|
||||
**Flow**:
|
||||
1. SET_CONTEXT adds `context = {"domain": "ai", "style": "analytical"}` to `ctx.params["context"]`.
|
||||
2. CALL_GLYPH reads `context` and adds `glyph_id = "glyph://knowledge_integration"`.
|
||||
3. `run_symbolic_pipeline(prompt, context={"domain": "ai", "style": "analytical", "glyph_id": "..."}, glyph_id="...")` is called.
|
||||
4. Symbolic pipeline creates SymbolicStep(glyph_call, ...) with the full context.
|
||||
5. LAIN kernel executes with context, allowing glyph-aware transformations.
|
||||
6. Result (output_text, fused_symbol) is stored in `ctx._state["glyph_glyph://knowledge_integration"]`.
|
||||
|
||||
---
|
||||
|
||||
## Backward Compatibility
|
||||
|
||||
- All v1 XIC programs continue to work unchanged.
|
||||
- RUN_PROMPT behavior in compressed mode (symbolic_mode=False) is identical to v1.
|
||||
- New symbolic pipeline is additive and does not affect compressed execution.
|
||||
- run_symbolic_prompt() in glyphos/cognitive_kernel.py is a thin wrapper around the pipeline.
|
||||
|
||||
---
|
||||
|
||||
## Summary of Changes from v1
|
||||
|
||||
| Change | v1 | v1.5 |
|
||||
|--------|----|----|
|
||||
| Symbolic pipeline abstraction | Inline in run_symbolic_prompt | Separate glyphos/symbolic_pipeline.py |
|
||||
| Glyph-aware transformations | Manual context manipulation | Explicit glyph_id parameter in run_symbolic_pipeline |
|
||||
| Pipeline introspection | Limited (just output_text) | Full SymbolicPipelineResult (steps, fused_symbol) |
|
||||
| Formal semantics | Implicit (docstrings) | Explicit (XIC_SEMANTICS_v1_5.md) |
|
||||
|
||||
---
|
||||
|
||||
**End of Specification**
|
||||
@@ -0,0 +1,381 @@
|
||||
# XIC v1.5 Symbolic Pipeline Extension Report
|
||||
|
||||
**Date**: 2026-05-21
|
||||
**Status**: ✅ Complete and validated
|
||||
**Scope**: Symbolic pipeline abstraction + glyph-aware transformations + formal semantics
|
||||
|
||||
---
|
||||
|
||||
## Executive Summary
|
||||
|
||||
Extended XIC v1 to v1.5 with:
|
||||
|
||||
1. **Symbolic Pipeline Abstraction** (`glyphos/symbolic_pipeline.py`)
|
||||
- Explicit pipeline with step tracking
|
||||
- Data structures: SymbolicStep, SymbolicPipelineResult
|
||||
- Function: `run_symbolic_pipeline(prompt, context, glyph_id)`
|
||||
|
||||
2. **Glyph-Aware Transformations**
|
||||
- CALL_GLYPH now routes through pipeline with explicit glyph_id
|
||||
- Context includes glyph metadata for LAIN kernel
|
||||
- Fused symbols captured in results
|
||||
|
||||
3. **Formal Semantics Specification** (`XIC_SEMANTICS_v1_5.md`)
|
||||
- Complete instruction semantics for all 9 ops
|
||||
- Preconditions, postconditions, side effects
|
||||
- Context model and pipeline flow
|
||||
- Backward compatibility guarantees
|
||||
|
||||
**Zero breaking changes**. All XIC v1 programs work unchanged.
|
||||
|
||||
---
|
||||
|
||||
## Phase 1: Symbolic Pipeline Abstraction
|
||||
|
||||
### File: `glyphos/symbolic_pipeline.py`
|
||||
|
||||
#### Data Structures
|
||||
|
||||
```python
|
||||
@dataclass
|
||||
class SymbolicStep:
|
||||
name: str # e.g., "initial_prompt", "glyph:xyz", "fusion"
|
||||
kind: str # "prompt", "glyph_call", "fused_symbol"
|
||||
payload: Any # Step data
|
||||
context: Dict[str, Any] # Context at this step
|
||||
|
||||
@dataclass
|
||||
class SymbolicPipelineResult:
|
||||
steps: List[SymbolicStep] # Execution steps taken
|
||||
output_text: str # Final text output
|
||||
fused_symbol: Optional[Dict] # Fused symbolic representation
|
||||
```
|
||||
|
||||
#### Core Function
|
||||
|
||||
```python
|
||||
def run_symbolic_pipeline(
|
||||
prompt: str,
|
||||
context: Optional[Dict[str, Any]] = None,
|
||||
glyph_id: Optional[str] = None,
|
||||
) -> SymbolicPipelineResult
|
||||
```
|
||||
|
||||
**Behavior**:
|
||||
1. Creates SymbolicStep for initial_prompt
|
||||
2. If glyph_id: adds glyph_id to context, creates glyph_call step
|
||||
3. Compresses prompt → GSZ3
|
||||
4. Builds minimal manifest/segments
|
||||
5. Calls `CognitiveKernel.execute_symbolic(manifest, segments, payload, mode="symbolic", context=...)`
|
||||
6. Extracts output_text and fused_symbol
|
||||
7. If fused_symbol: creates fusion step
|
||||
8. Returns SymbolicPipelineResult
|
||||
|
||||
**Integration with Cognitive Kernel**:
|
||||
- Uses existing `CognitiveKernel.execute_symbolic()` API
|
||||
- Wraps it with step tracking and glyph-aware routing
|
||||
- No circular imports (lazy import in glyphos/cognitive_kernel.py)
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: Glyph-Aware Transformations
|
||||
|
||||
### Integration Points
|
||||
|
||||
#### 1. RUN_PROMPT
|
||||
|
||||
```python
|
||||
def op_RUN_PROMPT(ctx, *args):
|
||||
if ctx.symbolic_mode:
|
||||
pipeline_result = run_symbolic_pipeline(
|
||||
prompt=prompt,
|
||||
context=ctx.params.get("context")
|
||||
)
|
||||
ctx._state["last_symbolic_pipeline"] = pipeline_result
|
||||
```
|
||||
|
||||
**Stores**:
|
||||
- `last_symbolic_result`: output_text string
|
||||
- `last_symbolic_pipeline`: full SymbolicPipelineResult
|
||||
|
||||
#### 2. STREAM
|
||||
|
||||
Same routing as RUN_PROMPT, but streams output line-by-line.
|
||||
|
||||
#### 3. CALL_GLYPH
|
||||
|
||||
```python
|
||||
def op_CALL_GLYPH(ctx, *args):
|
||||
glyph_id = str(args[0])
|
||||
payload = str(args[1]) if len(args) > 1 else ""
|
||||
|
||||
glyph_context = dict(ctx.params.get("context", {}))
|
||||
glyph_context["glyph_id"] = glyph_id
|
||||
|
||||
pipeline_result = run_symbolic_pipeline(
|
||||
prompt=payload,
|
||||
context=glyph_context,
|
||||
glyph_id=glyph_id,
|
||||
)
|
||||
|
||||
ctx._state[f"glyph_{glyph_id}"] = {
|
||||
"output_text": pipeline_result.output_text,
|
||||
"fused_symbol": pipeline_result.fused_symbol,
|
||||
"steps": [step metadata...]
|
||||
}
|
||||
```
|
||||
|
||||
**Stores**:
|
||||
- Key: `glyph_{glyph_id}`
|
||||
- Value: Dict with output_text, fused_symbol, steps
|
||||
|
||||
### Context Propagation
|
||||
|
||||
```
|
||||
SET_CONTEXT "domain" "glyph_cognition"
|
||||
SET_CONTEXT "style" "analytic"
|
||||
CALL_GLYPH "glyph://compression" "prompt..."
|
||||
↓
|
||||
context = {"domain": "glyph_cognition", "style": "analytic", "glyph_id": "glyph://compression"}
|
||||
↓
|
||||
run_symbolic_pipeline(prompt, context, glyph_id)
|
||||
↓
|
||||
LAIN kernel processes with glyph-aware context
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 3: XIC Instruction Semantics v1.5
|
||||
|
||||
### File: `XIC_SEMANTICS_v1_5.md`
|
||||
|
||||
Comprehensive formal specification covering:
|
||||
|
||||
1. **Overview**: Dual execution modes (compressed/symbolic), architecture
|
||||
2. **XICContext model**: Field definitions, context propagation
|
||||
3. **Instruction semantics**: All 9 ops with:
|
||||
- Signature (JSON form)
|
||||
- Preconditions
|
||||
- Postconditions
|
||||
- Side effects
|
||||
- Symbolic vs compressed behavior
|
||||
4. **Symbolic pipeline semantics**: run_symbolic_pipeline, SymbolicPipelineResult, SymbolicStep
|
||||
5. **Execution paths**: Compressed and symbolic flowcharts
|
||||
6. **Context flow**: Example of glyph-aware cognition
|
||||
7. **Backward compatibility**: v1 → v1.5 changes
|
||||
|
||||
### Key Changes from v1
|
||||
|
||||
| Aspect | v1 | v1.5 |
|
||||
|--------|----|----|
|
||||
| Pipeline implementation | Inline in run_symbolic_prompt | Separate glyphos/symbolic_pipeline.py |
|
||||
| Glyph support | Manual context manipulation | Explicit glyph_id parameter |
|
||||
| Step tracking | None | Full SymbolicStep list |
|
||||
| Result structure | String only | SymbolicPipelineResult (steps + fused_symbol) |
|
||||
| Formal spec | Docstrings | XIC_SEMANTICS_v1_5.md |
|
||||
|
||||
---
|
||||
|
||||
## Phase 4: Demo Program and Validation
|
||||
|
||||
### Demo Program: `programs/demo_symbolic_pipeline.gx.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"instructions": [
|
||||
{ "op": "SET_MODE", "args": ["symbolic"] },
|
||||
{ "op": "SET_CONTEXT", "args": ["domain", "glyph_cognition"] },
|
||||
{ "op": "SET_CONTEXT", "args": ["style", "analytic"] },
|
||||
{ "op": "CHAIN", "args": ["glyph_analysis"] },
|
||||
{ "op": "LOG", "args": ["Starting glyph-aware symbolic pipeline"] },
|
||||
{ "op": "CALL_GLYPH", "args": ["glyph://compression", "..."] },
|
||||
{ "op": "RUN_PROMPT", "args": ["..."] }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Validation Results (7/7 Tests Passed)
|
||||
|
||||
✅ Symbolic pipeline module imports
|
||||
✅ run_symbolic_pipeline() execution
|
||||
✅ Glyph-aware pipeline (glyph_id parameter)
|
||||
✅ Demo symbolic pipeline program
|
||||
✅ CALL_GLYPH result storage (output_text, fused_symbol, steps)
|
||||
✅ Backward compatibility (demo_chat.gx.json)
|
||||
✅ run_symbolic_prompt() wrapper works
|
||||
|
||||
---
|
||||
|
||||
## Architecture
|
||||
|
||||
### Module Hierarchy
|
||||
|
||||
```
|
||||
glyphos/
|
||||
├── cognitive_kernel.py (CognitiveKernel, get_kernel, run_symbolic_prompt wrapper)
|
||||
├── symbolic_pipeline.py (SymbolicStep, SymbolicPipelineResult, run_symbolic_pipeline)
|
||||
├── events.py (EventBus, emit, on)
|
||||
└── __init__.py (exports all)
|
||||
|
||||
xic_ops.py
|
||||
└── Uses: run_symbolic_pipeline (lazy import inside ops)
|
||||
└── RUN_PROMPT, STREAM, CALL_GLYPH route through pipeline
|
||||
```
|
||||
|
||||
### Data Flow (Symbolic Mode)
|
||||
|
||||
```
|
||||
XIC Program
|
||||
↓
|
||||
RUN_PROMPT / STREAM / CALL_GLYPH
|
||||
↓
|
||||
run_symbolic_pipeline(prompt, context, glyph_id)
|
||||
↓
|
||||
[Step 1] Initial prompt
|
||||
[Step 2] Glyph call (if glyph_id present)
|
||||
[Step 3] Compress + build manifest
|
||||
[Step 4] CognitiveKernel.execute_symbolic()
|
||||
[Step 5] LAIN 8-lane cognition
|
||||
[Step 6] Fusion step (if fused_symbol present)
|
||||
↓
|
||||
SymbolicPipelineResult
|
||||
├── steps: [...SymbolicStep...]
|
||||
├── output_text: str
|
||||
└── fused_symbol: Dict | None
|
||||
↓
|
||||
Store in ctx._state
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Backward Compatibility
|
||||
|
||||
✅ **XIC v1 programs work unchanged**:
|
||||
- demo_chat.gx.json executes identically
|
||||
- execute_gx() behavior preserved
|
||||
- Compressed mode execution path unchanged
|
||||
|
||||
✅ **run_symbolic_prompt() thin wrapper**:
|
||||
- Existing code importing run_symbolic_prompt() still works
|
||||
- Now routes through pipeline (transparent upgrade)
|
||||
|
||||
✅ **No binary format changes**:
|
||||
- .gx files unchanged
|
||||
- JSON manifest format unchanged
|
||||
- GXIC1 magic and version unchanged
|
||||
|
||||
---
|
||||
|
||||
## Files Modified or Created
|
||||
|
||||
### Created
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| glyphos/symbolic_pipeline.py | Symbolic pipeline abstraction |
|
||||
| XIC_SEMANTICS_v1_5.md | Formal instruction semantics spec |
|
||||
| programs/demo_symbolic_pipeline.gx.json | Demo of glyph-aware pipeline |
|
||||
|
||||
### Modified
|
||||
|
||||
| File | Changes |
|
||||
|------|---------|
|
||||
| glyphos/__init__.py | +export SymbolicStep, SymbolicPipelineResult, run_symbolic_pipeline |
|
||||
| glyphos/cognitive_kernel.py | run_symbolic_prompt() → thin wrapper around pipeline |
|
||||
| xic_ops.py | op_RUN_PROMPT, op_STREAM, op_CALL_GLYPH → use pipeline |
|
||||
|
||||
### Unchanged (Backward Compatibility)
|
||||
|
||||
- xic_loader.py
|
||||
- xic_vm.py
|
||||
- xic_executor.py
|
||||
- runtime_executor/runner.py
|
||||
- All .gx binary files
|
||||
|
||||
---
|
||||
|
||||
## Key Design Decisions
|
||||
|
||||
### 1. Separate Pipeline Module (symbolic_pipeline.py)
|
||||
|
||||
**Rationale**: Makes pipeline structure explicit and testable. Enables step tracking without modifying core kernel.
|
||||
|
||||
### 2. SymbolicPipelineResult with Steps
|
||||
|
||||
**Rationale**: Supports introspection, debugging, and future enhancements (e.g., step replay, conditional routing).
|
||||
|
||||
### 3. Explicit glyph_id Parameter
|
||||
|
||||
**Rationale**: Makes glyph-aware cognition intentional and traceable. Simplifies context propagation.
|
||||
|
||||
### 4. Formal Semantics Specification
|
||||
|
||||
**Rationale**: Documents contract clearly for tool builders, enables static analysis, serves as implementation guide.
|
||||
|
||||
---
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Example 1: Symbolic Mode with Context
|
||||
|
||||
```bash
|
||||
glyph --xic -c "
|
||||
SET_MODE symbolic
|
||||
SET_CONTEXT domain compression_theory
|
||||
SET_CONTEXT style analytical
|
||||
RUN_PROMPT 'Explain lossy compression as a glyph.'
|
||||
"
|
||||
```
|
||||
|
||||
### Example 2: Glyph-Aware Cognition
|
||||
|
||||
```bash
|
||||
glyph --xic programs/demo_symbolic_pipeline.gx.json
|
||||
```
|
||||
|
||||
Results in:
|
||||
- `ctx._state["glyph_glyph://compression"]` with output_text, fused_symbol, steps
|
||||
- Full execution trace via SymbolicPipelineResult
|
||||
|
||||
---
|
||||
|
||||
## Testing
|
||||
|
||||
All validation tests pass:
|
||||
|
||||
```
|
||||
[TEST 1] Symbolic pipeline module imports ✅
|
||||
[TEST 2] run_symbolic_pipeline() execution ✅
|
||||
[TEST 3] Glyph-aware pipeline (glyph_id parameter) ✅
|
||||
[TEST 4] Demo symbolic pipeline program ✅
|
||||
[TEST 5] CALL_GLYPH result storage ✅
|
||||
[TEST 6] Backward compatibility ✅
|
||||
[TEST 7] run_symbolic_prompt() wrapper ✅
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## References
|
||||
|
||||
- **Formal Specification**: See `XIC_SEMANTICS_v1_5.md` for complete instruction semantics
|
||||
- **Previous Reports**: `XIC_SYMBOLIC_EXTENSION_REPORT.md` documents symbolic mode v1
|
||||
- **Cognitive Kernel**: `glyphos/cognitive_kernel.py` (CognitiveKernel.execute_symbolic API)
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
XIC v1.5 extends the v1 engine with:
|
||||
- Explicit symbolic pipeline abstraction
|
||||
- Glyph-aware transformations with context propagation
|
||||
- Formal instruction semantics specification
|
||||
- Full backward compatibility
|
||||
|
||||
**No breaking changes**. All XIC v1 programs continue to work unchanged.
|
||||
|
||||
---
|
||||
|
||||
**Implementation Complete** ✅
|
||||
**All tests passing** ✅
|
||||
**Backward compatible** ✅
|
||||
**Formal semantics documented** ✅
|
||||
Binary file not shown.
@@ -14,6 +14,12 @@ from .cognitive_kernel import (
|
||||
kernel_status,
|
||||
)
|
||||
|
||||
from .symbolic_pipeline import (
|
||||
SymbolicStep,
|
||||
SymbolicPipelineResult,
|
||||
run_symbolic_pipeline,
|
||||
)
|
||||
|
||||
from .events import (
|
||||
EventBus,
|
||||
Event,
|
||||
@@ -29,6 +35,9 @@ __all__ = [
|
||||
"run_gx",
|
||||
"run_symbolic_prompt",
|
||||
"kernel_status",
|
||||
"SymbolicStep",
|
||||
"SymbolicPipelineResult",
|
||||
"run_symbolic_pipeline",
|
||||
"EventBus",
|
||||
"Event",
|
||||
"EventType",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -258,11 +258,9 @@ class CognitiveKernel:
|
||||
|
||||
|
||||
def run_symbolic_prompt(prompt: str, context: dict | None = None) -> str:
|
||||
"""Entry point for symbolic execution from XIC.
|
||||
"""Thin wrapper around the symbolic pipeline for backward compatibility.
|
||||
|
||||
Compresses the prompt text into GSZ3 bytes, builds a minimal manifest,
|
||||
and routes through the full LAIN 8-lane cognition pipeline via
|
||||
CognitiveKernel.execute_symbolic(). Returns the output_text string.
|
||||
Routes through run_symbolic_pipeline() and returns output_text.
|
||||
|
||||
Args:
|
||||
prompt: User or system prompt text
|
||||
@@ -271,36 +269,9 @@ def run_symbolic_prompt(prompt: str, context: dict | None = None) -> str:
|
||||
Returns:
|
||||
String result from the 8-lane cognition pipeline
|
||||
"""
|
||||
from gx_compiler.compressor import GXCompressor
|
||||
|
||||
kernel = get_kernel()
|
||||
prompt_bytes = prompt.encode("utf-8")
|
||||
|
||||
try:
|
||||
payload = GXCompressor.compress(prompt)
|
||||
except Exception as e:
|
||||
return f"[Symbolic Error] Compression failed: {e}"
|
||||
|
||||
manifest = {
|
||||
"source_file": "<symbolic>",
|
||||
"source_type": "symbolic",
|
||||
"version": "1.0.0",
|
||||
"contributor": "XIC-symbolic",
|
||||
"segments": [{"id": "seg_0", "start": 0, "end": 1,
|
||||
"start_byte": 0, "end_byte": len(prompt_bytes)}],
|
||||
}
|
||||
segments = [{"id": "seg_0", "start": 0, "end": 1,
|
||||
"start_byte": 0, "end_byte": len(prompt_bytes)}]
|
||||
|
||||
result = kernel.execute_symbolic(
|
||||
manifest=manifest,
|
||||
segments=segments,
|
||||
payload=payload,
|
||||
mode="symbolic",
|
||||
context=context or {},
|
||||
)
|
||||
|
||||
return result.get("output_text") or result.get("fused_symbol", {}).get("summary", prompt)
|
||||
from .symbolic_pipeline import run_symbolic_pipeline
|
||||
result = run_symbolic_pipeline(prompt=prompt, context=context)
|
||||
return result.output_text
|
||||
|
||||
|
||||
# Global singleton kernel instance
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
"""Symbolic Pipeline Abstraction for XIC.
|
||||
|
||||
Provides a structured, glyph-aware pipeline for symbolic cognition execution.
|
||||
Routes prompts through the LAIN 8-lane cognition kernel with explicit step tracking.
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
|
||||
@dataclass
|
||||
class SymbolicStep:
|
||||
"""A single step in the symbolic pipeline execution."""
|
||||
name: str
|
||||
kind: str # "prompt", "glyph_call", "fused_symbol"
|
||||
payload: Any
|
||||
context: Dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
|
||||
@dataclass
|
||||
class SymbolicPipelineResult:
|
||||
"""Result of a symbolic pipeline execution."""
|
||||
steps: List[SymbolicStep]
|
||||
output_text: str
|
||||
fused_symbol: Optional[Dict[str, Any]] = None
|
||||
|
||||
|
||||
def run_symbolic_pipeline(
|
||||
prompt: str,
|
||||
context: Optional[Dict[str, Any]] = None,
|
||||
glyph_id: Optional[str] = None,
|
||||
) -> SymbolicPipelineResult:
|
||||
"""
|
||||
High-level symbolic pipeline entrypoint for XIC.
|
||||
|
||||
Accepts a prompt and optional symbolic/glyph context, routes through
|
||||
the LAIN 8-lane cognition kernel via CognitiveKernel.execute_symbolic(),
|
||||
and returns a structured SymbolicPipelineResult with execution steps,
|
||||
final output text, and fused symbolic representation.
|
||||
|
||||
Args:
|
||||
prompt: User or system prompt text.
|
||||
context: Optional dict of symbolic/cognitive context metadata.
|
||||
glyph_id: Optional glyph identifier for glyph-aware cognition.
|
||||
|
||||
Returns:
|
||||
SymbolicPipelineResult with:
|
||||
- steps: List of SymbolicStep objects tracking execution flow.
|
||||
- output_text: Final text result from cognition layer.
|
||||
- fused_symbol: Fused symbolic representation (if produced by LAIN).
|
||||
"""
|
||||
from gx_compiler.compressor import GXCompressor
|
||||
from .cognitive_kernel import get_kernel
|
||||
|
||||
steps: List[SymbolicStep] = []
|
||||
kernel = get_kernel()
|
||||
prompt_bytes = prompt.encode("utf-8")
|
||||
|
||||
# Step 1: Initial prompt
|
||||
steps.append(SymbolicStep(
|
||||
name="initial_prompt",
|
||||
kind="prompt",
|
||||
payload=prompt,
|
||||
context=dict(context or {})
|
||||
))
|
||||
|
||||
# Step 2: Prepare context for glyph-aware processing
|
||||
exec_context = dict(context or {})
|
||||
if glyph_id:
|
||||
exec_context["glyph_id"] = glyph_id
|
||||
steps.append(SymbolicStep(
|
||||
name=f"glyph:{glyph_id}",
|
||||
kind="glyph_call",
|
||||
payload=prompt,
|
||||
context=exec_context
|
||||
))
|
||||
|
||||
# Step 3: Compress prompt and build manifest
|
||||
try:
|
||||
payload = GXCompressor.compress(prompt)
|
||||
except Exception as e:
|
||||
return SymbolicPipelineResult(
|
||||
steps=steps,
|
||||
output_text=f"[Pipeline Error] Compression failed: {e}",
|
||||
fused_symbol=None
|
||||
)
|
||||
|
||||
manifest = {
|
||||
"source_file": "<symbolic>",
|
||||
"source_type": "symbolic",
|
||||
"version": "1.0.0",
|
||||
"contributor": "XIC-symbolic",
|
||||
"segments": [{"id": "seg_0", "start": 0, "end": 1,
|
||||
"start_byte": 0, "end_byte": len(prompt_bytes)}],
|
||||
}
|
||||
segments = [{"id": "seg_0", "start": 0, "end": 1,
|
||||
"start_byte": 0, "end_byte": len(prompt_bytes)}]
|
||||
|
||||
# Step 4: Execute through LAIN cognition pipeline
|
||||
result = kernel.execute_symbolic(
|
||||
manifest=manifest,
|
||||
segments=segments,
|
||||
payload=payload,
|
||||
mode="symbolic",
|
||||
context=exec_context,
|
||||
)
|
||||
|
||||
# Step 5: Extract results
|
||||
fused_symbol = result.get("fused_symbol")
|
||||
output_text = result.get("output_text") or (
|
||||
fused_symbol.get("summary") if fused_symbol else prompt
|
||||
)
|
||||
|
||||
# Step 6: Record fusion step if fused_symbol present
|
||||
if fused_symbol:
|
||||
steps.append(SymbolicStep(
|
||||
name="fusion",
|
||||
kind="fused_symbol",
|
||||
payload=fused_symbol,
|
||||
context={}
|
||||
))
|
||||
|
||||
return SymbolicPipelineResult(
|
||||
steps=steps,
|
||||
output_text=output_text,
|
||||
fused_symbol=fused_symbol
|
||||
)
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"magic": "GXIC1",
|
||||
"version": 1,
|
||||
"model": "",
|
||||
"entrypoint": "main",
|
||||
"symbols": {
|
||||
"main": 0
|
||||
},
|
||||
"instructions": [
|
||||
{ "op": "SET_MODE", "args": ["symbolic"] },
|
||||
{ "op": "SET_CONTEXT", "args": ["domain", "glyph_cognition"] },
|
||||
{ "op": "SET_CONTEXT", "args": ["style", "analytic"] },
|
||||
{ "op": "CHAIN", "args": ["glyph_analysis"] },
|
||||
{ "op": "LOG", "args": ["Starting glyph-aware symbolic pipeline"] },
|
||||
{ "op": "CALL_GLYPH", "args": ["glyph://compression", "Explain how compression acts as a cognitive glyph."] },
|
||||
{ "op": "RUN_PROMPT", "args": ["Summarize the previous explanation in one sentence."] }
|
||||
]
|
||||
}
|
||||
+59
-16
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user