Commit Graph
201 Commits
Author SHA1 Message Date
ordinary being ad7e9e5416 fix(memory): page list row identities before loading payloads (#4687)
bridgeListEntries() and the sql.js listEntries() fallback selected full content and embedding columns before ORDER BY updated_at DESC LIMIT/OFFSET, so metadata-only pages sorted large payloads that were then discarded (#4686).\n\nUse a rowid subquery to order/limit row identities first, then fetch the page's payload columns. The original full-row query remains as a fallback for legacy WITHOUT ROWID tables. Filters (status/TTL/namespace/provenance/tags), total count, embedding cap, page membership, order and returned fields are unchanged.\n\nAdds a sql.js fixture test for descending offset pages, full content, total and limit 0. Existing sql.js list/provenance/tag and ADR-472 embedding tests pass 12/12 locally; tsc reports only the pre-existing missing workspace packages.
2026-11-04 09:05:02 -06:00
rUvandr bbd057eb17 fix(memory): find stored patterns when agentdb serves mock embeddings (#4643) (#4681)
agentdb_pattern-store writes through ReasoningBank.storePattern(), but when
agentdb's Transformers.js model fails to load (offline, failed sharp install,
or a loaded CI runner) it serves hash-based mock embeddings. A passage and a
query then embed to unrelated vectors, so searchPatterns() returned [] for a
pattern that was just stored. This is the full-suite #2226 failure that has
kept the CI ratchet red since the move to agentdb 3.2.

- bridgeSearchPatterns: when the agentdb vector search returns nothing, scan
  the same reasoning_patterns table for the query text, matching what the
  LocalReasoningBank branch already does over getAll().
- rescueAgentdbEmbedder: agentdb 3.x's ReasoningBank calls embedQuery() /
  embedPassage(), which bypass embed(). Patch the role methods too and clear
  the cached mock vectors, so a host with ONNX actually gets real vectors.
- Regression test forces AGENTDB_DISABLE_TRANSFORMERS=1 and requires the
  round-trip to hit; it fails without the fix.

Co-authored-by: r <r@x>
2026-11-04 01:57:56 -06:00
ordinary being 762fbf74c2 fix(memory): expose AgentDB init failures in health (#4667)
agentdb_health could return available:true with controllers while AgentDB itself had failed to open (for example because the daemon or another MCP server owned the RuVector store). The only trace was the separate isBridgeAvailable() check; the health payload had no init error or lock hint (#4654).\n\nbridgeHealthCheck now reads the registry's getAgentDBInitError(), reports available:false, includes agentdbInitError and the recorded bridgeFailureReason, and adds an actionable hint when the cause is an already-open/locked native store. Older registries without the record are unchanged.\n\nRegression extends the #4622 fake registry with listControllers and covers failed and healthy health payloads. Baseline returns available:true and no error for the failure case; candidate 5/5 with the Windows bridge opt-in, existing 3 tests unchanged.
2026-11-04 01:01:20 -06:00
rUv 3c30ee3fa3 feat(agentdb): episode CRUD over agentdb 3.3 (ADR-520) + release 3.69.0 (#4642)
* feat(agentdb): episode get/list/update/delete over agentdb 3.3 (ADR-520)

agentdb_episode-get, -list, -update and -delete reach agentdb 3.3's
ReflexionMemory through one new bridge helper (withReflexionController),
so a verified session can be marked success with a critique in place,
keeping its id, and recall re-ranks it. Strict integer ids; pre-3.3
builds get a clear error (delete is gated so the old parseInt-ing
deleteEpisode is never used).

agentdb ^3.3.0 in root and CLI, ruflo override >=3.3.0, both lockfiles;
marketplace agentdb plugin -> plugin-v3.3.0.

Co-Authored-By: RuFlo <ruv@ruv.net>

* fix(agentdb): ADR-112 use-when guidance on episode CRUD tool descriptions

Co-Authored-By: RuFlo <ruv@ruv.net>

* chore(release): 3.69.0

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-11-01 12:52:22 -05:00
rUvandr 73b20daf6e fix(cli): session-end consolidation, session snapshot IDs, Fisher decay env (#4638)
* fix(cli): session-end consolidation, snapshot IDs, Fisher decay env, read-path regression test

- #3908: bridgeSessionEnd probed only `nightlyLearner.consolidate`, which
  neither the MemoryConsolidator wrapper nor AgentDB's NightlyLearner has.
  Feature-detect consolidate -> run -> runAll, bounded (10s) and non-fatal.
- #4404: session_save keyed snapshot rows by a bare `namespace::key`, so
  tuples containing `::` collided (one dropped on save, a distinct sibling
  row skipped as a mirror). Percent-escape `%` and `:` per component;
  ordinary IDs are unchanged and restore reads the explicit fields.
- #3475: CLAUDE_FLOW_FISHER_DECAY overrides the default Fisher EMA decay;
  only a finite number in (0, 1] is honoured, constructor config still wins.
- #4570: the sql.js read paths no longer rewrite memory.db on main (fixed by
  #3918's ensureSchemaColumns change); add a regression test asserting
  inode/mtime/ctime/size are unchanged across searchEntries, listEntries,
  memory_search, memory_list and memory_search_unified.

Co-Authored-By: RuFlo <ruv@ruv.net>

* test(cli): drop #4570 regression test (issue closed separately as fixed by #3918)

Co-Authored-By: RuFlo <ruv@ruv.net>

---------

Co-authored-by: r <r@x>
2026-11-01 12:17:55 -05:00
rUvandr 2b1a392747 feat(memory): session episodes through agentdb 3.2 hybrid retrieval; release 3.68.0 (ADR-519) (#4632)
- Session end stores the summary as a ReflexionMemory episode (neutral reward,
  unverified). The bridge called startEpisode/endEpisode, which ReflexionMemory
  never had, so no session episode was ever written.
- New agentdb_episode-recall MCP tool: retrieveRelevant with agentdb 3.2's
  keyword + vector fusion by default, opt-in cross-encoder rerank.
- agentdb_session-start takes recall/k/hybrid/rerank and returns episodes.
- A failing secondary write no longer discards a stored or recalled episode.
- agentdb ^3.2.0 in cli and claude-flow, >=3.2.0 in the ruflo override.
- scripts/smoke-episode-recall.mjs runs the round trip on real agentdb.

Co-authored-by: r <r@x>
2026-11-01 00:33:07 -04:00
rUvandr 49adc540a0 fix(memory): report the original AgentDB open failure; memory_list reports failed queries (#4622); release 3.66.1 (#4623)
- ControllerRegistry keeps the first backend failure AgentDB logs (e.g. a
  native vector store locked by another process) instead of only the last
  fallback's format rejection, exposed as getAgentDBInitError(), with the
  single-owner HTTP remedy. @claude-flow/memory 3.2.0.
- The CLI bridge records that reason, so the sql.js fallback's refusal names
  it, and isBridgeAvailable() is false when AgentDB did not open.
- memory_list returns success:false with the error on a failed query instead
  of an empty inventory.
- Release 3.66.1 with plugin-agent-federation 1.0.4 (#4619 trust thresholds).

Co-authored-by: r <r@x>
2026-10-31 11:17:37 -04:00
rUvandr 243bc57f0b feat(learning): lessons say where the fix goes; reworded tasks learn together (ADR-511) (#4603)
* feat(learning): lessons say where the fix goes; reworded tasks learn together (ADR-511)

The §7 evaluation (#4581) showed three limits on what the verified-outcome
loop can learn:

- a lesson named an agent, nothing the model can act on;
- tasks naming different files merged into one lesson;
- the same task worded differently never learned (15 reworded verified
  successes left 15 patterns at one success each, zero lessons).

Changes:
- mods: a verified turn records its screened edited source files; a lesson
  names the three its passing fixes edited most and leads with them; pick()
  weighs rare keywords (IDF) and drops matches far below the best.
  ruflo-mods 0.13.0.
- cli: files are counted per pattern (successes only) into learned-lessons.json;
  SONA takes them as pattern anchors (never keywords), so reworded tasks that
  fixed the same file reinforce one pattern; tasks naming disjoint paths never
  merge. Lesson building moves to verified-lessons.ts.
- eval: the harness gains --ablate, --test-index, --concurrency, --lessons,
  --save-lessons, --eval-sample, --calibrate and --max-turns;
  scripts/eval-learning-loop-corpus.mjs writes a validated 15+30-task corpus.

Proved offline (tests): 15 reworded prompts form 5 lessons, up from 0; the
first run's prompts form 5 lessons, up from 1; the right lesson ranks first
for 30 of 30 eval prompts, with 1.07 lessons shown per prompt.

Paid pilots (haiku, about $6.80) are directional and did not reach the gate:
- 8-turn cap: off 2/10, on 4/10, lessons without files 1/10;
- uncapped: 6/6 vs 6/6, cost within 1%.
ADR-511 §5 has the details.

Co-Authored-By: RuFlo <ruv@ruv.net>

* docs(adr): ADR-511 cites PR #4603

Co-Authored-By: RuFlo <ruv@ruv.net>

---------

Co-authored-by: r <r@x>
2026-10-30 12:12:42 -04:00
rUvandr 38112e0042 feat(mods): learning-loop gaming defences — taints, re-verify, anomaly gate (ADR-503) (#4590)
* feat(learning-loop): gaming defences for verified outcomes (ADR-503)

The verified-outcome loop (ADR-502) trusts a verifier's exit status, but the
model chooses what that verifier checks. Four downgrade-only layers:

- mod: a verified-success record carries taints when the turn edited a test
  file (edited-tests), a verifier config (edited-verifier-config), or decided
  on a weakened/narrowed command (narrowed-verifier); a per-process session
  token is written on every record. The outcome word never changes.
- CLI: a success with a taint not listed in .claude-flow/config.json
  learningLoop.allowTaint is counted under `tainted` and never reaches SONA.
- CLI: opt-in re-verify (learningLoop.reverify, off by default) re-runs a
  rotating allowlisted manifest check in a temp detached git worktree at HEAD
  with a timeout; failure, timeout or error downgrades to unknown. Only an
  explicit verified-ingest re-verifies; hot callers defer.
- CLI: anomaly gate holds would-be lessons that are perfect-and-tainted,
  only-narrowed, or from one session, listed as `held: <id> (<reason>)`.

Adds scripts/eval-learning-loop.mjs (manual, plan-only unless --run).

Co-Authored-By: RuFlo <ruv@ruv.net>

* docs(adr): ADR-503 status names PR #4590

Co-Authored-By: RuFlo <ruv@ruv.net>

* fix(learning-loop): shell edits of tests taint; test the real re-verify runner (ADR-503)

- A Bash command that writes, moves or deletes a test file or verifier
  config (rm, mv, cp, tee, truncate, sed -i/perl -i, output redirection,
  git rm/checkout/restore/...) now sets edited-tests /
  edited-verifier-config like an Edit of that file. Before this change,
  Edit src/a.ts + `sed -i 's/it(/it.skip(/' src/a.test.ts` + `npm test`
  produced an untainted verified-success. Downgrade-only: reads and test
  runs earn nothing.
- gitWorktreeRunner is now tested against a throwaway git repo: pass,
  fail, missing script, timeout (hung script's process verified dead),
  non-repo error. After each run only the main worktree remains and no
  ruflo-reverify-* dir is left. A negative control (kill only the direct
  child) makes the timeout test fail.
- ADR-503 implementation notes record both, plus the interpreter-write gap.

Co-Authored-By: RuFlo <ruv@ruv.net>

* test(learning-loop): give the hung-check re-verify test an 8s budget for cold CI runners

Co-Authored-By: RuFlo <ruv@ruv.net>

* chore(ruflo-mods): 0.9.0 for ADR-503

Co-Authored-By: RuFlo <ruv@ruv.net>

---------

Co-authored-by: r <r@x>
2026-10-29 18:57:12 -04:00
rUvandr 375e846c66 feat(mods): verified-outcome learning loop, on by default (learningLoop, #4581, ADR-502) (#4583)
* feat(mods): verified-outcome learning loop (learningLoop, #4581, ADR-502)

ruflo-mods 0.8.0 adds the learningLoop option (default off). Each main-loop
turn becomes a trajectory whose outcome is verified-success/verified-failure
only when a recognised test/build/typecheck/lint command ran after the
turn's last edit and the shell's exit status said so; otherwise unknown.
A masked status (|| true, pipes, ;, background, substitution) verifies
nothing, and the model's own words are never read.

The CLI ingests the records (ruflo hooks verified-ingest, the
hooks_intelligence_verified-ingest MCP tool, and automatically from
hooks_route and hooks_session-end): only verified records train SONA,
unknown ones are counted; each id once; PII-redacted. It writes
learned-lessons.json, and the mod adds at most three cited lessons at or
above the 0.6 gate to a matching prompt. doctor --component learning-loop
reports whether outcomes reach SONA.

Stages 5-7 of #4581 (pane, autonomous /loop-run, GEPA self-tuning) are
deferred; the on-by-default evaluation has not been run.

Co-Authored-By: RuFlo <ruv@ruv.net>

* fix(mods): learning loop needs an edit to verify; redact e-mails before writing (#4581)

A turn that edited nothing is unknown (a verifier verifies a change).
The mod replaces e-mail addresses in the stored task; ADR-502 states the
privacy limit (broader PII redaction runs at CLI ingest).

Co-Authored-By: RuFlo <ruv@ruv.net>

* feat(mods): learningLoop on by default (#4581)

Maintainer decision: ship the learning loop on by default. Set the
learningLoop option to false to turn it off. ADR-502 records that the
issue's 30-task evaluation has not been run yet.

Co-Authored-By: RuFlo <ruv@ruv.net>

* fix(cli): ADR-112 guidance on hooks_intelligence_verified-ingest (#4581)

Co-Authored-By: RuFlo <ruv@ruv.net>

---------

Co-authored-by: r <r@x>
2026-10-29 16:38:56 -04:00
rUvandr cbd1986979 fix(cli): store patterns in LocalReasoningBank when it is the registered bank (#4567)
@claude-flow/memory 3.1.0 (#4550) made ControllerRegistry.set() real, so the
bridge now registers the intelligence module's LocalReasoningBank whenever
agentdb's ReasoningBank is unavailable. It has store()/findSimilar() but no
storePattern(), so bridgeStorePattern wrote to the SQL pattern namespace while
bridgeSearchPatterns read the bank: a stored pattern was never found when the
bank already held other patterns (the #2226 test failed on CI for #4566).

- bridgeStorePattern writes to the bank's store() with an embedding from the
  same generateEmbedding() the search uses, and flushes it to disk.
- bridgeSearchPatterns falls through to the SQL namespace when the bank has
  no match, so patterns written by the fallback path stay findable.

Co-authored-by: r <r@x>
2026-10-28 14:16:31 -04:00
ordinary being aca151dfe1 fix(memory): rescue each store's embedder, not just the first (#4421)
rescueAgentdbEmbedder() used a process-wide boolean to avoid re-patching. AgentDB registries are keyed by dbPath and each owns a distinct embedder, so after the first store was rescued every later store kept its mock embedder and wrote/searchable vectors from AgentDB's random fallback (#4410 memory scan).\n\nThe per-embedder __ruvectorRescued sentinel already makes the patch idempotent. Remove the global flag, keep the sentinel check, and export the helper for a focused two-store regression. Baseline (export-only, no behavior change) rescues the first embedder and leaves the second false; candidate rescues both.
2026-10-23 08:33:50 -04:00
rUvandr 17da11320a fix(memory): restore 10000-row bridge search window, configurable (#4397 part 1) (#4405)
The #2982 ORDER BY fix kept LIMIT 1000, so rows outside the newest 1000
were unfindable (3.38.3 and the sql.js path use 10000). Default is now
10000; CLAUDE_FLOW_SEARCH_WINDOW overrides (clamped 100..100000).

Co-authored-by: r <r@x>
2026-10-22 22:16:10 -04:00
ordinary being 947204c082 fix(memory): scrub deleted payload from tombstones (#4351)
memory delete is a soft delete so the UNIQUE(namespace,key) slot stays occupied and a later upsert can resurrect the row. Both write paths kept the payload on disk: the native bridge left content, embedding, tags and metadata intact, and the sql.js fallback only nulled embedding. A deleted value therefore remained readable by anyone opening memory.db/agentdb-memory.db directly (#3785 residual).\n\nScrub content, embedding, embedding_model, embedding_dimensions, tags and metadata in both the bridge SQL and the sql.js image path. content is NOT NULL in the schema, so use the empty string rather than SQL NULL; identity, namespace, status, provenance and timestamps remain for resurrection and audit. Enable PRAGMA secure_delete=ON before both soft-delete paths and namespace purges so SQLite overwrites the old cells instead of leaving the payload in free pages.\n\nAdd sql.js delete/purge regression tests that also scan the raw image, plus a native better-sqlite3 case that checks the columns and the image after a WAL truncate checkpoint. Baseline local cases fail on the raw markers; the fix passes, and related delete/purge/upsert/concurrency tests pass 25/26 (native case skipped locally).
2026-10-21 09:14:47 -04:00
Gss d7f2286835 fix(memory): build the RaBitQ index on demand and use it on the vector path (#4318)
* fix(memory): build the RaBitQ index on demand and use it on the vector path (#4203)

shouldRebuildRabitq() had no callers and the index was only ever populated by the explicit embeddings_rabitq_build tool, so searchRabitq() always returned null and the sql.js pre-filter was dead.

ensureRabitqIndex() drives the existing thresholds from the search entry points (60s throttle, 10-vector floor, 20% drift, disabled after a missing-WASM failure, bound to the source dbPath and dimensions).

The bridge cosine path now scans RaBitQ candidates and reranks them with the same exact cosine, falling back to the unchanged exhaustive scan on any error.

* test(memory): cover RaBitQ auto-build, exact rerank and top-k recall (#4203)

Six tests against a real sqlite store: build on demand, bridge uses the index and reranks with exact cosine, no rebuild per search, below-floor negative control, exhaustive-vs-indexed parity when the corpus fits the candidate window, and recall plus exact-rerank on a 60-row corpus larger than the window (>=80% top-5 recall).
2026-10-20 06:00:14 -04:00
Mathew BeaneandRuFlo f67d3b201f feat(memory,ollama): tag filter for memory list, export v1.1, local Ollama default model (#3526) (#3526)
Rebased onto main 3.56.9.

- memory_list / `memory list --tags`: exact AND tag filter via json_each,
  ANDed with namespace and provenance on the sql.js and bridge paths;
  coexists with ADR-472 embeddings and #4056 includeExpired.
- memory_export v1.1 carries tags; memory_import restores them and reports
  withTags alongside main's vectors/failed accounting.
- Ollama: tier aliases and claude-* ids resolve to OLLAMA_DEFAULT_MODEL or
  the persisted `providers configure` model; only the real ollama.com
  endpoint falls back to gpt-oss:120b-cloud, a local endpoint without a
  default fails loudly instead of egressing to Ollama Cloud.

Provider precedence is dropped from this change: main's #3493 (explicit
provider fails closed) supersedes the earlier narrowing.

Co-authored-by: RuFlo <ruv@ruv.net>
2026-10-20 05:36:37 -04:00
6afffb777c fix(embeddings): writable model cache dir + retryable degraded state (#3692) (#3831)
A system-prefix global install's default ONNX model cache lives under its
own package directory, which is root-owned — an ordinary runtime user hits
EACCES the first time any of three independent call sites load the local
transformers.js pipeline. The resulting failure also got memoized as
permanent mock-embedding state for a worker's entire process lifetime, so
fixing cache permissions mid-run never helped an already-running worker.

- Resolve a writable cache dir (TRANSFORMERS_CACHE/HF_HOME, else
  ~/.cache/ruflo/models) and set it before pipeline() init at all three
  call sites: transformers-loader.ts, memory-initializer.ts, task-embedder.ts.
- Distinguish a permanently-missing backend from a retryable environmental
  failure (EACCES, ENOSPC, transient network) in memory-initializer.ts and
  task-embedder.ts, so a retryable degraded state re-attempts real
  initialization after a bounded interval instead of requiring a restart.
- Keep ADR-390's truthful backend:'onnx'|'mock' reporting unchanged.

See ADR-454 for the full decision record.

Co-authored-by: Nicholas Ruest <nicholasruest@Nicholass-MacBook-Pro.local>
Co-authored-by: RuFlo <ruv@ruv.net>
2026-10-19 22:56:02 -04:00
rUvandClaude e86134e45b feat(memory): add read-only memory peek command (#3508) (#3620)
Reports which memory.db/agentdb-memory.db files this cwd resolves to,
their active row counts, last write, and why the route was chosen —
without calling ensureInitialized(), the MCP tool layer, or writing
anything. Addresses the gap left after #3463/#3448: memory_stats and
friends still initialize the default store when called with no path,
answer for one file per call, and never report both stores or the
sharedKeys intersection (so a naive consumer double-counts mirrored
rows).

- src/memory/memory-peek.ts: new, self-contained read-only probe.
  sql.js store is read as a one-shot in-memory byte buffer (never
  written back); the native agentdb-memory.db sibling is opened
  readonly/fileMustExist, same as sibling-store.ts. Neither file is
  ever opened unless existsSync() first confirms it exists.
- src/commands/memory.ts: wires `memory peek [--path] [--format json]`
  into the existing subcommand list/help text.
- __tests__/memory-peek-3508.test.ts: asserts a fresh project ends up
  with zero files after a peek, plus correctness coverage for row
  counts (excluding soft-deleted rows), last-write timestamps, the
  sharedKeys intersection (not sum), route-source labeling, and the
  encrypted-at-rest case.

Scoped to the CLI subcommand only; the MCP `memory_peek` tool and
doctor integration from the issue's "smallest API" are left for a
follow-up to keep this change minimal.


Claude-Session: https://claude.ai/code/session_019gH7pnqfexcs77Ca1UCqHr

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-19 21:49:41 -04:00
rUv 2b15ef2715 Merge pull request #4191 from 555aaditya/fix/3113-3114-reasoningbank-embedder
fix(memory): use the ReasoningBank embedder instead of the hash fallback
2026-10-19 17:21:52 -04:00
rUv 0bec340c54 Merge pull request #4298 from ruvnet/fix/4291-graph-query-db-path
fix(memory): resolve graph reads through explicit CLAUDE_FLOW_DB_PATH binding (#4291)
2026-10-19 17:02:21 -04:00
randRuFlo 14f659089f fix(memory): resolve graph reads through explicit CLAUDE_FLOW_DB_PATH binding (#4291)
getBridgeDb() and isBridgeDbEncryptedAtRest() in graph-edge-writer.ts
resolved the memory.db path as `customDbPath ?? path.join(getMemoryRoot(),
'memory.db')`, bypassing resolveDbPath() (memory-initializer.ts) — the
function that actually implements the documented path-priority rule
(explicit CLAUDE_FLOW_DB_PATH wins over the plain default). A caller that
explicitly selected a store via that env var silently got graph-query
results read from a different, unselected memory.db instead — a
source-bound read leaking data from a store it never chose.

Both functions now resolve the file through resolveDbPath(customDbPath),
so a custom argument, then CLAUDE_FLOW_DB_PATH, then the memory-root
default are tried in that order, and encryption sniffing (isRfe1EncryptedAtRest)
and the native open always agree on the same resolved file. A missing or
encrypted-at-rest explicit source still refuses (returns null) rather than
falling back to any other store — unchanged behavior, just now applied to
the correct path.

Adds __tests__/graph-query-explicit-db-path-4291.test.ts, reproducing the
issue's exact synthetic fixture (two sqlite stores under a fixture .swarm
dir, CLAUDE_FLOW_MEMORY_PATH + CLAUDE_FLOW_DB_PATH env bindings, a k-hop
agentdb_graph-query call) plus: unchanged default behavior with no env
binding, refusal when the explicit path is missing, and refusal when the
explicit source is encrypted at rest. Does not touch the independent
agentdb-memory.db controller default (#3155/#3156) or the ControllerRegistry
identity fix (#3143).

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-19 15:00:25 -04:00
rUv 227a9176c4 Merge branch 'main' into fix/3113-3114-reasoningbank-embedder 2026-10-19 19:49:28 +01:00
kevin9327 ed98c2341e fix(intelligence): write learned patterns before a one-shot command exits (#4283)
recordTrajectory() saved stats.json synchronously but left the
ReasoningBank save to its 100 ms debounce timer. The one-shot bins call
process.exit(0) as soon as the command resolves, so the timer never
fired: patternsLearned went up while patterns.json was never written.
Flush the bank next to savePersistedStats() so the counter is never
persisted for a pattern that wasn't.
2026-10-19 09:14:27 +09:00
xjh bd92ac5b4c fix(intelligence): forward trajectories using the ruvllm contract (#4222)
Map outcomes and steps to the fields consumed by ruvllm pattern extraction. Add coverage for success, failure, and partial trajectories.

Refs #4199 (part A).
2026-10-17 16:35:22 +01:00
Rudy Mizrahi Celekli f429ccac53 fix: serialize learning stats read-merge-write transactions (#4240) 2026-10-17 14:59:04 +01:00
555aaditya 1ec4cddcfa fix(memory): use the ReasoningBank embedder instead of the hash fallback
When agentic-flow/reasoningbank was the first available local embedder,
every memory store and search still produced hash-fallback vectors:

- #3113: the loader registered the model as { embed: computeEmbedding },
  but generateLocalEmbedding() only calls the model when it is a
  function, so the object never ran. It also advertised 768 dimensions
  for agentic-flow's 384-dim all-MiniLM-L6-v2 model.
- #3114: computeEmbedding() resolves to a Float32Array, which has no
  .data and fails Array.isArray(), so its output was discarded even
  when called.

Register a function wrapper with 384 dimensions, as the ruvector branch
already does, and accept typed-array output. DataView is excluded: it is
an ArrayBuffer view without an iterator, so Array.from() would return []
and be reported as a real zero-length vector. The transformers
(output.data) and ruvector (plain array) paths are unchanged.

vitest externalizes agentic-flow*, so the regression runs the source in
a child process under the existing agentic-flow-root-probe loader hooks,
which gain a PROBE_REASONINGBANK=float32|dataview mode.

Fixes #3113
Fixes #3114
2026-10-14 23:10:16 +05:30
randRuFlo 0aaff49bcb fix(cli): neural data dir resolves through getProjectCwd (env-var precedence audit)
Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-14 10:25:25 -04:00
randRuFlo fca96f9fc0 Merge main into perf/mcp-memory-on-core
Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-14 10:24:16 -04:00
rUv d4f7af9983 Merge pull request #4185 from ruvnet/fix/sona-neighbour-reinforcement-4134
fix(sona): reinforce the nearest existing pattern for near-identical tasks (#4134)
2026-10-14 06:10:39 -07:00
rUv 7359862715 Merge pull request #4184 from ruvnet/fix/memory-search-threshold-4129
fix(memory): calibrated default search threshold and near-miss hints (#4129)
2026-10-14 06:09:26 -07:00
r 1377b17c1c Merge origin/main into fix/3979 2026-10-14 06:31:45 -04:00
randRuFlo db2d737ffe fix(sona): reinforce the nearest existing pattern for near-identical tasks and report distance to the routing gate (#4134)
Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-14 05:46:38 -04:00
randRuFlo 6c5992a030 fix(memory): calibrated default search threshold (0.2) and near-miss hints when a default search is empty (#4129)
Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-14 05:33:39 -04:00
RuFlo 5c00b076ef fix(cli): declare @ruvector/rvagent-wasm optional; count only new patterns (#3979)
Item 1: dist/src/ruvector/agent-wasm.js imports @ruvector/rvagent-wasm but the CLI never declared it,
so a global install never fetched it and every wasm_gallery/agent tool failed with a raw
ERR_MODULE_NOT_FOUND trace. It is now an optional dependency (^0.1.0, 620 KB, no install scripts,
MIT/Apache) and initAgentWasm() reports a missing package as 'not installed' with the install command.

Item 4: 'patterns learned' always equalled trajectories because recordTrajectory() bumped the counter
for every successful step even when LocalReasoningBank.store() merged it into an existing pattern.
store() now returns whether a new pattern was added and only that is counted.

Tests first: __tests__/patterns-learned-dedup-3979.test.ts (13 identical successes counted 13) and
__tests__/agent-wasm-not-installed-3979.test.ts both fail on main. pnpm-lock.yaml: only the two
rvagent-wasm hunks (frozen-lockfile clean).

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-14 05:32:46 -04:00
r 18e5fddad5 Merge remote-tracking branch 'origin/main' into pr-3988 2026-10-14 05:25:42 -04:00
Dragan Spiridonov dc9b25121b fix(memory): restore logging when database directory creation fails 2026-10-13 19:06:39 +02:00
martinvladandClaude Opus 5.5 114c97a32f fix(memory): create the AgentDB directory before the bridge opens it (#4132)
In a project without `.swarm/` (any fresh git worktree), getRegistry passed
`<root>/.swarm/agentdb-memory.db` to registry.initialize() without creating
the directory. better-sqlite3 refuses a missing parent, so AgentDB was marked
unavailable, the degraded registry was cached for the server's lifetime, and
hierarchical memory silently ran on the volatile fallback while every store
reported success. Create the parent directory first (skipped for :memory:).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RMjr52YGVk9fkqtNvb5jg2
2026-10-13 07:57:21 -07:00
RuFlo 18ecd8ae7b fix(memory,hooks): keep the on-disk format on sql.js write-back (#4057); command-recording off switch, redaction and a cleanup that sees expired rows (#4056)
#4057: with encryption at rest on, `memory purge`'s sql.js fallback rewrote a
plaintext native SQLite store as an RFE1 blob and still printed [OK]; the
native bridge and every SQLite reader then rejected the file. Every whole-file
read-modify-write (purge, delete, get access-count, store, schema migration,
decay) now writes the image back in the format it read (plaintext -> plaintext,
RFE1 -> RFE1) via writeDbImagePreservingFormat. applyTemporalDecay also read
the raw bytes, so it failed on encrypted stores, and wrote plaintext: both
fixed.

#4056: `hooks post-command` stored every Bash command in full with no off
switch. Add CLAUDE_FLOW_HOOKS_RECORD_COMMANDS=0 / CLAUDE_FLOW_HOOKS_ENABLED=false /
hooks.recordCommands=false (nothing is stored when off), redact common secret
shapes and cap stored text at 2000 chars (bounded patterns, linear on hostile
input). `memory cleanup --expired-only` never saw expired rows because
listEntries hides them (TTL is a read-time rule): listEntries gains
includeExpired + expiresAt, and memory_cleanup uses it. ruflo-core 0.2.8: the
Bash shim stands down when recording is off.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-11 14:07:02 -04:00
randRuFlo 41fe2242e5 fix(memory): read the RFE1 header in a bounded child so the sniff cannot drop live SQLite locks (#4040)
Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-10 18:59:36 -04:00
rUv c75a1ed34c Merge pull request #3955 from ruvnet/fix/node24-better-sqlite3-abort
fix(memory): open AgentDB with our better-sqlite3 so Node 24 does not abort
2026-10-10 07:50:41 -07:00
rUv 2145a31f0d Merge pull request #3958 from ruvnet/fix/agentic-flow-root-import
fix(cli,integration): never import the agentic-flow root entry (it runs agentic-flow's CLI)
2026-10-10 07:50:39 -07:00
Marius CarlssonandClaude Opus 5.5 d719737054 fix(learning): persist trajectory counts across processes; daemon jobs feed SONA
- intelligence.ts: stats.json persistence is now delta-merged (read-merge-
  atomic-rename) instead of overwriting with the process-local snapshot. The
  memory-bridge recordSignalProcessed() path persisted without ever loading
  stats.json, resetting trajectoriesRecorded/patternsLearned to 0 on disk
  every 16 writes; concurrent MCP server + daemon also erased each other.
- getIntelligenceStats() lazily loads persisted stats so read-only status
  processes (ruvllm_status, neural status) report the real totals.
- Neural data dir honours CLAUDE_FLOW_CWD like getProjectCwd().
- ruvllm_status: add native.trajectoriesRecorded (project-persisted) next to
  the process-local `trajectories` buffer count.
- worker-daemon: every finished worker job records a one-step trajectory
  (success/failure verdict). Opt-out: RUFLO_DAEMON_NO_LEARN=1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 15:33:24 +02:00
Dragan Spiridonov c536e77fda fix(memory): reroute the stale-lock retry AgentDB too; memory 3.0.4
Rebased onto main, where ControllerRegistry and AgentDBBackend build AgentDB
inside withAgentdbLockRecovery(); useHostSqliteDriver() now runs inside that
closure right after each `new AgentDB`, so the instance a stale-lock retry
creates also opens its handle with getHostSqliteDriver(). Tests drive the
retry path for both sites.

@claude-flow/memory 3.0.3 was published by 3.56.3 without the driver, so
this ships as 3.0.4 and the CLI pins 3.0.4. The #3693 memory-owner test
now reports a skip when no native addon is available instead of passing.
2026-10-10 09:49:07 +02:00
Dragan Spiridonov d4458abdff fix(memory,cli): keep the CLI's better-sqlite3 handles on AgentDB's copy
Follow-up to the AgentDB driver change. shared-sqlite.ts (#3693/#3883)
resolved better-sqlite3 from agentdb's location so CLI handles share
AgentDB's native copy. With AgentDB now opened through
@claude-flow/memory's better-sqlite3, that put graph-edge-writer, the
memory-initializer repair paths, backup restore, distillation, tuning and
the attestation log back on agentdb's nested 11.x: `hooks post-task` still
loaded both addons (and aborted on Node 24), and mixing copies on one file
can delete the -wal/-shm sidecars under AgentDB's live handle.

- @claude-flow/memory exports getHostSqliteDriver(), the one source of the
  constructor; useHostSqliteDriver() opens AgentDB with it and reports
  whether it replaced the loader.
- shared-sqlite resolves better-sqlite3 from @claude-flow/memory when the
  installed memory carries agentdb-native-driver.js, else from agentdb as
  before, so either memory version keeps one copy per process.
- @claude-flow/memory 3.0.3, CLI pin 3.0.3 (leaf-publish gate).

Tests: identity between AgentDB's handle constructor and
loadBetterSqlite3(); #3693 owner model for the memory holder and the
pre-3.0.3 fallback; both AgentDB construction sites; routing against a
real nested copy; a drift guard on agentdb's initializeDatabase contract.
2026-10-10 09:44:50 +02:00
randRuFlo 01fa240e7c wip(memory): agentdb alpha.20 floor + sql.js lock/concurrency guard
Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-09 17:17:36 -04:00
Dragan Spiridonov 74669662f7 fix(cli,integration): never import the agentic-flow root entry
agentic-flow 3.0.0-alpha.1/.2 call their CLI main() at the bottom of
dist/index.js with no is-main guard (2.x has one). Importing the root as a
library therefore parses the host's process.argv: with `--help` it prints
agentic-flow's help and exits the host, with `mcp start` it would start its
MCP server, and with no agentic-flow flag it runs its demo agents with
whatever model credentials are in the environment, plus a health server on
:8080 and a runtime patch that rewrites files under node_modules.

The root import was only ever a fallback or a probe for exports that no
published root has (`embeddings`, `createAgenticFlow`, `VERSION`,
`configTuning`; checked 2.0.14, 2.1.4, 3.0.0-alpha.1/.2):

- cli memory-initializer: drop the dead root `embeddings` fallback.
- cli hooks token-optimize: drop the root availability fallback; the root
  re-exports the same reasoningbank module the subpath check already loads.
- integration TokenOptimizer: detect agentic-flow from the reasoningbank /
  agent-booster subpaths instead of the root.
- integration AgentAdapter, SwarmAdapter, AgenticFlowBridge: stop importing
  the root for a `createAgenticFlow` factory no release exports; keep the
  existing local-implementation path and events.
- integration SDKBridge: use the baseline version instead of a root VERSION
  export that does not exist.
- Point the "for ML embeddings" comments at agentic-flow/reasoningbank.

The regression test runs the CLI source in a child process with loader
hooks that replace the root entry with a marker, and scans v3 sources for
any root-entry import.
2026-10-09 20:54:48 +02:00
randRuFlo 6625465a50 fix(cli): ensureSchemaColumns rewrites the store only when something changed (#3918)
The status backfill set modified=true even when the UPDATE touched 0 rows, so
every open of an up-to-date store re-exported and rewrote the whole image; with
encryption at rest each write uses a fresh nonce, so read-only commands such as
'memory stats' changed the RFE1 bytes every call. Gate on getRowsModified().

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-08 22:50:40 -04:00
randRuFlo e201290385 style(memory): move append-conditions imports below the file header (#3750 review nit)
Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-08 16:56:05 -04:00
r fa7e4a966c Merge branch 'pr-3750' into feat/release-3.56.0-batch 2026-10-08 16:55:50 -04:00
r be5da99198 Merge branch 'pr-3904' into feat/release-3.56.0-batch 2026-10-08 16:55:50 -04:00