
zongyuan-root-agent
io.github.tanbopiao/zongyuan-root-agent
Authorized execution agent MCP: task registry, level-based authorization, audit ledger, replay.
Documentation
zongyuan-root-agent 根仓代理
受权执行代理内核:任务在册、授权分级、执行留痕、重放可验,纯标准库。
|元枢体系 YUANSHU
定名语义
- 道统出处:枢纽之使,持圭行命——受根仓授权、代根仓行事的执行代理
- 工程映射:纯标准库的受权执行代理内核——命必在册、权必分级、行必留痕、史必可验
这是什么
一个纯标准库的受权执行代理内核:任务一律注册制(任务名+最低授权级别+处理函数),未注册的任务拒执行;代理持授权级别(见习、执事、主事、枢使),低于任务门槛即拒(越权即拒);每次执行记入只追加审计簿(逻辑钟、代理、任务、参数、结果),拒执行的命不入账;审计簿可重放执行史,逐位一致;摘要基于审计簿,一字被改必现形——「篡改现形」是本内核的第一契约。
道统映射
| 道统名 | 内核对象 | 职责 |
|---|---|---|
| 持圭 | RootAgent(name, level) | 代理持授权级别,级别不在册即拒 |
| 行命 | register / execute | 任务在册注册制,越权拒执行 |
| 留痕 | audit | 只追加审计簿,逐执行记录,拷贝隔离 |
| 复命 | replay | 从审计簿重放执行史,逐位一致 |
| 验圭 | digest | SHA-256(canonical 审计簿),篡改现形 |
快速开始
from zongyuan_root_agent import RootAgent
agent = RootAgent("代行使", "执事")
agent.register("问安", "见习", lambda p: {"greeting": f"你好,{p['name']}"})
agent.register("结算", "主事", lambda p: {"total": p["amount"] * p["rate"]})
print(agent.execute("问安", {"name": "昆仑"}))
agent.execute("结算", {"amount": 100, "rate": 7}) # 执事 < 主事:越权被拒
print(agent.audit()) # 执行史
print(agent.replay() == agent.audit()) # True:重放逐位一致
print(agent.digest()) # 摘要:篡改现形
命令行:
python tools/zongyuan_root_agent.py stats audit.json
python tools/zongyuan_root_agent.py digest audit.json
python tools/zongyuan_root_agent.py replay audit.json
MCP 门面
内核随长随开放:mcp_server/ 提供 stdio 门面,八件工具——register_task(注册任务,内建处理函数表选用)、execute(执行)、audit(审计簿)、replay(重放)、digest(摘要)、stats(清点)、builtins(内建清单)、describe(自述)。
python run_mcp_server.py # 一键启动 stdio MCP 服务器
门面依赖 mcp>=1.0(仅门面需要,内核保持纯标准库)。server.json 登记 io.github.tanbopiao/zongyuan-root-agent。
设计约定
- 纯标准库(
json/hashlib),无第三方依赖,无网络服务。 - 授权从严:任务未注册、级别越权、参数不合、处理函数不可调用一律
AgentError,不静默。 - 审计只追加:拒执行的命不入账;外界只拿到拷贝,改不动账。
- 摘要基于审计簿:任何一字被改,摘要必不一致——「篡改现形」是本内核的第一契约。
回归
regression.md 登记回归铁律(授权、执行、审计、重放、摘要五域契约)。运行:
python3 -m unittest discover -s . -p "test_*.py"
许可证
No installation packages available.
Related Servers
io.github.tanbopiao/agent-eval-engine
Verifiable agent evaluation engine: deterministic scoring, hash-chain audit trail, MCP over stdio.
io.github.tanbopiao/constraint-runtime
Agent constraint runtime: ten governance components plus a config-driven orchestration harness.
io.github.tanbopiao/evidence-gate
Evidence anchoring kernel MCP: append-only hash-chain ledger, tamper-evident snapshots, fail-closed.