{"record":{"id":"e21897db523bb2d9","repo":"ruvnet/ruflo","slug":"darwin-archive-exceeded-candidate-count-budget","errorCode":null,"errorMessage":"Darwin archive exceeded candidate-count budget","messagePattern":"Darwin archive exceeded candidate-count budget","errorType":"exception","errorClass":"DarwinUnavailableError","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/services/flywheel-proposer.ts","lineNumber":225,"sourceCode":"        budget: {\n          maxEvaluationCostMicros: input.safetyEnvelope.maxEvaluationCostMicros,\n          maxConcurrency: input.maxConcurrency ?? 2,\n          maxWallTimeMs,\n        },\n      }),\n      new Promise<never>((_, reject) => {\n        timeout = setTimeout(() => reject(new DarwinUnavailableError('Darwin exceeded wall-time budget')), maxWallTimeMs);\n        timeout.unref?.();\n      }),\n    ]).finally(() => {\n      if (timeout) clearTimeout(timeout);\n    });\n    if (!result.completed) {\n      if (input.mode === 'darwin') throw new DarwinUnavailableError(result.reason ?? 'Darwin archive incomplete');\n      return runLocal(`darwin-incomplete:${result.reason ?? 'unknown'}`);\n    }\n    if (result.candidates.length > (input.maxCandidates ?? 256)) {\n      throw new DarwinUnavailableError('Darwin archive exceeded candidate-count budget');\n    }\n    const evaluationCost = result.candidates.reduce(\n      (sum, candidate) => sum + candidate.resources.evaluationCostMicros,\n      0,\n    );\n    if (evaluationCost > input.safetyEnvelope.maxEvaluationCostMicros) {\n      throw new DarwinUnavailableError('Darwin archive exceeded evaluation-cost budget');\n    }\n    return finalizeArchive({\n      requested: input.mode,\n      effective: 'darwin',\n      promotionAllowed: true,\n      baselineRef,\n      safetyEnvelope: input.safetyEnvelope,\n      seed: input.seed,\n      candidates: result.candidates,\n      completed: true,\n    });","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/services/flywheel-proposer.ts#L207-L243","documentation":"After a completed Darwin run, proposeFlywheelCandidates checks that result.candidates.length does not exceed maxCandidates (default 256). Exceeding it means Darwin produced more candidates than the caller budgeted for, which could blow downstream evaluation cost, so it throws DarwinUnavailableError.","triggerScenarios":"The Darwin backend returns more candidates than input.maxCandidates (or the 256 default), e.g. Darwin ignored the budget or the caller set maxCandidates lower than Darwin's natural output.","commonSituations":"maxCandidates set tightly (e.g. 8) while Darwin generates dozens; a Darwin version change increases default output; maxCandidates not coordinated with Darwin's own generation count.","solutions":["Raise input.maxCandidates to a value Darwin will stay under, if your evaluation budget allows.","Configure Darwin's own candidate-generation limit so its output fits within maxCandidates.","Use mode 'auto' so a budget overrun falls back to the local proposer instead of throwing.","If overruns are persistent, cap candidates in the darwinInvoker wrapper before returning."],"exampleFix":"// before\nproposeFlywheelCandidates({ mode: 'darwin', darwinInvoker, maxCandidates: 8, ... }); // throws if Darwin returns >8\n\n// after — align budgets, or cap inside the invoker\nconst cappedInvoker = async (req) => {\n  const r = await darwinInvoker(req);\n  return { ...r, candidates: r.candidates.slice(0, 256) };\n};\nproposeFlywheelCandidates({ mode: 'darwin', darwinInvoker: cappedInvoker, maxCandidates: 256, ... });","handlingStrategy":"validation","validationCode":"const maxCandidates = 256; // align with what Darwin will produce\nawait proposeFlywheelCandidates({ mode: 'darwin', darwinInvoker, maxCandidates, ... });","typeGuard":null,"tryCatchPattern":"try {\n  return await proposeFlywheelCandidates({ mode: 'darwin', darwinInvoker, maxCandidates: 8, ... });\n} catch (e) {\n  if (e instanceof DarwinUnavailableError && /candidate-count budget/.test(e.message)) {\n    return await proposeFlywheelCandidates({ mode: 'darwin', darwinInvoker, maxCandidates: 256, ... });\n  }\n  throw e;\n}","preventionTips":["Size maxCandidates to Darwin's expected output volume.","Cap candidate count inside the darwinInvoker wrapper if Darwin cannot self-limit.","Use mode 'auto' so overruns fall back to local instead of throwing.","Coordinate maxCandidates with the downstream evaluation budget."],"tags":["darwin","flywheel","budget","typescript"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}