2158 Commits
Author SHA1 Message Date
ruv d582270956 release 3.51.0: re-sign helper manifest
Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-02 00:56:10 -04:00
ruv 00d13f551c release 3.51.0: bump train to 3.51.0
Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-02 00:55:34 -04:00
ruv 6383a28267 feat(mods): ruflo-console is a required mod plugin; catalog lists /ruflo
#3614 shipped ruflo-console on main, so `ruflo init` and `ruflo mods install`
now install it like ruflo-mods and ruflo-swarm. A marketplace clone without
it is stale (a doctor failure with the exact repair), never "pending".

- MOD_PLUGINS: ruflo-console@ruflo required: true.
- `ruflo mods install` points at /ruflo (and /ruflo mods) instead of /ruflo-mods.
- ADR-406 catalog: the source scan now reads `$.command.registerCommand`, and
  the engine parser splits a `command=a|b` matcher into its names and treats
  `command=?` (a matcher chosen at run time) as naming nothing, deferring to
  the source scan for that plugin. Without this, regenerating after #3614
  either failed schema validation (`ruflo|ruflo-console`, `?`) or dropped the
  five /ruflo-swarm-* commands. Regenerated: 241 -> 243 entries (+/ruflo,
  +/ruflo-console), none removed; the console's catalog copy is synced.
- Tests and the e2e-mods-init script now expect ruflo-console installed.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-02 00:33:07 -04:00
rUv 93974863e6 Merge pull request #3617 from ruvnet/feat/adr-406-mission-control
feat: ADR-406 command registry (P0/P1) and mission control runtime (M0/M1)
2026-10-01 23:37:56 -04:00
ruv 48ec166d9b fix(missions): ADR-112 guidance in mission MCP tool descriptions
Each mission_* description now states when to use it and why the nearest
alternative (task_create, memory_store, task_status, polling mission_get,
task_cancel) is wrong. scripts/audit-tool-descriptions.mjs: 392/392 with
guidance, all gates pass.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 22:58:17 -04:00
ruv 5913dd519b fix(mods): ADR-406 catalog classifies lower-case report workflows and anchors to inventoried files
`.*report.*` labelled the real workflow analysis:performance-report as
documentation. Loader-exposed docs are the all-caps basenames (README,
COMMAND_COMPLIANCE_REPORT); match those only. 226 shipped, 15 documentation.

The catalog's sourceCommit was the newest commit under any scanned root, so
an unrelated plugin commit made `catalog generate --check` stale. It is now
the newest commit touching a file the catalog actually inventories.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 22:39:15 -04:00
ruv 0483ac5517 feat(missions): ADR-406 M1 mission observation via CLI and MCP, e2e gate
`ruflo mission create|plan|get|events|action` and the mission_create,
mission_plan, mission_get, mission_events and mission_request_action MCP
tools are thin transports over the one MissionService and its zod schemas;
MCP calls are still authorized by the existing policy runtime in
mcp-client.ts. A bounded, sanitized .claude-flow/missions/observation.json
(contract ruflo.mission-observation/1, source-time observedAt) is rewritten
atomically after each committed event for the workbench to read.

scripts/e2e-adr-406.mjs runs the built CLI in throwaway HOME,
CLAUDE_CONFIG_DIR and project dirs: catalog current and verified, legacy
command files byte-unchanged, CLI create + MCP plan reading identical
records and events, revision conflict, honest admit refusal, SIGKILL of a
writer then restart, and the §18 fixture replay with mods off vs on
(permissions, policy mode and outcomes unchanged; uninstall restores).
RUFLO_E2E_LIVE=1 adds engine version and plugin validate (no model calls).

Mod hooks the engine confirms are recorded against their declaring source
file, so the catalog is identical with or without an engine. mission_*
tools are classified in the capability brain's tasks/workflows domain.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 22:34:58 -04:00
ruv 67206969b9 feat(mods): uninstall what ruflo installed, --source local (directory marketplace), exact disclosure
- mods uninstall runs `claude plugin uninstall <id> --scope <scope>` for
  exactly the plugins ruflo installed (absent before, enabled by ruflo;
  recorded as claudeInstalled in install.json), then removes exactly the
  settings keys it added. A plugin installed before is never uninstalled.
- mods install --source local [--marketplace-path <dir>]: declares the
  ruflo marketplace as a directory source (a ruflo checkout), adds it, and
  installs nothing, so the plugins load live from the working tree.
  Verified on 2.1.287 in an isolated config: loads with no install record,
  and an edit shows on the next run. Doctor reports the source type and
  warns when the project's declared source differs from the known one.
