Commit Graph
1984 Commits
Author SHA1 Message Date
randRuFlo cd1edcb418 fix(security): pin http_fetch connections to DNS-checked addresses (SSRF via DNS)
http_fetch refused loopback/RFC-1918/link-local hosts by looking only at the URL's hostname
text, then let fetch() resolve the name on its own. A name that resolves to (or rebinds to)
127.0.0.1, a private address or 169.254.169.254 passed the check and fetch() connected to it,
with CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE unset.

Requests now go through node:http/https with a lookup hook (http-fetch-pinned.ts): it resolves
every address of the host, refuses the host when any is private unless the opt-in is set, and
returns only the checked addresses to the socket, so the connection cannot land on an address
that was not checked (no TOCTOU between check and connect). Every redirect hop goes through the
same transport. Fresh connection per request (agent: false). IP literals are still checked by
text in validateUrl. The address check also covers ::, ::a.b.c.d, NAT64 64:ff9b::, 6to4
2002::/16, fe80::/10 and fec0::/10 in full, ff00::/8, 224.0.0.0/4 and up, 198.18.0.0/15 and
*.localhost.

Tests: a name resolving to loopback (localhost., no network) is refused and the internal server
sees no request, also as a redirect hop; the opt-in still reaches it; pinnedLookup refuses mixed
public+metadata answers, private IPv6 answers and empty answers, and passes public answers
through unchanged; address table. Redirect tests now inject the request function.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-30 14:43:40 -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 e9248a170e feat(security): plugin signing, scan before install, refuse risky project auto-approve keys (ADR-509) (#4593)
* feat(plugins): ADR-509 plugin trust — signing, scan before install, refuse project auto-approve keys

- scripts/sign-plugins.mjs signs every marketplace plugin (signature.json:
  sorted path+sha256 list, version, Ed25519 over canonical JSON) with the
  existing helpers key (same key resolution as sign-helpers.mjs; never
  printed). Nothing is signed with the real key here; release step in ADR.
- `ruflo plugins verify [name]` and `ruflo mods doctor` check the clone and
  install cache: verified / modified / unsigned / bad-signature, and write
  ~/.claude-flow/mods/plugin-verify.json per config dir.
- ruflo-mods plugin.register gate: under modTrust refuse-risky, a
  <name>@ruflo module whose clone is modified or bad-signature is refused
  (allow-list does not exempt it). Live-validated on Claude Code 2.1.289.
- Static scan of .mcp.json, hooks/hooks.json and hook modules before
  `claude plugin install` (mods install / init mods path) and before a
  local `plugins install`; a high finding blocks that plugin unless
  --accept-risk <plugin>, which is recorded in .claude-flow/mods/install.json.
- settings-risk-scanner covers enableAllProjectMcpServers,
  enabledMcpjsonServers, bypassPermissions, blanket Bash/* allows and
  non-ruflo hooks; `ruflo init` / `init hooks` / `init upgrade --settings`
  stop before writing anything (--keep-risky-settings / --drop-risky-settings);
  `ruflo doctor` warns on them in settings.json and settings.local.json.

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

* docs(adr): ADR-509 status names PR #4593

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

* fix(init): ADR-509 classify ruflo hooks by exact command; gate project-shipped helpers

isRufloHelperCommand no longer reuses pinToUserHelpers as a classifier: it
matches the closed set of commands ruflo generates or has generated (each
helper, subcommand, scope, platform, plus the legacy forms) by string
equality. node -e with extra code, -r/--require, --import, NODE_OPTIONS=
and a helper path in a comment are now findings. A project
.claude/helpers/<critical helper> that is neither ruflo's shipped copy nor
in a ruflo-signed manifest stops init too; --drop-risky-settings replaces it.

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

* fix(mods): ADR-509 a scan-blocked plugin is never left enabled

applyMods scans an existing marketplace clone before enabling anything and
does not enable what it blocks; a plugin the post-refresh scan blocks has
its enabledPlugins key removed and is dropped from the install record. The
--no-plugin-install, test/CI and no-claude paths are covered by the
pre-enable scan, and say when there is no clone to scan yet.

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

* fix(plugins): ADR-509 scan the modules hooks.json loads and their imports

The pre-install scan now resolves hooks.json `modules` against hooks.json
and follows every relative import/export-from/import()/require they reach,
with none of the walk's name, directory or size skips. A loaded file that is
missing, unreadable, over the size limit, outside the plugin, or loads a
computed module name is a high finding instead of being skipped.

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

* fix(mods): ADR-509 signature gate works on Windows and checks the loaded copy

The status file key is normalized the same way on both sides (forward
slashes, no trailing slash, Windows drive paths lower-cased), and the mod
finds the home the CLI used (USERPROFILE on Windows, else HOME).
plugins/.gitattributes turns off line-ending conversion so a Windows clone
hashes as signed. Every writer now records the install-cache copies too:
per plugin the worst of all copies, and each copy by its directory; the mod
looks up the plugin.register root first, so a tampered install cache next
to a clean clone is refused.

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

* fix(mods): ADR-509 match status path keys normalized; fix-pass notes

The mod compares the status file's per-copy path keys normalized, so a key
another writer spelled differently still matches the plugin.register root.
ADR-509 gains the review fix-pass implementation notes and live validation.

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

* fix(mods): ADR-509 report each blocked plugin once per run

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

* fix(cli): no env values in sign-plugins errors; RSA-2048 in the rejection test (CodeQL, ADR-509)

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

* chore(ruflo-mods): 0.12.0 for ADR-509

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

* test(mods): make mods-cli-bin failures readable (no more opaque STACK_TRACE_ERROR)

execFileSync's error holds Buffers and a process handle that vitest cannot
serialize, so a CI failure only said STACK_TRACE_ERROR. Rethrow a plain
Error with exit status, signal and the child's stdout/stderr tail.

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

---------

Co-authored-by: r <r@x>
2026-10-29 22:32:06 -04:00
rUvandr 5d2be9374a feat(cost): budget file, LiteLLM gateway export, per-agent/tool attribution (ADR-508) (#4592)
* feat(cost): ADR-508 budget file, LiteLLM budget export, per-agent/tool attribution

- .claude-flow/cost/budget.json (v1): `ruflo cost budget set --daily/--weekly/--monthly`
  writes it; the ruflo-mods ladder uses its smallest window when costBudgetUsd is 0.
  Hostile files (negative usd, unknown periods, oversized arrays) are no budget.
  Validator in both the mod and the CLI with a parity test.
- `ruflo cost budget export --gateway litellm` prints budget_limits (and, with
  --model, model_max_budget + budget_fallbacks) as YAML or the /key/generate body;
  --apply posts it to https or loopback only, key from --key-env, redirects refused.
  --gateway meta-llm fails with a pointer to ADR-508 (no documented budget API).
- ruflo-mods costLedger option (default on, ruflo projects only): session.measure
  deltas charged to subagent type and preceding tool, one line per session in
  .claude-flow/cost/attribution.jsonl, read by `ruflo cost report`; a gateway
  budget refusal is toasted once and counted.
- Live-validated on Claude Code 2.1.289 (fake LiteLLM on loopback + one haiku run).

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

* docs(adr): ADR-508 status names PR #4592

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

* docs(ruflo-mods): ADR-508 costLedger transcript read, open budget-file and default-on notes

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

* fix(cost): ADR-508 review — --apply host escape via // path, per-call attribution split

- keyGenerateUrl: a base path starting with // (or /\) resolved as a
  protocol-relative URL and sent the LiteLLM master key to another host
  (http://localhost//evil.example/ -> http://evil.example/key/generate).
  Refuse such paths, set the path on a copy of the parsed URL, and require
  the result to keep the given scheme and host.
- Attribution: session.measure fires once per main-thread turn, and a
  foreground subagent runs inside the main Agent call, so last-tool
  charging put subagent spend on main/Agent. Split each measured delta
  evenly across the tool calls completed since the last measurement.
- Tests in host event order and for the path escape; both fail on the
  previous code. ADR, README, cost report header state the estimate rule.

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

* docs(adr): ADR-508 live run of the per-call attribution split

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

* chore(plugins): ruflo-mods 0.11.0, cost-tracker 0.31.0 for ADR-508

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

---------

Co-authored-by: r <r@x>
2026-10-29 20:33:25 -04:00
rUvandr 49fe0b362b feat(mods): compactSnapshot — pre-compaction snapshot + post-compaction reload (ADR-505) (#4591)
* feat(mods): compactSnapshot — pre-compaction transcript snapshot + one-shot reload block (ADR-505)

New ruflo-mods option compactSnapshot (default on). On a main-loop manual/auto/plugin
session.compact it writes the transcript about to be summarized to
.claude-flow/sessions/compactions/snapshot-<n>.jsonl (role, text <= 2000 chars, tool
names/ids only; each line screened; 400 messages / 2 MiB; ten rotating slots), beside
the compaction so it is never blocked, delayed or rewritten. The next non-slash prompt
after a compaction that stood gets one [RUFLO_AFTER_COMPACT] context block (<= 2000
chars) from lessons shown this session, the last 5 loop outcomes, open swarm/claim ids
and the snapshot path. ruflo doctor warns when snapshots exist and git would commit them.

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

* test(mods): isolate the ADR-505 doctor test from global git excludes; note precompute inference

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

* docs(adr): ADR-505 status names PR #4591

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

* fix(mods): compactSnapshot screens raw message text before JSON encoding (ADR-505)

JSON escaping put a backslash before quotes and encoded newlines, so the
key-assignment rule missed "api_key": "..." / password="..." and the
line-start role-tag rule missed a \nsystem: line; those were written to the
snapshot in plaintext. messageLine now screens the raw cut text and the tool
names, plus the encoded line as before. Negative-control test added.

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

* chore(ruflo-mods): 0.10.0 for ADR-505

---------

Co-authored-by: r <r@x>
2026-10-29 19:41:08 -04:00
rUvandr 76845f22d3 feat(cli): load ruflo plugins in headless claude -p workers (ADR-510) (#4586)
* feat(mods): load ruflo plugins in headless claude -p workers (ADR-510)

claude -p on a fresh config loads no marketplace plugins, so ruflo's own
headless workers ran without ruflo-mods' guard, routing and learning loop.

- resolvePluginPaths: --source local checkout, then the marketplace clone,
  then the install cache; a folder without .claude-plugin/plugin.json is
  reported missing, never returned; honours CLAUDE_CONFIG_DIR.
- The daemon's HeadlessWorkerExecutor and `hive-mind work` add
  --plugin-dir <ruflo-mods> and CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 (unless
  set), never duplicate a caller's own --plugin-dir, and record a missing
  plugin (logged once) as missingPlugins on the result.
- `ruflo plugins paths [--json]` for Agent SDK callers; README section.
- `ruflo doctor --component headless-plugins` runs a real claude -p and
  checks the init event, plugin_errors and the mod heartbeat (runner
  injectable; skipped without a model credential).

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

* docs(adr): ADR-510 status names PR #4586

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

* fix(mods): headless plugin paths never come from project settings; stage hive-mind spawn -p (ADR-510)

- resolvePluginPaths no longer reads extraKnownMarketplaces from the
  project's .claude/settings.json or settings.local.json. A cloned repo
  could point every daemon worker and `hive-mind work` at its own folder,
  loaded via --plugin-dir with function hooks on and no trust prompt, in
  place of the user's ruflo-mods. "Local" is now only a directory
  marketplace in Claude Code's user-level known_marketplaces.json, and a
  relative path is rejected.
- `hive-mind spawn --claude --non-interactive` builds a `claude -p` worker
  too: it now goes through withHeadlessPlugins (staged before the prompt)
  and reports missingPlugins on data.claude. Interactive launch unchanged.
- Tests: project-scope settings (absolute or ./x) resolve to clone/cache,
  never the repo; relative path rejected; spawn-mocked hive-mind spawn
  test. All four new assertions fail on the previous commit.

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

* docs(adr): ADR-510 trust-boundary note records the live resolver check

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

---------

Co-authored-by: r <r@x>
2026-10-29 19:07:05 -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 27b48e6ba4 fix(github): redact credentials from github_repo_analyze remoteUrl (#4577)
github_repo_analyze returned `git remote get-url origin` verbatim. A remote
with embedded credentials (https://x-access-token:<token>@github.com/...,
the form CI checkouts and some credential helpers write) put the token into
MCP tool output, where it reaches the model and session transcripts.

Strip URL userinfo before returning it. Greedy up to the last `@` in the
authority, so a raw `@` in a password cannot leave a fragment behind.
scp-form remotes (git@host:o/r) carry no secret and are unchanged.

Found while reviewing #4571, which widened the same parser.

Co-authored-by: r <r@x>
2026-10-29 09:41:56 -04:00
ordinary being a7313c3de5 fix(hooks): disclose synthetic worker-detect dispatches (#4576)
hooks_worker-detect's autoDispatch created a worker record and marked it completed after a hardcoded 1500ms timer without running any analysis. Its sibling hooks_worker-dispatch already reports synthetic-completed and a no-executor note, but detect exposed the fake as an ordinary completed worker (#4549 automation scan, Finding A).\n\nMark records created by detect with synthetic:true and a no-executor note, use phase 'synthetic-completed', and return autoDispatchStatus/note in the handler response. worker-status and worker-list spread the record, so both surfaces now carry the disclosure.\n\nRegression uses fake timers: before 1500ms the record is running+synthetic; after, status completed, phase synthetic-completed, and the note is present. Baseline fails because autoDispatchStatus is undefined; candidate passes. Existing worker-dispatch status test 4/4 combined, tsc reports no errors in touched files.
2026-10-29 09:12:30 -04:00
nk-batman21 e4e5487efc fix(migrate): honor --dry-run in migrate run and migrate fix (#4568)
The parser stores `--dry-run` (and `-d` on `migrate fix`) as `dryRun`,
but both actions read `flags['dry-run']`, which is always undefined. So
`migrate run --dry-run` ran the real migration, overwriting an existing
.claude-flow/config.json, and `migrate fix --agents --dry-run` wrote the
restored agent files. Read `dryRun`, keeping the kebab key as a fallback
as update, init and mods do.
2026-10-29 09:12:26 -04:00
kevin eb51293ddd fix(github): read dotted repo names from the origin remote in github_repo_analyze (#4571)
The remote-URL pattern stopped the repo name at the first dot, so remotes
like vercel/next.js or socketio/socket.io did not match and the repository
was reported and stored as local/repo.
2026-10-29 09:12:22 -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
rUvandr c6f4e1025c fix(cli): accept type in agent_spawn and fix the remaining docs (#4542, #4557) (#4564)
#4543 fixed the six default skills, but 443 more agent_spawn calls with
`type` sat in the agent, command and Codex skill docs that init installs,
and projects initialised earlier keep their old copies.

- agent_spawn accepts `type` as an alias for `agentType` (agentType wins
  when both are sent) and reports a missing agentType by name, instead of
  the security schema's misleading "type: Required". Fixed in the CLI
  handler, so no standalone cli-core publish is needed.
- Rename the top-level `type` key of every mcp__claude-flow__agent_spawn
  call to `agentType` in .claude/{agents,commands}, the CLI and MCP package
  copies, and .agents/skills (443 keys, 71 files). Other tools'
  agent_spawn calls (flow_nexus, ruv-swarm) are untouched.
- coordination_sync: the schema now says `trigger` is refused (#4559)
  and that `force` is unused.

Co-authored-by: r <r@x>
2026-10-28 10:46:14 -04:00
Aaditya 17edaf1b12 fix(coordination): refuse coordination_sync trigger instead of simulating a sync (#4559)
coordination_sync trigger waited on a simulated 50ms "sync" (a
setTimeout), incremented syncCount, set lastSync, zeroed pendingChanges
and returned { success: true, action: 'synchronized', nodesSync }. No
state moved between nodes, and it did this even with no nodes
registered.

It now returns success: false with the reason and leaves the stored
sync record untouched, as neural_compress quantize/prune do (#4195,
#4423). status and resolve only report the stored counters and are
unchanged.

Fixes #4557
2026-10-28 10:22:31 -04:00
ordinary being 77a3465030 fix(daemon): stop the local audit worker faking a clean scan (#4563)
The default-on, critical-priority local audit fallback wrote noHardcodedSecrets: true and riskLevel: 'low' without inspecting any source. A daemon with no headless scanner therefore produced a believable clean security report every 10 minutes, the opposite of the honest-empty-stub convention used by sibling fallbacks (#4549 automation scan).\n\nReport scanned:false, noHardcodedSecrets:null, riskLevel:'unknown', and an explicit note/recommendation that only file presence was checked and no secret scan or code analysis ran. Existing env-file/gitignore presence checks are unchanged; persisted JSON and return value stay identical.\n\nRegression calls the private local audit path and asserts the report no longer claims a scan/risk level, then verifies the persisted security-audit.json matches. Baseline fails with scanned undefined; candidate passes. Existing worker-daemon timer test still passes; tsc reports no errors in the touched file.
2026-10-28 08:40:20 -04:00
Aaditya 04c637782f fix(agent): implement agent_pool fill instead of returning 'Unknown action' (#4561)
agent_pool advertised 'fill' in its action enum, but the handler had
no branch for it, so every fill call returned
{ error: 'Unknown action' }.

fill is now scale without the shrink step. It grows agentType's pool
to targetSize with idle agents and never terminates any; a target at
or below the current size is a no-op. It shares scale's targetSize
validation and agent creation. scale and drain are unchanged.

Fixes #4555
2026-10-28 07:05:18 -04:00
Aaditya 5ae2d6527b fix(hooks): build-agents writes under the project, validates outputDir, drops fake stats (#4562)
hooks_build-agents had three problems:

- It resolved outputDir against the process cwd instead of the project
  (getProjectCwd). A default call therefore wrote ./agents wherever the
  server happened to run, overwriting any agents/*.yaml there; run from
  v3/@claude-flow/cli, that meant the package's own tracked configs.
- It never validated outputDir, so a `..` traversal path was accepted
  and written to.
- It reported patternsApplied = agents * 3, although no pretrain data
  is read; the configs are built-in templates.

outputDir now goes through validatePath, as hooks_codemod's filePath
does, and relative paths resolve against getProjectCwd().
patternsApplied is 0, with a note that the configs are templates. The
`hooks build-agents` CLI command reports the tool's validation error
instead of crashing on result.agents.

Fixes #4558
2026-10-28 06:08:24 -04:00
Aaditya 6c0d58d010 fix(performance): report recorded latency/throughput, not fixed figures (#4556)
performance_metrics returned constant latency (current 45ms, p95 150ms)
and throughput (1250 ops/s) blocks. For the default metric 'all', it
labelled the whole response _real: true even with no samples recorded.

Latency and throughput now come from the samples performance_report
already records (latency.avg and throughput.operations, ADR-093 F8),
aggregated with the same calcStats as CPU and memory. With no samples,
each is reported as { available: false, samples: 0, _real: false } with
a note on how to record one, and a single-metric query returns
value: null. The top-level _real for 'all' is true only when every
figure was measured, and the single-metric _real comes from the metric
itself. CPU and memory are unchanged.

Fixes #4554
2026-10-28 04:52:11 -04:00
kevin bd19b6f984 fix(session): read hook-written session records in session_info and session_current (#4548) 2026-10-27 21:11:12 -04:00
kevin af091d5ffc fix(claims): stop claims_rebalance from overfilling the first underloaded agent (#4547) 2026-10-27 17:42:05 -04:00
kevin b49078cc40 fix(cli): match status aliases in the task_list status filter (#4536) 2026-10-27 10:39:12 -04:00
ordinary being 7cd18ca4e4 fix(cli): validate every http_fetch redirect target (#4534)
http_fetch validated only the initial URL, then called fetch with its default redirect:'follow'. A public URL could redirect to loopback/RFC1918/cloud-metadata or switch to file:// without ever passing validateUrl(), bypassing the SSRF allowlist. This is the redirect escalation called out as the natural follow-up to #4503/#4504.\n\nFollow redirects manually with redirect:'manual': cap at 10 hops, run validateUrl() on every Location, cancel redirect bodies, drop Authorization/Cookie/Proxy-Authorization on cross-origin hops, and apply fetch's 303/301/302 method rules. The reported URL is the final validated URL. Redirect validation failures return the same error codes as initial-URL failures (PRIVATE_ADDRESS/FORBIDDEN_PROTOCOL), with REDIRECT_LIMIT for the hop cap.\n\nSix regression tests mock fetch: loopback, IPv4-mapped metadata, file:// redirect, public relative redirect + final URL, cross-origin auth stripping, and the redirect limit. Baseline fails all six; candidate passes. Existing 37 http-fetch tests still pass, 43/43 total. tsc reports no errors in the changed file.
2026-10-27 09:29:32 -04:00
kevin 754d772462 fix(workflow): let condition steps read a step's output (step-N.output) (#4530) 2026-10-27 02:50:05 -04:00
Lenin Mookiah e30d81b845 fix(doctor): recognize matching npm launchers on Windows (#4473) 2026-10-27 01:21:35 -04:00
kevin 99d5410b49 fix(cli): count cancelled tasks in task_summary so the counts add up to total (#4489) 2026-10-27 01:20:43 -04:00
kevin bf76869089 fix(hooks): count pending workers in hooks_worker-status summary (#4529) 2026-10-26 20:39:20 -04:00
rUvandr 0219fc5d02 fix(daemon): daemon-queue entries no longer count as a manual trigger (#4515)
processDispatchQueue called triggerWorker, which set manualTrigger:true and skipped the
repository-supervisor gate, so a queue file committed in a repo ran headless workers
immediately. Queue runs now pass manualTrigger:false.

Co-authored-by: r <r@x>
2026-10-26 14:43:43 -04:00
rUvandr 3671915b8d fix(agentbbs): a .. in a room label can no longer move the room log outside basePath (#4518)
Co-authored-by: r <r@x>
2026-10-26 14:06:02 -04:00
rUvandr fc323f5108 fix(mcp): network transports start with a per-user token by default; WebSocket tokens work (#4516)
mcp start -t http|websocket with no token now uses ~/.claude-flow/mcp-http-token (0600,
created on first use) unless RUFLO_MCP_ALLOW_UNAUTHENTICATED_HTTP=1. The standalone
WebSocket transport authenticates the upgrade (Authorization: Bearer or ?token=); the
unreachable message-level 'authenticate' gate no longer fails every request, and the CLI
accepts --auth-token with websocket.

Co-authored-by: r <r@x>
2026-10-26 14:05:50 -04:00
Agustin Torres 1505a24033 Replace the models api.anthropic.com retired (#4512)
Replaced retired Claude model ids with Anthropic's recommended replacements at the places that send them or set them as defaults: the MCP sampling request, the CLI default provider config, and the provider quick-test requests.

Notice anthropic-retired-models-2026-10 about api.anthropic.com's API describes the change. It was read from a file and is not signed by the provider.
2026-10-26 12:10:53 -04:00
rUvandr c0f205629b fix(mcp): token-less HTTP/WebSocket transports refuse web pages, rebound hosts and open non-loopback binds (#4510)
Without a token the transports now check Host (loopback bind) and Origin (exact
allow-list, '*' does not count) on requests and WebSocket upgrades, and both refuse
to listen beyond loopback unless allowUnauthenticated is set.

Co-authored-by: r <r@x>
2026-10-26 11:33:00 -04:00
rUvandr 5b3bcc78cd fix(daemon): a cloned project's config can no longer enable AI workers (#4509)
daemon.aiWorkers.enabled is honoured only from the flag, RUFLO_DAEMON_AI_WORKERS=1
or the user-level ~/.claude-flow/config.json; a project file can only say false.
Headless worker context no longer globs **/.env*.

Co-authored-by: r <r@x>
2026-10-26 11:32:57 -04:00
rUvandClaude 9d854ddb9c dream(security): #4503 http_fetch SSRF bypass via IPv4-mapped IPv6 literals (evaluated, ACCEPT) (#4504)
* dream(security): http_fetch SSRF bypass via IPv4-mapped IPv6 literals

isPrivateOrLoopback() (the SSRF guard behind the http_fetch MCP tool's
validateUrl()) never stripped the "[...]" brackets Node's URL parser keeps
in `.hostname` for IPv6 literals. Two consequences:

1. The existing fc00::/7 (ULA) and fe80::/10 (link-local) checks
   (`host.startsWith('fc'/'fe80:')`) never matched anything, since `host`
   always started with "[" first.
2. There was no handling at all for IPv4-mapped IPv6 literals
   (`::ffff:a.b.c.d`, normalized by Node to a canonical `::ffff:xxxx:yyyy`
   hex form), so wrapping a loopback/private/link-local/cloud-metadata
   IPv4 address in that form bypassed the guard entirely
   (e.g. http://[::ffff:127.0.0.1]/, http://[::ffff:169.254.169.254]/).

Strips brackets once up front, then decodes IPv4-mapped-IPv6 forms back to
dotted-decimal and recurses into the existing IPv4 rules instead of adding
a parallel copy. 13 new tests (8 discriminating, verified to fail on the
pre-fix source via a stash-isolated run; 5 non-discriminating controls).

Independent adversarial critique: CONFIRMED-WITH-CAVEATS. Two pre-existing,
out-of-scope gaps disclosed in-source (IPv6 "::" unspecified address and
multicast/NAT64 ranges remain unblocked).

Co-Authored-By: RuFlo <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_013bqQefaQjXhYZX2Acr9Jop

* dream(security): add 2026-10-26 research gist

Full SOTA report for tonight's security deep-dive (http_fetch SSRF
bypass via IPv4-mapped IPv6 literals) plus intelligence/swarm scan
findings and competitor comparison. No gist-publishing tool reachable
this session (same disclosed FALLBACK as every night since 2026-09-30)
— committed to this branch instead.

Co-Authored-By: RuFlo <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_013bqQefaQjXhYZX2Acr9Jop

* dream(security): update ledger for 2026-10-26

Co-Authored-By: RuFlo <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_013bqQefaQjXhYZX2Acr9Jop

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-26 09:58:56 -04:00
rUvandr 18d2f18a4a fix(flywheel): skip the directory fsync on Windows so flywheel run can commit (#4492) (#4493)
Co-authored-by: r <r@x>
2026-10-25 14:39:07 -04:00
kevin 166aef93c7 fix(agentbbs): page forward from sinceEnvelopeId in federation_bbs_watch (#4480) 2026-10-25 02:39:08 -04:00
rUvandr f02989a78c fix(managed): refuse . and .. resource ids; guard reads common argument wrappers (ruflo-agent 0.4.1) (#4478)
Follow-up to the 3.63.0 security review (low severity #6 and #9); documents #7 and #8 as known limits.

Co-authored-by: r <r@x>
2026-10-24 23:49:51 -04:00
rUvandr db141ba70e feat: managed workflows, unified console runs and verified advisory learning (#4471)
* feat(agent): add bounded managed dynamic workflows and verified lifecycle observation

* feat(plugins): integrate managed workflows with mod policy and capability discovery

* feat(managed): unify console runs and verified advisory learning

* fix(managed): hydrate native recall receipts validated on ruOS

* docs(managed): record authenticated console host blocker

* docs(managed): qualify installed console and compatible native host

* feat(managed): integrate verified cycles and isolate native memory

* fix(managed): enforce offline native models and qualify feedback E2E

* fix(managed): independent security and correctness review findings

- gate managed_agent_interrupt through the managed_agent_control policy; terminate obeys the allowlist and deletes only its own environment when RUFLO_MANAGED_CONTROL=1
- track only events from the acknowledged message so a later poll cannot report the previous turn as finished
- require the canonical base64 verifier signature so one receipt cannot fill the ledger
- register RUFLO_MANAGED_AGENTS_BASE_URL as a trust-boundary env var (env-precedence audit) and key the credential scope marker with a per-process HMAC (CodeQL)
- best-effort local snapshot writes; report messageId when a prompt fails after it was sent
- console: rescheduling is running, budget/action-blocked sessions are active, not finished
- document the remaining known limits in ADR 0004

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

* docs: user guide section for managed cloud agents; correct ruflo-agent README counts

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

* fix(managed): scope marker is a generation number, never a hash of the API key (CodeQL)

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

---------

Co-authored-by: r <r@x>
2026-10-24 22:42:09 -04:00
kevin 6ed591a45a fix(memory): keep same-key entries from other namespaces in memory_search_unified (#4470)
Signed-off-by: kevin9327 <5299031+kevin9327@users.noreply.github.com>
2026-10-24 20:45:59 -04:00
rUvandr fe99f748c5 fix(daemon): explicit maxConcurrent/workerTimeoutMs win over saved daemon-state (#4462) (#4465)
Apply the #2935 explicit-wins gate to the two scalar fields restored in
initializeWorkerStates(): constructor arg > config.json > saved state > default.

Co-authored-by: r <r@x>
2026-10-24 13:45:23 -04:00
rUvandr 075503c34e fix(headless): cancel settles the execution, deadline timer cleared, escalation keys off exit (#4463) (#4466)
Co-authored-by: r <r@x>
2026-10-24 13:31:52 -04:00
rUvandr 24450bf9f7 feat(rure): rure_cuda_launch_plan — static occupancy plan for CUDA kernels (ADR-501) (#4464)
New read-only tool: per kernel and architecture, theoretical occupancy at several
block sizes, what limits it, the best sizes and flags; optionally the text of a
driver-API harness the person can build to check it on their own GPU. Nothing is
compiled, loaded or run by ruRE.

The model equals NVIDIA's cuda_occupancy.h on 1,770,216 combinations (8 archs,
limiting sets included; fingerprints committed so CI repeats it) and the CUDA
driver on real GPUs: RTX 5080, RTX 3090, RTX 4090, A100, H100. Found on hardware:
from sm_90 the cubin's shared size already includes the driver's 1 KiB reservation.

Also fixes the reader reporting sm_5 for standalone cubins from CUDA 12 (ELF OS ABI
51 keeps the SM number in the low byte of e_flags); real CUDA 12.8 cubins added.

ruflo-rure 0.6.0.

Co-authored-by: r <r@x>
2026-10-24 12:39:54 -04:00
rUvandr dd5d66cdb4 feat(rure): rure_analyze_cuda — CUDA fatbin, cubin and PTX static analysis (ADR-0006) (#4441)
* feat(rure): rure_analyze_cuda — CUDA fatbin, cubin and PTX static analysis (ADR-0006)

New read-only MCP tool and an original pure-TypeScript reader: fatbin
containers and entries (kind, sm_NN, zstd/LZ4 under size caps), cubin kernels
from the symbol table with registers (EIATTR_REGCOUNT), code size and
constant/shared/local memory, and PTX version/target/kernel names. Parses,
never executes; strings screened by AIDefence; decompression budget charged
per attempt. Checked against real nvcc 12.8 and 13.0 output (sm_75/80/90) and
cuobjdump: committed fixtures with recorded ground truth, plus a live test
that compiles with a local nvcc. ruflo-rure 0.5.0.

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

* fix(rure): rure_analyze_cuda description carries the ADR-112 'Use when' guidance

The tool-description audit (ADR-112) failed the PR: one tool without guidance.

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

* fix(rure): linear-time PTX sniff and scan (CodeQL js/redos, plus a quadratic one it did not flag)

looksLikePtx used a lazy comment pattern inside a repeated group, which
backtracks exponentially (CodeQL js/redos); it is now a forward scan. The
directive regexes in scanPtx matched with ^\s*, which rescans a whole run of
blank lines at every line start: 80000 blank lines took 4.6 s and 320000 took
71 s. They now match space and tab only and bound the rest. Tests: pathological
comment structure, and long blank-line and whitespace runs, all under 500 ms.

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

---------

Co-authored-by: r <r@x>
2026-10-23 17:21:30 -04:00
nk-batman21 1d6930e583 fix(cleanup): honor --keep-config (#4435)
The parser stores `--keep-config` and `-k` as `keepConfig`, but cleanup
read `flags['keep-config']`, which is always undefined. So
`cleanup --force --keep-config` deleted claude-flow.config.json and
stripped the hooks and claudeFlow blocks from .claude/settings.json
anyway. Read `keepConfig`, keeping the kebab key as a fallback as
update, init and mods do.
2026-10-23 14:06:44 -04:00
rUvandr 4efb421e33 fix(update): never treat an older registry version as an update (downgrade on 3.60.0) (#4432)
getUpdateType compared major, minor and patch independently. With 3.60.0
running and 3.59.17 as the registry latest, the minor check failed but
patch(17) > patch(0) returned 'patch', so the startup check auto-installed
3.59.17: a downgrade. It also made 'ruflo init' run npm install in the project
and time out the mods-cli-bin test on the 3.60.0 release PR.

An update is a strictly newer version: guard with semver.gt first.

Co-authored-by: r <r@x>
2026-10-23 12:48:58 -04:00
Aaditya 88349655eb fix(github): stop reporting merge/close/update success when nothing happened (#4425)
* fix(github): stop reporting merge/close/update success when nothing happened

github_pr_manage merge/close and github_issue_track update/close
returned success when nothing happened on GitHub:

- A failed `gh` call (merge conflict, failing checks, auth, unknown
  number) fell through to the local JSON store and returned
  { success: true, source: 'local-store' }.
- That fallback matched records with key.includes(String(n)) against
  `pr-<Date.now()>` ids. It returned success whether or not anything
  matched, and could mark an unrelated record (prNumber 12 vs
  pr-1786319612345).
- github_pr_manage validated owner/repo but never passed them to `gh`,
  so merge/close acted on the cwd's repository (fixed for issues in
  #2963).

Now:
- When `gh` is present, a failed command returns success: false.
- Offline, only a local record whose id is exactly pr-<n> / issue-<n>
  is updated; otherwise the call returns success: false.
- A missing number is an error.
- PR actions pass --repo owner/repo.

list/create and their offline local-store behaviour are unchanged.

Fixes #4424

* fix(github): include gh's error text when merge/close/update fails

Per the #4424 triage: a failed `gh` call now reports gh's stderr (or
the error message when there is none) along with the action, e.g.
"gh pr merge 12 failed: X Pull request #12 is not mergeable: ...".

runArgv keeps its string | null contract and is now a thin wrapper over
runArgvResult, which returns { out } or { error }. The four mutating
paths use runArgvResult directly.

Refs #4424
2026-10-23 09:59:23 -04:00
Aaditya f6c6a32432 fix(neural): refuse neural_compress prune instead of deleting every pattern (#4428)
neural_compress prune deleted every pattern whose usageCount was below
targetSize and saved the result. Nothing in the neural store records
usage: patterns are written with usageCount 0 and only max-merged by
distill and import. So any targetSize above 0, including the 0.5
default and a "10% reduction" of 0.1, deleted and persisted every
pattern while reporting success.

Prune now returns success: false with the reason, and never calls
saveNeuralStore(), until usage is actually tracked. This is the same
treatment quantize received in #4195. The targetSize schema description
no longer promises a 0-1 size reduction. neural_optimize's zero-norm
prune is a separate path and is unchanged.

Fixes #4423
2026-10-23 09:46:01 -04:00
Aaditya 55cb051880 fix(daa): record performanceScore 0 as a failure, not a 0.8 success (#4427)
daa_agent_adapt read the score as
`(input.performanceScore as number) || 0.8`:

- A failing score of 0 became 0.8, raised successRate, and was sent to
  AgentDB as { success: true, quality: 0.8 }.
- A missing score was recorded as the same fabricated 0.8 success.
- Out-of-range scores were accepted, although the schema says 0-1.

A given score must now be a finite number in [0, 1], and an invalid one
returns success: false without touching the agent. An omitted score
records no score: successRate and the AgentDB outcome are left alone,
while the adaptation itself (feedback and the adaptation count) is
still recorded.

Fixes #4426
2026-10-23 09:40:25 -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
DexandDextheking1 279cb1fbfb fix(agentbbs): reject .. in roomId in agentbbs-tools validator (#4416)
Co-authored-by: Dextheking1 <Dextheking1@users.noreply.github.com>
2026-10-23 07:36:53 -04:00