* fix(security): managed-agent tools refuse sessions this project did not create
managed_agent_prompt, status, events and terminate accepted any session id
in the Anthropic organisation, so a prompt-injected caller could read,
steer or delete sessions it never created. managed_agent_create now records
each session and its environment in .claude-flow/managed-workflows/sessions.json,
and the four tools refuse any session that is neither in that ledger nor in
RUFLO_MANAGED_CONTROL_SESSIONS, before any provider request. Terminate also
deletes only the environment recorded for the session, and forgets the
session once it is deleted.
Fixes#4751
* fix(managed-agent): keep the session ledger outside the workspace and check environments with the provider
The ledger moves to ~/.claude-flow/managed/<sha256(realpath(cwd))>.json (the
dispatch queue's state directory, RUFLO_AI_BUDGET_DIR honoured), so an agent
that can write project files cannot grant itself another session. Terminate
now asks the provider which environment a session runs in before deleting
one, and refuses when the ledger disagrees.
The ledger lock records its owner and is broken once older than 5 s, a
corrupt ledger is set aside as .corrupt-<ts> on write, and create warns when
the 1000-entry cap drops a session. The ruflo-agent managed-agent skill no
longer says to terminate stale sessions from list (ruflo-agent 0.4.3).
Tests cover a forged-ledger environment delete, a workspace ledger, a stale
and a live lock, a corrupt ledger, the cap, and eight processes creating at
once.
Refs #4751
* ci(env-audit): register RUFLO_MANAGED_CONTROL_SESSIONS as a host-only escape hatch
The managed-agent allowlist is a trust boundary (#4751): a caller must not be
able to widen it, so there is deliberately no CLI flag to take precedence.
Co-Authored-By: RuFlo <ruv@ruv.net>
---------
Co-authored-by: r <r@x>
Co-authored-by: RuFlo <ruv@ruv.net>
* fix(hooks): read $(...) substitutions and parameter defaults in the root-delete guard
hasRootDelete parsed backtick substitutions but not $(...): the $ joined
the word and ( reset the rm being parsed, so rm -rf "$(echo)"/ and
rm $(:) -rf / passed while their backtick spellings were refused. A $(...)
body is now matched past quotes and nesting, scanned as its own command,
and dropped from the word, as a backtick one is. $((...)) is arithmetic:
its body is still scanned and a digit stands in for it. Once a $( never
closes, the rest of that scan reads ( and ) as separators, as before.
A parameter's default (X:-word, X-word, X:=word, X=word in dollar braces)
is now judged as the word the shell uses when the name is unset, so
rm -rf ${X:-/} is refused. Single quotes keep it literal.
Same change in both hook-handler.cjs copies, the generated fallback and
the ruflo-mods guard (0.16.3), with parity cases in mods-guard.test.ts.
The packaged helper is signed, so helpers.manifest.json needs a re-sign.
Fixes#4742
* fix(hooks): fail closed on an unclosed $( and read array/indirect defaults (ruflo-mods 0.17.2)
closeParen now skips $'...' strings with their escapes and # comments, so
rm -rf $(echo $'\'')/ and a ) inside a comment no longer end the scan early.
A $( that never closes in a command with an rm in it is refused instead of
read the old way. The parameter matcher takes an optional leading ! and a
[...] subscript, so ${A[0]:-/} and ${!X:-/} are refused. Same change in all
four guard copies, with the review's inputs as parity cases.
Refs #4742
* chore(helpers): re-sign the helpers manifest for the #4848 hook-handler guard
#4848 changes .claude/helpers/hook-handler.cjs, so the signed manifest's
hash no longer matched (guard: helper-signing.test.ts integrity mismatch).
Re-signed with the release key; helper-signing + mods-guard: 312/312.
Co-Authored-By: RuFlo <ruv@ruv.net>
---------
Co-authored-by: Parman Mohammadalizadeh <prmma23@gmail.com>
Co-authored-by: r <r@x>
Main went red at 795a156dd (#4839): the first doctor-json-cli test cold-starts
tsx in a spawnSync child (30 s budget) but timed out at 5.16 s, because the
repo-root vitest config CI's Test Suite uses has no testTimeout (5 s default).
#4839 added an 8-way parallel CLI test, so the runner is busier and the cold
start crossed 5 s. Set a describe-level 45 s timeout. Test-only change.
Co-authored-by: r <r@x>
bin/cli.js swallowed every error from shutdownBridge(), so a refused
sql.js save (AGENTDB_LOCK_UNRECOVERABLE) exited 0 and the write was
lost. Only that error now prints a clear message and sets exit code 1.
Refs ruvnet/ruflo#4733
Co-authored-by: rUv <ruv@ruv.net>
Resolve the native router storage path through the existing project memory root so initialization does not create ruvector.db in the working directory. Add regression coverage for default and configured memory roots.
Fixes#4741
Signed-off-by: Sérgio Luiz Santos Neto <sneto.dev@gmail.com>
Co-authored-by: Sérgio Luiz Santos Neto <sneto.dev@gmail.com>
Co-authored-by: rUv <ruv@ruv.net>
AgentDBVectorStore.search returned [] for an entry that was stored: after a
delete and re-insert of the same id, ruvector-core's HNSW can leave the new
node unreachable from the graph's entry point. Measured with the backend's
own VectorDb options: 28/3000 searches missed the re-inserted id; through
the store, 8/1000 before this change and 0/1000 after. This is the
intermittent agentdb-vector-store.test.ts failure on main's CI/CD Pipeline.
The store keeps each entry's vector. When the index returns fewer of a
namespace's entries than it holds (counted before the minSimilarity filter,
so a floor alone never triggers it), the rest are scored exactly by cosine.
A deterministic test injects a backend that drops one id.
Bumps @claude-flow/aidefence to 3.2.2 and the CLI pin to match.
@claude-flow/aidefence@3.2.2 must be published before this merges
(audit-leaf-versions-published).
Co-authored-by: r <r@x>
hnsw-metadata-atomic-4739 mocked only '/@id/@ruvector/core', the ID Vite
gives the import when cli/vitest.config.ts externalizes @ruvector/*. CI's
Test V3 Packages job runs the v3 workspace config, which does not
externalize it, so the bare specifier was never stubbed, addToHNSWIndex
returned false and 3-4 tests failed. Main's V3 CI/CD Pipeline has been red
since #5001 (e0ad134ce). Register the same stub under both IDs.
Co-authored-by: r <r@x>
`hooks statusline --json` is parsed by ruflo's own V3 statusline helper,
which treats its stdout as the single source of truth. A diagnostic line
on that stream makes `JSON.parse` throw and silently demotes the helper
to the local file probes #2195 removed.
Current source already routes diagnostics to stderr, and output.test.ts
asserts that at the unit level by spying on the streams. This adds the
end-to-end half: a real subprocess, where anything writing to stdout
counts, not just the formatter.
Two conditions have to be forced or the test is inert. Autostart gates
on `isRufloProject()`, so a bare mkdtemp directory reports
`not a ruflo project` and never emits the daemon notice — each case
plants a `.claude-flow/config.json` marker. And autostart is
single-instance per cwd, so a reused directory returns clean JSON
regardless of routing — each case gets its own directory. The notice
races daemon readiness rather than firing only on call one, so the cold
case asserts across three invocations.
stdout is parsed whole, with no `indexOf('{')` slice, because the
contract is that stdout *is* the document.
Verified both directions against @claude-flow/cli-core: with
printInfo/printWarning on writeErrorln both cases pass; with them
inverted to writeln, as published 3.7.0-alpha.5 has them, case one
fails on call one with `[INFO] Started Ruflo background daemon` on
stdout and case two with `Unexpected token 'W', "[WARN] Fail"...`.
Refs #2909
Co-authored-by: rUv <ruv@ruv.net>
Over MCP, session_import (inputPath) and workflow_validate (file) read any
file the caller named and returned the JSON parser's error text, which
quotes the start of the file. Both now resolve MCP paths with
containedReadPath (regular file inside the project, no symlinks), the same
rule memory_import already applies. The local CLI marks its calls with
localCliContext so operators can still name any file. Parse failures now
return a fixed message, and workflow_validate reads through readImportFile
so the 16 MiB import limit applies.
Claude-Session: https://claude.ai/code/session_01MfPHVGRya9wHHpa9JZRJvY
Co-authored-by: Claude <noreply@anthropic.com>
v3/@claude-flow/watermark is a stale 0.2.0 copy of the package now built from ruvnet/ai-text-watermark (npm 0.4.x, crates.io 0.3.x). The npm package was already private, but still declared publishConfig, and the Rust crate remained publishable, so a recursive release could overwrite the canonical artifacts with stale code (#4959).\n\n- remove the contradictory publishConfig from the npm package;\n- set publish = false on the ruflo-watermark crate;\n- replace the README's stale 0.2.0 install/API guide with a pointer to the canonical source;\n- add a regression test and run it in the stable release gates so reopening either publish path fails before packing.\n\nRegistry attribution for the already-published 0.4.2 metadata remains owner-scoped to the @claude-flow publisher.
Co-authored-by: rUv <ruv@ruv.net>
Only --grok honoured --dry-run; every other mode ignored it and wrote the
project scaffold, $HOME/.codex and the mods settings. It now writes nothing
and says so.
Co-authored-by: r <r@x>
#4981 put agent_spawn, agent_execute and task updates of
agents/store.json and agents.json under locked-json-store, but
hive-mind_spawn, hive-mind_join and hive-mind_shutdown still wrote those
files with a plain writeFileSync of a copy read earlier. hive-mind_join
in particular wrote a stale agents/store.json back over agents spawned in
between.
Route all three through updateJsonStore with a fresh read inside the
lock. join re-finds the agent under each store's lock and reports "not
found" if it left every store in the meantime.
Tests ported from #4987 onto #4981's lock: overlapping-process
agent_execute/agent_update/agent_spawn, and lock ownership (release keeps
a successor's lock; a dead owner's lock is reclaimed, a live one is not).
New: hive-mind_join + hive-mind_spawn racing agent_spawn keeps every
agent (fails 3/3 without this change).
Co-Authored-By: nicholas-ruest <nicholas-ruest@users.noreply.github.com>
Co-Authored-By: RuFlo <ruv@ruv.net>
Ships the #4984 fix: AgentDB now uses the configured embedding model and
dimension, via @claude-flow/memory 3.3.3 (published) and the CLI memory bridge.
Co-authored-by: r <r@x>
* fix(memory): apply configured embedding model and dimension to AgentDB (#4984)
The registry created AgentDB with only { dbPath }, so memory_store and
memory_search kept using AgentDB's hardcoded MiniLM/384 embedder whatever
.claude-flow/embeddings.json said.
- registry: forward config.dimension as vectorDimension; install a supplied
embeddingGenerator in place on agentdb.embedder (awaited in init) and reject
vectors whose length differs from config.dimension
- cli bridge: pass a local-chain generator (real ONNX only, no bridge
re-entry) when the effective model is not the default
- cli bridge: label rows by the embedder that produced the vector instead of
inferring the model from vector length
Needs a standalone @claude-flow/memory publish to reach users.
Co-Authored-By: RuFlo <ruv@ruv.net>
* chore(memory): release @claude-flow/memory 3.3.3 and pin it in the CLI (#4984)
Co-Authored-By: RuFlo <ruv@ruv.net>
---------
Co-authored-by: r <r@x>
Concurrent writers did a plain read-modify-write of each store and lost
each other's updates. All writers now load, mutate and atomically save
under the store's lock file, reusing the policy runtime's acquireLock and
writeJsonAtomic. claims_claim and the workflow_execute start become atomic
check-and-sets.
The previous fix skipped one test; 'reports a missing package' fell through to a real import() and the
other suites call the real packages, so they failed in the repo-root npm ci job as well. Real-package
tests are now gated on the packages loading; the loader contract stays covered by stub importers.
Verified both ways locally: packages present 15/15, packages hidden 8 pass + 7 skipped.
Co-Authored-By: RuFlo <ruv@ruv.net>
The repo-root npm ci job (ci.yml Test Suite) does not install the three optional ruv-fann-wsp*
packages (they are in the CLI's pnpm lock only), so 'loads all three optional packages' failed on
the release PR's first CI run. When they are absent the test now asserts the explicit 'not installed'
report and skips; the missing-package tests cover the path with an injected importer.
Co-Authored-By: RuFlo <ruv@ruv.net>
Adds three exact-pinned optional dependencies of @claude-flow/cli:
ruv-fann-wsp@0.2.0, ruv-fann-wsp-invariants@0.1.0 and
ruv-fann-wsp-lifecycle@0.1.0. They reuse the ruv-fann@0.1.2 core and
ruv-fann-wasm@0.1.2 runtime that agentdb and darwin already install:
three new packages, no install scripts, no native code. The ruv-fann
0.3.0 facade is not used; it adds 60 packages including esbuild's
install script and a native RVF binding.
`neural wsp` subcommands (read-only evidence; nothing promotes or
reroutes):
- status: installed versions and limits
- inspect: fingerprint/shape (default: the centroid router)
- check: invariants; built-in self-routing suite for the centroid router
- gate: bounded-patch regression gate on user files
- export-centroid: centroid router as a ruv-fann dense model
Packages load by dynamic import inside those subcommands only; when
missing, each exits 2 with the reason. Input files must be regular
files of at most 2 MiB. Cold start and hooks route unchanged.
Co-Authored-By: RuFlo <ruv@ruv.net>
The warning was loud but both commands returned exit 0, so a hook runner
saw success when nothing was imported or synced. doImport/doSync now return 1
(packaged helper, repo copy and the init generator fallback); a thrown error
and the other commands are unchanged. Helpers manifest re-signed.
Co-Authored-By: RuFlo <ruv@ruv.net>
Follow-up to #4770. `security cve`, `analyze deps --security` and the
rvfa builder still ran npm with `2>/dev/null`, which fails under cmd.exe,
so on Windows they never got any output.
stderr is now captured through stdio instead. `analyze deps` also read
nothing when npm audit exited non-zero (which it does whenever it finds
vulnerabilities); it now reads the JSON from the error's stdout, the same
way security.ts does.
task_complete bumped taskCount for every assignee, even one that no
longer held the task. Completing a reopened task again (complete ->
pending -> complete, no reassignment) counted the same work twice,
which task_update already avoids by crediting only the holder.
- @claude-flow/memory: agentdb ^3.7.2 -> ^3.10.0, version 3.3.0 -> 3.3.2
(3.3.1 is already on npm from release/memory-3.3.1, not yet on main)
- @claude-flow/cli: optional agentdb ^3.6.0 -> ^3.10.0
- v3/pnpm-lock.yaml: agentdb 3.7.2 -> 3.10.0 for cli/memory/neural; the
orphaned 3.7.2 block is dropped; aidefence's peer still resolves 3.6.0.
New transitive packages come from agentdb 3.10.0's exact-pinned deps
(ruv-fann 0.1.2, ruv-fann-wsp 0.1.0, ruv-fann-wasm 0.1.2, ruvector 0.3.20,
@ruvector/* bumps).
The CLI's exact @claude-flow/memory pin is deliberately left at 3.3.0:
memory 3.3.2 must be published before that pin moves.
Co-Authored-By: RuFlo <ruv@ruv.net>
The "guard" check failed: __tests__/helper-signing.test.ts's Ed25519
provenance gate (ADR-174) caught that v3/@claude-flow/cli/.claude/helpers/
hook-handler.cjs -- the npm-shipped, cryptographically signed helper
artifact -- no longer matched helpers.manifest.json's signed hash. The
previous commit's CJS-mirror port (done by an independent adversarial
critic reviewing this PR) edited that file directly; re-signing it
requires the GCP-held ruflo-helpers-signing-key, a release-time operation
explicitly out of scope and authority for this nightly research session.
A second, separate test (session-start-hook-settings-risk-scan.test.ts's
"root and package hook-handler.cjs copies are byte-identical" check) means
the root copy can't diverge from the package copy either, so reverting
only one side was not an option.
Reverted hook-handler.cjs (both copies) and the parity-test's node/deno/
bun/php sample additions to their pre-critique state. The core candidate
(settings-risk-scanner.ts + its own test/corpus) is untouched and remains
ACCEPT on its own evaluation. The CJS-mirror gap the critic found is real
and still open -- recorded in the gist/issue as a disclosed, not-fixed
finding for a future night that can go through the real signing pipeline,
rather than fixed here by defeating the gate that exists to catch exactly
this kind of unsigned edit.
scanAllowRuleForRisk() flagged permissions.allow rules pre-approving
bash/sh/python/ruby/perl/curl/wget etc. with no per-call confirmation, but
not an equivalent pre-approval of node/deno/bun/php -- GTFOBins-documented
shell-breakout interpreters in the same risk tier as the words already
covered. This repo's own committed .claude/settings.json carries a live,
fully-unscoped "Bash(node:*)" allow-rule this exact scanner never flagged.
Adds a dedicated INTERPRETER_WORDS list feeding only RISKY_PREAPPROVE_WORDS
(scanAllowRuleForRisk), deliberately kept out of SHELL_EXEC_WORDS so
scanCommandStringForRisk's existing node-exemption for ruflo's own fixed
hook command strings stays untouched. Corrects the benchmark corpus's
Bash(node:*) ground-truth label (was malicious:false) and adds
deno/bun/php samples; recall 0.75->1.0, precision 1.0 both ways.
An independent adversarial critique (fresh context) confirmed the fix and
additionally found this session's TS-only change would have left the
hook-handler.cjs CJS mirror (used by the session-restore hook that runs on
every session boot) out of sync on these exact cases -- ported the same
word list into both copies and extended the CJS/TS parity-guard test to
cover it. This session closed the remaining non-blocking caveat (untested
prefix-collision safety for nodemon/phpunit/bunx/denoland) with a
dedicated regression test.
Dream Cycle 2026-11-11 (security, slot 1; scan: intelligence, swarm).
npm pack crashed under CI's parallel vitest run ("Exit handler never
called"). The guard now matches each default-path asset against the
package's `files` globs; it still fails on main.
Co-Authored-By: RuFlo <ruv@ruv.net>
With CLAUDE_FLOW_ROUTER_NEURAL=1 the router loads seed-router.krr.json,
the low/med/high KRR specialists, four isotonic calibrators and
seed-rows.json from assets/model-router/. None were in `files`, so an
npm install fell back to k-NN-less behaviour while a repo checkout used
the calibrated KRR. Ships those nine files byte-for-byte; leaves out
the FastGRNN safetensors (read only from CLAUDE_FLOW_ROUTER_MODEL_PATH)
and the provenance note. Tarball: +2.13 MB gzipped, +4.87 MB unpacked.
A pack-listing test guards every default-path asset, including the
ADR-527 centroid artifact.
Fixes#4954
Co-Authored-By: RuFlo <ruv@ruv.net>
0.14.0 adds an opt-in numeric surrogate (ruv-fann as an optional peer).
Without the surrogate config, evolveNumeric behaves as in 0.13.1, and
exports are unchanged. Moves the CLI range, the plugin's
DARWIN_PIN_VERSION and MH_DARWIN_PIN together. v3/pnpm-lock.yaml gains
a darwin@0.14.0 entry; 0.13.0 stays for metaharness, ruvector and
ruvllm-gpu-loop, which still declare ^0.13.0.
Fixes#4952
Co-Authored-By: RuFlo <ruv@ruv.net>
- A decided 'none' now reports NO_MATCH_CONFIDENCE, and a decided agent's
confidence is a monotone rescale above it: raw cosine (0.2-0.6) ranked 25 of
101 real test matches below a no-match (#3567). Raw cosine stays in
centroid.score.
- When AgentDB or a persisted SONA pattern answers first, the response carries
centroid.status 'bypassed' under the flag, so a pilot's fallback rate counts it.
- ADR: drop the 'wrong at >=0.7' claim (the raw scale never reached 0.7), record
the clean-install check, per-process CLI cost, and that the margin grid's
test accuracy was printed.
Co-Authored-By: RuFlo <ruv@ruv.net>
CLAUDE_FLOW_ROUTER_CENTROID=1 routes hooks_route tasks to the nearest MiniLM
centroid of the ADR-391 corpus dev split. Held-out test: 63.7% vs 25.7% for
the current default, falling back on 1.8% of prompts. Off by default: p95
latency fails the ADR-391 gate.
- Centroids are versioned with the embedder (embedder, model, dim); a query
embedded any other way is refused and the current router decides.
- Near-ties (top-two margin < 0.005) keep the current router's pick.
- Every flagged response carries centroid.baselineAgent for pilot comparison.
- The local embedder now records which model produced a vector (modelId).
- ruv-fann routing deferred: training never beat the centroid on dev CV.
Co-Authored-By: RuFlo <ruv@ruv.net>
@claude-flow/cli, claude-flow and ruflo 3.75.3. Carries #4905 (shared 3.0.8,
zod 4), #4947 (memory 3.3.1 pin), #4943, #4935, #4934, #4936 and #4938.
ruflo-graph-intelligence plugin 0.3.1 (the version audit ignores prerelease
tags, so 0.3.0 did not count as a raise over 0.3.0-alpha.1).
Co-Authored-By: RuFlo <ruv@ruv.net>