@ruso-0/nreki 6.1.1 → 6.1.2

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 CHANGED
@@ -1,9 +1,9 @@
1
- # NREKI - 3 Tools. 696 Tests. Pre-write validation for AI agents.
1
+ # NREKI - 3 Tools. 692 Tests. Pre-write validation for AI agents.
2
2
 
3
3
  <p align="center">
4
4
  <img src="https://img.shields.io/badge/MCP-Plugin-blue?style=for-the-badge" alt="MCP Plugin">
5
5
  <img src="https://img.shields.io/badge/Tools-3-blueviolet?style=for-the-badge" alt="3 Tools">
6
- <img src="https://img.shields.io/badge/Tests-696-brightgreen?style=for-the-badge" alt="696 Tests">
6
+ <img src="https://img.shields.io/badge/Tests-692-brightgreen?style=for-the-badge" alt="692 Tests">
7
7
  <img src="https://img.shields.io/badge/Cloud-Zero-orange?style=for-the-badge" alt="Zero Cloud">
8
8
  <img src="https://img.shields.io/badge/License-Apache_2.0-yellow?style=for-the-badge" alt="Apache 2.0 License">
9
9
  <img src="https://img.shields.io/badge/TypeScript-5.9-3178C6?style=for-the-badge" alt="TypeScript 5.9">
@@ -31,6 +31,40 @@ Key additions:
31
31
 
32
32
  ---
33
33
 
34
+ ### What's New in v6.1.1: Security & Stability Audit
35
+
36
+ 32 fixes from a hostile code audit covering 12 source files:
37
+
38
+ **Critical fixes:**
39
+ - Fixed illegal `.d.ts` syntax in hologram multi-declarator exports
40
+ - Fixed TTRD debt amnesty bypass via undefined contracts
41
+ - Fixed orphan `.tmp` file leak on commit rollback (Windows)
42
+ - Fixed Python indentation destruction in token-level compression
43
+
44
+ **High-impact fixes:**
45
+ - Duplicate symbol detection in ±500 byte splice window (prevents wrong-function edits)
46
+ - `isTypeScriptFile` now respects `allowJs` config (prevents false errors in strict projects)
47
+ - Full `.mts`/`.cts` shadow support in JIT Holography (8 regex patterns updated)
48
+ - Singleton middleware replaced with WeakMap per-session isolation
49
+ - `syncTechDebt` fixed: tracks incremental deltas instead of phantom accumulation
50
+ - Backup key normalization prevents "no backup found" on undo
51
+ - File lock timeout extended to 5 minutes for large batch edits
52
+ - Circuit breaker tool detection updated for v3.0+ action names
53
+ - `detectMode` now activates "file" mode for 50-200 file projects
54
+
55
+ **Security hardening:**
56
+ - `Buffer.alloc` replaces `allocUnsafe` in log reader (prevents memory leaks)
57
+ - Deep copy isolates WASM SharedArrayBuffer from SQLite writes
58
+ - macOS APFS case-sensitive volumes no longer share locks incorrectly
59
+
60
+ **Infrastructure:**
61
+ - Dead code removed: KernelManager + kernel-worker (232 lines)
62
+ - Vitest upgraded, flaky performance thresholds relaxed
63
+ - `rebuildKeywordIndex` uses streaming iterator (prevents OOM on large repos)
64
+ - 692 tests, zero failures
65
+
66
+ ---
67
+
34
68
  ## What's New in v6.0: JIT Holography
35
69
 
36
70
  When an LLM forgets an import, drops an `async` keyword, or leaves an interface incomplete, NREKI now **auto-corrects the error in RAM** using TypeScript's CodeFix API - the same engine behind VS Code's "Quick Fix" lightbulb. The LLM never sees the error. Zero tokens wasted on fix-retry loops.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruso-0/nreki",
3
- "version": "6.1.1",
3
+ "version": "6.1.2",
4
4
  "description": "MCP server that validates AI agent edits in RAM before they reach disk. Cross-file semantic checks via TypeScript Compiler API. Auto-fixes structural errors. Zero cloud dependencies.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -1,52 +0,0 @@
