# Top 10 Production Priorities (Availability-First) Context: - Scope reviewed: all nodes under `nodes/*` plus shared `nodes/generalFunctions/*`. - Target posture: keep runtime alive; emit `null`/degraded outputs instead of crashing. ## Priority List 1. Remove import-time executable code from machine group runtime module. - Why: `makeMachines()` runs at module load and can execute demo logic in production runtime. - Evidence: `nodes/machineGroupControl/src/specificClass.js:1294`, `nodes/machineGroupControl/src/specificClass.js:1399`. - Availability target: no side effects on `require`; test/demo code must be isolated from runtime path. 2. Guard `registerChild` in node wrappers to prevent null dereference crashes. - Why: multiple wrappers dereference `childObj.source` without checking child existence. - Evidence: `nodes/reactor/src/nodeClass.js:54`, `nodes/settler/src/nodeClass.js:39`, `nodes/valve/src/nodeClass.js:256`, `nodes/valveGroupControl/src/nodeClass.js:178`, `nodes/machineGroupControl/src/nodeClass.js:215`. - Availability target: if child missing, log warning and continue. 3. Harden shared child registration utility contract checks. - Why: shared helper destructures `child.config.*` without validation. - Evidence: `nodes/generalFunctions/src/helper/childRegistrationUtils.js:9`, `nodes/generalFunctions/src/helper/childRegistrationUtils.js:10`. - Availability target: reject invalid child payload with warning, no throw. 4. Add global input-handler error boundary pattern across nodes. - Why: many handlers do work without `try/catch`; one thrown error can bubble and destabilize node behavior. - Evidence: `nodes/measurement/src/nodeClass.js:156`, `nodes/valve/src/nodeClass.js:250`, `nodes/valveGroupControl/src/nodeClass.js:169`, `nodes/settler/src/nodeClass.js:32`. - Availability target: wrap topic routing; map failures to warning + safe `done(err)`/`done()` handling. 5. Normalize `done` callback handling for Node-RED compatibility. - Why: several nodes call `done()` unguarded; older/inconsistent runtime callbacks can fail. - Evidence: `nodes/measurement/src/nodeClass.js:167`, `nodes/valve/src/nodeClass.js:280`, `nodes/valveGroupControl/src/nodeClass.js:201`, `nodes/machineGroupControl/src/nodeClass.js:257`. - Availability target: `if (typeof done === 'function') done();` everywhere. 6. Fix reactor runtime routing and setup defects. - Why: `Temperature` topic routes to missing setter path and default reactor warning references wrong variable. - Evidence: `nodes/reactor/src/nodeClass.js:46`, `nodes/reactor/src/nodeClass.js:140`. - Availability target: unknown/unsupported control topics fail soft with warning; setup path cannot throw from bad references. 7. Fix valve mode-selection bug using undefined config source. - Why: `setMode` references `defaultConfig` instead of instance config; can throw or silently break mode changes. - Evidence: `nodes/valve/src/specificClass.js:142`. - Availability target: invalid mode inputs are rejected safely, valid mode changes deterministic. 8. Replace hard-throw chain semantics in measurement container with safe-return options. - Why: chain API currently throws for sequence misuse; upstream callers can crash control loops. - Evidence: `nodes/generalFunctions/src/measurements/MeasurementContainer.js:99`, `nodes/generalFunctions/src/measurements/MeasurementContainer.js:109`. - Availability target: invalid chain usage logs and returns no-op/null path in production mode. 9. Remove noisy console/debug/test logging from runtime paths. - Why: heavy `console.log/error` in control and shared code adds noise and can hide real failures. - Evidence: `nodes/reactor/src/nodeClass.js:58`, `nodes/measurement/src/nodeClass.js:90`, `nodes/pumpingStation/src/nodeClass.js:87`, `nodes/valve/src/specificClass.js:207`. - Availability target: use structured logger with levels; disable debug by default. 10. Standardize output contract for unchanged state to explicit `null` output. - Why: `formatMsg` returns `undefined` when no change; behavior differs by node send implementation. - Evidence: `nodes/generalFunctions/src/helper/outputUtils.js:37`, `nodes/generalFunctions/src/helper/outputUtils.js:62`. - Availability target: unchanged outputs always return `null` to keep port contract deterministic. ## Implementation Status - Implemented on 2026-02-19 in current session. - Verification: node test suites passed for modified runtime nodes (`measurement`, `reactor`, `valve`, `valveGroupControl`, `machineGroupControl`, `settler`, `pumpingStation`, `dashboardAPI`, `monster`, `rotatingMachine`). - Remaining follow-up items are tracked in `.agents/improvements/IMPROVEMENTS_BACKLOG.md`.