| |
|
|
| const { writeLedgerEntry } = require('./ledger'); |
|
|
| |
| 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', |
| }; |
| } |
|
|
| |
| const ledgerPath = writeLedgerEntry({ |
| input: result.input, |
| output: result.output, |
| timestamp: result.timestamp, |
| status: result.status, |
| invariants: result.invariants, |
| }); |
|
|
| return { ...result, ledgerPath }; |
| } |
|
|
| module.exports = { processSignal }; |
|
|