- The repair honours the marketplace the settings file declares.
- Init output, README and ADR state exactly what loads: ruflo-swarm's
  commands/skills/agents without function hooks, its host-command mod with
  them; the first trusted start clones github.com/ruvnet/ruflo; headless -p
  on a fresh config loads nothing; refuse-risky + modTrustAllow as opt-in
  hardening (modTrust stays observe). Claude Code's re-serialization of
  settings.json is reported, never fought.
- e2e: live load is `claude -p "/ruflo-mods"` behind RUFLO_E2E_LIVE=1 with
  CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY; no credential file copied,
  nothing printed; adds the --source local and uninstall scenarios.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 22:31:28 -04:00
ruv b3b6c3469d feat(missions): ADR-406 M0 mission contract and durable storage
Versioned mission schemas (§19.3 MissionRecord exactly, strict inputs with
bounded strings and integer monetary units), the §19.4 transition table as
data with guards (exact-plan authorization, atomic budget reservation
against the ceiling, lease epochs that fence stale executors, verified
evidence bound to plan/criteria/artifact, connectivity loss never counted as
failure), and a reducer that replays a hash-chained append-only log.

Store decision: reuse ruflo's existing authoritative-state pattern (project
files + per-file lock + atomic replace, as the policy ledger, claims and
leases do) rather than optional better-sqlite3 or in-memory sql.js. Events
are one fsynced line each; a torn final line is ignored and truncated by the
next locked writer; the snapshot is a cache that must agree with the log.
Exports the policy runtime's acquireLock (dead-owner detection by pid, pid
namespace and boot id) instead of copying it.

The shared MissionService derives principal/tenant/workspace from the local
context, deduplicates by request id (same input replays, different input is
refused), rejects stale revisions with the current one, and refuses
admit/resume until a durable executor exists. Tests: table exactness,
seeded property tests over random sequences, snapshot+tail == full replay,
torn-tail repair, chain tamper, concurrent create and plan races, and a
SIGKILL of a writer process mid-stream.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 22:28:18 -04:00
ruv b0976f3b1e feat(mods): ADR-406 P0 command inventory and P1 canonical registry
Inventory every Ruflo slash command across repository command dirs, the
packaged init templates, marketplace and source plugin command folders, and
mod command hooks observed by `claude plugin validate` (engine 2.1.287).
Records channel, package, digest, observed invocation, binding and shipped
packages (npm pack --dry-run). Loader-exposed READMEs and reports are
cataloged as documentation, not workflows.

