progmune-runtime 2.0.4 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.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/README.md +108 -54
- 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/action-runtime.js +1 -0
- package/dist/all-sessions.js +11 -0
- package/dist/antibody-stats.js +11 -0
- package/dist/audit.js +222 -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 +393 -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 +283 -0
- package/dist/emitter.js +143 -12
- package/dist/exec-metrics.js +11 -0
- package/dist/execute.js +251 -0
- package/dist/extract-ir.js +592 -5
- package/dist/failure-collector.js +163 -0
- package/dist/failure-corpus.js +507 -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 +10 -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 +34 -22
- package/dist/ir-utils.js +18 -0
- package/dist/learned.js +11 -0
- package/dist/ledger-registry.js +252 -0
- package/dist/llm.js +46 -2
- package/dist/load-benchmarks.js +47 -0
- package/dist/main.js +2 -1
- package/dist/mcp-server.mjs +445 -43
- package/dist/memory-layer.js +54 -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 +996 -80
- package/dist/protocol-registry.js +112 -0
- package/dist/recent-session.js +12 -0
- package/dist/repair-proposal.js +363 -0
- package/dist/runtime-invariants.js +170 -0
- package/dist/runtime-types.js +117 -0
- package/dist/runtime.js +1 -0
- package/dist/search-planner.js +39 -9
- package/dist/semantic-snapshot.js +157 -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/session-utils.js +19 -0
- package/dist/sessions.js +11 -0
- package/dist/ssg-validator.js +666 -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/utils.js +2 -0
- package/dist/valid-fingerprints.js +13 -0
- package/dist/validator.js +118 -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 +131 -11
- package/public/dashboard.html +119 -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/episodic.json +0 -186
- package/.progmune_memory/fingerprints.json +0 -7
- package/.progmune_memory/opt_in.json +0 -4
- 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,20 +66,32 @@ 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
|
}
|
|
94
|
+
/** @requires EXECUTION_DATA @produces MEMORY_ID */
|
|
73
95
|
function recordEpisode(episode) {
|
|
74
96
|
const episodes = loadEpisodes();
|
|
75
97
|
const newEpisode = {
|
|
@@ -78,10 +100,12 @@ function recordEpisode(episode) {
|
|
|
78
100
|
timestamp: new Date().toISOString(),
|
|
79
101
|
};
|
|
80
102
|
episodes.unshift(newEpisode);
|
|
81
|
-
if (episodes.length > MAX_EPISODES)
|
|
103
|
+
if (episodes.length > MAX_EPISODES) {
|
|
82
104
|
episodes.length = MAX_EPISODES;
|
|
105
|
+
}
|
|
83
106
|
saveEpisodes(episodes);
|
|
84
107
|
}
|
|
108
|
+
/** @requires LIMIT @produces EPISODE_LIST */
|
|
85
109
|
function getRecentEpisodes(limit = 10) {
|
|
86
110
|
return loadEpisodes().slice(0, limit);
|
|
87
111
|
}
|
|
@@ -89,15 +113,31 @@ function getSuccessfulEpisodes(limit = 10) {
|
|
|
89
113
|
return loadEpisodes().filter(e => e.success).slice(0, limit);
|
|
90
114
|
}
|
|
91
115
|
const SEMANTIC_FILE = path.join(MEMORY_DIR, "semantic.json");
|
|
116
|
+
const SEMANTIC_TTL_MS = 30 * 24 * 60 * 60 * 1000; // 30 天
|
|
92
117
|
function loadSemantic() {
|
|
93
118
|
ensureDir(MEMORY_DIR);
|
|
94
119
|
if (!fs.existsSync(SEMANTIC_FILE))
|
|
95
120
|
return [];
|
|
96
|
-
|
|
121
|
+
const all = JSON.parse(fs.readFileSync(SEMANTIC_FILE, "utf-8"));
|
|
122
|
+
const cutoff = Date.now() - SEMANTIC_TTL_MS;
|
|
123
|
+
const fresh = all.filter(t => new Date(t.lastUsedAt).getTime() > cutoff);
|
|
124
|
+
if (fresh.length < all.length) {
|
|
125
|
+
console.error(`[记忆衰减-读取] 清理了 ${all.length - fresh.length} 个过期语义模板`);
|
|
126
|
+
fs.writeFileSync(SEMANTIC_FILE, JSON.stringify(fresh, null, 2));
|
|
127
|
+
}
|
|
128
|
+
return fresh;
|
|
97
129
|
}
|
|
98
130
|
function saveSemantic(templates) {
|
|
99
|
-
|
|
100
|
-
|
|
131
|
+
(0, file_lock_1.withLock)("semantic.json", () => {
|
|
132
|
+
ensureDir(MEMORY_DIR);
|
|
133
|
+
// TTL 衰减:清理超过 30 天未使用的语义模板
|
|
134
|
+
const cutoff = Date.now() - SEMANTIC_TTL_MS;
|
|
135
|
+
const fresh = templates.filter(t => new Date(t.lastUsedAt).getTime() > cutoff);
|
|
136
|
+
if (fresh.length !== templates.length) {
|
|
137
|
+
console.error(`[记忆衰减] 清理了 ${templates.length - fresh.length} 个过期语义模板`);
|
|
138
|
+
}
|
|
139
|
+
fs.writeFileSync(SEMANTIC_FILE, JSON.stringify(fresh, null, 2));
|
|
140
|
+
});
|
|
101
141
|
}
|
|
102
142
|
function consolidateSemantic(minOccurrences = 3) {
|
|
103
143
|
const episodes = getSuccessfulEpisodes(MAX_EPISODES);
|
|
@@ -132,8 +172,9 @@ function consolidateSemantic(minOccurrences = 3) {
|
|
|
132
172
|
}
|
|
133
173
|
}
|
|
134
174
|
saveSemantic(templates);
|
|
135
|
-
console.
|
|
175
|
+
console.error(`[语义记忆] 巩固完成,模板数量: ${templates.length}`);
|
|
136
176
|
}
|
|
177
|
+
/** @requires INTENT @produces TEMPLATE */
|
|
137
178
|
function findSemanticTemplate(intent) {
|
|
138
179
|
const templates = loadSemantic();
|
|
139
180
|
if (templates.length === 0)
|
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();
|