Skip to content

Commit 2554ce8

Browse files
committed
init: kvlang project scaffold
- README with architecture overview - pyproject.toml (redis + pyyaml deps) - .gitignore - src/kvlang/ and tests/ stubs
0 parents  commit 2554ce8

5 files changed

Lines changed: 137 additions & 0 deletions

File tree

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
__pycache__/
2+
*.pyc
3+
.venv/
4+
.env
5+
*.egg-info/
6+
dist/
7+
.pytest_cache/

README.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# kvlang
2+
3+
基于 Redis KV 空间的声明式图解释器。Livebyte 运行时的核心引擎。
4+
5+
## 定位
6+
7+
```
8+
livebyte(语言+工具链)
9+
10+
11+
kvlang(解释执行引擎) ← 本项目
12+
13+
├── VM 图遍历、模板解析、拓扑排序、上下文压缩
14+
├── Scheduler LLM API 网关:优先级队列、速率限制、重试熔断
15+
└── Workers 执行器:bash/file/http/llm/search/browser/subagent
16+
17+
18+
Redis(KV 存储) 所有状态持久化:fn/graph/session/tool/worker/lock
19+
```
20+
21+
## 核心概念
22+
23+
**kvlang 不编程,只解释。** 输入是编译后的函数图(JSON),输出是执行结果。
24+
语言层(LBL 语法、编译优化)属于 `livebyte` 项目,kvlang 只负责跑图。
25+
26+
```
27+
LBL 函数(YAML) 编译图(JSON)
28+
┌─────────────────┐ lbc ┌──────────────────┐ kvlang
29+
│ fn: review │ ────────▶ │ nodes / edges │ ──────────▶ 结果
30+
│ graph: ... │ 编译 │ deps / status │ 解释执行
31+
└─────────────────┘ └──────────────────┘
32+
```
33+
34+
## 安装
35+
36+
```bash
37+
pip install kvlang
38+
# 需要在本地或远端运行 Redis(默认 localhost:6379)
39+
```
40+
41+
## 快速开始
42+
43+
```bash
44+
# 启动 Worker
45+
kvlang worker start --all
46+
47+
# 启动调度器
48+
kvlang scheduler start
49+
50+
# 提交图执行
51+
kvlang run --fn code_review --input path=src/main.py
52+
53+
# 查看状态
54+
kvlang status --graph graph:abc123
55+
```
56+
57+
## 命令
58+
59+
| 命令 | 说明 |
60+
|------|------|
61+
| `kvlang run` | 提交函数图到 Redis,VM 自动开始执行 |
62+
| `kvlang worker` | 启动/停止各类 Worker |
63+
| `kvlang scheduler` | 启动调度器(LLM API 网关) |
64+
| `kvlang status` | 查看图执行进度、Worker 负载 |
65+
| `kvlang inspect` | 导出 Redis 中任意 key 的完整状态 |
66+
| `kvlang compact` | 手动触发某个 session 的上下文压缩 |
67+
| `kvlang clean` | 清理已完成的图和过期 session |
68+
69+
## Redis Schema
70+
71+
```
72+
kvlang:fn:{name} 函数定义
73+
kvlang:graph:{id} 执行中的图实例
74+
kvlang:graph:{id}:nodes HASH node_id → {status,output,elapsed}
75+
kvlang:graph:{id}:events STREAM 执行事件流
76+
kvlang:session:{id} HASH 对话 session
77+
kvlang:session:{id}:msgs LIST 消息历史
78+
kvlang:tool:{name} HASH 工具注册信息
79+
kvlang:worker:{id} HASH Worker 状态与心跳
80+
kvlang:worker:{id}:queue LIST 任务队列
81+
kvlang:scheduler:queue ZSET 优先级队列
82+
kvlang:lock:{resource} STRING 分布式锁
83+
```
84+
85+
## 架构
86+
87+
```
88+
┌────────────────────────┐
89+
│ kvlang │
90+
│ │
91+
编译图 ──────────▶│ ┌──────────────────┐ │
92+
(from Redis) │ │ VM │ │
93+
│ │ 拓扑排序+执行 │ │
94+
│ └──────┬───────────┘ │
95+
│ │ │
96+
│ ┌────┴────┐ │
97+
│ │ dispatch│ │
98+
│ └────┬────┘ │
99+
│ │ │
100+
│ ┌──────┴───────┐ │
101+
│ │ │ │
102+
│ ▼ ▼ │
103+
│ Scheduler Worker池 │
104+
│ (LLM 网关) (bash/file │
105+
│ 优先级队列 http/...) │
106+
│ │ │ │
107+
└──┼──────────────┼───────┘
108+
│ │
109+
▼ ▼
110+
┌─────────────────────┐
111+
│ Redis │
112+
└─────────────────────┘
113+
```
114+
115+
## License
116+
117+
MIT

pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[project]
2+
name = "kvlang"
3+
version = "0.1.0"
4+
description = "KV-based declarative graph interpreter for Livebyte runtime"
5+
requires-python = ">=3.10"
6+
dependencies = ["redis>=5", "pyyaml>=6"]
7+
8+
[project.scripts]
9+
kvlang = "kvlang.cli:main"
10+
11+
[build-system]
12+
requires = ["setuptools>=64"]
13+
build-backend = "setuptools.build_meta"

src/kvlang/__init__.py

Whitespace-only changes.

tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)