{"record":{"id":"489e9bd3c5139b79","repo":"ruvnet/ruflo","slug":"rvfeventlog-not-initialized-call-initialize-fir","errorCode":null,"errorMessage":"RvfEventLog not initialized. Call initialize() first.","messagePattern":"RvfEventLog not initialized\\. Call initialize\\(\\) first\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/shared/src/events/rvf-event-log.ts","lineNumber":424,"sourceCode":"    // version tracker\n    const current = this.aggregateVersions.get(event.aggregateId) ?? 0;\n    if (event.version > current) {\n      this.aggregateVersions.set(event.aggregateId, event.version);\n    }\n  }\n\n  /** Ensure parent directory exists for a file path. */\n  private ensureDirectory(filePath: string): void {\n    const dir = dirname(filePath);\n    if (!existsSync(dir)) {\n      mkdirSync(dir, { recursive: true });\n    }\n  }\n\n  /** Guard that throws if initialize() has not been called. */\n  private ensureInitialized(): void {\n    if (!this.initialized) {\n      throw new Error('RvfEventLog not initialized. Call initialize() first.');\n    }\n  }\n}\n","sourceCodeStart":406,"sourceCodeEnd":428,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/shared/src/events/rvf-event-log.ts#L406-L428","documentation":"RvfEventLog gates its operations behind ensureInitialized(), which throws unless initialize() has run to completion in this instance. append(), replay, and snapshot helpers all require the log file and in-memory indexes to be set up first. Reusing a log after shutdown, skipping initialize(), or ignoring an initialize() failure all surface here.","triggerScenarios":"Calling log.append(event) without awaiting log.initialize(); fire-and-forget initialization racing the first append; calling operations after the log was shut down; initialize() failing on an unwritable directory while the error was swallowed.","commonSituations":"Missing await in startup wiring; background workers starting before the log finishes initialization; tests constructing RvfEventLog directly without the init step.","solutions":["await log.initialize() once at startup before any append/replay, and surface its errors","If initialization failed, fix the underlying filesystem issue (directory permissions, disk full) and re-initialize","Create a new RvfEventLog instance after shutdown instead of reusing the old one"],"exampleFix":"// before\nconst log = new RvfEventLog({ logPath });\nlog.append(event); // throws: not initialized\n\n// after\nconst log = new RvfEventLog({ logPath });\nawait log.initialize();\nawait log.append(event);","handlingStrategy":"validation","validationCode":"const log = new RvfEventLog({ logPath });\nawait log.initialize();\nawait log.append(event);","typeGuard":null,"tryCatchPattern":"try {\n  await log.append(event);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('not initialized')) {\n    await log.initialize();\n    await log.append(event);\n  } else throw e;\n}","preventionTips":["Await initialize() once at startup before any append/replay","Start background workers only after log initialization resolves","Do not reuse a RvfEventLog instance after shutdown"],"tags":["event-log","initialization","lifecycle","event-sourcing"],"backgroundTag":"not-initialized","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}