progmune-runtime 2.1.6 → 3.2.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 +119 -461
- package/dist/ablation-study.js +144 -0
- package/dist/ablation-study.test.js +18 -0
- package/dist/action-runtime.js +3 -1
- package/dist/active-learning.js +211 -0
- package/dist/analytics.js +139 -0
- package/dist/asset-factory.js +309 -0
- package/dist/asset-growth.js +244 -0
- package/dist/asset-promotion.js +382 -0
- package/dist/asset-quality.js +550 -0
- package/dist/audit/business-translator.js +285 -0
- package/dist/audit/cli.js +66 -0
- package/dist/audit/formatters/html.js +379 -0
- package/dist/audit/formatters/json.js +11 -0
- package/dist/audit/formatters/markdown.js +192 -0
- package/dist/audit/formatters/terminal.js +189 -0
- package/dist/audit/index.js +25 -0
- package/dist/audit/report-builder.js +318 -0
- package/dist/audit/types.js +8 -0
- package/dist/audit.js +3 -3
- package/dist/auto-benchmark-generator.js +137 -0
- package/dist/auto-benchmark-generator.test.js +45 -0
- package/dist/auto-protocol-synthesizer.js +362 -0
- package/dist/auto-protocol-synthesizer.test.js +82 -0
- package/dist/autonomous-patch.js +175 -0
- package/dist/autonomous-patch.test.js +128 -0
- package/dist/badge/badge-server.js +98 -0
- package/dist/behavior-miner.js +442 -0
- package/dist/belief-layer.js +475 -0
- package/dist/benchmark-count.js +5 -0
- package/dist/benchmark-generator.js +211 -0
- package/dist/benchmark-harness.js +201 -0
- package/dist/benchmark-pass-rate.js +7 -0
- package/dist/benchmark-report.js +8 -3
- package/dist/benchmark-save.js +14 -1
- package/dist/bootstrap-validation.js +197 -0
- package/dist/bootstrap-validation.test.js +51 -0
- package/dist/branch-ledger.js +1 -1
- package/dist/capability-gap.js +130 -0
- package/dist/certify-html.js +351 -0
- package/dist/certify.js +326 -0
- package/dist/check.js +4 -4
- package/dist/compliance-miner.js +447 -0
- package/dist/continuous-benchmark.js +194 -0
- package/dist/continuous-benchmark.test.js +116 -0
- package/dist/corpus-stats.js +173 -0
- package/dist/counterfactual-engine.js +288 -0
- package/dist/coverage-dashboard.js +109 -0
- package/dist/coverage-system.test.js +205 -0
- package/dist/cross-repo-precision.js +352 -0
- package/dist/cve-benchmark.js +180 -0
- package/dist/cve-benchmark.test.js +28 -0
- package/dist/cve-collector.js +73 -0
- package/dist/data-quality.js +141 -0
- package/dist/decision-engine.js +388 -0
- package/dist/derive-metadata.js +250 -0
- package/dist/difficulty-active.test.js +198 -0
- package/dist/difficulty-map.js +244 -0
- package/dist/discovery-analytics.js +125 -0
- package/dist/discovery-model.js +149 -0
- package/dist/discovery-optimize.test.js +199 -0
- package/dist/discovery-trace.js +276 -0
- package/dist/discovery-trace.test.js +97 -0
- package/dist/emitter.js +83 -1
- package/dist/enterprise-dashboard.js +405 -0
- package/dist/eval-hardening.js +297 -0
- package/dist/eval-hardening.test.js +85 -0
- package/dist/evaluation-campaign.js +359 -0
- package/dist/evaluation-campaign.test.js +181 -0
- package/dist/evidence-growth.js +143 -0
- package/dist/evidence-repository.js +209 -0
- package/dist/evidence-system.js +441 -0
- package/dist/execute.js +15 -7
- package/dist/experimental/software-physics.js +291 -0
- package/dist/experimental/state-inference.js +516 -0
- package/dist/experimental/unsupervised-physics.js +230 -0
- package/dist/extract-ir-python.js +54 -7
- package/dist/extract-ir.js +376 -12
- package/dist/failure-collector.js +2 -2
- package/dist/failure-corpus.js +322 -9
- package/dist/feedback.js +16 -5
- package/dist/feedback.test.js +49 -0
- package/dist/file-lock.js +1 -1
- package/dist/flywheel-batch.js +292 -0
- package/dist/frameworks/express-cli.js +237 -0
- package/dist/frameworks/express-detector.js +445 -0
- package/dist/frameworks/express-detector.test.js +206 -0
- package/dist/frameworks/index.js +30 -0
- package/dist/frameworks/nestjs-detector.js +302 -0
- package/dist/frameworks/trpc-detector.js +161 -0
- package/dist/frameworks/version-awareness.js +179 -0
- package/dist/function-synonyms.js +164 -0
- package/dist/function-synonyms.test.js +68 -0
- package/dist/generalization.test.js +352 -0
- package/dist/goal-annotator.js +113 -0
- package/dist/goal-planner.js +563 -0
- package/dist/gold-cve.js +164 -0
- package/dist/gold-cve.test.js +104 -0
- package/dist/gold-quality.js +206 -0
- package/dist/gold-tiers.js +241 -0
- package/dist/governance-dashboard.js +327 -0
- package/dist/graph-viz.js +240 -0
- package/dist/guided-frontier.js +195 -0
- package/dist/hierarchical-planner.js +148 -0
- package/dist/identifier-parser.js +260 -0
- package/dist/immune-metrics.js +93 -0
- package/dist/immune-receiver.js +158 -0
- package/dist/immune-reporter.js +1 -1
- package/dist/improvement-orchestrator.js +206 -0
- package/dist/inject-p0-vocabulary.js +300 -0
- package/dist/intent-parser.js +218 -0
- package/dist/invariant-algebra.js +476 -0
- package/dist/invariant-calculus.js +533 -0
- package/dist/ir-utils.js +70 -0
- package/dist/ir-utils.test.js +50 -0
- package/dist/knowledge-api.js +312 -0
- package/dist/knowledge-evolution.js +452 -0
- package/dist/knowledge-explorer.js +506 -0
- package/dist/knowledge-flywheel.js +274 -0
- package/dist/knowledge-governance.js +338 -0
- package/dist/knowledge-governance.test.js +150 -0
- package/dist/knowledge-graph.js +181 -0
- package/dist/knowledge-guided-synth.js +246 -0
- package/dist/knowledge-loop.test.js +77 -0
- package/dist/knowledge-object.js +316 -0
- package/dist/knowledge-package.js +98 -0
- package/dist/kpi-dashboard.js +561 -0
- package/dist/l3-cross-function.js +280 -0
- package/dist/learning-ranker.js +148 -0
- package/dist/learning-ranker.test.js +291 -0
- package/dist/ledger/accountability.js +322 -0
- package/dist/ledger/chain-builder.js +185 -0
- package/dist/ledger/cli.js +222 -0
- package/dist/ledger/index.js +13 -0
- package/dist/ledger/signatures.js +193 -0
- package/dist/ledger/types.js +9 -0
- package/dist/llm.js +74 -3
- package/dist/load-benchmarks.js +8 -3
- package/dist/logger.js +66 -0
- package/dist/logger.test.js +37 -0
- package/dist/logistic-reward.js +339 -0
- package/dist/logistic-reward.test.js +180 -0
- package/dist/macro-graph.js +193 -0
- package/dist/macro-repair.js +183 -0
- package/dist/mcp-server.mjs +1202 -483
- package/dist/memory-layer.js +42 -5
- package/dist/multi-repo-precision.js +422 -0
- package/dist/name-free-protocol.js +425 -0
- package/dist/name-free-protocol.test.js +170 -0
- package/dist/name-scrambling.js +138 -0
- package/dist/name-scrambling.test.js +16 -0
- package/dist/p3-observability.test.js +281 -0
- package/dist/p5-orchestrator.test.js +225 -0
- package/dist/pairwise-preference.js +294 -0
- package/dist/pairwise-preference.test.js +140 -0
- package/dist/planner-constraints.js +104 -0
- package/dist/planner-prompts.js +155 -0
- package/dist/planner-telemetry.js +415 -0
- package/dist/planner-trace.js +214 -0
- package/dist/planner.js +162 -167
- package/dist/plsb/artifact.js +116 -0
- package/dist/plsb/cli.js +71 -0
- package/dist/plsb/index.js +19 -0
- package/dist/plsb/leaderboard.js +249 -0
- package/dist/plsb/report-md.js +156 -0
- package/dist/plsb/schema.js +179 -0
- package/dist/plsb-benchmark.js +284 -0
- package/dist/plsb-benchmark.test.js +119 -0
- package/dist/policy/cli.js +134 -0
- package/dist/policy/engine.js +333 -0
- package/dist/policy/index.js +12 -0
- package/dist/policy/types.js +59 -0
- package/dist/policy-miner.js +505 -0
- package/dist/precision-analyze.js +229 -0
- package/dist/precision-benchmark.js +147 -0
- package/dist/precision-label-c.js +134 -0
- package/dist/precision-label.js +193 -0
- package/dist/precision-report-c.js +149 -0
- package/dist/precision-report.js +246 -0
- package/dist/progmune-status.js +108 -0
- package/dist/proof-engine.js +479 -0
- package/dist/proof-provenance.js +315 -0
- package/dist/protocol-coverage.js +294 -0
- package/dist/protocol-detector.js +1189 -0
- package/dist/protocol-embedding-expanded.js +297 -0
- package/dist/protocol-embedding-expanded.test.js +97 -0
- package/dist/protocol-embedding.js +195 -0
- package/dist/protocol-embedding.test.js +82 -0
- package/dist/protocol-extractor-v2.js +354 -0
- package/dist/protocol-extractor-v2.test.js +140 -0
- package/dist/protocol-extractor.js +310 -0
- package/dist/protocol-extractor.test.js +113 -0
- package/dist/protocol-foundation.js +322 -0
- package/dist/protocol-foundation.test.js +163 -0
- package/dist/protocol-frontier.js +243 -0
- package/dist/protocol-frontier.test.js +92 -0
- package/dist/protocol-gap-analyzer.js +228 -0
- package/dist/protocol-gap-analyzer.test.js +49 -0
- package/dist/protocol-invariants.js +276 -0
- package/dist/protocol-invariants.test.js +111 -0
- package/dist/protocol-knowledge.js +464 -0
- package/dist/protocol-miner.js +343 -0
- package/dist/protocol-mining.js +207 -0
- package/dist/protocol-mining.test.js +37 -0
- package/dist/protocol-registry.js +1 -1
- package/dist/protocol-security-benchmark.js +222 -0
- package/dist/protocol-vulnerability.js +257 -0
- package/dist/protocol-vulnerability.test.js +60 -0
- package/dist/python-benchmark.js +120 -0
- package/dist/python-emitter.js +163 -45
- package/dist/python-protocol-extractor.js +187 -0
- package/dist/python-protocol-extractor.test.js +116 -0
- package/dist/realworld-benchmark.js +646 -0
- package/dist/realworld-benchmark.test.js +36 -0
- package/dist/repair-arch.test.js +411 -0
- package/dist/repair-evolution.test.js +454 -0
- package/dist/repair-executor.js +719 -0
- package/dist/repair-proposal.js +4 -4
- package/dist/repair-ranker.js +141 -0
- package/dist/repair-strategies.js +419 -0
- package/dist/repair-taxonomy.js +234 -0
- package/dist/repair-types.js +12 -0
- package/dist/repo-evaluator.js +250 -0
- package/dist/repo-evaluator.test.js +128 -0
- package/dist/resource-abstraction.js +242 -0
- package/dist/resource-detector.js +211 -0
- package/dist/result.test.js +43 -0
- package/dist/reward-system.js +411 -0
- package/dist/reward-system.test.js +175 -0
- package/dist/risk-model.js +215 -0
- package/dist/rule-miner.js +234 -7
- package/dist/rule-specificity.js +254 -0
- package/dist/runtime-types.js +27 -0
- package/dist/scaffold.js +208 -0
- package/dist/scale-collector.test.js +101 -0
- package/dist/scale-trajectory-collector.js +128 -0
- package/dist/sdk.js +250 -0
- package/dist/search-planner.js +4 -41
- package/dist/semantic-snapshot.js +1 -1
- package/dist/semantic-topology.js +121 -0
- package/dist/semantic-trace.js +310 -317
- package/dist/sequence-extractor.js +343 -0
- package/dist/skill-library.js +245 -0
- package/dist/skill-planner.test.js +189 -0
- package/dist/software-physics.js +291 -0
- package/dist/software-physics.test.js +81 -0
- package/dist/ssg-precision.js +478 -0
- package/dist/ssg-validator.js +71 -21
- package/dist/state-inference-doubleblind.test.js +160 -0
- package/dist/state-inference.js +516 -0
- package/dist/state-inference.test.js +115 -0
- package/dist/state-machine-fingerprint.js +345 -0
- package/dist/state-machine-fingerprint.test.js +120 -0
- package/dist/state-miner.js +386 -0
- package/dist/state-name-inference.js +213 -0
- package/dist/state-name-inference.test.js +69 -0
- package/dist/strategy-planner.js +262 -96
- package/dist/strategy-planner.test.js +135 -0
- package/dist/telemetry-analytics.test.js +402 -0
- package/dist/terminal-format.js +68 -0
- package/dist/terminal-format.test.js +83 -0
- package/dist/topology-factory.js +196 -0
- package/dist/topology-representation.js +242 -0
- package/dist/topology-representation.test.js +27 -0
- package/dist/trajectory-augmentation.js +254 -0
- package/dist/trajectory-augmentation.test.js +63 -0
- package/dist/trajectory-corpus.js +440 -0
- package/dist/trajectory-corpus.test.js +32 -0
- package/dist/trajectory-feedback.test.js +116 -0
- package/dist/transition-synthesizer.js +286 -0
- package/dist/transition-synthesizer.test.js +123 -0
- package/dist/trust/api-semantic-mapper.js +809 -0
- package/dist/trust/call-graph-propagator.js +225 -0
- package/dist/trust/cli.js +122 -0
- package/dist/trust/compliance-scorer.js +283 -0
- package/dist/trust/confidence-calculator.js +261 -0
- package/dist/trust/engine.js +1145 -0
- package/dist/trust/explainability.js +85 -0
- package/dist/trust/formatters/ci.js +42 -0
- package/dist/trust/formatters/json.js +11 -0
- package/dist/trust/formatters/terminal.js +152 -0
- package/dist/trust/index.js +39 -0
- package/dist/trust/phase1-verify.js +171 -0
- package/dist/trust/protocol-domain-validator.js +697 -0
- package/dist/trust/score-calculator.js +282 -0
- package/dist/trust/ssg-bridge.js +641 -0
- package/dist/trust/ssg-bridge.test.js +269 -0
- package/dist/trust/types.js +67 -0
- package/dist/trust/violation-trace.js +335 -0
- package/dist/trust-api.js +179 -0
- package/dist/trust-calibration.js +279 -0
- package/dist/unknown-protocol-discovery.js +339 -0
- package/dist/unknown-protocol-discovery.test.js +102 -0
- package/dist/unsupervised-physics.js +230 -0
- package/dist/unsupervised-physics.test.js +95 -0
- package/dist/utils.test.js +37 -0
- package/dist/validator.js +187 -10
- package/dist/verification-intelligence.js +475 -0
- package/dist/verify-api.js +432 -0
- package/dist/vi-impact-report.js +293 -0
- package/dist/wl-fingerprint.js +162 -0
- package/dist/wl-fingerprint.test.js +130 -0
- package/dist/zeroshot-strategy.js +139 -0
- 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
- package/docs/Progmune_/351/241/271/347/233/256/345/205/250/350/247/243.html +721 -0
- package/package.json +73 -6
- package/protocols.json +1956 -50
- package/.dockerignore +0 -14
- package/.mcp.json +0 -11
- package/.progmune_allowlist +0 -50
- package/.test_report/test_report.md +0 -87
- package/Dockerfile +0 -9
- package/FAQ.md +0 -167
- package/WHITEPAPER.md +0 -540
- package/demo-project/auth.ts +0 -55
- package/demo-project/tsconfig.json +0 -8
- package/dist/acl-breakdown.js +0 -13
- package/dist/all-sessions.js +0 -11
- package/dist/antibody-stats.js +0 -11
- package/dist/branch-tree-count.js +0 -14
- package/dist/common-fixpath.js +0 -12
- package/dist/constraint-types.js +0 -12
- package/dist/exec-metrics.js +0 -11
- package/dist/failure-report.js +0 -11
- package/dist/fast-path-hits.js +0 -13
- package/dist/fingerprint-list.js +0 -15
- package/dist/gen-history-log.js +0 -13
- package/dist/heatmap-data.js +0 -11
- package/dist/recent-session.js +0 -12
- package/dist/svl-distribution.js +0 -11
- package/dist/terminal-status.js +0 -11
- package/dist/token-savings.js +0 -11
- package/dist/total-repairs.js +0 -12
- package/dist/unresolved-count.js +0 -12
- package/dist/valid-fingerprints.js +0 -13
- package/dist/verify-ledgers.js +0 -11
- package/docs/whitepaper-style.css +0 -77
- package/docs/whitepaper-v2.1.md +0 -609
- package/docs/whitepaper-v2.2.md +0 -1064
- package/docs/whitepaper-v2.2.pdf +0 -0
- package/fly.toml +0 -31
- package/public/dashboard.html +0 -119
- package/server/hub.js +0 -116
- package/test/replay-golden/sess_1780063202050_mgeld.json +0 -9
- package/test/replay-golden/sess_1780064032560_gocld.json +0 -354
- package/test/replay-golden/sess_1780064413331_s2709.json +0 -606
- package/test/replay-golden/sess_1780064792710_y3avo.json +0 -614
- package/test/replay-golden.ts +0 -84
- package/test_benchmark.js +0 -165
- package/test_comprehensive.mjs +0 -638
- package/test_concurrency.js +0 -129
- package/test_ir_robustness.js +0 -85
- package/test_semantic_contracts.js +0 -269
- package/test_ssg_stress.js +0 -156
- package/test_svl3.js +0 -58
- package/tsconfig.json +0 -17
package/README.md
CHANGED
|
@@ -1,546 +1,204 @@
|
|
|
1
|
-
# Progmune
|
|
1
|
+
# Progmune
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
**程序免疫学:为 AI 生成代码构建可信赖的免疫系统**
|
|
3
|
+
## AI Trust Decision Engine for AI-generated software.
|
|
6
4
|
|
|
7
5
|
[](https://opensource.org/licenses/MIT)
|
|
8
6
|
[](https://modelcontextprotocol.io)
|
|
9
|
-
[![
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## 💡 核心价值:为什么你的 AI 代码需要“免疫”与“生成”?
|
|
14
|
-
|
|
15
|
-
在 AI 辅助编程的时代,大语言模型(LLM)带来了前所未有的效率,但也伴随着“认知缺陷”:
|
|
16
|
-
|
|
17
|
-
* **幻觉**:LLM 可能会凭空捏造不存在的函数、类或变量,导致运行时错误。
|
|
18
|
-
* **类型漂移**:参数数量或类型与实际函数签名不匹配,引发类型错误。
|
|
19
|
-
* **协议违规**:生成违反业务逻辑顺序的代码,例如在用户未认证前就签发令牌。
|
|
20
|
-
|
|
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 生成代码的时间,让开发者更专注于业务逻辑。
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
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
|
-
```
|
|
67
|
-
|
|
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)**。这是从意图到可执行动作的关键“生成”步骤。
|
|
7
|
+
[]()
|
|
8
|
+
[]()
|
|
75
9
|
|
|
76
|
-
|
|
77
|
-
* **作用**:LLM 的提议和策略规划器生成的链,在这里被转化为一组**确定性 API 调用**(如 `call(func, ...args)`、`ifElse(condition, thenFn, elseFn)`)。这些 API 在沙箱环境中执行,并捕获为结构化的**动作树 (Action Tree)**。
|
|
78
|
-
* **价值**:从源头消除了代码注入漏洞和格式错误,将 LLM 的输出限制在可控、可验证的结构内。
|
|
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.
|
|
79
11
|
|
|
80
|
-
|
|
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)** 机制根据函数历史成功率动态调整权重,优化模糊意图下的能力链选择。
|
|
95
|
-
|
|
96
|
-
9. **代码发射器 (Code Emitter) —— 程序落地层**:
|
|
97
|
-
* **作用**:将所有验证通过的动作树确定性地翻译为可执行的 Python 或 TypeScript 代码,处理导入、变量作用域和代码格式化。
|
|
98
|
-
* **价值**:确保最终生成的代码是安全、正确且可用的。
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
## 📊 语义有效性级别 (SVL)
|
|
103
|
-
|
|
104
|
-
我们定义了 AI 生成代码的“健康标准”,为系统提供分层、可量化的验证保证:
|
|
105
|
-
|
|
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 为开放性研究方向。
|
|
12
|
+
Progmune doesn't trust what the model says. It verifies what the program actually does.
|
|
115
13
|
|
|
116
14
|
---
|
|
117
15
|
|
|
118
|
-
##
|
|
119
|
-
|
|
120
|
-
### 前置条件
|
|
121
|
-
* [Node.js](https://nodejs.org/) >= 18
|
|
122
|
-
* 一个有效的 LLM API 密钥(支持 OpenAI 兼容接口,推荐使用具备强推理能力的模型)
|
|
123
|
-
|
|
124
|
-
### 1. 全局安装
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
npm install -g progmune-runtime
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### 2. 初始化配置
|
|
131
|
-
|
|
132
|
-
在你的项目根目录下运行 setup,配置你的 API 密钥:
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
npx progmune-runtime setup "YOUR_API_KEY"
|
|
136
|
-
```
|
|
137
|
-
*(提示:你也可以通过设置环境变量 `OPENAI_API_KEY` 来配置)*
|
|
138
|
-
|
|
139
|
-
### 3. 提取程序真相 (IR)
|
|
140
|
-
|
|
141
|
-
让 Progmune 扫描你的项目,建立“自我认知”:
|
|
142
|
-
|
|
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 助手获得免疫能力:
|
|
16
|
+
## One Command
|
|
151
17
|
|
|
152
18
|
```bash
|
|
153
|
-
|
|
19
|
+
npm run sdk src/server.ts --explain
|
|
154
20
|
```
|
|
155
21
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
验证系统是否正常工作:
|
|
159
|
-
|
|
160
|
-
```bash
|
|
161
|
-
npx progmune-runtime test
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
## 📖 深入阅读
|
|
167
|
-
|
|
168
|
-
想要了解更多关于“程序免疫学”的理论基础、SSG 状态机的配置方法以及 v2.1.4 的最新特性(如 BFS 协议修复、信用循环),请参阅我们的:
|
|
169
|
-
|
|
170
|
-
👉 **[《Program Immunology 技术白皮书》](./WHITEPAPER.md)**
|
|
22
|
+
Output: `APPROVED` / `NEEDS_REVIEW` / `BLOCKED` — with Trust Score, evidence, and repair suggestions.
|
|
171
23
|
|
|
172
24
|
---
|
|
173
25
|
|
|
174
|
-
##
|
|
26
|
+
## Two Paths: Intercept or Verify
|
|
175
27
|
|
|
176
|
-
Progmune
|
|
28
|
+
Progmune covers **two code sources** with two complementary mechanisms:
|
|
177
29
|
|
|
178
|
-
|
|
30
|
+
| | **Generate path** (agent-time interception) | **Verify path** (post-hoc checking) |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| **Covers** | Code generated *through Progmune* (`progmune_generate` / `progmune_execute`) | Code written anywhere — Copilot, Cursor, humans (`progmune_trust_check` / SDK / CI) |
|
|
33
|
+
| **Mechanism** | 8 validation gates inside the generation loop: JSON parse → schema → SVL-1 symbol → SVL-2 types → SVL-3 dataflow → SVL-4 protocol state machine → BFS deterministic repair → semantic contract. Violating code is **never written to disk** — it is corrected or retried before emission. | Trust Engine: 4-dimension weighted scoring (policy 35% / protocol 30% / coverage 20% / governance 15%) → Decision + evidence trail |
|
|
34
|
+
| **When errors are handled** | At creation time — the error never exists | After the fact — the file already exists |
|
|
35
|
+
| **Cost curve** | Zero — the violation never landed | Higher the later it's found |
|
|
179
36
|
|
|
180
|
-
|
|
37
|
+
This is the core product thesis: **verify at generation time, not after the fact.** LLM outputs are proposals; the state machine is the referee. LLMs can be persuaded — state machines cannot.
|
|
181
38
|
|
|
182
39
|
---
|
|
183
40
|
|
|
184
|
-
|
|
41
|
+
## What Progmune Detects
|
|
185
42
|
|
|
186
|
-
|
|
43
|
+
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.
|
|
187
44
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
## 💡 Core Value: Why Your AI Code Needs "Immunity" and "Generation"?
|
|
197
|
-
|
|
198
|
-
In the era of AI-assisted programming, Large Language Models (LLMs) bring unprecedented efficiency but also come with "cognitive deficiencies":
|
|
199
|
-
|
|
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.
|
|
45
|
+
| Category | Example violations detected |
|
|
46
|
+
|----------|---------------------------|
|
|
47
|
+
| **TLS / SSL** | Handshake without certificate verification, missing hostname validation |
|
|
48
|
+
| **Auth** | Token without expiry, session without timeout, missing rate limiting |
|
|
49
|
+
| **Payment** | Order without verification, refund without authorization, webhook without signature check |
|
|
50
|
+
| **Resource** | File opened but not closed, connection without cleanup, malloc without free |
|
|
51
|
+
| **Data Integrity** | Mutation without audit trail, missing input validation |
|
|
218
52
|
|
|
219
53
|
---
|
|
220
54
|
|
|
221
|
-
##
|
|
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.
|
|
252
|
-
|
|
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.
|
|
254
|
-
|
|
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.
|
|
258
|
-
|
|
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.
|
|
262
|
-
|
|
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.
|
|
266
|
-
|
|
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.
|
|
270
|
-
|
|
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.
|
|
274
|
-
|
|
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.
|
|
278
|
-
|
|
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.
|
|
282
|
-
|
|
283
|
-
---
|
|
284
|
-
|
|
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 |
|
|
296
|
-
|
|
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 密钥:
|
|
55
|
+
## Quick Start
|
|
316
56
|
|
|
317
57
|
```bash
|
|
318
|
-
|
|
319
|
-
```
|
|
320
|
-
*(提示:你也可以通过设置环境变量 `OPENAI_API_KEY` 来配置)*
|
|
321
|
-
|
|
322
|
-
### 3. 提取程序真相 (IR)
|
|
323
|
-
|
|
324
|
-
让 Progmune 扫描你的项目,建立“自我认知”:
|
|
325
|
-
|
|
326
|
-
```bash
|
|
327
|
-
npx progmune-runtime ir .
|
|
328
|
-
```
|
|
329
|
-
这会在项目目录下生成一个 `.progmune/ir.json` 文件,它是后续所有验证的基础。
|
|
58
|
+
npm install progmune-runtime
|
|
330
59
|
|
|
331
|
-
|
|
60
|
+
# Verify a file — get a Trust Decision
|
|
61
|
+
npm run sdk src/server.ts
|
|
332
62
|
|
|
333
|
-
|
|
63
|
+
# Full explanation with evidence and repair suggestions
|
|
64
|
+
npm run sdk src/server.ts --explain
|
|
334
65
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
### 5. 运行内置测试
|
|
66
|
+
# Trust check (CI-ready JSON output)
|
|
67
|
+
npm run trust -- --project . --json
|
|
340
68
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
```bash
|
|
344
|
-
npx progmune-runtime test
|
|
69
|
+
# Run benchmark suite
|
|
70
|
+
npm run precision:all
|
|
345
71
|
```
|
|
346
72
|
|
|
347
73
|
---
|
|
348
74
|
|
|
349
|
-
##
|
|
350
|
-
|
|
351
|
-
想要了解更多关于“程序免疫学”的理论基础、SSG 状态机的配置方法以及 v2.1.4 的最新特性(如 BFS 协议修复、信用循环),请参阅我们的:
|
|
352
|
-
|
|
353
|
-
👉 **[《Program Immunology 技术白皮书》](./WHITEPAPER.md)**
|
|
354
|
-
|
|
355
|
-
---
|
|
75
|
+
## The Trust Decision
|
|
356
76
|
|
|
357
|
-
|
|
77
|
+
Progmune's output is a **decision** backed by evidence, not a raw list of findings:
|
|
358
78
|
|
|
359
|
-
|
|
79
|
+
| Output | Meaning |
|
|
80
|
+
|--------|---------|
|
|
81
|
+
| **Trust Score** (0–100) | Quantified trust level across 4 dimensions |
|
|
82
|
+
| **Decision** | `APPROVED` / `NEEDS_REVIEW` / `BLOCKED` |
|
|
83
|
+
| **Confidence** | `HIGH` / `MEDIUM` / `LOW` / `UNCERTAIN` |
|
|
84
|
+
| **Evidence** | Each violation traced to code location + RFC reference + fix suggestion |
|
|
360
85
|
|
|
361
|
-
|
|
86
|
+
**Critical violations → hard BLOCK regardless of score.** Enterprises care about "can I deploy?" not "is my score 58 or 61."
|
|
362
87
|
|
|
363
|
-
|
|
88
|
+
→ [Trust Decision Model](docs/ai-trust-decision-model-v1.md)
|
|
364
89
|
|
|
365
90
|
---
|
|
366
91
|
|
|
367
|
-
|
|
92
|
+
## Coverage
|
|
368
93
|
|
|
369
|
-
|
|
94
|
+
Progmune is honest about what it can and cannot verify.
|
|
370
95
|
|
|
371
|
-
|
|
96
|
+
| Language | Status | Evidence |
|
|
97
|
+
|----------|--------|----------|
|
|
98
|
+
| **TypeScript / JavaScript** | ✅ Production | Blind benchmark: P=86.8%, R=83.6%, F1=85.2% (432 sequences, 10 projects) |
|
|
99
|
+
| **C** | ⚠️ Research-only | Gold benchmark F1=16.5%. L3 cross-function experiment terminated; L4 not planned. See [C Language Status](docs/c-language-status.md). |
|
|
100
|
+
| **Python** | 🔨 IR only | IR extractor exists (`extract-ir-python.ts`), no verification rules yet |
|
|
101
|
+
| **Go, Java** | ❌ None | Planned |
|
|
372
102
|
|
|
373
|
-
|
|
374
|
-
[](https://modelcontextprotocol.io)
|
|
375
|
-
[]()
|
|
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.
|
|
103
|
+
**Framework adapters: 2/13.** Express ✅ and tRPC ✅ have dedicated detectors; Next.js has version-aware governance; NestJS is partial. Django, FastAPI and 8 more remain — framework adaptation is the #1 product gap.
|
|
390
104
|
|
|
391
|
-
|
|
105
|
+
### What Progmune does NOT cover (honest boundaries)
|
|
392
106
|
|
|
393
|
-
|
|
394
|
-
|
|
107
|
+
- **Taint-based injection flaws** — SQL injection, XSS, command injection. These require dataflow/taint tracking, which is deliberately out of scope in Phase 1 (adding it would make Progmune a generic SAST competitor; protocol-sequence verification is the differentiator).
|
|
108
|
+
- **SCA / dependency vulnerabilities** — hallucinated package names, supply-chain issues. Separate tooling exists for this.
|
|
109
|
+
- **Runtime behavior** — Progmune is static analysis only; no DAST/sandbox execution.
|
|
110
|
+
- **Obfuscated or dynamic code** — `eval`, `Function` constructor, and heavily obfuscated flows degrade regex/IR detection recall.
|
|
111
|
+
- **Known failure boundaries are documented** rather than hidden: if Progmune cannot verify a language (e.g. Go), Confidence is lowered instead of pretending 100%.
|
|
395
112
|
|
|
396
|
-
|
|
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.
|
|
113
|
+
→ [Full Coverage Matrix](docs/coverage-matrix.md)
|
|
401
114
|
|
|
402
115
|
---
|
|
403
116
|
|
|
404
|
-
##
|
|
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.
|
|
117
|
+
## Benchmarks
|
|
435
118
|
|
|
436
|
-
|
|
119
|
+
Public, reproducible precision data. All numbers measured against gold-annotated benchmarks.
|
|
437
120
|
|
|
438
|
-
|
|
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.
|
|
121
|
+
### TypeScript (Blind Benchmark v6)
|
|
441
122
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
123
|
+
| Metric | Value |
|
|
124
|
+
|--------|-------|
|
|
125
|
+
| Precision | 86.8% |
|
|
126
|
+
| Recall | 83.6% |
|
|
127
|
+
| F1 | 85.2% |
|
|
128
|
+
| Projects | 10 (ecommerce, blog, chat, crm, forum, wiki, issuetracker, filestorage, todo, scheduler) |
|
|
445
129
|
|
|
446
|
-
|
|
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.
|
|
130
|
+
### C (Gold Benchmark — research status)
|
|
449
131
|
|
|
450
|
-
|
|
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.
|
|
132
|
+
C analysis is **research-only**: gold benchmark F1=16.5% across 4 repos (curl, libssh, nginx, openssl). The bottleneck is rule coverage, not context. L3 (cross-function) was terminated with data; L4 (pointer/CFG) is a multi-year research problem and not planned. See [C Language Status](docs/c-language-status.md) for the full picture and reasoning.
|
|
453
133
|
|
|
454
|
-
|
|
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.
|
|
134
|
+
### P0-P3 Rule Injection (2026-08)
|
|
457
135
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
136
|
+
- **+19 new detections** across 10 TS projects, **0 false positives** across 6 C repos + PostgreSQL
|
|
137
|
+
- Bootstrapping deadlock broken: all 21 protocol namespaces now have rule vocabulary
|
|
138
|
+
- `excludePatterns` + `languages` architecture for FP management
|
|
461
139
|
|
|
462
|
-
|
|
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.
|
|
140
|
+
→ [Two-Hump Report](docs/two-hump-report.md) · [P0-P3 Final Report](docs/p0-p3-final-report.md)
|
|
465
141
|
|
|
466
142
|
---
|
|
467
143
|
|
|
468
|
-
##
|
|
469
|
-
|
|
470
|
-
We define the "health standards" for AI-generated code, providing a layered, quantifiable validation guarantee for the system:
|
|
471
|
-
|
|
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 |
|
|
479
|
-
|
|
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。
|
|
481
|
-
|
|
482
|
-
---
|
|
483
|
-
|
|
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)
|
|
144
|
+
## Architecture
|
|
489
145
|
|
|
490
|
-
### 1. Global Installation
|
|
491
|
-
|
|
492
|
-
```bash
|
|
493
|
-
npm install -g progmune-runtime
|
|
494
146
|
```
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
147
|
+
SDK (src/sdk.ts) verify() → APPROVED / NEEDS_REVIEW / BLOCKED
|
|
148
|
+
└─ Trust Engine 4-dimension scoring → Decision
|
|
149
|
+
├─ Policy Engine Enterprise policy enforcement (ALLOW/WARN/BLOCK)
|
|
150
|
+
├─ SSG Validator Protocol state machine verification
|
|
151
|
+
├─ Protocol Detector Regex-based protocol step detection (22 detectors)
|
|
152
|
+
├─ IR Extractor TypeScript AST → function IR (ts-morph)
|
|
153
|
+
├─ Repair Executor detect → plan → fix → validate → commit/rollback
|
|
154
|
+
└─ Knowledge Base 31 domains, 140 rules, evidence chains
|
|
502
155
|
```
|
|
503
|
-
*(Hint: You can also configure by setting the `OPENAI_API_KEY` environment variable)*
|
|
504
|
-
|
|
505
|
-
### 3. Extract Program Truth (IR)
|
|
506
156
|
|
|
507
|
-
|
|
157
|
+
### Interfaces
|
|
508
158
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
159
|
+
| Interface | Purpose |
|
|
160
|
+
|-----------|---------|
|
|
161
|
+
| **SDK** (`verify()`) | One-call API for developers |
|
|
162
|
+
| **CLI** (`npm run trust`) | Command-line trust checks |
|
|
163
|
+
| **MCP Server** | Claude Code integration (`progmune_check`, `progmune_trust_check`) |
|
|
164
|
+
| **GitHub Action** | CI/CD gate — blocks unverified AI code at PR |
|
|
165
|
+
| **Trust API** | `POST /trust/check` — machine-to-machine |
|
|
513
166
|
|
|
514
|
-
|
|
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:
|
|
167
|
+
---
|
|
517
168
|
|
|
518
|
-
|
|
519
|
-
npx progmune-runtime start
|
|
520
|
-
```
|
|
169
|
+
## Scientific Foundation
|
|
521
170
|
|
|
522
|
-
|
|
171
|
+
Progmune is built on the premise that **LLM outputs are statistical performances, not reasoning** — a view developed by Subbarao Kambhampati et al. in the position paper ["Stop Anthropomorphizing Intermediate Tokens as Reasoning/Thinking Traces!"](https://arxiv.org/abs/2505.22285) (arXiv:2505.22285, 2025) and elaborated in his ICML 2026 talk "On the Role of Verifiers and Thinking Traces in Reasoning Models". 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.
|
|
523
172
|
|
|
524
|
-
|
|
173
|
+
Coverage-gap analysis borrows the "two-hump problem" terminology **as a cross-domain analogy** from Sergei Gukov's work in mathematical physics (the Andrews-Curtis conjecture in group theory, 2026) — it describes a bimodal coverage distribution, not a collaboration. See [Two-Hump Report](docs/two-hump-report.md) for the full methodology.
|
|
525
174
|
|
|
526
|
-
|
|
527
|
-
npx progmune-runtime test
|
|
528
|
-
```
|
|
175
|
+
→ [Investor Whitepaper](docs/Progmune_投资人白皮书_v2.0.html) · [Trust Decision Model](docs/ai-trust-decision-model-v1.md)
|
|
529
176
|
|
|
530
177
|
---
|
|
531
178
|
|
|
532
|
-
##
|
|
179
|
+
## Contributing
|
|
533
180
|
|
|
534
|
-
|
|
181
|
+
See [CLAUDE.md](CLAUDE.md) for architecture and code conventions, and [CONTRIBUTING.md](CONTRIBUTING.md) for the development workflow.
|
|
535
182
|
|
|
536
|
-
|
|
183
|
+
High-impact contribution areas:
|
|
184
|
+
- **Framework adapters** (Express, Next.js, FastAPI) — the #1 product gap
|
|
185
|
+
- **Python verification rules** — extend beyond TypeScript
|
|
186
|
+
- **Bug fixes** for existing detectors and safeguards
|
|
537
187
|
|
|
538
188
|
---
|
|
539
189
|
|
|
540
|
-
##
|
|
190
|
+
## Status
|
|
541
191
|
|
|
542
|
-
|
|
192
|
+
- **Runtime Pipeline:** Detect → Explain → Repair → Validate (L1–L4)
|
|
193
|
+
- **Trust Engine:** 4-dimension scoring with binary explainability gate
|
|
194
|
+
- **MCP Tools:** 19 — `progmune_trust_check`, `progmune_score`, `progmune_policy_check`, `progmune_certify`, and more
|
|
195
|
+
- **Framework Adapters:** Express ✅, tRPC ✅, NestJS partial (2/13)
|
|
196
|
+
- **Knowledge Base:** 31 domains, 148 protocol rules, 22 detectors, 26 safeguards, PLSB 13/13 categories
|
|
197
|
+
- **Corpus:** 2,500+ trajectories across 6+ repositories
|
|
198
|
+
- **Current focus:** Framework adaptation + enterprise PoC validation
|
|
199
|
+
|
|
200
|
+
---
|
|
543
201
|
|
|
544
|
-
##
|
|
202
|
+
## License
|
|
545
203
|
|
|
546
|
-
|
|
204
|
+
MIT — [LICENSE](LICENSE)
|