ruvnet/ruflo · error
No ruvbot memory instance attached. Call attachMemory() befo
Error message
No ruvbot memory instance attached. Call attachMemory() before performing memory operations.
What it means
Thrown by RuvBotMemoryAdapter in @claude-flow/guidance when a governed memory operation (read, write, or delete) is invoked before a ruvbot memory instance has been attached. The adapter proxies every operation to the wrapped RuvBotMemory after running it through the MemoryWriteGate, so it refuses to operate on a null delegate. It is a wiring/setup error, not a runtime data error.
Source
Thrown at v3/@claude-flow/guidance/src/ruvbot-integration.ts:595
/**
* Get the count of governed operations.
*/
get operationCount(): number {
return this.operationLog.length;
}
/**
* Clear the operation log.
*/
clearLog(): void {
this.operationLog = [];
}
// ===== Private Helpers =====
private ensureMemoryAttached(): void {
if (!this.ruvbotMemory) {
throw new Error(
'No ruvbot memory instance attached. Call attachMemory() before ' +
'performing memory operations.',
);
}
}
}
// ============================================================================
// RuvBotGuidanceBridge
// ============================================================================
/**
* Bridges a ruvbot instance with the @claude-flow/guidance control plane.
*
* Wires ruvbot event hooks to guidance enforcement and trust systems:
*
* - `message` -> EnforcementGates (secrets, destructive ops) + AIDefence
* - `agent:spawn` -> ManifestValidatorView on GitHub (pinned to fa13ee4ad6)
Solutions
- Call adapter.attachMemory(ruvbotMemory) with an object implementing RuvBotMemory (read/write/delete) immediately after constructing the adapter
- Wrap construction and attachment in a single factory function so the adapter can never be handed out un-attached
- In tests, attach a stub memory: adapter.attachMemory({ read: async () => value, write: async () => {}, delete: async () => {} })
Example fix
// before
const adapter = new RuvBotMemoryAdapter(memoryGate, scheduler);
await adapter.read('key', 'ns'); // throws: no ruvbot memory attached
// after
const adapter = new RuvBotMemoryAdapter(memoryGate, scheduler);
adapter.attachMemory(ruvbotMemory); // required before any read/write/delete
await adapter.read('key', 'ns'); Defensive patterns
Strategy: validation
Validate before calling
// Make attachment atomic with construction so the error cannot fire later
function createGovernedMemory(
memoryGate: MemoryWriteGate,
scheduler: CoherenceScheduler,
memory: RuvBotMemory,
): RuvBotMemoryAdapter {
const adapter = new RuvBotMemoryAdapter(memoryGate, scheduler);
adapter.attachMemory(memory); // mandatory before read/write/delete
return adapter;
} Type guard
// ruvbotMemory is private; track attachment externally
const attachedMemories = new WeakSet<RuvBotMemoryAdapter>();
function hasMemoryAttached(adapter: RuvBotMemoryAdapter): boolean {
return attachedMemories.has(adapter);
}
// after adapter.attachMemory(m): attachedMemories.add(adapter); Try / catch
try {
await adapter.write(key, ns, value, authority);
} catch (e) {
if (e instanceof Error && e.message.includes('attachMemory()')) {
throw new Error('Setup bug: adapter used before attachMemory()', { cause: e });
}
throw e;
} Prevention
- Never hand out a RuvBotMemoryAdapter from a factory without attaching memory in the same call
- Treat attachMemory as part of the constructor contract in review checklists
- In tests, always attach a stub RuvBotMemory right after construction
When it happens
Trigger: Constructing RuvBotMemoryAdapter(memoryGate, coherenceScheduler) and then calling adapter.read(key, ns), adapter.write(key, ns, value, authority), or adapter.delete(...) without ever calling adapter.attachMemory(memory). The guard ensureMemoryAttached() runs as the first statement of every proxied operation.
Common situations: Setup code copied from docs that shows construction but omits the attach step; DI containers that build the adapter lazily and skip the second-phase attach; unit tests that instantiate the adapter directly with real gates but forget to attach a mock RuvBotMemory.
Related errors
- AIDefenceGate not attached. Call attachGuidance({ aiDefenceG
- dimension is required when creating a new memory file
- Root guidance file not found: ${this.config.rootGuidancePath
- GuidanceControlPlane not initialized. Call initialize() firs
- No policy bundle loaded. Call loadBundle() first.
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/11e8e20fc69f8d38.
Report an issue: GitHub.