{"record":{"id":"e12088ad8e40c9e6","repo":"ruvnet/ruflo","slug":"memory-store-failed-r-stderr-slice-0-200","errorCode":null,"errorMessage":"memory store failed: ${r.stderr?.slice(0, 200) || r.status}","messagePattern":"memory store failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/ruflo-cost-tracker/scripts/budget.mjs","lineNumber":44,"sourceCode":"  ? '@claude-flow/cli-core@alpha'\n  : '@claude-flow/cli@latest';\n\nconst NS = process.env.BUDGET_NAMESPACE || 'cost-tracking';\nconst KEY = 'budget-config';\n\nfunction memoryStore(key, value) {\n  // The @claude-flow/cli memory layer has a UNIQUE-constraint quirk where\n  // `store` rejects keys that `retrieve` doesn't surface. Workaround:\n  // - For the budget-config key (single record), append a timestamp suffix\n  //   on each write and update a small index that points at the latest.\n  //   This avoids the conflict entirely. Retrieve resolves via the index.\n  if (key === KEY) {\n    const stamped = `${KEY}-${Date.now()}`;\n    const r = spawnNpxSync([\n      CLI_PKG, 'memory', 'store',\n      '--namespace', NS, '--key', stamped, '--value', JSON.stringify(value),\n    ], { stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf-8', shell: process.platform === 'win32' });\n    if (r.status !== 0) throw new Error(`memory store failed: ${r.stderr?.slice(0, 200) || r.status}`);\n    // The \"current pointer\" is found at retrieval time by listing all\n    // budget-config-* keys and picking the lexicographically-largest\n    // (timestamp suffixes sort correctly because they are equal-width).\n    return;\n  }\n  const r = spawnNpxSync([\n    CLI_PKG, 'memory', 'store',\n    '--namespace', NS, '--key', key, '--value', JSON.stringify(value),\n  ], { stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf-8', shell: process.platform === 'win32' });\n  if (r.status !== 0) throw new Error(`memory store failed: ${r.stderr?.slice(0, 200) || r.status}`);\n}\n\nfunction memoryRetrieveOne(key) {\n  const r = spawnNpxSync([\n    CLI_PKG, 'memory', 'retrieve',\n    '--namespace', NS, '--key', key, '--value-only',\n  ], { stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf-8', shell: process.platform === 'win32' });\n  if (r.status !== 0) return null;","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/plugins/ruflo-cost-tracker/scripts/budget.mjs#L26-L62","documentation":"memoryStore() ran the claude-flow CLI `memory store` subprocess and it exited non-zero (stderr prefix captured, or just the exit status). The budget-config write to the cost-tracking namespace failed — commonly the UNIQUE-key constraint quirk the timestamp-suffix workaround targets, or the CLI being unavailable.","triggerScenarios":"Thrown at plugins/ruflo-cost-tracker/scripts/budget.mjs:44 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the underlying cause in logs, fix the root issue, and retry the operation.","Validate inputs and preconditions before invoking this code path so the error is avoided."],"exampleFix":null,"handlingStrategy":"retry","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-14T00:17:10.932Z"}