Skip to content

[Dream Cycle 2026-10-17] intelligence: agentdb-backend.ts calls a native HNSW controller that has never existed in the real agentdb package + capabilities,memory scan #4249

Open

Description

@ruvnet

1. Tonight's Rotation

DATE=2026-10-17
DEEP=intelligence
SCAN=capabilities,memory
SLOT=2
COMMIT=1882006a02487590c8c66a7eec8d7504f6af33c3
BRANCH=dream/2026-10-17-intelligence

2. Ledger Check

Read docs/dream-cycle/LEDGER.md (127 rows). Inspected the last 14+ rows.
GitHub-verified fates for the trailing recent nights (via pull_request_read,
gh CLI unavailable this session but GitHub MCP tools authenticated as
ruvnet): #4053 (10-11, security) MERGED, #3977 (10-10, performance)
MERGED
, #3929 (10-09, swarm) MERGED — a healthy, non-zero recent merge
rate, so no bias toward an artificially small candidate was needed on that
basis (the candidate below is naturally small anyway).

Nights 10-12 through 10-16 all ran as real branches/PRs (confirmed via
search_pull_requests, not inferred): #4081 (10-12, intelligence — SONA
learning-state persistence), #4138 (10-13, memory), #4174 (10-14, swarm),
#4215 (10-15, performance), #4230 (10-16, security) — all open/draft, none
of this is transcribed as its own ledger row here (same structural
"ledger rows only reach main via PR merge" gap documented repeatedly since
2026-08-19).

3. Deep Dive Findings (intelligence)

Exhausted-vein check (STEP 1.1): SONA/EWC/Fisher-matrix consolidation
wiring has been fixed/wired 6 times in the last ~2 months (#3110, #3395,
#3476, #3622, #3879, #4081) and ModelRouter prior-decay twice (#3049,
#3350) — both explicitly excluded from tonight's research as exhausted
directions.

Fresh 2026 research surfaced: SLEUTH epistemic working memory (basis of
Ruflo's own unimplemented ADR-367), "When Routing Collapses" (scalar-score
routers over-escalate to expensive tiers — a real structural analogy to
Ruflo's own fixed-threshold bandit router, flagged as a future-night
candidate), cheap linear-probe reward-hack detection vs. unreliable
LLM-judge-only detection, HNSW tombstone-repair literature, and SLoRA
continual-learning. Full report: see gist.

Candidate found via direct architecture review: AgentDBBackend
(v3/@claude-flow/memory/src/agentdb-backend.ts) — storeInAgentDB(),
searchWithAgentDB(), and getStats() each call
this.agentdb.getController('hnsw') inside a try/catch, expecting an
optional native HNSW controller from the agentdb npm package. Confirmed
by directly reading the real installed agentdb@3.0.0-alpha.20's
AgentDB.getController() switch statement (dist/src/core/AgentDB.js):
it recognizes only 'memory'/'reflexion', 'skills',
'causal'/'causalGraph' — anything else, 'hnsw' included, hits
default: throw new Error('Unknown controller: ' + name). All three call
sites always throw-and-silently-catch; searchWithAgentDB's catch
additionally logs console.error('HNSW search failed:', error) on every
single search call (confirmed firing in a direct reproduction against a
real, non-mocked agentdb instance) — pure noise, since the code
unconditionally falls back to the already-correct bruteForceSearch()
either way. This is the third instance of the same recurring pattern this
repo's ledger has already documented twice (2026-08-30 diskann-backend.ts
removal, 2026-10-10 graph-analyzer.ts native-acceleration correction):
aspirational "native acceleration" integration code checking for an export
or controller that was never real in the installed dependency.

4. Hypothesis

Given AgentDBBackend's three getController('hnsw') call sites, when
they are removed (the call always throws against the real agentdb
package and is unconditionally caught either way), then (a) the false
"HNSW search failed" stderr log disappears with zero change to search
results, and (b) a real, isolated, per-call thrown-exception cost is
removed, subject to: zero change to returned search results/ranking, zero
regression in the existing @claude-flow/memory suite, deterministic $0
evaluation. Frozen before evaluation; not modified after.

5. Evaluation Receipt

evaluated: accepted. Real evaluator: Vitest 4.1.8 against a real
(non-mocked) agentdb@3.0.0-alpha.20 instance (:memory: db), after a
full pnpm install --filter @claude-flow/memory....

  • Direct reproduction: a probe against the unmodified source shows
    console.error called with ["HNSW search failed:", {}] during a
    normal store() + search() — the bug fires in practice, not just in
    theory.
  • New test 1 (false-error regression guard): stash-isolated — fails on
    baseline
    (expected [] to have length 0 but got 1), passes on
    candidate
    .
  • New test 2 (tripwire): directly asserts the real agentdb package's
    getController('hnsw') throws /Unknown controller/ — so a future
    agentdb release that does add real HNSW support fails this test
    loudly instead of the dead code silently staying dead forever.
  • agentdb-backend.test.ts: 21/21 (baseline) → 23/23 (candidate, +2 new),
    0 regressions.
  • Full @claude-flow/memory suite: 614/616 both baseline and candidate —
    the 2 failures are pre-existing/unrelated (a read-only-file permission
    test that doesn't work running as root; an N=5000 perf test that timed
    out at 34s vs. a 30s ceiling, neither touching this file; the first
    confirmed failing identically on baseline via stash isolation).
  • tsc --noEmit: 0 errors, both ways.
  • Consumer regression check: hybrid-backend.test.ts +
    database-provider.test.ts 41/41 pass on candidate.
  • Isolated microbenchmark (NOT an end-to-end timing claim — a synthetic
    probe of the exact mechanism removed): a tight loop, throw-then-catch
    vs. direct-return, 200k iterations each: ~5.66µs/call vs. ~0.008µs/call,
    ~700x — consistent with V8's documented stack-trace-capture cost for
    thrown exceptions.

