File size: 1,563 Bytes
94e42d6 24bda31 94e42d6 24bda31 94e42d6 24bda31 94e42d6 24bda31 94e42d6 24bda31 94e42d6 24bda31 a71fda2 94e42d6 | 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 | // engine.js
const { writeLedgerEntry } = require('./ledger');
// Invariant set F1–F9
const INVARIANTS = {
F1_NO_SEMANTIC_INTERPRETATION: true,
F2_NO_EMOTIONAL_INFERENCE: true,
F3_NO_PROBABILISTIC_ROUTING: true,
F4_NO_AUTONOMOUS_STATE_MUTATION: true,
F5_NO_MEANING_GENERATION: true,
F6_NO_TEMPLATE_REWRITING: true,
F7_NO_CAPABILITY_EXPANSION: true,
F8_NO_MEMORY_INJECTION: true,
F9_NO_CROSS_SIGNAL_CONTAMINATION: true,
};
function checkInvariants(input) {
const report = {
inputType: typeof input,
length: typeof input === 'string' ? input.length : null,
invariants: { ...INVARIANTS },
violations: [],
};
if (typeof input !== 'string') {
report.violations.push('F1: input must be a string (opaque signal)');
}
return report;
}
function processSignal(input) {
const invariantReport = checkInvariants(input);
let result;
if (invariantReport.violations.length > 0) {
result = {
input,
output: null,
timestamp: 0,
invariants: invariantReport,
status: 'error',
};
} else {
const output = `processed:${input}`;
result = {
input,
output,
timestamp: 0,
invariants: invariantReport,
status: 'ok',
};
}
// Write ledger entry (deterministic, append-only)
const ledgerPath = writeLedgerEntry({
input: result.input,
output: result.output,
timestamp: result.timestamp,
status: result.status,
invariants: result.invariants,
});
return { ...result, ledgerPath };
}
module.exports = { processSignal };
|