progmune-runtime 2.1.5 → 3.2.0

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.
Files changed (356) hide show
  1. package/README.md +108 -468
  2. package/dist/ablation-study.js +144 -0
  3. package/dist/ablation-study.test.js +18 -0
  4. package/dist/action-runtime.js +3 -1
  5. package/dist/active-learning.js +211 -0
  6. package/dist/analytics.js +139 -0
  7. package/dist/asset-factory.js +309 -0
  8. package/dist/asset-growth.js +244 -0
  9. package/dist/asset-promotion.js +382 -0
  10. package/dist/asset-quality.js +550 -0
  11. package/dist/audit/business-translator.js +285 -0
  12. package/dist/audit/cli.js +66 -0
  13. package/dist/audit/formatters/html.js +379 -0
  14. package/dist/audit/formatters/json.js +11 -0
  15. package/dist/audit/formatters/markdown.js +192 -0
  16. package/dist/audit/formatters/terminal.js +189 -0
  17. package/dist/audit/index.js +25 -0
  18. package/dist/audit/report-builder.js +318 -0
  19. package/dist/audit/types.js +8 -0
  20. package/dist/audit.js +3 -3
  21. package/dist/auto-benchmark-generator.js +137 -0
  22. package/dist/auto-benchmark-generator.test.js +45 -0
  23. package/dist/auto-protocol-synthesizer.js +362 -0
  24. package/dist/auto-protocol-synthesizer.test.js +82 -0
  25. package/dist/autonomous-patch.js +175 -0
  26. package/dist/autonomous-patch.test.js +128 -0
  27. package/dist/badge/badge-server.js +98 -0
  28. package/dist/behavior-miner.js +442 -0
  29. package/dist/belief-layer.js +475 -0
  30. package/dist/benchmark-count.js +5 -0
  31. package/dist/benchmark-generator.js +211 -0
  32. package/dist/benchmark-harness.js +201 -0
  33. package/dist/benchmark-pass-rate.js +7 -0
  34. package/dist/benchmark-report.js +8 -3
  35. package/dist/benchmark-save.js +14 -1
  36. package/dist/bootstrap-validation.js +197 -0
  37. package/dist/bootstrap-validation.test.js +51 -0
  38. package/dist/branch-ledger.js +1 -1
  39. package/dist/capability-gap.js +130 -0
  40. package/dist/certify-html.js +351 -0
  41. package/dist/certify.js +326 -0
  42. package/dist/check.js +4 -4
  43. package/dist/compliance-miner.js +447 -0
  44. package/dist/continuous-benchmark.js +194 -0
  45. package/dist/continuous-benchmark.test.js +116 -0
  46. package/dist/corpus-stats.js +173 -0
  47. package/dist/counterfactual-engine.js +288 -0
  48. package/dist/coverage-dashboard.js +109 -0
  49. package/dist/coverage-system.test.js +205 -0
  50. package/dist/cross-repo-precision.js +352 -0
  51. package/dist/cve-benchmark.js +180 -0
  52. package/dist/cve-benchmark.test.js +28 -0
  53. package/dist/cve-collector.js +73 -0
  54. package/dist/data-quality.js +141 -0
  55. package/dist/decision-engine.js +388 -0
  56. package/dist/derive-metadata.js +250 -0
  57. package/dist/difficulty-active.test.js +198 -0
  58. package/dist/difficulty-map.js +244 -0
  59. package/dist/discovery-analytics.js +125 -0
  60. package/dist/discovery-model.js +149 -0
  61. package/dist/discovery-optimize.test.js +199 -0
  62. package/dist/discovery-trace.js +276 -0
  63. package/dist/discovery-trace.test.js +97 -0
  64. package/dist/emitter.js +83 -1
  65. package/dist/enterprise-dashboard.js +405 -0
  66. package/dist/eval-hardening.js +297 -0
  67. package/dist/eval-hardening.test.js +85 -0
  68. package/dist/evaluation-campaign.js +359 -0
  69. package/dist/evaluation-campaign.test.js +181 -0
  70. package/dist/evidence-growth.js +143 -0
  71. package/dist/evidence-repository.js +209 -0
  72. package/dist/evidence-system.js +441 -0
  73. package/dist/execute.js +15 -7
  74. package/dist/experimental/software-physics.js +291 -0
  75. package/dist/experimental/state-inference.js +516 -0
  76. package/dist/experimental/unsupervised-physics.js +230 -0
  77. package/dist/extract-ir-python.js +54 -7
  78. package/dist/extract-ir.js +376 -12
  79. package/dist/failure-collector.js +2 -2
  80. package/dist/failure-corpus.js +322 -9
  81. package/dist/feedback.js +16 -5
  82. package/dist/feedback.test.js +49 -0
  83. package/dist/file-lock.js +1 -1
  84. package/dist/flywheel-batch.js +292 -0
  85. package/dist/frameworks/express-cli.js +237 -0
  86. package/dist/frameworks/express-detector.js +445 -0
  87. package/dist/frameworks/express-detector.test.js +206 -0
  88. package/dist/frameworks/index.js +30 -0
  89. package/dist/frameworks/nestjs-detector.js +302 -0
  90. package/dist/frameworks/trpc-detector.js +161 -0
  91. package/dist/frameworks/version-awareness.js +179 -0
  92. package/dist/function-synonyms.js +164 -0
  93. package/dist/function-synonyms.test.js +68 -0
  94. package/dist/generalization.test.js +352 -0
  95. package/dist/goal-annotator.js +113 -0
  96. package/dist/goal-planner.js +563 -0
  97. package/dist/gold-cve.js +164 -0
  98. package/dist/gold-cve.test.js +104 -0
  99. package/dist/gold-quality.js +206 -0
  100. package/dist/gold-tiers.js +241 -0
  101. package/dist/governance-dashboard.js +327 -0
  102. package/dist/graph-viz.js +240 -0
  103. package/dist/guided-frontier.js +195 -0
  104. package/dist/hierarchical-planner.js +148 -0
  105. package/dist/identifier-parser.js +260 -0
  106. package/dist/immune-metrics.js +93 -0
  107. package/dist/immune-receiver.js +158 -0
  108. package/dist/immune-reporter.js +1 -1
  109. package/dist/improvement-orchestrator.js +206 -0
  110. package/dist/inject-p0-vocabulary.js +300 -0
  111. package/dist/intent-parser.js +218 -0
  112. package/dist/invariant-algebra.js +476 -0
  113. package/dist/invariant-calculus.js +533 -0
  114. package/dist/ir-utils.js +70 -0
  115. package/dist/ir-utils.test.js +50 -0
  116. package/dist/knowledge-api.js +312 -0
  117. package/dist/knowledge-evolution.js +452 -0
  118. package/dist/knowledge-explorer.js +506 -0
  119. package/dist/knowledge-flywheel.js +274 -0
  120. package/dist/knowledge-governance.js +338 -0
  121. package/dist/knowledge-governance.test.js +150 -0
  122. package/dist/knowledge-graph.js +181 -0
  123. package/dist/knowledge-guided-synth.js +246 -0
  124. package/dist/knowledge-loop.test.js +77 -0
  125. package/dist/knowledge-object.js +316 -0
  126. package/dist/knowledge-package.js +98 -0
  127. package/dist/kpi-dashboard.js +561 -0
  128. package/dist/l3-cross-function.js +280 -0
  129. package/dist/learning-ranker.js +148 -0
  130. package/dist/learning-ranker.test.js +291 -0
  131. package/dist/ledger/accountability.js +322 -0
  132. package/dist/ledger/chain-builder.js +185 -0
  133. package/dist/ledger/cli.js +222 -0
  134. package/dist/ledger/index.js +13 -0
  135. package/dist/ledger/signatures.js +193 -0
  136. package/dist/ledger/types.js +9 -0
  137. package/dist/llm.js +74 -3
  138. package/dist/load-benchmarks.js +8 -3
  139. package/dist/logger.js +66 -0
  140. package/dist/logger.test.js +37 -0
  141. package/dist/logistic-reward.js +339 -0
  142. package/dist/logistic-reward.test.js +180 -0
  143. package/dist/macro-graph.js +193 -0
  144. package/dist/macro-repair.js +183 -0
  145. package/dist/mcp-server.mjs +1202 -483
  146. package/dist/memory-layer.js +42 -5
  147. package/dist/multi-repo-precision.js +422 -0
  148. package/dist/name-free-protocol.js +425 -0
  149. package/dist/name-free-protocol.test.js +170 -0
  150. package/dist/name-scrambling.js +138 -0
  151. package/dist/name-scrambling.test.js +16 -0
  152. package/dist/p3-observability.test.js +281 -0
  153. package/dist/p5-orchestrator.test.js +225 -0
  154. package/dist/pairwise-preference.js +294 -0
  155. package/dist/pairwise-preference.test.js +140 -0
  156. package/dist/planner-constraints.js +104 -0
  157. package/dist/planner-prompts.js +155 -0
  158. package/dist/planner-telemetry.js +415 -0
  159. package/dist/planner-trace.js +214 -0
  160. package/dist/planner.js +162 -167
  161. package/dist/plsb/artifact.js +116 -0
  162. package/dist/plsb/cli.js +71 -0
  163. package/dist/plsb/index.js +19 -0
  164. package/dist/plsb/leaderboard.js +249 -0
  165. package/dist/plsb/report-md.js +156 -0
  166. package/dist/plsb/schema.js +179 -0
  167. package/dist/plsb-benchmark.js +284 -0
  168. package/dist/plsb-benchmark.test.js +119 -0
  169. package/dist/policy/cli.js +134 -0
  170. package/dist/policy/engine.js +333 -0
  171. package/dist/policy/index.js +12 -0
  172. package/dist/policy/types.js +59 -0
  173. package/dist/policy-miner.js +505 -0
  174. package/dist/precision-analyze.js +229 -0
  175. package/dist/precision-benchmark.js +147 -0
  176. package/dist/precision-label-c.js +134 -0
  177. package/dist/precision-label.js +193 -0
  178. package/dist/precision-report-c.js +149 -0
  179. package/dist/precision-report.js +246 -0
  180. package/dist/progmune-status.js +108 -0
  181. package/dist/proof-engine.js +479 -0
  182. package/dist/proof-provenance.js +315 -0
  183. package/dist/protocol-coverage.js +294 -0
  184. package/dist/protocol-detector.js +1189 -0
  185. package/dist/protocol-embedding-expanded.js +297 -0
  186. package/dist/protocol-embedding-expanded.test.js +97 -0
  187. package/dist/protocol-embedding.js +195 -0
  188. package/dist/protocol-embedding.test.js +82 -0
  189. package/dist/protocol-extractor-v2.js +354 -0
  190. package/dist/protocol-extractor-v2.test.js +140 -0
  191. package/dist/protocol-extractor.js +310 -0
  192. package/dist/protocol-extractor.test.js +113 -0
  193. package/dist/protocol-foundation.js +322 -0
  194. package/dist/protocol-foundation.test.js +163 -0
  195. package/dist/protocol-frontier.js +243 -0
  196. package/dist/protocol-frontier.test.js +92 -0
  197. package/dist/protocol-gap-analyzer.js +228 -0
  198. package/dist/protocol-gap-analyzer.test.js +49 -0
  199. package/dist/protocol-invariants.js +276 -0
  200. package/dist/protocol-invariants.test.js +111 -0
  201. package/dist/protocol-knowledge.js +464 -0
  202. package/dist/protocol-miner.js +343 -0
  203. package/dist/protocol-mining.js +207 -0
  204. package/dist/protocol-mining.test.js +37 -0
  205. package/dist/protocol-registry.js +1 -1
  206. package/dist/protocol-security-benchmark.js +222 -0
  207. package/dist/protocol-vulnerability.js +257 -0
  208. package/dist/protocol-vulnerability.test.js +60 -0
  209. package/dist/python-benchmark.js +120 -0
  210. package/dist/python-emitter.js +163 -45
  211. package/dist/python-protocol-extractor.js +187 -0
  212. package/dist/python-protocol-extractor.test.js +116 -0
  213. package/dist/realworld-benchmark.js +646 -0
  214. package/dist/realworld-benchmark.test.js +36 -0
  215. package/dist/repair-arch.test.js +411 -0
  216. package/dist/repair-evolution.test.js +454 -0
  217. package/dist/repair-executor.js +719 -0
  218. package/dist/repair-proposal.js +4 -4
  219. package/dist/repair-ranker.js +141 -0
  220. package/dist/repair-strategies.js +419 -0
  221. package/dist/repair-taxonomy.js +234 -0
  222. package/dist/repair-types.js +12 -0
  223. package/dist/repo-evaluator.js +250 -0
  224. package/dist/repo-evaluator.test.js +128 -0
  225. package/dist/resource-abstraction.js +242 -0
  226. package/dist/resource-detector.js +211 -0
  227. package/dist/result.test.js +43 -0
  228. package/dist/reward-system.js +411 -0
  229. package/dist/reward-system.test.js +175 -0
  230. package/dist/risk-model.js +215 -0
  231. package/dist/rule-miner.js +234 -7
  232. package/dist/rule-specificity.js +254 -0
  233. package/dist/runtime-types.js +27 -0
  234. package/dist/scaffold.js +208 -0
  235. package/dist/scale-collector.test.js +101 -0
  236. package/dist/scale-trajectory-collector.js +128 -0
  237. package/dist/sdk.js +250 -0
  238. package/dist/search-planner.js +4 -41
  239. package/dist/semantic-snapshot.js +1 -1
  240. package/dist/semantic-topology.js +121 -0
  241. package/dist/semantic-trace.js +310 -317
  242. package/dist/sequence-extractor.js +343 -0
  243. package/dist/skill-library.js +245 -0
  244. package/dist/skill-planner.test.js +189 -0
  245. package/dist/software-physics.js +291 -0
  246. package/dist/software-physics.test.js +81 -0
  247. package/dist/ssg-precision.js +478 -0
  248. package/dist/ssg-validator.js +71 -21
  249. package/dist/state-inference-doubleblind.test.js +160 -0
  250. package/dist/state-inference.js +516 -0
  251. package/dist/state-inference.test.js +115 -0
  252. package/dist/state-machine-fingerprint.js +345 -0
  253. package/dist/state-machine-fingerprint.test.js +120 -0
  254. package/dist/state-miner.js +386 -0
  255. package/dist/state-name-inference.js +213 -0
  256. package/dist/state-name-inference.test.js +69 -0
  257. package/dist/strategy-planner.js +326 -59
  258. package/dist/strategy-planner.test.js +135 -0
  259. package/dist/telemetry-analytics.test.js +402 -0
  260. package/dist/terminal-format.js +68 -0
  261. package/dist/terminal-format.test.js +83 -0
  262. package/dist/topology-factory.js +196 -0
  263. package/dist/topology-representation.js +242 -0
  264. package/dist/topology-representation.test.js +27 -0
  265. package/dist/trajectory-augmentation.js +254 -0
  266. package/dist/trajectory-augmentation.test.js +63 -0
  267. package/dist/trajectory-corpus.js +440 -0
  268. package/dist/trajectory-corpus.test.js +32 -0
  269. package/dist/trajectory-feedback.test.js +116 -0
  270. package/dist/transition-synthesizer.js +286 -0
  271. package/dist/transition-synthesizer.test.js +123 -0
  272. package/dist/trust/api-semantic-mapper.js +809 -0
  273. package/dist/trust/call-graph-propagator.js +225 -0
  274. package/dist/trust/cli.js +122 -0
  275. package/dist/trust/compliance-scorer.js +283 -0
  276. package/dist/trust/confidence-calculator.js +261 -0
  277. package/dist/trust/engine.js +1145 -0
  278. package/dist/trust/explainability.js +85 -0
  279. package/dist/trust/formatters/ci.js +42 -0
  280. package/dist/trust/formatters/json.js +11 -0
  281. package/dist/trust/formatters/terminal.js +152 -0
  282. package/dist/trust/index.js +39 -0
  283. package/dist/trust/phase1-verify.js +171 -0
  284. package/dist/trust/protocol-domain-validator.js +697 -0
  285. package/dist/trust/score-calculator.js +282 -0
  286. package/dist/trust/ssg-bridge.js +641 -0
  287. package/dist/trust/ssg-bridge.test.js +269 -0
  288. package/dist/trust/types.js +67 -0
  289. package/dist/trust/violation-trace.js +335 -0
  290. package/dist/trust-api.js +179 -0
  291. package/dist/trust-calibration.js +279 -0
  292. package/dist/unknown-protocol-discovery.js +339 -0
  293. package/dist/unknown-protocol-discovery.test.js +102 -0
  294. package/dist/unsupervised-physics.js +230 -0
  295. package/dist/unsupervised-physics.test.js +95 -0
  296. package/dist/utils.test.js +37 -0
  297. package/dist/validator.js +187 -10
  298. package/dist/verification-intelligence.js +475 -0
  299. package/dist/verify-api.js +432 -0
  300. package/dist/vi-impact-report.js +293 -0
  301. package/dist/wl-fingerprint.js +162 -0
  302. package/dist/wl-fingerprint.test.js +130 -0
  303. package/dist/zeroshot-strategy.js +139 -0
  304. package/docs/Progmune_/346/212/225/350/265/204/344/272/272/347/231/275/347/232/256/344/271/246_v2.0.html +576 -0
  305. package/docs/Progmune_/351/241/271/347/233/256/345/205/250/350/247/243.html +710 -0
  306. package/package.json +74 -7
  307. package/protocols.json +1956 -50
  308. package/.dockerignore +0 -14
  309. package/.mcp.json +0 -11
  310. package/.progmune_allowlist +0 -50
  311. package/.test_report/test_report.md +0 -87
  312. package/Dockerfile +0 -9
  313. package/FAQ.md +0 -167
  314. package/WHITEPAPER.md +0 -540
  315. package/demo-project/auth.ts +0 -55
  316. package/demo-project/tsconfig.json +0 -8
  317. package/dist/acl-breakdown.js +0 -13
  318. package/dist/all-sessions.js +0 -11
  319. package/dist/antibody-stats.js +0 -11
  320. package/dist/branch-tree-count.js +0 -14
  321. package/dist/common-fixpath.js +0 -12
  322. package/dist/constraint-types.js +0 -12
  323. package/dist/exec-metrics.js +0 -11
  324. package/dist/failure-report.js +0 -11
  325. package/dist/fast-path-hits.js +0 -13
  326. package/dist/fingerprint-list.js +0 -15
  327. package/dist/gen-history-log.js +0 -13
  328. package/dist/heatmap-data.js +0 -11
  329. package/dist/recent-session.js +0 -12
  330. package/dist/svl-distribution.js +0 -11
  331. package/dist/terminal-status.js +0 -11
  332. package/dist/token-savings.js +0 -11
  333. package/dist/total-repairs.js +0 -12
  334. package/dist/unresolved-count.js +0 -12
  335. package/dist/valid-fingerprints.js +0 -13
  336. package/dist/verify-ledgers.js +0 -11
  337. package/docs/whitepaper-style.css +0 -77
  338. package/docs/whitepaper-v2.1.md +0 -609
  339. package/docs/whitepaper-v2.2.md +0 -1064
  340. package/docs/whitepaper-v2.2.pdf +0 -0
  341. package/fly.toml +0 -31
  342. package/public/dashboard.html +0 -119
  343. package/server/hub.js +0 -116
  344. package/test/replay-golden/sess_1780063202050_mgeld.json +0 -9
  345. package/test/replay-golden/sess_1780064032560_gocld.json +0 -354
  346. package/test/replay-golden/sess_1780064413331_s2709.json +0 -606
  347. package/test/replay-golden/sess_1780064792710_y3avo.json +0 -614
  348. package/test/replay-golden.ts +0 -84
  349. package/test_benchmark.js +0 -165
  350. package/test_comprehensive.mjs +0 -638
  351. package/test_concurrency.js +0 -129
  352. package/test_ir_robustness.js +0 -85
  353. package/test_semantic_contracts.js +0 -269
  354. package/test_ssg_stress.js +0 -156
  355. package/test_svl3.js +0 -58
  356. package/tsconfig.json +0 -17
