Create sei.js
Browse files
sei.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// sei.js
|
| 2 |
+
// Signal Ecology Integration (SEI)
|
| 3 |
+
// Deterministic ecological index for Meaning Units (MU)
|
| 4 |
+
|
| 5 |
+
const fs = require('fs');
|
| 6 |
+
const path = require('path');
|
| 7 |
+
|
| 8 |
+
const SEI_PATH = path.join(__dirname, 'sei.json');
|
| 9 |
+
|
| 10 |
+
// Ensure SEI index exists
|
| 11 |
+
function ensureSEI() {
|
| 12 |
+
if (!fs.existsSync(SEI_PATH)) {
|
| 13 |
+
fs.writeFileSync(SEI_PATH, JSON.stringify({
|
| 14 |
+
seiVersion: "v0.1",
|
| 15 |
+
species: []
|
| 16 |
+
}, null, 2));
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
// Register MU as a species in the ecology
|
| 21 |
+
function registerSpecies(mu) {
|
| 22 |
+
ensureSEI();
|
| 23 |
+
|
| 24 |
+
const sei = JSON.parse(fs.readFileSync(SEI_PATH, 'utf8'));
|
| 25 |
+
|
| 26 |
+
// Species entry (deterministic, no semantics)
|
| 27 |
+
const speciesEntry = {
|
| 28 |
+
id: mu.id,
|
| 29 |
+
length: mu.payload.length,
|
| 30 |
+
type: mu.payload.type,
|
| 31 |
+
compiledAt: mu.compiledAt,
|
| 32 |
+
ecologicalClass: "meaning-unit", // substrate-level class
|
| 33 |
+
driftPotential: 0, // DSLO v0: no drift allowed
|
| 34 |
+
stability: "deterministic"
|
| 35 |
+
};
|
| 36 |
+
|
| 37 |
+
sei.species.push(speciesEntry);
|
| 38 |
+
|
| 39 |
+
fs.writeFileSync(SEI_PATH, JSON.stringify(sei, null, 2));
|
| 40 |
+
|
| 41 |
+
return sei;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
module.exports = { registerSpecies };
|