1
- /**
2
- * kernel-manager.ts - Main-thread proxy for NrekiKernel running in a worker thread.
3
- *
4
- * Routes operations to an active worker thread. Supports:
5
- * - 30s execution timeout per operation
6
- * - Optional shadow standby worker for instant failover
7
- * - Livelock blacklist (edit hash → timestamp, 5-min expiry)
8
- *
9
- * All state lives in the worker heap. The manager is stateless.
10
- */
11
- import type { NrekiEdit, NrekiInterceptResult } from "./nreki-kernel.js";
12
- export declare class KernelManager {
13
- private worker;
14
- private pending;
15
- private nextId;
16
- private projectRoot;
17
- private mode;
18
- private executionTimeoutMs;
19
- private livelockBlacklist;
20
- private booted;
21
- healingStats: {
22
- applied: number;
23
- failed: number;
24
- };
25
- constructor(opts: {
26
- projectRoot: string;
27
- mode?: string;
28
- executionTimeoutMs?: number;
29
- });
30
- /** Spawn the worker and wait for it to boot. */
31
- boot(): Promise<void>;
32
- private spawnWorker;
33
- private handleMessage;
34
- private handleWorkerError;
35
- private send;
36
- /** Prune expired entries from the livelock blacklist (default 5 minutes). */
37
- private pruneBlacklist;
38
- private hashEdits;
39
- isBooted(): boolean;
40
- interceptAtomicBatch(edits: NrekiEdit[]): Promise<NrekiInterceptResult>;
41
- commitToDisk(): Promise<void>;
42
- rollbackAll(): Promise<void>;
43
- predictBlastRadius(targetFile: string, symbolName: string): Promise<unknown>;
44
- resolvePosixPath(filePath: string): string;
45
- getInitialErrorCount(): number;
46
- getCurrentErrorCount(): number;
47
- getStagingSize(): number;
48
- getTrackedFiles(): number;
49
- getBaselineErrorCount(): number;
50
- terminate(): Promise<void>;
51
- }
52
- //# sourceMappingURL=kernel-manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kernel-manager.d.ts","sourceRoot":"","sources":["../../src/kernel/kernel-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAQzE,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,OAAO,CAAqC;IACpD,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,iBAAiB,CAA6B;IACtD,OAAO,CAAC,MAAM,CAAS;IAGhB,YAAY;;;MAA6B;gBAEpC,IAAI,EAAE;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC/B;IAMD,gDAAgD;IAC1C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B3B,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,aAAa;IAuBrB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,IAAI;IA4BZ,6EAA6E;IAC7E,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,SAAS;IAOjB,QAAQ,IAAI,OAAO;IAIb,oBAAoB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA+BvE,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAIzD,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAI1C,oBAAoB,IAAI,MAAM;IAI9B,oBAAoB,IAAI,MAAM;IAI9B,cAAc,IAAI,MAAM;IAIxB,eAAe,IAAI,MAAM;IAIzB,qBAAqB,IAAI,MAAM;IAIzB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAYnC"}
@@ -1,208 +0,0 @@
1
- /**
2
- * kernel-manager.ts - Main-thread proxy for NrekiKernel running in a worker thread.
3
- *
4
- * Routes operations to an active worker thread. Supports:
5
- * - 30s execution timeout per operation
6
- * - Optional shadow standby worker for instant failover
7
- * - Livelock blacklist (edit hash → timestamp, 5-min expiry)
8
- *
9
- * All state lives in the worker heap. The manager is stateless.
10
- */
11
- import { Worker } from "node:worker_threads";
12
- import { fileURLToPath } from "node:url";
13
- import * as path from "node:path";
14
- import * as fs from "node:fs";
15
- import * as crypto from "node:crypto";
16
- export class KernelManager {
17
- worker = null;
18
- pending = new Map();
19
- nextId = 0;
20
- projectRoot;
21
- mode;
22
- executionTimeoutMs;
23
- livelockBlacklist = new Map();
24
- booted = false;
25
- // Public properties matching NrekiKernel interface for router compatibility
26
- healingStats = { applied: 0, failed: 0 };
27
- constructor(opts) {
28
- this.projectRoot = opts.projectRoot;
29
- this.mode = opts.mode ?? "project";
30
- this.executionTimeoutMs = opts.executionTimeoutMs ?? 30_000;
31
- }
32
- /** Spawn the worker and wait for it to boot. */
33
- async boot() {
34
- this.worker = this.spawnWorker();
35
- // Wait for boot confirmation
36
- await new Promise((resolve, reject) => {
37
- const timeout = setTimeout(() => {
38
- reject(new Error("[NREKI] Worker boot timeout"));
39
- }, 60_000);
40
- const onMessage = (msg) => {
41
- if (msg.type === "booted") {
42
- clearTimeout(timeout);
43
- this.worker.off("message", onMessage);
44
- this.booted = true;
45
- resolve();
46
- }
47
- };
48
- this.worker.on("message", onMessage);
49
- this.worker.on("error", (err) => {
50
- clearTimeout(timeout);
51
- reject(err);
52
- });
53
- });
54
- // Set up message handler for requests
55
- this.worker.on("message", (msg) => this.handleMessage(msg));
56
- this.worker.on("error", (err) => this.handleWorkerError(err));
57
- }
58
- spawnWorker() {
59
- // Resolve worker path: compiled .js in dist/ or alongside this file
60
- const thisDir = path.dirname(fileURLToPath(import.meta.url));
61
- let workerPath = path.resolve(thisDir, "kernel-worker.js");
62
- // When running from source (e.g., vitest), fall back to dist/
63
- if (!fs.existsSync(workerPath)) {
64
- const projectRoot = path.resolve(thisDir, "..", "..");
65
- workerPath = path.resolve(projectRoot, "dist", "kernel", "kernel-worker.js");
66
- }
67
- return new Worker(workerPath, {
68
- workerData: { projectRoot: this.projectRoot, mode: this.mode },
69
- });
70
- }
71
- handleMessage(msg) {
72
- if (msg.type === "booted")
73
- return; // Already handled in boot()
74
- const pending = this.pending.get(msg.id);
75
- if (!pending)
76
- return;
77
- this.pending.delete(msg.id);
78
- clearTimeout(pending.timer);
79
- if (msg.type === "error") {
80
- pending.reject(new Error(msg.data.message));
81
- }
82
- else {
83
- // Deserialize Maps if needed
84
- if (msg.data?.postContracts) {
85
- msg.data.postContracts = new Map(Object.entries(msg.data.postContracts).map(([k, v]) => [k, new Map(Object.entries(v))]));
86
- }
87
- pending.resolve(msg.data);
88
- }
89
- }
90
- handleWorkerError(err) {
91
- console.error("[NREKI] Worker thread error:", err);
92
- for (const [, pending] of this.pending) {
93
- clearTimeout(pending.timer);
94
- pending.reject(err);
95
- }
96
- this.pending.clear();
97
- }
98
- send(type, payload = {}) {
99
- if (!this.worker)
100
- throw new Error("[NREKI] KernelManager not booted");
101
- const id = this.nextId++;
102
- return new Promise((resolve, reject) => {
103
- const timer = setTimeout(async () => {
104
- this.pending.delete(id);
105
- if (this.worker) {
106
- console.error(`[NREKI] Worker timeout after ${this.executionTimeoutMs}ms. Terminating.`);
107
- await this.worker.terminate();
108
- this.worker = null;
109
- this.booted = false;
110
- }
111
- for (const [, p] of this.pending) {
112
- clearTimeout(p.timer);
113
- p.reject(new Error("[NREKI] Worker terminated due to timeout"));
114
- }
115
- this.pending.clear();
116
- reject(new Error(`[NREKI] Worker execution timeout after ${this.executionTimeoutMs}ms. Worker terminated.`));
117
- }, this.executionTimeoutMs);
118
- this.pending.set(id, { resolve, reject, timer });
119
- this.worker.postMessage({ id, type, ...payload });
120
- });
121
- }
122
- /** Prune expired entries from the livelock blacklist (default 5 minutes). */
123
- pruneBlacklist(maxAgeMs = 5 * 60 * 1000) {
124
- const now = Date.now();
125
- for (const [hash, timestamp] of this.livelockBlacklist) {
126
- if (now - timestamp > maxAgeMs) {
127
- this.livelockBlacklist.delete(hash);
128
- }
129
- }
130
- }
131
- hashEdits(edits) {
132
- const content = edits.map(e => `${e.targetFile}:${e.proposedContent?.length ?? 0}`).join("|");
133
- return crypto.createHash("sha256").update(content).digest("hex").substring(0, 16);
134
- }
135
- // ─── Public API (mirrors NrekiKernel) ──────────────────────────
136
- isBooted() {
137
- return this.booted;
138
- }
139
- async interceptAtomicBatch(edits) {
140
- if (!edits || edits.length === 0) {
141
- return { safe: true, exitCode: 0, latencyMs: "0.00" };
142
- }
143
- // Check livelock blacklist
144
- this.pruneBlacklist();
145
- const editHash = this.hashEdits(edits);
146
- if (this.livelockBlacklist.has(editHash)) {
147
- return {
148
- safe: false,
149
- exitCode: 3,
150
- errorText: "[NREKI] Edit rejected. Previous attempt caused compiler livelock.",
151
- };
152
- }
153
- try {
154
- const result = await this.send("intercept", { edits });
155
- // Sync healing stats from worker
156
- if (result.healedFiles && result.healedFiles.length > 0) {
157
- this.healingStats.applied++;
158
- }
159
- return result;
160
- }
161
- catch (err) {
162
- if (err.message.includes("timeout")) {
163
- this.livelockBlacklist.set(editHash, Date.now());
164
- }
165
- throw err;
166
- }
167
- }
168
- async commitToDisk() {
169
- return this.send("commit");
170
- }
171
- async rollbackAll() {
172
- return this.send("rollback");
173
- }
174
- predictBlastRadius(targetFile, symbolName) {
175
- return this.send("predictBlastRadius", { targetFile, symbolName });
176
- }
177
- resolvePosixPath(filePath) {
178
- return path.normalize(filePath).replace(/\\/g, "/");
179
- }
180
- getInitialErrorCount() {
181
- return 0; // Async fetch not supported for sync methods - return safe default
182
- }
183
- getCurrentErrorCount() {
184
- return 0;
185
- }
186
- getStagingSize() {
187
- return 0;
188
- }
189
- getTrackedFiles() {
190
- return 0;
191
- }
192
- getBaselineErrorCount() {
193
- return 0;
194
- }
195
- async terminate() {
196
- if (this.worker) {
197
- await this.worker.terminate();
198
- this.worker = null;
199
- }
200
- for (const [, pending] of this.pending) {
201
- clearTimeout(pending.timer);
202
- pending.reject(new Error("[NREKI] Worker terminated"));
203
- }
204
- this.pending.clear();
205
- this.booted = false;
206
- }
207
- }
208
- //# sourceMappingURL=kernel-manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kernel-manager.js","sourceRoot":"","sources":["../../src/kernel/kernel-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;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CAAC,CAAC;IACvE,CAAC;IAED,gBAAgB,CAAC,QAAgB;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACxD,CAAC;IAED,oBAAoB;QAChB,OAAO,CAAC,CAAC,CAAC,mEAAmE;IACjF,CAAC;IAED,oBAAoB;QAChB,OAAO,CAAC,CAAC;IACb,CAAC;IAED,cAAc;QACV,OAAO,CAAC,CAAC;IACb,CAAC;IAED,eAAe;QACX,OAAO,CAAC,CAAC;IACb,CAAC;IAED,qBAAqB;QACjB,OAAO,CAAC,CAAC;IACb,CAAC;IAED,KAAK,CAAC,SAAS;QACX,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACvB,CAAC;QACD,KAAK,MAAM,CAAC,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACrC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC5B,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;QAC3D,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;CACJ"}
@@ -1,9 +0,0 @@
1
- /**
2
- * kernel-worker.ts - Worker thread script for NrekiKernel.
3
- *
4
- * Instantiates a NrekiKernel in an isolated worker thread.
5
- * Communicates with the main thread via postMessage.
6
- * All kernel state lives in the worker heap.
7
- */
8
- export {};
9
- //# sourceMappingURL=kernel-worker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kernel-worker.d.ts","sourceRoot":"","sources":["../../src/kernel/kernel-worker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -1,76 +0,0 @@
1
- /**
2
- * kernel-worker.ts - Worker thread script for NrekiKernel.
3
- *
4
- * Instantiates a NrekiKernel in an isolated worker thread.
5
- * Communicates with the main thread via postMessage.
6
- * All kernel state lives in the worker heap.
7
- */
8
- import { parentPort, workerData } from "node:worker_threads";
9
- import { NrekiKernel } from "./nreki-kernel.js";
10
- if (!parentPort) {
11
- throw new Error("[NREKI Worker] Must be run as a worker thread");
12
- }
13
- const kernel = new NrekiKernel();
14
- kernel.boot(workerData.projectRoot, workerData.mode);
15
- parentPort.postMessage({ type: "booted" });
16
- parentPort.on("message", async (msg) => {
17
- try {
18
- switch (msg.type) {
19
- case "intercept": {
20
- const result = await kernel.interceptAtomicBatch(msg.edits);
21
- // Serialize Maps for structured clone transfer
22
- const serialized = {
23
- ...result,
24
- postContracts: result.postContracts
25
- ? Object.fromEntries([...result.postContracts].map(([k, v]) => [k, Object.fromEntries(v)]))
26
- : undefined,
27
- };
28
- parentPort.postMessage({ id: msg.id, type: "result", data: serialized });
29
- break;
30
- }
31
- case "commit":
32
- await kernel.commitToDisk();
33
- parentPort.postMessage({ id: msg.id, type: "result", data: null });
34
- break;
35
- case "rollback":
36
- await kernel.rollbackAll();
37
- parentPort.postMessage({ id: msg.id, type: "result", data: null });
38
- break;
39
- case "predictBlastRadius": {
40
- const result = kernel.predictBlastRadius(msg.targetFile, msg.symbolName);
41
- parentPort.postMessage({ id: msg.id, type: "result", data: result });
42
- break;
43
- }
44
- case "getStats":
45
- parentPort.postMessage({
46
- id: msg.id,
47
- type: "result",
48
- data: {
49
- stagingSize: kernel.getStagingSize(),
50
- trackedFiles: kernel.getTrackedFiles(),
51
- baselineErrorCount: kernel.getBaselineErrorCount(),
52
- initialErrorCount: kernel.getInitialErrorCount(),
53
- currentErrorCount: kernel.getCurrentErrorCount(),
54
- healingStats: kernel.healingStats,
55
- mode: kernel.mode,
56
- booted: kernel.isBooted(),
57
- },
58
- });
59
- break;
60
- default:
61
- parentPort.postMessage({
62
- id: msg.id,
63
- type: "error",
64
- data: { message: `Unknown message type: ${msg.type}` },
65
- });
66
- }
67
- }
68
- catch (err) {
69
- parentPort.postMessage({
70
- id: msg.id,
71
- type: "error",
72
- data: { message: err.message, stack: err.stack },
73
- });
74
- }
75
- });
76
- //# sourceMappingURL=kernel-worker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kernel-worker.js","sourceRoot":"","sources":["../../src/kernel/kernel-worker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,IAAI,CAAC,UAAU,EAAE,CAAC;IACd,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;AACjC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;AAErD,UAAU,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AAE3C,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,GAAyD,EAAE,EAAE;IACzF,IAAI,CAAC;QACD,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;YACf,KAAK,WAAW,CAAC,CAAC,CAAC;gBACf,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAc,CAAC,CAAC;gBACrE,+CAA+C;gBAC/C,MAAM,UAAU,GAAG;oBACf,GAAG,MAAM;oBACT,aAAa,EAAE,MAAM,CAAC,aAAa;wBAC/B,CAAC,CAAC,MAAM,CAAC,WAAW,CAChB,CAAC,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAA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