progmune-runtime 2.0.2 → 2.1.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/.mcp.json +11 -0
- package/.progmune_allowlist +50 -0
- package/.test_report/test_report.md +87 -0
- package/Dockerfile +2 -10
- package/FAQ.md +167 -0
- package/demo-project/auth.ts +55 -0
- package/demo-project/tsconfig.json +8 -0
- package/dist/ab-stats.js +11 -0
- package/dist/acl-breakdown.js +13 -0
- package/dist/all-sessions.js +11 -0
- package/dist/antibody-stats.js +11 -0
- package/dist/audit.js +218 -0
- package/dist/benchmark-count.js +7 -0
- package/dist/benchmark-full.js +17 -0
- package/dist/benchmark-pass-rate.js +54 -0
- package/dist/benchmark-report.js +67 -0
- package/dist/benchmark-save.js +62 -0
- package/dist/benchmark-status.js +15 -0
- package/dist/branch-ledger.js +365 -0
- package/dist/branch-tree-count.js +14 -0
- package/dist/check.js +506 -0
- package/dist/common-fixpath.js +12 -0
- package/dist/constraint-types.js +12 -0
- package/dist/deterministic-replay.js +277 -0
- package/dist/emitter.js +112 -12
- package/dist/exec-metrics.js +11 -0
- package/dist/execute.js +242 -0
- package/dist/extract-ir.js +550 -5
- package/dist/failure-collector.js +143 -0
- package/dist/failure-corpus.js +481 -35
- package/dist/failure-report.js +11 -0
- package/dist/failures.js +11 -0
- package/dist/fast-path-hits.js +13 -0
- package/dist/feedback.js +6 -3
- package/dist/file-lock.js +82 -0
- package/dist/find-session.js +10 -0
- package/dist/fingerprint-list.js +15 -0
- package/dist/gen-history-log.js +13 -0
- package/dist/generate.js +2 -1
- package/dist/generate_500.js +4 -2
- package/dist/genome.js +11 -0
- package/dist/heatmap-data.js +11 -0
- package/dist/heatmap.js +11 -0
- package/dist/immune-reporter.js +137 -0
- package/dist/learned.js +11 -0
- package/dist/ledger-registry.js +241 -0
- package/dist/llm.js +43 -2
- package/dist/load-benchmarks.js +47 -0
- package/dist/main.js +2 -1
- package/dist/mcp-server.mjs +446 -34
- package/dist/memory-layer.js +51 -13
- package/dist/metrics.js +11 -0
- package/dist/obs-web.js +561 -0
- package/dist/p0_ssg_demo.js +255 -40
- package/dist/planner.js +933 -65
- package/dist/protocol-registry.js +105 -0
- package/dist/recent-session.js +12 -0
- package/dist/repair-proposal.js +353 -0
- package/dist/report.js +32 -0
- package/dist/runtime-invariants.js +161 -0
- package/dist/runtime-types.js +117 -0
- package/dist/search-planner.js +38 -9
- package/dist/semantic-snapshot.js +155 -0
- package/dist/semantic-trace.js +1497 -0
- package/dist/semantic-validator.js +3 -2
- package/dist/semantic_guard_test.js +2 -1
- package/dist/sessions.js +11 -0
- package/dist/ssg-validator.js +658 -20
- package/dist/svl-distribution.js +11 -0
- package/dist/terminal-status.js +11 -0
- package/dist/test_failure_corpus.js +3 -1
- package/dist/token-savings.js +11 -0
- package/dist/total-repairs.js +12 -0
- package/dist/unresolved-count.js +12 -0
- package/dist/valid-fingerprints.js +13 -0
- package/dist/validator.js +116 -60
- package/dist/verify-fps.js +11 -0
- package/dist/verify-ledgers.js +11 -0
- package/docs/whitepaper-style.css +77 -0
- package/docs/whitepaper-v2.1.md +609 -0
- package/docs/whitepaper-v2.2.md +1064 -0
- package/docs/whitepaper-v2.2.pdf +0 -0
- package/fly.toml +1 -1
- package/package.json +13 -4
- package/protocols.json +136 -0
- package/public/dashboard.html +119 -0
- package/readme.md +829 -0
- package/server/hub.js +84 -12
- package/test/replay-golden/sess_1780063202050_mgeld.json +9 -0
- package/test/replay-golden/sess_1780064032560_gocld.json +354 -0
- package/test/replay-golden/sess_1780064413331_s2709.json +606 -0
- package/test/replay-golden/sess_1780064792710_y3avo.json +614 -0
- package/test/replay-golden.ts +84 -0
- package/test_benchmark.js +165 -0
- package/test_comprehensive.mjs +638 -0
- package/test_concurrency.js +129 -0
- package/test_ir_robustness.js +85 -0
- package/test_semantic_contracts.js +269 -0
- package/test_ssg_stress.js +156 -0
- package/test_svl3.js +58 -0
- package/tsconfig.json +1 -1
- package/.env.example +0 -3
- package/.progmune_memory/fingerprints.json +0 -7
- package/.progmune_memory/opt_in.json +0 -4
- package/README.md +0 -118
- package/dist/mcp-server.js +0 -55
- package/immune_hub_data/2026-05-14.json +0 -50
package/dist/memory-layer.js
CHANGED
|
@@ -41,7 +41,17 @@ exports.consolidateSemantic = consolidateSemantic;
|
|
|
41
41
|
exports.findSemanticTemplate = findSemanticTemplate;
|
|
42
42
|
const fs = __importStar(require("fs"));
|
|
43
43
|
const path = __importStar(require("path"));
|
|
44
|
-
const
|
|
44
|
+
const file_lock_1 = require("./file-lock");
|
|
45
|
+
// 基于项目路径的隔离记忆目录,可通过环境变量 PROGMUNE_MEMORY_DIR 自定义
|
|
46
|
+
// 优先使用 PROGMUNE_PROJECT_DIR(由 MCP 服务器在调用时设置),确保多项目隔离
|
|
47
|
+
const projectDir = process.env.PROGMUNE_PROJECT_DIR || process.cwd();
|
|
48
|
+
const MEMORY_DIR = process.env.PROGMUNE_MEMORY_DIR
|
|
49
|
+
|| path.resolve(projectDir, ".progmune_memory");
|
|
50
|
+
function ensureDir(dir) {
|
|
51
|
+
if (!fs.existsSync(dir))
|
|
52
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
53
|
+
}
|
|
54
|
+
// ========== 工作记忆 ==========
|
|
45
55
|
class WorkMemory {
|
|
46
56
|
constructor() {
|
|
47
57
|
this.bindings = new Map();
|
|
@@ -56,19 +66,30 @@ class WorkMemory {
|
|
|
56
66
|
exports.WorkMemory = WorkMemory;
|
|
57
67
|
const EPISODIC_FILE = path.join(MEMORY_DIR, "episodic.json");
|
|
58
68
|
const MAX_EPISODES = 50;
|
|
59
|
-
|
|
60
|
-
if (!fs.existsSync(dir))
|
|
61
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
62
|
-
}
|
|
69
|
+
const EPISODE_TTL_MS = 7 * 24 * 60 * 60 * 1000; // 7 天
|
|
63
70
|
function loadEpisodes() {
|
|
64
71
|
ensureDir(MEMORY_DIR);
|
|
65
72
|
if (!fs.existsSync(EPISODIC_FILE))
|
|
66
73
|
return [];
|
|
67
|
-
|
|
74
|
+
const all = JSON.parse(fs.readFileSync(EPISODIC_FILE, "utf-8"));
|
|
75
|
+
const cutoff = Date.now() - EPISODE_TTL_MS;
|
|
76
|
+
const fresh = all.filter(e => new Date(e.timestamp).getTime() > cutoff);
|
|
77
|
+
if (fresh.length < all.length) {
|
|
78
|
+
console.error(`[记忆衰减-读取] 过滤了 ${all.length - fresh.length} 条过期情景记忆`);
|
|
79
|
+
fs.writeFileSync(EPISODIC_FILE, JSON.stringify(fresh, null, 2));
|
|
80
|
+
}
|
|
81
|
+
return fresh;
|
|
68
82
|
}
|
|
69
83
|
function saveEpisodes(episodes) {
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
(0, file_lock_1.withLock)("episodic.json", () => {
|
|
85
|
+
ensureDir(MEMORY_DIR);
|
|
86
|
+
const cutoff = Date.now() - EPISODE_TTL_MS;
|
|
87
|
+
const fresh = episodes.filter(e => new Date(e.timestamp).getTime() > cutoff);
|
|
88
|
+
if (fresh.length !== episodes.length) {
|
|
89
|
+
console.error(`[记忆衰减-写入] 清理了 ${episodes.length - fresh.length} 条过期情景记忆`);
|
|
90
|
+
}
|
|
91
|
+
fs.writeFileSync(EPISODIC_FILE, JSON.stringify(fresh.slice(0, MAX_EPISODES), null, 2));
|
|
92
|
+
});
|
|
72
93
|
}
|
|
73
94
|
function recordEpisode(episode) {
|
|
74
95
|
const episodes = loadEpisodes();
|
|
@@ -78,8 +99,9 @@ function recordEpisode(episode) {
|
|
|
78
99
|
timestamp: new Date().toISOString(),
|
|
79
100
|
};
|
|
80
101
|
episodes.unshift(newEpisode);
|
|
81
|
-
if (episodes.length > MAX_EPISODES)
|
|
102
|
+
if (episodes.length > MAX_EPISODES) {
|
|
82
103
|
episodes.length = MAX_EPISODES;
|
|
104
|
+
}
|
|
83
105
|
saveEpisodes(episodes);
|
|
84
106
|
}
|
|
85
107
|
function getRecentEpisodes(limit = 10) {
|
|
@@ -89,15 +111,31 @@ function getSuccessfulEpisodes(limit = 10) {
|
|
|
89
111
|
return loadEpisodes().filter(e => e.success).slice(0, limit);
|
|
90
112
|
}
|
|
91
113
|
const SEMANTIC_FILE = path.join(MEMORY_DIR, "semantic.json");
|
|
114
|
+
const SEMANTIC_TTL_MS = 30 * 24 * 60 * 60 * 1000; // 30 天
|
|
92
115
|
function loadSemantic() {
|
|
93
116
|
ensureDir(MEMORY_DIR);
|
|
94
117
|
if (!fs.existsSync(SEMANTIC_FILE))
|
|
95
118
|
return [];
|
|
96
|
-
|
|
119
|
+
const all = JSON.parse(fs.readFileSync(SEMANTIC_FILE, "utf-8"));
|
|
120
|
+
const cutoff = Date.now() - SEMANTIC_TTL_MS;
|
|
121
|
+
const fresh = all.filter(t => new Date(t.lastUsedAt).getTime() > cutoff);
|
|
122
|
+
if (fresh.length < all.length) {
|
|
123
|
+
console.error(`[记忆衰减-读取] 清理了 ${all.length - fresh.length} 个过期语义模板`);
|
|
124
|
+
fs.writeFileSync(SEMANTIC_FILE, JSON.stringify(fresh, null, 2));
|
|
125
|
+
}
|
|
126
|
+
return fresh;
|
|
97
127
|
}
|
|
98
128
|
function saveSemantic(templates) {
|
|
99
|
-
|
|
100
|
-
|
|
129
|
+
(0, file_lock_1.withLock)("semantic.json", () => {
|
|
130
|
+
ensureDir(MEMORY_DIR);
|
|
131
|
+
// TTL 衰减:清理超过 30 天未使用的语义模板
|
|
132
|
+
const cutoff = Date.now() - SEMANTIC_TTL_MS;
|
|
133
|
+
const fresh = templates.filter(t => new Date(t.lastUsedAt).getTime() > cutoff);
|
|
134
|
+
if (fresh.length !== templates.length) {
|
|
135
|
+
console.error(`[记忆衰减] 清理了 ${templates.length - fresh.length} 个过期语义模板`);
|
|
136
|
+
}
|
|
137
|
+
fs.writeFileSync(SEMANTIC_FILE, JSON.stringify(fresh, null, 2));
|
|
138
|
+
});
|
|
101
139
|
}
|
|
102
140
|
function consolidateSemantic(minOccurrences = 3) {
|
|
103
141
|
const episodes = getSuccessfulEpisodes(MAX_EPISODES);
|
|
@@ -132,7 +170,7 @@ function consolidateSemantic(minOccurrences = 3) {
|
|
|
132
170
|
}
|
|
133
171
|
}
|
|
134
172
|
saveSemantic(templates);
|
|
135
|
-
console.
|
|
173
|
+
console.error(`[语义记忆] 巩固完成,模板数量: ${templates.length}`);
|
|
136
174
|
}
|
|
137
175
|
function findSemanticTemplate(intent) {
|
|
138
176
|
const templates = loadSemantic();
|
package/dist/metrics.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.main = main;
|
|
4
|
+
// @progmune-generated session=sess_1780345721473_u5ik3 timestamp=2026-06-01T20:28:42.736Z ruleHash=9dec68bc2995e92a
|
|
5
|
+
// Generated with IR constraint: 387 functions, 17 protocol rules
|
|
6
|
+
const execute_1 = require("./execute");
|
|
7
|
+
function main() {
|
|
8
|
+
const metrics = (0, execute_1.getExecutionMetrics)();
|
|
9
|
+
return metrics;
|
|
10
|
+
}
|
|
11
|
+
main();
|