progmune-runtime 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -0
- package/dist/action-runtime.js +1 -0
- package/dist/audit.js +4 -0
- package/dist/branch-ledger.js +28 -0
- package/dist/deterministic-replay.js +6 -0
- package/dist/emitter.js +31 -0
- package/dist/execute.js +9 -0
- package/dist/extract-ir.js +48 -6
- package/dist/failure-collector.js +20 -0
- package/dist/failure-corpus.js +26 -0
- package/dist/feedback.js +4 -0
- package/dist/immune-reporter.js +1 -0
- package/dist/ir-utils.js +18 -0
- package/dist/ledger-registry.js +11 -0
- package/dist/llm.js +3 -0
- package/dist/memory-layer.js +3 -0
- package/dist/planner.js +109 -18
- package/dist/protocol-registry.js +7 -0
- package/dist/repair-proposal.js +10 -0
- package/dist/runtime-invariants.js +9 -0
- package/dist/runtime.js +1 -0
- package/dist/search-planner.js +1 -0
- package/dist/semantic-snapshot.js +2 -0
- package/dist/session-utils.js +19 -0
- package/dist/ssg-validator.js +8 -0
- package/dist/utils.js +2 -0
- package/dist/validator.js +2 -0
- package/package.json +1 -1
- package/readme.md +0 -829
package/readme.md
DELETED
|
@@ -1,829 +0,0 @@
|
|
|
1
|
-
# Progmune Runtime(免序)
|
|
2
|
-
|
|
3
|
-
**程序免疫学:约束引导的程序合成运行时**
|
|
4
|
-
|
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
|
6
|
-
[](https://modelcontextprotocol.io)
|
|
7
|
-
[]()
|
|
8
|
-
|
|
9
|
-
Progmune(免序)不是一个 AI 编程助手,而是一个面向生成式程序的免疫系统。它将大语言模型(LLM)从开放世界的代码生成器,降级为在程序真相层(IR)严格约束下的启发式搜索器,确保生成的代码不仅在符号和类型上正确,更在行为协议上合法。
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## 目录
|
|
14
|
-
|
|
15
|
-
- [核心命题](#核心命题ai-生成的程序必须具备免疫系统)
|
|
16
|
-
- [架构概览](#架构概览一个会学习会记忆会防御的运行时)
|
|
17
|
-
- [语义有效性级别 (SVL)](#语义有效性级别-svl)
|
|
18
|
-
- [Semantic Observatory](#semantic-observatory语义观测台)
|
|
19
|
-
- [快速开始](#快速开始)
|
|
20
|
-
- [CLI 命令](#cli-命令)
|
|
21
|
-
- [MCP 工具](#mcp-工具)
|
|
22
|
-
- [LLM 后端配置](#llm-后端配置)
|
|
23
|
-
- [全球免疫网络](#全球免疫网络-global-immune-network)
|
|
24
|
-
- [常见问题](#常见问题)
|
|
25
|
-
- [Action 对象字段说明](#action-对象字段说明)
|
|
26
|
-
- [许可证](#许可证)
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## 核心命题:AI 生成的程序必须具备免疫系统
|
|
31
|
-
|
|
32
|
-
LLM 在生成代码时会产生"幻觉"——调用不存在的函数、违反类型约束、跳过关键的业务步骤。传统的提示工程和事后校验无法根除这些问题,因为它们将 LLM 置于系统的中心,缺乏第一性原理的约束。
|
|
33
|
-
|
|
34
|
-
Progmune 提出**程序免疫学(Program Immunology)**范式,为生成式程序建立一套可识别、可记忆、可进化的防御体系:
|
|
35
|
-
|
|
36
|
-
1. **天然免疫**:快速识别并拒绝违反符号存在性、类型兼容性和数据流规则的代码。
|
|
37
|
-
2. **获得性免疫**:从过去的失败案例中学习,生成特异性的防御规则,主动预防未来同类错误。
|
|
38
|
-
3. **免疫记忆**:将成功和失败的模式沉淀为结构化的知识,使系统随着使用持续进化,越用越可靠。
|
|
39
|
-
|
|
40
|
-
**详细理论框架请参阅《[Program Immunology 白皮书](./WHITEPAPER.md)》。**
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## 架构概览:一个会学习、会记忆、会防御的运行时
|
|
45
|
-
|
|
46
|
-
Progmune 的架构受生物免疫系统启发,分为三层:
|
|
47
|
-
|
|
48
|
-
| 生物免疫系统 | 程序免疫 (Progmune) | 核心职责 |
|
|
49
|
-
|:-------------|:--------------------|:---------|
|
|
50
|
-
| **天然免疫** | **约束引擎** (IR + SVL-1~SVL-3) | 快速、自动地拒绝调用不存在的函数、类型错误和数据流问题。 |
|
|
51
|
-
| **获得性免疫** | **语义状态图 (SSG)** | 通过可编程的状态机,精确拦截非法业务逻辑跃迁(如"未认证即签发令牌"),输出结构化修复路径。 |
|
|
52
|
-
| **免疫记忆** | **三层记忆 + Failure Corpus** | 工作记忆、情景记忆和语义记忆协同;失败基因组记录每次语义异常、修复路径和适应轨迹。 |
|
|
53
|
-
| **抗体生成** | **Antibody Registry** | 从失败中自动挖掘修复模式,按 ACL-1~4 置信度分级,生成候选免疫规则。 |
|
|
54
|
-
| **免疫观测** | **Semantic Observatory** | 终端原生语义观测工具——时间线、认知回放、状态机追踪、基因组热力图。 |
|
|
55
|
-
|
|
56
|
-
### SSG:语义状态图
|
|
57
|
-
|
|
58
|
-
SSG 是 Progmune 的协议级验证引擎。通过 `@protocol` JSDoc 注解声明函数的前置/后置状态和失效规则:
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
/**
|
|
62
|
-
* 签发 JWT 令牌
|
|
63
|
-
* @protocol pre_states=["PASSWORD_VERIFIED"] post_states=["TOKEN_ISSUED"] invalidate=["PASSWORD_VERIFIED"]
|
|
64
|
-
*/
|
|
65
|
-
export function generate_jwt(userId: string, expiresIn: number): string
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
当 AI 生成的代码违反协议时,SSG 输出结构化拒绝:被拦截的函数、当前状态、所需状态、缺失步骤和完整修复路径。
|
|
69
|
-
|
|
70
|
-
#### 资源中心 SSG(Resource-Centric SSG)
|
|
71
|
-
|
|
72
|
-
SSG 支持命名空间隔离的状态机,不同资源域(认证、文件、数据库)各自维护独立的状态空间:
|
|
73
|
-
|
|
74
|
-
```typescript
|
|
75
|
-
// 文件资源生命周期(namespace=file)
|
|
76
|
-
/** @protocol namespace=file pre_states=[] post_states=["FILE_OPEN"] */
|
|
77
|
-
export function open_file(path: string): FileHandle
|
|
78
|
-
|
|
79
|
-
/** @protocol namespace=file pre_states=["FILE_OPEN"] post_states=["FILE_READ"] */
|
|
80
|
-
export function read_file(fh: FileHandle): string
|
|
81
|
-
|
|
82
|
-
// 数据库资源生命周期(namespace=db)
|
|
83
|
-
/** @protocol namespace=db pre_states=[] post_states=["DB_CONNECTED"] */
|
|
84
|
-
export function connect_db(url: string): Connection
|
|
85
|
-
|
|
86
|
-
/** @protocol namespace=db pre_states=["DB_CONNECTED"] post_states=["DB_QUERIED"] */
|
|
87
|
-
export function query_db(conn: Connection, sql: string): Result[]
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
每个命名空间维护独立的状态集合,跨命名空间的函数调用互不干扰。命名空间初始状态可在 `protocols.json` 中通过 `namespaceInitialStates` 配置。
|
|
91
|
-
|
|
92
|
-
### 确定性修复规划器(Deterministic Repair Planner)
|
|
93
|
-
|
|
94
|
-
当 SSG 检测到协议违规时,规划器使用 **BFS 多跳修复路径搜索**自动补全缺失步骤:
|
|
95
|
-
|
|
96
|
-
```
|
|
97
|
-
违规:AI 尝试直接调用 generate_jwt(),但当前状态为 UNAUTHENTICATED
|
|
98
|
-
BFS 搜索:UNAUTHENTICATED → verify_password() → PASSWORD_VERIFIED → generate_jwt() → TOKEN_ISSUED
|
|
99
|
-
修复路径:[verify_password, generate_jwt]
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
BFS 搜索替代了原来的单跳线性扫描,可处理任意长度的协议缺口链。修复路径通过 SSG 校验后自动插入到 Action 序列中,无需 LLM 参与。
|
|
103
|
-
|
|
104
|
-
### Failure Corpus:AI 失败基因组
|
|
105
|
-
|
|
106
|
-
每次语义异常被记录为一条基因组记录,包含:违规 SVL 级别、约束类型、SSG 状态快照、修复路径、缺失函数、规划器重试次数。`IntentSession` 将同一意图的所有适应尝试链接为完整的"认知会话"——记录 AI 如何从失败中逐渐学会正确完成任务。
|
|
107
|
-
|
|
108
|
-
### 语义快照引擎(Semantic Snapshot Engine)
|
|
109
|
-
|
|
110
|
-
每次规划会话自动捕获 IR 快照,记录当时的所有函数名和签名。快照支持三种操作:
|
|
111
|
-
|
|
112
|
-
| 命令 | 用途 |
|
|
113
|
-
|:-----|:-----|
|
|
114
|
-
| `ts-node src/semantic-trace.ts --snapshots` | 列出所有 IR 快照 |
|
|
115
|
-
| `ts-node src/semantic-trace.ts --diff <idA> <idB>` | 比较两个快照的 IR 差异(新增/删除/变更函数) |
|
|
116
|
-
| `ts-node src/semantic-trace.ts --validate <sessionId>` | 确定性回放验证 |
|
|
117
|
-
|
|
118
|
-
### 确定性回放(Deterministic Replay)
|
|
119
|
-
|
|
120
|
-
`--validate` 命令将会话中的 Action 序列在快照 IR 和当前 IR 上分别校验,逐函数对比结果:
|
|
121
|
-
|
|
122
|
-
```
|
|
123
|
-
Action │ Snapshot IR │ Live IR │ Status
|
|
124
|
-
────────────────┼────────────────────┼────────────────────┼──────────
|
|
125
|
-
verify_password │ ✔ exists (1 param) │ ✔ exists (1 param) │ STABLE
|
|
126
|
-
generate_jwt │ ✔ exists (2 param) │ ✔ exists (2 param) │ STABLE
|
|
127
|
-
create_session │ ✔ exists (1 param) │ ✖ NOT FOUND │ REGRESSION
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
通过对比快照与当前 IR,可检测代码变更是否破坏了已有的正确修复路径。
|
|
131
|
-
|
|
132
|
-
### 抗体推理集成(Antibody Inference Integration)
|
|
133
|
-
|
|
134
|
-
抗体注册表中的修复模式已集成到规划器的推理层:
|
|
135
|
-
|
|
136
|
-
| ACL 级别 | 推理行为 |
|
|
137
|
-
|:---------|:---------|
|
|
138
|
-
| ACL-3 | 将已验证的修复路径注入 LLM 提示,约束其按已知正确顺序生成 |
|
|
139
|
-
| ACL-4 | 完全跳过 LLM——直接从 fixPath 构建 Action 序列,经 SSG 校验后返回(零 LLM 调用) |
|
|
140
|
-
|
|
141
|
-
抗体匹配使用 Jaccard 相似度(阈值 20%)将新意图与已知修复模式关联,实现"一次修复,永久免疫"。
|
|
142
|
-
|
|
143
|
-
### IR 外部函数提取
|
|
144
|
-
|
|
145
|
-
IR 提取器不仅捕获项目内声明的函数,还自动识别外部依赖函数(如 `readFileSync`、`parse`、`resolve` 等),为它们注册已知的 Node.js/JavaScript API 签名。这使得约束引擎可以对外部 API 调用进行 SVL-1~SVL-2 校验。
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
## 语义有效性级别 (SVL)
|
|
150
|
-
|
|
151
|
-
Progmune 定义了 AI 生成代码正确性的分层标准:
|
|
152
|
-
|
|
153
|
-
| 级别 | 名称 | 保证 |
|
|
154
|
-
|:-----|:-----|:-----|
|
|
155
|
-
| SVL-1 | 符号存在性 | 绝不调用项目中不存在的函数 |
|
|
156
|
-
| SVL-2 | 类型有效性 | 参数数量和类型严格匹配 |
|
|
157
|
-
| SVL-3 | 数据流正确性 | 变量先声明后使用,无循环引用 |
|
|
158
|
-
| SVL-4 | 协议合法性 | 业务步骤顺序必须遵守状态迁移规则 |
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
## Semantic Observatory(语义观测台)
|
|
163
|
-
|
|
164
|
-
终端原生的 AI 推理可观测性工具。零依赖,纯 ANSI + Unicode box-drawing。
|
|
165
|
-
|
|
166
|
-
```bash
|
|
167
|
-
# 会话摘要表
|
|
168
|
-
ts-node src/semantic-trace.ts
|
|
169
|
-
|
|
170
|
-
# 单会话完整时间线
|
|
171
|
-
ts-node src/semantic-trace.ts <sessionId>
|
|
172
|
-
|
|
173
|
-
# 逐步认知回放(含适应差异对比)
|
|
174
|
-
ts-node src/semantic-trace.ts replay <sessionId>
|
|
175
|
-
|
|
176
|
-
# 状态机转换追踪(+/− 状态获取/失效标记)
|
|
177
|
-
ts-node src/semantic-trace.ts --states <sessionId>
|
|
178
|
-
|
|
179
|
-
# 失败基因组(SVL 分布条状图)
|
|
180
|
-
ts-node src/semantic-trace.ts --genome
|
|
181
|
-
|
|
182
|
-
# 抗体注册表(ACL-1~4 置信度)
|
|
183
|
-
ts-node src/semantic-trace.ts --learned
|
|
184
|
-
|
|
185
|
-
# 语义热力图(脆弱协议 / 免疫层活跃度 / 约束共现 / 高摩擦任务)
|
|
186
|
-
ts-node src/semantic-trace.ts --heatmap
|
|
187
|
-
|
|
188
|
-
# 确定性回放(对比快照 IR vs 当前 IR,检测回归)
|
|
189
|
-
ts-node src/semantic-trace.ts --validate <sessionId>
|
|
190
|
-
|
|
191
|
-
# 列出所有 IR 快照
|
|
192
|
-
ts-node src/semantic-trace.ts --snapshots
|
|
193
|
-
|
|
194
|
-
# 比较两个快照的 IR 差异
|
|
195
|
-
ts-node src/semantic-trace.ts --diff <idA> <idB>
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### 抗体置信度级别 (ACL)
|
|
199
|
-
|
|
200
|
-
| 级别 | 标准 | 含义 |
|
|
201
|
-
|:-----|:-----|:-----|
|
|
202
|
-
| ACL-1 | 单案例观察 | 首次出现的修复模式,仅记录 |
|
|
203
|
-
| ACL-2 | 重复观察(2+ 会话) | 同一模式在多个会话中重现,标记关注 |
|
|
204
|
-
| ACL-3 | 跨任务验证(4+ 次或 3+ 独立意图) | 高置信候选,可考虑纳入默认规则 |
|
|
205
|
-
| ACL-4 | 全局稳定(10+ 次 / 5+ 独立意图) | 已验证的免疫规则,可自动应用 |
|
|
206
|
-
|
|
207
|
-
> ACL 门槛可通过环境变量配置:`PROGMUNE_ACL4_COUNT`(默认 10)、`PROGMUNE_ACL4_INTENTS`(默认 5)、`PROGMUNE_ACL3_COUNT`(默认 4)、`PROGMUNE_ACL3_INTENTS`(默认 3)、`PROGMUNE_ACL2_COUNT`(默认 2)。设置较低值可加速抗体升级。
|
|
208
|
-
|
|
209
|
-
---
|
|
210
|
-
|
|
211
|
-
## 快速开始
|
|
212
|
-
|
|
213
|
-
### 前置条件
|
|
214
|
-
|
|
215
|
-
- [Node.js](https://nodejs.org/) >= 18
|
|
216
|
-
- 一个有效的 LLM API 密钥(DeepSeek 或 OpenAI 兼容接口)
|
|
217
|
-
|
|
218
|
-
### 1. 安装
|
|
219
|
-
|
|
220
|
-
```bash
|
|
221
|
-
npm install -g progmune-runtime
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### 2. 配置 LLM API 密钥
|
|
225
|
-
|
|
226
|
-
```bash
|
|
227
|
-
# 方式一:快速配置(推荐)
|
|
228
|
-
npx progmune-runtime setup "你的DeepSeek或OpenAI密钥"
|
|
229
|
-
|
|
230
|
-
# 方式二:环境变量
|
|
231
|
-
export LLM_API_KEY="你的DeepSeek或OpenAI密钥"
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
支持多模型后端,详见 [LLM 后端配置](#llm-后端配置)。
|
|
235
|
-
|
|
236
|
-
### 3. 在 MCP 客户端中配置
|
|
237
|
-
|
|
238
|
-
**Claude Code** — 编辑 `~/.claude/settings.json`:
|
|
239
|
-
|
|
240
|
-
```json
|
|
241
|
-
{
|
|
242
|
-
"mcpServers": {
|
|
243
|
-
"progmune": {
|
|
244
|
-
"command": "npx",
|
|
245
|
-
"args": ["progmune-runtime"],
|
|
246
|
-
"env": {
|
|
247
|
-
"LLM_API_KEY": "你的DeepSeek或OpenAI密钥",
|
|
248
|
-
"LLM_BASE_URL": "https://api.deepseek.com/v1"
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
> `env` 字段是必需的。仅设置终端环境变量可能不会被 MCP 子进程继承。
|
|
256
|
-
|
|
257
|
-
**Manus / 其他客户端**:Command: `npx`, Args: `progmune-runtime`,并在客户端环境变量中配置 `LLM_API_KEY`。
|
|
258
|
-
|
|
259
|
-
### 4. 验证安装
|
|
260
|
-
|
|
261
|
-
```bash
|
|
262
|
-
npx progmune-runtime test
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
输出示例:
|
|
266
|
-
```
|
|
267
|
-
🧪 Progmune Runtime 自测试
|
|
268
|
-
✅ SVL-1: 存在函数通过
|
|
269
|
-
✅ SVL-1: 不存在函数拦截
|
|
270
|
-
✅ SVL-2: 参数数量匹配通过
|
|
271
|
-
✅ SVL-4: 非法跃迁拦截(无 auth)
|
|
272
|
-
📊 结果: 11/11 通过 (100%)
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
配置完成后,在对话中直接描述编程需求,AI 代理会自动调用 Progmune 生成安全代码。
|
|
276
|
-
|
|
277
|
-
---
|
|
278
|
-
|
|
279
|
-
## CLI 命令
|
|
280
|
-
|
|
281
|
-
| 命令 | 用途 |
|
|
282
|
-
|:-----|:------|
|
|
283
|
-
| `progmune-runtime setup <key>` | 配置向导,引导完成 LLM 密钥和 MCP 设置 |
|
|
284
|
-
| `progmune-runtime test` | 运行内置自测试(11 项),验证部署是否正常 |
|
|
285
|
-
| `progmune-runtime opt-in [enable\|disable\|status]` | 管理免疫网络上报 |
|
|
286
|
-
| `progmune-runtime` | 以 MCP 服务器模式运行(供 MCP 客户端调用) |
|
|
287
|
-
|
|
288
|
-
---
|
|
289
|
-
|
|
290
|
-
## MCP 工具
|
|
291
|
-
|
|
292
|
-
Progmune MCP 服务器暴露以下工具:
|
|
293
|
-
|
|
294
|
-
| 工具 | 描述 |
|
|
295
|
-
|:-----|:------|
|
|
296
|
-
| `progmune_generate` | 生成类型安全的 Python 代码(需传入 `intent` 和 `projectPath`) |
|
|
297
|
-
| `progmune_status` | 查看运行时状态、LLM 调用统计、免疫网络状况 |
|
|
298
|
-
|
|
299
|
-
**progmune_status 输出示例**:
|
|
300
|
-
|
|
301
|
-
```json
|
|
302
|
-
{
|
|
303
|
-
"version": "2.1.0",
|
|
304
|
-
"llm": { "model": "deepseek-chat", "callCount": 3, "apiKeySet": true },
|
|
305
|
-
"immuneNetwork": { "optIn": true, "hubReachable": true, "totalFailures": 14 }
|
|
306
|
-
}
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
---
|
|
310
|
-
|
|
311
|
-
## LLM 后端配置
|
|
312
|
-
|
|
313
|
-
通过 `LLM_PROVIDER` 环境变量切换后端:
|
|
314
|
-
|
|
315
|
-
### DeepSeek(默认)
|
|
316
|
-
|
|
317
|
-
```bash
|
|
318
|
-
export LLM_PROVIDER=deepseek
|
|
319
|
-
export LLM_API_KEY="你的密钥"
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
### OpenAI
|
|
323
|
-
|
|
324
|
-
```bash
|
|
325
|
-
export LLM_PROVIDER=openai
|
|
326
|
-
export LLM_API_KEY="你的密钥"
|
|
327
|
-
export LLM_BASE_URL=https://api.openai.com/v1
|
|
328
|
-
export LLM_MODEL=gpt-4
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
### Ollama(本地模型,无需联网)
|
|
332
|
-
|
|
333
|
-
```bash
|
|
334
|
-
export LLM_PROVIDER=ollama
|
|
335
|
-
# 默认使用 http://localhost:11434/v1,模型 llama3
|
|
336
|
-
# 可通过 LLM_BASE_URL 和 LLM_MODEL 覆盖
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
Ollama 模式不需要 `LLM_API_KEY`,适合完全离线使用。
|
|
340
|
-
|
|
341
|
-
---
|
|
342
|
-
|
|
343
|
-
## 全球免疫网络 (Global Immune Network)
|
|
344
|
-
|
|
345
|
-
Progmune 支持将本地脱敏后的错误指纹上报至中央免疫服务器,实现"群体免疫"。开启上报后,每次 `progmune_generate` 调用会自动上报。
|
|
346
|
-
|
|
347
|
-
### 开启上报
|
|
348
|
-
|
|
349
|
-
```bash
|
|
350
|
-
npx progmune-runtime opt-in enable
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
### 启动本地 Hub 服务器
|
|
354
|
-
|
|
355
|
-
```bash
|
|
356
|
-
# 启动(默认端口 8080)
|
|
357
|
-
node server/hub.js
|
|
358
|
-
|
|
359
|
-
# 访问仪表板
|
|
360
|
-
open http://localhost:8080/
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
仪表板包含实时统计、高频错误模式、SVL 分布和最近免疫事件时间线。
|
|
364
|
-
|
|
365
|
-
### 配置中央服务器地址
|
|
366
|
-
|
|
367
|
-
```bash
|
|
368
|
-
export PROGMUNE_HUB="http://localhost:8080/report"
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
### 预览和手动上报
|
|
372
|
-
|
|
373
|
-
```bash
|
|
374
|
-
# 预览待上报的脱敏数据
|
|
375
|
-
npx ts-node src/report.ts preview
|
|
376
|
-
|
|
377
|
-
# 手动执行安全上报
|
|
378
|
-
npx ts-node src/report.ts report
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
### 隐私保护
|
|
382
|
-
|
|
383
|
-
只上传函数名序列、SVL 级别、状态迁移,**绝不包含**任何代码片段、变量值或用户数据。
|
|
384
|
-
|
|
385
|
-
---
|
|
386
|
-
|
|
387
|
-
## 常见问题
|
|
388
|
-
|
|
389
|
-
遇到问题?请查阅 [FAQ.md](./FAQ.md),涵盖:
|
|
390
|
-
|
|
391
|
-
- 如何获取 API 密钥
|
|
392
|
-
- MCP 配置失败的排查步骤
|
|
393
|
-
- 免疫网络上报说明
|
|
394
|
-
- 数据隐私保障
|
|
395
|
-
- 错误调试指南
|
|
396
|
-
|
|
397
|
-
---
|
|
398
|
-
|
|
399
|
-
## Action 对象字段说明
|
|
400
|
-
|
|
401
|
-
当使用 Progmune 的 Action API 时,请遵循以下字段规范:
|
|
402
|
-
|
|
403
|
-
| 字段 | 类型 | 必填 | 说明 |
|
|
404
|
-
|------|------|------|------|
|
|
405
|
-
| `kind` | `"call" \| "if" \| "assign" \| "return"` | 是 | 动作类型 |
|
|
406
|
-
| `function` | `string` | 当 `kind` 为 `"call"` 时 | 被调用的函数名。**注意不是 `fn` 或 `name`** |
|
|
407
|
-
| `args` | `Arg[]` | 当 `kind` 为 `"call"` 时 | 参数列表,每个元素为 `{ name: string, type: string, value: any }` |
|
|
408
|
-
| `assignTo` | `string` | 否 | 将返回值绑定到的变量名 |
|
|
409
|
-
| `condition` | `string` | 当 `kind` 为 `"if"` 时 | 条件变量名,必须是已声明的变量 |
|
|
410
|
-
|
|
411
|
-
**常见错误**:使用 `action.fn` 代替 `action.function` 会导致校验器报告"函数 'undefined' 不存在"。
|
|
412
|
-
|
|
413
|
-
---
|
|
414
|
-
|
|
415
|
-
## 许可证
|
|
416
|
-
|
|
417
|
-
MIT License。
|
|
418
|
-
|
|
419
|
-
Progmune 正在重新定义 AI 辅助编程——不是"让模型更聪明",而是"让程序真相主导生成"。加入我们的技术预览,一起构建可验证的 AI 编码未来。
|
|
420
|
-
|
|
421
|
-
---
|
|
422
|
-
|
|
423
|
-
# Progmune Runtime
|
|
424
|
-
|
|
425
|
-
**Program Immunology: Constraint-Guided Program Synthesis Runtime**
|
|
426
|
-
|
|
427
|
-
[](https://opensource.org/licenses/MIT)
|
|
428
|
-
[](https://modelcontextprotocol.io)
|
|
429
|
-
[]()
|
|
430
|
-
|
|
431
|
-
Progmune is not an AI programming assistant, but an immune system for generative programs. It demotes Large Language Models (LLMs) from open-world code generators to heuristic searchers strictly constrained by the Program Truth Layer (IR), ensuring that generated code is not only symbolically and type-correct but also behaviorally legal.
|
|
432
|
-
|
|
433
|
-
---
|
|
434
|
-
|
|
435
|
-
## Table of Contents
|
|
436
|
-
|
|
437
|
-
- [Core Proposition](#core-proposition-ai-generated-programs-must-have-an-immune-system)
|
|
438
|
-
- [Architecture Overview](#architecture-overview-a-runtime-that-learns-remembers-and-defends)
|
|
439
|
-
- [Semantic Validity Levels (SVL)](#semantic-validity-levels-svl)
|
|
440
|
-
- [Semantic Observatory](#semantic-observatory)
|
|
441
|
-
- [Quick Start](#quick-start)
|
|
442
|
-
- [CLI Commands](#cli-commands)
|
|
443
|
-
- [MCP Tools](#mcp-tools)
|
|
444
|
-
- [LLM Backend Configuration](#llm-backend-configuration)
|
|
445
|
-
- [Global Immune Network](#global-immune-network)
|
|
446
|
-
- [FAQ](#faq)
|
|
447
|
-
- [Action Object Fields](#action-object-fields)
|
|
448
|
-
- [License](#license-1)
|
|
449
|
-
|
|
450
|
-
---
|
|
451
|
-
|
|
452
|
-
## Core Proposition: AI-Generated Programs Must Have an Immune System
|
|
453
|
-
|
|
454
|
-
LLMs often hallucinate when generating code—calling non-existent functions, violating type constraints, or skipping critical business steps. Traditional prompt engineering and post-hoc validation cannot eradicate these issues because they place the LLM at the center of the system, lacking first-principle constraints.
|
|
455
|
-
|
|
456
|
-
Progmune proposes the **Program Immunology** paradigm, establishing an identifiable, memorable, and evolvable defense system for generative programs:
|
|
457
|
-
|
|
458
|
-
1. **Innate Immunity**: Rapidly identify and reject code that violates symbolic existence, type compatibility, and dataflow rules.
|
|
459
|
-
2. **Adaptive Immunity**: Learn from past failure cases to generate specific defense rules, actively preventing similar future errors.
|
|
460
|
-
3. **Immune Memory**: Consolidate successful and failed patterns into structured knowledge, allowing the system to continuously evolve and become more reliable with use.
|
|
461
|
-
|
|
462
|
-
**For a detailed theoretical framework, please refer to the [Program Immunology Whitepaper](./WHITEPAPER.md).**
|
|
463
|
-
|
|
464
|
-
---
|
|
465
|
-
|
|
466
|
-
## Architecture Overview: A Runtime That Learns, Remembers, and Defends
|
|
467
|
-
|
|
468
|
-
Inspired by biological immune systems, Progmune's architecture consists of three layers:
|
|
469
|
-
|
|
470
|
-
| Biological Immune System | Program Immunology (Progmune) | Core Responsibility |
|
|
471
|
-
|:-------------------------|:------------------------------|:--------------------|
|
|
472
|
-
| **Innate Immunity** | **Constraint Engine** (IR + SVL-1~SVL-3) | Rapidly and automatically rejects calls to non-existent functions, type errors, and dataflow issues. |
|
|
473
|
-
| **Adaptive Immunity** | **Semantic State Graph (SSG)** | Precisely intercepts illegal business logic transitions (e.g., "issue token before authentication") via programmable state machines, outputting structured repair paths. |
|
|
474
|
-
| **Immune Memory** | **Three-Layer Memory + Failure Corpus** | Working, episodic, and semantic memory collaborate; the failure genome records every semantic anomaly, repair path, and adaptation trajectory. |
|
|
475
|
-
| **Antibody Synthesis** | **Antibody Registry** | Automatically mines repair patterns from failures, graded by ACL-1~4 confidence, generating candidate immune rules. |
|
|
476
|
-
| **Immune Observability** | **Semantic Observatory** | Terminal-native semantic observability tool — timeline, cognitive replay, state machine trace, genome heatmap. |
|
|
477
|
-
|
|
478
|
-
### SSG: Semantic State Graph
|
|
479
|
-
|
|
480
|
-
SSG is Progmune's protocol-level validation engine. Functions declare pre/post states and invalidation rules via `@protocol` JSDoc annotations:
|
|
481
|
-
|
|
482
|
-
```typescript
|
|
483
|
-
/**
|
|
484
|
-
* Issue JWT token
|
|
485
|
-
* @protocol pre_states=["PASSWORD_VERIFIED"] post_states=["TOKEN_ISSUED"] invalidate=["PASSWORD_VERIFIED"]
|
|
486
|
-
*/
|
|
487
|
-
export function generate_jwt(userId: string, expiresIn: number): string
|
|
488
|
-
```
|
|
489
|
-
|
|
490
|
-
When AI-generated code violates a protocol, SSG outputs a structured rejection: blocked function, current state, required state, missing steps, and a complete repair path.
|
|
491
|
-
|
|
492
|
-
#### Resource-Centric SSG
|
|
493
|
-
|
|
494
|
-
SSG supports namespace-isolated state machines, where different resource domains (auth, file, database) maintain independent state spaces:
|
|
495
|
-
|
|
496
|
-
```typescript
|
|
497
|
-
// File resource lifecycle (namespace=file)
|
|
498
|
-
/** @protocol namespace=file pre_states=[] post_states=["FILE_OPEN"] */
|
|
499
|
-
export function open_file(path: string): FileHandle
|
|
500
|
-
|
|
501
|
-
/** @protocol namespace=file pre_states=["FILE_OPEN"] post_states=["FILE_READ"] */
|
|
502
|
-
export function read_file(fh: FileHandle): string
|
|
503
|
-
|
|
504
|
-
// Database resource lifecycle (namespace=db)
|
|
505
|
-
/** @protocol namespace=db pre_states=[] post_states=["DB_CONNECTED"] */
|
|
506
|
-
export function connect_db(url: string): Connection
|
|
507
|
-
|
|
508
|
-
/** @protocol namespace=db pre_states=["DB_CONNECTED"] post_states=["DB_QUERIED"] */
|
|
509
|
-
export function query_db(conn: Connection, sql: string): Result[]
|
|
510
|
-
```
|
|
511
|
-
|
|
512
|
-
Each namespace maintains an independent state set; cross-namespace function calls do not interfere. Namespace initial states are configurable via `namespaceInitialStates` in `protocols.json`.
|
|
513
|
-
|
|
514
|
-
### Deterministic Repair Planner
|
|
515
|
-
|
|
516
|
-
When SSG detects a protocol violation, the planner uses **BFS multi-hop fixPath search** to automatically fill missing steps:
|
|
517
|
-
|
|
518
|
-
```
|
|
519
|
-
Violation: AI tried to call generate_jwt() directly, but current state is UNAUTHENTICATED
|
|
520
|
-
BFS search: UNAUTHENTICATED → verify_password() → PASSWORD_VERIFIED → generate_jwt() → TOKEN_ISSUED
|
|
521
|
-
Repair path: [verify_password, generate_jwt]
|
|
522
|
-
```
|
|
523
|
-
|
|
524
|
-
BFS search replaces the original single-hop linear scan, handling protocol gap chains of arbitrary length. Repair paths are validated through SSG and auto-inserted into the Action sequence without LLM involvement.
|
|
525
|
-
|
|
526
|
-
### Failure Corpus: AI Failure Genome
|
|
527
|
-
|
|
528
|
-
Every semantic anomaly is recorded as a genome entry containing: violated SVL level, constraint type, SSG state snapshot, repair path, missing functions, and planner retry count. `IntentSession` links all adaptation attempts for a single intent into a complete "cognitive session" — recording how AI gradually learns to complete tasks correctly.
|
|
529
|
-
|
|
530
|
-
### Semantic Snapshot Engine
|
|
531
|
-
|
|
532
|
-
Each planner session automatically captures an IR snapshot, recording all function names and signatures at that point in time. Snapshots support three operations:
|
|
533
|
-
|
|
534
|
-
| Command | Purpose |
|
|
535
|
-
|:--------|:-------|
|
|
536
|
-
| `ts-node src/semantic-trace.ts --snapshots` | List all IR snapshots |
|
|
537
|
-
| `ts-node src/semantic-trace.ts --diff <idA> <idB>` | Compare IR differences between two snapshots (added/removed/changed) |
|
|
538
|
-
| `ts-node src/semantic-trace.ts --validate <sessionId>` | Deterministic replay validation |
|
|
539
|
-
|
|
540
|
-
### Deterministic Replay
|
|
541
|
-
|
|
542
|
-
The `--validate` command replays a session's Action sequence against both the snapshot IR and the live IR, comparing results per function:
|
|
543
|
-
|
|
544
|
-
```
|
|
545
|
-
Action │ Snapshot IR │ Live IR │ Status
|
|
546
|
-
────────────────┼────────────────────┼────────────────────┼──────────
|
|
547
|
-
verify_password │ ✔ exists (1 param) │ ✔ exists (1 param) │ STABLE
|
|
548
|
-
generate_jwt │ ✔ exists (2 param) │ ✔ exists (2 param) │ STABLE
|
|
549
|
-
create_session │ ✔ exists (1 param) │ ✖ NOT FOUND │ REGRESSION
|
|
550
|
-
```
|
|
551
|
-
|
|
552
|
-
By comparing snapshot vs. current IR, you can detect whether code changes have broken previously correct repair paths.
|
|
553
|
-
|
|
554
|
-
### Antibody Inference Integration
|
|
555
|
-
|
|
556
|
-
Repair patterns from the Antibody Registry are integrated into the planner's inference layer:
|
|
557
|
-
|
|
558
|
-
| ACL Level | Inference Behavior |
|
|
559
|
-
|:----------|:-------------------|
|
|
560
|
-
| ACL-3 | Injects validated fix paths into the LLM prompt, constraining generation to known-correct sequences |
|
|
561
|
-
| ACL-4 | Skips the LLM entirely — builds Action sequences directly from fixPath, validates via SSG, returns immediately (zero LLM calls) |
|
|
562
|
-
|
|
563
|
-
Antibody matching uses Jaccard similarity (20% threshold) to associate new intents with known repair patterns, achieving "fix once, immune forever."
|
|
564
|
-
|
|
565
|
-
### IR External Function Extraction
|
|
566
|
-
|
|
567
|
-
The IR extractor now captures not only project-local functions but also external dependencies (e.g., `readFileSync`, `parse`, `resolve`), registering them with known Node.js/JavaScript API signatures. This enables the constraint engine to perform SVL-1~SVL-2 validation on external API calls.
|
|
568
|
-
|
|
569
|
-
---
|
|
570
|
-
|
|
571
|
-
## Semantic Validity Levels (SVL)
|
|
572
|
-
|
|
573
|
-
Progmune defines a layered standard for the correctness of AI-generated code:
|
|
574
|
-
|
|
575
|
-
| Level | Name | Guarantee |
|
|
576
|
-
|:------|:-----|:----------|
|
|
577
|
-
| SVL-1 | Symbolic Existence | Never calls functions that do not exist in the project |
|
|
578
|
-
| SVL-2 | Type Validity | Parameter count and types strictly match |
|
|
579
|
-
| SVL-3 | Dataflow Correctness | Variables are declared before use, no circular references |
|
|
580
|
-
| SVL-4 | Protocol Legality | Business step order must adhere to state transition rules |
|
|
581
|
-
|
|
582
|
-
---
|
|
583
|
-
|
|
584
|
-
## Semantic Observatory
|
|
585
|
-
|
|
586
|
-
Terminal-native AI reasoning observability tool. Zero dependencies, pure ANSI + Unicode box-drawing.
|
|
587
|
-
|
|
588
|
-
```bash
|
|
589
|
-
# Session summary table
|
|
590
|
-
ts-node src/semantic-trace.ts
|
|
591
|
-
|
|
592
|
-
# Full timeline for a single session
|
|
593
|
-
ts-node src/semantic-trace.ts <sessionId>
|
|
594
|
-
|
|
595
|
-
# Step-by-step cognitive replay (with adaptation diffs)
|
|
596
|
-
ts-node src/semantic-trace.ts replay <sessionId>
|
|
597
|
-
|
|
598
|
-
# State machine transition trace (+/− state gain/invalidation)
|
|
599
|
-
ts-node src/semantic-trace.ts --states <sessionId>
|
|
600
|
-
|
|
601
|
-
# Failure genome (SVL bar charts)
|
|
602
|
-
ts-node src/semantic-trace.ts --genome
|
|
603
|
-
|
|
604
|
-
# Antibody registry (ACL-1~4 confidence levels)
|
|
605
|
-
ts-node src/semantic-trace.ts --learned
|
|
606
|
-
|
|
607
|
-
# Semantic heatmap (fragile protocols / immune layer activity / constraint co-occurrence / high-friction intents)
|
|
608
|
-
ts-node src/semantic-trace.ts --heatmap
|
|
609
|
-
|
|
610
|
-
# Deterministic replay (compare snapshot IR vs live IR, detect regressions)
|
|
611
|
-
ts-node src/semantic-trace.ts --validate <sessionId>
|
|
612
|
-
|
|
613
|
-
# List all IR snapshots
|
|
614
|
-
ts-node src/semantic-trace.ts --snapshots
|
|
615
|
-
|
|
616
|
-
# Compare IR differences between two snapshots
|
|
617
|
-
ts-node src/semantic-trace.ts --diff <idA> <idB>
|
|
618
|
-
```
|
|
619
|
-
|
|
620
|
-
### Antibody Confidence Levels (ACL)
|
|
621
|
-
|
|
622
|
-
| Level | Criteria | Meaning |
|
|
623
|
-
|:------|:---------|:--------|
|
|
624
|
-
| ACL-1 | Single case observation | First occurrence — record only |
|
|
625
|
-
| ACL-2 | Repeated observation (2+ sessions) | Pattern reproduced across sessions — flag for attention |
|
|
626
|
-
| ACL-3 | Cross-task validated (4+ occurrences or 3+ distinct intents) | High-confidence candidate — consider as default rule |
|
|
627
|
-
| ACL-4 | Globally stable (10+ occurrences / 5+ distinct intents) | Validated immune rule — safe for automatic application |
|
|
628
|
-
|
|
629
|
-
> ACL thresholds are configurable via environment variables: `PROGMUNE_ACL4_COUNT` (default 10), `PROGMUNE_ACL4_INTENTS` (default 5), `PROGMUNE_ACL3_COUNT` (default 4), `PROGMUNE_ACL3_INTENTS` (default 3), `PROGMUNE_ACL2_COUNT` (default 2). Lower values accelerate antibody promotion.
|
|
630
|
-
|
|
631
|
-
---
|
|
632
|
-
|
|
633
|
-
## Quick Start
|
|
634
|
-
|
|
635
|
-
### Prerequisites
|
|
636
|
-
|
|
637
|
-
- [Node.js](https://nodejs.org/) >= 18
|
|
638
|
-
- A valid LLM API key (DeepSeek or OpenAI compatible)
|
|
639
|
-
|
|
640
|
-
### 1. Installation
|
|
641
|
-
|
|
642
|
-
```bash
|
|
643
|
-
npm install -g progmune-runtime
|
|
644
|
-
```
|
|
645
|
-
|
|
646
|
-
### 2. Configure LLM API Key
|
|
647
|
-
|
|
648
|
-
```bash
|
|
649
|
-
# Option 1: Setup wizard (recommended)
|
|
650
|
-
npx progmune-runtime setup "YOUR_API_KEY"
|
|
651
|
-
|
|
652
|
-
# Option 2: Environment variable
|
|
653
|
-
export LLM_API_KEY="YOUR_DEEPSEEK_OR_OPENAI_KEY"
|
|
654
|
-
```
|
|
655
|
-
|
|
656
|
-
See [LLM Backend Configuration](#llm-backend-configuration) for multi-model support.
|
|
657
|
-
|
|
658
|
-
### 3. Configure in MCP Client
|
|
659
|
-
|
|
660
|
-
**Claude Code** — Edit `~/.claude/settings.json`:
|
|
661
|
-
|
|
662
|
-
```json
|
|
663
|
-
{
|
|
664
|
-
"mcpServers": {
|
|
665
|
-
"progmune": {
|
|
666
|
-
"command": "npx",
|
|
667
|
-
"args": ["progmune-runtime"],
|
|
668
|
-
"env": {
|
|
669
|
-
"LLM_API_KEY": "YOUR_DEEPSEEK_OR_OPENAI_KEY",
|
|
670
|
-
"LLM_BASE_URL": "https://api.deepseek.com/v1"
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
```
|
|
676
|
-
|
|
677
|
-
> The `env` field is required. Terminal-level environment variables may not be inherited by MCP subprocesses.
|
|
678
|
-
|
|
679
|
-
**Manus / Other Clients**: Command: `npx`, Args: `progmune-runtime`, configure `LLM_API_KEY` in the client's environment variables.
|
|
680
|
-
|
|
681
|
-
### 4. Verify Installation
|
|
682
|
-
|
|
683
|
-
```bash
|
|
684
|
-
npx progmune-runtime test
|
|
685
|
-
```
|
|
686
|
-
|
|
687
|
-
Expected output:
|
|
688
|
-
```
|
|
689
|
-
🧪 Progmune Runtime 自测试
|
|
690
|
-
✅ SVL-1: 存在函数通过
|
|
691
|
-
✅ SVL-1: 不存在函数拦截
|
|
692
|
-
✅ SVL-2: 参数数量匹配通过
|
|
693
|
-
✅ SVL-4: 非法跃迁拦截(无 auth)
|
|
694
|
-
📊 结果: 11/11 通过 (100%)
|
|
695
|
-
```
|
|
696
|
-
|
|
697
|
-
After configuration, describe your programming needs directly in the conversation, and the AI agent will automatically invoke Progmune to generate secure code.
|
|
698
|
-
|
|
699
|
-
---
|
|
700
|
-
|
|
701
|
-
## CLI Commands
|
|
702
|
-
|
|
703
|
-
| Command | Description |
|
|
704
|
-
|:--------|:------------|
|
|
705
|
-
| `progmune-runtime setup <key>` | Setup wizard for LLM API key and MCP configuration |
|
|
706
|
-
| `progmune-runtime test` | Run 11 built-in self-tests to verify the installation |
|
|
707
|
-
| `progmune-runtime opt-in [enable\|disable\|status]` | Manage immune network reporting |
|
|
708
|
-
| `progmune-runtime` | Run as MCP server (for MCP clients) |
|
|
709
|
-
|
|
710
|
-
---
|
|
711
|
-
|
|
712
|
-
## MCP Tools
|
|
713
|
-
|
|
714
|
-
| Tool | Description |
|
|
715
|
-
|:-----|:------------|
|
|
716
|
-
| `progmune_generate` | Generate type-safe Python code (requires `intent` and `projectPath`) |
|
|
717
|
-
| `progmune_status` | View runtime status, LLM stats, and immune network health |
|
|
718
|
-
|
|
719
|
-
**progmune_status example**:
|
|
720
|
-
|
|
721
|
-
```json
|
|
722
|
-
{
|
|
723
|
-
"version": "2.1.0",
|
|
724
|
-
"llm": { "model": "deepseek-chat", "callCount": 3, "apiKeySet": true },
|
|
725
|
-
"immuneNetwork": { "optIn": true, "hubReachable": true, "totalFailures": 14 }
|
|
726
|
-
}
|
|
727
|
-
```
|
|
728
|
-
|
|
729
|
-
---
|
|
730
|
-
|
|
731
|
-
## LLM Backend Configuration
|
|
732
|
-
|
|
733
|
-
Set `LLM_PROVIDER` environment variable to switch backends:
|
|
734
|
-
|
|
735
|
-
### DeepSeek (default)
|
|
736
|
-
|
|
737
|
-
```bash
|
|
738
|
-
export LLM_PROVIDER=deepseek
|
|
739
|
-
export LLM_API_KEY="your-key"
|
|
740
|
-
```
|
|
741
|
-
|
|
742
|
-
### OpenAI
|
|
743
|
-
|
|
744
|
-
```bash
|
|
745
|
-
export LLM_PROVIDER=openai
|
|
746
|
-
export LLM_API_KEY="your-key"
|
|
747
|
-
export LLM_BASE_URL=https://api.openai.com/v1
|
|
748
|
-
export LLM_MODEL=gpt-4
|
|
749
|
-
```
|
|
750
|
-
|
|
751
|
-
### Ollama (local, no internet required)
|
|
752
|
-
|
|
753
|
-
```bash
|
|
754
|
-
export LLM_PROVIDER=ollama
|
|
755
|
-
# Defaults to http://localhost:11434/v1, model llama3
|
|
756
|
-
```
|
|
757
|
-
|
|
758
|
-
Ollama mode does not require `LLM_API_KEY`.
|
|
759
|
-
|
|
760
|
-
---
|
|
761
|
-
|
|
762
|
-
## Global Immune Network
|
|
763
|
-
|
|
764
|
-
Progmune supports securely reporting anonymized error fingerprints to a central immune server to achieve "herd immunity." When opt-in is enabled, each `progmune_generate` call automatically uploads fingerprints.
|
|
765
|
-
|
|
766
|
-
### Enable Reporting
|
|
767
|
-
|
|
768
|
-
```bash
|
|
769
|
-
npx progmune-runtime opt-in enable
|
|
770
|
-
```
|
|
771
|
-
|
|
772
|
-
### Start Local Hub Server
|
|
773
|
-
|
|
774
|
-
```bash
|
|
775
|
-
node server/hub.js
|
|
776
|
-
# Dashboard: http://localhost:8080/
|
|
777
|
-
```
|
|
778
|
-
|
|
779
|
-
The dashboard provides real-time stats, top error patterns, SVL distribution, and event timeline.
|
|
780
|
-
|
|
781
|
-
### Set Central Server Address
|
|
782
|
-
|
|
783
|
-
```bash
|
|
784
|
-
export PROGMUNE_HUB="http://localhost:8080/report"
|
|
785
|
-
```
|
|
786
|
-
|
|
787
|
-
### Preview and Manual Report
|
|
788
|
-
|
|
789
|
-
```bash
|
|
790
|
-
# Preview anonymized data
|
|
791
|
-
npx ts-node src/report.ts preview
|
|
792
|
-
|
|
793
|
-
# Manual report
|
|
794
|
-
npx ts-node src/report.ts report
|
|
795
|
-
```
|
|
796
|
-
|
|
797
|
-
### Privacy Protection
|
|
798
|
-
|
|
799
|
-
Only function name sequences, SVL levels, and state transitions are uploaded; **no** code snippets, variable values, or user data are ever included.
|
|
800
|
-
|
|
801
|
-
---
|
|
802
|
-
|
|
803
|
-
## FAQ
|
|
804
|
-
|
|
805
|
-
See [FAQ.md](./FAQ.md) for troubleshooting and common issues including API key setup, MCP configuration debugging, and immune network setup.
|
|
806
|
-
|
|
807
|
-
---
|
|
808
|
-
|
|
809
|
-
## Action Object Fields
|
|
810
|
-
|
|
811
|
-
When using Progmune's Action API, follow these field conventions:
|
|
812
|
-
|
|
813
|
-
| Field | Type | Required | Description |
|
|
814
|
-
|:------|:-----|:---------|:------------|
|
|
815
|
-
| `kind` | `"call" \| "if" \| "assign" \| "return"` | Yes | Action type |
|
|
816
|
-
| `function` | `string` | When `kind` is `"call"` | Function name to call. **Not `fn` or `name`** |
|
|
817
|
-
| `args` | `Arg[]` | When `kind` is `"call"` | Arguments, each `{ name: string, type: string, value: any }` |
|
|
818
|
-
| `assignTo` | `string` | No | Variable to bind the return value to |
|
|
819
|
-
| `condition` | `string` | When `kind` is `"if"` | Condition variable name, must be declared |
|
|
820
|
-
|
|
821
|
-
**Common mistake**: Using `action.fn` instead of `action.function` causes the validator to report "function 'undefined' does not exist."
|
|
822
|
-
|
|
823
|
-
---
|
|
824
|
-
|
|
825
|
-
## License
|
|
826
|
-
|
|
827
|
-
MIT License.
|
|
828
|
-
|
|
829
|
-
Progmune is redefining AI-assisted programming—not by "making models smarter," but by "letting program truth govern generation." Join our technical preview and build a future of verifiable AI coding together.
|