{"record":{"id":"b723799e8c638a11","repo":"ruvnet/ruflo","slug":"iot-cognitum-not-initialized-run-iot-register-f","errorCode":null,"errorMessage":"IoT Cognitum not initialized. Run \"iot register\" first.","messagePattern":"IoT Cognitum not initialized\\. Run \"iot register\" first\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/plugin-iot-cognitum/src/cli-commands.ts","lineNumber":10,"sourceCode":"import type { CLICommandDefinition, PluginContext } from '@claude-flow/shared/src/plugin-interface.js';\nimport type { IoTCoordinator } from './application/iot-coordinator.js';\nimport { getDeviceTrustLabel } from './domain/entities/device-trust-level.js';\n\ntype CoordinatorGetter = () => IoTCoordinator | null;\ntype ContextGetter = () => PluginContext | null;\n\nfunction requireCoordinator(get: CoordinatorGetter): IoTCoordinator {\n  const c = get();\n  if (!c) throw new Error('IoT Cognitum not initialized. Run \"iot register\" first.');\n  return c;\n}\n\nfunction parseVector(raw: string): number[] {\n  const parsed = JSON.parse(raw) as unknown;\n  if (!Array.isArray(parsed) || !parsed.every((n) => typeof n === 'number')) {\n    throw new Error(`--vector must be a JSON array of numbers, got: ${raw}`);\n  }\n  return parsed as number[];\n}\n\nexport function createCliCommands(\n  getCoordinator: CoordinatorGetter,\n  _getContext: ContextGetter,\n): CLICommandDefinition[] {\n  return [\n    {\n      name: 'iot init',","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/plugin-iot-cognitum/src/cli-commands.ts#L1-L28","documentation":"CLI-level precondition guard for the IoT Cognitum plugin: operational iot commands obtain the coordinator through requireCoordinator(get), which throws when the plugin's IoTCoordinator is null — IoT Cognitum was never initialized in this project. The message names the remedy: run iot register first.","triggerScenarios":"Running any operational iot command (ingest, mesh, fleet/device commands) before the one-time iot init plus iot register setup completed successfully in the same working directory.","commonSituations":"Fresh clone or new machine without IoT state; the plugin failed to load at startup; running the CLI from a different directory so the per-project state is not found; init step skipped in automation scripts.","solutions":["Run `iot register` (after `iot init` if not yet configured) and re-run the command","Verify the IoT plugin is loaded and healthy via plugin status or init output","Run the CLI in the project directory where the IoT state was created"],"exampleFix":"# before\n$ iot ingest --device-id seed-42 --vector '[0.1,0.2]'\n# Error: IoT Cognitum not initialized. Run \"iot register\" first.\n\n# after\n$ iot register\n$ iot ingest --device-id seed-42 --vector '[0.1,0.2]'","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\niot init\niot register || exit 1\niot ingest --device-id seed-42 --vector '[0.1,0.2]'","typeGuard":null,"tryCatchPattern":"try {\n  await runCli(['iot', 'ingest', ...args]);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('IoT Cognitum not initialized')) {\n    await runCli(['iot', 'register']); // one-time bootstrap, then retry\n  } else throw e;\n}","preventionTips":["Make `iot init` plus `iot register` the first commands of any IoT automation script","Run iot commands from the project directory that owns the IoT state","Check plugin load status after upgrades before invoking iot commands"],"tags":["cli","iot","initialization","setup-required"],"backgroundTag":"service-not-initialized","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}