progmune-runtime 2.1.6 → 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.
- package/README.md +108 -468
- 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 +710 -0
- package/package.json +74 -7
- 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
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Progmune V8 — Belief Layer
|
|
4
|
+
* ===========================
|
|
5
|
+
* Proof 回答 "能否从前提推导出来?" → 形式逻辑,无概率。
|
|
6
|
+
* Belief 回答 "我们有多相信它?" → 独立证据融合,有概率。
|
|
7
|
+
*
|
|
8
|
+
* 两者永远分离。
|
|
9
|
+
*
|
|
10
|
+
* Belief 来源(独立):
|
|
11
|
+
* 1. Derivation Depth — 推导链越深,信念越低(多步推导增加出错概率)
|
|
12
|
+
* 2. Refutation Status — 被反例驳倒 → 信念骤降
|
|
13
|
+
* 3. Git History — 代码变更频繁的区域,不变量可能已过时
|
|
14
|
+
* 4. Cross-domain Match — 同一模式在多个域中出现 → 更可信
|
|
15
|
+
* 5. Logic Type — FORBIDS(直接来自状态机声明)比 REQUIRES(推断的)更可靠
|
|
16
|
+
* 6. Human Label — 人工标注(未来)
|
|
17
|
+
*
|
|
18
|
+
* 组合方法: 每个来源独立给出 mass 分配,Dempster 规则融合。
|
|
19
|
+
* 没有预设权重。信任度从证据之间的互动中涌现。
|
|
20
|
+
*/
|
|
21
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
24
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
25
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
26
|
+
}
|
|
27
|
+
Object.defineProperty(o, k2, desc);
|
|
28
|
+
}) : (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
o[k2] = m[k];
|
|
31
|
+
}));
|
|
32
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
33
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
34
|
+
}) : function(o, v) {
|
|
35
|
+
o["default"] = v;
|
|
36
|
+
});
|
|
37
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
38
|
+
var ownKeys = function(o) {
|
|
39
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
40
|
+
var ar = [];
|
|
41
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
42
|
+
return ar;
|
|
43
|
+
};
|
|
44
|
+
return ownKeys(o);
|
|
45
|
+
};
|
|
46
|
+
return function (mod) {
|
|
47
|
+
if (mod && mod.__esModule) return mod;
|
|
48
|
+
var result = {};
|
|
49
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
50
|
+
__setModuleDefault(result, mod);
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
})();
|
|
54
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
+
exports.buildBeliefLayer = buildBeliefLayer;
|
|
56
|
+
const fs = __importStar(require("fs"));
|
|
57
|
+
const path = __importStar(require("path"));
|
|
58
|
+
const child_process_1 = require("child_process");
|
|
59
|
+
// ══════════════════════════════════════════════
|
|
60
|
+
// BELIEF SOURCES — each is independent
|
|
61
|
+
// ══════════════════════════════════════════════
|
|
62
|
+
/**
|
|
63
|
+
* Source 1: Derivation Depth
|
|
64
|
+
* 推导链越深,每一步都引入不确定性。OBSERVATION 直接来自代码 → 高信念。
|
|
65
|
+
* 传递闭包推导 → 中信念(两步推导)。
|
|
66
|
+
*/
|
|
67
|
+
function sourceDerivationDepth(inv) {
|
|
68
|
+
const depth = inv.derivationDepth || 1;
|
|
69
|
+
if (depth <= 1) {
|
|
70
|
+
return {
|
|
71
|
+
name: "derivation_depth",
|
|
72
|
+
massFor: 0.85,
|
|
73
|
+
massAgainst: 0.05,
|
|
74
|
+
massUncertain: 0.10,
|
|
75
|
+
reasoning: `推导深度=${depth}(直接来自代码)→ 高信念`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
else if (depth === 2) {
|
|
79
|
+
return {
|
|
80
|
+
name: "derivation_depth",
|
|
81
|
+
massFor: 0.60,
|
|
82
|
+
massAgainst: 0.15,
|
|
83
|
+
massUncertain: 0.25,
|
|
84
|
+
reasoning: `推导深度=${depth}(经过一次传递闭包)→ 中信念`,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
return {
|
|
89
|
+
name: "derivation_depth",
|
|
90
|
+
massFor: 0.40,
|
|
91
|
+
massAgainst: 0.25,
|
|
92
|
+
massUncertain: 0.35,
|
|
93
|
+
reasoning: `推导深度=${depth}(多步推导)→ 低信念`,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Source 2: Refutation Status
|
|
99
|
+
* 被 V6 BFS 反例驳倒 → 强反对。
|
|
100
|
+
* 未被驳倒但属于被驳倒的同一个域 → 轻微不确定。
|
|
101
|
+
*/
|
|
102
|
+
function sourceRefutation(inv) {
|
|
103
|
+
if (inv.isRefuted) {
|
|
104
|
+
return {
|
|
105
|
+
name: "refutation_status",
|
|
106
|
+
massFor: 0.0,
|
|
107
|
+
massAgainst: 0.98,
|
|
108
|
+
massUncertain: 0.02,
|
|
109
|
+
reasoning: "V6 BFS 找到了绕过此不变量的具体路径 → 反例是决定性证据",
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
name: "refutation_status",
|
|
114
|
+
massFor: 0.70,
|
|
115
|
+
massAgainst: 0.05,
|
|
116
|
+
massUncertain: 0.25,
|
|
117
|
+
reasoning: "V6 BFS 未找到反例 → 支持(但非穷举验证)",
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Source 3: Logic Type
|
|
122
|
+
* FORBIDS 直接来自状态机的 invalidTransitions → 最高信念。
|
|
123
|
+
* REQUIRES 是推断的 → 中信念。
|
|
124
|
+
* TERMINAL/UNIQUE/INITIAL 来自结构属性 → 中高信念。
|
|
125
|
+
*/
|
|
126
|
+
function sourceLogicType(inv) {
|
|
127
|
+
switch (inv.logicType) {
|
|
128
|
+
case "FORBIDS":
|
|
129
|
+
return {
|
|
130
|
+
name: "logic_type",
|
|
131
|
+
massFor: 0.90,
|
|
132
|
+
massAgainst: 0.02,
|
|
133
|
+
massUncertain: 0.08,
|
|
134
|
+
reasoning: "FORBIDS — 直接来自状态机声明的非法转移 → 极高信念",
|
|
135
|
+
};
|
|
136
|
+
case "TERMINAL":
|
|
137
|
+
case "INITIAL":
|
|
138
|
+
return {
|
|
139
|
+
name: "logic_type",
|
|
140
|
+
massFor: 0.80,
|
|
141
|
+
massAgainst: 0.05,
|
|
142
|
+
massUncertain: 0.15,
|
|
143
|
+
reasoning: `${inv.logicType} — 来自状态机结构属性 → 高信念`,
|
|
144
|
+
};
|
|
145
|
+
case "UNIQUE":
|
|
146
|
+
return {
|
|
147
|
+
name: "logic_type",
|
|
148
|
+
massFor: 0.70,
|
|
149
|
+
massAgainst: 0.10,
|
|
150
|
+
massUncertain: 0.20,
|
|
151
|
+
reasoning: "UNIQUE — 模板匹配,需领域确认 → 中高信念",
|
|
152
|
+
};
|
|
153
|
+
case "REQUIRES":
|
|
154
|
+
return {
|
|
155
|
+
name: "logic_type",
|
|
156
|
+
massFor: 0.50,
|
|
157
|
+
massAgainst: 0.20,
|
|
158
|
+
massUncertain: 0.30,
|
|
159
|
+
reasoning: "REQUIRES — 从转移边推断的先决关系,可能被捷径绕过 → 中信念",
|
|
160
|
+
};
|
|
161
|
+
default:
|
|
162
|
+
return {
|
|
163
|
+
name: "logic_type",
|
|
164
|
+
massFor: 0.40,
|
|
165
|
+
massAgainst: 0.20,
|
|
166
|
+
massUncertain: 0.40,
|
|
167
|
+
reasoning: "未知类型 → 高不确定性",
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Source 4: Git History Freshness
|
|
173
|
+
* 包含该不变量相关代码的文件最近被修改过 → 不变量可能过时。
|
|
174
|
+
* 使用真实的 git log 数据。
|
|
175
|
+
*/
|
|
176
|
+
function sourceGitHistory(inv, projectPath) {
|
|
177
|
+
const domain = (inv.domain || "").toLowerCase();
|
|
178
|
+
// Map domain to likely source files
|
|
179
|
+
const domainFiles = {
|
|
180
|
+
"order_suppliers": ["server/order-logistics-router.ts", "server/order-payment-router.ts", "drizzle/schema.ts"],
|
|
181
|
+
"share_links": ["server/share-db.ts", "server/share-router.ts"],
|
|
182
|
+
"points_log": ["server/db.ts", "drizzle/schema.ts"],
|
|
183
|
+
"notifications": ["server/notifications-db.ts", "server/notifications-router.ts"],
|
|
184
|
+
};
|
|
185
|
+
const files = domainFiles[domain] || [];
|
|
186
|
+
let daysSinceLastChange = 999;
|
|
187
|
+
try {
|
|
188
|
+
for (const file of files) {
|
|
189
|
+
const fullPath = path.join(projectPath, file);
|
|
190
|
+
if (fs.existsSync(fullPath)) {
|
|
191
|
+
const log = (0, child_process_1.execSync)(`git log -1 --format="%ct" -- "${file}"`, { cwd: projectPath, encoding: "utf-8", timeout: 5000 }).trim();
|
|
192
|
+
if (log) {
|
|
193
|
+
const lastChange = new Date(parseInt(log) * 1000);
|
|
194
|
+
const days = Math.floor((Date.now() - lastChange.getTime()) / (1000 * 60 * 60 * 24));
|
|
195
|
+
daysSinceLastChange = Math.min(daysSinceLastChange, days);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
// git not available
|
|
202
|
+
}
|
|
203
|
+
if (daysSinceLastChange <= 7) {
|
|
204
|
+
return {
|
|
205
|
+
name: "git_history",
|
|
206
|
+
massFor: 0.55,
|
|
207
|
+
massAgainst: 0.15,
|
|
208
|
+
massUncertain: 0.30,
|
|
209
|
+
reasoning: `相关文件 ${daysSinceLastChange} 天前修改 → 不变量可能仍准确,存在过时风险`,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
else if (daysSinceLastChange <= 30) {
|
|
213
|
+
return {
|
|
214
|
+
name: "git_history",
|
|
215
|
+
massFor: 0.70,
|
|
216
|
+
massAgainst: 0.05,
|
|
217
|
+
massUncertain: 0.25,
|
|
218
|
+
reasoning: `相关文件 ${daysSinceLastChange} 天前修改 → 不变量基本稳定`,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
else if (daysSinceLastChange < 900) {
|
|
222
|
+
return {
|
|
223
|
+
name: "git_history",
|
|
224
|
+
massFor: 0.80,
|
|
225
|
+
massAgainst: 0.03,
|
|
226
|
+
massUncertain: 0.17,
|
|
227
|
+
reasoning: `相关文件 ${daysSinceLastChange} 天前修改 → 不变量高度稳定`,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
return {
|
|
232
|
+
name: "git_history",
|
|
233
|
+
massFor: 0.50,
|
|
234
|
+
massAgainst: 0.05,
|
|
235
|
+
massUncertain: 0.45,
|
|
236
|
+
reasoning: "无 git 历史数据 → 高不确定性",
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Source 5: Cross-domain Pattern Match
|
|
242
|
+
* 同一条不变量模式在多个域中出现 → 更可信。
|
|
243
|
+
*/
|
|
244
|
+
function sourceCrossDomain(inv, allInvariants) {
|
|
245
|
+
const pred = (inv.predicate || "").toLowerCase();
|
|
246
|
+
// Extract the pattern: "shipped ⇒ pending" → pattern is "X ⇒ Y"
|
|
247
|
+
const pattern = pred.replace(/\w+/g, "X");
|
|
248
|
+
// Count how many other invariants share the same logic structure
|
|
249
|
+
const samePattern = allInvariants.filter((other) => {
|
|
250
|
+
if (other.id === inv.id)
|
|
251
|
+
return false;
|
|
252
|
+
const otherPred = (other.predicate || "").toLowerCase();
|
|
253
|
+
const otherPattern = otherPred.replace(/\w+/g, "X");
|
|
254
|
+
return otherPattern === pattern && other.domain !== inv.domain;
|
|
255
|
+
});
|
|
256
|
+
if (samePattern.length >= 3) {
|
|
257
|
+
return {
|
|
258
|
+
name: "cross_domain",
|
|
259
|
+
massFor: 0.75,
|
|
260
|
+
massAgainst: 0.05,
|
|
261
|
+
massUncertain: 0.20,
|
|
262
|
+
reasoning: `相同模式在 ${samePattern.length} 个其他域中出现 → 跨域一致性强`,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
else if (samePattern.length >= 1) {
|
|
266
|
+
return {
|
|
267
|
+
name: "cross_domain",
|
|
268
|
+
massFor: 0.60,
|
|
269
|
+
massAgainst: 0.10,
|
|
270
|
+
massUncertain: 0.30,
|
|
271
|
+
reasoning: `相同模式在 ${samePattern.length} 个其他域中出现 → 有一定跨域支持`,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
name: "cross_domain",
|
|
276
|
+
massFor: 0.45,
|
|
277
|
+
massAgainst: 0.10,
|
|
278
|
+
massUncertain: 0.45,
|
|
279
|
+
reasoning: "此模式仅在当前域出现 → 无法跨域验证",
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
// ══════════════════════════════════════════════
|
|
283
|
+
// DEMPSTER-SHAFER COMBINATION
|
|
284
|
+
// ══════════════════════════════════════════════
|
|
285
|
+
/**
|
|
286
|
+
* Combine two independent belief masses using Dempster's rule.
|
|
287
|
+
*
|
|
288
|
+
* Dempster combination:
|
|
289
|
+
* m₁₂(A) = (1 / (1 - K)) × Σ_{B∩C=A} m₁(B) × m₂(C)
|
|
290
|
+
* where K = Σ_{B∩C=∅} m₁(B) × m₂(C) (conflict mass)
|
|
291
|
+
*
|
|
292
|
+
* For our binary frame {FOR, AGAINST}:
|
|
293
|
+
* K = m₁(FOR)×m₂(AGAINST) + m₁(AGAINST)×m₂(FOR)
|
|
294
|
+
*
|
|
295
|
+
* m₁₂(FOR) = (m₁(FOR)×m₂(FOR) + m₁(FOR)×m₂(UNCERTAIN) + m₁(UNCERTAIN)×m₂(FOR)) / (1-K)
|
|
296
|
+
* m₁₂(AGAINST) = (m₁(AGAINST)×m₂(AGAINST) + m₁(AGAINST)×m₂(UNCERTAIN) + m₁(UNCERTAIN)×m₂(AGAINST)) / (1-K)
|
|
297
|
+
* m₁₂(UNCERTAIN) = (m₁(UNCERTAIN)×m₂(UNCERTAIN)) / (1-K)
|
|
298
|
+
*/
|
|
299
|
+
function dempsterCombine(sources) {
|
|
300
|
+
if (sources.length === 0) {
|
|
301
|
+
return { beliefFor: 0, beliefAgainst: 0, uncertainty: 1.0 };
|
|
302
|
+
}
|
|
303
|
+
// Start with the first source
|
|
304
|
+
let mFor = sources[0].massFor;
|
|
305
|
+
let mAgainst = sources[0].massAgainst;
|
|
306
|
+
let mUncertain = sources[0].massUncertain;
|
|
307
|
+
// Combine with each subsequent source
|
|
308
|
+
for (let i = 1; i < sources.length; i++) {
|
|
309
|
+
const s = sources[i];
|
|
310
|
+
// Conflict mass K
|
|
311
|
+
const K = mFor * s.massAgainst + mAgainst * s.massFor;
|
|
312
|
+
if (K >= 1.0) {
|
|
313
|
+
// Total conflict — sources completely disagree
|
|
314
|
+
// Fall back to averaging (DS breaks down under total conflict)
|
|
315
|
+
mFor = (mFor + s.massFor) / 2;
|
|
316
|
+
mAgainst = (mAgainst + s.massAgainst) / 2;
|
|
317
|
+
mUncertain = (mUncertain + s.massUncertain) / 2;
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
// Dempster combination
|
|
321
|
+
const norm = 1.0 / (1.0 - K);
|
|
322
|
+
mFor = (mFor * s.massFor + mFor * s.massUncertain + mUncertain * s.massFor) * norm;
|
|
323
|
+
mAgainst = (mAgainst * s.massAgainst + mAgainst * s.massUncertain + mUncertain * s.massAgainst) * norm;
|
|
324
|
+
mUncertain = (mUncertain * s.massUncertain) * norm;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
// Clamp to [0, 1]
|
|
328
|
+
return {
|
|
329
|
+
beliefFor: Math.max(0, Math.min(1, mFor)),
|
|
330
|
+
beliefAgainst: Math.max(0, Math.min(1, mAgainst)),
|
|
331
|
+
uncertainty: Math.max(0, Math.min(1, mUncertain)),
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
// ══════════════════════════════════════════════
|
|
335
|
+
// MAIN
|
|
336
|
+
// ══════════════════════════════════════════════
|
|
337
|
+
function buildBeliefLayer(projectPath) {
|
|
338
|
+
console.log("🔬 Progmune Belief Layer — V8");
|
|
339
|
+
console.log(" Project:", projectPath);
|
|
340
|
+
const provenancePath = path.join(projectPath, ".progmune_provenance.json");
|
|
341
|
+
if (!fs.existsSync(provenancePath)) {
|
|
342
|
+
console.log(" Run V7 first: npx ts-node src/proof-provenance.ts");
|
|
343
|
+
return { timestamp: new Date().toISOString(), assessments: [], summary: { total: 0, highBelief: 0, mediumBelief: 0, lowBelief: 0, refuted: 0, averageBelief: 0 } };
|
|
344
|
+
}
|
|
345
|
+
const v7 = JSON.parse(fs.readFileSync(provenancePath, "utf-8"));
|
|
346
|
+
const allInvariants = v7.invariants || [];
|
|
347
|
+
console.log(` Loaded ${allInvariants.length} provenanced invariants from V7`);
|
|
348
|
+
const assessments = [];
|
|
349
|
+
for (const inv of allInvariants) {
|
|
350
|
+
// Gather all independent belief sources
|
|
351
|
+
const sources = [
|
|
352
|
+
sourceDerivationDepth(inv),
|
|
353
|
+
sourceRefutation(inv),
|
|
354
|
+
sourceLogicType(inv),
|
|
355
|
+
sourceGitHistory(inv, projectPath),
|
|
356
|
+
sourceCrossDomain(inv, allInvariants),
|
|
357
|
+
];
|
|
358
|
+
// Dempster combination
|
|
359
|
+
let { beliefFor, beliefAgainst, uncertainty } = dempsterCombine(sources);
|
|
360
|
+
// Post-processing: refutation is definitive. If V6 found a concrete
|
|
361
|
+
// counterexample, the invariant is falsified regardless of other sources.
|
|
362
|
+
// Cross-domain pattern may still be valid, but THIS specific invariant is wrong.
|
|
363
|
+
if (inv.isRefuted) {
|
|
364
|
+
beliefFor = Math.min(beliefFor, 0.15); // Pin to ≤15%
|
|
365
|
+
beliefAgainst = Math.max(beliefAgainst, 0.80);
|
|
366
|
+
}
|
|
367
|
+
// Determine belief level
|
|
368
|
+
let beliefLevel;
|
|
369
|
+
if (inv.isRefuted) {
|
|
370
|
+
beliefLevel = "REFUTED";
|
|
371
|
+
}
|
|
372
|
+
else if (beliefFor >= 0.75) {
|
|
373
|
+
beliefLevel = "HIGH";
|
|
374
|
+
}
|
|
375
|
+
else if (beliefFor >= 0.50) {
|
|
376
|
+
beliefLevel = "MEDIUM";
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
beliefLevel = "LOW";
|
|
380
|
+
}
|
|
381
|
+
// Generate explanation
|
|
382
|
+
const explanationParts = [];
|
|
383
|
+
if (inv.isRefuted) {
|
|
384
|
+
explanationParts.push(`REFUTED by V6: ${inv.counterexampleExplanation || "counterexample found"}`);
|
|
385
|
+
}
|
|
386
|
+
if (beliefLevel === "HIGH") {
|
|
387
|
+
explanationParts.push("多个独立证据源一致支持 → 高信念");
|
|
388
|
+
}
|
|
389
|
+
else if (beliefLevel === "MEDIUM") {
|
|
390
|
+
const conflicts = sources.filter(s => s.massAgainst > 0.15);
|
|
391
|
+
if (conflicts.length > 0) {
|
|
392
|
+
explanationParts.push(`证据部分冲突: ${conflicts.map(s => s.name).join(", ")} → 中信念`);
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
explanationParts.push("证据支持但不确定性较高 → 中信念");
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
else if (beliefLevel === "LOW") {
|
|
399
|
+
explanationParts.push("证据弱或不一致 → 低信念,建议人工确认");
|
|
400
|
+
}
|
|
401
|
+
assessments.push({
|
|
402
|
+
invariantId: inv.id,
|
|
403
|
+
predicate: inv.predicate,
|
|
404
|
+
domain: inv.domain,
|
|
405
|
+
logicType: inv.logicType,
|
|
406
|
+
isRefuted: inv.isRefuted || false,
|
|
407
|
+
sources,
|
|
408
|
+
combinedBelief: Math.round(beliefFor * 100),
|
|
409
|
+
combinedDisbelief: Math.round(beliefAgainst * 100),
|
|
410
|
+
combinedUncertainty: Math.round(uncertainty * 100),
|
|
411
|
+
beliefLevel,
|
|
412
|
+
explanation: explanationParts.join("; "),
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
// Compute summary
|
|
416
|
+
const highBelief = assessments.filter(a => a.beliefLevel === "HIGH").length;
|
|
417
|
+
const mediumBelief = assessments.filter(a => a.beliefLevel === "MEDIUM").length;
|
|
418
|
+
const lowBelief = assessments.filter(a => a.beliefLevel === "LOW").length;
|
|
419
|
+
const refuted = assessments.filter(a => a.beliefLevel === "REFUTED").length;
|
|
420
|
+
const avgBelief = Math.round(assessments.reduce((s, a) => s + a.combinedBelief, 0) / assessments.length);
|
|
421
|
+
// Print details
|
|
422
|
+
console.log(`\n Belief Distribution:`);
|
|
423
|
+
console.log(` HIGH: ${highBelief} invariants (≥75% belief)`);
|
|
424
|
+
console.log(` MEDIUM: ${mediumBelief} invariants (50-74%)`);
|
|
425
|
+
console.log(` LOW: ${lowBelief} invariants (<50%)`);
|
|
426
|
+
console.log(` REFUTED: ${refuted} invariants`);
|
|
427
|
+
// Show the most interesting cases
|
|
428
|
+
console.log("\n ── REFUTED invariants (belief collapsed) ──");
|
|
429
|
+
for (const a of assessments.filter(a => a.beliefLevel === "REFUTED")) {
|
|
430
|
+
console.log(` ❌ ${a.predicate}`);
|
|
431
|
+
console.log(` Belief: ${a.combinedBelief}% | Disbelief: ${a.combinedDisbelief}% | Uncertainty: ${a.combinedUncertainty}%`);
|
|
432
|
+
console.log(` ${a.explanation}`);
|
|
433
|
+
for (const s of a.sources) {
|
|
434
|
+
console.log(` ${s.name}: FOR=${(s.massFor * 100).toFixed(0)}% AGAINST=${(s.massAgainst * 100).toFixed(0)}% UNCERTAIN=${(s.massUncertain * 100).toFixed(0)}% — ${s.reasoning}`);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
console.log("\n ── HIGH belief invariants (strong consensus) ──");
|
|
438
|
+
for (const a of assessments.filter(a => a.beliefLevel === "HIGH").slice(0, 3)) {
|
|
439
|
+
console.log(` ✅ ${a.predicate} [${a.combinedBelief}% belief, ${a.combinedUncertainty}% uncertainty]`);
|
|
440
|
+
console.log(` ${a.explanation}`);
|
|
441
|
+
}
|
|
442
|
+
console.log("\n ── LOW belief invariants (needs human review) ──");
|
|
443
|
+
for (const a of assessments.filter(a => a.beliefLevel === "LOW").slice(0, 3)) {
|
|
444
|
+
console.log(` ⚠️ ${a.predicate} [${a.combinedBelief}% belief, ${a.combinedUncertainty}% uncertainty]`);
|
|
445
|
+
console.log(` ${a.explanation}`);
|
|
446
|
+
}
|
|
447
|
+
const report = {
|
|
448
|
+
timestamp: new Date().toISOString(),
|
|
449
|
+
assessments,
|
|
450
|
+
summary: { total: assessments.length, highBelief, mediumBelief, lowBelief, refuted, averageBelief: avgBelief },
|
|
451
|
+
};
|
|
452
|
+
return report;
|
|
453
|
+
}
|
|
454
|
+
// ══════════════════════════════════════════════
|
|
455
|
+
// CLI
|
|
456
|
+
// ══════════════════════════════════════════════
|
|
457
|
+
if (require.main === module) {
|
|
458
|
+
const targetProject = process.argv[2];
|
|
459
|
+
if (!targetProject) {
|
|
460
|
+
console.error("Usage: npx ts-node src/belief-layer.ts <project-path>");
|
|
461
|
+
process.exit(1);
|
|
462
|
+
}
|
|
463
|
+
const report = buildBeliefLayer(targetProject);
|
|
464
|
+
const outputPath = path.join(targetProject, ".progmune_belief.json");
|
|
465
|
+
fs.writeFileSync(outputPath, JSON.stringify(report, null, 2));
|
|
466
|
+
console.log(`\n✅ Belief report saved to: ${outputPath}`);
|
|
467
|
+
console.log("\n═══ Belief Layer Summary ═══");
|
|
468
|
+
console.log(` Total: ${report.summary.total}`);
|
|
469
|
+
console.log(` HIGH belief: ${report.summary.highBelief}`);
|
|
470
|
+
console.log(` MEDIUM belief: ${report.summary.mediumBelief}`);
|
|
471
|
+
console.log(` LOW belief: ${report.summary.lowBelief}`);
|
|
472
|
+
console.log(` REFUTED: ${report.summary.refuted}`);
|
|
473
|
+
console.log(` Average belief: ${report.summary.averageBelief}%`);
|
|
474
|
+
console.log();
|
|
475
|
+
}
|
package/dist/benchmark-count.js
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.benchmarkCount = benchmarkCount;
|
|
4
4
|
const load_benchmarks_1 = require("./load-benchmarks");
|
|
5
|
+
/**
|
|
6
|
+
* @requires BENCHMARK_TASKS @produces TASK_COUNT
|
|
7
|
+
* @purpose Count benchmark tasks available
|
|
8
|
+
* @tags benchmark, count, statistics
|
|
9
|
+
*/
|
|
5
10
|
function benchmarkCount() {
|
|
6
11
|
return (0, load_benchmarks_1.loadBenchmarks)().length;
|
|
7
12
|
}
|