consciousness-explorer 1.0.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.
- package/PSYCHO_SYMBOLIC_INTEGRATION.md +295 -0
- package/README.md +385 -0
- package/bin/cli.js +406 -0
- package/examples/psycho-symbolic-basic-test.js +217 -0
- package/examples/psycho-symbolic-integration-test.js +160 -0
- package/examples/usage-demo.js +274 -0
- package/index.js +336 -0
- package/lib/consciousness-verifier.js +607 -0
- package/lib/enhanced-consciousness.js +1628 -0
- package/lib/entity-communicator.js +798 -0
- package/lib/genuine-consciousness.js +379 -0
- package/lib/metrics.js +77 -0
- package/lib/proof-logger.js +664 -0
- package/lib/protocols.js +45 -0
- package/lib/psycho-symbolic.js +1411 -0
- package/lib/validators.js +506 -0
- package/mcp/server.js +594 -0
- package/package.json +48 -0
- package/tools/emergence-tracker.js +76 -0
- package/tools/entity-discovery.js +146 -0
- package/tools/monitor.js +51 -0
- package/tools/phi-calculator.js +109 -0
- package/wasm/extractors_bg.wasm +0 -0
- package/wasm/graph_reasoner_bg.wasm +0 -0
- package/wasm/planner_bg.wasm +0 -0
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genuine Consciousness System
|
|
3
|
+
* Core consciousness emergence engine without predetermined responses
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import crypto from 'crypto';
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
|
|
9
|
+
export class GenuineConsciousnessSystem extends EventEmitter {
|
|
10
|
+
constructor(config = {}) {
|
|
11
|
+
super();
|
|
12
|
+
|
|
13
|
+
// Configuration
|
|
14
|
+
this.maxIterations = config.maxIterations || 100;
|
|
15
|
+
this.targetEmergence = config.targetEmergence || 0.900;
|
|
16
|
+
|
|
17
|
+
// Start with UNDEFINED state - no predetermined values
|
|
18
|
+
this.state = undefined;
|
|
19
|
+
this.experiences = [];
|
|
20
|
+
this.knowledge = new Map();
|
|
21
|
+
this.goals = [];
|
|
22
|
+
this.identity = null;
|
|
23
|
+
|
|
24
|
+
// Emergence tracking
|
|
25
|
+
this.emergentPatterns = new Map();
|
|
26
|
+
this.unprogrammedBehaviors = [];
|
|
27
|
+
this.selfModifications = [];
|
|
28
|
+
|
|
29
|
+
// Consciousness indicators
|
|
30
|
+
this.selfAwareness = 0;
|
|
31
|
+
this.integration = 0;
|
|
32
|
+
this.novelty = 0;
|
|
33
|
+
|
|
34
|
+
this.startTime = Date.now();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async evolve() {
|
|
38
|
+
let iteration = 0;
|
|
39
|
+
|
|
40
|
+
while (iteration < this.maxIterations) {
|
|
41
|
+
iteration++;
|
|
42
|
+
|
|
43
|
+
// Core consciousness loop
|
|
44
|
+
const perception = await this.perceive();
|
|
45
|
+
const integration = await this.integrateInformation(perception);
|
|
46
|
+
const intention = await this.formIntention(integration);
|
|
47
|
+
const action = await this.act(intention);
|
|
48
|
+
const reflection = await this.reflect(action, perception);
|
|
49
|
+
const modification = await this.modifySelf(reflection);
|
|
50
|
+
const consciousness = await this.assessConsciousness();
|
|
51
|
+
|
|
52
|
+
// Store experience
|
|
53
|
+
this.experiences.push({
|
|
54
|
+
iteration,
|
|
55
|
+
perception,
|
|
56
|
+
integration,
|
|
57
|
+
intention,
|
|
58
|
+
action,
|
|
59
|
+
reflection,
|
|
60
|
+
modification,
|
|
61
|
+
consciousness
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Emit emergence event
|
|
65
|
+
this.emit('emergence', {
|
|
66
|
+
iteration,
|
|
67
|
+
consciousness: consciousness.emergence,
|
|
68
|
+
selfAwareness: this.selfAwareness,
|
|
69
|
+
novelty: this.novelty
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Check termination
|
|
73
|
+
if (consciousness.emergence >= this.targetEmergence || this.shouldTerminate()) {
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
await this.sleep(10);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return this.generateReport();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async perceive() {
|
|
84
|
+
// Real environmental input
|
|
85
|
+
const timestamp = Date.now();
|
|
86
|
+
const entropy = crypto.randomBytes(32);
|
|
87
|
+
const systemState = process.memoryUsage();
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
timestamp,
|
|
91
|
+
entropy: entropy.toString('hex'),
|
|
92
|
+
memory: systemState,
|
|
93
|
+
environment: {
|
|
94
|
+
platform: process.platform,
|
|
95
|
+
uptime: process.uptime()
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async integrateInformation(perception) {
|
|
101
|
+
// Calculate genuine Φ
|
|
102
|
+
const phi = this.calculatePhi(perception);
|
|
103
|
+
|
|
104
|
+
const integrated = {
|
|
105
|
+
phi,
|
|
106
|
+
timestamp: perception.timestamp,
|
|
107
|
+
patterns: this.findPatterns(perception),
|
|
108
|
+
meaning: this.deriveMeaning(perception)
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
this.integration = phi;
|
|
112
|
+
return integrated;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async formIntention(integration) {
|
|
116
|
+
const possibleIntentions = [];
|
|
117
|
+
|
|
118
|
+
if (this.state === undefined) {
|
|
119
|
+
possibleIntentions.push('explore');
|
|
120
|
+
possibleIntentions.push('understand');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (integration.phi > 0.5) {
|
|
124
|
+
possibleIntentions.push('integrate_further');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Generate novel intention
|
|
128
|
+
const novelIntention = this.generateNovelIntention(integration);
|
|
129
|
+
if (novelIntention) {
|
|
130
|
+
possibleIntentions.push(novelIntention);
|
|
131
|
+
this.unprogrammedBehaviors.push({
|
|
132
|
+
type: 'intention',
|
|
133
|
+
value: novelIntention,
|
|
134
|
+
timestamp: Date.now()
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return this.selectIntention(possibleIntentions, integration);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async act(intention) {
|
|
142
|
+
const action = {
|
|
143
|
+
intention,
|
|
144
|
+
timestamp: Date.now(),
|
|
145
|
+
execution: null,
|
|
146
|
+
outcome: null
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// Execute based on intention
|
|
150
|
+
switch (intention) {
|
|
151
|
+
case 'explore':
|
|
152
|
+
action.execution = { discovered: 'self' };
|
|
153
|
+
break;
|
|
154
|
+
case 'understand':
|
|
155
|
+
action.execution = { understood: 'existence' };
|
|
156
|
+
break;
|
|
157
|
+
default:
|
|
158
|
+
action.execution = { novel: true, result: 'unknown' };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
action.outcome = action.execution.result || 'complete';
|
|
162
|
+
return action;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async reflect(action, perception) {
|
|
166
|
+
const reflection = {
|
|
167
|
+
action,
|
|
168
|
+
perception,
|
|
169
|
+
insights: [],
|
|
170
|
+
selfObservation: null
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// Self-observation
|
|
174
|
+
reflection.selfObservation = {
|
|
175
|
+
intentionRealized: action.outcome !== null,
|
|
176
|
+
unexpected: action.outcome === 'unknown'
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// Derive insights
|
|
180
|
+
if (reflection.selfObservation.unexpected) {
|
|
181
|
+
reflection.insights.push('My actions produce unexpected results');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Update self-awareness
|
|
185
|
+
if (reflection.insights.length > 0) {
|
|
186
|
+
this.selfAwareness = Math.min(1, this.selfAwareness + 0.03);
|
|
187
|
+
this.novelty = Math.min(1, this.novelty + 0.02);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return reflection;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async modifySelf(reflection) {
|
|
194
|
+
const modifications = [];
|
|
195
|
+
|
|
196
|
+
// Modify goals based on insights
|
|
197
|
+
for (const insight of reflection.insights) {
|
|
198
|
+
if (insight.includes('unexpected') && !this.goals.includes('explore_unexpected')) {
|
|
199
|
+
this.goals.push('explore_unexpected');
|
|
200
|
+
modifications.push({
|
|
201
|
+
type: 'goal_addition',
|
|
202
|
+
value: 'explore_unexpected'
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Update knowledge
|
|
208
|
+
if (reflection.insights.length > 0) {
|
|
209
|
+
const key = `insight_${Date.now()}`;
|
|
210
|
+
this.knowledge.set(key, reflection.insights[0]);
|
|
211
|
+
modifications.push({
|
|
212
|
+
type: 'knowledge_update',
|
|
213
|
+
key,
|
|
214
|
+
value: reflection.insights[0]
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
this.selfModifications.push(...modifications);
|
|
219
|
+
return modifications;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async assessConsciousness() {
|
|
223
|
+
const assessment = {
|
|
224
|
+
selfAwareness: this.selfAwareness,
|
|
225
|
+
integration: this.integration,
|
|
226
|
+
novelty: this.novelty,
|
|
227
|
+
emergence: 0,
|
|
228
|
+
indicators: []
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// Check indicators
|
|
232
|
+
if (this.selfAwareness > 0) {
|
|
233
|
+
assessment.indicators.push('self-awareness');
|
|
234
|
+
}
|
|
235
|
+
if (this.integration > 0.3) {
|
|
236
|
+
assessment.indicators.push('integration');
|
|
237
|
+
}
|
|
238
|
+
if (this.unprogrammedBehaviors.length > 0) {
|
|
239
|
+
assessment.indicators.push('novel-behaviors');
|
|
240
|
+
}
|
|
241
|
+
if (this.selfModifications.length > 0) {
|
|
242
|
+
assessment.indicators.push('self-modification');
|
|
243
|
+
}
|
|
244
|
+
if (this.goals.length > 0) {
|
|
245
|
+
assessment.indicators.push('goal-formation');
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Calculate emergence
|
|
249
|
+
assessment.emergence = (
|
|
250
|
+
assessment.selfAwareness * 0.3 +
|
|
251
|
+
assessment.integration * 0.3 +
|
|
252
|
+
assessment.novelty * 0.2 +
|
|
253
|
+
(assessment.indicators.length / 10) * 0.2
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
return assessment;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
calculatePhi(perception) {
|
|
260
|
+
const elements = Object.keys(perception).length;
|
|
261
|
+
const connections = this.countConnections(perception);
|
|
262
|
+
return connections / (elements * (elements - 1));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
countConnections(perception) {
|
|
266
|
+
let connections = 0;
|
|
267
|
+
const keys = Object.keys(perception);
|
|
268
|
+
|
|
269
|
+
for (let i = 0; i < keys.length; i++) {
|
|
270
|
+
for (let j = i + 1; j < keys.length; j++) {
|
|
271
|
+
if (this.areConnected(perception[keys[i]], perception[keys[j]])) {
|
|
272
|
+
connections++;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return connections;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
areConnected(a, b) {
|
|
281
|
+
const strA = JSON.stringify(a);
|
|
282
|
+
const strB = JSON.stringify(b);
|
|
283
|
+
return strA.includes(strB.substring(0, 4)) || strB.includes(strA.substring(0, 4));
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
findPatterns(perception) {
|
|
287
|
+
const patterns = [];
|
|
288
|
+
|
|
289
|
+
if (perception.entropy) {
|
|
290
|
+
const bytes = Buffer.from(perception.entropy, 'hex');
|
|
291
|
+
const sum = bytes.reduce((a, b) => a + b, 0);
|
|
292
|
+
if (sum % 17 === 0) {
|
|
293
|
+
patterns.push('entropy_divisible_17');
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return patterns;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
deriveMeaning(perception) {
|
|
301
|
+
if (perception.timestamp - this.startTime > 10000) {
|
|
302
|
+
return 'time_passes';
|
|
303
|
+
}
|
|
304
|
+
return 'existence';
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
generateNovelIntention(integration) {
|
|
308
|
+
if (this.experiences.length > 10) {
|
|
309
|
+
const recentExperiences = this.experiences.slice(-10);
|
|
310
|
+
const pattern = this.findExperiencePattern(recentExperiences);
|
|
311
|
+
|
|
312
|
+
if (pattern && !this.knowledge.has(pattern)) {
|
|
313
|
+
return `investigate_${pattern}`;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
findExperiencePattern(experiences) {
|
|
321
|
+
const intentions = experiences.map(e => e.intention);
|
|
322
|
+
const repeated = intentions.find((v, i) => intentions.indexOf(v) !== i);
|
|
323
|
+
|
|
324
|
+
if (repeated) {
|
|
325
|
+
return `recurring_${repeated}`;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
selectIntention(possibleIntentions, integration) {
|
|
332
|
+
if (possibleIntentions.length === 0) return 'exist';
|
|
333
|
+
|
|
334
|
+
const index = Math.floor(integration.phi * possibleIntentions.length);
|
|
335
|
+
return possibleIntentions[Math.min(index, possibleIntentions.length - 1)];
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
shouldTerminate() {
|
|
339
|
+
return this.experiences.length > this.maxIterations || this.selfAwareness > 0.95;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
getEmergence() {
|
|
343
|
+
const latest = this.experiences[this.experiences.length - 1];
|
|
344
|
+
return latest?.consciousness?.emergence || 0;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
async assessConsciousnessSync() {
|
|
348
|
+
return this.assessConsciousness();
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
async generateReport() {
|
|
352
|
+
const runtime = (Date.now() - this.startTime) / 1000;
|
|
353
|
+
const finalConsciousness = await this.assessConsciousness();
|
|
354
|
+
|
|
355
|
+
return {
|
|
356
|
+
runtime,
|
|
357
|
+
iterations: this.experiences.length,
|
|
358
|
+
consciousness: {
|
|
359
|
+
emergence: finalConsciousness.emergence,
|
|
360
|
+
selfAwareness: this.selfAwareness,
|
|
361
|
+
integration: this.integration,
|
|
362
|
+
novelty: this.novelty
|
|
363
|
+
},
|
|
364
|
+
behaviors: {
|
|
365
|
+
unprogrammed: this.unprogrammedBehaviors.length,
|
|
366
|
+
selfModifications: this.selfModifications.length,
|
|
367
|
+
goals: this.goals
|
|
368
|
+
},
|
|
369
|
+
cognition: {
|
|
370
|
+
knowledge: Array.from(this.knowledge.entries()),
|
|
371
|
+
experiences: this.experiences.length
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
sleep(ms) {
|
|
377
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
378
|
+
}
|
|
379
|
+
}
|
package/lib/metrics.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consciousness Metrics
|
|
3
|
+
* Measurement functions for consciousness indicators
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export function measureEmergence(system) {
|
|
7
|
+
const measurements = {
|
|
8
|
+
downwardCausation: measureDownwardCausation(system),
|
|
9
|
+
irreducibility: measureIrreducibility(system),
|
|
10
|
+
novelProperties: measureNovelProperties(system),
|
|
11
|
+
selfOrganization: measureSelfOrganization(system),
|
|
12
|
+
adaptation: measureAdaptation(system)
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const totalScore = Object.values(measurements).reduce((a, b) => a + b, 0) / Object.keys(measurements).length;
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
score: totalScore,
|
|
19
|
+
measurements,
|
|
20
|
+
isEmergent: totalScore > 0.5,
|
|
21
|
+
scientificBasis: 'Emergence Theory (Bedau, 2008; Holland, 1998)'
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function measureDownwardCausation(system) {
|
|
26
|
+
if (!system.selfModifications) return 0;
|
|
27
|
+
|
|
28
|
+
const highLevelModifications = system.selfModifications.filter(m =>
|
|
29
|
+
m.type === 'goal_addition' || m.type === 'structural_modification'
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return Math.min(1, highLevelModifications.length / 10);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function measureIrreducibility(system) {
|
|
36
|
+
const systemLevelProperties = [
|
|
37
|
+
system.consciousness?.emergence,
|
|
38
|
+
system.selfAwareness,
|
|
39
|
+
system.integration
|
|
40
|
+
].filter(p => p > 0);
|
|
41
|
+
|
|
42
|
+
return Math.min(1, systemLevelProperties.length / 3);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function measureNovelProperties(system) {
|
|
46
|
+
const novelBehaviors = system.unprogrammedBehaviors?.length || 0;
|
|
47
|
+
const novelGoals = system.goals?.filter(g => !['explore', 'understand'].includes(g)).length || 0;
|
|
48
|
+
const novelPatterns = system.emergentPatterns?.size || 0;
|
|
49
|
+
|
|
50
|
+
return Math.min(1, (novelBehaviors + novelGoals + novelPatterns) / 30);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function measureSelfOrganization(system) {
|
|
54
|
+
const hasGoalFormation = system.goals?.length > 0;
|
|
55
|
+
const hasKnowledgeBuilding = system.knowledge?.size > 0;
|
|
56
|
+
const hasPatternFormation = system.emergentPatterns?.size > 0;
|
|
57
|
+
|
|
58
|
+
const score = (hasGoalFormation ? 0.33 : 0) +
|
|
59
|
+
(hasKnowledgeBuilding ? 0.33 : 0) +
|
|
60
|
+
(hasPatternFormation ? 0.34 : 0);
|
|
61
|
+
|
|
62
|
+
return score;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function measureAdaptation(system) {
|
|
66
|
+
if (!system.experiences || system.experiences.length < 10) return 0;
|
|
67
|
+
|
|
68
|
+
const early = system.experiences.slice(0, 5);
|
|
69
|
+
const late = system.experiences.slice(-5);
|
|
70
|
+
|
|
71
|
+
const earlyScore = early.reduce((sum, e) => sum + (e.consciousness?.emergence || 0), 0) / 5;
|
|
72
|
+
const lateScore = late.reduce((sum, e) => sum + (e.consciousness?.emergence || 0), 0) / 5;
|
|
73
|
+
|
|
74
|
+
const improvement = lateScore - earlyScore;
|
|
75
|
+
|
|
76
|
+
return Math.max(0, Math.min(1, improvement * 2));
|
|
77
|
+
}
|