package/README.md CHANGED
@@ -1,546 +1,186 @@
1
- # Progmune Runtime(免序)
1
+ # Progmune
2
2
 
3
- ![Progmune Runtime Preview](./social-preview.png)
4
-
5
- **程序免疫学:为 AI 生成代码构建可信赖的免疫系统**
3
+ ## AI Trust Decision Engine for AI-generated software.
6
4
 
7
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
6
  [![MCP](https://img.shields.io/badge/MCP-Compatible-blue)](https://modelcontextprotocol.io)
9
- [![Stage: Technical Preview](https://img.shields.io/badge/Stage-Technical_Preview-orange)]()
10
-
11
- ---
12
-
13
- ## 💡 核心价值:为什么你的 AI 代码需要“免疫”与“生成”?
14
-
15
- 在 AI 辅助编程的时代,大语言模型(LLM)带来了前所未有的效率,但也伴随着“认知缺陷”:
7
+ [![TS Benchmark](https://img.shields.io/badge/TS%20F1-85.2%25-22c55e)]()
8
+ [![Tests](https://img.shields.io/badge/Tests-92%20passing-22c55e)]()
16
9
 
17
- * **幻觉**:LLM 可能会凭空捏造不存在的函数、类或变量,导致运行时错误。
18
- * **类型漂移**:参数数量或类型与实际函数签名不匹配,引发类型错误。
19
- * **协议违规**:生成违反业务逻辑顺序的代码,例如在用户未认证前就签发令牌。
10
+ **Verify AI-generated code before it reaches production.** Progmune checks whether your AI-generated code follows correct protocol lifecycles — TLS handshakes, auth flows, payment integrity, resource management — violations that SAST and SCA tools cannot see because they span sequences of function calls, not single statements.
20
11
 
21
- **Progmune Runtime 旨在解决这些核心痛点,为 AI 生成代码提供一个强大的“免疫系统”,同时赋能可信赖的“生成”能力。**
22
-
23
- 它将 LLM 从一个“不受约束的代码生成器”降级为**“受约束的启发式提议者”**,将代码的最终决定权交还给**程序真相(Intermediate Representation, IR)**。这意味着,Progmune 不仅能**消除代码幻觉**,**保障协议安全**,还能通过学习历史错误**“越用越聪明”**,显著提升 AI 生成代码的可靠性和安全性。
24
-
25
- **核心理念:以免疫保障生成,以生成驱动免疫。**
26
-
27
- * **免疫**:通过多层验证机制,确保 AI 生成的每一步都符合程序真相和业务逻辑。
28
- * **生成**:在免疫系统的约束下,高效、智能地将模糊意图转化为可执行的、高质量的代码。
29
-
30
- **对开发者的直接价值:**
31
- * **🚫 终结代码幻觉**:生成的代码 100% 保证只调用项目中真实存在的函数和变量。
32
- * **🛡️ 协议级安全**:自动拦截非法的业务逻辑跳转,确保代码行为符合预期。
33
- * **🧠 越用越聪明**:系统从失败中学习,自动形成“抗体”,修复类似问题,减少 LLM token 消耗。
34
- * **🚀 提升开发效率**:减少调试和重构 AI 生成代码的时间,让开发者更专注于业务逻辑。
12
+ Progmune doesn't trust what the model says. It verifies what the program actually does.
35
13
 
36
14
  ---
37
15
 
38
- ## 🏗️ 核心架构:生成与免疫的协同
39
-
40
- Progmune Runtime 的设计灵感来源于生物免疫系统,构建了多层防御机制,确保 AI 生成代码的语义有效性。其核心架构清晰地展示了“生成”与“免疫”两大核心能力的协同工作:
41
-
42
- ```mermaid
43
- graph TD
44
- UserIntent[用户意图] --> A(LLM Proposer)
45
- A --> B(Semantic Topology & Strategy Planner)
46
- B --> C(Action Runtime)
47
- C --> D{Constraint Engine}
48
- D --> |SVL-1, SVL-2, SVL-3 Valid| E{"Semantic State Graph (SSG)"}
49
- D --> |Invalid| F(Failure Corpus)
50
- E --> |SVL-4 Valid| G(Code Emitter)
51
- E --> |Invalid| F
52
- F --> H(Immune Memory)
53
- H --> I(Antibody Registry & Credit Loops)
54
- I --> B
55
- subgraph "Program Truth (IR)"
56
- J[Symbol Table]
57
- K[Type Graph]
58
- L[Call Graph]
59
- M[Protocol Annotations]
60
- end
61
- J --> D
62
- K --> D
63
- L --> D
64
- M --> E
65
- G --> N[可执行代码]
66
- ```
16
+ ## One Command
67
17
 
68
- 1. **用户意图 (User Intent)**:开发者以自然语言描述其编程需求。
69
-
70
- 2. **LLM 提议者 (LLM Proposer)**:大语言模型根据用户意图,生成初步的、高层次的动作序列提议。它不再直接生成代码,而是提出一系列抽象的函数调用和逻辑结构。
71
-
72
- 3. **语义拓扑与策略规划器 (Semantic Topology & Strategy Planner)**:
73
- * **语义拓扑 (Semantic Topology)**:从程序真相 (IR) 中构建一个语义相似度图,理解项目中函数、模块之间的关联性。
74
- * **策略规划器 (Strategy Planner)**:利用语义拓扑,将 LLM 的模糊意图映射到项目内具体、可执行的**能力链 (Capability Chains)**。这是从意图到可执行动作的关键“生成”步骤。
75
-
76
- 4. **Action Runtime —— 确定性合成边界**:
77
- * **作用**:LLM 的提议和策略规划器生成的链,在这里被转化为一组**确定性 API 调用**(如 `call(func, ...args)`、`ifElse(condition, thenFn, elseFn)`)。这些 API 在沙箱环境中执行,并捕获为结构化的**动作树 (Action Tree)**。
78
- * **价值**:从源头消除了代码注入漏洞和格式错误,将 LLM 的输出限制在可控、可验证的结构内。
79
-
80
- 5. **程序真相 (IR) —— 自我模型**:
81
- * **作用**:Progmune 的“基因组”,是系统对项目代码的唯一、确定性认知。它通过静态分析源代码,提取出**符号表、类型图、调用图**和可选的**协议注解**。
82
- * **价值**:定义了 AI 可以操作的“封闭世界”,是所有后续验证的基础,确保 AI 不会“幻想”出不存在的实体。
83
-
84
- 6. **约束引擎 (Constraint Engine) —— 天然免疫层**:
85
- * **作用**:基于 IR 对动作树进行快速、规则化的验证,主要检查 **SVL-1(符号存在性)、SVL-2(类型有效性)和 SVL-3(数据流正确性)**。
86
- * **价值**:在毫秒级拦截最常见的“低级错误”(如函数不存在、参数类型不匹配),提供第一道防线。
87
-
88
- 7. **语义状态图 (Semantic State Graph, SSG) —— 获得性免疫层**:
89
- * **作用**:通过可编程的状态机,建模系统资源的有效状态及其允许的转移。它验证 **SVL-4(协议合法性)**,确保函数调用序列符合预定义的业务协议(例如,`UNAUTHENTICATED` -> `AUTHENTICATED` -> `TOKEN_ISSUED`)。
90
- * **价值**:防止 AI 生成违反业务流程的代码,将验证从静态正确性提升到行为合法性。v2.1.4 引入的 **BFS 协议修复**功能,使其能自动补全复杂的协议缺失。
91
-
92
- 8. **免疫记忆与失败语料库 (Immune Memory & Failure Corpus) —— 免疫记忆层**:
93
- * **作用**:每次约束违规都会被记录到**失败语料库**中,包含意图、错误详情和 SSG 状态。系统从这些失败模式中学习,生成高置信度的“抗体规则”,并存储在**抗体注册表 (Antibody Registry)** 中。
94
- * **价值**:使系统能够从错误中学习,形成“免疫记忆”,主动预防未来同类错误。**信用循环 (Credit Loops)** 机制根据函数历史成功率动态调整权重,优化模糊意图下的能力链选择。
18
+ ```bash
19
+ npm run sdk src/server.ts --explain
20
+ ```
95
21
 
96
- 9. **代码发射器 (Code Emitter) —— 程序落地层**:
97
- * **作用**:将所有验证通过的动作树确定性地翻译为可执行的 Python 或 TypeScript 代码,处理导入、变量作用域和代码格式化。
98
- * **价值**:确保最终生成的代码是安全、正确且可用的。
22
+ Output: `APPROVED` / `NEEDS_REVIEW` / `BLOCKED` — with Trust Score, evidence, and repair suggestions.
99
23
 
100
24
  ---
101
25
 
102
- ## 📊 语义有效性级别 (SVL)
26
+ ## What Progmune Detects
103
27
 
104
- 我们定义了 AI 生成代码的“健康标准”,为系统提供分层、可量化的验证保证:
28
+ AI code generators produce syntactically valid code that often violates **protocol lifecycles** — the correct sequence of operations like open→read→close or auth→validate→respond. These violations are invisible to traditional static analysis.
105
29
 
106
- | 级别 | 名称 | 描述 | Progmune 的保证 |
107
- |:-----|:-----|:-----|:-----|
108
- | **SVL-1** | 符号存在性 | 每个被调用的函数、变量和导入在项目中均实际存在 | 100% 消除幻觉 API 调用 |
109
- | **SVL-2** | 类型有效性 | 参数数量和类型与声明的签名相匹配 | 100% 消除类型不匹配错误 |
110
- | **SVL-3** | 数据流正确性 | 变量在使用前已声明;无循环引用或未初始化访问 | 100% 消除 NameError / UnboundLocalError |
111
- | **SVL-4** | 协议合法性 | 函数调用序列符合声明的前/后状态转换规则 | 严格遵守业务状态机,无非法状态跳转 |
112
- | **SVL-5** | 语义意图正确性 | 生成代码忠实实现预期业务逻辑 | 远期目标;当前版本通过 SVL-1~4 间接保障 |
113
-
114
- Progmune Runtime v2.1.4 完整保证 SVL-1 至 SVL-3,SVL-4 作为可选协议约束系统实现。SVL-5 为开放性研究方向。
30
+ | Category | Example violations detected |
31
+ |----------|---------------------------|
32
+ | **TLS / SSL** | Handshake without certificate verification, missing hostname validation |
33
+ | **Auth** | Token without expiry, session without timeout, missing rate limiting |
34
+ | **Payment** | Order without verification, refund without authorization, webhook without signature check |
35
+ | **Resource** | File opened but not closed, connection without cleanup, malloc without free |
36
+ | **Data Integrity** | Mutation without audit trail, missing input validation |
115
37
 
116
38
  ---
117
39
 
118
- ## 🚀 快速上手指南
119
-
120
- ### 前置条件
121
- * [Node.js](https://nodejs.org/) >= 18
122
- * 一个有效的 LLM API 密钥(支持 OpenAI 兼容接口,推荐使用具备强推理能力的模型)
123
-
124
- ### 1. 全局安装
40
+ ## Quick Start
125
41
 
126
42
  ```bash
127
- npm install -g progmune-runtime
128
- ```
129
-
130
- ### 2. 初始化配置
43
+ npm install progmune-runtime
131
44
 
132
- 在你的项目根目录下运行 setup,配置你的 API 密钥:
45
+ # Verify a file — get a Trust Decision
46
+ npm run sdk src/server.ts
133
47
 
134
- ```bash
135
- npx progmune-runtime setup "YOUR_API_KEY"
136
- ```
137
- *(提示:你也可以通过设置环境变量 `OPENAI_API_KEY` 来配置)*
138
-
139
- ### 3. 提取程序真相 (IR)
48
+ # Full explanation with evidence and repair suggestions
49
+ npm run sdk src/server.ts --explain
140
50
 
141
- Progmune 扫描你的项目,建立“自我认知”:
51
+ # Trust check (CI-ready JSON output)
52
+ npm run trust -- --project . --json
142
53
 
143
- ```bash
144
- npx progmune-runtime ir .
145
- ```
146
- 这会在项目目录下生成一个 `.progmune/ir.json` 文件,它是后续所有验证的基础。
147
-
148
- ### 4. 启动 MCP 服务器 (可选)
149
-
150
- 如果你使用 Cursor、Claude Desktop 等支持 MCP (Model Context Protocol) 的客户端,可以直接启动 Progmune 作为 MCP 服务器,让你的 AI 助手获得免疫能力:
151
-
152
- ```bash
153
- npx progmune-runtime start
154
- ```
155
-
156
- ### 5. 运行内置测试
157
-
158
- 验证系统是否正常工作:
159
-
160
- ```bash
161
- npx progmune-runtime test
54
+ # Run benchmark suite
55
+ npm run precision:all
162
56
  ```
163
57
 
164
58
  ---
165
59
 
166
- ## 📖 深入阅读
60
+ ## The Trust Decision
167
61
 
168
- 想要了解更多关于“程序免疫学”的理论基础、SSG 状态机的配置方法以及 v2.1.4 的最新特性(如 BFS 协议修复、信用循环),请参阅我们的:
62
+ Progmune's output is a **decision** backed by evidence, not a raw list of findings:
169
63
 
170
- 👉 **[《Program Immunology 技术白皮书》](./WHITEPAPER.md)**
64
+ | Output | Meaning |
65
+ |--------|---------|
66
+ | **Trust Score** (0–100) | Quantified trust level across 4 dimensions |
67
+ | **Decision** | `APPROVED` / `NEEDS_REVIEW` / `BLOCKED` |
68
+ | **Confidence** | `HIGH` / `MEDIUM` / `LOW` / `UNCERTAIN` |
69
+ | **Evidence** | Each violation traced to code location + RFC reference + fix suggestion |
171
70
 
172
- ---
173
-
174
- ## 🤝 参与贡献
175
-
176
- Progmune 正在重新定义 AI 辅助编程——**让程序真相主导生成**。我们欢迎提交 Issue、Pull Request,或者在 Discussions 中分享你的想法!
71
+ **Critical violations → hard BLOCK regardless of score.** Enterprises care about "can I deploy?" not "is my score 58 or 61."
177
72
 
178
- ## 📄 许可证
179
-
180
- 本项目采用 MIT License。
73
+ [Trust Decision Model](docs/ai-trust-decision-model-v1.md)
181
74
 
182
75
  ---
183
76
 
184
- # Progmune Runtime (English Version)
185
-
186
- ![Progmune Runtime Preview](./social-preview.png)
77
+ ## Coverage
187
78
 
188
- **Program Immunology: Building a Trustworthy Immune System for AI-Generated Code**
189
-
190
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
191
- [![MCP](https://img.shields.io/badge/MCP-Compatible-blue)](https://modelcontextprotocol.io)
192
- [![Stage: Technical Preview](https://img.shields.io/badge/Stage-Technical_Preview-orange)]()
193
-
194
- ---
79
+ Progmune is honest about what it can and cannot verify.
195
80
 
196
- ## 💡 Core Value: Why Your AI Code Needs "Immunity" and "Generation"?
81
+ | Language | Status | Evidence |
82
+ |----------|--------|----------|
83
+ | **TypeScript / JavaScript** | ✅ Production | Blind benchmark: P=86.8%, R=83.6%, F1=85.2% (432 sequences, 10 projects) |
84
+ | **C** | ⚠️ Research | Gold benchmark: curl F1=45.7%, libssh F1=46.2%. L3 cross-function experiment terminated — L4 (pointer/CFG) needed. |
85
+ | **Python** | 🔨 IR only | IR extractor exists (`extract-ir-python.ts`), no verification rules yet |
86
+ | **Go, Java** | ❌ None | Planned |
197
87
 
198
- In the era of AI-assisted programming, Large Language Models (LLMs) bring unprecedented efficiency but also come with "cognitive deficiencies":
88
+ **Framework adapters: 1/13.** Express is the first. Next.js, NestJS, Fastify, Django, FastAPI 12 remaining. Framework adaptation is the #1 product gap.
199
89
 
200
- * **Hallucinations**: LLMs may invent non-existent functions, classes, or variables, leading to runtime errors.
201
- * **Type Drift**: Mismatched parameter counts or types with actual function signatures, causing type errors.
202
- * **Protocol Violations**: Generating code that violates the logical order of business processes, such as issuing tokens before user authentication.
203
-
204
- **Progmune Runtime aims to solve these core pain points by providing a robust "immune system" for AI-generated code, while also enabling trustworthy "generation" capabilities.**
205
-
206
- It demotes LLMs from "unconstrained code generators" to **"constrained heuristic proposers,"** returning the ultimate decision-making power over code to **Program Truth (Intermediate Representation, IR)**. This means Progmune can not only **eliminate code hallucinations** and **ensure protocol security** but also **"get smarter with use"** by learning from historical errors, significantly enhancing the reliability and safety of AI-generated code.
207
-
208
- **Core Philosophy: Immunity guarantees generation, and generation drives immunity.**
209
-
210
- * **Immunity**: Through multi-layered validation mechanisms, ensuring every step of AI generation conforms to program truth and business logic.
211
- * **Generation**: Under the constraints of the immune system, efficiently and intelligently transforms ambiguous intentions into executable, high-quality code.
212
-
213
- **Direct Value for Developers:**
214
- * **🚫 End Code Hallucinations**: 100% guarantee that generated code only calls functions and variables that genuinely exist in your project.
215
- * **🛡️ Protocol-Level Security**: Automatically intercepts illegal business logic transitions, ensuring code behavior aligns with expectations.
216
- * **🧠 Smarter with Use**: The system learns from failures, automatically forming "antibodies" to fix similar issues, reducing LLM token consumption.
217
- * **🚀 Boost Development Efficiency**: Reduces time spent debugging and refactoring AI-generated code, allowing developers to focus more on business logic.
90
+ [Full Coverage Matrix](docs/coverage-matrix.md)
218
91
 
219
92
  ---
220
93
 
221
- ## 🏗️ Core Architecture: The Synergy of Generation and Immunity
222
-
223
- Progmune Runtime's design is inspired by the biological immune system, building multi-layered defense mechanisms to ensure the semantic validity of AI-generated code. Its core architecture clearly illustrates the synergistic operation of its two core capabilities: "Generation" and "Immunity."
224
-
225
- ```mermaid
226
- graph TD
227
- UserIntent[User Intent] --> A(LLM Proposer)
228
- A --> B(Semantic Topology & Strategy Planner)
229
- B --> C(Action Runtime)
230
- C --> D{Constraint Engine}
231
- D --> |SVL-1, SVL-2, SVL-3 Valid| E{"Semantic State Graph (SSG)"}
232
- D --> |Invalid| F(Failure Corpus)
233
- E --> |SVL-4 Valid| G(Code Emitter)
234
- E --> |Invalid| F
235
- F --> H(Immune Memory)
236
- H --> I(Antibody Registry & Credit Loops)
237
- I --> B
238
- subgraph "Program Truth (IR)"
239
- J[Symbol Table]
240
- K[Type Graph]
241
- L[Call Graph]
242
- M[Protocol Annotations]
243
- end
244
- J --> D
245
- K --> D
246
- L --> D
247
- M --> E
248
- G --> N[Executable Code]
249
- ```
250
-
251
- 1. **User Intent**: Developers describe their programming needs in natural language.
94
+ ## Benchmarks
252
95
 
253
- 2. **LLM Proposer**: The Large Language Model, based on user intent, generates preliminary, high-level proposals for action sequences. It no longer directly generates code but proposes a series of abstract function calls and logical structures.
96
+ Public, reproducible precision data. All numbers measured against gold-annotated benchmarks.
254
97
 
255
- 3. **Semantic Topology & Strategy Planner**:
256
- * **Semantic Topology**: Constructs a semantic similarity graph from the Program Truth (IR), understanding the relationships between functions and modules within the project.
257
- * **Strategy Planner**: Utilizes the Semantic Topology to map the LLM's ambiguous intentions to concrete, executable **Capability Chains** within the project. This is a crucial "generation" step from intent to executable actions.
98
+ ### TypeScript (Blind Benchmark v6)
258
99
 
259
- 4. **Action Runtime Deterministic Synthesis Boundary**:
260
- * **Role**: The LLM's proposals and the capability chains generated by the Strategy Planner are translated here into a set of **deterministic API calls** (e.g., `call(func, ...args)`, `ifElse(condition, thenFn, elseFn)`). These APIs are executed in a sandboxed environment and captured as structured **Action Trees**.
261
- * **Value**: Eliminates code injection vulnerabilities and formatting errors at the source, confining LLM output within a controllable and verifiable structure.
100
+ | Metric | Value |
101
+ |--------|-------|
102
+ | Precision | 86.8% |
103
+ | Recall | 83.6% |
104
+ | F1 | 85.2% |
105
+ | Projects | 10 (ecommerce, blog, chat, crm, forum, wiki, issuetracker, filestorage, todo, scheduler) |
262
106
 
263
- 5. **Program Truth (IR) Self-Model**:
264
- * **Role**: Progmune's "genome," the system's sole and deterministic understanding of project code. It statically analyzes source code to extract **Symbol Tables, Type Graphs, Call Graphs**, and optional **Protocol Annotations**.
265
- * **Value**: Defines the "closed world" in which AI can operate, serving as the foundation for all subsequent validations, ensuring AI does not "hallucinate" non-existent entities.
107
+ ### C (Gold Benchmark v7)
266
108
 
267
- 6. **Constraint Engine Innate Immunity Layer**:
268
- * **Role**: Performs rapid, rule-based validation of Action Trees based on the IR, primarily checking for **SVL-1 (Symbolic Existence), SVL-2 (Type Validity), and SVL-3 (Dataflow Correctness)**.
269
- * **Value**: Intercepts the most common "low-level errors" (e.g., non-existent functions, parameter type mismatches) in milliseconds, providing the first line of defense.
109
+ | Repo | Precision | Recall | F1 | Samples |
110
+ |------|-----------|--------|-----|---------|
111
+ | curl | 30.9% | 87.5% | 45.7% | 85 |
112
+ | libssh | 36.0% | 64.3% | 46.2% | 47 |
113
+ | nginx | — | — | 0 FP | 50 |
114
+ | redis | — | — | 0 FP | 50 |
270
115
 
271
- 7. **Semantic State Graph (SSG) — Adaptive Immunity Layer**:
272
- * **Role**: Models the valid states of system resources and their allowed transitions through programmable state machines. It validates **SVL-4 (Protocol Legality)**, ensuring that function call sequences conform to predefined business protocols (e.g., `UNAUTHENTICATED` -> `AUTHENTICATED` -> `TOKEN_ISSUED`).
273
- * **Value**: Prevents AI from generating code that violates business processes, elevating validation from static correctness to behavioral legality. The **BFS Protocol Repair** feature introduced in v2.1.4 enables it to automatically complete complex missing protocols.
116
+ ### P0-P3 Rule Injection (2026-08)
274
117
 
275
- 8. **Immune Memory & Failure Corpus Immune Memory Layer**:
276
- * **Role**: Every constraint violation is recorded in the **Failure Corpus**, including intent, error details, and SSG state. The system learns from these failure patterns to generate high-confidence "antibody rules," stored in the **Antibody Registry**.
277
- * **Value**: Enables the system to learn from errors, form "immune memory," and proactively prevent similar future errors. The **Credit Loops** mechanism dynamically adjusts weights based on historical function success rates, optimizing capability chain selection under ambiguous intentions.
118
+ - **+19 new detections** across 10 TS projects, **0 false positives** across 6 C repos + PostgreSQL
119
+ - Bootstrapping deadlock broken: all 21 protocol namespaces now have rule vocabulary
120
+ - `excludePatterns` + `languages` architecture for FP management
278
121
 
279
- 9. **Code Emitter Program Landing Layer**:
280
- * **Role**: Deterministically translates all validated Action Trees into executable Python or TypeScript code, handling import resolution, variable scoping, object literal generation, and correct indentation for nested control structures.
281
- * **Value**: Ensures that the final generated code is safe, correct, and usable.
122
+ → [Two-Hump Report](docs/two-hump-report.md) · [P0-P3 Final Report](docs/p0-p3-final-report.md)
282
123
 
283
124
  ---
284
125
 
285
- ## 📊 Semantic Validity Levels (SVL)
286
-
287
- We define the "health standards" for AI-generated code, providing a layered, quantifiable validation guarantee for the system:
288
-
289
- | Level | Name | Description | Progmune's Guarantee |
290
- |:-----|:-----|:-----|:-----|
291
- | **SVL-1** | Symbolic Existence | Every called function, variable, and import actually exists in the project | 100% elimination of hallucinated API calls |
292
- | **SVL-2** | Type Validity | Parameter count and types match the declared signature | 100% elimination of type mismatch errors |
293
- | **SVL-3** | Dataflow Correctness | Variables are declared before use; no circular references or uninitialized access | 100% elimination of NameError / UnboundLocalError |
294
- | **SVL-4** | Protocol Legality | Function call sequences conform to declared pre/post-state transition rules | Strict adherence to business state machines, no illegal state jumps |
295
- | **SVL-5** | Semantic Intent Correctness | Generated code faithfully implements the intended business logic | Long-term goal; indirectly guaranteed by SVL-1~4 in current version |
126
+ ## Architecture
296
127
 
297
- Progmune Runtime v2.1.4 fully guarantees SVL-1 to SVL-3, with SVL-4 implemented as an optional protocol constraint system. SVL-5 is an open research direction.
298
-
299
- ---
300
-
301
- ## 🚀 快速上手指南
302
-
303
- ### 前置条件
304
- * [Node.js](https://nodejs.org/) >= 18
305
- * 一个有效的 LLM API 密钥(支持 OpenAI 兼容接口,推荐使用具备强推理能力的模型)
306
-
307
- ### 1. 全局安装
308
-
309
- ```bash
310
- npm install -g progmune-runtime
311
- ```
312
-
313
- ### 2. 初始化配置
314
-
315
- 在你的项目根目录下运行 setup,配置你的 API 密钥:
316
-
317
- ```bash
318
- npx progmune-runtime setup "YOUR_API_KEY"
319
128
  ```
320
- *(提示:你也可以通过设置环境变量 `OPENAI_API_KEY` 来配置)*
321
-
322
- ### 3. 提取程序真相 (IR)
323
-
324
- Progmune 扫描你的项目,建立“自我认知”:
325
-
326
- ```bash
327
- npx progmune-runtime ir .
129
+ SDK (src/sdk.ts) verify() APPROVED / NEEDS_REVIEW / BLOCKED
130
+ └─ Trust Engine 4-dimension scoring → Decision
131
+ ├─ Policy Engine Enterprise policy enforcement (ALLOW/WARN/BLOCK)
132
+ ├─ SSG Validator Protocol state machine verification
133
+ ├─ Protocol Detector Regex-based protocol step detection (22 detectors)
134
+ ├─ IR Extractor TypeScript AST → function IR (ts-morph)
135
+ ├─ Repair Executor detect → plan → fix → validate → commit/rollback
136
+ └─ Knowledge Base 31 domains, 140 rules, evidence chains
328
137
  ```
329
- 这会在项目目录下生成一个 `.progmune/ir.json` 文件,它是后续所有验证的基础。
330
138
 
331
- ### 4. 启动 MCP 服务器 (可选)
139
+ ### Interfaces
332
140
 
333
- 如果你使用 Cursor、Claude Desktop 等支持 MCP (Model Context Protocol) 的客户端,可以直接启动 Progmune 作为 MCP 服务器,让你的 AI 助手获得免疫能力:
334
-
335
- ```bash
336
- npx progmune-runtime start
337
- ```
338
-
339
- ### 5. 运行内置测试
340
-
341
- 验证系统是否正常工作:
342
-
343
- ```bash
344
- npx progmune-runtime test
345
- ```
346
-
347
- ---
348
-
349
- ## 📖 深入阅读
350
-
351
- 想要了解更多关于“程序免疫学”的理论基础、SSG 状态机的配置方法以及 v2.1.4 的最新特性(如 BFS 协议修复、信用循环),请参阅我们的:
352
-
353
- 👉 **[《Program Immunology 技术白皮书》](./WHITEPAPER.md)**
354
-
355
- ---
356
-
357
- ## 🤝 参与贡献
358
-
359
- Progmune 正在重新定义 AI 辅助编程——**让程序真相主导生成**。我们欢迎提交 Issue、Pull Request,或者在 Discussions 中分享你的想法!
360
-
361
- ## 📄 许可证
362
-
363
- 本项目采用 MIT License。
364
-
365
- ---
366
-
367
- # Progmune Runtime (English Version)
368
-
369
- ![Progmune Runtime Preview](./social-preview.png)
370
-
371
- **Program Immunology: Building a Trustworthy Immune System for AI-Generated Code**
372
-
373
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
374
- [![MCP](https://img.shields.io/badge/MCP-Compatible-blue)](https://modelcontextprotocol.io)
375
- [![Stage: Technical Preview](https://img.shields.io/badge/Stage-Technical_Preview-orange)]()
376
-
377
- ---
378
-
379
- ## 💡 Core Value: Why Your AI Code Needs "Immunity" and "Generation"?
380
-
381
- In the era of AI-assisted programming, Large Language Models (LLMs) bring unprecedented efficiency but also come with "cognitive deficiencies":
382
-
383
- * **Hallucinations**: LLMs may invent non-existent functions, classes, or variables, leading to runtime errors.
384
- * **Type Drift**: Mismatched parameter counts or types with actual function signatures, causing type errors.
385
- * **Protocol Violations**: Generating code that violates the logical order of business processes, such as issuing tokens before user authentication.
386
-
387
- **Progmune Runtime aims to solve these core pain points by providing a robust "immune system" for AI-generated code, while also enabling trustworthy "generation" capabilities.**
388
-
389
- It demotes LLMs from "unconstrained code generators" to **"constrained heuristic proposers,"** returning the ultimate decision-making power over code to **Program Truth (Intermediate Representation, IR)**. This means Progmune can not only **eliminate code hallucinations** and **ensure protocol security** but also **"get smarter with use"** by learning from historical errors, significantly enhancing the reliability and safety of AI-generated code.
390
-
391
- **Core Philosophy: Immunity guarantees generation, and generation drives immunity.**
392
-
393
- * **Immunity**: Through multi-layered validation mechanisms, ensuring every step of AI generation conforms to program truth and business logic.
394
- * **Generation**: Under the constraints of the immune system, efficiently and intelligently transforms ambiguous intentions into executable, high-quality code.
395
-
396
- **Direct Value for Developers:**
397
- * **🚫 End Code Hallucinations**: 100% guarantee that generated code only calls functions and variables that genuinely exist in your project.
398
- * **🛡️ Protocol-Level Security**: Automatically intercepts illegal business logic transitions, ensuring code behavior aligns with expectations.
399
- * **🧠 Smarter with Use**: The system learns from failures, automatically forming "antibodies" to fix similar issues, reducing LLM token consumption.
400
- * **🚀 Boost Development Efficiency**: Reduces time spent debugging and refactoring AI-generated code, allowing developers to focus more on business logic.
401
-
402
- ---
403
-
404
- ## 🏗️ Core Architecture: The Synergy of Generation and Immunity
405
-
406
- Progmune Runtime's design is inspired by the biological immune system, building multi-layered defense mechanisms to ensure the semantic validity of AI-generated code. Its core architecture clearly illustrates the synergistic operation of its two core capabilities: "Generation" and "Immunity."
407
-
408
- ```mermaid
409
- graph TD
410
- UserIntent[User Intent] --> A(LLM Proposer)
411
- A --> B(Semantic Topology & Strategy Planner)
412
- B --> C(Action Runtime)
413
- C --> D{Constraint Engine}
414
- D --> |SVL-1, SVL-2, SVL-3 Valid| E{"Semantic State Graph (SSG)"}
415
- D --> |Invalid| F(Failure Corpus)
416
- E --> |SVL-4 Valid| G(Code Emitter)
417
- E --> |Invalid| F
418
- F --> H(Immune Memory)
419
- H --> I(Antibody Registry & Credit Loops)
420
- I --> B
421
- subgraph "Program Truth (IR)"
422
- J[Symbol Table]
423
- K[Type Graph]
424
- L[Call Graph]
425
- M[Protocol Annotations]
426
- end
427
- J --> D
428
- K --> D
429
- L --> D
430
- M --> E
431
- G --> N[Executable Code]
432
- ```
433
-
434
- 1. **User Intent**: Developers describe their programming needs in natural language.
435
-
436
- 2. **LLM Proposer**: The Large Language Model, based on user intent, generates preliminary, high-level proposals for action sequences. It no longer directly generates code but proposes a series of abstract function calls and logical structures.
437
-
438
- 3. **Semantic Topology & Strategy Planner**:
439
- * **Semantic Topology**: Constructs a semantic similarity graph from the Program Truth (IR), understanding the relationships between functions and modules within the project.
440
- * **Strategy Planner**: Utilizes the Semantic Topology to map the LLM's ambiguous intentions to concrete, executable **Capability Chains** within the project. This is a crucial "generation" step from intent to executable actions.
441
-
442
- 4. **Action Runtime — Deterministic Synthesis Boundary**:
443
- * **Role**: The LLM's proposals and the capability chains generated by the Strategy Planner are translated here into a set of **deterministic API calls** (e.g., `call(func, ...args)`, `ifElse(condition, thenFn, elseFn)`). These APIs are executed in a sandboxed environment and captured as structured **Action Trees**.
444
- * **Value**: Eliminates code injection vulnerabilities and formatting errors at the source, confining LLM output within a controllable and verifiable structure.
445
-
446
- 5. **Program Truth (IR) — Self-Model**:
447
- * **Role**: Progmune's "genome," the system's sole and deterministic understanding of project code. It statically analyzes source code to extract **Symbol Tables, Type Graphs, Call Graphs**, and optional **Protocol Annotations**.
448
- * **Value**: Defines the "closed world" in which AI can operate, serving as the foundation for all subsequent validations, ensuring AI does not "hallucinate" non-existent entities.
449
-
450
- 6. **Constraint Engine — Innate Immunity Layer**:
451
- * **Role**: Performs rapid, rule-based validation of Action Trees based on the IR, primarily checking for **SVL-1 (Symbolic Existence), SVL-2 (Type Validity), and SVL-3 (Dataflow Correctness)**.
452
- * **Value**: Intercepts the most common "low-level errors" (e.g., non-existent functions, parameter type mismatches) in milliseconds, providing the first line of defense.
453
-
454
- 7. **Semantic State Graph (SSG) — Adaptive Immunity Layer**:
455
- * **Role**: Models the valid states of system resources and their allowed transitions through programmable state machines. It validates **SVL-4 (Protocol Legality)**, ensuring that function call sequences conform to predefined business protocols (e.g., `UNAUTHENTICATED` -> `AUTHENTICATED` -> `TOKEN_ISSUED`).
456
- * **Value**: Prevents AI from generating code that violates business processes, elevating validation from static correctness to behavioral legality. The **BFS Protocol Repair** feature introduced in v2.1.4 enables it to automatically complete complex missing protocols.
457
-
458
- 8. **Immune Memory & Failure Corpus — Immune Memory Layer**:
459
- * **Role**: Every constraint violation is recorded in the **Failure Corpus**, including intent, error details, and SSG state. The system learns from these failure patterns to generate high-confidence "antibody rules," stored in the **Antibody Registry**.
460
- * **Value**: Enables the system to learn from errors, form "immune memory," and proactively prevent similar future errors. The **Credit Loops** mechanism dynamically adjusts weights based on historical function success rates, optimizing capability chain selection under ambiguous intentions.
461
-
462
- 9. **Code Emitter — Program Landing Layer**:
463
- * **Role**: Deterministically translates all validated Action Trees into executable Python or TypeScript code, handling import resolution, variable scoping, object literal generation, and correct indentation for nested control structures.
464
- * **Value**: Ensures that the final generated code is safe, correct, and usable.
141
+ | Interface | Purpose |
142
+ |-----------|---------|
143
+ | **SDK** (`verify()`) | One-call API for developers |
144
+ | **CLI** (`npm run trust`) | Command-line trust checks |
145
+ | **MCP Server** | Claude Code integration (`progmune_check`, `progmune_trust_check`) |
146
+ | **GitHub Action** | CI/CD gate — blocks unverified AI code at PR |
147
+ | **Trust API** | `POST /trust/check` — machine-to-machine |
465
148
 
466
149
  ---
467
150
 
468
- ## 📊 Semantic Validity Levels (SVL)
151
+ ## Scientific Foundation
469
152
 
470
- We define the "health standards" for AI-generated code, providing a layered, quantifiable validation guarantee for the system:
153
+ Progmune is built on the premise that **LLM outputs are statistical performances, not reasoning** (Kambhampati et al., ICML 2026). Rather than trusting what the model says about code, Progmune verifies what the program actually does — using protocol state machines, IR extraction, and evidence-backed decision chains.
471
154
 
472
- | Level | Name | Description | Progmune's Guarantee |
473
- |:-----|:-----|:-----|:-----|
474
- | **SVL-1** | Symbolic Existence | Every called function, variable, and import actually exists in the project | 100% elimination of hallucinated API calls |
475
- | **SVL-2** | Type Validity | Parameter count and types match the declared signature | 100% elimination of type mismatch errors |
476
- | **SVL-3** | Dataflow Correctness | Variables are declared before use; no circular references or uninitialized access | 100% elimination of NameError / UnboundLocalError |
477
- | **SVL-4** | Protocol Legality | Function call sequences conform to declared pre/post-state transition rules | Strict adherence to business state machines, no illegal state jumps |
478
- | **SVL-5** | Semantic Intent Correctness | Generated code faithfully implements the intended business logic | Long-term goal; indirectly guaranteed by SVL-1~4 in current version |
155
+ Recent work applies Sergei Gukov's "Two-Hump Problem" framework to understand and systematically close detection capability gaps.
479
156
 
480
- Progmune Runtime v2.1.4 fully guarantees SVL-1 to SVL-3, with SVL-4 implemented as an optional protocol constraint system. SVL-5 is an open research direction。
157
+ [Investor Whitepaper](docs/Progmune_投资人白皮书_v2.0.html) · [Trust Decision Model](docs/ai-trust-decision-model-v1.md)
481
158
 
482
159
  ---
483
160
 
484
- ## 🚀 Quick Start Guide
485
-
486
- ### Prerequisites
487
- * [Node.js](https://nodejs.org/) >= 18
488
- * A valid LLM API key (supports OpenAI-compatible interfaces, models with strong reasoning capabilities are recommended)
489
-
490
- ### 1. Global Installation
161
+ ## Contributing
491
162
 
492
- ```bash
493
- npm install -g progmune-runtime
494
- ```
163
+ See [CLAUDE.md](CLAUDE.md) for architecture and code conventions, and [CONTRIBUTING.md](CONTRIBUTING.md) for the development workflow.
495
164
 
496
- ### 2. Configuration Initialization
497
-
498
- Run setup in your project root to configure your API key:
499
-
500
- ```bash
501
- npx progmune-runtime setup "YOUR_API_KEY"
502
- ```
503
- *(Hint: You can also configure by setting the `OPENAI_API_KEY` environment variable)*
504
-
505
- ### 3. Extract Program Truth (IR)
506
-
507
- Let Progmune scan your project to establish "self-awareness":
508
-
509
- ```bash
510
- npx progmune-runtime ir .
511
- ```
512
- This will generate a `.progmune/ir.json` file in your project directory, which is the basis for all subsequent validations.
513
-
514
- ### 4. Start MCP Server (Optional)
515
-
516
- If you use clients like Cursor or Claude Desktop that support MCP (Model Context Protocol), you can directly start Progmune as an MCP server to give your AI assistant immune capabilities:
517
-
518
- ```bash
519
- npx progmune-runtime start
520
- ```
521
-
522
- ### 5. Run Built-in Tests
523
-
524
- Verify that the system is working correctly:
525
-
526
- ```bash
527
- npx progmune-runtime test
528
- ```
165
+ High-impact contribution areas:
166
+ - **Framework adapters** (Express, Next.js, FastAPI) — the #1 product gap
167
+ - **Python verification rules** extend beyond TypeScript
168
+ - **Bug fixes** for existing detectors and safeguards
529
169
 
530
170
  ---
531
171
 
532
- ## 📖 Further Reading
533
-
534
- To learn more about the theoretical foundations of "Program Immunology," how to configure SSG state machines, and the latest features of v2.1.4 (such as BFS Protocol Repair, Credit Loops), please refer to our:
172
+ ## Status
535
173
 
536
- 👉 **[《Program Immunology Technical Whitepaper》](./WHITEPAPER.md)**
174
+ - **Runtime Pipeline:** Detect → Explain → Repair → Validate (L1–L4)
175
+ - **Trust Engine:** 4-dimension scoring with binary explainability gate
176
+ - **MCP Tools:** 19 — `progmune_trust_check`, `progmune_score`, `progmune_policy_check`, `progmune_certify`, and more
177
+ - **Framework Adapters:** Express ✅ (1/13)
178
+ - **Knowledge Base:** 31 domains, 140 protocol rules, 22 detectors, 26 safeguards
179
+ - **Corpus:** 2,500+ trajectories across 6+ repositories
180
+ - **Current focus:** Framework adaptation + enterprise PoC validation
537
181
 
538
182
  ---
539
183
 
540
- ## 🤝 Contributing
541
-
542
- Progmune is redefining AI-assisted programming—**letting program truth drive generation**. We welcome Issues, Pull Requests, or sharing your thoughts in Discussions!
543
-
544
- ## 📄 License
184
+ ## License
545
185
 
546
- This project is licensed under the MIT License.
186
+ MIT [LICENSE](LICENSE)