Skip to content

fix: ADR-0059 — RvfBackend swap, CJS bug fixes, packaging fixes#1528

Closed
sparkling wants to merge 1 commit intoruvnet:mainfrom
sparkling:fix/all-patches-clean
Closed

fix: ADR-0059 — RvfBackend swap, CJS bug fixes, packaging fixes#1528
sparkling wants to merge 1 commit intoruvnet:mainfrom
sparkling:fix/all-patches-clean

Conversation

@sparkling
Copy link
Copy Markdown

@sparkling sparkling commented Apr 4, 2026

Issue

Fixes #1526

Summary

1 commit, 6 files, 214 insertions, 63 deletions. ADR-0059 fixes + their direct prerequisites only. No version bumps, no unrelated changes.

ADR-0059 Changes

File Change
auto-memory-hook.mjs createBackend(): RvfBackend preferred → AgentDBBackend fallback → JsonFileBackend. Fixes silent data loss — AgentDBBackend degraded to in-memory Map every session.
intelligence.cjs ID collision (entries.length suffix), ML-006 scope (current project only), ranked dedup (deduped.map not store.map)
hook-handler.cjs tool_input (snake_case) before toolInput (camelCase) — Claude Code sends snake_case; every edit was recorded as "unknown"
cli/package.json @claude-flow/memory: optional → required (0 controllers is not a valid state)
memory/package.json better-sqlite3: optional → required, pinned 11.10.0 (confirmed prebuilts for darwin-arm64/x64, linux-x64)
github-safe.js → .mjs ESM syntax with .js extension fails node -c

Prerequisite Patches Included

These prior patches are bundled because ADR-0059 cannot work without them:

WM-003 (in auto-memory-hook.mjs): createBackend() factory with config.json reader and backend selection. ADR-0059's RvfBackend swap is a change TO this function — it must exist first. Upstream only has a hardcoded JsonFileBackend instantiation.

IN-003/IN-004 (in intelligence.cjs): CJS snapshot reader + signal writer. Provides the intelligence pipeline (init, getContext, recordEdit, consolidate, feedback) that ADR-0059's bug fixes target.

dc179d6 (in intelligence.cjs): Dedup guard — creates the deduped variable. ADR-0059 changes store.map(...) to deduped.map(...) in two places. Without this, the code throws ReferenceError: deduped is not defined.

Root Cause

AgentDBBackend.initialize() does import('@claude-flow/agentdb') — a cross-package dynamic import that fails silently in the hook subprocess. Data writes to an in-memory Map, lost on process exit. The .rvf file is never created. The session-boundary drain (ADR-048) has never worked.

Test Results

  • Acceptance: 69/69 (12/12 ADR-0059 checks)
  • Unit: 539/539
  • Pipeline: 131/131

🤖 Generated with claude-flow

Fixes ruvnet#1526

## ADR-0059 changes (this session)

auto-memory-hook.mjs — createBackend() prefers RvfBackend (same package,
atomic persist, zero native deps). Falls back to AgentDBBackend then
JsonFileBackend. AgentDBBackend silently degraded to in-memory Map —
data lost every session.

intelligence.cjs — ID collision (entries.length suffix), ML-006 scope
(current project only, not all 51 dirs), ranked dedup (deduped.map not
store.map).

hook-handler.cjs — tool_input (snake_case) before toolInput (camelCase).
Claude Code sends snake_case; every edit was recorded as "unknown".

cli/package.json — @claude-flow/memory: optional → required.
memory/package.json — better-sqlite3: optional → required, pinned 11.10.0.
github-safe.js → .mjs — ESM syntax fix.

## Prerequisite patches included (required for ADR-0059 to work)

auto-memory-hook.mjs also includes:
  WM-003: createBackend() factory + config.json reader

intelligence.cjs also includes:
  IN-003/IN-004: CJS snapshot reader + signal writer
  dc179d6: dedup guard (creates 'deduped' variable ADR-0059 references)

Co-Authored-By: claude-flow <ruv@ruv.net>
@sparkling
Copy link
Copy Markdown
Author

Closing — this work is being tracked in ruflo-patch ADR-0059/0065 instead. The RvfBackend swap and CJS fixes are applied in our fork pipeline.

@sparkling sparkling closed this Apr 5, 2026
sparkling added a commit to sparkling/ruflo-patch that referenced this pull request Apr 6, 2026
…, fork hygiene

Phase 1: RvfBackend preferred in auto-memory-hook createBackend()
Phase 2: ID collision fix, ML-006 scope, tool_input snake_case, ranked dedup

Acceptance: 12 ADR-0059 checks + removed 9 phantom checks for tools/controllers
that never existed in any upstream branch. Fixed e2e-causal-edge tool name
(underscore→hyphen). Suite: 60/60, ADR-0059: 12/12.

Harness: removed --ignore-scripts (match real user installs).
Attention check: accept success:true without results field.
CLAUDE.md: test pyramid with cascading pipeline, per-change-type table.
ADR-0060: fork patch hygiene rules (10 fix-on-fix patterns identified).

Upstream: ruvnet/ruflo#1526 (issue), ruvnet/ruflo#1528 (PR, 1 commit, 6 files).

Co-Authored-By: claude-flow <ruv@ruv.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: auto-memory hook silently drops all session data + 4 packaging bugs

1 participant