{"record":{"id":"f7768eed5f8f8dce","repo":"affaan-m/ECC","slug":"watch-needs-a-positive-seconds-value","errorCode":null,"errorMessage":"--watch needs a positive seconds value","messagePattern":"--watch needs a positive seconds value","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/proximity-tick.js","lineNumber":31,"sourceCode":" * Messages are internal ECC agent-to-agent coordination (the ecc2 `messages`\n * table) — not any external channel.\n */\n\nconst { resolveControlPaneConfig, buildControlPaneSnapshot } = require('./lib/control-pane/state');\nconst { createProximityDispatcher, runProximityTick } = require('./lib/control-pane/proximity');\nconst { createEccMessageSink } = require('./lib/control-pane/message-sink');\n\nfunction parseArgs(argv) {\n  const args = argv.slice(2);\n  const parsed = { watchSec: 0, dryRun: false, json: false, help: false, dbPath: null, stateDbPath: null };\n  for (let i = 0; i < args.length; i += 1) {\n    const a = args[i];\n    if (a === '--help' || a === '-h') parsed.help = true;\n    else if (a === '--dry-run') parsed.dryRun = true;\n    else if (a === '--json') parsed.json = true;\n    else if (a === '--watch') {\n      const v = Number.parseInt(args[i + 1], 10);\n      if (!Number.isInteger(v) || v <= 0) throw new Error('--watch needs a positive seconds value');\n      parsed.watchSec = v;\n      i += 1;\n    } else if (a === '--db') {\n      parsed.dbPath = args[i + 1];\n      i += 1;\n    } else if (a === '--state-db') {\n      parsed.stateDbPath = args[i + 1];\n      i += 1;\n    } else {\n      throw new Error(`Unknown argument: ${a}`);\n    }\n  }\n  return parsed;\n}\n\nfunction showHelp() {\n  console.log(\n    [","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/proximity-tick.js#L13-L49","documentation":"Thrown by proximity-tick's parseArgs when `--watch` is given a value that is not a positive integer. The watch loop re-scans agent proximity on a fixed cadence, so a zero/negative/non-integer interval is meaningless and rejected up front. `Number.parseInt` plus `Number.isInteger` and `> 0` is the gate.","triggerScenarios":"`--watch 0`, `--watch -5`, `--watch 1.5`, `--watch abc`, `--watch` with no following token (parseInt → NaN), or an env-derived cadence that came through empty.","commonSituations":"User sets `--watch 0` thinking it disables watch (it doesn't — omit the flag for a one-shot); shell variable for seconds expanded to empty; decimal seconds intended but only ints accepted.","solutions":["Pass a positive whole second count: `--watch 30`.","For a one-shot run, omit --watch entirely (watchSec defaults to 0, meaning no loop).","Validate env-supplied cadence: integer > 0, else fall back to a sensible default."],"exampleFix":"# before\nnode scripts/proximity-tick.js --watch 0\n# after — one shot (no flag)\nnode scripts/proximity-tick.js\n# or — loop every 30s\nnode scripts/proximity-tick.js --watch 30","handlingStrategy":"validation","validationCode":"function parseWatchSeconds(raw) {\n  const v = Number.parseInt(raw, 10);\n  if (!Number.isInteger(v) || v <= 0) {\n    throw new Error('--watch needs a positive seconds value');\n  }\n  return v;\n}","typeGuard":"function isPositiveIntSeconds(value) {\n  return typeof value === 'string' && /^[1-9]\\d*$/.test(value.trim());\n}","tryCatchPattern":"try {\n  parseArgs(process.argv);\n} catch (err) {\n  if (err.message === '--watch needs a positive seconds value') {\n    console.error('Pass a positive whole-second count, e.g. --watch 30. Omit --watch for a one-shot run.');\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Omit --watch for a one-shot scan; do not pass --watch 0 to disable.","Pass a positive integer (>= 1) of seconds.","Validate env-derived cadence before forwarding."],"tags":["cli","argument-validation","proximity-tick","watch"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}