π The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(core,cli): record failed tool outcomes, run hooks from the project root, keep telemetry off the tool path
rb98935f34f94
diff --git a/plugins/ruflo-core/.claude-plugin/plugin.json b/plugins/ruflo-core/.claude-plugin/plugin.jsonindex d301be5d83..d1c9c09013 100644--- a/plugins/ruflo-core/.claude-plugin/plugin.json+++ b/plugins/ruflo-core/.claude-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "ruflo-core","description": "Foundation plugin β registers the ruflo MCP server (300+ tools across memory/agentdb/embeddings/hooks/aidefence/neural/autopilot/browser/agent/swarm), provides 4 generalist agents (coder/researcher/reviewer/witness-curator), 5 skills (discover-plugins/init-project/ruflo-doctor/ruflo-status/witness), and a curated plugin-discovery catalog",- "version": "0.2.8",+ "version": "0.2.9","author": {"name": "ruvnet","url": "https://github.com/ruvnet"diff --git a/plugins/ruflo-core/CHANGELOG.md b/plugins/ruflo-core/CHANGELOG.mdindex ee693c14c6..4aedcc10e1 100644--- a/plugins/ruflo-core/CHANGELOG.md+++ b/plugins/ruflo-core/CHANGELOG.md@@ -2,6 +2,11 @@Newest first. One `## <version> β <date>` heading per version, then `feat:`, `fix:`, `breaking:` and `chore:` bullets (ADR-478). Built from git history; this is the whole history.+## 0.2.9 β 2026-10-14+- fix: failed Bash commands and failed edits are recorded as failures: PostToolUseFailure is registered and forwarded to post-command / post-edit with `-s false` and the real exit code, so the learning layer no longer sees a 100% success rate (#4127, thanks @rudycelekli for #4170)+- fix: the hook shim starts the CLI from CLAUDE_PROJECT_DIR, so a session that `cd`ed into a subdirectory no longer gets .claude-flow/ and proven-config files written there (#4176)+- perf: telemetry hooks no longer block the tool: the CLI is started detached and the shim returns in about 25 ms instead of 0.2 to 4 s per call; at most 4 run at once per project (RUFLO_HOOK_MAX_PARALLEL), Stop is never dropped, RUFLO_HOOK_SYNC=1 restores the synchronous path (#4128)+## 0.2.8 β 2026-10-11- fix: the PostToolUse Bash shim stands down when command recording is switched off (`CLAUDE_FLOW_HOOKS_RECORD_COMMANDS=0` or `CLAUDE_FLOW_HOOKS_ENABLED=false`), so no CLI process is started per Bash call (#4056)diff --git a/plugins/ruflo-core/scripts/background-hooks.test.cjs b/plugins/ruflo-core/scripts/background-hooks.test.cjsnew file mode 100644index 0000000000..038f617464--- /dev/null+++ b/plugins/ruflo-core/scripts/background-hooks.test.cjs@@ -0,0 +1,118 @@+'use strict';+/**+ * #4128 (telemetry off the tool path) and #4176 (CLI runs from the project root).+ * Drives the real shim exactly as hooks.json does, against a slow fake CLI.+ */+const test = require('node:test');+const assert = require('node:assert/strict');+const fs = require('fs');+const os = require('os');+const path = require('path');+const { spawnSync } = require('child_process');++const SHIM = path.join(__dirname, 'ruflo-hook.cjs');+const SLOW = path.join(__dirname, 'fixtures', 'hook-cli-slow.cjs');+const dedupFreeEnv = (extra) => ({+ ...process.env,+ RUFLO_MODS_OWNS: '',+ RUFLO_DISABLE_HOOK_DEDUP: '1',+ RUFLO_HOOK_SKIP_NPX: '1',+ RUFLO_HOOK_CLI_OVERRIDE: `"${process.execPath}" "${SLOW}"`,+ ...extra,+});+const sleep = (ms) => new Promise((r) => setTimeout(r, ms));+async function waitFor(file, ms = 8000) {+ const end = Date.now() + ms;+ while (Date.now() < end) { if (fs.existsSync(file)) return JSON.parse(fs.readFileSync(file, 'utf8')); await sleep(50); }+ return null;+}+function runShim(subcommand, event, env, cwd) {+ const t0 = Date.now();+ const r = spawnSync(process.execPath, [SHIM, subcommand], { input: JSON.stringify(event), env, cwd, encoding: 'utf8', timeout: 20_000 });+ return { ms: Date.now() - t0, status: r.status, stdout: r.stdout };+}+const tmp = (name) => fs.mkdtempSync(path.join(os.tmpdir(), name));++test('post-command returns before a slow CLI finishes, and the CLI still gets argv and stdin (#4128)', async () => {+ const work = tmp('rf-bg-'); const out = path.join(work, 'out.json');+ const env = dedupFreeEnv({ HOOK_SLOW_OUT: out, HOOK_SLOW_MS: '2500', RUFLO_HOOK_TMP_DIR: work });+ const event = { tool_input: { command: 'echo hi' }, tool_response: { exit_code: 0 } };+ const r = runShim('post-command', event, env, work);+ assert.equal(r.status, 0);+ assert.ok(r.ms < 1800, `shim took ${r.ms} ms, expected well under the CLI's 2500 ms`);+ assert.equal(fs.existsSync(out), false, 'CLI has not finished yet');+ const got = await waitFor(out);+ assert.ok(got, 'the detached CLI completed');+ assert.deepEqual(got.argv, ['hooks', 'post-command', '-c', 'echo hi', '-s', 'true', '-e', '0']);+ assert.deepEqual(JSON.parse(got.stdin), event);+});++test('PreToolUse telemetry is detached too and the verdict is still printed (#4128)', async () => {+ const work = tmp('rf-bg-'); const out = path.join(work, 'out.json');+ const env = dedupFreeEnv({ HOOK_SLOW_OUT: out, HOOK_SLOW_MS: '2500', RUFLO_HOOK_TMP_DIR: work });+ const r = runShim('modify-bash', { tool_input: { command: 'ls' } }, env, work);+ assert.equal(r.stdout, '{"permission":"allow"}');+ assert.ok(r.ms < 1800, `shim took ${r.ms} ms`);+ assert.ok(await waitFor(out), 'CLI still ran');+});++test('RUFLO_HOOK_SYNC=1 restores the synchronous path', () => {+ const work = tmp('rf-bg-'); const out = path.join(work, 'out.json');+ const env = dedupFreeEnv({ HOOK_SLOW_OUT: out, HOOK_SLOW_MS: '600', RUFLO_HOOK_SYNC: '1', RUFLO_HOOK_TMP_DIR: work });+ const r = runShim('post-command', { tool_input: { command: 'x' }, tool_response: { exit_code: 0 } }, env, work);+ assert.equal(r.status, 0);+ assert.equal(fs.existsSync(out), true, 'the CLI had finished when the shim returned');+});++test('the CLI runs from CLAUDE_PROJECT_DIR, not the shell directory the session cd-ed into (#4176)', async () => {+ const project = fs.realpathSync(tmp('rf-proj-')); const sub = path.join(project, 'sub', 'deep');+ fs.mkdirSync(sub, { recursive: true });+ const out = path.join(project, 'out.json');+ const env = dedupFreeEnv({ HOOK_SLOW_OUT: out, HOOK_SLOW_MS: '50', CLAUDE_PROJECT_DIR: project, RUFLO_HOOK_TMP_DIR: project });+ runShim('post-command', { tool_input: { command: 'x' }, tool_response: { exit_code: 0 } }, env, sub);+ const got = await waitFor(out);+ assert.ok(got, 'CLI ran');+ assert.equal(fs.realpathSync(got.cwd), project);+});++test('an unusable CLAUDE_PROJECT_DIR is ignored and the process cwd is kept (#4176)', async () => {+ const work = fs.realpathSync(tmp('rf-cwd-')); const out = path.join(work, 'out.json');+ for (const bad of ['relative/dir', path.join(work, 'does-not-exist'), path.join(work, 'out-file')]) {+ fs.rmSync(out, { force: true }); fs.writeFileSync(path.join(work, 'out-file'), 'x');+ const env = dedupFreeEnv({ HOOK_SLOW_OUT: out, HOOK_SLOW_MS: '50', CLAUDE_PROJECT_DIR: bad, RUFLO_HOOK_TMP_DIR: work });+ runShim('post-command', { tool_input: { command: 'x' }, tool_response: { exit_code: 0 } }, env, work);+ const got = await waitFor(out);+ assert.ok(got, `CLI ran for ${bad}`);+ assert.equal(fs.realpathSync(got.cwd), work);+ }+});++test('a burst over the concurrency cap drops telemetry instead of spawning without limit (#4128)', async () => {+ const work = tmp('rf-cap-');+ const outs = [0, 1, 2, 3, 4, 5].map((i) => path.join(work, `o${i}.json`));+ const results = outs.map((o) => runShim('post-command', { tool_input: { command: 'c' }, tool_response: { exit_code: 0 } },+ dedupFreeEnv({ HOOK_SLOW_OUT: o, HOOK_SLOW_MS: '3000', RUFLO_HOOK_MAX_PARALLEL: '2', RUFLO_HOOK_TMP_DIR: work }), work));+ assert.ok(results.every((r) => r.status === 0), 'no shim ever fails the turn');+ await sleep(4500);+ const finished = outs.filter((o) => fs.existsSync(o)).length;+ assert.equal(finished, 2, `exactly the cap of 2 ran, got ${finished}`);+});++test('a freed slot is reused: after the CLIs exit the next event runs again', async () => {+ const work = tmp('rf-reuse-'); const out = path.join(work, 'o.json');+ const env = dedupFreeEnv({ HOOK_SLOW_OUT: out, HOOK_SLOW_MS: '150', RUFLO_HOOK_MAX_PARALLEL: '1', RUFLO_HOOK_TMP_DIR: work });+ const ev = { tool_input: { command: 'c' }, tool_response: { exit_code: 0 } };+ runShim('post-command', ev, env, work);+ assert.ok(await waitFor(out), 'first ran');+ await sleep(300); fs.rmSync(out, { force: true });+ runShim('post-command', ev, env, work);+ assert.ok(await waitFor(out), 'second ran after the first exited');+});++test('session-end is never dropped by the cap', async () => {+ const work = tmp('rf-stop-'); const out = path.join(work, 'o.json');+ const base = { HOOK_SLOW_MS: '3000', RUFLO_HOOK_MAX_PARALLEL: '1', RUFLO_HOOK_TMP_DIR: work };+ runShim('post-command', { tool_input: { command: 'c' }, tool_response: { exit_code: 0 } }, dedupFreeEnv({ ...base, HOOK_SLOW_OUT: path.join(work, 'x.json') }), work);+ runShim('session-end', {}, dedupFreeEnv({ ...base, HOOK_SLOW_MS: '100', HOOK_SLOW_OUT: out }), work);+ assert.ok(await waitFor(out), 'session-end ran although the single slot was busy');+});diff --git a/plugins/ruflo-core/scripts/fixtures/hook-cli-slow.cjs b/plugins/ruflo-core/scripts/fixtures/hook-cli-slow.cjsnew file mode 100644index 0000000000..59ec0412d6--- /dev/null+++ b/plugins/ruflo-core/scripts/fixtures/hook-cli-slow.cjs@@ -0,0 +1,11 @@+// Test fixture: a "CLI" that is slow like a cold ruflo start and records what it+// received (argv, cwd, stdin) so a test can prove the hook shim returned first+// and still delivered everything (#4128, #4176).+const fs = require('fs');+const out = process.env.HOOK_SLOW_OUT;+const delay = Number(process.env.HOOK_SLOW_MS || 1500);+let stdin = '';+try { stdin = fs.readFileSync(0, 'utf8'); } catch { /* no stdin */ }+setTimeout(() => {+ if (out) fs.writeFileSync(out, JSON.stringify({ argv: process.argv.slice(2), cwd: process.cwd(), stdin }));+}, delay);diff --git a/plugins/ruflo-core/scripts/ruflo-hook.cjs b/plugins/ruflo-core/scripts/ruflo-hook.cjsindex 8f28ecaeab..4812309d98 100644--- a/plugins/ruflo-core/scripts/ruflo-hook.cjs+++ b/plugins/ruflo-core/scripts/ruflo-hook.cjs@@ -40,7 +40,7 @@'use strict';-const { spawnSync } = require('child_process');+const { spawn, spawnSync } = require('child_process');const fs = require('fs');const path = require('path');const os = require('os');@@ -66,6 +66,105 @@ function npxPrefix(env = process.env) {return envValue(env, 'CLAUDE_PLUGIN_DATA') || envValue(env, 'PLUGIN_DATA') || require('os').homedir();}+/**+ * #4176: run the CLI from the project root, not from wherever the session's+ * shell last `cd`ed to. Claude Code keeps a `cd` across Bash calls, so without+ * an explicit cwd every hook spawned the CLI inside a subdirectory and the CLI+ * wrote .claude-flow/ and proven-config state there. CLAUDE_PROJECT_DIR is the+ * host's own statement of the project root; anything that is not an existing+ * absolute directory is ignored (the CLI then keeps the process cwd, as before).+ */+function projectCwd(env = process.env) {+ const dir = envValue(env, 'CLAUDE_PROJECT_DIR');+ if (!dir || !path.isAbsolute(dir)) return undefined;+ try { return fs.statSync(dir).isDirectory() ? dir : undefined; } catch { return undefined; }+}++/**+ * #4128: telemetry must not sit on the tool path. Measured 0.9 s per PreToolUse+ * and 1.5-4 s per PostToolUse (a cold CLI start each time). Unless a test asks+ * for the synchronous path (RUFLO_HOOK_DEBUG_STDOUT=1 or RUFLO_HOOK_SYNC=1) the+ * CLI is started detached and the shim returns at once. Two guards keep that+ * from becoming a process storm in a tool-call burst: a small slot table (the+ * default of 4 concurrent telemetry CLIs, RUFLO_HOOK_MAX_PARALLEL to change it;+ * over the cap an event is dropped, because this is best-effort telemetry) and a+ * 0600 temp file that carries the event JSON to the child's stdin, so the shim+ * can exit without waiting for a pipe to drain.+ */+function backgroundEnabled(env = process.env) {+ if ((envValue(env, 'RUFLO_HOOK_DEBUG_STDOUT') || '') === '1') return false;+ return !/^(1|true|yes|on)$/i.test(envValue(env, 'RUFLO_HOOK_SYNC') || '');+}++function hookTempDir(name, env = process.env) {+ return path.join(envValue(env, 'RUFLO_HOOK_TMP_DIR') || os.tmpdir(), name);+}++function pidAlive(pid) {+ if (!Number.isSafeInteger(pid) || pid <= 0) return false;+ try { process.kill(pid, 0); return true; } catch (error) { return error?.code === 'EPERM'; }+}++/** Claim one of N slots for this project. Returns {release(pid)} or null when all are busy. */+function acquireSlot(env = process.env, keepAlways = false) {+ const max = Math.max(1, Math.min(32, Number.parseInt(envValue(env, 'RUFLO_HOOK_MAX_PARALLEL') || '4', 10) || 4));+ try {+ const project = crypto.createHash('sha256').update(path.resolve(projectCwd(env) || process.cwd())).digest('hex').slice(0, 16);+ const dir = path.join(hookTempDir('ruflo-hook-slots-v1', env), project);+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });+ for (let i = 0; i < max; i++) {+ const file = path.join(dir, 'slot-' + i);+ for (let attempt = 0; attempt < 2; attempt++) {+ try {+ const fd = fs.openSync(file, 'wx', 0o600);+ fs.writeSync(fd, String(Date.now()));+ fs.closeSync(fd);+ return { file };+ } catch (error) {+ if (error?.code !== 'EEXIST') return keepAlways ? { file: null } : null;+ // Reclaim a slot whose CLI is gone (pid recorded after spawn) or that is stale.+ let content = '';+ try { content = fs.readFileSync(file, 'utf8'); } catch { continue; }+ const [stamp, pid] = content.split(':');+ const age = Date.now() - Number(stamp);+ const dead = pid !== undefined && !pidAlive(Number(pid));+ if (dead || !(age < 120_000)) { try { fs.unlinkSync(file); } catch { /* raced */ } continue; }+ break;+ }+ }+ }+ return keepAlways ? { file: null } : null;+ } catch {+ return keepAlways ? { file: null } : null; // cannot track: run, never block the turn+ }+}++function recordSlotPid(slot, pid) {+ if (!slot?.file || !pid) return;+ try { fs.writeFileSync(slot.file, Date.now() + ':' + pid, { mode: 0o600 }); } catch { /* best effort */ }+}++/** Write the event to a private temp file and hand back a read fd for the child's stdin. */+function stdinFd(input, env = process.env) {+ const dir = hookTempDir('ruflo-hook-stdin-v1', env);+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });+ const file = path.join(dir, crypto.randomBytes(12).toString('hex'));+ fs.writeFileSync(file, input || '', { mode: 0o600 });+ const fd = fs.openSync(file, 'r');+ return { fd, file };+}++/** Delete stdin files older than an hour (Windows cannot unlink a file still open in the child). */+function sweepStdinFiles(env = process.env) {+ try {+ const dir = hookTempDir('ruflo-hook-stdin-v1', env);+ for (const name of fs.readdirSync(dir)) {+ const file = path.join(dir, name);+ try { if (Date.now() - fs.statSync(file).mtimeMs > 3_600_000) fs.unlinkSync(file); } catch { /* raced */ }+ }+ } catch { /* none */ }+}+/*** Locate a command on PATH using fs only.*@@ -183,6 +282,51 @@ function escapeCmdArg(arg) {return s.replace(/[()%!^"<>&|;,]/g, '^$&');}+/**+ * Start the CLI detached (see backgroundEnabled) and return at once. Same+ * resolution rules as the synchronous path: no shell where one can be avoided,+ * every element escaped where cmd.exe is unavoidable. Returns true when a CLI+ * was started, false when the event was dropped over the concurrency cap or the+ * start failed. Never throws.+ */+function invokeBackground(bin, binArgs, hookSubcommand, hookArgs, stdinData, { env, platform, cwd, keep }) {+ let slot = null;+ let input = null;+ try {+ slot = acquireSlot(env, keep);+ if (!slot) return false;+ const args = [...binArgs, 'hooks', hookSubcommand, ...hookArgs];+ const invocation = resolveInvocation(bin, binArgs, { env, platform });+ const useShell = !invocation && platform === 'win32' && bin !== 'node' && bin !== process.execPath;+ input = stdinFd(stdinData, env);+ const child = spawn(+ invocation ? invocation.command : (useShell ? escapeCmdArg(bin) : bin),+ invocation ? [...invocation.args, 'hooks', hookSubcommand, ...hookArgs] : (useShell ? args.map(escapeCmdArg) : args),+ {+ stdio: [input.fd, 'ignore', 'ignore'],+ env,+ ...(cwd ? { cwd } : {}),+ detached: true,+ windowsHide: true,+ shell: useShell,+ },+ );+ child.on('error', () => { /* best effort: the host never sees a hook failure */ });+ child.unref();+ recordSlotPid(slot, child.pid);+ return true;+ } catch {+ if (slot?.file) { try { fs.unlinkSync(slot.file); } catch { /* none */ } }+ return false;+ } finally {+ if (input) {+ try { fs.closeSync(input.fd); } catch { /* closed */ }+ try { fs.unlinkSync(input.file); } catch { /* Windows keeps it until the child exits; swept later */ }+ if (Math.random() < 0.05) sweepStdinFiles(env);+ }+ }+}+/*** Spawn the CLI with the hook subcommand + args, forwarding stdinData.* Returns true on success (exit 0), false otherwise. Never throws.@@ -197,14 +341,18 @@ function invokeHook(bin, binArgs, hookSubcommand, hookArgs, stdinData, options =// flag-wiring regressions). Production never sets this β hooks must// never leak CLI output into the host (Cursor's PreToolUse contract).const debug = (envValue(env, 'RUFLO_HOOK_DEBUG_STDOUT') || '') === '1';+ const cwd = projectCwd(env);const base = {input: stdinData || '',encoding: 'utf8',stdio: debug ? ['pipe', 'pipe', 'pipe'] : ['pipe', 'ignore', 'ignore'],timeout: 30_000,env,+ ...(cwd ? { cwd } : {}),};+ const background = options.background === true && backgroundEnabled(env);try {+ if (background) return invokeBackground(bin, binArgs, hookSubcommand, hookArgs, stdinData, { env, platform, cwd, keep: options.keep === true });// Layer 1 β no shell. resolveInvocation() maps the command to a real// executable, and on Windows maps npm's .cmd/.ps1 shim to the .js// entrypoint it wraps, so this becomes `node <entry>` and CreateProcess@@ -257,6 +405,8 @@ function splitCliOverride(str) {/** Best-effort: try ruflo, then claude-flow, then npx. Never throws. */function invokeCli(hookSubcommand, hookArgs, stdinData) {+ // Telemetry runs detached (#4128); Stop is never dropped by the concurrency cap.+ const options = { background: true, keep: hookSubcommand === 'session-end' };// Test-only escape hatch: point at a specific local build instead of the// commandExists() PATH probe (used by test-hooks.mjs and the plugin-hooks// real-command smoke so tests exercise the build under test, not whatever@@ -265,15 +415,15 @@ function invokeCli(hookSubcommand, hookArgs, stdinData) {const override = process.env.RUFLO_HOOK_CLI_OVERRIDE;if (override) {const [bin, ...binArgs] = splitCliOverride(override);- invokeHook(bin, binArgs, hookSubcommand, hookArgs, stdinData);+ invokeHook(bin, binArgs, hookSubcommand, hookArgs, stdinData, options);return;}if (resolveCommandPath('ruflo')) {- invokeHook('ruflo', [], hookSubcommand, hookArgs, stdinData);+ invokeHook('ruflo', [], hookSubcommand, hookArgs, stdinData, options);return;}if (resolveCommandPath('claude-flow')) {- invokeHook('claude-flow', [], hookSubcommand, hookArgs, stdinData);+ invokeHook('claude-flow', [], hookSubcommand, hookArgs, stdinData, options);return;}// SKIP npx when RUFLO_HOOK_SKIP_NPX=1 β used by CI smokes that test the@@ -283,7 +433,7 @@ function invokeCli(hookSubcommand, hookArgs, stdinData) {// itself works correctly. The bash version doesn't hit this because it// backgrounded the work.if (process.env.RUFLO_HOOK_SKIP_NPX !== '1') {- invokeHook('npx', ['--prefer-offline', '--yes', '--prefix', npxPrefix(), 'ruflo@latest'], hookSubcommand, hookArgs, stdinData);+ invokeHook('npx', ['--prefer-offline', '--yes', '--prefix', npxPrefix(), 'ruflo@latest'], hookSubcommand, hookArgs, stdinData, options);}}@@ -499,4 +649,4 @@ if (process.env.RUFLO_HOOK_UNIT_TEST !== '1') {main();}-module.exports = { commandRecordingOff, escapeCmdArg, invokeHook, npxPrefix, resolveCommandPath, resolveInvocation, resolveNpmShim };+module.exports = { acquireSlot, backgroundEnabled, commandRecordingOff, escapeCmdArg, projectCwd, invokeHook, npxPrefix, resolveCommandPath, resolveInvocation, resolveNpmShim };diff --git a/plugins/ruflo-core/scripts/smoke.sh b/plugins/ruflo-core/scripts/smoke.shindex f406f556f4..aa3c9c8a19 100755--- a/plugins/ruflo-core/scripts/smoke.sh+++ b/plugins/ruflo-core/scripts/smoke.sh@@ -1,5 +1,5 @@#!/usr/bin/env bash-# Structural smoke test for ruflo-core v0.2.8 (ADR-0001).+# Structural smoke test for ruflo-core v0.2.9 (ADR-0001).set -uROOT="$(cd "$(dirname "$0")/.." && pwd)"PASS=0@@ -8,10 +8,10 @@ step() { printf "β %s ... " "$1"; }ok() { printf "PASS\n"; PASS=$((PASS+1)); }bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }-step "1. plugin.json declares 0.2.8 with new keywords"+step "1. plugin.json declares 0.2.9 with new keywords"v=$(grep -E '"version"' "$ROOT/.claude-plugin/plugin.json" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)-if [[ "$v" != "0.2.8" ]]; then- bad "expected 0.2.8, got '$v'"+if [[ "$v" != "0.2.9" ]]; then+ bad "expected 0.2.9, got '$v'"elsemiss=""for k in foundation mcp-server plugin-catalog discovery; dodiff --git a/scripts/ci-test-excluded.txt b/scripts/ci-test-excluded.txtindex f7fa8e4d27..7ddac5069f 100644--- a/scripts/ci-test-excluded.txt+++ b/scripts/ci-test-excluded.txt@@ -95,5 +95,6 @@ plugins/ruflo-swarm/tests/toast.test.tsplugins/ruflo-mods/tests/protector.test.tsplugins/ruflo-mods/tests/selfcheck.test.tsplugins/ruflo-testgen/scripts/tdd-repair/tdd-repair.test.mjs+plugins/ruflo-core/scripts/background-hooks.test.cjsplugins/ruflo-core/scripts/command-recording-switch.test.cjstests/regression/oct12-coverage.test.cjsdiff --git a/v3/@claude-flow/cli/__tests__/proven-config-refresh.test.ts b/v3/@claude-flow/cli/__tests__/proven-config-refresh.test.tsindex 74c960eaa8..c047e399a2 100644--- a/v3/@claude-flow/cli/__tests__/proven-config-refresh.test.ts+++ b/v3/@claude-flow/cli/__tests__/proven-config-refresh.test.ts@@ -7,7 +7,7 @@ import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync } fromimport { join } from 'node:path';import { tmpdir } from 'node:os';import { generateKeyPairSync } from 'node:crypto';-import { adoptSignedConfig, PROVEN_CONFIG_STAMP, ADOPTED_CONFIG_FILE } from '../src/config/proven-config-refresh.js';+import { adoptSignedConfig, isRufloProject, PROVEN_CONFIG_STAMP, ADOPTED_CONFIG_FILE } from '../src/config/proven-config-refresh.js';import { signProvenConfig, type ProvenConfigManifest, type InstallEnv } from '../src/config/proven-config.js';const kp = generateKeyPairSync('ed25519', { publicKeyEncoding: { type: 'spki', format: 'pem' }, privateKeyEncoding: { type: 'pkcs8', format: 'pem' } });@@ -27,6 +27,7 @@ const env: InstallEnv = { platform: 'darwin', versions: { ruflo: '3.24.0' } };function project(): string {const cwd = mkdtempSync(join(tmpdir(), 'pcfg-'));mkdirSync(join(cwd, '.claude'), { recursive: true });+ writeFileSync(join(cwd, '.claude', 'settings.json'), '{}'); // ruflo init's marker (#4176)return cwd;}@@ -68,6 +69,27 @@ describe('adoptSignedConfig (ADR-177 propagation)', () => {expect(r.skipped).toBeUndefined();});+ it('is a no-op in a directory Claude Code created .claude/.cc-writes in (#4176)', () => {+ const cwd = mkdtempSync(join(tmpdir(), 'cc-only-'));+ mkdirSync(join(cwd, '.claude', '.cc-writes'), { recursive: true });+ const r = adoptSignedConfig(cwd, signProvenConfig(manifest(), kp.privateKey), env, { pubkeyPem: kp.publicKey });+ expect(r.adopted).toBe(false);+ expect(existsSync(join(cwd, '.claude', ADOPTED_CONFIG_FILE))).toBe(false);+ expect(existsSync(join(cwd, '.claude', PROVEN_CONFIG_STAMP))).toBe(false);+ });++ it('isRufloProject: init markers count, a bare or Claude-Code-only .claude does not (#4176)', () => {+ const bare = mkdtempSync(join(tmpdir(), 'bare-')); mkdirSync(join(bare, '.claude'));+ expect(isRufloProject(bare)).toBe(false);+ const helpers = mkdtempSync(join(tmpdir(), 'helpers-')); mkdirSync(join(helpers, '.claude', 'helpers'), { recursive: true });+ expect(isRufloProject(helpers)).toBe(true);+ const stamped = mkdtempSync(join(tmpdir(), 'stamped-')); mkdirSync(join(stamped, '.claude'));+ writeFileSync(join(stamped, '.claude', PROVEN_CONFIG_STAMP), 'x');+ expect(isRufloProject(stamped)).toBe(true);+ expect(isRufloProject(project())).toBe(true);+ expect(isRufloProject(join(tmpdir(), 'does-not-exist-4176'))).toBe(false);+ });+it('is a no-op outside a ruflo project (no .claude)', () => {const cwd = mkdtempSync(join(tmpdir(), 'not-ruflo-'));const r = adoptSignedConfig(cwd, signProvenConfig(manifest(), kp.privateKey), env, { pubkeyPem: kp.publicKey });diff --git a/v3/@claude-flow/cli/__tests__/proven-config-rvfa.test.ts b/v3/@claude-flow/cli/__tests__/proven-config-rvfa.test.tsindex 589b1a1ab8..0b3672a2f3 100644--- a/v3/@claude-flow/cli/__tests__/proven-config-rvfa.test.ts+++ b/v3/@claude-flow/cli/__tests__/proven-config-rvfa.test.ts@@ -71,6 +71,7 @@ describe('adopt path parity β RVFA-packed champion adopts like raw JSON', () =const cwd = mkdtempSync(join(tmpdir(), 'pcrvfa-'));mkdirSync(join(cwd, '.claude'), { recursive: true });+ writeFileSync(join(cwd, '.claude', 'settings.json'), '{}'); // ruflo init marker (#4176)const rvfPath = join(cwd, PROVEN_CONFIG_RVFA_FILE);writeFileSync(rvfPath, packProvenConfigRvfa(signed));diff --git a/v3/@claude-flow/cli/src/config/proven-config-refresh.ts b/v3/@claude-flow/cli/src/config/proven-config-refresh.tsindex 99a3ab8a77..fb51b40d49 100644--- a/v3/@claude-flow/cli/src/config/proven-config-refresh.ts+++ b/v3/@claude-flow/cli/src/config/proven-config-refresh.ts@@ -84,6 +84,26 @@ export function currentInstallEnv(cwd: string = process.cwd()): InstallEnv {return env;}+/**+ * #4176: is `cwd` a ruflo project? A bare `.claude/` is not enough: Claude Code+ * itself creates `.claude/.cc-writes/` in whatever directory a Bash command ran+ * in, so every subdirectory a session cd-ed into used to qualify and received a+ * proven-config.json. A ruflo project carries `ruflo init`'s own markers: a+ * `.claude/settings.json`, the `.claude/helpers/` directory, or an earlier+ * adoption stamp.+ */+export function isRufloProject(cwd: string): boolean {+ try {+ const claudeDir = path.join(cwd, '.claude');+ if (!fs.statSync(claudeDir).isDirectory()) return false;+ return fs.existsSync(path.join(claudeDir, 'settings.json'))+ || fs.existsSync(path.join(claudeDir, 'helpers'))+ || fs.existsSync(path.join(claudeDir, PROVEN_CONFIG_STAMP));+ } catch {+ return false;+ }+}+export interface AdoptResult { adopted: boolean; from?: string; to?: string; reason?: string; skipped?: string }/**@@ -99,7 +119,7 @@ export function adoptSignedConfig(): AdoptResult {try {const claudeDir = path.join(cwd, '.claude');- if (!fs.existsSync(claudeDir)) return { adopted: false }; // not a ruflo project+ if (!isRufloProject(cwd)) return { adopted: false }; // not a ruflo project (#4176)const championId = signed.manifest?.policy?.ref;if (!championId) return { adopted: false, skipped: 'manifest missing policy.ref' };@@ -135,7 +155,7 @@ export function adoptSignedConfig(*/export async function autoAdoptProvenConfigIfStale(cwd: string = process.cwd()): Promise<AdoptResult> {try {- if (!fs.existsSync(path.join(cwd, '.claude'))) return { adopted: false };+ if (!isRufloProject(cwd)) return { adopted: false };const src = findPackageProvenConfig();if (!src) return { adopted: false }; // no champion ships β no-op (additive)const signed = loadShippedChampion(src);