Commit Graph
7782 Commits
Author SHA1 Message Date
ruv 4b9e86840f fix(ci): bump 3 ruflo-metaharness stale lock-counts for ADR-153 tools
3 more plugin-contract failures from no-metaharness-smoke, all the same
root cause: ADR-153 added bench/evolve/security_bench MCP tools but the
smoke contract had hardcoded counts pinned to the pre-ADR-153 tool set.

  - 17z53: \`runScript('foo.mjs', ...)\` reference count 9 → 12
  - 17z9:  MCP_SUCCESS_SEMANTIC occurrence count 10 → 13 (1 decl + 12 uses)
  - 17z7:  \`success: r.success\` handler count 9 → 12
  - 17z6:  test-mcp-tools.mjs phase-1 \`tools.length === 9\` → 12, plus
           the 3 new tool names added to the expectedNames set

These are anchor counts that exist deliberately so a future iter adding
a tool also touches the smoke and CLAUDE.md catalog. Bumping in lockstep
with the 3 new tools.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-25 18:53:01 -04:00
ruv 575a7bdeed fix(ci): ruflo-metaharness smoke — fix brittle 17z61 lookback + iter-93 stale count
Two plugin-contract failures in the no-metaharness-smoke job for
ruflo-metaharness:

- **17z61** (drift-from-history dispatcher round-trip) used
  \`grep -B100\` to walk back from the step to its enclosing job header.
  metaharness-ci.yml grew past 100 lines between that step (now line 604)
  and its \`metaharness-real-data:\` job header (line 493). Replaced the
  fixed-window grep with an awk one-pass that finds the most-recent
  top-level job header above the step.

- **17z56** (every MCP tool documented in CLAUDE.md, iter 93) asserted
  exactly 9 MCP tools. ADR-153 added 3 more (\`metaharness_bench\`,
  \`metaharness_evolve\`, \`metaharness_security_bench\`) without updating
  the lock count or the CLAUDE.md catalog. Documented the 3 tools in
  CLAUDE.md and bumped the count to 12.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-25 18:36:12 -04:00
ruv 3f1747a527 fix(ci): graph schema smoke — checkpoint WAL before sql.js re-read
The smoke test asserts (a) the writer (better-sqlite3) succeeds and then
(b) re-reads the DB file via sql.js to verify the insert/migration landed.
Since #2431 put the writer in WAL mode (\`journal_mode = WAL\`), inserts
sit in the \`.db-wal\` sidecar until checkpointed; sql.js reads only the
main file and saw nothing. Symptoms: tests 2c, 3b, 5b all asserted false
even though tests 2a, 3a, 5a confirmed the writer succeeded.

Closing the writer connection (\`_resetBridgeDb\` calls
\`better-sqlite3.close()\`, which checkpoints WAL by default) before
each sql.js readback unblocks the verification. This is a smoke-script
bug surfaced by the Build V3 unblock — pre-3.14.2 the build broke before
this code ran, so the latent WAL incompatibility never tripped CI.

Local: 23/23 pass (was 18/23 with 4 WAL-related fails + 1 cascade).

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-25 18:32:28 -04:00
ruv 3cce463e19 fix(ci): convert integration-tests.yml flow-style needs[] to block style
Same fix as verification-pipeline.yml — js-yaml 4.x rejects multi-line
flow-style sequences as \"deficient indentation\" because the closing
bracket lines up with the opening key. Converted to plain block style.

Verified: \`node scripts/smoke-workflows-yaml.mjs\` reports
\`ok integration-tests.yml (6 jobs)\`.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-25 18:23:40 -04:00
ruv 92c9c9b08e fix(ci): regenerate root lockfile after ws override bump; fix YAML flow-style indent
Two follow-up fixes after first push of fix/ci-greenify:

1. **package-lock.json** — the ws override was bumped from \`>=8.18.4\` to
   \`>=8.21.0\` in package.json but the root lockfile was regenerated BEFORE
   that bump, so ws@8.20.1 stuck in the lock. CI's \`npm ci\` failed:

      npm error Invalid: lock file's ws@8.20.1 does not satisfy ws@8.21.0

   Re-ran \`npm install --package-lock-only\` to pull ws@8.21.0 into the lock.

2. **verification-pipeline.yml** — \`Static regression guards\` got past the
   js-yaml ESM import fix and surfaced an actual yaml syntax error:

      FAIL  verification-pipeline.yml  371:5  deficient indentation

   The block-flow-mixed style \`needs: [ a, b, c ]\` across multiple lines
   was rejected by js-yaml 4.x's stricter indent rules. Converted to plain
   block style \`needs: - a - b - c\` — semantically identical, unambiguous.

Local: \`node scripts/smoke-workflows-yaml.mjs\` → exit 0.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-25 18:21:15 -04:00
ruv d09a0e4cbd fix(ci): 5 CI failures — Build V3, Static guards, ADR-112, witness verify, supply-chain audit
Stacked fixes to clear the remaining red CI checks on \`main\` that pre-dated
the #2412 lockfile-cascade fix. Each one verified locally before commit.

1. **Build V3 (ubuntu/macos/windows)** — \`graph-edge-writer.ts\` did a static
   \`await import('better-sqlite3')\` which forces tsc to resolve the package's
   types at build time. \`better-sqlite3\` is in \`optionalDependencies\` (so
   CI doesn't install it) — type resolution failed with TS2307 on every
   platform. Routed the module name through a variable so the static analyzer
   stops trying to resolve it; runtime presence is still gated by the
   existing try/catch.

2. **Static regression guards (#2267)** — \`scripts/smoke-workflows-yaml.mjs\`
   crashed with \`SyntaxError: The requested module 'js-yaml' does not provide
   an export named 'default'\` after js-yaml dropped the synthetic default
   from its package exports. Switched to \`import * as yaml from 'js-yaml'\`.

3. **Tool description discoverability (ADR-112)** — two MCP tools regressed
   the no-guidance baseline (count went from 0 → 2):
     - \`metaharness_bench\` had no Use-when / Prefer / Pair-with hint
     - \`testgen_tdd_repair\` had \"Use when …\" in a *later* string
       fragment of a concatenated description, which the audit regex
       (single-quoted-literal-only) misses
   Added explicit \"Use when …\" guidance to the first fragment of each.
   Audit now reports 340/340 tools with guidance.

4. **witness verify precondition smoke (#1880)** — Root \`package-lock.json\`
   drifted: \`agentdb@3.0.0-alpha.16\` in lock vs \`^3.0.0-alpha.17\` in
   package.json (same root cause as #2412 but for the npm lockfile, not the
   pnpm one fixed last release). Every job that runs \`npm ci\` was failing
   at install. Regenerated via \`npm install --package-lock-only\`. Verified:
   \`npm ci --dry-run --legacy-peer-deps\` now exits 0.

5. **Supply-chain audit (#2046)** — \`plugins/ruflo-graph-intelligence\` had
   1 HIGH/CRITICAL unaccepted direct-dep finding:
     - \`ws@8.20.1\` pulled by \`sublinear-time-solver\` (GHSA-96hv-2xvq-fx4p,
       memory exhaustion DoS) — bumped root override \`ws >=8.18.4\` →
       \`>=8.21.0\` and added the same override to the plugin's own
       package.json so it propagates through the plugin's own npm install
     - \`@claude-flow/cli\` peerDep surfaces every HIGH transitive in cli's
       own tree inside the plugin's audit report — added a tracked,
       expiring accepted-finding (cli ships its own audit pipeline on
       every publish; the plugin doesn't redistribute cli's tree).
   Audit now reports \`OK: no hard-fail findings\`.

Verified locally:
  - \`npm run build\` in v3/@claude-flow/cli: clean
  - \`node scripts/smoke-workflows-yaml.mjs\`: exit 0, 53 workflows parsed
  - \`node scripts/audit-tool-descriptions.mjs\`: 340/340 with guidance, OK
  - \`npm ci --dry-run --legacy-peer-deps\` at repo root: exit 0
  - \`node scripts/audit-supply-chain.mjs\`: OK, no hard-fail findings

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-25 18:18:19 -04:00
rUv 03d4f848ce Merge pull request #2467 from ruvnet/fix/issue-2461-embedding-fallthrough
fix(memory): #2461 — embedding fall-through, null guard, default namespace (3.14.2)
v3.14.2
2026-06-25 18:06:51 -04:00
ruv 5201f8e540 chore(release): 3.14.1 → 3.14.2
Patch release for #2461 — Windows embedding crash + secondary
\`memory store\` undefined-namespace bug. All three packages bumped
in lockstep per the publishing rules:
  @claude-flow/cli@3.14.2
  claude-flow@3.14.2
  ruflo@3.14.2

Verified against the published npm artifact: 50/50 successful
\`generateLocalEmbedding\` calls with zero crashes from a fresh
\`npm i ruflo@3.14.2\` (was: instant null-dereference crash on
\`memory store\`/\`memory search\` on Windows behind a proxy).

Legacy \`alpha\` and \`v3alpha\` dist-tags repointed to 3.14.2 for
backward-compatibility.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-25 18:06:22 -04:00
ruv c22a12badb fix(memory): #2461 fall through when transformers fetch fails; null-guard generateLocalEmbedding; default namespace
Three bugs fixed, all reproduced + verified against the built artifact.

1. \`loadEmbeddingModel()\` aborted on transformers failure. When
   \`pipeline('feature-extraction', ...)\` throws (e.g. \`fetch failed\`
   on Windows behind a corporate proxy / firewall), the throw escaped
   the outer try and returned \`{ success: false }\` BEFORE reaching
   the ruvector ONNX fallback that ships in-tree and works offline.
   The bundled ruvector embedder returns real 384-dim non-zero vectors;
   the user had a working fallback we just never tried. Wrapped the
   transformers branch in try/catch so a failure now falls through.

2. \`generateLocalEmbedding()\` crashed with "Cannot read properties of
   null (reading 'model')" because (1) left \`embeddingModelState=null\`
   and the function used a \`!\` non-null assertion. Replaced with a
   null coalescing default so we degrade to the hash fallback instead
   of crashing every \`memory store\` / \`memory search\` call.

3. Secondary bug filed in the same issue: \`memory store\` without
   \`-n\` stored under the literal namespace "undefined" (silent data
   loss for first-time users). Added \`|| 'default'\` on both store
   and retrieve.

Verified against the built dist/:
  - 100 \`generateLocalEmbedding\` calls with ALL embedding modules
    unresolvable → 100/100 success (was: instant crash on call #1)
  - \`memory store\` default namespace guard present in compiled JS

Reporter (#2461): Pishro-canadaapply did the root-cause investigation
and proposed the exact fix shape. Thanks.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-25 18:02:34 -04:00
rUv 79b8634bd1 Merge pull request #2454 from ruvnet/fix/issues-2412-2422-2426-2450
fix: 4 user-reported bugs — CI lockfile, statusline migration, MCP 64KB pipe, USERGUIDE consensus
2026-06-23 12:19:33 -04:00
ruv 4e2a30ce30 chore(release): 3.14.0 → 3.14.1
Patch release bundling 4 user-reported bug fixes:
  - #2412 CI: regenerate pnpm-lock.yaml to match cli/package.json
  - #2450 statusline: detect bare `claude-flow hooks statusline` migration form
  - #2426 MCP:  blocking stdout in stdio mode for >64KB JSON-RPC frames
  - #2422 docs: USERGUIDE consensus modes match what ships

All three packages bumped in lockstep per the publishing rules:
  @claude-flow/cli@3.14.1
  claude-flow@3.14.1
  ruflo@3.14.1

Published to npm. Legacy `alpha` and `v3alpha` dist-tags repointed at 3.14.1
for backward compatibility (CLAUDE.md publishing rules — stable-only series,
alpha/v3alpha tags continue to mirror latest).

Co-Authored-By: RuFlo <ruv@ruv.net>
v3.14.1
2026-06-23 12:16:10 -04:00
ruv 8037f03671 docs(userguide): #2422 remove unimplemented Weighted/Majority consensus claims
USERGUIDE.md documented three consensus modes — Majority, Weighted (Queen 3x),
Byzantine — and three queen types — Strategic / Tactical / Adaptive. As
filed in #2422 by @sparkling, none of the weighted-voting behavior is wired:

  $ npx @claude-flow/cli@latest hive-mind init -c weighted
  [ERROR] Invalid value for --consensus: weighted.
          Must be one of: byzantine, raft, gossip, crdt, quorum

And \`calculateRequiredVotes()\` in the shipped hive-mind engine is a pure
equal-vote threshold — no queen multiplier exists in the codebase.

Rewrote 4 USERGUIDE locations (lines ~263, 268, 1693, 2437) to document
the actually-shipped 5 modes: byzantine / raft / gossip / crdt / quorum.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-23 12:09:01 -04:00
ruv a2858d2a06 fix(mcp): #2426 set stdout/stderr blocking so >64KB JSON-RPC frames deliver
The macOS pipe buffer is 64 KiB. Ruflo's MCP \`tools/list\` response with
all 314 tools is 65,747 bytes — just over the limit. Without blocking
writes, \`process.stdout.write()\` on Unix returns after a partial write
when the kernel buffer fills; the truncated frame is unparseable JSON
and Claude Code silently registers zero MCP tools on macOS.

Call \`process.stdout._handle.setBlocking(true)\` (and same for stderr)
at stdio-server init. This is what the official MCP SDK's
StdioServerTransport does for the same reason. Feature-gated so we
degrade gracefully on exotic stdout handles (e.g., tests where stdout
isn't bound to a pipe).

Verified with a direct stdio probe writing 70KB+ to a pipe and reading
in a child process:
  baseline (non-blocking) → reader gets exactly 65,536 bytes (truncated)
  with setBlocking(true)  → reader gets full 83,146 bytes (intact)

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-23 12:08:36 -04:00
ruv acb5705b70 fix(init): #2450 detect bare \claude-flow hooks statusline\ form in migration
The #2448 migration in `executor.ts` only rewrote settings.json entries
that ran the statusline via `npx @claude-flow/cli@latest hooks statusline`.
Users on v3.13.3 reported (#2450) that their settings still contain the
older bare-command form:

    "claude-flow hooks statusline 2>/dev/null || node .claude/helpers/statusline.cjs ..."

That form was not matched by BROKEN_STATUSLINE_RE so the migration left it
in place. The bare command cold-loads the ONNX embedding model on every
fire (~1s), Claude Code's statusLine refresh times out, and the status
bar never renders.

Broadened the regex to catch `(npx [flags])? [@]claude-flow[/cli][@<tag>]?
hooks statusline` — covers npx + tag, npx + prefer-offline, and the bare
form (with or without `||` fallback chains). Migration now rewrites all
forms to the local-helper NEW_STATUSLINE_CMD which runs in <20ms.

Regex test: catches all 5 broken forms, correctly skips the new
`node -e "..."` replacement and the bare local-helper invocation.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-23 12:08:25 -04:00
ruv 8d084146d8 fix(ci): #2412 regenerate pnpm-lock.yaml to match cli/package.json
The v3 lockfile drifted from `v3/@claude-flow/cli/package.json` after
version bumps for `@claude-flow/memory` (alpha.20→21), `agentdb`
(alpha.16→17), `metaharness` (~0.1.11→~0.2.6), and the addition of
`@metaharness/darwin@~0.3.1`. Every v3-ci.yml job runs
`pnpm install --frozen-lockfile`, which has been hard-failing with
ERR_PNPM_OUTDATED_LOCKFILE since 2026-06-18 — 10+ recurrences,
blocking all merges from receiving CI signal.

Regenerated via `pnpm install --lockfile-only`. Verified locally:
`pnpm install --frozen-lockfile` now exits 0.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-23 12:08:13 -04:00
rUv ec1a187996 Merge pull request #2451 from ruvnet/feat/testgen-tdd-repair-darwin
feat(testgen): Test-Driven Repair via headless claude -p (ADR-175-inspired) + release 3.14.0
v3.14.0
2026-06-22 17:16:23 -04:00
ruv 1b336e9ced feat(testgen): Test-Driven Repair via headless claude -p (ADR-175-inspired)
Adds a new ruflo-testgen surface that closes the loop the existing TDD
plugins didn't — we generate tests, this fixes the code to satisfy them.
Inspired by agent-harness-generator/packages/darwin-mode ADR-175 Test-
Driven Repair mode, but implemented via headless `claude -p` instead of
wrapping `metaharness-darwin evolve`. Rationale:

  1. `claude -p` already in our stack (no new optional dep)
  2. Bounded cost via --max-budget-usd (first-class flag)
  3. Capability-restricted via --allowedTools Read,Edit,Bash
  4. Test exit code IS the fitness function (no LLM-as-judge)
  5. Resumable via --session-id

Surface:
  - plugins/ruflo-testgen/scripts/tdd-repair/tdd-repair.mjs (script)
  - plugins/ruflo-testgen/skills/tdd-repair/SKILL.md       (skill)
  - v3/@claude-flow/cli/src/mcp-tools/testgen-tools.ts     (MCP tool:
                                                             testgen_tdd_repair)

Pipeline (Test-Driven mode):
  1. Pre-flight: run the test command. Refuse if already passing.
  2. Spawn `claude -p` with focused prompt (read failing test, fix
     source, don't touch test, verify by running it).
  3. Re-run test to verify the fix; emit per-attempt receipts incl.
     usage.cost_usd from claude's --output-format json.
  4. If green: success. If red after --max-attempts: emit failure
     receipts; workspace left as-modified for review.

Safety (mirrors ADR-153 conventions):
  - --confirm REQUIRED (dry-run otherwise)
  - --max-budget-usd hard cap (default $5, divided across attempts)
  - --allowedTools restricts spawned claude to Read/Edit/Bash
  - --permission-mode acceptEdits (auto-accept within the allowed set)
  - 15 min hard timeout
  - Pre-flight catches --test-command typos before any spend

Conformant mode (--no-test-oracle, agent writes own repro via MCTS)
is scoped for a follow-up ADR — current --no-test-oracle returns
config error with a clear hint.

Smoke verification (docs/benchmarks/tdd-repair/SMOKE-2026-06-22.md):
  Built minimal failing-test fixture: add(a,b) returns a-b instead of
  a+b. Pre-repair: 2/2 tests fail. After `tdd-repair --confirm`:
  source patched to a+b, 2/2 tests pass. Verified by re-running.

Version bump 3.13.3 → 3.14.0 (MINOR per semver — backward-compatible
new MCP tool + new skill). Published with all three dist-tags (latest,
alpha, v3alpha) for @claude-flow/cli, claude-flow, ruflo.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-22 17:15:32 -04:00
rUv 204703067d Merge pull request #2449 from ruvnet/fix/2448-stale-npx-statusline-migration
fix(init,doctor): #2448 — migrate stale npx @latest in statusLine/hooks + release 3.13.3
v3.13.3
2026-06-22 14:01:06 -04:00
ruv 8009a152f8 fix(init,doctor): #2448 — migrate stale npx @latest statusLine + hooks
CRITICAL — affected user reported load average 49 / jetsam / kernel
watchdog panic on macOS 26.1 / 48 GB. Pre-#2337 init wrote
`npx @claude-flow/cli@latest hooks <sub>` into ~/.claude/settings.json
for both the statusLine and the per-action hooks. Each invocation cold-
spawns a Node process (~130 MB) plus an npm registry round-trip to
re-resolve @latest. The statusLine refires every few hundred ms; hooks
fire per tool use. They stack faster than they exit.

The current source already emits the local-helper form
(`sh -c '… exec node "$D/.claude/helpers/<helper>" <sub>'`), but
executor.ts:362 preserved the user's existing `statusLine.command`
verbatim on re-init — so anyone who installed pre-#2337 and upgraded
to 3.13.2 still has the runaway commands.

Two changes:

  1. v3/@claude-flow/cli/src/init/executor.ts
     - Detect the broken `npx @claude-flow/cli@latest hooks …` pattern
       in `existing.statusLine.command` AND walk every hooks.<event>[]
       hooks[].command — regenerate to the local-helper form when
       matched. Idempotent on already-correct settings.
     - Captures the subcommand from the broken string (pre-bash,
       post-edit, route, etc.) so the regenerated command preserves
       the user's intent.

  2. v3/@claude-flow/cli/src/commands/doctor.ts
     - New `checkStaleSettingsNpx` health check. Scans both
       project-local AND $HOME/.claude/settings.json for the broken
       pattern in statusLine + hooks. Reports `fail` with file path
       + offending sections when found, with fix instruction
       (`npx ruflo init` to migrate). Reports `pass` otherwise.
     - Registered as `stale-settings` in the component map so users
       can run `ruflo doctor --component stale-settings` directly.

Smoke-verified against a synthetic fixture containing all three
offender shapes (statusLine, PreToolUse hook, UserPromptSubmit hook
with --prefer-offline prefix). Doctor correctly flagged all three.

Release: 3.13.2 → 3.13.3 (PATCH per semver — pure bug fix).
Published with all three dist-tags (latest/alpha/v3alpha) for
@claude-flow/cli, claude-flow, and ruflo.

Closes #2448.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-22 14:00:19 -04:00
rUv 699f0560b4 Merge pull request #2447 from ruvnet/docs/readme-add-ruflo-arena
docs(readme): add missing ruflo-arena to plugin list + fix count 34 → 35
2026-06-22 12:47:26 -04:00
ruv aaf183bcbe docs(readme): add missing ruflo-arena to plugin list (#2446 followup)
The "🔌 All 34 plugins" collapsed section was missing ruflo-arena
(35 ruflo-* dirs on disk, only 34 listed in README). Slotted into the
Architecture & Methodology section next to ruflo-metaharness — they're
evolutionary-strategy siblings (Arena = competition / tournaments,
MetaHarness = audit / score).

Also bumped the summary count "All 34 plugins" → "All 35 plugins".

Post-fix:
  $ ls plugins/ | grep -c ruflo-      # 35
  $ grep -oE '\[\*\*ruflo-[a-z-]+\*\*\]' README.md | sort -u | wc -l   # 35
  $ diff <(both lists)                  # (empty — perfect match)

Followup to #2446 (README top tightening).

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-22 12:47:20 -04:00
rUv 04317a2ce5 Merge pull request #2446 from ruvnet/docs/readme-top-tightening
docs(readme): tighten top — definition-first, ecosystem-second, story collapsed
2026-06-22 12:40:24 -04:00
ruv dc2b08f8b7 docs(readme): tighten top — definition-first, ecosystem-second, story collapsed
Surgical edits to top 50 lines per industry-trends review (no changes
below "Quick Start"). Three changes:

1. **Definition-first opening.** Replaces "Multi-agent AI harness for
   Claude Code and Codex" with the now-standard "Agent = Model + Harness"
   mental model, then locks in "Ruflo is the harness" with what's
   actually in it. Matches how Databricks, LangChain, Hugging Face
   define this layer in 2026.

2. **Two-tier badge clustering.** Top tier (4 for-the-badge badges) =
   what first-time visitors actually act on: Try UI, npm install, License,
   GitHub Star. Bottom tier (7 flat-square badges) = ecosystem context:
   Goal Planner, Live Agents, RuVector, downloads, clones, Claude Code
   plugin, Codex plugin. Cuts the wall-of-CTAs problem at the top.

3. **Origin story collapsed.** Moved the "Claude Flow is now Ruflo —
   named by rUv..." block from page 1 into a <details> "Background"
   block right above the GIF. Visible, but doesn't compete for attention
   with the value prop.

Also removed the redundant RuVector badge that appeared on two strips,
and standardized en-dashes in the "New to Ruflo?" callout.

No content removed — every link, image, and structural section below
"Quick Start" is identical. Diff is +22/-21 in one file.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-22 12:39:57 -04:00
rUv 8d5120f955 Merge pull request #2445 from ruvnet/chore/bump-agentdb-3.0.0-alpha.17
chore(deps): bump agentdb ^3.0.0-alpha.16 → ^3.0.0-alpha.17 + release 3.13.2
v3.13.2
2026-06-22 12:07:54 -04:00
ruv c1ff505de2 chore(deps): bump agentdb ^3.0.0-alpha.16 → ^3.0.0-alpha.17 + release 3.13.2
Picks up upstream agentdb fix for the SqlJsRvfBackend MEMFS safety net
(ruvnet/agentdb#9, ruvnet/agentdb#10) — FinalizationRegistry now reclaims
MEMFS files when a backend wrapper is GC'd without explicit close().

This is the upstream-side fix complementing ruflo's downstream-side fix
in v3.13.1 (PR #2444): the downstream PR closed prior controllers on
replacement; the upstream PR adds a belt-and-suspenders safety net so
even consumers who forget close() don't leak.

Combined effect: the #2432 leak class is closed at BOTH layers.

Version bumps:
  - agentdb              3.0.0-alpha.16 → 3.0.0-alpha.17 (upstream)
  - @claude-flow/cli     3.13.1          → 3.13.2  (pin bump)
  - claude-flow umbrella 3.13.1          → 3.13.2
  - ruflo wrapper        3.13.1          → 3.13.2

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-22 12:07:22 -04:00
rUv 43b5958194 Merge pull request #2444 from ruvnet/fix/2432-2431-memory-leaks
fix(memory): #2432 #2431 + release 3.13.1 — close prior controllers, WAL-safe graph-edge writes
v3.13.1
2026-06-22 11:51:07 -04:00
ruv d112d4fc8b fix(memory): #2432 #2431 + release 3.13.1 — close prior controllers, WAL-safe graph-edge writes
PATCH per semver — pure bug fixes, no API changes.

Fixes:

#2432 — Unbounded sql.js MEMFS leak (~36 GB observed in production)
  Root cause: ControllerRegistry.initController() called controllers.set(name, ...)
  without closing the prior instance. SqlJsRvfBackend wrappers held an
  Emscripten MEMFS file (~11 MB each = sizeof memory.db) that only releases
  on explicit .close() — JS GC of the wrapper does NOT reclaim MEMFS because
  the sql.js module is a process singleton.
  Fix: added closePriorIfAny(name) helper, called before every controllers.set()
  site in v3/@claude-flow/memory/src/controller-registry.ts. Best-effort close
  (catches errors so replacement always proceeds).

#2431 — graph-edge-writer.ts dual-write corrupts memory.db (ADR-130 regression)
  Root cause: sql.js opened memory.db, did in-memory writes, then called
  fs.writeFileSync(dbPath, db.export()) after every edge insert. This
  whole-file flush overwrote memory.db while the better-sqlite3 bridge was
  writing through its WAL — exactly the dual-write race that ADR-068 (#1257)
  removed. Symptom: PRAGMA integrity_check reports "database disk image is
  malformed (11)" after a single memory_store + causal-edge sequence.
  Fix: ported v3/@claude-flow/cli/src/memory/graph-edge-writer.ts from sql.js
  to better-sqlite3 + WAL mode. Same native engine as the bridge, no whole-file
  fsync, no race. Public API unchanged. Smoke-tested: 50 concurrent insertGraphEdge()
  calls + PRAGMA integrity_check → ok.

  Note: this is the minimum-safe fix. The architecturally cleaner fix (route
  edge writes through the bridge's controller layer per ADR-068) is deferred
  to a future ADR. The current fix removes the race by ensuring both writers
  share the same WAL-coordinated SQLite engine.

Version bumps:
  - @claude-flow/memory   3.0.0-alpha.20 → 3.0.0-alpha.21
  - @claude-flow/cli      3.13.0          → 3.13.1   (pins memory ^3.0.0-alpha.21)
  - claude-flow umbrella  3.13.0          → 3.13.1
  - ruflo wrapper         3.13.0          → 3.13.1

Published to npm with all three dist-tags (latest, alpha, v3alpha) for each
of the four packages. Verified post-publish: every package × every tag = 3.13.1
(memory at alpha.21).

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-22 11:50:17 -04:00
rUv db5400e4e4 Merge pull request #2443 from ruvnet/fix/high-issues-2437-2432
fix(doctor): #2437 — MetaHarness plugin locator (npx/global install) + severity (fail→warn)
2026-06-22 11:42:14 -04:00
ruv 65bb11dc4e fix(doctor): #2437 — MetaHarness plugin locator + severity
Two bugs in checkMetaharnessIntegration():

1. **Path resolution** — only walked up from process.cwd() and checked one
   hard-coded node_modules path. Missed the two installations users actually
   run from:
     (a) `npx @claude-flow/cli@<tag>` → resolves under `~/.npm/_npx/<hash>/...`
     (b) `npm install -g @claude-flow/cli` → lives under `$(npm prefix -g)/lib/...`

   Fix: walk up from this module's own location via `import.meta.url` —
   the plugins/ dir is always a sibling of the package root regardless of
   where it was installed.

2. **Severity** — reported `fail (✗)` when the plugin was genuinely absent.
   But MetaHarness is in optionalDependencies per ADR-150 constraint #2;
   a missing optional dep warrants `warn (⚠)`, not `fail`. The runtime
   path already returns {degraded: true, exit 0} — doctor should reflect
   the same posture so a clean install of the cli alone doesn't report
   "Some checks failed".

   Reserved `fail` for the case where the plugin SHOULD be present but
   has broken/missing required files — that's a genuine misconfiguration.

Also extends the required-files list with the v3.13.0 Darwin Mode surfaces
(ADR-153): _darwin.mjs, evolve.mjs, security-bench.mjs, bench.mjs and
their three skill SKILL.md files. Gates against silent deletion.

Closes #2437.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-22 11:40:07 -04:00
rUv 0b00665f6f Merge pull request #2441 from ruvnet/chore/release-3.13.0
chore(release): bump 3.12.4 → 3.13.0 — @metaharness/darwin integration
v3.13.0
2026-06-22 10:42:40 -04:00
ruv 4940b4005a chore(release): bump 3.12.4 → 3.13.0 — @metaharness/darwin integration
MINOR per semver — backward-compatible additions:
- 3 new MCP tools: metaharness_evolve, metaharness_security_bench, metaharness_bench
- 3 new skills: harness-evolve, harness-security-bench, harness-bench
- New optional dep: @metaharness/darwin ~0.3.1
- Umbrella bump: metaharness ~0.1.11 → ~0.2.6

Changes:
- Root `package.json`              3.12.4 → 3.13.0
- `v3/@claude-flow/cli`            3.12.4 → 3.13.0
- `ruflo/` wrapper                 3.12.4 → 3.13.0

Published to npm with all three legacy dist-tags pointing at 3.13.0:

  @claude-flow/cli@3.13.0  →  latest, alpha, v3alpha
  claude-flow@3.13.0       →  latest, alpha, v3alpha
  ruflo@3.13.0             →  latest, alpha, v3alpha

Implements ADR-153 (Darwin Mode integration). All 4 ADR-150 architectural
constraints honored — removable, optional, graceful, CI-gated. Connects to
ADR-155 (#2417, #2418) by surfacing the upstream Darwin Shield as an
empirical floor for Loop A reward-signal soundness.

Verified post-publish: every package × every dist-tag = 3.13.0.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-22 10:42:12 -04:00
rUv a67e0ead73 Merge pull request #2440 from ruvnet/feat/metaharness-darwin-integration
feat(metaharness): integrate @metaharness/darwin@0.3.1 + bump umbrella to 0.2.6
2026-06-22 10:38:38 -04:00
ruv fdeacad7f8 feat(metaharness): integrate @metaharness/darwin@0.3.1 + bump umbrella to 0.2.6
Implements ADR-153 (Darwin Mode integration). Adds the WRITE layer that
closes the loop ADR-150's READ layer opens: score/genome describe a
harness; evolve changes one.

Three new surfaces, all honoring the four ADR-150 architectural constraints
(removable / optional / graceful degradation / CI-absent-path coverage):

  - harness-evolve         mutate 1 of 7 policy surfaces, sandbox-score, promote
  - harness-security-bench upstream's "Darwin Shield" (their own ADR-155)
  - harness-bench          create/verify bench suites for evolve --bench

Wiring:
  - plugins/ruflo-metaharness/scripts/_darwin.mjs       — shared subprocess helper
  - plugins/ruflo-metaharness/scripts/evolve.mjs        — main verb (--confirm gate)
  - plugins/ruflo-metaharness/scripts/security-bench.mjs — Darwin Shield wrapper
  - plugins/ruflo-metaharness/scripts/bench.mjs         — supporting verb
  - plugins/ruflo-metaharness/skills/harness-{evolve,security-bench,bench}/SKILL.md
  - v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts — 3 new MCP tools:
      metaharness_evolve, metaharness_security_bench, metaharness_bench
  - v3/@claude-flow/cli/package.json optionalDependencies:
      + @metaharness/darwin ~0.3.1
      bump metaharness ~0.1.11 -> ~0.2.6
  - ruflo/package.json optionalDependencies: mirrored (per the #2112 lesson —
      wrapper does NOT inherit root overrides; required for transitive pin)

Safety posture (matches mint.mjs convention):
  - evolve requires --confirm; without it, returns a dry-run plan
  - Ruflo caps: --generations 1..50, --children 1..20, --concurrency 1..8,
    --population 1..20, --cycles 1..100 (upstream supports more)
  - Upstream exit code 99 (safety-disqualified) propagates VERBATIM —
    not remapped — so CI can distinguish "evolution failed" from
    "evolution surfaced a safety-tripping mutation"
  - All three scripts emit {degraded: true, reason: 'metaharness-darwin-not-available'}
    and exit 0 when the optional dep is absent

Connection to ruflo's own ADR-155 (nightly self-learning security harness,
PR #2417, issue #2418): harness-security-bench is the closest reference
implementation for our Loop A reward-signal sanity check. Running it
periodically gives us the empirical floor — if Darwin Shield's champion
reaches TPR=1/FPR=0 on the seeded corpus, our loop A's gradient signal
is sound.

Tests:
  - plugins/ruflo-metaharness/scripts/test-graceful-degradation.mjs extended
    with the 3 new scripts; all 16 assertions pass (8 skills × 2 contracts:
    exit 0 AND emit "degraded": true)
  - npx tsc --noEmit clean on v3/@claude-flow/cli

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-22 10:04:42 -04:00
rUv 9c28fe038c Merge pull request #2416 from ruvnet/chore/marketplace-add-metaharness-arena
chore(marketplace): register ruflo-metaharness and ruflo-arena in marketplace.json
2026-06-18 14:14:55 -04:00
ruv e2b48c32ce chore(marketplace): register ruflo-metaharness and ruflo-arena plugins
Both plugins live in plugins/ on disk but were missing from
.claude-plugin/marketplace.json, so `/plugin marketplace add ruvnet/ruflo`
in Claude Code did not surface them.

Adds:
- ruflo-metaharness (ADR-148/149/150) — score, genome, mint, mcp-scan,
  threat-model, oia-audit; optional dep, never required at runtime
- ruflo-arena (ADR-147/148) — competitive ruliology arenas, tournaments,
  adaptive co-evolution of program strategies

Manifest now lists 35 plugins, matching the 35 ruflo-* directories under
plugins/. JSON validated with python3 -m json.tool.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-18 14:11:28 -04:00
rUv da901d06cc Merge pull request #2415 from ruvnet/security/cwe-78-agentic-flow-bump
security(deps): bump agentic-flow ^2.0.13 → ^2.0.14 (CWE-78), release 3.12.4
v3.12.4
2026-06-18 10:39:53 -04:00
ruv 5ab8d35a12 chore(release): bump 3.12.3 → 3.12.4 — CWE-78 agentic-flow security patch
Picks up the agentic-flow@2.0.14 release that closes CWE-78 OS command
injection in its MCP server tools (see ruvnet/agentic-flow#169 +
companion ruvnet/ruflo#2414).

Changes:
- Root `package.json`            3.12.3 → 3.12.4, `agentic-flow` ^2.0.13 → ^2.0.14 (bumped earlier in d51d56930)
- `v3/@claude-flow/cli`          3.12.3 → 3.12.4
- `ruflo/` wrapper               3.12.3 → 3.12.4
- `ruflo/` wrapper overrides     add `"agentic-flow": ">=2.0.14"` defense-in-depth pin (mirrors the #2112 lesson — wrapper does NOT inherit root overrides; required because wrapper deps don't pin agentic-flow directly)

Published to npm with all three legacy dist-tags pointing at 3.12.4:

  @claude-flow/cli@3.12.4  →  latest, alpha, v3alpha
  claude-flow@3.12.4        →  latest, alpha, v3alpha
  ruflo@3.12.4              →  latest, alpha, v3alpha

End users running any of:
  npx ruflo@latest
  npx claude-flow@latest
  npx @claude-flow/cli@latest

are pinned away from the vulnerable agentic-flow ≤ 2.0.13 line.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-18 10:39:06 -04:00
ruv d51d569309 chore(deps): bump agentic-flow ^2.0.13 → ^2.0.14 for CWE-78 fix
Upstream agentic-flow 2.0.14 fixes CWE-78 OS command injection in its
MCP server tools (standalone-stdio, http-sse, http-streaming-updated,
stdio-full, claude-flow-sdk, poc-stdio, plus fastmcp tools/agent/swarm
sinks). Attacker-influenceable MCP tool parameters (agent, task, name,
language, agentdb args) were template-interpolated into shell command
strings passed to execSync(); a value like

  x"; touch INJECTED; echo "

broke out of the surrounding quotes. The fix routes every shell-out
through execFileSync('npx', argv, { shell: false }) so argv elements
hit execve(2) without shell parsing.

This commit bumps the root agentic-flow dep to ^2.0.14 and refreshes
package-lock.json. Verified post-install: node_modules/agentic-flow
is at 2.0.14 with zero execSync() call sites remaining in
dist/mcp/standalone-stdio.js.

Upstream commit: agentic-flow a0f9c2b
Advisory: CWE-78 / OS Command Injection in MCP server tools

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-18 10:24:32 -04:00
ruv b7423693ab docs(adr): ADR-154 — @metaharness/kernel platform binaries gap
Side finding from the @metaharness/* package review: @metaharness/kernel@0.1.2
declares 5 per-platform NAPI-RS native packages in optionalDependencies but
NONE are published to npm. Runtime evidence on darwin-arm64:

   $ npm install ruflo@3.12.3
   $ node -e "(await import('@metaharness/kernel')).loadKernel().then(k => console.log(k.backend))"
   wasm

The WASM fallback path is functional; the README's advertised "wasm primary,
NAPI-RS native fallback" is currently inverted (WASM is the only path).

Decision: ACCEPT the WASM-only state as the supported configuration. No code
change needed — `loadKernel()` already does the right thing. Add a smoke gate
that asserts `backend === 'wasm'` so we'll know when upstream ships the
natives (the gate fires `kernel-now-native-rebaseline-perf-docs` and we
re-baseline perf docs).

This is a descriptive ADR, not a behavioral change. Documents:
   * Current state (5 native packages NOT_PUBLISHED)
   * Runtime impact (WASM-only path works; no user-visible breakage)
   * Why not block on upstream (functionality intact, perf ceiling not binding)
   * Smoke gate to catch upstream publish + re-baseline trigger
   * Cross-link from any user-facing doc that cites kernel perf

Paired with ADR-153 (Darwin Mode integration) as part of the @metaharness/*
ecosystem review.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-17 22:25:37 -04:00
ruv a56f021c82 docs(adr): ADR-153 — @metaharness/darwin (Darwin Mode) integration
Proposed integration of @metaharness/darwin@0.1.0 as ruflo's
harness-evolution layer. Closes the read-write loop that ADR-150
opened: where ADR-150 describes a harness (score, genome, mcp-scan,
threat-model, similarity, drift), Darwin Mode evolves it
(population-based self-improvement of 7 policy surfaces under a
sandbox + safety inspector + promotion gate).

Same architectural pattern as ADR-150 — four constraints:
   1. Removable — npm ls --without @metaharness/darwin still works
   2. Optional in package.json — never `dependencies`
   3. Graceful degradation — MODULE_NOT_FOUND emits standard payload
   4. CI gate — no-metaharness-smoke covers absence

Surfaces proposed (Phase 1 MVP):
   * CLI:  npx ruflo evolve <repo> [--generations N --children N ...]
   * MCP:  mcp__claude-flow__metaharness_evolve
   * Script: plugins/ruflo-metaharness/scripts/evolve.mjs
   * Doctor: --component metaharness extended

Explicit non-goals:
   * No model fine-tuning (model is frozen; harness evolves)
   * No auto-evolve in CI (user-initiated operation)
   * No bypass of existing CVE/threat-model/mcp-scan checks
   * No cross-repo promotion (federation is Phase 3)
   * No mutation of ruflo's own surfaces in-place

Phase 2-4 tracked as follow-ups (witness-signed archives, federation,
per-repo policy file).

Upstream: @metaharness/darwin@0.1.0 — MIT, zero runtime deps, 266 KB,
published 2026-06-17 by ruvnet, mirrors ADR-070..075 in
ruvnet/agent-harness-generator/packages/darwin-mode.

Phase 1 implementation tracked as a checklist in the ADR; this commit
is the ADR only, no code changes yet.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-17 22:24:26 -04:00
ruv f8fbb00601 chore(release): bump 3.12.2 → 3.12.3 (#2395 mock-embedding fix) v3.12.3 2026-06-17 19:38:56 -04:00
ruv 04f4744506 fix(memory): reject 128-dim bridge results — MCP no longer emits mock embeddings (#2395)
Closes #2395 — MCP `memory_store` emitted persistent 128-dim mock
(hash-fallback) embeddings instead of the real 384-dim ONNX
embeddings, while the standalone CLI worked correctly. The CLI vs
MCP divergence wasted any benefit of vector memory and silently
corrupted similarity recall.

ROOT CAUSE

`bridgeGenerateEmbedding` (v3/@claude-flow/cli/src/memory/memory-bridge.ts)
called `embedder.embed(text)` and unconditionally returned the result
labeled `model: 'Xenova/all-MiniLM-L6-v2', backend: 'onnx'`. The model
name promises 384-dim, but AgentDB's vectorBackend controller may
initialize as `enabled: false` (e.g., when ruvector isn't yet wired
into its neural substrate) and silently substitute a 128-dim hash
stub.  The stub doesn't expose `isMock=true`, so the existing
`isMock` check let it through with a wrong `'onnx'` label.

Downstream `generateEmbedding` saw the non-null bridge result and
returned it immediately, skipping the local ONNX chain
(transformers.js / ruvector) which DOES produce 384-dim correctly.

FIX

Add a dimensional sanity check: if `emb.length !== 384`, the bridge
result is definitively a stub (the model name we hardcode always
produces 384). Return null instead. Caller falls through to
`generateLocalEmbedding` which routes via the local ONNX chain.

This is conservative: the only behavior change is that a previously-
misclassified 128-dim "onnx" path now becomes a 384-dim real-ONNX
path (when the local chain has transformers.js or ruvector) OR a
clearly-labeled 128-dim hash fallback (when local ONNX also fails).
Either way the backend label now matches the actual semantics.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-17 19:36:50 -04:00
ruv 1b788705b0 chore(release): bump 3.12.1 → 3.12.2
Published with two bundled fixes from PRs #2408 + #2397:

   #2407 (CRITICAL — kernel-panic culprit) — atomic O_EXCL lockfile +
     drop init.ts:424 shell `&`. Concurrent `daemon start` invocations
     can no longer race the PID-file dedup → no more 39-zombie-daemon
     accumulations.

   #2403 — `security cve` subcommand was a stub printing "No CVE
     database configured". Now delegates to `npm audit --json` (same
     GitHub Advisory DB source as `security scan`), extracts CVE IDs,
     supports --check CVE-X and --severity filters.

   #2397 (community contributor @tjaiyen) — harden memory/hook
     helpers: real timeout via Promise.race, signal cleanup, truncation
     transparency, cross-platform slug. 248+/49− across 8 files.

   Dependabot bumps (3 of 5 merged cleanly): @types/node, vitest, agent-browser
     in /v3/@claude-flow/browser + /plugins/ruflo-graph-intelligence.

Co-Authored-By: RuFlo <ruv@ruv.net>
v3.12.2
2026-06-17 18:45:20 -04:00
rUv 5482fe7f98 Merge pull request #2387 from ruvnet/dependabot/npm_and_yarn/v3/claude-flow/browser/types/node-20.19.43
chore(deps-dev): bump @types/node from 20.19.41 to 20.19.43 in /v3/@claude-flow/browser
2026-06-17 18:42:10 -04:00
rUv da72b97de8 Merge pull request #2385 from ruvnet/dependabot/npm_and_yarn/v3/claude-flow/browser/vitest-4.1.9
chore(deps-dev): bump vitest from 4.1.6 to 4.1.9 in /v3/@claude-flow/browser
2026-06-17 18:42:05 -04:00
rUv 11fee2a7ac Merge pull request #2383 from ruvnet/dependabot/npm_and_yarn/plugins/ruflo-graph-intelligence/vitest-4.1.9
chore(deps-dev): bump vitest from 4.1.6 to 4.1.9 in /plugins/ruflo-graph-intelligence
2026-06-17 18:42:01 -04:00
rUv 774c6e2e41 Merge pull request #2397 from tjaiyen/harden-helpers-upstream
fix(hooks): harden memory/hook helpers (timeout race, signal cleanup, truncation, cross-platform slug)
2026-06-17 18:41:58 -04:00
rUv 82331a88fc Merge pull request #2408 from ruvnet/fix/2407-daemon-race
fix(daemon + security): #2407 daemon race + #2403 cve subcommand
2026-06-17 18:41:55 -04:00
ruv 05b0e92bea fix(security): cve subcommand delegates to npm audit (#2403)
Closes #2403 — `security cve` was a stub that just printed "No CVE
database configured" and pointed users at `security scan`. Now it
actually does the work: invokes `npm audit --json` (same GitHub
Advisory DB source as scan), extracts CVE IDs from the `via` field
titles + URLs, filters by --check CVE-ID and/or --severity, and
renders a table.

Behavior:
  cve              → list all affected packages with their CVE IDs
  cve --check X    → filter to a specific CVE-XXXX-NNNN
  cve -s critical  → filter by severity (critical/high/medium/low)

Local verify on this repo:
  $ npx ruflo security cve
  Found 37 affected package(s):
    HIGH @grpc/grpc-js (no CVE id) — A malformed request ...
    MEDIUM @opentelemetry/core ...
    ...

Exit 0 either way (informational). Source attribution surfaced in
output footer for transparency.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-17 18:41:31 -04:00
ruv 7cafd268f8 fix(daemon): atomic lockfile + drop init.ts:424 shell & (#2407)
Closes #2407 — daemon proliferation racing the PID-file dedup
accumulated 39 zombie daemons (~8.5 GiB resident) on a long-running
Mac and contributed to the 2026-06-15 21:06 kernel panic
(compressor 27 GiB, configd watchdog timeout).

ROOT CAUSE (2-stage race)

Stage 1 — init.ts:424 used `daemon start ... &` (shell background).
execSync returned the instant the shell forked, before the daemon
wrote its PID file. Concurrent init invocations (devcontainer setup +
VS Code task + MCP hook firing within ~500 ms) all hit Stage 2 with
an empty PID file.

Stage 2 — daemon.ts:95-105's dedup read the PID file and forked
startBackgroundDaemon non-atomically. N concurrent callers all saw
an empty PID, all proceeded, all forked their own daemons. Last
write to the PID file won; the other N-1 ran orphaned.

FIX

(1) init.ts: drop the shell `&`. `daemon start` (default non-foreground
    mode) already handles its own detached background fork via
    startBackgroundDaemon AND writes the PID file synchronously before
    returning. execSync without `&` waits long enough for the dedup-
    relevant PID-file write. Timeout bumped 10s → 30s for npx cold-
    cache scenarios.

(2) daemon.ts: wrap the dedup + spawn in an O_EXCL atomic lockfile
    (`.claude-flow/daemon.lock`). Winner reads PID file, spawns or
    short-circuits. Losers see EEXIST, poll for up to 5s waiting for
    the winner's PID to land, then return "already running" cleanly.
    Stale lockfile (crashed mid-spawn) is recovered by unlinking after
    timeout and falling through to killStaleDaemons.

VALIDATION

Race test — 5 concurrent `node cli.js daemon start` invocations
against a fresh /tmp/race-test2 workspace:

  Before fix: 3 surviving daemons (all 3 forked, race resolution failed)
  After fix:  1 surviving daemon (PID 84773), 2 callers saw
              "Daemon already running in background", killStaleDaemons
              swept 2 mid-spawn crashes.

Local repro of the 3-daemon scenario was tested against the v3.12.1
dist before the fix — three of three init invocations spawned
independent daemons. After the fix, only one survives regardless of
how many parallel callers race.

NEXT STEPS

The MacOS memory guard at ~/scripts/mac-memory-guard.sh (built during
the kernel-panic diagnosis) remains as the second-line defense
against this and other memory leaks. The first-line fix is here.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-17 18:37:17 -04:00