4215 Commits
Author SHA1 Message Date
rUv 9936abe8b5 fix(cli): isolate tool-time npx, contain metaharness file arguments, validate daemon stop target (3.80.3) (#5085)
Tool-time npx calls resolve packages from a ruflo-owned prefix instead of the opened project; metaharness MCP file arguments stay inside the project; daemon stop only signals a validated ruflo process. Release 3.80.3 (helpers manifest re-signed).

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-11-23 14:17:00 -05:00
171ab4550f dream(memory): ReasoningBank never enforces its own contradiction-exclusion flag (evaluated, ACCEPT) #5081 (#5082)
* dream(memory): #5081 ReasoningBank never enforces its own contradiction-exclusion flag

detectContradictions() marks the lower-quality side of a contradicting
memory pair consolidated=true ("to exclude from retrieval"), but
retrieve()/retrieveByContent() never checked that flag. Add the filter
in both read paths; byte-identical for any entry never flagged.

Independently corroborated by two research roles (external-literature
review and pure code review) before either saw the other's output, and
independently reproduced by a fresh-context adversarial critic. 184/184
full @claude-flow/neural suite, tsc clean, 0 regressions. Darwin skipped
(binary guard, no tunable parameter, precedent: 2026-11-14).

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

* docs(dream-cycle): fill in 2026-11-23 gist witness block

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

* docs(dream-cycle): append 2026-11-23 ledger row (#5081/#5082)

Also records direct verification of the 2026-11-19..22 no-run gap and
that #4973/#4983/#5012/#5034 were batch-integrated via #5041 (merged
2026-11-19), not rejected.

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

* fix(neural): skip consolidated memories while gathering candidates (#5081)

Filtering after candidate selection let an HNSW hit list made only of
consolidated entries return nothing instead of falling back to brute force,
and counted it as an HNSW retrieval.

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

* chore(neural): publish 3.1.2 and pin it (#5081)

The ReasoningBank fix lives in a non-bundled leaf; @claude-flow/neural 3.1.2 is
published standalone so the train carries it.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: r <r@x>
2026-11-23 13:56:07 -05:00
rUvandr dba3a947a8 fix(doctor): Version Freshness compares against latest, not the frozen alpha tag (#5079) (#5086)
doctor asked npm for @claude-flow/cli@alpha, frozen at 3.75.2 since ADR-513, so
every version from 3.75.2 on reported "up to date". Query @latest, the tag its
fix advice installs. The federation fix advice installed the frozen @alpha
(1.0.3; latest is 1.0.7); point it at @latest too.

Co-authored-by: r <r@x>
2026-11-23 13:54:57 -05:00
rUvandr c4e05f5bd3 chore(release): 3.80.2 (#5078)
Fixes since 3.80.1:
- #5076: a crash between creating and writing the policy state lock left an
  empty state.lock that failed every MCP tool call (Codex's guidance_brain and
  memory_search included) with policy-state-lock-timeout. The lock is now
  published whole with link(), and a stuck lock names its cause and path.
- #5077: Codex parsed the hook handler's `[INFO]`/`[OK]` reports as JSON
  ("invalid user prompt submit JSON output"); under a Codex payload the
  handler now emits hook JSON (additionalContext) or nothing on stdout.

Re-signed helpers.manifest.json.

Co-authored-by: r <r@x>
2026-11-23 13:20:35 -05:00
rUvandr 326687da9b fix(policy): never leave an empty state.lock; say how to recover a stuck one (#5076)
* fix(policy): never leave an empty state.lock; say how to recover a stuck one

acquireLock created state.lock and then wrote its owner into it. A process
that died in between (a reboot, SIGKILL, OOM) left an empty lock that names
no owner, so it can never be reclaimed: every MCP tool call, Codex's
guidance_brain and memory_search included, waited 5 s and failed with a
bare policy-state-lock-timeout. Seen live: a 0-byte lock from a previous
boot blocked the project for five days.

- The owner is written to a private temp file first and link() publishes
  the lock whole (EEXIST when held, never follows a symlink). Windows and
  filesystems without hard links keep create-then-write, which now removes
  its own lock if the write fails.
- A timeout against an owner that can never be identified (empty, unreadable,
  another host, an earlier boot, another PID namespace) now says which, its
  age, and the path to remove. A live owner keeps the bare message, which the
  console retries.
- Unknown owners are still never taken over automatically.

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

* test(mcp-tools-deep): give the in-memory fs fake linkSync for the atomic lock

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

---------

Co-authored-by: r <r@x>
2026-11-22 22:32:29 -05:00
rUvandr dd233e6055 fix(hooks): keep Codex hook stdout valid JSON (#5077)
* fix(hooks): keep Codex hook stdout valid JSON (invalid user prompt submit JSON output)

Codex reads a hook's stdout as hook JSON when it starts with `{` or `[`.
hook-handler.cjs reports in lines like `[INFO] Routing task` and
`[OK] Edit recorded`, so under Codex every UserPromptSubmit failed with
"invalid user prompt submit JSON output", and PostToolUse/SubagentStop the
same way. #3163 fixed this for auto-memory's Stop hook only.

Under a Codex payload (it carries turn_id, as in #3163) the handler now
collects what it logs and writes it once at exit: as
hookSpecificOutput.additionalContext for UserPromptSubmit and SessionStart,
so the routing report still reaches the model, and on stderr for every other
event, leaving stdout empty. Claude Code payloads are unchanged. pre-bash
keeps its own blocking protocol. Same change in the generated fallback.

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

* chore(helpers): re-sign the helper manifest for the Codex stdout change

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

---------

Co-authored-by: r <r@x>
2026-11-22 22:09:02 -05:00
rUvandr 6104acc82e fix(update): never load package files from the working directory (3.80.1) (#5072)
getInstalledVersion() resolved <pkg>/package.json with paths: [process.cwd()]
and loaded it with require(). A package's exports map can point
./package.json at a .js file, so a node_modules/@claude-flow/security (or
embeddings, integration, testing) committed to a cloned repository ran inside
the CLI on the startup update check of almost any command.

Resolve from the CLI's own install only and read the file with JSON.parse,
so nothing is executed. Adds update-checker-cwd-hijack.test.ts (fails on
3.80.0, passes here); the 4755 opt-in test now also mocks the file read.
Release 3.80.1 (helpers manifest re-signed).

Co-authored-by: r <r@x>
2026-11-22 15:43:49 -05:00
rUvandr f0dd7e6b6e fix(x-gateway): single-use invites, invite revoke, ordered federation_sync cursor (#5029, #5030) (#5057)
* fix(x-gateway): single-use invites, invite revocation, ordered sync cursor (#5029, #5030)

#5029
- mintInvite and federation_invite_mint default to max_uses 1 (was 25);
  maxUses/ttlSecs must be positive integers.
- New legacy-only, admin-only federation_invite_revoke: revokes by code or id
  via buzz-relay POST /api/invites/revoke (block/buzz#9680). Admission is
  decided by the relay, so revocation lives there; a relay build without the
  route answers 404 and the tool reports "unsupported". Withheld from the
  directory profiles because it accepts an invite code.
- CLI: x_federation_invite_revoke passthrough; mint/--uses text says default 1.

#5030
- federation_sync returns next_cursor and accepts since_cursor. The relay
  exposes no receive-order sequence, so the cursor carries a window floor plus
  48-bit prefixes of the ids already delivered inside it. Each call reads the
  whole window (full NIP-01 pages are narrowed by `until` bisection, because
  `limit` keeps the newest events) and delivers unseen events oldest first by
  (created_at, id). Same-second events and late arrivals within 300 s are
  delivered exactly once. A timed-out read hands the same cursor back.
- The cursor is decoded as hostile input: length cap, strict shape, lookback
  clamped to 30 days, bound to the type filter.
- No-cursor calls keep the old window read and relay filter.
- CLI: since_cursor in the x_federation_sync schema; `federation sync --cursor`.

Gateway package 0.9.2 -> 0.10.0, plugin 0.10.6 -> 0.11.0.

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

* fix(x-gateway): judge sync completeness on the raw relay page; compact cursor

buzz-relay applies `limit` in SQL before it matches #t/#k in Rust
(handlers/req.rs filter_fully_pushable), so a short #t-filtered page does not
prove a window complete. Cursor reads now send only kinds/since/until/limit,
match the swarm tag and type locally, and judge completeness on the raw count.
A no-cursor read cannot prove completeness either, so its next_cursor keeps the
whole requested window and remembers what was returned.

The cursor encodes delivered ids as delta-coded seconds, so the largest cursor
the gateway can emit (2000 ids in distinct seconds) fits the schema cap, and
any type string the tool accepts round-trips. Tests: the fake relay applies
limit before tag matching and carries non-swarm traffic; a property test pins
the cursor size bound.

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

* test(ci): list the new x-gateway node:test files in the root ratchet baseline

invite-admin and sync-cursor import nostr-tools, which only the plugin's own
`npm test` installs (157/157 pass there), like the other x-gateway suites.

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

---------

Co-authored-by: r <r@x>
2026-11-22 15:23:50 -05:00
243adcbc36 fix(daemon): gate workers on available memory on macOS (#2935) (#5064)
On Darwin, os.freemem() counts only free and speculative pages. The kernel
keeps reclaimable file cache on the inactive queue, so an idle Mac reads as a
few percent "free" and the worker daemon defers almost every worker.

The memory gate now measures available memory on Darwin from vm_stat as
(free + speculative + inactive) x page size, clamped to totalmem, with the
page size read from vm_stat's own header (16 KiB on Apple Silicon). Purgeable
pages are not added because they already sit on other queues. Linux and
Windows keep os.freemem() unchanged.

vm_stat runs without a shell, with a 1 s timeout; concurrent checks share one
probe and results are cached for 5 s. If the probe fails the gate falls back
to os.freemem() and logs that once per daemon. Threshold defaults are not
changed.

Refs #2935

Co-authored-by: Lenin Mookiah <2639584+leninworld@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:23:44 -05:00
Andrew Chen 4be918c6f2 fix(memory): honour minConfidence 0 in bridgeSearchPatterns (#5060) 2026-11-22 15:23:38 -05:00
rUvandr e86f3dd321 fix(memory): search and read-only list fallbacks never write the store (#5065) (#5071)
The sql.js fallbacks behind memory_search and memory_search_unified took
memory.db.lock and could migrate the schema on every call (via
ensureSchemaColumns), opened and wrote hnsw.index, and wrote
rabitq.meta.json when a search built the RaBitQ pre-filter.

- readOnlySchemaError(): probes PRAGMA table_info on the loaded image, no lock;
  a store that needs migrating is refused with an error naming the fix.
- searchEntries: uses the probe, searches an HNSW index only if this process
  already opened one, and builds RaBitQ in memory without its meta file.
- listEntries({ readOnly: true }): no lock, no migration, no native-handle
  release; memory_search_unified passes it. Other listEntries callers keep
  the migrating path.

Co-authored-by: r <r@x>
2026-11-22 14:46:08 -05:00
21c24d3218 fix(learning-loop): help/list runs are not verifiers; never store part of a secret (#5067) (#5068)
* fix(learning-loop): help/list runs are not verifiers; never store part of a secret

An edit followed by a test command that only printed help or listed tests
(`npm test --help`, `npx vitest list`, `npx jest --listTests`,
`pytest --collect-only`, `cargo test --no-run`, `go test -list .`) was
recorded as verified-success: classify() matched the command head and
ignored the rest, and those commands exit 0 without running a check.

- classify(): a verifier segment whose bash words ask for help, version,
  a listing, a config dump, a dry run or a compile-only build is not a
  verifier; `vitest list` / `cargo nextest list` likewise. Words are split
  as bash does, so a quoted argument that contains `--help` (a test-name
  pattern) still verifies. A command with a shell comment is refused:
  `npm run build # && npm test` ran only the build.
- Verifier evidence is screened for secret shapes; a command carrying one
  keeps its kind and outcome and is stored as `[redacted]`. Evidence reaches
  SONA feedback, the ledger and learned lessons.
- taskText() screened only the first 300 characters, after the cut, so a
  key the cut split was stored in part (`ghp_ABCDEFGHIJKLMNO`). It now
  screens the kept text plus 1 KiB, cuts at a word boundary so a long key
  (JWT) is dropped whole, and reads at most 64 KiB of the prompt
  (32M-character prompt: ~6 ms, against ~1.4 s unbounded).

Regenerated both learning-loop.cjs copies. helpers.manifest.json needs a
maintainer re-sign for the new bytes.

Co-Authored-By: Ruflo & AQE
Claude-Session: https://claude.ai/code/session_01GLQCdgnsuwts6j51rwcqgB

* fix(learning-loop): per-runner no-run flags, raw screening, SONA skips [redacted] (0.17.5)

Third adversarial review of #5068:

- More commands that exit 0 without a check are not verifiers: tsc -v,
  --listFilesOnly, -b --dry, --init; eslint -v, --env-info; vitest/jest
  -v; make -n/-q (and clusters); go test -c/-n; dotnet test -t; pytest
  --fixtures/--markers/--setup-plan; npm/pnpm/yarn/bun --if-present.
  Flags are read for the program actually run (past npx, pnpm exec,
  python -m, uv/poetry run), so `pytest -v` stays a run and
  `jest --testNamePattern vitest list` is not taken for `vitest list`.
- Bash removes a backslash-newline outright; classify() now joins without
  a space (`--ver\<newline>sion` is --version). An escaped space no longer
  starts a word, so `a\ #b` is not a comment.
- shellWords()/hasComment() move to hooks/loop/words.ts; narrows() uses
  them, so a partly quoted --passWithNoTests still taints (ADR-503).
- Evidence and task text are screened as given as well as normalised: a
  line separator or control character inside a key hid it from the
  folded screen. A kept key-block header ("-----BEGIN") is refused.
- Ingest counts a task stored as [redacted] and never trains SONA with
  it (it learned `coder:redacted`).
- ruflo-mods 0.17.5 with a CHANGELOG entry (version-bump check).

Every guard is covered: reverting any one of the 12 fails a test.

Co-Authored-By: Ruflo & AQE
Claude-Session: https://claude.ai/code/session_01GLQCdgnsuwts6j51rwcqgB

* chore(helpers): re-sign helpers.manifest.json for the rebuilt learning-loop.cjs (#5067)

Rebuilt learning-loop.cjs from source with build-learning-loop-helper.mjs;
the bytes match the committed bundle (sha256 0a39ee1d50d3349d...).

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

---------

Co-authored-by: r <r@x>
Co-authored-by: RuFlo <ruv@ruv.net>
2026-11-22 14:46:02 -05:00
ordinary being 1ca8b28cd1 fix(agentbbs): refuse symlinked state files (#5063)
.agentbbs is project-local and can be committed by a cloned repository. The identity, peer registry, room registry and room logs were read and written with path-following APIs, so a symlink shipped in the repo could make addPeer/register/publish/sync create or overwrite a file outside the project, or make serve/watch read one.\n\n- ensureAgentbbsDir refuses a symlinked or non-directory basePath.\n- assertRegularStateFile lstat-checks identity, peers, rooms.json and room logs before read/write; symlinks and special files fail closed.\n- getNodeIdentity creates with 'wx', so a dangling symlink is refused rather than followed, and re-reads a concurrent creator.\n- writePeers writes a temp sibling and renames, so a crash cannot leave a truncated peer registry that readPeers would treat as an empty, unpinned list.\n- agentbbs-tools reuses the same checks before nextSeq/readEnvelopes/registry read/append.\n\nRegression tests create real symlinks in temp dirs. On Linux the four federation cases fail against the pre-change source (victim overwritten, dangling target created, room log appended, symlinked basePath accepted) and pass with the change; the tools nextSeq case passes too.
2026-11-22 14:45:56 -05:00
Dragan SpiridonovandRuflo & AQE 6b7f267abe fix(hooks): redact Google, Cognitum and header/query-string keys in recorded commands (#5062)
* fix(hooks): redact Google, Cognitum and header/query-string keys in recorded commands

redactCommandForStorage (#4056) caught Authorization headers, --token flags,
*_TOKEN= assignments and well-known token shapes, but stored these verbatim:

- Google API keys (AIza…, 39 chars) — Firebase/identitytoolkit ?key= calls and
  Gemini keys;
- Cognitum API keys (cog_…);
- keys sent in x-api-key / X-Goog-Api-Key / x-auth-token headers;
- ?key= / &api_key= query-string credentials.

Adds two rules and two shapes; each is bounded like the existing ones, and the
hostile-input test covers the new prefixes. 8 new cases: 7 fail on main, all
35 pass with the fix. Fixtures are built by concatenation so secret scanners
do not flag them (gitleaks: no leaks in the diff).

Co-Authored-By: Ruflo & AQE
Claude-Session: https://claude.ai/code/session_01GLQCdgnsuwts6j51rwcqgB

* fix(hooks): close quoted-value and form-body leaks in command redaction

Review follow-up for the recorded-command redactor:

- header and Authorization rules accept a quoted value, so object-literal
  headers ({"x-api-key":"..."}) no longer leak
- new JSON/object-literal rule for api_key/apiKey/access_token/auth_token
  and quoted bare 'key'
- form bodies: api_key=/apikey= after whitespace or a quote, and bare key=
  after -d / --data*
- more header names (apikey, api-key, Ocp-Apim-Subscription-Key,
  Private-Token, X-Auth-Key, x-access-token) with an optional scheme;
  a colon is still required, so `grep -rn x-api-key src` is untouched
- cog_ keys matched as cog_ + 64 lowercase hex with hex lookarounds:
  catches prefix_cog_<hex>, leaves cog_SomeIdentifier alone
- bare ?token= no longer redacted (pagination cursors); ?key= kept on
  purpose and pinned by a test
- flag rule needs a non-word, non-dash char before its dash, so it no
  longer fires inside x-api-key (kept the colon of "x-api-key :v")
- negative tests with exact output; hostile-input test extended

Co-Authored-By: Ruflo & AQE
Claude-Session: https://claude.ai/code/session_01GLQCdgnsuwts6j51rwcqgB
2026-11-22 14:45:49 -05:00
rUvandClaude 19af6d8acb fix(security): unsigned content in agentbbs federation envelopes (#5061)
The canonical bytes an envelope signature covers were built by assigning
payload keys onto a plain object. An own `__proto__` key set the prototype
instead, so that key and its subtree dropped out of the signed bytes while
still being stored and re-served as the origin's content. Merge also stored
every top-level field of an incoming envelope, including fields the
signature does not cover.

- canonicalEnvelopeBytes refuses a payload containing a `__proto__` key,
  so verification fails and signing throws.
- mergeEnvelopes stores only the signed fields plus signature and hops.
- New test: agentbbs-federation-signed-coverage.test.ts (5 cases; all fail
  before, pass after).


Claude-Session: https://claude.ai/code/session_01MfPHVJbk1daZwNMDkX4iAC

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-22 14:45:42 -05:00
rUvandr 87f612cef1 chore(release): 3.80.0 (#5056)
* chore(release): 3.80.0 (codex 3.0.9)

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

* fix(cli): bundled OpenRouter alternates are opt-in (#4957)

#5038 loaded the bundled openrouter-alts.json for every npm install, which
changes which OpenRouter models users are billed for. Its PR asked for a
maintainer decision on that default. Until then, the bundled copy loads only
with CLAUDE_FLOW_ROUTER_OPENROUTER_ALTS=bundled; npm installs keep the
previous behaviour (no per-tier alternate). The file still ships.

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

* chore(release): pin @metaharness/darwin ~0.16.0; codex VERSION 3.0.9

darwin 0.16.0 is npm latest (it fixes the 0.15.0 bug that could leave SIM
journals unreadable), so the metaharness pin-drift gate flags ~0.14.0 as
stale. Bump the CLI dependency, MH_DARWIN_PIN and the plugin helper pin.
The pnpm lock entry is edited by hand to the 0.16.0 integrity; nothing else
in the lock moves. codex's exported VERSION follows the 3.0.9 bump.

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

* chore(ruflo-metaharness): 0.5.3 for the darwin ~0.16.0 helper pin

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

---------

Co-authored-by: r <r@x>
2026-11-20 22:21:35 -05:00
ordinary being 6822e67d69 fix(agentbbs): advance federation sync per origin (#5031) (#5052)
A room log interleaves envelopes from multiple origins, and each origin numbers its own seq. syncRoomFromPeer stored one room-wide max and sent it as since, so after merging an origin with a high seq, a later envelope from another origin with a lower seq was skipped by the next incremental pull.\n\n- Track per-origin high-water marks in FederationPeer.lastSeqByOrigin and send them as a JSON since cursor.\n- Teach serveFederation to parse that cursor while retaining the numeric since form for older clients; malformed or oversized cursors are rejected with 400.\n- Report acceptedByOrigin from mergeEnvelopes. Duplicates use the stored envelope's origin/seq, so a duplicate cannot move another origin's cursor.\n- Start a legacy peer's first per-origin sync from 0: an old room-wide cursor may already have skipped envelopes and is not a safe baseline.\n- Tests cover interleaved origins, a new origin with no cursor entry, numeric and malformed cursors, and duplicate-origin poisoning.
2026-11-20 21:16:07 -05:00
rUvandr 662796a974 fix: openrouter-alts resolves from the package (#4957); single winner on stale ledger lock (#5025) (#5038)
* fix(cli): resolve openrouter-alts.json from the package (#4957)

loadOpenRouterAlts() probed only process.cwd(), and the file was not in the
CLI's files allowlist, so an npm install never loaded the ADR-148 per-tier
OpenRouter alternates. Resolve it relative to the module (import.meta.url,
as neural-router.ts does), keep the cwd probes as a dev fallback, and ship
the file.

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

* fix(cli): only one waiter breaks a stale managed-agent ledger lock (#5025)

Breaking a stale lock was lstat -> unlink, so two waiters that saw the same
dead lock could both break it: the second unlinked the fresh lock the first
had just taken, and two writers raced their read-modify-rename. Breakers now
serialise on <lock>.reclaim and re-check the lock's identity and age under
it, as policy-runtime.ts reclaimDeadLock does. Release removes the lock only
if it is still the file this writer created.

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

---------

Co-authored-by: r <r@x>
2026-11-20 21:16:01 -05:00
rUvandr 6da74f2874 fix(cli): statusline tips and examples name commands that exist (#5042)
Four seed statusline tips described their commands wrongly:
- `ruflo status watch`: watch is the --watch flag. The positional was
  ignored and status printed once. Now `ruflo status --watch`.
- `doctor --fix` "auto-repair": --fix prints suggested commands and
  applies nothing. Reworded.
- `hooks route` "3-tier model routing cuts token cost 30-75%": hooks
  route suggests an agent type for a task (model tiers are
  `hooks model-route`), and the percentage has no source in the docs.
  Reworded, number dropped.
- `security scan --depth deep` "audits dependencies and config": the scan
  checks dependencies (npm audit), hardcoded secrets and code patterns.

Help examples:
- `memory store -k ... -v "..."`: -v is the global --verbose. The value
  only landed through the positional fallback, with verbose switched on.
  Now --value.
- `status --json`: not a declared option. The action reads
  --format json, so the example printed text. Now --format json.

Message ids and URLs are unchanged. New test
funnel-messages-commands.test.ts resolves every educational tip against
the real Command objects. `adr index` is exempt: there is no `adr` CLI
command, which is left for a separate fix.

Co-authored-by: r <r@x>
2026-11-20 21:15:54 -05:00
rUvandClaude 69e24c392e fix(security): prototype pollution in codex config.toml validator (#5051)
parseToml looked up section headers on a plain object, so a [__proto__]
or [constructor] header in an untrusted config.toml resolved to a shared
built-in and the following key = value lines were written onto it. Use
null-prototype maps for the parsed data and its sections, check own
properties only, and replace non-object values instead of writing onto them.


Claude-Session: https://claude.ai/code/session_01MfPHVKgRKN2gU6psLP1NGd

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-20 21:15:48 -05:00
rUv 4a80b5af8c feat(cli): opt-in signed SIM handoff ingestion (metaharness sim-ingest) (#5054)
* feat(cli): opt-in signed SIM handoff ingestion (metaharness sim-ingest)

Consumes metaharness.sim.handoff.v2 envelopes (ruvnet/metaharness#524).
An independent Node-crypto verifier checks the Ed25519 signature over
canonical JSON, a trusted key set, the key-to-tenant binding, freshness
and that every record belongs to the tenant. Verified evidence is stored
under sim:<owner>/<repo> in a dedicated .claude-flow/sim/sim-memory.db,
separate from task-agent memory, via the real memory-initializer API.

Disabled until .claude-flow/sim/trusted-keys.json sets enabled:true.
Idempotent on the content-derived event id; revoke-event leaves a
tombstone, revoke-key deletes its events and marks it revoked; reads
re-verify each row; every decision goes to an id/hash-only audit log.

Refs ruvnet/metaharness#524

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

* fix(cli): harden sim-ingest revocation, retention and store separation proof

- revoke-key confirms each row's signer before deleting instead of
  trusting the store's tag filter (two-keys-one-tenant test with the tag
  filter ignored).
- Retention runs from the producer's createdAt; a replay after it has
  elapsed is rejected (retention_elapsed) rather than re-stored.
- An insert that collides with a soft-deleted or expired row reclaims it
  (tombstones are checked first); covered on the real store by re-signing
  revoked-key content with a second trusted key.
- Real-store test now points CLAUDE_FLOW_DB_PATH at a real task-agent db
  and proves it holds no sim: rows and that search finds only task notes.

Refs ruvnet/metaharness#524

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-11-20 16:38:07 -05:00
rUvandr 3c2ae91170 fix(release): absolute README URLs on npm pages + release 3.79.1 (#5053)
* fix(release): absolute README URLs on the ruflo and @claude-flow/cli npm pages

npmjs.com resolves relative README URLs against repository.directory, so on
the ruflo page docs/assets/x.svg became raw.githubusercontent.com/.../HEAD/
ruflo/docs/assets/x.svg: 41 of 51 images and every relative link 404ed. The
@claude-flow/cli page had the same problem. claude-flow publishes from the
root and was unaffected.

The release workflow now stages both subdirectory READMEs through
scripts/readme-absolute-urls.mjs, which rewrites relative images to
raw.githubusercontent.com and relative links to github.com/blob, pinned to
the commit being published. Both prepare-publish scripts use it too. Also
fixes the README's Verification link (verification.md moved to
verification/README.md in May).

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

* chore(release): 3.79.1

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

---------

Co-authored-by: r <r@x>
2026-11-20 08:34:42 -05:00
rUvandr 861179f621 fix(auto-memory): Codex Stop hook stdout (#3163) + release 3.79.0 (#5049)
* fix(auto-memory): keep Codex Stop hook stdout empty (#3163)

Codex parses a Stop hook's stdout as hook JSON, so the AutoMemory status
prose failed every Stop with "invalid stop hook JSON output". A Codex
hook payload carries a turn_id that Claude Code's does not; under Codex the
helper now sends its status to stderr and leaves stdout empty. Claude Code,
terminal and unparseable-stdin runs keep stdout feedback. Stdin is read only
when it is not a TTY, capped at 500 ms and 1 MiB.

Verified end to end on Codex 0.170: Stop Failed with the old helper,
Completed with the new one.

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

* chore(release): 3.79.0

First train release published from CI with SLSA provenance (ADR-545).
Bumps the three packages and re-signs the helper manifest for 3.79.0
(auto-memory-hook.mjs changed for #3163).

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

---------

Co-authored-by: r <r@x>
2026-11-19 16:45:01 -05:00
rUvandr ad343eb14d feat(release): SLSA provenance publishing + pinned init output (ADR-545) (#5048)
* feat(release): publish the train with SLSA provenance (ADR-545)

stable-npm-release publishes with --provenance (id-token: write), checks
repository.url before publishing, defaults to a dry run, publishes only
from main, and promotes to latest only after the registry holds a SLSA v1
attestation for exactly the verified archive built in ruvnet/ruflo.
Only latest moves (ADR-513). ADR-545 records the client review items.

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

* fix(release): drop the dead root npm ci step that runs security's tsc prepare

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

* fix(release): clear x-gateway audit gate; allow HEAD dry runs (ADR-545)

npm audit fix clears the 2 high advisories; a scoped override lifts
rimraf's glob to ^14.0.2 for the remaining glob/minimatch moderates
(0 vulnerabilities, 142/142 gateway tests). tag=HEAD (dry run only)
builds the dispatched commit so a release can be rehearsed before it
is tagged.

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

* docs(adr-545): record RuVector#1516 and the laptop-only package gap

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

* chore(release): commit the signed helper manifest for 3.78.1 (ADR-545)

CI verifies the committed manifest; the signing key stays off CI.

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

* fix(release): npm ls --all warns instead of gating (#5047)

The published 3.78.1 tree already has invalid nested ranges; the
functional smoke checks stay the gate until #5047 aligns the pins.

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

* feat(cli): pin init output to the CLI's exact version, add repin and provenance check (ADR-545)

- init writes @claude-flow/cli, claude-flow and ruflo pinned to the running
  CLI's version (one specifier helper, src/init/pinning.ts); third-party MCP
  refs (ruv-swarm, flow-nexus, agentic-jujutsu) pinned to known versions.
  `--channel latest` keeps the previous floating output byte-for-byte.
- `ruflo init repin` / `init --repin`: idempotent rewrite of settings.json,
  .mcp.json, CLAUDE.md and .claude/helpers with --dry-run and a per-line
  report. Leaves signed helpers, JSON keys and #2448 runaway hook commands
  alone and says why.
- Helper refresh never rewrites signed helpers, so pins survive it.
- Provenance check (registry attestations, SLSA v1 predicate, subject digest
  == dist.integrity, repo == github.com/ruvnet/ruflo) via
  `doctor -c provenance`, after repin, and as a non-fatal warning at init.
  Fetch is injectable; tests use recorded registry fixtures.

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

* fix(release): test the federation WebSocket fallback by removing agentic-flow

The CLI now depends on stable agentic-flow ^3.0.0, so pinning the
alpha no longer forces the fallback; the smoke step was stale.

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

* fix(cli): pin untagged npx runs in helper scripts; update #2206 CI guard (ADR-545)

`npx @claude-flow/cli hooks …` with no tag floats exactly like @latest.
The generated pre-commit hook and copied unsigned helpers (post-commit,
pre-commit) ran it untagged. Init now pins those runs on copy and in the
generator, and `init repin` pins them in .claude/helpers. Docs copied from
the package and the user's CLAUDE.md are left as is. The --prefix form used
by the signed helpers is not matched.

The wizard-init guard required the literal `ruflo@latest` in
mcp-generator.ts; it now requires the args to run the ruflo wrapper via
ourSpec('ruflo', …).

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

* docs(adr-545): CI-only train publishing in CLAUDE.md; record dry-run findings

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

* chore(x-gateway): bump plugin to 0.10.6 for the dependency audit fix

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

* fix(adr-545): unambiguous flag regex (CodeQL ReDoS), anchored scope replace, keep doctor help ending in metaharness)

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

* ci: exclude the node:test provenance gate test from the vitest ratchet (runs via node --test in v3-ci)

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

---------

Co-authored-by: r <r@x>
2026-11-19 16:21:20 -05:00
rUvandr d9213d356c feat(mods): enable Project Anatole (ruflo-protector) by default (#5046)
ruflo init and ruflo mods install now enable ruflo-protector@ruflo with
the other ruflo mods (MOD_PLUGINS). It starts in learn mode, graduates
only to notify, and never enables enforce by itself. An explicit false
in enabledPlugins is preserved. ADR-453 §14.1 amended; protector 0.1.3.

Co-authored-by: r <r@x>
2026-11-19 15:02:49 -05:00
rUvandr 9c25e5a31f chore(release): 3.78.1 (#5045)
Ships #5044 (SONA balanced-mode recall fix) via @claude-flow/neural 3.1.1.

Co-authored-by: r <r@x>
2026-11-19 11:54:05 -05:00
rUvandr 26fc585b14 fix(neural): return current, exact SONA matches in balanced mode (#5044)
* fix(neural): return live exact SONA matches in balanced mode

* chore(neural): bump to 3.1.1 for balanced-mode recall fix

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

* chore(deps): pin @claude-flow/neural 3.1.1 (published)

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

---------

Co-authored-by: r <r@x>
2026-11-19 11:25:00 -05:00
rUvandr 337c8981e6 chore(release): 3.78.0 (#5043)
Bumps cli, claude-flow and ruflo to 3.78.0. Bumps the bundled mcp (3.1.8)
and security (3.0.8) leaves so their standalone packages pick up #4962 and
#5021, which changed their source after the 3.1.7/3.0.7 publishes.

Co-authored-by: r <r@x>
2026-11-19 02:12:49 -05:00
89a00242b3 integrate: dream-cycle memory/neural fixes (#4660, #4973, #4081, #3650, #4983, #5034, #5012) (#5041)
* dream(memory): #3649 restore quantizer config/codebooks across HNSWIndex serialize/deserialize

HNSWIndex.serialize()/deserialize() never persisted config.quantization or
trained PQ codebooks, so this.quantizer came back null after any
save/reload cycle — silently re-breaking the product-quantization distance
dispatch fixed 2026-08-25 (#3093/#3094) every time AgentDBAdapter.saveToDisk()/
loadFromDisk() round-trips an index. Added a versioned magic header (v1/v2)
so serialize() now writes quantization config + trained codebooks, and
deserialize() restores them, while old-format snapshots still read
correctly with no quantizer (unchanged pre-existing behavior).

Evaluated: pre-serialize recall@10 0.270 -> post-deserialize 0.010 on
baseline (bug reproduced) -> ~0.270 on candidate. 557/558 full suite both
ways (1 pre-existing unrelated failure), tsc clean. Independent adversarial
critic CONFIRMED, including a stronger real pre-fix v1-buffer repro.

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

* docs(dream-cycle): fill candidate commit sha in 2026-10-03 gist witness table

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

* fix(memory): validate importCodebooks() input, reject malformed shape

Addresses ruvnet's review on #3650: deserialize() fed JSON.parse() output
straight into this.codebooks with no validation, so a corrupted v2
snapshot could either throw (invalid JSON) or silently adopt a
wrong-shaped/non-finite codebooks array, poisoning every subsequent
distance computed against it with garbage or NaN.

importCodebooks() now validates shape (numSubquantizers sub-arrays, each
numCentroids centroids of the expected per-subvector length) and that
every value is a finite number, returning false and leaving the quantizer
untrained on any mismatch -- same as the existing pre-training bootstrap
state, not a new failure mode. deserialize() now guards the JSON.parse()
call itself so corrupt JSON degrades to "untrained" instead of throwing.

2 new discriminating tests, both verified to fail against the pre-fix
code via git-stash isolation (one throws on corrupt JSON, one silently
accepted a wrong-shaped array). Full suite 559/560 (1 pre-existing
unrelated failure), tsc --noEmit clean.

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

* docs(dream-cycle): record post-review hardening in 2026-10-03 gist

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

* dream(intelligence): #4080 wire SONA learning-state persistence into LearningBridge (evaluated, ACCEPT)

LearningBridge is the only production path that exercises SONAManager
(via auto-memory-hook.mjs's SessionStart/SessionEnd hooks), and every
short-lived hook invocation constructed a fresh, empty neural learning
state. SONAManager.serialize()/deserialize() already existed but were
never called. Wires that round-trip into LearningBridge.loadNeural()
(restore) and destroy() (persist, synchronous since destroy() is called
unawaited right before process exit), mirroring MoERouter's existing
.swarm/moe-weights.json persistence pattern.

This supersedes the handed-in candidate for tonight (fixing SONAManager's
EWC key-mismatch), which an architecture review proved would be
behaviorally inert: SONAManager.loraWeights.A/B are never updated by
gradient descent anywhere, so aligning EWC's keys would only change
internal telemetry, not real behavior. The persistence gap fixed here is
the actual root cause making SONA's learning trigger (EWC included)
practically unreachable in the first place.

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

* docs(dream-cycle): append 2026-10-12 intelligence ledger row

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

* chore(release): bump neural/memory leaves for #4081's source change

v3/@claude-flow/neural and v3/@claude-flow/memory are non-bundled leaf
packages resolved from the registry, not shipped with the release train
(CLAUDE.md "Publishing Rules") — a source change without a version bump
would ship nobody the fix (ruvnet/ruflo#3335, #3390). Minor-bumps both
(3.0.0->3.1.0, 3.0.4->3.1.0: backward-compatible additions, no breaking
API change) and updates v3/@claude-flow/cli's exact pins + v3/pnpm-lock.yaml
to match.

Root claude-flow's own @claude-flow/neural dependency resolves from the
real npm registry (not a workspace link, confirmed via package-lock.json's
resolved tarball URL) — widened to "^3.0.0" rather than bumped to "3.1.0",
since 3.1.0 isn't published yet and pinning to it would break `npm ci`.
@claude-flow/memory isn't a direct dependency of the root package, so it
needed no equivalent change there.

Verified: audit-leaf-package-publish.mjs, audit-wrapper-dep-ranges.mjs,
audit-plugin-packages.mjs, audit-package-dep-overlap.mjs, and
audit-umbrella-version-lockstep.mjs all pass locally; `npm ci` and
`pnpm install --frozen-lockfile` (in v3/) both succeed cleanly.

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

* fix(cli): widen neural/memory pins to ranges, not an unpublished exact version

The previous commit exact-pinned @claude-flow/cli's neural/memory deps to
3.1.0 to match the leaf version bump — but the CLI package is consumed via
real npm resolution when packed/installed (npx, or a real `npm install` of
the published tarball), not via the pnpm workspace link that made the pin
look fine locally. 3.1.0 isn't published, so smoke-cli-npx-install.mjs's
real `npm install` of the packed CLI tarball failed: `ETARGET No matching
version found for @claude-flow/neural@3.1.0`.

Same fix as the prior commit's root package.json change: widen to "^3.0.0"
rather than bump to the unpublished version. This still satisfies
audit-leaf-package-publish.mjs's range-coverage check (^3.0.0 covers the
workspace's 3.1.0) without requiring a real registry publish, and resolves
correctly to whatever's actually published (3.0.0) when installed for
real. CLAUDE.md documents this exact failure mode happening before
(memory@3.0.0-alpha.27, 2026-09-28) — exact-pinning to vaporware breaks
installs outright.

Verified: ran scripts/smoke-cli-npx-install.mjs locally end-to-end (packs
the real tarball, npm installs it, runs `cli --version`) — passes. All
other audit scripts + both packages' test suites unchanged/green.

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

* fix(cli): restore exact memory pin to satisfy witness-marker guard (#2021/#1825)

The previous commit widened @claude-flow/cli's "@claude-flow/memory" dep
(both dependencies and optionalDependencies) to "^3.0.0" to avoid the same
ETARGET problem neural hit. That broke a different, deliberate guard:
`witness marker drift smoke (#2021)` flags any change to a line previously
witnessed as a historical fix. #1825's fix (PR #1827) specifically pins
this field to an exact "3.x" version after a `workspace:` protocol leak
crashed npm's resolver entirely for ALL users — the marker
`"@claude-flow/memory": "3.` guards against regressing that.

memory doesn't need the same treatment neural got: it's listed in BOTH
`dependencies` and `optionalDependencies` (pre-existing, not introduced
here), and pnpm/npm treat a dependency declared in both as optional
overall — confirmed empirically by running scripts/smoke-cli-npx-install.mjs
locally with memory exact-pinned to the unpublished 3.1.0: npm installs
the tarball cleanly, because an unresolvable optional dependency doesn't
fail the install (unlike neural, which is required and must stay on a
range that resolves to what's actually published).

Restored the exact "3.1.0" pin (matching the new leaf version, satisfying
both the witness marker's "3." substring and
audit-leaf-package-publish.mjs's range-coverage) in both package.json
fields and the pnpm-lock.yaml specifier; left neural's "^3.0.0" from the
prior commit untouched.

Verified: smoke-witness-marker-drift.mjs (0 drifted, was 1),
smoke-cli-npx-install.mjs, audit-leaf-package-publish.mjs,
audit-wrapper-dep-ranges.mjs, audit-plugin-packages.mjs,
audit-package-dep-overlap.mjs, audit-umbrella-version-lockstep.mjs all
pass; pnpm install --frozen-lockfile (v3/) succeeds; both affected
packages' test suites unchanged.

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

* fix(memory,neural): harden SONA state persistence found in #4081 review

- LearningBridge never follows a symlink at statePath (read or write) and never
  writes into a symlinked directory: the file lives in the project directory, so
  it is untrusted input (reproduced: a planted symlink was overwritten).
- Atomic write (private 0600 temp file + rename); no torn files.
- Persist only when something was learned: no stray .swarm/ in every cwd.
- A file from another schema version is preserved, never overwritten.
- A rejected restore is rolled back to the pre-restore snapshot; reads are size-capped.
- SONAManager.deserialize validates the whole snapshot before assigning any field
  (reproduced: {"schemaVersion":1} left the manager half-applied and permanently
  unable to learn or self-heal).
Known limitation, documented: concurrent processes are last-writer-wins
(8 parallel processes kept 4 of 8 trajectories).

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

* dream(intelligence): #LOCAL wire ResearchMode.getConsolidationSnapshot() into SONA EWC++ (evaluated, ACCEPT-scoped)

Continues 2026-10-27 (#4531/#4532) and 2026-11-01 (#4633 SCAN)'s own
disclosed gap: BalancedMode was the only SONA learning mode wired into
SONAManager's EWC++ consolidation path. ResearchMode already maintains
real per-key gradient-shaped state (adamM/adamV, already read back by its
own dormant computeEWCLoss()) so it can be wired honestly using the exact
reviewed Balanced-mode delta-since-snapshot pattern, with zero
sona-manager.ts changes needed (the hook is mode-agnostic).

EdgeMode and RealTimeMode are explicitly NOT wired (no real gradient-shaped
state exists to snapshot without fabricating it); BatchMode is also not
wired (its accumulatedGradients map is zeroed on an independent 4-step
flush cadence, making a direct port semantically ambiguous).

5 new tests (3 discriminating, 2 controls), stash-isolated baseline fails
3/5 exactly as predicted, candidate 5/5 pass. Full @claude-flow/neural
suite 153/153 both ways except the 3 discriminating failures, 0
regressions. tsc --noEmit 0 errors both ways. Independent adversarial
critique: CONFIRMED-WITH-CAVEATS (one test-strength nit, fixed forward
same session).

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

* docs(dream-cycle): fill in witness stamp for 2026-11-02 gist

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

* docs(dream-cycle): append 2026-11-02 ledger row (#4659/#4660)

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

* fix(ci): bump @claude-flow/neural to 3.0.3 for the leaf-package-publish audit

CI's audit-leaf-package-publish.mjs correctly flagged this PR: @claude-flow/
neural is a non-bundled leaf (resolves from the registry, not shipped inside
the release train tarballs), and this PR changed its publishable source
(src/modes/research.ts) without bumping its package.json version — a release
now would ship the old copy and the ResearchMode EWC fix would reach nobody.

Bumps v3/@claude-flow/neural to 3.0.3 and the CLI's exact pin + lockfile
specifier to match (the CLI pins an exact version, not a range, so both must
move together). Verified locally: audit-leaf-package-publish.mjs now passes
clean against the PR base; @claude-flow/neural suite still 153/153, tsc
--noEmit still 0 errors.

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

* fix(ci): bump root claude-flow umbrella's @claude-flow/neural pin to 3.0.3

audit-wrapper-dep-ranges.mjs flagged a second, independent pin: the root
claude-flow umbrella's own dependencies block also pins @claude-flow/neural
exactly, separately from the CLI's pin fixed in 0e5b4a9. Bumped to 3.0.3 to
match the workspace source version. package-lock.json's resolved tarball
entry intentionally stays at the last-published 3.0.2 until neural is
actually published alongside a future release -- that's expected pre-publish
drift, not something this PR fixes, per CLAUDE.md's publishing rules.

Verified locally: audit-wrapper-dep-ranges.mjs, audit-leaf-package-publish.mjs,
and audit-umbrella-version-lockstep.mjs all pass clean.

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

* Revert "fix(ci): bump root claude-flow umbrella's @claude-flow/neural pin to 3.0.3"

This reverts commit 9c060b680e.

* Revert "fix(ci): bump @claude-flow/neural to 3.0.3 for the leaf-package-publish audit"

This reverts commit 0e5b4a9852.

* dream(intelligence): #4972 SONAManager.triggerLearning() backlog-replay fix (post-critique scoped)

triggerLearning() re-filtered the entire trajectories map every call with
no "already learned from" marker, so trajectories surviving pruning got
re-fed into gradient accumulation / EWC Fisher updates on every subsequent
cycle, purely from replay. Disclosed-but-not-fixed 2026-10-27 (#4531/#4532);
fixed here via a new Trajectory.learnedFrom gate.

An independent adversarial critique found the fix is real but narrower
than first claimed: it stops replay of stalled trajectories, but
BalancedMode's gradientAccumulator/ewcState.means are never reset at all,
so the same unbounded growth persists under ordinary continuous operation.
Disclosed in both test docstrings and the gist, carried forward as the
next priority candidate rather than shipped as fully fixed.

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

* dream(intelligence): #4972 record PR #4973 in ledger

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

* dream(intelligence): #4972 bump @claude-flow/neural to 3.0.4

Patch bump for the triggerLearning() backlog-replay fix — neural is a
non-bundled leaf resolved from the registry, so the CLI's pin must be
raised and the leaf republished at actual release time for this fix to
reach users (CLAUDE.md "Publishing Rules"; CI's
audit-leaf-package-publish.mjs caught the unbumped version).

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

* dream(memory): wire causalRecall into ControllerRegistry.initialize()

ControllerRegistry declares `causalRecall` as an AgentDBControllerName
with a real createController() case (dynamic agentdb import, built with
the ADR-514-adapted embedder, same shape as its already-wired siblings
causalGraph/learningSystem/explainableRecall) and includes it in the
isControllerEnabled() "AgentDB-internal controllers" branch. But it was
absent from every level of INIT_LEVELS, so initialize() never called
createController() for it, and the public get() accessor's fallback path
(agentdb[name] / agentdb.getController(name)) never runs this wrapper's
own construction logic either. Net effect: registry.get('causalRecall')
always returned null, silently.

Disclosed-but-deferred by a 2026-10-28 session ("needs a human call on
init-level ordering"). agentdb and its .database/.embedder/.vectorBackend
are already populated before the INIT_LEVELS loop runs, so level
placement doesn't affect correctness; grouped with construction-sibling
causalGraph in level 4.

Two discriminating tests added: a structural assertion that causalRecall
appears in INIT_LEVELS, and an extension of the existing ADR-514
real-agentdb embedder-wiring integration test to cover causalRecall
alongside its siblings. Both fail against the baseline exactly as
predicted (toContain assertion; get() returns null) and pass against the
candidate. Full package suite 717/718 with the fix (1 pre-existing,
unrelated, environmental chmod-as-root failure in
auto-memory-bridge.test.ts, confirmed byte-identical on the stashed
baseline). tsc --noEmit clean both ways.

Zero production call sites currently request causalRecall, so today's
blast radius is zero — this makes a correctly-built, research-aligned
capability (causal-provenance-conditioned memory recall) reachable for
the first time rather than fixing a live breakage.

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

* fixup(memory): correct causalGraph construction claim in causalRecall comments

Independent adversarial critique (Dream Cycle 2026-11-13) found the prior
commit's comments overstated that causalRecall is "same shape as
causalGraph" — causalGraph is actually built via agentdb's own
getController() switch, not the dynamic-import-and-construct pattern
causalRecall shares with learningSystem/explainableRecall. Cosmetic only;
does not change behavior. Re-ran the targeted suite (94/94) and
tsc --noEmit (clean) after this change.

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

* docs(dream-cycle): add 2026-11-13 memory SOTA gist

Gist publishing blocked by the environment's proxy policy ("Gist writes
are not permitted through this proxy", HTTP 403 on api.github.com/gists)
-- a different root cause than prior nights' broken GH_TOKEN, same
FALLBACK-for-remote-gist-publication outcome. Committed locally per
established convention; full report embedded in the issue as well.

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

* docs(dream-cycle): append 2026-11-13 ledger row

Issue #4982, PR #4983 (causalRecall wired into ControllerRegistry.initialize()).

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

* chore(memory): bump @claude-flow/memory to 3.3.3 for the causalRecall fix

CI's audit-leaf-package-publish.mjs (added 2026-11-02, ruvnet/ruflo#3335/
#3390/#3327 Finding A) flags any non-bundled @claude-flow/* leaf whose
publishable source changed without a version bump -- @claude-flow/memory
is resolved from the registry by @claude-flow/cli, not bundled into the
release tarball, so an unbumped source change here would silently never
reach a fresh install. PATCH bump (bug fix, no API/schema change) per
CLAUDE.md's semver policy.

This does not, by itself, turn the check fully green: the CLI's exact pin
(v3/@claude-flow/cli/package.json, still "3.3.2") now fails the sibling
range-coverage check, since 3.3.3 is not yet published and the pin cannot
honestly point at an unpublished version. Same unresolved shape as PR
#4973 (2026-11-12), which hit the identical gap bumping
@claude-flow/neural and left it to a human publish -- full resolution
needs `npm publish @claude-flow/memory@3.3.3` plus a CLI-pin bump in a
follow-up, which is outside this session's authority (see CLAUDE.md
"Publishing to npm").

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

* dream(intelligence): ReasoningBank.distill() discards failed trajectories, losing all pitfall-avoidance memory

ReasoningBank.distill() judged every trajectory but only distilled
successes into the retrievable memory pool; failures were judged then
unconditionally discarded. An accepted ICLR 2026 paper (ReasoningBank,
arXiv 2509.25140) measures that failure-aware distillation beats
success-only memory on web/SWE benchmarks, and Ruflo already has a
disconnected dual-track distiller (reasoningbank-adapter.ts) showing the
team built this pattern once and never wired it in.

- distill() now distills unsuccessful trajectories into a distinct
  memoryType: 'pitfall' memory (strategy framed as "AVOID: ...") instead
  of returning null, for any trajectory with at least one recorded step.
- completeTask()'s call into PatternLearner.extractPattern() is now
  gated on memoryType === 'success', so a pitfall can never be promoted
  into a positive-exemplar Pattern (independently confirmed by adversarial
  critique to be load-bearing: PatternLearner's own qualityThreshold
  (0.5) and ReasoningBank's distillationThreshold (0.6) already diverge,
  so a ~0.55-quality trajectory could reach extractPattern with no prior
  memoryType field to stop it).
- deduplicateMemories() is fixed forward: it would otherwise delete a
  pitfall memory that happens to share a near-identical embedding with a
  higher-quality success memory, treating opposite outcomes as
  duplicates -- a direct consequence of merging both types into one
  pool. Dedup now skips any pair whose memoryType differs.

Evaluated: stash-isolated baseline fails exactly the new/changed tests
(38/42 unaffected pass); candidate 43/43; full package 152/152, 0
regressions; related @claude-flow/memory learning-bridge suite 78/78;
tsc --noEmit clean. Independently reproduced by an adversarial critic
(verdict: CONFIRMED-WITH-CAVEATS -> forward-fixed -> re-verified).

Human review required. Do not self-merge.

* dream(intelligence): #5011 publish research gist (local, no gh gist access)

docs/dream-cycle/dream-gist-2026-11-17.md -- full SOTA report, competitor
comparison, hypothesis, evaluation receipt, and witness for issue #5011.

* dream(intelligence): #5011 append ledger row (PR #5012)

* dream(intelligence): #5011 bump @claude-flow/neural to 3.0.4 (CI: leaf-package-publish)

The "Plugin package install-safety" CI gate (audit-leaf-package-publish.mjs)
correctly flagged that this PR changes @claude-flow/neural's publishable
source (index.ts, reasoning-bank.ts, types.ts) without a version bump --
it's a non-bundled leaf per CLAUDE.md's Publishing Rules, so an unbumped
version means the fix would ship to nobody at release time. Bump to 3.0.4
(patch: bug fix, no breaking API removal) and keep @claude-flow/cli's
exact pin in lockstep to avoid introducing new cli-pin/workspace drift.

* dream(intelligence): #5011 sync v3/pnpm-lock.yaml for @claude-flow/neural@3.0.4

CI's "Smoke (no better-sqlite3)" and "Static regression guards" jobs both
failed with ERR_PNPM_OUTDATED_LOCKFILE after the prior commit bumped
@claude-flow/cli's @claude-flow/neural specifier without regenerating the
lockfile in the same commit. @claude-flow/neural resolves via
link:../neural regardless of specifier value (it's a local workspace
link, not a registry/integrity entry), so this is a minimal, surgical
specifier-only edit rather than a full `pnpm install --lockfile-only`
regen -- the latter pulled in unrelated pre-existing drift (@claude-flow/codex
and @claude-flow/memory switching to workspace links, a ruvector bump)
that has nothing to do with this PR. Verified locally with pnpm@8.15.0
(matching CI's pinned version, not this environment's default pnpm@10.28,
which produces a differently-shaped lockfile): `pnpm install
--frozen-lockfile --lockfile-only` now passes clean.

* dream(intelligence): #5011 bump root package.json's @claude-flow/neural range too

audit-wrapper-dep-ranges.mjs caught a third pin location I'd missed:
the root `claude-flow` umbrella package.json declares its own
"@claude-flow/neural": "3.0.3" dependency range, separate from
@claude-flow/cli's pin. Bumped to 3.0.4 to match. Did NOT touch
package-lock.json: its @claude-flow/neural entry carries a real
resolved/integrity hash from the npm registry for 3.0.3, and
@claude-flow/neural@3.0.4 is not yet published there -- regenerating it
would require either a real `npm install` (which fails ETARGET, same as
the CLI npx-install smoke failure already reported on this PR) or
fabricating a resolved URL/integrity for a tarball that doesn't exist,
which would be unsafe. Any CI job that runs `npm ci` at the repo root
will stay red for the same reason already documented on this PR: this
needs an actual npm publish of @claude-flow/neural@3.0.4, which is a
separate, human-authorized release action outside this session's scope.

* Revert "dream(intelligence): #5011 bump root package.json's @claude-flow/neural range too"

This reverts commit 96f0a32e56.

* dream(memory): #5033 CacheManager frequency-aware eviction (HTM-EAR-grounded)

Adds an opt-in, Darwin-tuned frequencyWeight/evictionScanWindow blend to
CacheManager's eviction policy. Default (unset/0) is byte-identical to the
existing pure-LRU tail eviction via an early return - zero behavior change
for every current caller (AgentDBAdapter, TieredCacheManager,
ControllerRegistry's tieredCache).

Motivated by HTM-EAR (arXiv:2603.10032, Feb 2026), which shows pure-LRU
eviction permanently drops high-access-frequency entries under skewed
access even though CachedEntry.accessCount already tracks exactly the
signal needed.

Evaluation: baseline 718/719 (1 pre-existing environmental failure) ->
candidate 722/723, tsc clean both ways, stash-isolated discriminating
tests fail on baseline exactly as predicted. Independently reproduced by a
fresh-context adversarial critic (verdict: CONFIRMED). Bounded 3-gen x
4-candidate Darwin sweep over a new synthetic skewed-workload benchmark
finds an interior optimum (frequencyWeight=0.85) that beats both the
baseline and a naive frequencyWeight=1.0 - full lineage persisted.

Full receipt in docs/dream-cycle/dream-gist-2026-11-18.md and issue #5033.

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

* dream(memory): #5033 witness finalization

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

* dream(memory): #5033 ledger update

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

* dream(memory): #5033 bump @claude-flow/memory 3.3.3 -> 3.4.0 + CLI pin

audit-leaf-package-publish flagged that this PR changes publishable
source in @claude-flow/memory (a non-bundled leaf that resolves from the
registry, not the release tarball) without a version bump - per
CLAUDE.md's Publishing Rules, that would ship nobody the fix.

Minor bump (backward-compatible: two new optional CacheConfig fields,
default-off). CLI's exact pin raised to match, mirroring PR #5021's
documented precedent for @claude-flow/cli-core: the leaf needs an actual
npm publish before a real release, which is a separately-authorized
human action out of scope for this PR. v3/pnpm-lock.yaml is deliberately
left unchanged (still resolving 3.3.3) until that publish happens - its
integrity entries can't be computed for an unpublished tarball, same
reasoning as #5021's "fill in the integrity after the publish".

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

* dream(memory): #5033 sync pnpm-lock.yaml specifier for the memory bump

pnpm install --frozen-lockfile was failing (ERR_PNPM_OUTDATED_LOCKFILE)
across ~14 CI jobs (Smoke, Type Check V3, Test V3 Packages, Plugin hooks
smoke, Windows hooks smoke, MCP paired-tool smoke, guard, etc.) because
v3/pnpm-lock.yaml still specified @claude-flow/memory@3.3.3 for the cli
importer after 7423f32 bumped package.json to 3.4.0.

Minimal hand-edit (2 lines), not a full `pnpm install --no-frozen-lockfile`
regeneration - that pulls in unrelated registry drift (ruvector/router
version bumps, dropped platform-optional entries) with no connection to
this change, which PR #5021 explicitly avoided for the same reason
("lockfiles are hand-edited to the minimum"). The cli importer's entry now
resolves via workspace link (`link:../memory`), matching how every other
importer in this lockfile already references @claude-flow/memory. Verified
locally: `pnpm install --frozen-lockfile` passes.

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

* fix(neural): keep distill()'s success-path threshold from #5012

#5012 dropped the distillationThreshold check for every trajectory. judge()
already applies it to success verdicts, but a verdict set without judge()
would now distill below threshold. Restore the check for successes only;
pitfalls are unaffected.

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

* chore(release): bump @claude-flow/neural 3.1.0 and @claude-flow/memory 3.4.0

One bump per touched leaf for the integrated dream-cycle fixes (both add
public surface: NeuralLearningSystem.serialize/deserialize,
DistilledMemory.memoryType, Trajectory.learnedFrom; LearningBridge statePath,
CacheConfig.frequencyWeight/evictionScanWindow). CLI and root umbrella pins
follow. pnpm-lock edited by hand (specifiers only, plus memory now linking
to the workspace since 3.4.0 is not yet on npm). The root package-lock.json
still records neural 3.0.3 and needs a refresh after the leaves publish
(same as 68c8d74b23 -> 3ce46cfa57).

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

* fix(neural): treat memories without memoryType as successes when deduplicating

ReasoningBank snapshots saved before #5012 have no memoryType, so the new
success/pitfall dedup guard never matched them against fresh success
memories. They only ever held successes; default the field accordingly.

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

* chore(deps): root lockfile resolves published @claude-flow/neural 3.1.0

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: r <r@x>
2026-11-19 01:44:33 -05:00
5cdb56feb7 fix: sign companion helpers, guard every .claude-flow write (#4746, integrates #4991) (#5039)
* fix: sign companion helpers and refuse symlinked .claude-flow writes (#4746)

* fix: sign companion helpers and refuse symlinked .claude-flow writes (#4746)

* fix: sign companion helpers and refuse symlinked .claude-flow writes (#4746)

* fix: sign companion helpers and refuse symlinked .claude-flow writes (#4746)

* fix: sign companion helpers and refuse symlinked .claude-flow writes (#4746)

* fix: sign companion helpers and refuse symlinked .claude-flow writes (#4746)

* fix: sign companion helpers and refuse symlinked .claude-flow writes (#4746)

* fix(ruflo-mods): route every .claude-flow write through the link guard (#4746)

The PR guarded only the session heartbeat and the compaction snapshot. Edit
records, the learning-loop ledger, guidance observations, context-delegation
metrics, cost attribution and the console toast ring still wrote through
$.fs.write, which follows links. All of them now go through one helper,
projectWrite (state.ts), over writeWithoutLinks: a symlinked .claude-flow or
any symlinked folder below it refuses the write. Appends are read-then-
rewrite, so they are covered by the same path.

The cost hook's project check no longer counts a symlinked .claude-flow as
the project's state (the live engine reports the target's kind plus isLink).

The mods harness gains liveLinkStat (stat as the live engine answers it), and
mods-every-write-guarded-4746.test.ts drives every writing hook entry point:
a control run proves each path writes into a real .claude-flow, and runs with
a symlinked .claude-flow and with symlinked data/cost/metrics/sessions folders
must leave the outside directory byte-identical. Without this change those two
runs fail with six files written outside the project.

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

* fix(cli): init --upgrade installs the signed companion bytes (#4746)

session.cjs and memory.cjs joined the signed critical set in this PR, but
executeUpgrade still regenerated both from the CLI's generators, whose output
is not byte-identical to the packaged copies. The next run's integrity check
then reported both as tampered: once (healed) on a normal install, on every
run under .LOCKED, RUFLO_HELPERS_LOCKED or an ahead stamp, where the refresh
only inspects.

ensureCommonJsCompanions takes an optional sourceDir. The upgrade passes the
package's own .claude/helpers (findPackageHelpersDir, the source the startup
refresh verifies against): a companion present there as a regular file is
copied byte-for-byte through the existing link-safe atomic write; only a
missing one (or one shipped as a link) comes from the generators. The startup
ensure for missing companions is unchanged.

upgrade-companion-integrity-4746.test.ts upgrades a project and runs the
startup integrity check against a throwaway-key manifest over the package's
companion bytes; without this change it reports
['session.cjs', 'memory.cjs'] as tampered.

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

* chore(ruflo-mods): 0.17.3 — every .claude-flow write is link-guarded (#4746)

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

* test(ruflo-mods): cover the toast writer session.start binds (#4746)

With engine.create, the $.ruflo noun's toast writer is the one in use, so the
binder in session.start was guarded but never exercised. A run without
engine.create drives it; reverting session.ts alone now fails that case
(console/toasts/mods.jsonl written outside the project). Reverting any other
call-site file alone fails the existing cases.

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

* chore(helpers): re-sign manifest with session.cjs and memory.cjs (#4746)

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

---------

Co-authored-by: Aditya Chandrajit Deore <adityadeoreofficial@gmail.com>
Co-authored-by: r <r@x>
2026-11-19 01:21:48 -05:00
cec89383d7 test(mcp): cover 12 untested MCP tools (#4767, integrates #4840) (#5040)
* test(mcp): cover 12 untested MCP tools

Adds success and argument-validation tests for the tools listed in
ruvnet/ruflo#4767. swarm_exists is not a registered tool; it is a check
name inside swarm_health and is covered through that tool. progress_sync
runs in its own file because it writes to the repo root.

Refs ruvnet/ruflo#4767

* test(mcp): mock @claude-flow/aidefence in the aidefence_stats case (#4767)

Unmocked, the tool's loader falls back to a real npm install when the
package does not resolve (the repo-root CI install), which failed the
ratchet with STACK_TRACE_ERROR and would mutate the checkout.

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

---------

Co-authored-by: Sachin Sharma <sachinsharma3191@gmail.com>
Co-authored-by: r <r@x>
2026-11-19 01:06:43 -05:00
rUvandClaude e5d024059d dream(security): #3834 wire settings.json risk scanner into hooks session-restore (evaluated, ACCEPT-scoped) (#3835)
* dream(security): #3834 wire settings.json risk scanner into hooks session-restore (scoped)

The advisory .claude/settings.json risk scanner (settings-risk-scanner.ts,
2026-08-16) was wired into `ruflo init`/`--upgrade` only -- the sole call
sites of scanSettingsForRisk()/formatRiskFindingsAsWarnings() in the whole
package. hooksSessionRestore's handler now also runs the same, unmodified
scan, folding findings into its existing `warnings` field, for an explicit
`ruflo hooks session-restore` call or an MCP client calling
`hooks_session-restore`.

Scoped post-critique: an independent adversarial critic found the original
claim ("closes the gap for any later session") overstated reach -- the
automatic SessionStart hook Claude Code fires for every real session runs a
separate generated/signed helper template (hook-handler.cjs -> session.cjs)
this scan isn't wired into. Extending there is a larger, separate-night
change; disclosed as a follow-up rather than silently dropped. Also hardened
per the critic's minor finding: the try/catch around the scan now only
swallows JSON.parse SyntaxErrors, so a real bug in the scanner itself would
surface instead of being silently absorbed.

6 new discriminating tests, baseline-fails/candidate-passes via stash
isolation (3/6 fail on baseline exactly as predicted, 6/6 pass on
candidate). Full @claude-flow/cli suite byte-identical FAIL-line diff
(full untruncated logs) baseline vs candidate outside those 3 tests;
tsc --noEmit byte-identical (9 pre-existing errors, none in changed files).

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

* dream(security): #3834 update ledger for 2026-10-06 + backfill 09-22..10-05 note

Appends tonight's row and a backfill note for 09-22 through 10-05 (ledger
rows only reach main via PR merge, so these were never individually
transcribed live). Confirms the 09-26 batch merge and the 09-23/09-25/09-26/
10-04 no-run gaps via git ls-remote + pull_request_read, not inferred.

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

* dream(security): #3834 guard non-object parsed settings.json (review fix)

A .claude/settings.json whose content is valid JSON but not an object --
literally `null`, or a top-level array -- made hooksSessionRestore's new
scan crash: `settings.hooks` on `null` throws a TypeError, which the
existing catch correctly re-throws (it's not a JSON.parse SyntaxError),
so hooks_session-restore failed outright instead of staying advisory-only.

Found by ruvnet's backlog-sweep review. Guard: only run the scan when the
parsed value is a non-null, non-array object; otherwise treat it the same
as "not this scan's concern," matching the existing malformed-JSON
behavior. Added discriminating tests for both `null` and `[]`.

Reproduced the exact reported crash via stash isolation before fixing:
baseline throws "Cannot read properties of null (reading 'hooks')" on the
new null-content test; candidate: 8/8 pass.

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

* fix(cli): never let the advisory settings scan abort hooks_session-restore

A non-SyntaxError from the scanner was rethrown, failing the whole
restore; #4053 hit the same issue on the SessionStart path. Also points
the scope comment at #4053 instead of calling it future work.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-19 00:48:06 -05:00
rUvandClaude 28c9d36992 dream(swarm): setMaxListeners(0) on ByzantineConsensus/GossipConsensus (evaluated, ACCEPT) #4988 (#4989)
* dream(swarm): setMaxListeners(0) on ByzantineConsensus/GossipConsensus

RaftConsensus already guards against Node's default EventEmitter
10-listener cap with setMaxListeners(0), because awaitConsensus() adds
one 'consensus.achieved' listener per in-flight proposal. Byzantine and
Gossip got the identical per-proposal listener pattern when their
awaitConsensus() was converted from busy-polling to event-driven
(#4458/#4498), but never got the guard copied over. Confirmed live via
direct reproduction (both classes threw a real MaxListenersExceededWarning
under >10 concurrent proposals); fixed by mirroring Raft's existing,
already-reviewed pattern exactly.

Baseline (fix stashed): 2 new discriminating tests fail with the real
captured warning. Candidate: 6/6 pass, full @claude-flow/swarm suite
382/382, tsc clean. Independently reproduced by an adversarial critic
with no authoring context, including a 50-concurrent-proposal stress
test and a 3x flakiness check.

Evaluated, ACCEPT. Human review required; no self-merge.

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

* docs(dream-cycle): fill in witness stamp for 2026-11-14 gist

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

* docs(dream-cycle): backfill 11-12/11-13 rows, append 2026-11-14 ledger row

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-19 00:48:02 -05:00
rUvandClaude db712a64eb dream(intelligence): fix guidance_brain's dead coveragePercent/classifiedToolCount (evaluated, ACCEPT) #5003 (#5004)
* dream(intelligence): fix guidance_brain's dead coveragePercent/classifiedToolCount metrics

buildCapabilityBrain() (v3/@claude-flow/cli/src/mcp-tools/capability-brain.ts)
hardcoded coveragePercent to 100 and classifiedToolCount to the raw unique-tool
count, regardless of how many tools fell back to the generic runtime-services
domain -- a declared-but-dead metric reachable through the live guidance_brain
MCP tool that CLAUDE.md instructs agents to call before complex work, and a
direct violation of ADR-329's own coverage-gate invariant.

classifiedToolCount now subtracts the number of distinct fallback-classified
tool names, and coveragePercent is computed from it instead of being a
constant. An independent adversarial critique found and this session fixed
forward a related edge case: a duplicate tool name that also falls back to
runtime-services could drive the count negative; fixed by deduping via a Set
before subtracting.

3 new discriminating/control tests added to guidance-brain.test.ts. Stash-isolated
baseline fails the predicted test; candidate is 11/11, tui-command.test.ts
(the other real consumer-adjacent suite) is 13/13 (+3 pre-existing skips), 0
regressions. tsc --noEmit: 0 errors in either changed file.

Research: tonight's DEEP=intelligence slot surfaced a stronger-evidenced EWC
gradient-accumulator-decay candidate, but an independent architecture review
disqualified it from tonight's production_value score (its output is
currently discarded by learn(), never reaching a real weight update) -- this
SCAN=capabilities finding scored higher and is a disclosed SCAN-override,
same precedent as 2026-10-29/2026-11-10. Full research and evaluation receipt
in docs/dream-cycle/dream-gist-2026-11-16.md.

Also backfills three missing ledger rows (2026-11-12/13/14) that each pushed
a real, evaluated, witnessed draft PR but never appended their ledger row --
a genuine STEP 25 gap found during tonight's STEP 1 ledger check.

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

* dream(intelligence): finalize witness block and append ledger row for #5003/#5004

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-19 00:47:57 -05:00
65fc26d0fa fix(learning-loop): show lessons only from a file this machine wrote (#4747, integrates #4854) (#5037)
* fix(learning-loop): show lessons only from a file this machine wrote

A repository could commit .claude-flow/data/learned-lessons.json, and both
the ruflo-mods prompt hook and the classic learning-loop.cjs helper showed
its lessons as this project's own test and build history.

The CLI ingest now stamps the lessons file with an origin id kept under the
home directory (~/.claude-flow/learning-loop-origin, 32 hex characters,
created on first use with mode 0600). Both readers show nothing from a file
whose origin is missing or does not match this machine's id, so a file
carried in by a clone is ignored. A lessons file written before this change
shows nothing until the next ingest rewrites it.

ruflo-mods 0.16.3. The helper bundle is rebuilt, so helpers.manifest.json
needs a maintainer re-sign.

Fixes #4747

* chore(helpers): re-sign manifest for the #4747 learning-loop.cjs change

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

---------

Co-authored-by: Parman Mohammadalizadeh <prmma23@gmail.com>
Co-authored-by: r <r@x>
2026-11-18 23:51:56 -05:00
e7299de48c fix(security): daily scan 2026-11-18 — 2 fixes (#5032)
* fix(security): vulnerable zod pin in claude-flow umbrella

The zod 4 migration (#5021) describes bumping the root claude-flow
package from zod 3.25.76 to 4.6.7, but the root package.json and
package-lock.json still pin 3.25.76, which is affected by
GHSA-mrhx-c7xc-m3w5 (memory exhaustion while validating oversized
constrained collections, high). The umbrella ships the cli and shared
dist, which resolve zod from the umbrella's own dependency, so this pin
is what claude-flow users get, and it also leaves the migrated zod 4
code running against zod 3.

Pin zod 4.6.7 (matching every @claude-flow/* leaf) and update the
lockfile. npm deduped the nested zod 4 copies onto the hoisted one and
synced the stale @claude-flow/shared workspace version (3.0.8 -> 3.0.9)
in the lockfile. Remaining zod 3 copies come only from agentic-flow and
the published plugin-gastown-bridge.

Test: tests/root-zod-advisory-pin.test.mjs fails on main, passes here.

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

* fix(security): missing auth on /ws in shared MCP HTTP transport

@claude-flow/shared ships its own HttpTransport (exported via MCPServer
and createTransport). #4962 hardened the @claude-flow/mcp copy, but the
shared copy still accepted every /ws upgrade when token auth was
enabled, and nothing after the upgrade checked a token. Token auth is
the setting that lets the transport bind beyond loopback, so that
configuration exposed every registered MCP tool over /ws without
credentials. The HTTP check also accepted any bearer token when the
token list was empty or unset, and compared tokens in non-constant time.

- verifyClient authenticates the upgrade when auth is enabled
  (Authorization: Bearer, or ?token= for browsers, parsed against a
  fixed base URL; never throws).
- Token matching fails closed on an empty list, skips unset entries,
  and compares SHA-256 digests with timingSafeEqual, no early exit.

Test: shared/__tests__/mcp/http-transport-ws-upgrade-auth.test.ts
(2 of 4 cases fail on main, all pass here).

shared is a non-bundled leaf: it needs a standalone publish to reach
direct consumers.

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

* fix(security): keep legacy v3/mcp tools compiling on zod 4

Follow-up to the root zod 4.6.7 pin: zod 4 removed the single-argument
z.record(value) form, so the 17 call sites in v3/mcp/tools added type
errors to the root tsc build. Use z.record(z.string(), z.unknown()),
the same rewrite #5021 applied to the @claude-flow packages. The root
build error set is now identical to origin/main.

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

* chore(shared): 3.0.10 for the /ws auth fix; CLI pins it

The shared transport fix is publishable source in a non-bundled leaf, so
the leaf-package-publish gate requires a version bump. Bump shared to
3.0.10 and the CLI's exact pin (pnpm lock specifier only; it stays a
workspace link).

Not done here, because it needs the published tarball: the root
claude-flow pin and package-lock.json entry stay at 3.0.9 until
@claude-flow/shared@3.0.10 is on npm (the lockfile needs its integrity
hash). Until then audit-leaf-versions-published and
audit-wrapper-dep-ranges report the unpublished pin, as designed.

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

* fix(security): claude-flow umbrella pins @claude-flow/shared 3.0.10

shared 3.0.10 (the /ws auth fix) is now published; the umbrella's exact
range must include it or audit-wrapper-dep-ranges fails and npx installs
resolve two shared copies.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: r <r@x>
2026-11-18 23:51:47 -05:00
edf7ddb3fe fix(security): transport and WebSocket limits (#4752) (#4962)
* fix(security): enforce transport and WebSocket limits (#4752)

- x-gateway ws-proxy: release a connection slot once per connection;
  close/error on both sockets decremented `active` up to four times,
  which defeated the 500-connection cap.
- mcp http transport: /ws now has maxPayload (maxMessageSize, default
  10 MiB) and checks the bearer token in verifyClient, before the
  upgrade, using the same Authorization header as the HTTP routes
  (no ?token=). Unset token entries are skipped instead of throwing.
- mcp http transport: cap legacy SSE streams on GET /mcp
  (maxSseClients, default 100); extra streams get 503 + Retry-After.
- agent-federation fallback WebSocket listener: maxPayload (default
  4 MiB, configurable) instead of the ws 100 MiB default.
- agentbbs sync: redirect "error", reject an oversized Content-Length
  up front, and stream the body with a running byte cap instead of
  buffering it whole.

Each limit has a test.

* fix(mcp): keep ?token= on /ws, checked before the upgrade (#4752)

Browsers cannot set Authorization on a WebSocket, so dropping ?token=
would cut browser clients off /ws and make the HTTP transport behave
differently from the standalone WebSocket transport. verifyClient now
takes the token from the Authorization header or, failing that, from
?token=, still before the upgrade and still failing closed on an empty
token list. ADR-479 describes the new check.

Also:
- maxMessageSize and maxSseClients fall back to their defaults unless
  they are positive numbers.
- shared/src/mcp/transport/http.ts: /ws gets maxPayload (maxMessageSize,
  default 10 MiB) instead of the ws 100 MiB default.

* chore(ruflo-x-gateway): bump to 0.10.5 for the ws-proxy slot fix

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

* chore(leaves): shared 3.0.9 for the /ws payload cap (#4752)

The /ws maxPayload change in shared/src/mcp/transport/http.ts only reaches
users through a standalone shared publish. shared 3.0.9 is published; the CLI
and root manifests pin it and both lockfiles follow.

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

* test(ci): list the x-gateway ws-proxy node:test file with its siblings

Root vitest cannot run plugins/ruflo-x-gateway node:test files (they run via
the plugin's npm test), so each one is listed in ci-test-baseline.txt. The new
ws-proxy test was missing, which failed the ratchet with 'No test suite found'.

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

---------

Co-authored-by: Rutvij97 <218486544+Rutvij97@users.noreply.github.com>
Co-authored-by: rUv <ruv@ruv.net>
Co-authored-by: r <r@x>
2026-11-17 23:15:27 -05:00
9456ae1eb5 integrate: zod 4 migration (#4535) (#5021)
* fix(deps): migrate @claude-flow packages from zod 3 to zod 4

zod 3.25.76 is affected by GHSA-mrhx-c7xc-m3w5 (memory exhaustion while
validating oversized constrained collections, High). The fix exists only
in zod 4.6.6+, so downstream lockfiles cannot clear it while
@claude-flow/{cli,security,shared,hooks,claims} require zod ^3.

Forcing zod 4 onto the current releases breaks them at runtime, which is
what this migration fixes:

- security/input-validator: z.string().ip() was removed. It threw at module
  load, so importing @claude-flow/memory failed and the AgentDB bridge
  silently degraded (memory_store returned "Database not initialized").
  Use z.ipv4() and z.union([z.ipv4(), z.ipv6()]).
- security/input-validator: the global error map used the zod 3 signature
  and returned ctx.defaultError. zod 4 calls the map without ctx, so every
  unmapped issue raised a TypeError instead of a ZodError, process-wide.
  Port it to z.config({ customError }) and map invalid_format by format.
- shared/config/validator: ZodError.errors was removed; use .issues.
  Invalid configs threw a TypeError instead of returning errors.
- z.record(valueSchema) -> z.record(z.string(), valueSchema), and the
  removed ZodTypeDef / SafeParseReturnType types.
- Root claude-flow package: zod 3.25.76 -> 4.6.7 (root CI resolves zod
  from here). fastmcp's nested zod 4.3.5 now dedupes onto 4.6.7.

New tests fail on main with zod 4 installed and pass after:
security/__tests__/zod4-compat.test.ts, shared/__tests__/zod4-config-validator.test.ts.

Still on zod 3 after this change: agentic-flow (separate repo, ^3.25.76)
and the published @claude-flow/plugin-gastown-bridge 0.1.4.

Claude-Session: https://claude.ai/code/session_0157fpfsb1SsSv3XAL3oxF1E

* fix(zod4): keep custom agent types, foreign ZodErrors and UUID parity

Follow-ups from an adversarial review of the zod 4 migration:

- cli-core validateAgentSpawn swallowed only `invalid_enum_value`. zod 4
  reports an out-of-enum value as `invalid_value`, so wherever
  @claude-flow/security resolves (any hoisted install) every custom agent
  type would be rejected. Extract isUnknownAgentTypeIssue(), accept both
  codes, and only for the `type` path. The existing "custom type" test used
  memory-specialist, which is in the enum, so it never reached this branch;
  the new test drives the rule with real SpawnAgentSchema issues.
- shared ConfigValidator: recognise a ZodError from another zod copy by
  shape (callers may pass zod 3 schemas), and stringify path segments so a
  symbol key cannot make path.join() throw.
- security UUIDSchema: zod 4's uuid() is strict RFC 9562 and rejected ids
  zod 3 accepted (e.g. 00000000-0000-0000-0000-000000000001). Use z.guid(),
  which keeps zod 3's 8-4-4-4-12 hex check.

Each new assertion fails when its fix is reverted.

Claude-Session: https://claude.ai/code/session_0157fpfsb1SsSv3XAL3oxF1E

* fix(zod4): report a missing agent type; reject impostor ZodErrors

Second adversarial round on the zod 4 migration:

- zod 4 raises `invalid_value` at ['type'] for a missing, null or
  non-string agent type, where zod 3 raised `invalid_type`. The previous
  fix suppressed every `invalid_value` at that path, so
  validateAgentSpawn({}) passed. Suppress only when the submitted type is
  a string and the issue path is exactly ['type'] (zod 3 parity).
- isZodErrorLike now requires a non-empty issues array of {path, message,
  code} objects, so an operational Error that happens to be named
  ZodError still propagates.

Each new assertion fails when its guard is removed.

Claude-Session: https://claude.ai/code/session_0157fpfsb1SsSv3XAL3oxF1E

* fix(plugins): build and run the v3 plugins under zod 3 and zod 4

The install-safety job builds v3/plugins against the repo-root zod, which this
branch moves to 4. Six plugins failed to typecheck, and two also broke at runtime:

- z.record(v) -> z.record(z.string(), v). zod 4 needs the key schema; the
  one-argument form also fails at parse time, not only in tsc.
- z.ZodTypeDef is gone in zod 4. ZodType<TInput, any, any> is valid under both
  majors (zod 3 reads <Output, Def, Input>, zod 4 <Output, Input, Internals>).
- prime-radiant: zod 4 returns a .default() value without parsing it, so
  .default({}) dropped every nested config default. Default to Schema.parse({}).
- gastown-bridge: ZodError.errors no longer exists (use .issues, present in
  both), and zodToJsonSchema called _def.shape(), which is an object in zod 4.
  It threw inside a try and returned an empty schema for every MCP tool.

The plugins keep their declared zod ranges and lockfiles; the code now
typechecks and passes under zod 3.25.76 and zod 4.6.7. New tests fail
against the previous source.

Claude-Session: https://claude.ai/code/session_0157fpfsb1SsSv3XAL3oxF1E

* chore(leaves): bump cli-core to 3.7.6 and shared to 3.0.7 for the zod 4 change

Both are non-bundled leaves, so the zod 4 source changes reach nobody until
they are published (audit-leaf-package-publish). Bumped the CLI's pins and the
pnpm-lock specifiers to match, as in b0bd254ec. The root claude-flow pins stay
on the published 3.7.5 / 3.0.6 until these two are published, because pinning
an unpublished version breaks `npm install` at the root.

Claude-Session: https://claude.ai/code/session_0157fpfsb1SsSv3XAL3oxF1E

* chore(root): pin claude-flow to cli-core 3.7.6 and shared 3.0.7

audit-wrapper-dep-ranges requires the umbrella's pins to include the
workspace versions bumped in the previous commit. Requested by the
maintainer on #4535.

Until both versions are on npm, root `npm ci` fails with ETARGET and
package-lock.json cannot be regenerated, so it is left unchanged here.
After the standalone publish, run `npm install --package-lock-only` at
the root and commit the lockfile.

Claude-Session: https://claude.ai/code/session_0157fpfsb1SsSv3XAL3oxF1E

* chore(leaves): cli-core 3.7.8 for the zod 4 agent-type fix; cli on zod ^4.6.7

validate-input.ts changed (isUnknownAgentTypeIssue), and cli-core is a
non-bundled leaf of @claude-flow/cli, so it needs its own version and a
standalone publish before this merges:

- @claude-flow/cli-core 3.7.7 -> 3.7.8; cli and claude-flow pins follow.
- @claude-flow/cli zod ^3.22.0 -> ^4.6.7.

Lockfiles are hand-edited to the minimum: v3/pnpm-lock.yaml moves only the
cli importer's cli-core/zod specifiers and the zod peer suffix of the
memory/agentdb/ruvector entries it already resolves to; package-lock.json
moves only the cli-core entry. Its integrity is left blank until 3.7.8 is
on the registry (npm fills it on the next install).

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

---------

Co-authored-by: Dragan Spiridonov <spiridonovdragan@gmail.com>
Co-authored-by: r <r@x>
2026-11-17 22:49:51 -05:00
cc3c43d90d fix(memory): keep database locks owned during long writes (#4822)
* fix(memory): keep database locks owned during long writes

* fix(memory): recover stale database lock artifacts

* fix(memory): fall back to exclusive locks on EXDEV

* fix(memory): five-minute lease overrides a live-looking PID (#4738)

Review items 1 and 2 on #4822:
- A lock or guard not renewed for five minutes is taken over even when its
  PID answers, covering PID reuse and pre-reboot locks on hosts without a
  boot id. Inside the lease only a provably dead owner is taken over.
- removeExpiredMemoryDbLockFile no longer waits out the lease for a guard or
  candidate whose owner is provably dead.
Tests: PID-reuse recovery for the lock and the guard, early removal of a dead
reclaimer's guard; the live-owner tests now run inside the lease.

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

---------

Co-authored-by: rUv <ruv@ruv.net>
Co-authored-by: r <r@x>
2026-11-17 22:42:26 -05:00
rUvandr b9398c7306 chore(release): 3.77.2 (#5026)
Co-authored-by: r <r@x>
2026-11-17 16:48:58 -05:00
9e98e96fa7 fix(security): managed-agent tools refuse sessions this project did not create (#4831)
* fix(security): managed-agent tools refuse sessions this project did not create

managed_agent_prompt, status, events and terminate accepted any session id
in the Anthropic organisation, so a prompt-injected caller could read,
steer or delete sessions it never created. managed_agent_create now records
each session and its environment in .claude-flow/managed-workflows/sessions.json,
and the four tools refuse any session that is neither in that ledger nor in
RUFLO_MANAGED_CONTROL_SESSIONS, before any provider request. Terminate also
deletes only the environment recorded for the session, and forgets the
session once it is deleted.

Fixes #4751

* fix(managed-agent): keep the session ledger outside the workspace and check environments with the provider

The ledger moves to ~/.claude-flow/managed/<sha256(realpath(cwd))>.json (the
dispatch queue's state directory, RUFLO_AI_BUDGET_DIR honoured), so an agent
that can write project files cannot grant itself another session. Terminate
now asks the provider which environment a session runs in before deleting
one, and refuses when the ledger disagrees.

The ledger lock records its owner and is broken once older than 5 s, a
corrupt ledger is set aside as .corrupt-<ts> on write, and create warns when
the 1000-entry cap drops a session. The ruflo-agent managed-agent skill no
longer says to terminate stale sessions from list (ruflo-agent 0.4.3).

Tests cover a forged-ledger environment delete, a workspace ledger, a stale
and a live lock, a corrupt ledger, the cap, and eight processes creating at
once.

Refs #4751

* ci(env-audit): register RUFLO_MANAGED_CONTROL_SESSIONS as a host-only escape hatch

The managed-agent allowlist is a trust boundary (#4751): a caller must not be
able to widen it, so there is deliberately no CLI flag to take precedence.

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

---------

Co-authored-by: r <r@x>
Co-authored-by: RuFlo <ruv@ruv.net>
2026-11-17 15:43:26 -05:00
289581e9c1 integrate: pre-bash guard reads $(...) and parameter defaults (#4848) (#5024)
* fix(hooks): read $(...) substitutions and parameter defaults in the root-delete guard

hasRootDelete parsed backtick substitutions but not $(...): the $ joined
the word and ( reset the rm being parsed, so rm -rf "$(echo)"/ and
rm $(:) -rf / passed while their backtick spellings were refused. A $(...)
body is now matched past quotes and nesting, scanned as its own command,
and dropped from the word, as a backtick one is. $((...)) is arithmetic:
its body is still scanned and a digit stands in for it. Once a $( never
closes, the rest of that scan reads ( and ) as separators, as before.

A parameter's default (X:-word, X-word, X:=word, X=word in dollar braces)
is now judged as the word the shell uses when the name is unset, so
rm -rf ${X:-/} is refused. Single quotes keep it literal.

Same change in both hook-handler.cjs copies, the generated fallback and
the ruflo-mods guard (0.16.3), with parity cases in mods-guard.test.ts.
The packaged helper is signed, so helpers.manifest.json needs a re-sign.

Fixes #4742

* fix(hooks): fail closed on an unclosed $( and read array/indirect defaults (ruflo-mods 0.17.2)

closeParen now skips $'...' strings with their escapes and # comments, so
rm -rf $(echo $'\'')/ and a ) inside a comment no longer end the scan early.
A $( that never closes in a command with an rm in it is refused instead of
read the old way. The parameter matcher takes an optional leading ! and a
[...] subscript, so ${A[0]:-/} and ${!X:-/} are refused. Same change in all
four guard copies, with the review's inputs as parity cases.

Refs #4742

* chore(helpers): re-sign the helpers manifest for the #4848 hook-handler guard

#4848 changes .claude/helpers/hook-handler.cjs, so the signed manifest's
hash no longer matched (guard: helper-signing.test.ts integrity mismatch).
Re-signed with the release key; helper-signing + mods-guard: 312/312.

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

---------

Co-authored-by: Parman Mohammadalizadeh <prmma23@gmail.com>
Co-authored-by: r <r@x>
2026-11-17 15:28:35 -05:00
rUvandr 2dca4afd14 test(cli): give doctor-json-cli its child-process budget under the root config (#5023)
Main went red at 795a156dd (#4839): the first doctor-json-cli test cold-starts
tsx in a spawnSync child (30 s budget) but timed out at 5.16 s, because the
repo-root vitest config CI's Test Suite uses has no testTimeout (5 s default).
#4839 added an 8-way parallel CLI test, so the runner is busier and the cold
start crossed 5 s. Set a describe-level 45 s timeout. Test-only change.

Co-authored-by: r <r@x>
2026-11-17 15:14:56 -05:00
Sachin SharmaandrUv 795a156dd1 fix(memory): exit non-zero when a refused sql.js save loses writes (#4839)
bin/cli.js swallowed every error from shutdownBridge(), so a refused
sql.js save (AGENTDB_LOCK_UNRECOVERABLE) exited 0 and the write was
lost. Only that error now prints a clear message and sets exit code 1.

Refs ruvnet/ruflo#4733

Co-authored-by: rUv <ruv@ruv.net>
2026-11-17 14:09:43 -05:00
cd1c7207e9 integrate: federation envelope freshness + replay guard (#4849) (#5022)
* fix(federation): validate inbound envelope freshness and replay

Signed-off-by: luojie <16602829831@163.com>

* fix(federation): reject JCS envelopes signed before replay history began

The inbound replay guard is in memory and created in initialize(), so an
envelope captured up to ~5.5 min before a restart could be replayed once
into the new lifecycle. Record the guard's creation time and fail closed
with MESSAGE_PREDATES_REPLAY_HISTORY for earlier signed timestamps.

Tests: guard-level restart-window test with an injected clock, and a
plugin-level test with real Ed25519 signatures showing an envelope
accepted by one instance is rejected by a fresh instance created after.

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

---------

Signed-off-by: luojie <16602829831@163.com>
Co-authored-by: luojie <16602829831@163.com>
Co-authored-by: r <r@x>
2026-11-17 14:00:22 -05:00
f8a9ce20b4 fix(cli): keep semantic router database under memory root (#4835)
Resolve the native router storage path through the existing project memory root so initialization does not create ruvector.db in the working directory. Add regression coverage for default and configured memory roots.

Fixes #4741

Signed-off-by: Sérgio Luiz Santos Neto <sneto.dev@gmail.com>
Co-authored-by: Sérgio Luiz Santos Neto <sneto.dev@gmail.com>
Co-authored-by: rUv <ruv@ruv.net>
2026-11-17 13:55:38 -05:00
rUvandr c1bd710d45 fix(aidefence): recover entries the HNSW graph cannot reach (3.2.2) (#5018)
AgentDBVectorStore.search returned [] for an entry that was stored: after a
delete and re-insert of the same id, ruvector-core's HNSW can leave the new
node unreachable from the graph's entry point. Measured with the backend's
own VectorDb options: 28/3000 searches missed the re-inserted id; through
the store, 8/1000 before this change and 0/1000 after. This is the
intermittent agentdb-vector-store.test.ts failure on main's CI/CD Pipeline.

The store keeps each entry's vector. When the index returns fewer of a
namespace's entries than it holds (counted before the minSimilarity filter,
so a floor alone never triggers it), the rest are scored exactly by cosine.
A deterministic test injects a backend that drops one id.

Bumps @claude-flow/aidefence to 3.2.2 and the CLI pin to match.
@claude-flow/aidefence@3.2.2 must be published before this merges
(audit-leaf-versions-published).

Co-authored-by: r <r@x>
2026-11-17 13:41:25 -05:00
rUv 84718fbb7b Merge branch 'main' into integrate/2026-11-17 2026-11-17 12:30:28 -05:00
rUvandr b686065122 test(memory): stub @ruvector/core under both vitest configs (#4739) (#5015)
hnsw-metadata-atomic-4739 mocked only '/@id/@ruvector/core', the ID Vite
gives the import when cli/vitest.config.ts externalizes @ruvector/*. CI's
Test V3 Packages job runs the v3 workspace config, which does not
externalize it, so the bare specifier was never stubbed, addToHNSWIndex
returned false and 3-4 tests failed. Main's V3 CI/CD Pipeline has been red
since #5001 (e0ad134ce). Register the same stub under both IDs.

Co-authored-by: r <r@x>
2026-11-17 12:30:24 -05:00
randRuFlo e346ef6cdf Merge origin/main into integrate/2026-11-17
Resolve workflow-tools.ts imports: keep locked-json-store (#4981) and
path-containment/import-limits (#4878); drop fs helpers neither side uses.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-11-17 11:49:19 -05:00