* docs(adr): ADR-129 — rvagent full integration (4 phases, post-3.7.0 baseline)
Proposes a 4-phase integration of @ruvector/rvagent-wasm@0.1.0 to make
WasmAgents first-class participants in the ruflo swarm.
## Gaps found in current code (verified by deep-researcher)
- agent-wasm.ts:165-196 — echo-stub bypass (JsModelProvider never
constructed; verified by `grep -rn 'new JsModelProvider'` returns 0
hits). WasmAgent.prompt() either echoes or hits a default — not
routed through the v3 provider system from #2042.
- agent-wasm.ts:420-429 — buildRvfFromTemplate silently drops
template.mcp_tools, so wasm_gallery_create can't surface MCP tools
to the agent.
- 10 of 13 gallery methods unexposed (loadRvf, configure, getCategories,
listByCategory, addCustom, removeCustom, importCustom, exportCustom,
getActive, getConfig).
- 6 agent introspection methods unexposed (get_state, get_todos,
get_tools, turn_count, is_stopped, reset).
- No bridge from any of the 35 ruflo plugins to the WASM agent runtime.
## 4 phases
| Phase | What | Smoke |
|---|---|---|
| 1 | JsModelProvider → callAnthropicMessages bridge | smoke-wasm-provider-bridge.mjs |
| 2 | wasm_agent_compose + addMcpTools bridge (314 tools) | smoke-wasm-rvf-compose.mjs |
| 3 | 16 new MCP tools (gallery CRUD + introspection) | smoke-wasm-gallery-crud.mjs |
| 4 | Plugin bridge contract | smoke-wasm-plugin-bridge.mjs |
## Top 3 risks
1. Billing expansion — Phase 1 turns wasm_agent_prompt into billable
LLM calls (was echo).
2. addMcpTools over-permissioning — Phase 2 default must be explicit
allowlist, not full dump (314 tools include destructive ones like
memory_delete, federation_*).
3. importCustom prompt-injection — Phase 3 deserializes user JSON in
the WASM runtime; AIDefence gate required.
No phase needs a separate ADR. Anchored in #2042 (provider routing),
ADR-115 (rvagent rename), ADR-127 (smoke pattern).
Co-Authored-By: RuFlo <ruflo-bot@users.noreply.github.com>
* feat(rvagent): #ADR-129 P1 — JsModelProvider routes WasmAgent through v3 provider system
Wire set_model_provider() at agent-creation time so the WASM runtime's
internal conversation loop dispatches through callAnthropicMessages
(Anthropic / OpenRouter / Ollama, same routing as agent_execute #2042).
Echo-stub fallback preserved for keyless environments. Smoke +
CI job added: smoke-wasm-provider-bridge.mjs / wasm-provider-bridge-smoke.
Co-Authored-By: RuFlo <ruv@ruv.net>
* feat(rvagent): #ADR-129 P2 — wasm_agent_compose + addMcpTools bridge (314-tool unlock with allowlist gate)
Fix silent drop of template.mcp_tools in buildRvfFromTemplate; extend
buildRvfContainer to accept mcpTools param → builder.addMcpTools().
Add wasm_agent_compose MCP tool with explicit allowlist, destructive-tool
gate (mcpToolsAllowDestructive required for *_delete/*_shutdown/federation_*),
and includePlugins P4 wire. Smoke + CI job: smoke-wasm-rvf-compose.mjs.
Co-Authored-By: RuFlo <ruv@ruv.net>
* feat(rvagent): #ADR-129 P3 — 16 new MCP tools (10 gallery CRUD + 6 introspection) with AIDefence gate on import
Add wasm_gallery_load_rvf, configure, categories, list_by_category,
add_custom, remove_custom, import (HIGH_RISK + AIDefence gate), export,
active, config. Add wasm_agent_state, todos, tools, turn_count,
is_stopped, reset. Export 10 new functions from agent-wasm.ts.
Smoke + CI job: smoke-wasm-gallery-crud.mjs.
Co-Authored-By: RuFlo <ruv@ruv.net>
* feat(rvagent): #ADR-129 P4 — plugin manifest "rvagent" field + includePlugins in compose
Add loadPluginManifest() + extractPluginSkills() to wasm-agent-tools.ts.
wasm_agent_compose gains includePlugins?: string[] — reads each plugin's
.claude-plugin/plugin.json, parses rvagent.exposeSkillsAsTools, and adds
matching skills to the RVF container. Unknown plugin name → warning,
not error. Smoke + CI job: smoke-wasm-plugin-bridge.mjs.
Co-Authored-By: RuFlo <ruv@ruv.net>
* fix(ci): #2120 — memory smoke uses pnpm (workspace: protocol unsupported by npm)
The memory-stats-legacy-db-smoke job hit `EUNSUPPORTEDPROTOCOL:
Unsupported URL Type "workspace:"` in CI because `cd v3/@claude-flow/cli
&& npm install` ran against a package.json with workspace:* deps that
only pnpm understands. Same pattern as the agent-execute smoke fix.
Switch the job to pnpm/action-setup + `pnpm install` + `pnpm --filter
@claude-flow/cli build`. The smoke logic is unchanged.
Co-Authored-By: RuFlo <ruflo-bot@users.noreply.github.com>
* fix(rvagent): #ADR-129 — pad 16 new wasm tool descriptions to ADR-112 spec (>=80 chars + Use-when guidance)
Co-Authored-By: RuFlo <ruv@ruv.net>
* feat(rvagent): #ADR-129 — benchmark suite (provider routing, compose, gallery CRUD, plugin enum)
Co-Authored-By: RuFlo <ruv@ruv.net>
* feat(witness): #ADR-103 — register ADR-129 P1-P4 fixes in witness manifest
Co-Authored-By: RuFlo <ruv@ruv.net>
* fix(ci): #2120 — pnpm install must run from v3/ (workspace root)
My prior fix (2d2091fe7) ran `pnpm install` at repo root, but the
pnpm-workspace.yaml lives in v3/, not at the root. Result: no
node_modules under v3/@claude-flow/cli, tsc errored on missing
@types/node, build never produced dist.
Mirror the working pattern used elsewhere in this workflow:
`working-directory: v3` + `pnpm install` + `pnpm --filter
@claude-flow/cli build`. Keep the root `npm install` for sql.js
which the smoke fixture imports from the repo root.
Co-Authored-By: RuFlo <ruflo-bot@users.noreply.github.com>
* fix(ci): #2120 — recursive build (CLI tsc depends on swarm dist)
Previous fix (cec3cef48) installed correctly from v3/ but the CLI's tsc
emits TS6305 because it has project references to @claude-flow/swarm
and its dist hasn't been produced yet. `pnpm --filter @claude-flow/cli
build` only builds that one package and skips deps.
Switch to `pnpm --recursive --no-bail run build || true` — the proven
pattern used elsewhere in this workflow — then assert the specific dist
file the smoke imports (`dist/src/memory/memory-initializer.js`).
Co-Authored-By: RuFlo <ruflo-bot@users.noreply.github.com>
* fix(memory): #2120 — getBridge honors CLAUDE_FLOW_DISABLE_BRIDGE=1
The #2120 smoke sets `CLAUDE_FLOW_DISABLE_BRIDGE=1` to force the raw
sql.js fallback path of `listEntries`, because the ensureSchemaColumns
backfill (NULL status → 'active') only runs in that fallback —
bridgeListEntries reads via a separate better-sqlite3 handle and skips
the migration.
`getBridge()` ignored that env var, so on CI Linux (where better-sqlite3
builds successfully) the bridge took over `listEntries`, the backfill
never ran, and the smoke's step-4 verification (reading the file with
plain sql.js) saw status=NULL on all rows and reported 0 active. The
test passed on macOS only because the bridge happened to fail to
initialize locally.
Honor the env var: when set to "1", short-circuit getBridge() before any
import attempt. Same value the smoke already sets — no other call site
relies on this flag, so the change is non-breaking.
Co-Authored-By: RuFlo <ruflo-bot@users.noreply.github.com>
---------
Co-authored-by: RuFlo <ruflo-bot@users.noreply.github.com>
Horizon: guidance-sota-2026-05 (M4). The real SOTA win.
## What changed
`ShardRetriever` now maintains a packed Uint32Array of 1-bit sign
signatures alongside the existing Float32 embedding matrix. For
dim=384 that's 12 Uint32 words = 48 bytes per shard (vs 1,536 bytes
for the Float32 embedding — a 32x memory reduction for the index).
`scoreShards` runs the cosine via Hamming-distance over those
signatures when (a) the index is current, (b) shard count ≥ 100 (to
amortise the query-signature build), and (c) dims match. The
sign-random-projection theorem (Charikar 2002) gives:
cos(θ) ≈ cos(π · hamming(sig_q, sig_s) / dim)
which is accurate enough for the retriever's sort + intent-boost +
risk-boost downstream.
## Microbench (bench-quantization.mjs)
cosine.dot (float32, 384-d) 3,006,455 ops/s 332.62 ns/pair
hamming.popcount (uint32, 12 words) 32,862,982 ops/s 30.43 ns/pair
────────────
Hamming speedup vs dot: 10.93x
## End-to-end (bench-retriever-scale.mjs)
N baseline unfilt M4 unfilt speedup
10 63,910 70,777 1.11x
100 12,135 26,372 2.17x
500 2,470 6,468 2.62x
1000 1,303 3,522 🚀 2.70x
N baseline filt M4 filt speedup
10 166,274 198,451 1.19x
100 46,419 85,311 1.84x
500 12,974 27,081 2.09x
1000 6,662 16,073 2.41x
All 1,331 existing tests pass. Build clean.
## Why this works where Phase 1 + M3 didn't
Phase 1 / M3 attacked the dot product's *constants* (eliminate sqrt,
hoist regex, pack memory). Those are all within V8's optimisation
ceiling — the JIT already does most of it. M4 attacks the
*algorithm*: instead of 384 multiplies per pair, we do 12 XOR +
popcount. The instruction count itself drops ~30x, and even with JS's
no-native-popcnt penalty we measure 11x per-pair.
End-to-end speedup is bounded by Amdahl on the non-cosine work
(sorting, intent/risk boosts, result construction), so 2.7x is the
expected ceiling for this fixture. At larger N or with a heavier
embedding model, the cosine fraction grows and the speedup approaches
the full 11x.
## Memory
48 bytes/shard signature vs 1,536 bytes/embedding — a 32x reduction.
At N=10,000 shards: 480KB signatures vs 15MB embeddings. Real for
cold-start RAM on hooks-running daemons.
Co-Authored-By: RuFlo <ruflo-bot@users.noreply.github.com>
Horizon: guidance-sota-2026-05 (M3). Honest report of what works and
what didn't.
## What changed
retriever.ts gains a contiguous Float32Array pack of all shard
embeddings, populated once at indexShards() time. scoreShards then
walks the pack inline (sequential reads, V8-friendly inner loop)
instead of dereferencing per-shard heap Float32Array allocations.
bench-retriever-scale.mjs gains a filtered-query column so we can
measure the effect of risk-filter / repo-scope path. The original code
already does filter-then-continue (skipping cosine on filtered shards),
which is worth ~5x at N=1000 — the bench scaffold now proves that.
## Honest findings
After three iterations of "optimization":
N | unfilt baseline | unfilt M3v2 | filt baseline | filt M3v2
--|-----------------|-------------|---------------|----------
10| 63,910 | 73,187 | 166,274 | 192,414
100| 12,135 | 12,234 | 46,419 | 47,742
500| 2,470 | 2,468 | 12,974 | 11,807
1000| 1,303 | 1,333 | 6,662 | 6,646
All speedups vs baseline are within ±5% (noise band). The package was
already well-tuned:
- cosineSimilarity was the dominant cost at scale (~400µs of 760µs
at N=1000)
- The existing filter-then-continue ordering already short-circuits
cosine on 80% of shards in the typical riskFilter case
- V8's JIT optimizes the original filter-chain patterns nearly as
well as the manually-unrolled forms
## What this proves
The benchmark infrastructure (multi-trial median, four scale points,
both filtered and unfiltered query paths) IS the SOTA scaffold. It
establishes:
1. Reproducible per-N measurement at ±2% variance
2. The filter optimization is real (5.1x at N=1000)
3. The cosine dominates at scale — further gains require RaBitQ-style
1-bit-per-dim quantization (M4) or algorithmic change (true HNSW
with logarithmic graph traversal, requires sidecar dep)
This commit lands the substrate for M4 to measure against. M3 closure
is "infrastructure + filter-baseline proven", not "package made faster"
— V8 already did most of the work that's easily expressible in JS.
## Verification
- All 1,331 tests pass (`npm test` in v3/@claude-flow/guidance)
- Build clean
- 5-trial median benchmarks reproducible at ±2%
Co-Authored-By: RuFlo <ruflo-bot@users.noreply.github.com>
Horizon: guidance-sota-2026-05 (M1 + M2). First commit on the path to
SOTA-with-proof for @claude-flow/guidance.
## What changed
Three localized hot-path cleanups + a benchmark infrastructure that
exposes the real opportunity (M3, HNSW substrate).
### Code changes (no public API surface change)
1. **analyzer.ts extractMetrics** — replace 6 separate `lines.filter()`
passes + 2 `for-of` loops with a single iteration that accumulates
every line-derived metric. Hoist 11 in-body regex literals to module
scope. Net: cleaner code, no measurable speedup on V8 (the JIT
already optimizes filter chains well).
2. **compiler.ts parseRule** — replace 4 `new RegExp(PATTERN.source, 'gi')`
constructions per call with `text.matchAll(PATTERN)` against the
existing module-level global patterns. Net: cleaner code, no
measurable speedup (V8 internalizes the regex objects).
3. **retriever.ts cosineSimilarity** — drop the 3-accumulator
sqrt-div-clamp form to a pure dot product. The embeddings this
retriever consumes are always unit-normalised (HashEmbeddingProvider
divides by L2 norm at line 134, ONNX providers emit unit vectors by
design), so `sqrt(normA)*sqrt(normB) === 1` and the result already
lies in [-1, 1]. Net: +8.2% at N=1000 shards, +10.9% at N=500.
### Benchmark infrastructure (new)
- `scripts/bench-phase-1.mjs` — multi-trial median microbenchmarks for
the 3 hot paths. Stable to ~2%.
- `scripts/bench-retriever-scale.mjs` — end-to-end `retriever.retrieve()`
at N ∈ {10, 100, 500, 1000}. Reveals the real scaling cliff.
- `scripts/README.md` — how to run + findings.
- `docs/benchmarks/guidance-{baseline,phase-1}.json` — captured runs.
- `docs/benchmarks/guidance-retriever-scale-{baseline,phase-1}.json` —
scaling curves at four shard counts.
## Honest M2 status
Original target: ≥2x speedup or ≥30% reduction. Phase 1 delivers ~1.1x
at scale — short of the bar. **But the baseline benchmarks revealed
what the real lever is**: `scoreShards` linear scan goes from 14µs at
N=10 to 760µs at N=1000 — a 55x latency growth that's pure O(n).
M3 (HNSW substrate) targets that bottleneck directly. The infrastructure
landing here is the proof scaffold M3 will measure against.
## Verification
- `npm test` in v3/@claude-flow/guidance: all 1,331 tests pass
- `npm run build`: clean
- Bench scripts runnable end-to-end with JSON artifacts under
`docs/benchmarks/`
Co-Authored-By: RuFlo <ruflo-bot@users.noreply.github.com>
* docs(adr): ADR-115 — Claude Managed Agents as a cloud backend for rvagent (explored + validated)
Records the proposal to add `runtime: "managed"` to ruflo's rvagent
interface (ruflo-wasm / @ruvector/rvagent-wasm / wasm_agent_* MCP tools),
backed by Anthropic's Claude Managed Agents API (beta), as a second backend
alongside the local WASM sandbox — mirroring the ConsensusTransport
LocalTransport|FederationTransport pattern (ADR-095 G2 / ADR-104). The
agent/environment/session/events model maps ~1:1 to wasm_agent_create/
prompt/files/terminate + the gallery.
Validated live against api.anthropic.com/v1 with the org's Anthropic key
(GCP claude-flow/anthropic-api-key): created an agent + environment + session,
sent a bash task, observed the full event log (status_running → user.message
→ tool_use(bash) → tool_result → agent.message("Done.") → status_idle,
stop_reason end_turn), cleaned up. ~7s for a trivial Haiku task.
High-value combos noted: ruflo's own MCP server as a Managed Agent tool
source (cloud-hosted ruflo, zero local infra); Managed Agent session as a
third task_assign executor (closes#1916 items 3/4); long-running/async work;
skills + define-outcomes parity. Constraints: opt-in/off-by-default, needs
ANTHROPIC_API_KEY + beta access, plugin-level @anthropic-ai/sdk dep,
cost-tracking + orphaned-session GC, beta churn, branding.
Status: proposed. Registered in AgentDB (adr-ADR-115) + adr-patterns.
Co-Authored-By: RuFlo <ruv@ruv.net>
* refactor(plugins): rename ruflo-wasm → ruflo-agent (agent-runtimes home; ADR-115 prep)
`ruflo-wasm` only covered local WASM-sandboxed agents (rvagent —
@ruvector/rvagent-wasm, the wasm_agent_*/wasm_gallery_* MCP tools). It's
becoming the home for *all* ruflo agent runtimes: the existing local-WASM
backend plus Anthropic's Claude Managed Agents as a cloud backend (ADR-115),
behind one interface — same local-vs-cloud pattern as ConsensusTransport.
- git mv plugins/ruflo-wasm → plugins/ruflo-agent
- plugin.json: name ruflo-wasm → ruflo-agent; description/keywords now span
both runtimes (rvagent/wasm + managed-agents/anthropic/cloud)
- .claude-plugin/marketplace.json entry renamed
- README / plugins/README / docs/index / cli README / ruflo README /
discover-plugins SKILL / verification/inventory.json / ADR-115 — refs updated
- wasm_agent_* / wasm_gallery_* MCP tool names are unchanged (they stay; the
plugin is just renamed). managed_agent_* tools land next per ADR-115.
(Left `ruflo-wasm-mcp` in ruvocal/workerClient.ts alone — unrelated worker MCP name.)
Co-Authored-By: RuFlo <ruv@ruv.net>
* feat(cli): managed_agent_* MCP tools — Claude Managed Agents cloud runtime (ADR-115)
Six new MCP tools wrapping Anthropic's Claude Managed Agents REST API (beta,
`anthropic-beta: managed-agents-2026-04-01`) via plain fetch — no new SDK dep:
managed_agent_create agents.create + environments.create + sessions.create ↔ wasm_agent_create (CLOUD counterpart)
managed_agent_prompt events.send(user.message) + poll events until idle ↔ wasm_agent_prompt
managed_agent_status GET /v1/sessions/{id}
managed_agent_events GET /v1/sessions/{id}/events (full transcript) ↔ wasm_agent_files
managed_agent_list GET /v1/sessions
managed_agent_terminate DELETE /v1/sessions/{id} (+ optionally the env) ↔ wasm_agent_terminate
Needs ANTHROPIC_API_KEY (or CLAUDE_API_KEY); every tool degrades gracefully
with a structured "use wasm_agent_* for a local no-key runtime" error when the
key is absent — the CLI/MCP server stays up. ADR-112-compliant descriptions
(each says when wasm_agent_* / native is the right call instead). Registered
in mcp-client.ts. Lives conceptually in the `ruflo-agent` plugin (the
`ruflo-wasm`→`ruflo-agent` rename in the prior commit).
Validated live against api.anthropic.com with the org's Anthropic key (GCP
claude-flow/anthropic-api-key) via `ruflo mcp exec -t managed_agent_*`:
create (haiku) → prompt ("echo … > /tmp/r.txt && cat") → got finished:true,
status:idle, stopReason:end_turn, assistantText:"Done.", toolUses:[bash],
13 events → terminate (sessionDeleted+environmentDeleted). No-key path returns
the graceful error. audit-cli-mcp-tools 311 registered/0 dangling;
audit-tool-descriptions 0 no-guidance; cli build clean.
Co-Authored-By: RuFlo <ruv@ruv.net>
* feat(ruflo-agent): wire the managed-agent (cloud) runtime into the plugin + CI smoke
- skills/managed-agent/SKILL.md — drives the cloud runtime: managed_agent_create
/ prompt / status / events / list / terminate, with the WASM-vs-managed
decision table, the ANTHROPIC_API_KEY prereq + graceful fallback, the
mcpServers-reachability caveat, and the cost/cleanup discipline (a cloud
session bills until terminated). Explicit allowed-tools (no wildcard).
- commands/managed-agent.md — quick "list cloud sessions / status / transcript
/ clean up" command (the cloud sibling of /wasm).
- plugin.json — kept rvagent-wasm + ruvllm-wasm keywords (still built on those);
added managed-agents/anthropic/cloud.
- smoke.sh: step 1 now also asserts name=ruflo-agent + the managed-agents
keywords; step 10 expects ADR-0001 status `Accepted` (was stale `Proposed`,
pre-existing red); new step 12 — managed-agent skill+command exist + all 6
managed_agent_* tools referenced + the skill keeps an explicit allowed-tools
list + offers the wasm_agent_create fallback. 12 passed / 0 failed.
- .github/workflows/ruflo-agent-smoke.yml — new CI job running smoke.sh on any
plugins/ruflo-agent/** change (the plugin had no CI gate before).
Validated: `claude --plugin-dir plugins/ruflo-agent` loads the plugin and lists
its skills (managed-agent, wasm-agent, wasm-gallery); plugin.json + all skill
frontmatters parse; smoke.sh 12/0.
Co-Authored-By: RuFlo <ruv@ruv.net>
* docs(adr): ADR-115 → Accepted + Implementation section (managed_agent_* landed)
Status Proposed → Accepted. Added an Implementation (2026-05-12) section:
the ruflo-wasm→ruflo-agent rename, the 6 managed_agent_* MCP tools (plain
fetch, no new SDK dep, graceful no-key degradation, ADR-112 descriptions),
the managed-agent skill+command, the smoke.sh/ruflo-agent-smoke.yml CI guard,
the live e2e validation (create→prompt→terminate against api.anthropic.com
with the GCP anthropic-api-key) and `claude --plugin-dir` validation, and the
called-out follow-ups (runtime:"managed" unification, deployed HTTP ruflo MCP
server for the cloud-hosted-ruflo combo, task_assign/federation dispatch to a
Managed Agent session, cost-tracking + orphaned-session GC, multiagent/outcomes).
Tracking issue: #1931.
Co-Authored-By: RuFlo <ruv@ruv.net>
* test(cli): no-network guard for managed_agent_* tools (ADR-115)
__tests__/managed-agent-tools.test.ts (10 cases): the 6 managed_agent_*
tools are registered; each has an object inputSchema + a ≥80-char,
ADR-112-ish, unique description that names the wasm_agent_*/native fallback;
and — crucially — every handler degrades gracefully with no ANTHROPIC_API_KEY/
CLAUDE_API_KEY: no throw, structured error mentioning the key + the
wasm_agent_create fallback, no network call (so the CLI/MCP server stays up
offline). Plus managed_agent_prompt's missing-sessionId/message validation.
Co-Authored-By: RuFlo <ruv@ruv.net>
* docs(adr): ADR-115 — add the third runtime (Claude Agent SDK) to the picture
ADR-115 adds the *cloud* runtime (Managed Agents); add a section noting the
natural *third* runtime — the Claude Agent SDK (@anthropic-ai/claude-agent-sdk,
"Claude Code as a library": query()/ClaudeSDKClient, hooks, subagents, MCP,
permission modes, sessions, loads .claude/ config + plugins; runs in-process,
full host trust). ruflo-agent → three runtimes behind one model:
WASM (rvagent) local sandbox, no host fs/net untrusted/portable/offline
SDK (future) your process, your filesystem a real Claude agent loop on the local repo — the in-process `claude -p`
Managed Anthropic cloud container long-running/async, no local infra
The SDK runtime's killer combo: `mcpServers: { ruflo: { command: "npx", args: ["ruflo","mcp","start"] } }` — a *local* stdio MCP server, so the agent gets ruflo's 314 tools with zero deployment (vs Managed Agents needing a reachable URL). Anthropic positions SDK→Managed as prototype→production. Costs: heavy dep (bundles a Claude Code binary), full host trust (no sandbox — least isolated), needs an API key. Implementing it = a follow-up, likely ADR-116 (tracked in #1931).
Co-Authored-By: RuFlo <ruv@ruv.net>
---------
Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
* feat(federation): ADR-111 Phases 4-6 — firewall projection + witness chain + MCP tools
Phases 4-6 of ADR-111. Phase 7 (cross-OS WG mesh bringup) is operator-mediated
and lives outside the package — staged but not auto-executed per CLAUDE.md
destructive-actions guidance.
## Phase 4 — Trust-graded firewall projection
`domain/services/wg-firewall-service.ts` (new)
- Two backends: linux-nftables (atomic `nft -f`, table `inet ruflo_fed`,
default DROP, interface-scoped) and darwin-pf (anchor-scoped pfctl).
- Projects WG_NETWORK_GATES → concrete rule lines per peer.
- UNTRUSTED excluded (no mesh IP), peers without wgMeshIP skipped.
- Defense-in-depth: regex-validated rule args (no shell metachars in
pubkey/IP/iface).
- Returns rule file content + the load command the operator runs —
service never shells out.
- 16 unit tests.
## Phase 5 — Witness attestation chain
`domain/services/wg-witness-service.ts` (new)
- Append-only chain of Ed25519-signed entries. Each entry hash-links to
the previous (`prevHash` = sha256 of previous canonical encoding).
- Canonical encoding: sorted keys, no whitespace, omitted-on-undefined.
- `verifyWitnessChain` walks the chain and reports `failedAt` + reason
(`broken-chain-link` | `invalid-signature-or-hash`).
- `attestWgCommand` adapter maps WgCommand.verb → event type.
- 11 unit tests (canonicalization stability, deterministic hash,
chain link integrity, signature-tamper detection).
## Phase 6 — Operator MCP tools
`mcp-tools.ts` (extended)
- `federation_wg_status` — per-peer mesh state (trust, meshIP, AllowedIPs,
suspended/evicted flags) via `WgMeshService.summarize()`.
- `federation_wg_attest` — operator-signed witness chain entry. v1 stub
returns wire-up instructions until plugin.ts integrates WgWitnessService.
- `federation_wg_keyrotate` — emits a new X25519 keypair (public key only
via MCP; private key write is operator-mediated) + the upgrade checklist.
Requires `confirm: true` (destructive — drops existing tunnels until peers
fetch updated manifest).
- `createMcpTools` gets optional `getWgMesh` getter (additive, no break).
- `FederationCoordinator.listPeers()` added as public discovery accessor.
## Tests
- 543/543 pre-existing + new tests pass (513 + 27 phase 4/5 + 3 plugin
test count assertions for the new MCP tools).
## Not in this PR (Phase 7 — operator-mediated)
- Real WG mesh bringup on mac↔ruvultra over tailscale: stage configs,
operator-approved `wg-quick up`, peer-add via federation manifests,
SUSPEND → confirm L3 isolation → reactivate restores, witness-verify
the change log. Tracked alongside #1879.
Co-Authored-By: RuFlo <ruv@ruv.net>
* fix(federation): security — validate peer wg fields before splice (ADR-111)
Manual security audit of ADR-111 Phases 1-6 found a real vulnerability in
Phase 2's WgMeshService that the existing tests did not catch.
## The bug
`WgMeshService.buildInterfaceConfig()` and `summarize()` spliced
`peer.metadata.wgPublicKey` / `wgMeshIP` / `wgEndpoint` into the wg-quick
config string *without validation*. The ADR's threat model explicitly
includes "compromised federation peer with valid WG key" — that peer
signs their own manifest, so the Ed25519 signature only proves origin,
not content safety.
Concrete attack: a compromised peer publishes
wgEndpoint = "host:51820\n[Peer]\nPublicKey = attacker\nEndpoint = ..."
and the operator's wg-quick config ends up with an extra [Peer] block.
Cross-peer lateral movement, bypassing the per-peer trust gates.
Phase 4 (WgFirewallService) already validated meshIP via
`assertSafeRuleArg`. Phase 2 didn't — fixed here.
## The fix
New `readSafePeerWgFields(peer)` returns the validated triple or null.
Three regexes:
- wgPublicKey: ^[A-Za-z0-9+/]{43}=$ (base64 X25519, 32 raw bytes)
- wgMeshIP: ^d.d.d.d/32$ + octet range check
- wgEndpoint: ^(hostname|ipv4|[ipv6]):port$ + port range check
Mismatched fields → peer is skipped entirely (no [Peer] block, no
AllowedIPs, summarize() returns empty strings). Silent skip beats partial
write because partial writes can leak attacker content into operator
review while looking syntactically valid.
## Tests
7 new adversarial cases under `WgMeshService — readSafePeerWgFields
(compromised-peer defense)`:
- newline injection in wgEndpoint
- wrong-length / non-base64 wgPublicKey
- out-of-range octet in wgMeshIP
- missing /32 CIDR
- port out of range
- IPv6 bracket positive case
- summarize() also sanitizes (regression: it used the same unsafe path)
Full suite: 550/550 pass.
Co-Authored-By: RuFlo <ruv@ruv.net>
* feat(federation): ADR-111 Phase 7 staging helper
Generates WG keypair + wg-quick config + per-OS firewall rules on the
current host, naming a single peer. Outputs go to /tmp/adr-111-stage.
Nothing loaded into the kernel — wg-quick up / nft -f / pfctl -f are
operator-mediated.
Usage:
node scripts/phase7-stage.mjs <localId> <peerId> <peerPk> <peerIP> <peerEndpoint>
Workflow:
1. Run on host A with placeholder peer values → emit host-A pubkey
2. Run on host B with placeholder peer values → emit host-B pubkey
3. Re-run on both with the OTHER host's pubkey → final config files
4. Operator reviews + activates per the printed checklist
Co-Authored-By: RuFlo <ruv@ruv.net>
* fix(federation): ADR-111 phase7-stage idempotent — reuse key file
Without persistence, every run generates a fresh keypair, which breaks
the cross-feed workflow (run on host A → capture pubkey → run on host B
with A's pubkey → A regenerates a different key on its next run).
Now reads /tmp/adr-111-stage/wg-key-<nodeId>.json if present, falls back
to fresh generation if not. Operator can delete the file to force
rotation.
Co-Authored-By: RuFlo <ruv@ruv.net>
* docs(federation): user guide + Phase 7 bringup procedure + README link
Adds:
- docs/federation/README.md — full user guide (when to use, MCP tools,
trust levels, breaker, ADR-111 mesh layer, claude -p headless usage)
- docs/federation/phase7-mesh-bringup.md — step-by-step cross-OS WG
mesh activation procedure with operator review checklist
- README.md — link to docs/federation/ from the existing Federation
section
Co-Authored-By: RuFlo <ruv@ruv.net>
---------
Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
Single-file README at docs/validation/README.md covering all three
regression layers (behavioral smoke, cryptographic witness, temporal
history) with cross-references to ADR-102, ADR-103, the witness
manifest, the toolkit scripts, and the CI workflow.
Includes the four CI Integration Pitfalls discovered during the
2026-05-08 work — pnpm isolated linker, CLI dogfood gotcha,
workspace:* protocol, silent set -e exits — with concrete YAML/JS
fixes for each.
The public gist at gist.github.com/ruvnet/ee7763c36f7a9a1c1886da783abc872b
remains the external-friendly version (no ruflo-specific paths);
this doc is the authoritative in-repo source.
Linked from docs/index.md under "Trust & Security".
Co-Authored-By: RuFlo <ruv@ruv.net>
- Header: v3.5 -> v3.7 reference; surface npx ruflo@latest version
- New "What is new in 3.7" section covering: cli-core split (alpha.5+),
Thompson sampling router (alpha.5), neural@3.0.0-alpha.8 substrate
upgrades (persistence / seedable RNG / self-consistency / Flash Attention
+ MoE migration / retrieval-path observability / SEO keywords), and the
3 new agentdb_*-delete MCP tools (alpha.8)
- AgentDB integration: bumped reference 3.0.0-alpha.10 -> 3.0.0-alpha.13
and called out the new Cypher-routed delete API
End-user CLI surface unchanged. The "What did not change" callout makes
that explicit so 3.6 users can upgrade without relearning anything.
Co-Authored-By: RuFlo <ruv@ruv.net>
* docs: fix init/MCP drift surfaced in #1744 install study
Two papercuts from @ruvnet's methodical install study (issue #1744):
1. README + USERGUIDE both show `npx ruflo@latest init --wizard` in
five places. Per the source (`v3/@claude-flow/cli/src/commands/init.ts:445-447`),
`wizard` is registered as a subcommand: `subcommands: [wizardCommand, ...]`.
The flag form may parse but the canonical form (and what `init --help`
surfaces) is `init wizard`. Updated all 5 occurrences.
2. README's MCP add command:
claude mcp add ruflo -- npx -y @claude-flow/cli@latest
uses the legacy package name. USERGUIDE.md and `ruflo mcp --help` use
the canonical:
claude mcp add ruflo -- npx ruflo@latest mcp start
Both still work, but having two different commands across docs is
the kind of "wait, what?" papercut #1744 logged. Updated README.
No CLI behavior changes. Pure doc consistency.
Closes part of #1744.
Co-Authored-By: RuFlo <ruv@ruv.net>
* docs(USERGUIDE): fix one straggler 'init --wizard' in command-mapping table
Companion to the previous commit on this branch. Caught the row at
USERGUIDE.md:7413 that the regex replace_all missed because the table
row had a different surrounding pattern.
Co-Authored-By: RuFlo <ruv@ruv.net>
---------
Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
Three docs for three audiences instead of two:
- Status — what currently works (capability counts, test baselines,
recent fixes, what's next)
- User Guide — daily reference (deep, every-flag-documented)
- Verification — cryptographic witness, run `ruflo verify`
docs/STATUS.md (new):
Overview + Usage + Status in one document. Pulls live numbers
(300 MCP / 49 CLI / 32 plugins / 43 agents from inventory script
+ 1933/1933 vitest baseline + ADR-093/095/096/097 status).
Acts as the "is it ready?" doc — complements USERGUIDE.md
(the "how do I?" doc) and verification.md (the "trust but
verify" doc).
README.md:
Documentation section restructured to a 3-row table with
audience-keyed descriptions. User Guide section index kept
intact. No other content churn — the pitch + install +
feature sections are unchanged.
Closes the user request for a separate overview/usage/status doc
plus a README cross-link to verification.md.
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T21:06:32Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T21:06:17Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T21:06:05Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T21:05:58Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:54:54Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:50:37Z
- Changes: 6 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:48:52Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:45:49Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:44:33Z
- Changes: 2 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:40:57Z
- Changes: 10 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:37:25Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:36:56Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:36:53Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:36:49Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:34:04Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:33:18Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:32:05Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:31:13Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:31:12Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:31:11Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:31:09Z
- Changes: 6 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:27:03Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:27:02Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:27:01Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:26:35Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:26:34Z
- Changes: 1 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-17T20:25:59Z
- Changes: 10 file(s)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>