{"record":{"id":"9b7fb5a3b2768a45","repo":"ruvnet/ruflo","slug":"amendment-not-found-amendmentid","errorCode":null,"errorMessage":"Amendment not found: ${amendmentId}","messagePattern":"Amendment not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/guidance/src/meta-governance.ts","lineNumber":391,"sourceCode":"    const amendment: Amendment = {\n      id: randomUUID(),\n      timestamp: now,\n      status: 'proposed',\n      votes: new Map(),\n      ...proposal,\n    };\n\n    this.amendments.set(amendment.id, amendment);\n    return amendment;\n  }\n\n  /**\n   * Vote on an amendment\n   */\n  voteOnAmendment(amendmentId: string, voterId: string, approve: boolean): void {\n    const amendment = this.amendments.get(amendmentId);\n    if (!amendment) {\n      throw new Error(`Amendment not found: ${amendmentId}`);\n    }\n    if (amendment.status !== 'proposed') {\n      throw new Error(`Cannot vote on amendment with status: ${amendment.status}`);\n    }\n\n    amendment.votes.set(voterId, approve);\n  }\n\n  /**\n   * Resolve an amendment (check if supermajority reached)\n   */\n  resolveAmendment(amendmentId: string): Amendment {\n    const amendment = this.amendments.get(amendmentId);\n    if (!amendment) {\n      throw new Error(`Amendment not found: ${amendmentId}`);\n    }\n    if (amendment.status !== 'proposed') {\n      throw new Error(`Amendment already resolved: ${amendment.status}`);","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/guidance/src/meta-governance.ts#L373-L409","documentation":"MetaGovernor.voteOnAmendment() looks up the live amendments map, which only holds amendments between proposeAmendment() and their terminal transition — both enactAmendment() and vetoAmendment() delete the entry and move it to amendmentHistory. 'Amendment not found' therefore means the ID was never proposed on this instance, was already enacted, was already vetoed, or came from another governor instance (all state is in-memory).","triggerScenarios":"Voting after the amendment was enacted or vetoed (both remove it from the map); passing a typo'd or foreign ID; voting on a new MetaGovernor after a process restart; using an id copied from getAmendmentHistory() instead of a live proposal.","commonSituations":"Multi-voter flows where enactment races a late vote; job replays after restart; mixing historical and live amendment IDs in logs.","solutions":["Vote using the exact id returned by proposeAmendment() on the same governor instance, before resolve/enact/veto","Pre-check governor.getPendingAmendments() to confirm the amendment is still live","Consult getAmendmentHistory() to see whether it was already enacted or vetoed","Catch the error and treat it as 'vote window closed' — the amendment already reached a terminal state"],"exampleFix":"// before\ngovernor.voteOnAmendment(amendmentId, 'voter-1', true);\n// after\nconst isLive = governor.getPendingAmendments().some(a => a.id === amendmentId);\nif (!isLive) {\n  logger.warn('Amendment no longer pending; vote dropped', { amendmentId });\n} else {\n  governor.voteOnAmendment(amendmentId, 'voter-1', true);\n}","handlingStrategy":"validation","validationCode":"const live = governor.getPendingAmendments().find(a => a.id === amendmentId);\nif (!live) {\n  const historical = governor.getAmendmentHistory().find(a => a.id === amendmentId);\n  logger.warn('Amendment not votable', { amendmentId, terminal: historical?.status ?? 'unknown' });\n  return;\n}\ngovernor.voteOnAmendment(amendmentId, voterId, approve);","typeGuard":"function isVotable(governor: MetaGovernor, id: string): boolean {\n  return governor.getPendingAmendments().some(a => a.id === id); // status === 'proposed'\n}","tryCatchPattern":"try {\n  governor.voteOnAmendment(amendmentId, voterId, approve);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Amendment not found')) {\n    return; // enacted/vetoed/restarted: vote window closed\n  }\n  throw err;\n}","preventionTips":["Vote only with IDs returned by proposeAmendment() on the same instance","Drive voting to completion before resolve/enact/veto consume the amendment","Treat getAmendmentHistory() entries as read-only records, never as live IDs"],"tags":["guidance","meta-governance","amendment","voting","entity-not-found"],"backgroundTag":"entity-not-found","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}