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.
Files changed (110) hide show
  1. package/.mcp.json +11 -0
  2. package/.progmune_allowlist +50 -0
  3. package/.test_report/test_report.md +87 -0
  4. package/Dockerfile +2 -10
  5. package/FAQ.md +167 -0
  6. package/README.md +108 -54
  7. package/demo-project/auth.ts +55 -0
  8. package/demo-project/tsconfig.json +8 -0
  9. package/dist/ab-stats.js +11 -0
  10. package/dist/acl-breakdown.js +13 -0
  11. package/dist/action-runtime.js +1 -0
  12. package/dist/all-sessions.js +11 -0
  13. package/dist/antibody-stats.js +11 -0
  14. package/dist/audit.js +222 -0
  15. package/dist/benchmark-count.js +7 -0
  16. package/dist/benchmark-full.js +17 -0
  17. package/dist/benchmark-pass-rate.js +54 -0
  18. package/dist/benchmark-report.js +67 -0
  19. package/dist/benchmark-save.js +62 -0
  20. package/dist/benchmark-status.js +15 -0
  21. package/dist/branch-ledger.js +393 -0
  22. package/dist/branch-tree-count.js +14 -0
  23. package/dist/check.js +506 -0
  24. package/dist/common-fixpath.js +12 -0
  25. package/dist/constraint-types.js +12 -0
  26. package/dist/deterministic-replay.js +283 -0
  27. package/dist/emitter.js +143 -12
  28. package/dist/exec-metrics.js +11 -0
  29. package/dist/execute.js +251 -0
  30. package/dist/extract-ir.js +592 -5
  31. package/dist/failure-collector.js +163 -0
  32. package/dist/failure-corpus.js +507 -35
  33. package/dist/failure-report.js +11 -0
  34. package/dist/failures.js +11 -0
  35. package/dist/fast-path-hits.js +13 -0
  36. package/dist/feedback.js +10 -3
  37. package/dist/file-lock.js +82 -0
  38. package/dist/find-session.js +10 -0
  39. package/dist/fingerprint-list.js +15 -0
  40. package/dist/gen-history-log.js +13 -0
  41. package/dist/generate.js +2 -1
  42. package/dist/generate_500.js +4 -2
  43. package/dist/genome.js +11 -0
  44. package/dist/heatmap-data.js +11 -0
  45. package/dist/heatmap.js +11 -0
  46. package/dist/immune-reporter.js +34 -22
  47. package/dist/ir-utils.js +18 -0
  48. package/dist/learned.js +11 -0
  49. package/dist/ledger-registry.js +252 -0
  50. package/dist/llm.js +46 -2
  51. package/dist/load-benchmarks.js +47 -0
  52. package/dist/main.js +2 -1
  53. package/dist/mcp-server.mjs +445 -43
  54. package/dist/memory-layer.js +54 -13
  55. package/dist/metrics.js +11 -0
  56. package/dist/obs-web.js +561 -0
  57. package/dist/p0_ssg_demo.js +255 -40
  58. package/dist/planner.js +996 -80
  59. package/dist/protocol-registry.js +112 -0
  60. package/dist/recent-session.js +12 -0
  61. package/dist/repair-proposal.js +363 -0
  62. package/dist/runtime-invariants.js +170 -0
  63. package/dist/runtime-types.js +117 -0
  64. package/dist/runtime.js +1 -0
  65. package/dist/search-planner.js +39 -9
  66. package/dist/semantic-snapshot.js +157 -0
  67. package/dist/semantic-trace.js +1497 -0
  68. package/dist/semantic-validator.js +3 -2
  69. package/dist/semantic_guard_test.js +2 -1
  70. package/dist/session-utils.js +19 -0
  71. package/dist/sessions.js +11 -0
  72. package/dist/ssg-validator.js +666 -20
  73. package/dist/svl-distribution.js +11 -0
  74. package/dist/terminal-status.js +11 -0
  75. package/dist/test_failure_corpus.js +3 -1
  76. package/dist/token-savings.js +11 -0
  77. package/dist/total-repairs.js +12 -0
  78. package/dist/unresolved-count.js +12 -0
  79. package/dist/utils.js +2 -0
  80. package/dist/valid-fingerprints.js +13 -0
  81. package/dist/validator.js +118 -60
  82. package/dist/verify-fps.js +11 -0
  83. package/dist/verify-ledgers.js +11 -0
  84. package/docs/whitepaper-style.css +77 -0
  85. package/docs/whitepaper-v2.1.md +609 -0
  86. package/docs/whitepaper-v2.2.md +1064 -0
  87. package/docs/whitepaper-v2.2.pdf +0 -0
  88. package/fly.toml +1 -1
  89. package/package.json +13 -4
  90. package/protocols.json +131 -11
  91. package/public/dashboard.html +119 -0
  92. package/server/hub.js +84 -12
  93. package/test/replay-golden/sess_1780063202050_mgeld.json +9 -0
  94. package/test/replay-golden/sess_1780064032560_gocld.json +354 -0
  95. package/test/replay-golden/sess_1780064413331_s2709.json +606 -0
  96. package/test/replay-golden/sess_1780064792710_y3avo.json +614 -0
  97. package/test/replay-golden.ts +84 -0
  98. package/test_benchmark.js +165 -0
  99. package/test_comprehensive.mjs +638 -0
  100. package/test_concurrency.js +129 -0
  101. package/test_ir_robustness.js +85 -0
  102. package/test_semantic_contracts.js +269 -0
  103. package/test_ssg_stress.js +156 -0
  104. package/test_svl3.js +58 -0
  105. package/tsconfig.json +1 -1
  106. package/.env.example +0 -3
  107. package/.progmune_memory/episodic.json +0 -186
  108. package/.progmune_memory/fingerprints.json +0 -7
  109. package/.progmune_memory/opt_in.json +0 -4
  110. package/immune_hub_data/2026-05-14.json +0 -50
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ /**
3
+ * Phase 7: Failure Corpus — collect and categorize emitter failures.
4
+ *
5
+ * Records every failed progmune_execute attempt with root cause classification.
6
+ * Feeds the Emitter Intelligence loop: collect → classify → fix → verify.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.classifyError = classifyError;
43
+ exports.classifyPlanError = classifyPlanError;
44
+ exports.recordFailure = recordFailure;
45
+ exports.loadFailures = loadFailures;
46
+ exports.failureStats = failureStats;
47
+ exports.formatFailureStats = formatFailureStats;
48
+ const fs = __importStar(require("fs"));
49
+ const CORPUS_DIR = "failure-corpus";
50
+ /** Classify a compile error string into a root cause. */
51
+ /** Classify a compile error into a root cause category. */
52
+ /** @requires ERROR_STRING @produces ROOT_CAUSE */
53
+ /** @requires ERROR_STRING @produces ROOT_CAUSE */
54
+ function classifyError(error) {
55
+ if (!error)
56
+ return "F10";
57
+ if (error.includes("declares") && error.includes("locally"))
58
+ return "F01";
59
+ if (error.includes("Cannot find module") || error.includes("has no exported member"))
60
+ return "F02";
61
+ if (error.includes("is not assignable") || error.includes("Type"))
62
+ return "F03";
63
+ if (error.includes("Expected") && error.includes("arguments"))
64
+ return "F04";
65
+ if (error.includes("Cannot find name"))
66
+ return "F06";
67
+ if (error.includes("is not a function") || error.includes("not callable"))
68
+ return "F05";
69
+ if (error.includes("return") && error.includes("type"))
70
+ return "F08";
71
+ return "F10";
72
+ }
73
+ /** Classify a planning failure. */
74
+ /** Classify a planning failure into a root cause category. */
75
+ /** @requires ERROR_STRING @produces ROOT_CAUSE */
76
+ /** @requires ERROR_STRING @produces ROOT_CAUSE */
77
+ function classifyPlanError(error) {
78
+ if (!error)
79
+ return "F10";
80
+ if (error.includes("protocol") || error.includes("SSG"))
81
+ return "F09";
82
+ if (error.includes("Cannot read properties") || error.includes("undefined"))
83
+ return "F07";
84
+ return "F07"; // most plan failures are parsing issues
85
+ }
86
+ /** Record a failure and save to disk. */
87
+ /** Record a generation failure to the failure corpus. */
88
+ /** @requires FAILURE_EVENT @produces FAILURE_ID */
89
+ function recordFailure(record) {
90
+ const id = `F-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
91
+ const entry = {
92
+ ...record,
93
+ id,
94
+ timestamp: Date.now(),
95
+ };
96
+ try {
97
+ if (!fs.existsSync(CORPUS_DIR))
98
+ fs.mkdirSync(CORPUS_DIR, { recursive: true });
99
+ fs.writeFileSync(`${CORPUS_DIR}/${id}.json`, JSON.stringify(entry, null, 2), "utf-8");
100
+ }
101
+ catch { }
102
+ return id;
103
+ }
104
+ /** Load all recorded failures. */
105
+ /** Load all recorded failures from the failure corpus. */
106
+ /** @requires FAILURE_CORPUS @produces FAILURE_LIST */
107
+ /** @requires FAILURE_CORPUS @produces FAILURE_LIST */
108
+ /** @requires FAILURE_CORPUS @produces FAILURE_LIST */
109
+ function loadFailures() {
110
+ if (!fs.existsSync(CORPUS_DIR))
111
+ return [];
112
+ const failures = [];
113
+ for (const f of fs.readdirSync(CORPUS_DIR)) {
114
+ if (!f.endsWith(".json") || f === "schema.json")
115
+ continue;
116
+ try {
117
+ failures.push(JSON.parse(fs.readFileSync(`${CORPUS_DIR}/${f}`, "utf-8")));
118
+ }
119
+ catch { }
120
+ }
121
+ return failures.sort((a, b) => b.timestamp - a.timestamp);
122
+ }
123
+ /** Get failure statistics grouped by root cause. */
124
+ /** Get failure statistics grouped by root cause. */
125
+ /** @requires FAILURE_LIST @produces FAILURE_STATS */
126
+ /** @requires FAILURE_LIST @produces FAILURE_STATS */
127
+ /** @requires FAILURE_LIST @produces FAILURE_STATS */
128
+ function failureStats() {
129
+ const failures = loadFailures();
130
+ const byRootCause = {};
131
+ for (const f of failures) {
132
+ byRootCause[f.rootCause] = (byRootCause[f.rootCause] || 0) + 1;
133
+ }
134
+ const sorted = Object.entries(byRootCause).sort((a, b) => b[1] - a[1]);
135
+ return {
136
+ total: failures.length,
137
+ byRootCause,
138
+ topCause: sorted.length > 0 ? sorted[0][0] : "none",
139
+ };
140
+ }
141
+ /** Format failure stats as readable text. */
142
+ /** Format failure statistics as a human-readable report. */
143
+ /** @requires FAILURE_STATS @produces FORMATTED_REPORT */
144
+ /** @requires FAILURE_STATS @produces FORMATTED_REPORT */
145
+ /** @requires FAILURE_STATS @produces FORMATTED_REPORT */
146
+ function formatFailureStats() {
147
+ const stats = failureStats();
148
+ if (stats.total === 0)
149
+ return "No failures recorded yet.";
150
+ const lines = [
151
+ `Failure Corpus: ${stats.total} failures`,
152
+ `Top cause: ${stats.topCause}`,
153
+ "",
154
+ ];
155
+ const sorted = Object.entries(stats.byRootCause).sort((a, b) => b[1] - a[1]);
156
+ const max = sorted[0]?.[1] || 1;
157
+ for (const [cause, count] of sorted) {
158
+ const bar = "█".repeat(Math.round((count / max) * 20));
159
+ const pct = ((count / stats.total) * 100).toFixed(0) + "%";
160
+ lines.push(` ${cause}: ${bar} ${count} (${pct})`);
161
+ }
162
+ return lines.join("\n");
163
+ }