2013 assertions green · 44 MCP tools · 10 languages

Reinventing Code Operations for LLMs

Malong·Liuhe Toolkit — a code-operation toolchain designed for LLMs, not humans

Traditional tools assume users with hands, eyes and memory. LLMs have none of the three. We rebuilt the entire pipeline — from parsing to writing — around those three missing pieces.

98ms
repo_map response
588/s
peak throughput
65%
token savings
128concurrent
zero OOM
The Routing Map

Every tool tells you where to go next

44 tools form a routing network — every result carries a next_step: where to go on success, where to go on error. Six layers, six return loops.

flowchart TB
    classDef layer fill:#141419,stroke:#e8b86e,color:#f9ecd6,font-size:14px,font-weight:600;
    classDef loop fill:none,stroke:#6d6d6d,color:#b0b0b0,font-size:11px,stroke-dasharray:6 4;

    L1["① Locate & Understand
find, read, map the symbol"]:::layer L2["② Impact & Pre-edit
blast radius · collision check"]:::layer L3["③ Edit & Write
transactional edits · rename"]:::layer L4["④ Verify & Test
diff_facts → test_bridge"]:::layer L5["⑤ Quality & Hygiene
review · security · dead code"]:::layer L6["⑥ Commit & Ops
git_worktree · health · feedback"]:::layer L1 -->|ok → symbol found| L2 L2 -->|ok → safe to edit| L3 L3 -->|ok → committed| L4 L4 -->|ok → 0 failures| L5 L5 -->|ok → clean| L6 L4 -. "A · fail → debug_runner → fix" .-> L3 L4 -. "B · commit → diff_facts" .-> L4 L5 -. "C · issues → ③ fix → ④ verify" .-> L3 L2 -. "E · high risk → sandbox_validate" .-> L3 L2 -. "F · conflict → re-read" .-> L3 L1 -. "D · cycles → fix_imports (⑤)" .-> L5
Philosophy

Core Philosophy

Not an IDE plugin for human programmers — OS primitives for LLMs.

No Hands

LLMs cannot click, drag or confirm. Every operation must be atomic, undoable and retryable.

edit_transaction
transaction + rollback + undo journal

No Eyes

LLMs cannot "see" code structure. Output must be structured and self-explaining — JSON for direct consumption, errors with fix suggestions.

// errors carry a next_action
{ "error": "...", "suggestion": "..." }

No Memory

LLM context is finite and unstable. Every call must be self-contained — workspace-anchored, with optimistic version concurrency control.

read_symbol → write_symbol(base_version)
6-state conflict machine
Performance

Measured, Not Claimed

Real numbers under a real 512MB Docker cgroup limit — no paper benchmarks.

1ms
small-file read P95
50 runs, after warmup
7ms
small-file write P95
incl. post-write re-index
98ms
repo_map full repo
optimized from tens of seconds
588/s
peak throughput
60-600x LLM demand

All metrics

Metric Value Note
Memory footprint RSS 134MB / 26% docker --memory=512m real cgroup limit
Concurrency 128 conc / 256 in-flight zero OOM, zero tearing
Token savings ↓65.3% same task 7673 → 2662 est
Call count ↓50.0% old 6 steps → new 3 primitives
Index throughput 538 files / 7s scoped reindex measured
dry_run consistency 47/47 100% 3-language golden hashes
Concurrent writes, same symbol 16/16 no silent overwrite exactly one win, one conflict
Storm conflict matrix passed
32-way read/write mix on hot files → zero tearing, integrity_check PASS, 95/95 controlled conflicts
Architecture

Four-Layer Architecture

Not an MCP shell — a 4-layer parsing/indexing/writing infrastructure.

JS

Node.js orchestration

MCP protocol, 44-tool orchestration, error recovery, Semaphore scheduling

RS

Rust parser service

tree-sitter + tokio + rayon, Unix Socket IPC, catch_unwind crash isolation

DB

SQLite index layer

WAL mode, single-file DB, integrity_check self-heal, per-workspace isolation

IO

Transactional write layer

temp+rename atomic writes, 6-state conflict machine, undo journal

Node.js MCP Orchestration 44 Tools · JSON-RPC · Semaphore Rust malong-parse tree-sitter · tokio · rayon · LRU Cache SQLite Index WAL · integrity_check · Workspace Isolation Atomic Write + Transaction Unix Socket

Why Rust for parsing

  • Zero-copy strings: &source[byte_range] vs JS slice() allocations
  • No GC pauses: Node batch indexing stalls 1-5ms every 50ms
  • No N-API boundary: node-tree-sitter crosses the boundary per child()
  • rayon true parallelism: worker_threads pay startup costs

Crash isolation (harder than performance)

Old architecture
A parse crash kills the whole MCP process — once every 2-4h on average
New architecture
catch_unwind turns panics into a PARSE_PANIC error code — the MCP server keeps running
Toolbox

44 MCP Tools

From symbolic read/write to quality gates — the full code-operation chain. Pure regex/AST, zero LLM calls.

I/O Primitives
read_symbol
write_symbol / write_symbols
version-anchored writes + conflict machine
Index & Search
reindex · symbol_search
code_search · repo_map
98ms-class file maps, NL intent search
Analysis
impact_analysis · call_chain
references · dep_graph · inspect
blast radius, call chains, constant tracing
Editing
edit_batch · edit_transaction
edit_sandbox · rename_symbol
atomic transactions + rollback + cross-file rename
Quality Gates
code_review · security_review
sweep_dead_code · guard_patterns
deterministic, zero LLM, auditable
Engineering
test_bridge · verify_pipeline
debug_runner · patch_parser
test orchestration, pipeline gates, error analysis
Safety

Transactional Safe Writes

The threat here is not external attackers — it's the LLM itself, under concurrency, crashes and conflicts.

6-State Conflict Machine

CLEAN no conflict, write
FILE_CHANGED_SYMBOL_STABLE file changed, symbol stable
SYMBOL_CHANGED symbol body changed
SYMBOL_SIGNATURE_CHANGED signature changed, review
SYMBOL_DELETED / AMBIGUOUS deleted / undeterminable

Write Defense Pipeline

1
guardRealPath
symlink guard — never write outside workspace
2
acquireLock + TOCTOU detection
resolve+read+conflict inside the lock
3
createJournal + temp write
unique tmp names — resists symlink planting
4
renameRetry atomic commit
Windows EPERM/EBUSY auto-retry
Post-write re-index + syntax check
fresh index, node --check / py_compile

SIGKILL half-write recovery (tested)

test passed
SIGKILL
process force-killed
kill -9 child
Journal
undo journal keeps staged state
.malong/journal/ dir
Auto-rollback
half-written transaction auto-rolls back or stays
new_hash guards misjudgment
Self-Hosting

Self-Evolution

30+ rounds of "Malong reviews Malong" — the suite audits and fixes its own code, each round growing the assertion suite.

Test Matrix

0
JS assertions
81
test files
92
Rust assertions
0
failures
Full-chain tests green · 2026-08-13 (v0.4.5)

30+ Self-Review Rounds

r12-r30
dogfood end-to-end
directory scope filter bug fixed
registered-form dead-code false positives fixed
constant-tracing read-point loss fixed
SQL parameterization hardening
Every fix ships with a locking test — test blind spots are where bugs hide.

Determinism Guarantee

Every quality-gate tool makes zero LLM calls — pure regex/AST, same input always yields the same output. Reproducible, CI-ready, auditable.

300 protocol fuzz rounds fixed-seed determinism crash injection 89 golden assertions 16/16 concurrent, no silent overwrite
Multi-Language

10 Languages

A tree-sitter-based symbol extraction engine covering mainstream languages.

📜
JavaScript
✓ symbols ✓ refs
🔷
TypeScript
✓ symbols ✓ refs
⚛️
TSX / JSX
✓ symbols ✓ refs
🐍
Python
✓ symbols ✓ refs
🐹
Go
✓ symbols ✓ refs
⚙️
Rust
✓ symbols ✓ refs
impl / trait / enum
🔧
C / C++
✓ symbols ✓ refs
headers included
Java
✓ symbols ✓ refs
🐚
Bash
✓ symbols ✓ refs
📦
MTS / CTS
✓ symbols ✓ refs
Quick Start

Running in 10 Seconds

Standard install: git clone + npm ci — up in under a minute.

bash
# 1) Clone and install (full better-sqlite3 backend)
git clone <repo-url> liuhe && cd liuhe/malong
npm ci   # full backend, incl. Rust parser binary

# 2) Start the MCP server
node mcp-server.js --workspace /path/to/project

# 3) Self-check (30s)
node tests/test-mcp-server.js  # 25 assertions
Offline / sandbox? Use the build-free tarball

When npm ci is impossible, grab the tarball for your platform on the download page and extract it (sql.js sandbox backend; upgrade hint on boot). Full and degraded builds are feature-identical — only the backend differs.

MCP client configuration

opencode.json
{
  "mcp": {
    "malong": {
      "type": "local",
      "command": [
        "node",
        "--max-old-space-size=512",
        "malong/mcp-server.js",
        "--workspace", "."
      ],
      "enabled": true
    }
  }
}
Claude Desktop
{
  "mcpServers": {
    "malong": {
      "command": "node",
      "args": [
        "/path/to/malong/mcp-server.js",
        "--workspace",
        "/path/to/project"
      ]
    }
  }
}