{"record":{"id":"a3edc957878db349","repo":"ruvnet/ruflo","slug":"invalid-apsc-role","errorCode":null,"errorMessage":"invalid APSC role","messagePattern":"invalid APSC role","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/services/pheromone-adaptive.ts","lineNumber":162,"sourceCode":"function counts(state: ApscState): { activeAgents: number; suspendedAgents: number } {\n  const values = Object.values(state.agents);\n  return {\n    activeAgents: values.filter((agent) => agent.status === 'active').length,\n    suspendedAgents: values.filter((agent) => agent.status === 'suspended').length,\n  };\n}\n\nfunction protectedRole(state: ApscState, role: string): boolean {\n  return state.config.protectedRoles.includes(role.toLowerCase());\n}\n\nexport function recordApscSignal(\n  current: ApscState,\n  signal: ApscSignal,\n  now = Date.now(),\n): { state: ApscState; decision: ApscDecision } {\n  if (!/^[A-Za-z0-9._:-]{1,160}$/.test(signal.agentId)) throw new Error('invalid APSC agentId');\n  if (!/^[A-Za-z0-9._:-]{1,100}$/.test(signal.role)) throw new Error('invalid APSC role');\n  const config = normalizeApscConfig(current.config);\n  const state: ApscState = {\n    ...current,\n    config,\n    round: current.round + 1,\n    roleBaselines: { ...current.roleBaselines },\n    agents: Object.fromEntries(Object.entries(current.agents).map(([id, agent]) => [id, { ...agent }])),\n  };\n  const success = unit(signal.taskSuccess, 'taskSuccess');\n  const latency = unit(signal.normalizedLatency, 'normalizedLatency');\n  const alignment = unit(signal.consensusAlignment, 'consensusAlignment');\n  const rawScore = config.alpha * success + config.beta * (1 - latency) + config.gamma * alignment;\n\n  const role = signal.role.toLowerCase();\n  // Compare against peers in the same role, excluding the current agent.\n  // Letting an agent update its own baseline before normalization caused a\n  // persistently weak agent to redefine \"normal\" downward and reactivate\n  // without any recovery.","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/services/pheromone-adaptive.ts#L144-L180","documentation":"recordApscSignal() rejected the signal's role string (empty or non-string), so it cannot be checked against the protectedRoles list or used for role-aware suspension logic. A guard on the signal input before any state update occurs.","triggerScenarios":"Thrown at v3/@claude-flow/cli/src/services/pheromone-adaptive.ts:162 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a valid APSC role string from the allowed set"],"exampleFix":"Pass a valid APSC role from the supported role set.","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}