mindforge-cc 5.1.0 → 5.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.
|
@@ -9,6 +9,8 @@ const path = require('node:path');
|
|
|
9
9
|
const Store = require('./knowledge-store');
|
|
10
10
|
const EISClient = require('./eis-client');
|
|
11
11
|
const crypto = require('node:crypto');
|
|
12
|
+
const EmbeddingEngine = require('./embedding-engine');
|
|
13
|
+
const adsEngine = require('../review/ads-engine');
|
|
12
14
|
|
|
13
15
|
class FederatedSync {
|
|
14
16
|
constructor(config = {}) {
|
|
@@ -92,16 +94,94 @@ class FederatedSync {
|
|
|
92
94
|
for (const remote of remoteEntries) {
|
|
93
95
|
const local = existingById.get(remote.id);
|
|
94
96
|
|
|
95
|
-
|
|
96
|
-
if (!local || new Date(remote.timestamp) > new Date(local.timestamp)) {
|
|
97
|
+
if (!local) {
|
|
97
98
|
fs.appendFileSync(globalPath, JSON.stringify(remote) + '\n');
|
|
98
99
|
mergedCount++;
|
|
100
|
+
continue;
|
|
99
101
|
}
|
|
102
|
+
|
|
103
|
+
// Pillar I (v5.2.0): Hybrid Semantic synthesis
|
|
104
|
+
let similarity = 0;
|
|
105
|
+
try {
|
|
106
|
+
similarity = EmbeddingEngine.cosineSimilarity(
|
|
107
|
+
EmbeddingEngine.computeTfIdfVector(EmbeddingEngine.tokenize(local.content), {}, 1),
|
|
108
|
+
EmbeddingEngine.computeTfIdfVector(EmbeddingEngine.tokenize(remote.content), {}, 1)
|
|
109
|
+
);
|
|
110
|
+
} catch (err) {
|
|
111
|
+
console.error(`[FIM-ERR] Semantic analysis failed for ${local.id}. Falling back to LWW.`, err);
|
|
112
|
+
// Fallback to basic LWW (Last-Write-Wins)
|
|
113
|
+
if (new Date(remote.timestamp) > new Date(local.timestamp)) {
|
|
114
|
+
this.writeToGlobalKB(remote, globalPath);
|
|
115
|
+
}
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
this.triggerHybridSynthesis(local, remote, similarity, globalPath);
|
|
120
|
+
mergedCount++;
|
|
100
121
|
}
|
|
101
122
|
|
|
102
123
|
return mergedCount;
|
|
103
124
|
}
|
|
104
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Hybrid Synthesis Logic (Pillar I v5.2.0)
|
|
128
|
+
*/
|
|
129
|
+
async triggerHybridSynthesis(local, remote, similarity, globalPath) {
|
|
130
|
+
console.log(`[FIM-SYNC] Analyzing semantic overlap for ${local.id} (Similarity: ${similarity.toFixed(4)})`);
|
|
131
|
+
|
|
132
|
+
// 1. LWW (Similarity > 0.9) - Near identical
|
|
133
|
+
if (similarity > 0.9) {
|
|
134
|
+
if (new Date(remote.timestamp) > new Date(local.timestamp)) {
|
|
135
|
+
this.writeToGlobalKB(remote, globalPath);
|
|
136
|
+
console.log(` └─ [LWW] Auto-resolved via timestamp.`);
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// 2. Autonomous Merge (0.75 - 0.9) - Semantic Overlap
|
|
142
|
+
if (similarity > 0.75) {
|
|
143
|
+
console.log(` └─ [ADS] Triggering Autonomous Knowledge Synthesis...`);
|
|
144
|
+
const merged = await this.triggerADSMerging(local, remote);
|
|
145
|
+
this.writeToGlobalKB(merged, globalPath);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 3. Human Stewardship (0.6 - 0.75) - Probable Disagreement
|
|
150
|
+
if (similarity > 0.6) {
|
|
151
|
+
console.log(` └─ [DHH] High disagreement. Triggering Nexus Handover...`);
|
|
152
|
+
this.localStore.markConflict(local.id, remote);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 4. Collision Isolation (< 0.6) - Topic Mismatch
|
|
157
|
+
console.log(` └─ [ISO] Semantic collision (Topic mismatch). Isolating entries.`);
|
|
158
|
+
this.writeToGlobalKB({ ...remote, id: `${remote.id}_collision_${Date.now()}` }, globalPath);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async triggerADSMerging(local, remote) {
|
|
162
|
+
const result = await adsEngine.runADSSynthesis({
|
|
163
|
+
phaseNum: 'SYNC',
|
|
164
|
+
goal: `Synthesize a unified knowledge entry for topic: ${local.topic || local.id}`,
|
|
165
|
+
context: `Local Entry: ${local.content}\n\nRemote Entry: ${remote.content}`,
|
|
166
|
+
sessionId: 'fim-sync-v5.2.0'
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Extract the final plan/content from ADS result
|
|
170
|
+
const mergedContent = fs.readFileSync(path.join(process.cwd(), '.planning', 'PLAN.md'), 'utf8');
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
...remote,
|
|
174
|
+
content: mergedContent,
|
|
175
|
+
confidence: 1.0,
|
|
176
|
+
synthesis_id: result.ads_id,
|
|
177
|
+
timestamp: new Date().toISOString()
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
writeToGlobalKB(entry, globalPath) {
|
|
182
|
+
fs.appendFileSync(globalPath, JSON.stringify(entry) + '\n');
|
|
183
|
+
}
|
|
184
|
+
|
|
105
185
|
isRecentlySynced(id) {
|
|
106
186
|
// Simple check against local sync-history log
|
|
107
187
|
if (!fs.existsSync(this.syncHistoryPath)) return false;
|
|
@@ -15,7 +15,11 @@ The V5 mesh is built on three core pillars residing in `bin/memory/`:
|
|
|
15
15
|
### B. Federated Sync (`federated-sync.js`)
|
|
16
16
|
- **Role**: High-performance synchronization engine between local stores and the organizational mesh.
|
|
17
17
|
- **Delta Sync**: Tracks the `last_sync` timestamp to only pull new organizational insights, significantly reducing latency and compute costs.
|
|
18
|
-
- **Conflict Resolution**: Uses **
|
|
18
|
+
- **Conflict Resolution**: Uses **Hybrid Semantic Synthesis** (Pillar I v5.2.0).
|
|
19
|
+
- **Similarity > 0.9**: Near-identical; auto-resolve via **Last-Write-Wins (LWW)**.
|
|
20
|
+
- **0.75 - 0.9**: Semantic Overlap; triggers **Autonomous ADS Merging**.
|
|
21
|
+
- **0.6 - 0.75**: Conflict; triggers **Nexus Handover (DHH)** for human steering.
|
|
22
|
+
- **< 0.6**: Topic Collision; isolates entries into unique IDs to prevent data loss.
|
|
19
23
|
|
|
20
24
|
### C. Knowledge Graph Bridge (`knowledge-graph.js`)
|
|
21
25
|
- **Role**: Unified memory interface that resolves both local project nodes and remote federated nodes.
|
|
@@ -32,4 +36,4 @@ The V5 mesh is built on three core pillars residing in `bin/memory/`:
|
|
|
32
36
|
- **Elimination of Redundancy**: Multi-thousand-token research chains are executed once and shared universally across the mesh.
|
|
33
37
|
|
|
34
38
|
---
|
|
35
|
-
*Status: V5
|
|
39
|
+
*Status: V5.2.0 Semantic Consensus Implemented & Verified (2026-03-28)*
|