6. Darwin Results

Skipped — binary dead-code-removal/log-suppression fix, no continuous or
categorical parameter for Darwin's real interface
(npx ruvector harness darwin <config> --execute, confirmed available) to
search over. Same skip class as nearly every accepted fix in this repo's
history.

7. Flywheel Evidence

No .claude-flow/flywheel/ state exists in this checkout (same disclosed
gap as every recent night). Evidence retained as: the 2 new discriminating
tests, the direct reproduction probe, the full-suite comparison, the
isolated microbenchmark, this issue, the gist, and the witness below.

8. Reward Hack Check

No standalone reward-hack CLI reachable this session (npx ruvector harness --help has no reward-hack-detection surface). Manual checklist:
no test weakened (purely additive — 2 new tests, 0 modified); no gold data
touched; no cherry-picking (full suite disclosed both ways); no evaluator
exploitation; no cost hiding ($0, deterministic); no seed
manipulation; no undocumented caching; no threshold tampering. An
independent adversarial critic subagent is reviewing this diff in
parallel — its verdict will be added to this issue and the PR once it
lands.

9. Security Review

Not security-sensitive — pure dead-code removal plus removing a
misleading log line. No new I/O/network/credential/filesystem surface; no
change to what gets stored, searched, or returned. The removed code never
executed any real functionality against the actual dependency.

10. Scan Findings: capabilities

Unsigned/unverified capability claims in the live federation handshake
path.
v3/@claude-flow/plugin-agent-federation/src/domain/services/handshake-service.ts's
respondToHandshake() signs only signChallenge(challenge.nonce) — not
the capabilities list carried alongside it in the same response.
verifyChallenge() authenticates the peer via the nonce signature, then
trusts response.capabilities verbatim to compute
negotiatedCapabilities, which feeds trustLevel: TrustLevel.ATTESTED
sessions that CLI/policy consumers treat as authoritative. A peer that
passes signature verification (proves key possession) can still claim any
capability string without failing verification. Inconsistent with the
sibling establishDiscoverySession() path, which signs the whole
manifest (capabilities included) and is correctly capped at VERIFIED
trust as a result. Testable: a unit test tampering response.capabilities
after signing (keeping signedNonce/publicKey valid) should currently
succeed and negotiate the tampered capability. Flagged for a future
security night — not bundled into tonight's patch (different file,
different risk class).

11. Scan Findings: memory

A parallel scan independently flagged agentdb-backend.ts's
deleteFromAgentDB() never removing entries from the native HNSW
controller on delete (asymmetric add/no-remove). Direct investigation
(this issue, section 3 above) found the more fundamental fact: that native
controller path is entirely dead against the real agentdb package —
getController('hnsw') always throws, so nothing is ever added to a real
native index for delete to have failed to clean up from in the first
place. The scan's observation about hnsw-index.ts (Ruflo's own local
HNSWIndex class, confirmed to have working removePoint()/rebuild())
having no over-fetch factor in searchWithFilter-adjacent code remains
real and worth a future memory night wherever that local class is the
live backend (as opposed to the dead agentdb-native path fixed tonight).

12. Competitors Reviewed

Full 9-row survey (LangGraph, AutoGen, CrewAI, OpenAI Agents SDK, Qdrant,
Weaviate, Milvus, LanceDB, Vespa) — see gist for sources/grades. Synthesis:
no agent framework surveyed ships a learned-from-outcomes routing
mechanism or EWC++-class forgetting mitigation comparable to Ruflo's
SONA+MoE+EWC++ stack; this is a genuine, actively-researched open
field-wide gap, not solved-but-unpublished. On vector memory, Ruflo's
"1.9x–4.7x vs. brute force" figure remains uncorroborated against any
competitor on that exact metric — no source in the last 12 months
benchmarks any of the 5 surveyed vector DBs directly against brute-force
on matched hardware.

13. Gist

docs/dream-cycle/dream-gist-2026-10-17.md (this branch).

14. Witness

Session commit:  1882006a02487590c8c66a7eec8d7504f6af33c3
Gist SHA-256:    cbc84de295ffb01ce5ddbe2e6fa5a78b544228dabdda7129cdf18f8aaa19dba4
Witness stamp:   e2abed9831542617a74b3b0254ff4e775beea19199327a159dbd6138bf3d6914

Verifier: fetch docs/dream-cycle/dream-gist-2026-10-17.md from this
branch, SHA-256 it, concatenate with the session commit above, SHA-256
again — must equal the witness stamp.

15. Recommendation

ACCEPT the removal as low-risk, well-evidenced cleanup (dead code +
misleading log removal, zero behavior change to real functionality,
isolated and measured). Human review still required before merge per
standing policy. Carry forward for future nights: (1) the router
rank-collapse diagnostic (EquiRouter-class risk against Ruflo's own fixed
confidenceThreshold), (2) hardening/benchmarking the local HNSWIndex
tombstone path wherever it is the live backend, (3) the federation
handshake capability-signing gap (security night candidate).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions