#3516·ruflo

[Dream Cycle 2026-09-28] memory: mmrRerank() cosine running-max-cache + plugins,automation scan

Author: ruvnetCreated Sep 28, 2026Updated Sep 28, 2026
Labelsdream-cycleresearchmemorypluginsautomation

1. Tonight's Rotation

DATE=2026-09-28
DEEP=memory
SCAN=plugins,automation
SLOT=3 (DAYINT % 5)
No bonus deep-dive triggers (DAYINT%25=3, DAYINT%75=53)
Session commit: b14c79e6f7793a358f13b7e3f9b5eb27317b4988

2. Ledger Check

Inspected docs/dream-cycle/LEDGER.md (last 14+ rows) and verified GitHub state via MCP tools (gh CLI unavailable this session — same FALLBACK-for-gist-only condition documented since 2026-09-17). Confirmed via search_pull_requests/pull_request_read:

  • #3476 (2026-09-27, intelligence, CLAUDE_FLOW_FISHER_DECAY env override) — still OPEN/draft, not yet transcribed to the ledger. Its own memory-scan finding is what tonight's candidate acts on.
  • #3412 (2026-09-24, dream/2026-09-24-github-safe-artifact-parity, a real security fix for issue #3411, not a standard Dream Cycle rotation) — MERGED 2026-09-26.
  • #3395 (2026-09-22, intelligence, EWC EMA direction) — MERGED 2026-09-26.
  • #3339 (2026-09-16, security, hive-mind auth round 2) — still OPEN/draft (811-line PR, larger scope, human review pending).
  • Bulk-search of search_pull_requests with head:dream/ shows most 09-15..09-22 PRs now state:closed (a fresh review batch on 2026-09-26, distinct from the earlier 2026-09-14/15 sweep); spot-verified 2/2 as genuinely merged:true via pull_request_read (not trusting search_pull_requests's own merged field, per the 2026-09-21 ledger note that it's unreliable).
  • No PR/branch found for 2026-09-23, 2026-09-25, 2026-09-26 — consistent with #3475's own noted no-run-gap pattern (2026-08-20..23, 09-13/14).

Not fully re-transcribing every row here (ledger update below adds tonight's own row only, per the established "avoid another copy stuck on another unmerged branch" convention).

3. Deep Dive Findings

See gist "What's New in 2026" / "Ruflo Current Capability". Summary: v3/@claude-flow/memory/src/smart-retrieval.ts's mmrRerank() embedding-cosine path re-walked the entire selected-item list every outer-loop pass (≈O(candidates×selected²) pairSimilarity calls), even though PR #3169/#3266 already made the Jaccard-fallback tokenization lazy. This is the exact finding 2026-09-27's own memory scan flagged grade-A and recommended for "the next memory night." Independently re-verified via direct code read (not assumed stale) before implementing.

4. Hypothesis

Given mmrRerank()'s embedding-cosine path recomputing max-similarity-to-selected from scratch every round, when a running per-remaining-candidate cache is added that folds in only the newest selection each round (mathematically identical to recomputing max(0, s_1..s_k), since max is associative), then total pairSimilarity calls should drop from O(candidates×selected²) to O(candidates×selected) and wall-clock should measurably improve, subject to: (1) selection order is byte-identical to the old algorithm across all-embedded/no-embedding/mixed/negative-cosine/lambda-extreme scenarios; (2) the Jaccard fallback path is untouched; (3) all existing MMR/smart-retrieval tests remain green; (4) deterministic, $0 evaluation.

Frozen before evaluation; not modified after seeing results.

5. Evaluation Receipt

evaluated: accepted. Vitest 4.1.8, deterministic, $0, zero LLM calls, against a freshly pnpm install-ed v3/ workspace (this checkout's v3/ pnpm workspace was not pre-built at session start). New file v3/@claude-flow/memory/src/mmr-rerank-cosine-cache.test.ts (11 tests): correctness parity vs. a frozen copy of the old algorithm (5 scenarios incl. a dedicated negative-cosine zero-floor edge case), a call-count comparison between two parallel frozen copies (old vs. new — not vi.spyOn on the production export; a throwaway debug test confirmed Vitest's ESM spy cannot intercept a same-module internal call, so a spy-based count would silently read 0 regardless of real behavior), and a wall-clock test against the real applyMMR export.

All 20 MMR-related tests (11 new + 9 pre-existing) pass against the candidate. Stash-isolated against the real, unmodified baseline: 10/11 new tests still pass trivially (comparing frozen copies to each other, an invariant); the one true discriminator — wall-clock of the real applyMMR export at N=200/limit=100 — fails on baseline (686.5ms vs. a 343.3ms/2x threshold, chosen before running) and passes on the candidate (consistently >2x faster). Full @claude-flow/memory suite: 564/565 both ways — the one failure (a chmod-read-only-file test in auto-memory-bridge.test.ts) reproduces identically on stash-isolated baseline, confirmed environmental (root-user chmod doesn't block root writes), unrelated to this change. tsc --noEmit: 0 errors, both ways.

6. Darwin Results

Skipped — structural algorithmic refactor (fixed data-structure change), not a continuous parameter with a fitness gradient for Darwin's real interface (npx ruvector harness darwin <config> --execute, confirmed available via control-plane discovery) to search over. Same skip class as nearly every accepted Dream Cycle night since 2026-08-18.

7. Flywheel Evidence

No .claude-flow/flywheel/ state or applicable signed bundle for a deterministic correctness/perf fix (confirmed via npx ruvector harness flywheel --help, which targets LLM-task-corpus evidence). Evidence retained as: the 11 new tests, this issue, the committed gist, the stash-isolated baseline-vs-candidate comparison, and the witness below.

8. Reward Hack Check

Manual checklist (no standalone reward-hack CLI reachable): no test weakened (new file only, existing 9 MMR tests untouched, still pass); no gold data touched; no cherry-picking (full package suite run both ways, one pre-existing unrelated failure disclosed); no seed manipulation (deterministic pseudo-embeddings); zero cost; the 2x wall-clock threshold was fixed before running, not tuned to pass after seeing results (well under the ~10x the call-count math predicts, for CI robustness).

9. Security Review

Not security-sensitive — pure internal data-structure/algorithm change on an already-trusted comparison path; no new user input, no auth/filesystem/network surface change.

10. Scan Findings: plugins

Re-verified 2026-09-27's finding as still true (unchanged since a version-bump-only commit): installCommand's --verify flag is dead; installFromNpm/installFromLocal take no checksum parameter; the tested PluginIntegrityVerifier is never imported in cli/src. New tonight: the IPFS-signed registry lookup is cosmetic at install time — real install always runs plain npm install against public npm, never verifying against the IPFS-hosted/checksummed tarball, so plugins info can show Trust: official while the installed bits are unauthenticated by any of that metadata. trust-anchors.json still holds a placeholder all-zero key. Grade A. Candidate for a future plugins/capabilities night.

11. Scan Findings: automation

5 of 12 documented background workers (ultralearn, preload, deepdive, refactor, benchmark) appear in WorkerType and the daemon's own CLI help but are absent from DEFAULT_WORKERS (worker-daemon.ts:145-155) — every dispatch path gates on config.workers, so these 5 can never run (silent no-op on enable, thrown error on trigger). Execution logic for all 5 still exists — dead configuration, not missing code. Grade A, file:line confirmed. Separately confirmed (not novel): no in-repo trigger/schedule exists for the Dream Cycle routine itself (LEDGER.md self-documents it as .github-external). Candidate for a future automation night.

12. Competitors Reviewed

LangGraph, AutoGen, CrewAI, OpenAI file_search, Qdrant, Weaviate — full comparison table in the gist. Headline: Weaviate ships this exact running-max-cache optimization in production (adapters/repos/db/vector/selection/mmr.go, GA'd 1.39/2025), confirmed via direct GitHub source read — while Qdrant's native MMR and LangChain's reference implementation (reused by Chroma etc.) both still do the naive full-rewalk or worse. No agent-orchestration framework treats diversity re-ranking as memory-layer-native at all.

13. Gist

docs/dream-cycle/dream-gist-2026-09-28.md (this branch).

14. Witness

Field Value
Session commit b14c79e6f7793a358f13b7e3f9b5eb27317b4988
Gist SHA-256 (pre-witness content) 7eb8ee7e3c1af889f759f1063894ac37fc79a10e38ca2b9f3fb818e5aeee7c7a
Witness stamp 85e464a6c739aa9e938a93b4d70131d96e534096a007493993a4a013d1169b2b

Self-verified end-to-end against the committed file before this issue was written (stripped witness table back to PENDING, re-hashed, re-derived the witness stamp, confirmed exact match).

15. Recommendation

ACCEPT. Human review and merge of the linked draft PR — one file (+35/-11 net) plus one new test file, one conceptual change, zero regressions, matches the precedent class of #3169/#3266/#3330. Follow-ups (not tonight): wire up the 5 dead worker types (automation), wire PluginIntegrityVerifier + real checksum verification (plugins/capabilities), fix hnsw-index.ts's missing binary/scalar quantization dispatch (memory, future night).


Generated with RuFlo

https://claude.ai/code/session_01NQn4ZDMLEVvSwbgKEfVgwg