# LispM: A Live-Image AI Agent Runtime with a — Lock-Free CSP Sidecar Kernel

- **Report Number**: RINGS-TR-2026-03
- **Institution**: Research Institute for Network Geometry & Security (RINGS)
- **Author**: Ryan J. Kung
- **Web Full-Text Reader**: https://rings.edu.rs/papers/lispm/
- **Embedded PDF Reader**: https://rings.edu.rs/papers/lispm/?view=pdf
- **Direct PDF**: https://rings.edu.rs/papers/lispm.pdf (672 KB, 13 pages)

## Abstract

Modern AI coding and desktop agent harnesses execute outside the user's interactive software environment, communicating with editors and applications via file-system side effects, sprawling Model Context Protocol (MCP) schemas, or brittle pixel-scraping interfaces. Inverting this architecture—hosting agents directly as first-class objects inside a self-documenting live runtime image (in the Lisp Machine and Smalltalk tradition, realized atop GNU Emacs)—unifies the editor's unsaved buffers, undo trees, and introspection primitives with the agent runtime, collapsing dozens of ad-hoc tool wrappers into live image evaluation. However, hosting concurrent agents inside a 40-year-old single-threaded, stop-the-world garbage-collected Lisp image exposes a severe responsiveness ceiling: scanning multi-megabyte agent transcripts, searching repositories, negotiating TLS, or spawning subprocess bursts stalls the host event loop for hundreds of milliseconds. We present LispM, an in-image agent runtime that resolves this tension through a dual-Lisp split-kernel architecture. Stateful workspace semantics—editable Org-mode context buffers, dirty-buffer coherence, policy-mediated Lisp actions (run_lisp), out-of-tree Git turn journals, and condition/restart recovery—remain inside GNU Emacs's single-threaded image. Latency-critical parallel workloads are offloaded over a zero-eval S-expression wire protocol to lispm- kernel, a crash-isolated Steel Bank Common Lisp (SBCL) sidecar process coordinated exclusively via lock-free Communicating Sequential Processes (CSP) without a single domain mutex. Inside lispm-kernel, a single-owner sequential scheduler, broadcast cancellation gates, a 4 MiB byte-credit backpressure sink with wait-free control bypass, and an async-signal-safe CAS wakeup pipe drive parallel worker pools while Emacs ingests results in 3 ms frame-clock slices that yield immediately to keystrokes. Across 12-run benchmarks over 256 session transcripts (68.6 MB) alongside eight active streaming terminals, LispM cuts median worst-case UI stall from 196.31 ms in pure Emacs Lisp (and 6.64 ms in an earlier mutex sidecar) to 0.54 ms (366× lower; 0.25 ms max stall across a real 314.7 MiB developer trace, 1,268× lower) with zero host garbage collections, while run_lisp replay continuations reduce multi-file refactoring prompt payloads by 178× and prefix-folded Org parsing scales to 120k-token contexts in 3.49 ms.

## Section Outline

## 1 Introduction
## 2 Background and Motivation
### 2.1 From Lisp Machines to Modern Agent Harnesses
### 2.2 Anatomy of Stalls in Single-Threaded Image Hosts
### 2.3 Evolution Beyond FFI Modules and Mutexes
## 3 Image-Native Agent Harness
### 3.1 Agent Object Model and Permission Ceilings
### 3.2 The Buffer Is the Context: Prefix-Cache Co-Design
### 3.3 Policy-Mediated Lisp Actions and Replay Continuations
### 3.4 Live Buffer Coherence, Turn Journals, and Restarts
## 4 Lock-Free CSP Sidecar Kernel
### 4.1 Zero-Eval S-Expression Wire Protocol
### 4.2 CSP Process Topology and Primitives
### 4.3 Single-Owner Coordinator (\(P_{\text{scheduler}}\))
### 4.4 Async-Signal-Safe Subprocess Multiplexing
### 4.5 Frame-Clock Time-Sliced Host Ingestion
## 5 Split-Responsibility Subsystems
### 5.1 Incremental Session Indexing and \(P_{\text{cache}}\)
### 5.2 Dirty-Buffer-Coherent Parallel Search
### 5.3 Non-Blocking Downloads, HTTP Streaming, and Verified Prebuilts
### 5.4 Implementation Footprint
## 6 Evaluation
### 6.1 RQ1: Session Discovery and Real-World Traces
### 6.2 RQ2: CSP Scheduler Scaling, Cancellation, and Backpressure
### 6.3 RQ3: Subprocess Bursts, Env Ablation, and Search
### 6.4 RQ4: In-Image Harness Overhead, Replay Continuation, and Context Scaling
## 7 Discussion, Related Work, and Conclusion
### 7.1 Limitations and Future Directions
### 7.2 Related Work
### 7.3 Conclusion
## References

## Citation (BibTeX)

```bibtex
@techreport{kung2026lispm,
  author      = {Ryan J. Kung},
  title       = {LispM: A Live-Image AI Agent Runtime with a — Lock-Free CSP Sidecar Kernel},
  institution = {Research Institute for Network Geometry & Security (RINGS)},
  year        = {2026},
  number      = {RINGS-TR-2026-03},
  url         = {https://rings.edu.rs/papers/lispm/}
}
```
