lockdown audit done

This commit is contained in:
legop3
2026-05-10 01:55:32 -04:00
parent a497c8a630
commit e58e5503e8
4 changed files with 57 additions and 2 deletions
+8
View File
@@ -6,6 +6,8 @@ const io = require('../../globals/io');
const logger = require('../../globals/logger').child('liftService'); const logger = require('../../globals/logger').child('liftService');
const { loadConfig } = require('../../helpers/configLoader'); const { loadConfig } = require('../../helpers/configLoader');
const { isVerified } = require('../verificationService'); const { isVerified } = require('../verificationService');
const { getMode, MODES } = require('../modeManager');
const { isLockdownAdmin } = require('../roleService');
const { const {
homeAssistantEvents, homeAssistantEvents,
getRawEntitySnapshot, getRawEntitySnapshot,
@@ -178,6 +180,9 @@ homeAssistantEvents.on('status', emitUpdate);
io.on('connection', (socket) => { io.on('connection', (socket) => {
socket.on('lift:up', async (_, cb = () => {}) => { socket.on('lift:up', async (_, cb = () => {}) => {
try { try {
if (getMode() === MODES.LOCKDOWN && !isLockdownAdmin(socket)) {
throw new Error('Server in lockdown');
}
if (!isVerified(socket)) throw new Error('VIP verification required'); if (!isVerified(socket)) throw new Error('VIP verification required');
const resp = await moveUp(socket.id || 'socket'); const resp = await moveUp(socket.id || 'socket');
cb({ success: true, ...resp }); cb({ success: true, ...resp });
@@ -188,6 +193,9 @@ io.on('connection', (socket) => {
socket.on('lift:down', async (_, cb = () => {}) => { socket.on('lift:down', async (_, cb = () => {}) => {
try { try {
if (getMode() === MODES.LOCKDOWN && !isLockdownAdmin(socket)) {
throw new Error('Server in lockdown');
}
if (!isVerified(socket)) throw new Error('VIP verification required'); if (!isVerified(socket)) throw new Error('VIP verification required');
const resp = await moveDown(socket.id || 'socket'); const resp = await moveDown(socket.id || 'socket');
cb({ success: true, ...resp }); cb({ success: true, ...resp });
@@ -7,6 +7,7 @@ const io = require('../../globals/io');
const logger = require('../../globals/logger').child('llmCommentary'); const logger = require('../../globals/logger').child('llmCommentary');
const { loadConfig } = require('../../helpers/configLoader'); const { loadConfig } = require('../../helpers/configLoader');
const { getRole, roleEvents } = require('../roleService'); const { getRole, roleEvents } = require('../roleService');
const { getMode, MODES, modeEvents } = require('../modeManager');
const roverManager = require('../roverManager'); const roverManager = require('../roverManager');
const { getActiveDrivers } = require('../turnService'); const { getActiveDrivers } = require('../turnService');
const { getNickname } = require('../nicknameService'); const { getNickname } = require('../nicknameService');
@@ -258,7 +259,9 @@ const runner = createRunner({
updateStatus, updateStatus,
}); });
if (enabled && model && ollamaUrl) { const canRunFromConfig = enabled && model && ollamaUrl;
if (canRunFromConfig) {
registerHooks({ registerHooks({
io, io,
roleEvents, roleEvents,
@@ -272,7 +275,22 @@ if (enabled && model && ollamaUrl) {
onRoverRemoved: snapshotEngine.removeRover, onRoverRemoved: snapshotEngine.removeRover,
}); });
const mode = getMode();
if (mode === MODES.LOCKDOWN) {
runner.stop('paused during lockdown');
logger.info('LLM commentary paused due to lockdown mode');
} else {
runner.start(); runner.start();
}
modeEvents.on('change', (nextMode) => {
if (nextMode === MODES.LOCKDOWN) {
runner.stop('paused during lockdown');
logger.info('LLM commentary paused due to lockdown mode');
return;
}
runner.start();
});
} else { } else {
const disabledReason = !enabled const disabledReason = !enabled
? 'llmCommentary.enabled is false' ? 'llmCommentary.enabled is false'
@@ -47,6 +47,21 @@ function createRunner(deps) {
scheduleNextTick(runTick, 0); scheduleNextTick(runTick, 0);
} }
function stop(reason = 'stopped') {
if (runtime.timer) {
clearTimeout(runtime.timer);
runtime.timer = null;
}
updatePhase('paused', {
running: false,
inFlight: false,
currentRunId: null,
nextRunAt: null,
lastOutcome: 'paused',
lastReason: reason,
});
}
function clearRuntimeHistory() { function clearRuntimeHistory() {
runtime.contextResetAt = Date.now(); runtime.contextResetAt = Date.now();
runtime.clearCount += 1; runtime.clearCount += 1;
@@ -331,6 +346,7 @@ function createRunner(deps) {
return { return {
start, start,
stop,
runTick, runTick,
clearRuntimeHistory, clearRuntimeHistory,
wakeForDriverActivity: () => wakeForDriverActivity(runTick), wakeForDriverActivity: () => wakeForDriverActivity(runTick),
+13
View File
@@ -6,6 +6,8 @@ const io = require('../../globals/io');
const logger = require('../../globals/logger').child('neatoService'); const logger = require('../../globals/logger').child('neatoService');
const { loadConfig } = require('../../helpers/configLoader'); const { loadConfig } = require('../../helpers/configLoader');
const { isVerified } = require('../verificationService'); const { isVerified } = require('../verificationService');
const { getMode, MODES } = require('../modeManager');
const { isLockdownAdmin } = require('../roleService');
const { createLidarRuntime } = require('./lidarRuntime'); const { createLidarRuntime } = require('./lidarRuntime');
const { const {
homeAssistantEvents, homeAssistantEvents,
@@ -315,8 +317,15 @@ if (lidarRuntime) {
} }
io.on('connection', (socket) => { io.on('connection', (socket) => {
function assertLockdownAccess() {
if (getMode() === MODES.LOCKDOWN && !isLockdownAdmin(socket)) {
throw new Error('Server in lockdown');
}
}
socket.on('neato:start', async (_, cb = () => {}) => { socket.on('neato:start', async (_, cb = () => {}) => {
try { try {
assertLockdownAccess();
if (!isVerified(socket)) { if (!isVerified(socket)) {
throw new Error('VIP verification required'); throw new Error('VIP verification required');
} }
@@ -329,6 +338,7 @@ io.on('connection', (socket) => {
socket.on('neato:sendHome', async (_, cb = () => {}) => { socket.on('neato:sendHome', async (_, cb = () => {}) => {
try { try {
assertLockdownAccess();
if (!isVerified(socket)) { if (!isVerified(socket)) {
throw new Error('VIP verification required'); throw new Error('VIP verification required');
} }
@@ -341,6 +351,7 @@ io.on('connection', (socket) => {
socket.on('neato:locate', async (_, cb = () => {}) => { socket.on('neato:locate', async (_, cb = () => {}) => {
try { try {
assertLockdownAccess();
if (!isVerified(socket)) { if (!isVerified(socket)) {
throw new Error('VIP verification required'); throw new Error('VIP verification required');
} }
@@ -353,6 +364,7 @@ io.on('connection', (socket) => {
socket.on('neato:clearErrors', async (_, cb = () => {}) => { socket.on('neato:clearErrors', async (_, cb = () => {}) => {
try { try {
assertLockdownAccess();
if (!isVerified(socket)) { if (!isVerified(socket)) {
throw new Error('VIP verification required'); throw new Error('VIP verification required');
} }
@@ -365,6 +377,7 @@ io.on('connection', (socket) => {
socket.on('neato:powerCycle', async (_, cb = () => {}) => { socket.on('neato:powerCycle', async (_, cb = () => {}) => {
try { try {
assertLockdownAccess();
if (!isVerified(socket)) { if (!isVerified(socket)) {
throw new Error('VIP verification required'); throw new Error('VIP verification required');
} }