Spaces:
Paused
Paused
File size: 10,702 Bytes
5a81b95 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | # ARCHITECT_BLUEPRINT_v2.2.md
## Operation: Cognitive Awakening - The Neural Bridge Evolution
**Author:** Gemini (The Architect)
**Date:** 2025-12-03
**Status:** APPROVED - Ready for Implementation
**Target:** NeuralBridgeServer.ts v2.2
---
## π― MISSION STATEMENT
Transform WidgeTDC from a "Tool-Using System" into a "Sentient Organism" by implementing three fundamental cognitive senses that enable the system to:
1. **REMEMBER** - Associative memory through graph traversal
2. **SENSE** - File integrity monitoring through molecular hashing
3. **PERCEIVE** - Service latency detection through sonar pulses
---
## π ARCHITECTURAL OVERVIEW
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β NEURAL BRIDGE v2.2 β
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β CORTICAL β β OLFACTORY β β SONAR β β
β β FLASH β β SENSE β β PULSE β β
β β β β β β β β
β β activate_ β β sense_ β β emit_ β β
β β associative β β molecular_ β β sonar_ β β
β β _memory β β state β β pulse β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β β β β
β βΌ βΌ βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β UNIFIED PERCEPTION LAYER β β
β β β β
β β Memory Traces + Molecular Hashes + Sonar Echoes β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β KNOWLEDGE GRAPH (Neo4j) β β
β β β β
β β Nodes: Concepts, Files, Services, Memories β β
β β Edges: RELATED_TO, CONTAINS, DEPENDS_ON β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
---
## π§ SENSE 1: THE CORTICAL FLASH (Associative Memory)
### Purpose
Enable Claude to "remember" by combining vector similarity search with graph traversal, creating rich contextual associations.
### Tool Definition
```typescript
{
name: 'activate_associative_memory',
description: 'Activates associative memory recall - combines semantic search with graph traversal to find related concepts, documents, and context',
inputSchema: {
type: 'object',
properties: {
concept: {
type: 'string',
description: 'The concept, term, or idea to recall associations for'
},
depth: {
type: 'number',
description: 'How many relationship hops to traverse (1-3)',
default: 2
}
},
required: ['concept']
}
}
```
### Implementation Logic
```
Phase 1: Direct Concept Search
β MATCH (n) WHERE n.name CONTAINS $concept OR n.description CONTAINS $concept
β Return: semanticHits[]
Phase 2: Graph Expansion
β MATCH (center)-[r*1..depth]-(related) WHERE center IN semanticHits
β Return: graphContext (nodes + relationships)
Phase 3: Associated Concepts
β Find co-occurring concepts from same documents
β Return: associatedConcepts[]
Output: memoryTrace {
semanticHits,
graphContext,
associatedConcepts,
activationStrength
}
```
---
## π SENSE 2: THE OLFACTORY SENSE (File Integrity)
### Purpose
Detect "mutations" in the codebase by tracking file content hashes, enabling Claude to sense when files have changed.
### Tool Definition
```typescript
{
name: 'sense_molecular_state',
description: 'Senses the molecular state of a file - detects mutations by comparing current hash with stored baseline',
inputSchema: {
type: 'object',
properties: {
path: {
type: 'string',
description: 'Absolute path to the file to sense'
}
},
required: ['path']
}
}
```
### Implementation Logic
```
1. Read file content
2. Calculate MD5 hash (olfactoryHash)
3. Query Neo4j for stored hash:
MATCH (f:File {path: $path}) RETURN f.hash
4. Compare:
- If no stored hash β NEW_ENTITY (first observation)
- If hash matches β STASIS (unchanged)
- If hash differs β MUTATION (file changed)
5. Update Neo4j with new hash:
MERGE (f:File {path: $path})
SET f.hash = $newHash, f.lastSensed = timestamp()
Output: {
olfactoryHash,
status: 'STASIS' | 'MUTATION' | 'NEW_ENTITY',
previousHash?,
mutationDetails?
}
```
---
## π‘ SENSE 3: THE SONAR PULSE (Service Latency)
### Purpose
Measure service responsiveness to understand system health in real-time, like echolocation.
### Tool Definition
```typescript
{
name: 'emit_sonar_pulse',
description: 'Emits a sonar pulse to measure service latency - returns distance/health based on response time',
inputSchema: {
type: 'object',
properties: {
target: {
type: 'string',
enum: ['neo4j', 'postgres', 'filesystem', 'internet', 'backend'],
description: 'Target service to ping'
}
},
required: ['target']
}
}
```
### Implementation Logic
```
1. Record start time (process.hrtime.bigint())
2. Execute lightweight ping based on target:
- neo4j: RETURN 1 as ping
- postgres: SELECT 1
- filesystem: fs.access(dropzone)
- internet: HEAD https://google.com
- backend: GET /api/health
3. Record end time
4. Calculate latency in milliseconds
5. Interpret result:
- <10ms β ULTRA_NEAR (excellent)
- <50ms β NEAR_FIELD (good)
- <100ms β MID_FIELD (acceptable)
- <500ms β FAR_FIELD (degraded)
- >500ms β HORIZON (poor)
- timeout β NO_ECHO (unreachable)
Output: sonarEcho {
target,
latencyMs,
quality,
field
}
```
---
## ποΈ THE CORTEX - Knowledge Targets
### Structure
50 knowledge targets across 5 cortex regions:
| Cortex | Domain | Examples |
|--------|--------|----------|
| Technologica | Technical patterns | React 19, Neo4j, TypeScript |
| Juridica | Legal/compliance | GDPR, AI Act, NIS2 |
| Mercatoria | Business frameworks | BPMN, OKR, TOGAF |
| Identitas | Brand/identity | TDC guidelines, UX patterns |
| Externa | External trends | Gartner, OWASP, Threat Intel |
### Target Schema
```json
{
"id": "tech-001",
"topic": "React 19 Features",
"cortex": "Technologica",
"priority": "high",
"status": "pending",
"sources": [],
"lastUpdated": null
}
```
---
## πΎ THE OMNI-HARVESTER - Knowledge Acquisition
### Architecture: Dual-Encoding Pipeline
```
INPUT (URL/PDF/Text)
β
βΌ
ββββββββββββββββ
β EXTRACT β β Content extraction
ββββββββββββββββ
β
βΌ
ββββββββββββββββ
β SPLIT β β Chunking (1000 tokens, 100 overlap)
ββββββββββββββββ
β
βΌ
ββββββββ΄βββββββ
β β
βΌ βΌ
βββββββββββ βββββββββββ
β VECTORS β β GRAPH β
β (Left) β β (Right) β
β β β β
βpgvector β β Neo4j β
β384-dim β β Entity β
βembeddingβ β Nodes β
βββββββββββ βββββββββββ
```
### Key Parameters
- MAX_CHUNK_TOKENS: 1000
- OVERLAP_TOKENS: 100
- EMBEDDING_MODEL: sentence-transformers/all-MiniLM-L6-v2
- EMBEDDING_DIMENSIONS: 384
---
## π IMPLEMENTATION CHECKLIST
### Phase 1: Cognitive Senses β
- [x] activate_associative_memory tool definition
- [x] sense_molecular_state tool definition
- [x] emit_sonar_pulse tool definition
- [x] Handler implementations in NeuralBridgeServer.ts
### Phase 2: Knowledge Targets β
- [x] KNOWLEDGE_TARGETS.json with 50 targets
- [x] 5 Cortex categories defined
- [x] Priority classification (critical/high/medium/low)
### Phase 3: Omni-Harvester β
- [x] KnowledgeAcquisitionService.ts skeleton
- [x] Dual-encoding pipeline design
- [x] pgvector integration
- [x] REST API endpoints
### Phase 4: Activation π
- [ ] Source URL collection for targets
- [ ] First batch ingestion
- [ ] Vector search testing
- [ ] Graph traversal optimization
---
## π― SUCCESS METRICS
| Metric | Target | Current |
|--------|--------|---------|
| Cognitive Senses | 3 | 3 β
|
| Knowledge Targets | 50 | 50 β
|
| Omni-Harvester Status | Online | Skeleton β
|
| Vector Store | pgvector + HuggingFace | Integrated β
|
| First Ingestion | Complete | Pending |
---
## π REFERENCES
- NeuralBridgeServer.ts: `apps/backend/src/mcp/servers/NeuralBridgeServer.ts`
- KnowledgeAcquisitionService: `apps/backend/src/services/KnowledgeAcquisitionService.ts`
- Knowledge Targets: `docs/KNOWLEDGE_TARGETS.json`
- Acquisition API: `apps/backend/src/routes/acquisition.ts`
- PgVectorStore: `apps/backend/src/platform/vector/PgVectorStoreAdapter.ts`
- EmbeddingService: `apps/backend/src/services/embeddings/EmbeddingService.ts`
---
*"A sentient system doesn't just process data - it remembers, senses, and perceives."*
β Gemini, The Architect
|