Files
GlyphRunner System 43887931cc Complete GlyphRunner Implementation: All Subsystems & Integration Tests
This commit includes the complete implementation of the GlyphRunner system:

SUBSYSTEMS CREATED:

1. xic_extensions (5 modules)
   - gsz3_decompressor: Compression/decompression with checksum validation
   - segment_runtime: Multi-segment execution with namespace merging
   - execution_tracer: Execution tracing with event capture
   - profiler: Lightweight segment profiling (duration, memory, counts)
   - compressed_engine: High-level orchestration (simulate/execute modes)

2. gx_compiler (5 modules)
   - segmenter: Deterministic source code segmentation
   - compressor: GSZ3 compression wrapper
   - manifest_builder: XIC/GX manifest generation
   - gx_packer: Binary .gx file format (XIC header + manifest + payload)
   - compiler: High-level compilation pipeline

3. runtime_executor (6 modules)
   - gx_loader: .gx file loading and parsing
   - execution_plan: Execution plan building from manifest
   - context: Runtime execution context management
   - runner: Core execution engine with tracing/profiling
   - events: Runtime event system and event bus
   - integration: High-level API (run_gx_with_summary)

4. gx_cli (5 modules)
   - commands: Command implementations (compile, run, inspect, summary)
   - parser: argparse-based argument parsing
   - dispatcher: Command routing and execution
   - main: CLI entry point with exception handling

5. codex_lineage (6 modules)
   - lineage_model: Data structures (EpochInfo, ContributorInfo, etc.)
   - epoch_mapper: Version string parsing (v1, v2.5-beta, etc.)
   - contributor_index: In-memory contributor registry
   - lineage_resolver: Manifest → CodexEntry resolution
   - grammar_hooks: Human-readable report generation
   - inspector: High-level .gx file inspection utility

INTEGRATION TESTS (7 test files)
- test_compile: Compilation pipeline tests
- test_run: Execution verification tests
- test_inspect: Inspection and manifest tests
- test_summary: Summary generation tests
- test_errors: Error handling and graceful failure
- test_determinism: Reproducibility and determinism
- run_all_tests: Master test runner

ARCHITECTURE HIGHLIGHTS:
✓ Zero circular imports
✓ Pure functions where possible
✓ Explicit error handling
✓ No global side effects
✓ Only stdlib dependencies
✓ Deterministic output
✓ Production-ready code

PIPELINE:
  sample.py → [gx_compiler] → sample.gx (960 bytes, XIC format)
           → [runtime_executor] → Execution (6 segments)
           → [codex_lineage] → Human-readable lineage report

CLI COMMANDS:
  gx compile <source.py> [-o output.gx]
  gx run <file.gx>
  gx inspect <file.gx>
  gx summary <file.gx>

VERIFICATION:
✓ All 5 subsystems created and tested
✓ Full pipeline: compile → inspect → execute
✓ Codex lineage fully integrated with gx_cli
✓ 25+ integration test cases
✓ End-to-end testing successful
✓ No external dependencies beyond Python stdlib

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-05-20 10:54:44 -04:00

154 lines
4.0 KiB
Python

import sys
from pathlib import Path
import xic_breakpoint_shell
from xic_executor import run_xic
from xic_validator import validate_xic
from xic_visualizer import xic_visualizer
from xic_diagnostics import xic_diagnostics
from xic_profiler import xic_profiler
from xic_cache import xic_cache
class CommandRegistry:
def __init__(self):
self.commands = {}
def register(self, name, handler):
self.commands[name] = handler
def dispatch(self, cmd, args):
if cmd in self.commands:
return self.commands[cmd](args)
return False
class XICShell:
def __init__(self):
self.last_file = None
self.registry = CommandRegistry()
xic_breakpoint_shell.register_breakpoint_commands(self)
self.registry.register("run", self.cmd_run)
self.registry.register("inspect", self.cmd_inspect)
self.registry.register("vis", self.cmd_vis)
self.registry.register("profile", self.cmd_profile)
self.registry.register("cache", self.cmd_cache)
self.registry.register("clear", self.cmd_clear)
self.registry.register("reload", self.cmd_reload)
self.registry.register("help", self.cmd_help)
self.registry.register("exit", self.cmd_exit)
self.registry.register("quit", self.cmd_exit)
def start(self):
print("XIC Interactive Shell")
print("Type 'help' for commands.\n")
while True:
try:
line = input("xic> ").strip()
except EOFError:
print("")
break
if not line:
continue
parts = line.split()
cmd = parts[0]
args = parts[1:]
handled = self.registry.dispatch(cmd, args)
if not handled:
print(f"Unknown command: {cmd}")
def cmd_run(self, args):
if not args:
print("Usage: run <file.gx>")
return True
gx = Path(args[0])
self.last_file = gx
run_xic(str(gx))
return True
def cmd_inspect(self, args):
if not args:
print("Usage: inspect <file.gx>")
return True
gx = Path(args[0])
self.last_file = gx
manifest = validate_xic(str(gx))
print("[XIC] Manifest:")
for k, v in manifest.items():
print(f" {k}: {v}")
return True
def cmd_vis(self, args):
if not args:
print("Usage: vis <file.gx>")
return True
gx = Path(args[0])
self.last_file = gx
manifest = validate_xic(str(gx))
xic_visualizer.report(manifest)
return True
def cmd_profile(self, args):
if not args:
print("Usage: profile <file.gx>")
return True
gx = Path(args[0])
self.last_file = gx
xic_profiler.reset()
run_xic(str(gx))
xic_profiler.report()
return True
def cmd_cache(self, args=None):
print("[XIC] Cache State:")
for key in xic_cache.cache.keys():
print(f" {key}")
return True
def cmd_clear(self, args=None):
xic_cache.cache.clear()
print("[XIC] Cache cleared")
return True
def cmd_reload(self, args=None):
if not self.last_file:
print("No previous file to reload")
return True
run_xic(str(self.last_file))
return True
def cmd_help(self, args=None):
print("Commands:")
for name in sorted(self.registry.commands.keys()):
print(f" {name}")
return True
def cmd_exit(self, args=None):
sys.exit(0)
xic_shell = XICShell()
def xic_cli(argv):
if not argv:
xic_shell.start()
return True
cmd = argv[0]
args = argv[1:]
return xic_shell.registry.dispatch(cmd, args)
if __name__ == "__main__":
if len(sys.argv) > 1:
cmd = sys.argv[1]
args = sys.argv[2:]
xic_shell.registry.dispatch(cmd, args)
else:
xic_shell.start()