P1: strict zod CommandDefinition per ADR-406 §6 (no unknown fields, size
caps, no dispatch for prompt workflows), duplicate id/name validator,
deterministic catalog (sorted, canonical JSON, per-file last commit, no
timestamp) with a sha256 sourceDigest consumers can recheck, and an
expected-hash write guard. Interim `ruflo catalog generate|verify|engine`
command until commands/mods.ts (PR #3612) can host it.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 22:19:15 -04:00
ruv 2546278c8c feat(mods): the init wizard enables the mods too (ADR-404 amendment 1)
Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 22:13:58 -04:00
ruv dcceb32585 feat(mods): default-on in ruflo init, init upgrade --mods, three mod plugins (ADR-404 amendment 1)
- ruflo init enables the mods by default (--no-mods opts out) in the
  committed .claude/settings.json: enabledPlugins for MOD_PLUGINS
  (ruflo-mods, ruflo-swarm, ruflo-console), extraKnownMarketplaces.ruflo and
  CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1, then refreshes the marketplace and
  `claude plugin install`s each plugin at project scope (--no-plugin-install
  skips; skipped under VITEST/CI; manual commands printed on failure).
- ruflo init upgrade --mods applies the same merge + install to an existing
  project; --add-missing and --settings imply it. Never clobbers: only absent
  keys are added (a plugin set to false stays false and is never installed,
  since `claude plugin install` would flip it), each addition is reported.
- MOD_PLUGINS is the one list; `required: false` marks a plugin not yet in
  the marketplace (ruflo-console): reported as pending, never a failure.
- Install record v2 per settings file; v1 (3.50.0) records are read; mods
  uninstall reverses exactly what was added in every file.
- Detection corrected from live evidence: an interactive trusted session
  loads plugins straight from the marketplace clone with no install record,
  so the clone decides. A stale clone (the field report, reproduced live:
  "Unknown command: /ruflo-mods") fails doctor; no clone yet is a warning.
- scripts/e2e-mods-init.sh: built CLI + real claude, isolated HOME and
  CLAUDE_CONFIG_DIR per scenario; E2E_LIVE=1 adds a live tmux session.
- ADR-404 Amendment 1, with where the "safe default" argument stops
  (ruflo-swarm's commands/skills load regardless; modTrust stays observe).

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 22:05:16 -04:00
ruv 6b8558ad99 fix(mods): install the ruflo-mods plugin, and fail doctor when Claude Code cannot resolve it
`ruflo mods install` only wrote enabledPlugins + extraKnownMarketplaces. With a
local clone of the ruflo marketplace older than ruflo-mods (seen live at
3.38.21), Claude Code skipped the enabled plugin silently and /ruflo-mods was
an unknown command, while `mods status` and `mods doctor` reported all fine.

- Detect (read-only, respects CLAUDE_CONFIG_DIR): two new findings once the
  plugin is enabled. `ruflo marketplace` checks the clone named by
  known_marketplaces.json for plugins/ruflo-mods/.claude-plugin/plugin.json;
  `ruflo-mods installed` checks installed_plugins.json for a user-scope entry
  or a local/project entry for this project whose cache dir exists. Not
  installed = FAIL; a stale clone FAILs only while nothing is installed (a
  cached install still loads). Each failure carries the exact commands.
- Repair on install: when a runnable claude is on PATH, run
  `claude plugin marketplace update ruflo` (or `marketplace add ruvnet/ruflo
  --scope <scope>` when unknown, so user settings are not edited), then
  `claude plugin install ruflo-mods@ruflo --scope <scope>` in the project dir.
  execFile with fixed argv, no shell, no -y, 150s/60s timeouts; re-reads
  Claude Code's records afterwards. --no-plugin-install skips it; --dry-run
  prints the commands; on failure the manual commands are printed and the
  exit is non-zero only with --strict.
- Status: "enabled in settings" is now distinct from installed/resolvable;
  `mods status` exits 0, `mods doctor` and `doctor --component mods` fail.
- README: install steps and the stale-clone failure mode.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 21:13:43 -04:00
ruv 7634d7a01e release 3.50.0: re-sign helper manifest, regenerate witness manifests
- helpers.manifest.json re-signed for 3.50.0
- verification/{linux,macos,windows}/manifest.md.json regenerated on a clean,
  fully built tree: 117/117 verified each, os field stamped per manifest

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 19:56:41 -04:00
ruv 519709a290 release 3.50.0: bump train to 3.50.0
Ships the Claude Code mods integration (ADR-404: ruflo mods CLI, doctor
component, init --mods, $.ruflo noun), the ruflo-swarm pane mod and the
ruflo-ruos plugin (ADR-405). No @claude-flow/* leaf source changed since
v3.49.0, so only the train moves.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 19:56:04 -04:00
ruv 969dcb2125 fix(mods): CI — keep metaharness last in doctor help; RUFLO_MODS_OWNS escape hatch; self-contained plugin tsconfigs
- doctor --component help lists 'mods' before 'metaharness': the
  ruflo-metaharness smoke step 17h greps 'metaharness)' (smoke-all,
  smoke-without-metaharness).
- audit-env-var-precedence: RUFLO_MODS_OWNS is the ADR-404 handshake set
  by the running mod, read by hook scripts with no CLI-flag surface
  (Plugin package install-safety job).
- plugins/ruflo-mods and the mod template tsconfigs no longer extend the
  gitignored .claude-plugin/types/tsconfig.json: vite/esbuild loads the
  nearest tsconfig for every transformed module, so in CI (types absent)
  root vitest failed to transform the six mods suites that import plugin
  code (TSCONFIG_ERROR: Tsconfig not found). typeRoots points at the
  generated folder instead; tsc still checks against it where present.

Verified: ruflo-metaharness smoke 125/125; env-var audit clean; root vitest
on the mods suites 99/99 with the generated types moved aside (as in CI);
tsc clean for mod and template; kit 16/16 + 1/1; validate passes.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 19:01:00 -04:00
ruv fd35a49cbc chore(helpers): re-sign helpers manifest for the mods hook-handler handshake (ADR-404)
hook-handler.cjs changed for the RUFLO_MODS_OWNS ownership handshake, so its
signed hash moves to 8876b17d…. Signed via the ruflo-helpers-signing-key secret.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 18:25:43 -04:00
ruv a0c4f99c2e fix(mods): trust gate allow-list by provenance, no name-keyed self-exemption; fs.write is risky; strip CSI/OSC from segments
A module's name is its manifest's own word: a Claude-written mod calling
itself 'ruflo-mods' walked past the gate under refuse-risky. The gate now
has no self-exemption (a module only judges those admitted after it) and
modTrustAllow matches the loader-keyed provenance (name@marketplace).
fs.write joins the risky calls (any path: settings/hooks persistence).
Segments lose ANSI CSI/OSC sequences, not just their ESC byte.

Kit 16/16 on 2.1.287 (inline provenance is <name>@claude-plugin-test);
vitest 99/99.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 18:22:57 -04:00
ruv f0a5d66c56 docs(adr): ADR-404 — 2.1.287 facts, $.ruflo contract, trust gate, live evidence, scaffold
Correction: 2.1.282 needs CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 (live: 'not
turned on' without it); the earlier 'loads unset' observation was on the
already-upgraded 2.1.287 binary. 2.1.287 loads by default; on both the
server-side rollout switch can hold mods off.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 18:19:29 -04:00
ruv c84c559189 feat(mods): doctor reports which claude runs, mods-by-default from 2.1.287, stale/mixed installs (ADR-404)
findClaudeInstalls walks PATH (plus ~/.local/bin) in order, de-duplicated by
real path; judgeInstalls reads the first: >= 2.1.287 mods on by default,
2.1.277..2.1.286 need CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1, older predates
mods; any other installed version is flagged as a possible shadow (e.g. a
2.1.107 npm-global beside a 2.1.287 native install).

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 18:10:59 -04:00
ruv 8a1e11f3bd feat(mods): $.ruflo noun, status segments, mod trust gate, refusal-tolerant $ (ADR-404)
- engine.create adds a flat $.ruflo noun (types/index.d.ts, plugin.json
  "types"): segment({id,text}), lastRoute(), snapshot(). Other mods (ruOS,
  ruflo-ruos) contribute status segments instead of drawing a second bar.
  Segments are untrusted: id token, control/bidi stripped, 48 chars, max 8,
  sorted by id. One drawer for the status line, from the $ beneath.
- plugin.register trust gate: names what a later-registering user-tier mod
  can do (process.run, http.fetch, env.set; tool.check, tool.call, *,
  classic.*, plugin.register, prompt.compose), from the host scan.
  userConfig modTrust: observe (default) | refuse-risky | off, plus
  modTrustAllow. Under refuse-risky a gate failure refuses.
- every ui.status/log/toast call tolerates refusal (admins can withhold $)
- tsconfig extends the types Claude Code >= 2.1.287 writes on load
- kit tests: 15/15 on Claude Code 2.1.287, incl. two tighten-only tool.check
  mods composing, trust refusal at load, budget ladder with options
- vitest: 95/95 (noun/segment and trust suites added)
- CI ratchet baseline: the four engine-kit files (claude-code/testing is not
  resolvable by root vitest), as #3605/#3607 do

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 18:09:25 -04:00
ruv 24c9c4a8d8 fix(mods): handshake in the generated helper; ENOENT-only missing; doctor reports the rollout switch (ADR-404)
- generateHookHandler() carries the same RUFLO_MODS_OWNS handshake, so a
  helper written by the refresh fallback still hands route/post-edit over
- isMissing matches ENOENT only: a misread error must fail the guard
  closed, never read as 'no policy'
- doctor: the server-side rollout switch decides whether the mod loads
  (observed live: loads with the enable variable unset while served on, not
  with it set while served off); the variable is reported, never sufficient
- bin-level tests for init --mods, doctor --component mods, mods status
- ADR: live-run evidence, final counts; README: where options are read

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 17:58:22 -04:00
ruv 5c74f1ecc3 test(mods): declaration-faithful harness, parity and no-double-fire suites, latency bench (ADR-404)
84 vitest tests: router/ranked-context parity with router.cjs and the real
hook-handler.cjs route output; tool.check never-loosen property and fail-
closed paths; ruleMatches parity with @claude-flow/security (10k+ cases);
exactly-once routing/edit records against the real hook-handler.cjs and
ruflo-core ruflo-hook.cjs; recordEdit format; budget.mjs ladder; CLI
install/uninstall/probe/projection incl. the real policy runtime.

scripts/bench-mods-latency.ts: classic spawn vs handed-over spawn vs the
in-process handler, median/p95.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 17:51:14 -04:00
ruv 73f530e908 feat(cli): ruflo mods install|uninstall|status|doctor|sync-policy, init --mods, doctor check (ADR-404)
- mods install writes enabledPlugins, the ruflo marketplace and the
  early-access switch to .claude/settings.local.json (default) and records
  what it added; uninstall removes only that. Classic hooks are untouched.
- status/doctor: plugin enabled, function hooks + cached rollout switch,
  allowManagedModsOnly refusal, helper handshake support (project and
  $HOME copies), policy projection, last mod start (heartbeat).
- policy-runtime writes .claude-flow/policy/claude-code.json after each
  successful state write: mode + rules naming claude-code.* actions only,
  for the mod's tighten-only tool.check. Never fails the state write; never
  touches receipts or the ledger anchor (#3602 unchanged).
- doctor: warn-only 'mods' component in the default run.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 17:51:14 -04:00
ruv c335261199 feat(helpers): hand route/post-edit to the ruflo mod via RUFLO_MODS_OWNS (ADR-404)
hook-handler.cjs (both copies) returns before any work for route or
post-edit when the ruflo mod, running in the same Claude Code process, has
named them in RUFLO_MODS_OWNS. Guards (pre-bash) and session hooks never
hand over, whatever the variable says. ruflo-core's ruflo-hook.cjs stands
down for post-edit likewise, so an edit is recorded exactly once.

hook-handler.cjs content changed: the helpers manifest must be re-signed at
release (helper-signing.test.ts fails on the hash until then).

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 17:51:02 -04:00
ruv 4b5e0e8231 release 3.49.0: re-sign helper manifest, regenerate witness manifests
- helpers.manifest.json re-signed for 3.49.0
- verification/{linux,macos,windows}/manifest.md.json regenerated on a clean,
  fully built tree: 117/117 verified each, os field stamped per manifest

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 19:51:39 -04:00
ruv 35cf4a49ea release 3.49.0: bump train to 3.49.0, @claude-flow/security to 3.0.1
security 3.0.1 carries the #3568 policy-ledger truncation fix (bundled into
the train and published standalone). codex's security pin relaxes to ^3.0.0
so the workspace keeps linking the local security package; codex source is
unchanged.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 19:50:50 -04:00
rUv d8e4d9535e Merge pull request #3583 from ruvnet/fix/3555-3565-helpers
fix(helpers): ship CommonJS helpers as .cjs so they load in ESM projects (#3555)
2026-09-30 19:47:19 -04:00
rUv 77befe1d90 Merge pull request #3582 from ruvnet/fix/3566-sibling-disclosure
fix(memory): disclose the sibling AgentDB store on partial hits too (#3566)
2026-09-30 19:19:09 -04:00
rUv 747d074833 Merge pull request #3571 from drakeo338/claude/3570-fix
fix(memory): validate namespace on memory store and memory import
2026-09-30 19:16:50 -04:00
rUv 63c041f766 Merge pull request #3581 from ruvnet/fix/3567-route-abstain
fix(hooks): route no longer reports its highest confidence when nothing matched (#3567)
2026-09-30 19:09:34 -04:00
rUv bf2c7b463f Merge pull request #3584 from ruvnet/fix/3573-3575-session
fix(session): import round-trips and save actually includes memory (#3573, #3575)
2026-09-30 19:06:56 -04:00
ruvandNick Ruest c1d425fafc Merge origin/main into fix/3555-3565-helpers
Resolves the helper-refresh.ts import conflict with #3576 (Nick Ruest's
post-install integrity re-check) by keeping both imports, and runs
ensureCommonJsCompanions after the #3565 heal path rewrites helpers too,
so a healed install also gets its .cjs companions (#3555).

Co-Authored-By: Nick Ruest <nicholas-ruest@users.noreply.github.com>
Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 19:06:24 -04:00
rUv 9672237333 Merge pull request #3580 from ruvnet/fix/3557-plugin-trust
fix(plugins): make --verify enforce trust and permissions on install (#3557)
2026-09-30 19:02:45 -04:00
rUv e1f7f2057b Merge pull request #3576 from nicholas-ruest/fix/signed-helper-verification-3565
fix(cli): re-verify signed critical helpers on every invocation, not just once (#3565)
2026-09-30 19:02:41 -04:00
rUv 8d7e3b26b9 Merge pull request #3579 from ruvnet/fix/3568-ledger-anchor
fix(policy): anchor the decision ledger head so truncation fails verification (#3568)
2026-09-30 18:56:38 -04:00
rUv 7840af50cf Merge pull request #3578 from ruvnet/fix/3572-swarm-progress
fix(swarm): status no longer invents 5% progress for a swarm with no tasks (#3572)
2026-09-30 18:51:59 -04:00
ruv ef99017d45 fix(helpers): ship session and memory helpers as .cjs too (#3555)
hook-handler.cjs also safeRequire()s session.js and memory.js, which are
CommonJS and fail in "type":"module" projects exactly as router.js did:
session-restore/-end then fall back to placeholder output and no session
is recorded. (In this repo the root copy already had session.cjs and
memory.cjs, so the .js requires never loaded anything at all.)

- rename the packaged session.js / memory.js to .cjs; hook-handler (both
  copies and the generated one), generateHelpers and the init generator
  fallback now use the .cjs names
- neither helper is in the signed critical set, so a pre-rename install
  whose hook-handler gets refreshed would lose them: the refresh and
  `init --upgrade` now write any missing session.cjs / memory.cjs from the
  compiled generators (helper-companions.ts). Stale .js copies are left in
  place and ignored; existing .cjs files are never overwritten
- hook-handler exports loadedHelpers so loading can be verified
- helpers manifest re-signed (hook-handler.cjs content changed)

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 18:07:47 -04:00
ruvanddrakeo338 b1811363ec fix(memory): one validator for namespaces and keys across store, import, export and purge (#3570 follow-up)
Follow-up to drakeo338's fix, closing the remaining gaps found in review:

- Keys: MCP memory_store rejected `../` in keys, but CLI `memory store`
  and `memory_import` accepted it. The MCP rule (DANGEROUS_KEY_PATTERN)
  is now exported through `memoryKeyError()` and used by all three;
  import checks every key up front, so a bad file writes nothing. Keys
  with a plain `/` (`probe/x`) stay legal.
- Purge: `purgeNamespace` used its own NAMESPACE_PATTERN, which rejected
  `:`, so `team:alice` could be stored and exported but never purged. It
  now uses `validateIdentifier`, like the other three operations.
- MCP memory_store: namespaces only faced the key blacklist, so
  `proj/sub` was accepted there but rejected by export and purge. It now
  uses `validateIdentifier` too.

Tests added to memory-store-import-namespace-3570.test.ts: each gap fails
on the prior head and passes here, plus a round-trip table asserting that
CLI store, MCP store and purge accept exactly the namespaces export
accepts.

Co-Authored-By: drakeo338 <drakeo338@users.noreply.github.com>
Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 18:07:28 -04:00
ruv 7099a95d9e fix(memory): drop unverified 150x/12,500x HNSW speedup claims from CLI output
`memory search --build-hnsw` printed "Search speedup: 12,500x / 150x / 10x"
chosen purely by entry count, and `memory stats` printed "150x-12,500x
faster search". The repo's measured numbers are ~1.9x-4.7x above the
crossover; the multiplier was never reproduced in-tree. Removed the
speedup line and the stats banner, and dropped the claim from the
backend hint and the --build-hnsw option description. No multiplier is
asserted anywhere in memory.ts now.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 18:03:16 -04:00
ruvandNick Ruest b72ca9f7d8 feat(doctor): report signed-helper integrity mismatches (#3565 follow-up)
Review finding on #3576: the issue asked that `ruflo doctor` report a
helper integrity mismatch, and doctor had no such check. Startup now heals
tampered helpers, but the paths it deliberately skips (.LOCKED,
RUFLO_HELPERS_LOCKED, an unverifiable package manifest, an unresolvable
package source) were invisible to doctor.

Adds `checkHelperIntegrity`, which reuses Nick's `verifyInstalledCriticalHelpers`
and the shared `CRITICAL_HELPERS` list (no second hard-coded copy), for both
<cwd>/.claude/helpers and ~/.claude/helpers:
- mismatch, not locked -> fail, naming the dir and files
- mismatch under .LOCKED / RUFLO_HELPERS_LOCKED -> warn (deliberate edit)
- manifest signature invalid -> fail closed
- package source not found -> warn instead of a false pass
Wired into the default run and `doctor --component helpers`.
`findPackageHelpersDir` is exported for the check. 8 new tests.

Co-Authored-By: Nick Ruest <nicholas-ruest@users.noreply.github.com>
Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 18:02:38 -04:00
ruv 9d026a8947 fix(helpers): ship router as .cjs so it loads in ESM projects (#3555)
`.claude/helpers/router.js` is CommonJS but shipped with a `.js`
extension. In any project whose package.json declares "type":"module",
Node loads it as ESM, `require` is undefined, it throws on load, and
hook-handler.cjs silently falls back to "Router not available, using
default routing" — so ADR-389's word-boundary routing fix never ran in
exactly the projects most new Node code uses.

Rename the shipped helper to router.cjs everywhere it is produced or
consumed: the packaged copy, the repo-root copy's hook-handler require,
helpers-generator (router + generated hook-handler), init executor
(upgrade copy list + generator fallbacks), helper-refresh
CRITICAL_HELPERS + generator fallback, sign/verify-helpers critical
lists, and the helper-signing security smoke. The helpers manifest is
re-signed. A stale router.js left in an existing install is harmless:
nothing requires it any more.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 18:02:37 -04:00
ruv 7d55ac6e77 fix(plugins): skip npm lifecycle scripts for untrusted plugin installs (#3557)
Withholding hooks was not enough: `npm install` ran the package's
preinstall/install/postinstall (and its dependencies') before the trust
decision, so an untrusted plugin's postinstall executed with the user's
privileges.

- installFromNpm passes --ignore-scripts unless --trust is given or the
  registry vouches for the plugin (official/verified); a warning names the
  skip and the --trust opt-in, and the manifest records scriptsRun.
- npm pack for checksum verification always runs with --ignore-scripts.
- upgrade keeps an install that recorded scriptsRun:false script-free.
- installFromLocal never runs npm or package scripts; it records
  scriptsRun:false.

Test drives real npm against a local tarball whose postinstall writes a
sentinel: no sentinel on a default install, sentinel with --trust. Both
cases fail on 755c70589.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 18:02:28 -04:00
ruv 18d6a7b70c fix(session): import round-trips and save actually includes memory (#3573, #3575)
#3575: `session import` passed a parsed `data` object to session_import,
which required `inputPath`, so it returned { error }; the CLI then printed
"Session imported" and crashed reading result.stats. The CLI now passes
the path, session_import also accepts an inline `data` record, and every
session subcommand checks the tool's { error } before printing success.
`session export` with no id now refuses (like delete) unless --latest is
given, and import/export help names the required positional argument.

#3573: session_save read only the pre-SQLite .claude-flow/memory/store.json,
which current installs never write, so --include-memory (default true)
saved nothing and reported "Memory Entries: 0". It now snapshots the live
memory DB plus rows found only in the sibling AgentDB store (deduped by
namespace+key), restore writes them back and reports the count actually
written, and the table says "not included" instead of an invented 0.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 18:02:04 -04:00
ruv 755c705895 fix(plugins): make --verify enforce trust and permissions on install (#3557)
`plugins install --verify` was parsed and never read, and a plugin's
declared trustLevel/permissions were neither recorded nor enforced, so an
"untrusted" local plugin declaring shell:exec/secrets:read registered its
hooks silently.

- Registry installs with a well-formed sha256 checksum are verified against
  the tarball actually installed (npm pack -> hash -> install that file) and
  fail closed on a mismatch. Placeholder checksums are reported as
  unverifiable and fall back to npm's own integrity check.
- Declared trustLevel and permissions are recorded in installed.json.
- Hooks and commands are withheld (and recorded under `withheld`) for a
  plugin that is untrusted/unverified or declares permissions beyond
  DEFAULT_PLUGIN_PERMISSIONS (memory:read), unless --trust is passed.
  Registry official/verified plugins are vouched for by the registry.
- --no-verify keeps the old behaviour and prints a warning.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 17:59:21 -04:00
ruv 45a3b2ddd2 fix(hooks): route no longer reports its highest confidence when nothing matched (#3567)
suggestAgentsForTask() ended with a hard-coded { confidence: 0.7 } reached
only when no keyword or learned pattern matched. Blank, punctuation-only and
non-English tasks therefore routed to `coder` at 70%, above a correctly
routed "deploy the release to production" (62%).

The no-match path now returns NO_MATCH_CONFIDENCE (0.3, below every real
signal: keyword hits >= 0.8, learned >= 0.7, eligible semantic > 0.4, and the
same value the helper router already uses) with matched: false,
reason: 'no-match-default' and a note saying why (no words, or the keyword
matchers are English-only). Tasks with no letters or digits skip semantic
scoring. hooks_route, hooks_explain and hooks_pre-task surface the marker;
the CLI labels the box "Default Suggestion (nothing matched)", reports
success probability as unknown, and refuses a whitespace-only --task like an
empty one.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 17:58:57 -04:00
ruv f090628452 fix(policy): anchor the decision ledger head so truncation fails verification (#3568)
The ADR-324 decision ledger is a hash chain, which rejects a modified or
deleted-middle receipt but not a deleted tail: a prefix of a valid chain is
itself a valid chain. Deleting the most recent receipts, or all of them, from
.claude-flow/policy/state.json still verified as valid: true.

- PolicyState gains ledgerHead/ledgerLength, updated in the same state write
  as every receipt append.
- verifyLedger fails with policy-ledger-truncated (or
  policy-ledger-anchor-mismatch) when the chain disagrees with its anchor, and
  answers an empty ledger distinctly (state: 'empty').
- appendReceipt refuses to extend a chain that no longer matches its anchor,
  so a new decision cannot re-anchor a truncated ledger and erase the evidence.
- Ledgers written before the anchor existed verify as valid and are anchored
  once (anchor: 'established-now'); truncation before that point is not
  detectable and is not claimed to be.
- verifyPolicyLedger is now a locked read instead of a write transaction, whose
  own post-operation check turned every failure into a generic
  policy-ledger-verification-failed. `policy verify` exits 1 when invalid.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 17:58:52 -04:00
ruv 2e8f419c22 fix(swarm): status no longer invents 5% progress for a swarm with no tasks (#3572)
getSwarmStatus() hard-coded progress to 5 whenever a swarm existed but had
no tasks, so `swarm status` rendered [##----] 5.0% forever, regardless of
how many agents were spawned. With no tasks there is nothing to be a
fraction of: progress is now null with progressReason "no tasks" (JSON)
and "Overall Progress: n/a (no tasks)" (text), matching the neighbouring
"Tokens Used: unknown" / "Success Rate: no data" fields. With tasks,
progress stays completed/total.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 17:58:06 -04:00
ruv 91ea1b524e fix(memory): disclose the sibling AgentDB store on partial hits too (#3566)
`memory search` and `memory retrieve` disclosed the sibling AgentDB store
(.swarm/agentdb-memory.db, written by the MCP path) only in their
empty-result branches, so a partial hit ("Found 1 results") read as
complete while the other store's rows went unread. The disclosure now
runs on every search path (semantic, hybrid, keyword-only, text and
JSON) and on a found retrieve, worded as "Partial result: N matches
came from the store read here". Warnings go to stderr, so --format json
and --value-only stdout stay parseable.

Also: `memory import` reported "Vectors: 0" while every value was
re-embedded. The memory_import tool now counts the vectors storeEntry
actually wrote.

Fixes #3566

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 17:56:03 -04:00
Nicholas RuestandRuFlo 3b885e5a7e fix(cli): re-verify signed critical helpers on every invocation, not just once (#3565)
`helper-refresh.ts` verified a critical helper's signature/hash once, at
copy time, then stamped the target dir with the installed CLI version.
Every later command short-circuited on "stamp already matches" with zero
further verification, so a critical helper (router.js, hook-handler.cjs,
etc.) modified on disk after that point — a sibling package's postinstall,
a losing writer from a concurrent-session race, direct tampering — stayed
silently modified through any number of subsequent commands, indefinitely.

Adds helper-integrity.ts: re-hashes each installed critical helper against
the signed manifest independent of the stamp. helper-refresh.ts now runs
this on every stamp-match call (both the lock-free fast path and the
under-lock authoritative path) and heals a mismatch via the existing
fail-closed verify-then-copy path. `.LOCKED`-marked installs are exempt —
a deliberate hand-edit is not tampering. index.ts surfaces a loud,
non-verbose-gated warning when tampering is detected and healed, for both
the project and global helper dirs.

Adds 4 new tests (heal-on-tamper, .LOCKED exemption, unverifiable-source
handling, genuine-no-op-when-intact) and updates one existing test whose
premise this fix intentionally changes (a same-version race between two
genuinely different signed sources has no real-world analog — production
always resolves one real trust root — so it's rewritten to assert no
redundant write happens once content is verified correct).

Verified: tsc --noEmit clean, full package build succeeds, compiled
dist/src/init/helper-refresh.js confirmed to no longer contain the bare
`if (stamped === version) return { refreshed: false }` #3565 flagged.
Full CLI test suite (4405 tests) passes except 4 pre-existing failures
unrelated to this change (confirmed against unmodified baseline / known
unbuilt-dependency issues in @claude-flow/mcp and @claude-flow/memory).

Fixes #3565

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-30 17:51:41 -04:00