diff --git a/package.json b/package.json index 726eb8a6d9..100ce1cfd7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "claude-flow", - "version": "3.7.0-alpha.12", + "version": "3.7.0-alpha.13", "description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration", "main": "dist/index.js", "type": "module", diff --git a/ruflo/package.json b/ruflo/package.json index aae98c8453..de3ed9178a 100644 --- a/ruflo/package.json +++ b/ruflo/package.json @@ -1,6 +1,6 @@ { "name": "ruflo", - "version": "3.7.0-alpha.12", + "version": "3.7.0-alpha.13", "description": "Ruflo - Enterprise AI agent orchestration platform. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration", "main": "bin/ruflo.js", "type": "module", diff --git a/v3/@claude-flow/cli/package.json b/v3/@claude-flow/cli/package.json index 81eada4779..37e8026216 100644 --- a/v3/@claude-flow/cli/package.json +++ b/v3/@claude-flow/cli/package.json @@ -1,6 +1,6 @@ { "name": "@claude-flow/cli", - "version": "3.7.0-alpha.12", + "version": "3.7.0-alpha.13", "type": "module", "description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code", "main": "dist/src/index.js", diff --git a/v3/@claude-flow/cli/src/services/worker-daemon.ts b/v3/@claude-flow/cli/src/services/worker-daemon.ts index af446cde7a..bf26333889 100644 --- a/v3/@claude-flow/cli/src/services/worker-daemon.ts +++ b/v3/@claude-flow/cli/src/services/worker-daemon.ts @@ -862,6 +862,16 @@ export class WorkerDaemon extends EventEmitter { try { this.log('info', `Running ${workerConfig.type} in headless mode (Claude Code AI)`); const result = await this.headlessExecutor.execute(workerConfig.type as HeadlessWorkerType); + // #1793: persist the headless result to the same metrics files the + // local workers write to. Without this, AI-mode runs produced rich + // parsedOutput that lived only in `.claude-flow/logs/headless/*` and + // never reached `.claude-flow/metrics/.json` — `memory stats` + // and downstream consumers saw nothing despite successful runs. + try { + this.persistHeadlessResult(workerConfig.type as HeadlessWorkerType, result); + } catch (persistError) { + this.log('warn', `Failed to persist headless result for ${workerConfig.type}: ${(persistError as Error).message}`); + } return { mode: 'headless', ...result, @@ -907,6 +917,59 @@ export class WorkerDaemon extends EventEmitter { } } + /** + * #1793: persist a headless worker result to the same metrics file the + * local fallback writes to. Without this, AI-mode workers produced rich + * structured output (audit findings, perf signals, test-gap analysis) + * that lived only in `.claude-flow/logs/headless/*_result.log` and was + * invisible to `npx ruflo memory stats` or the metrics consumers. + * + * The mapping mirrors the `*Local` worker implementations below so a + * single consumer path works regardless of execution mode. + */ + private persistHeadlessResult( + workerType: HeadlessWorkerType, + result: HeadlessExecutionResult, + ): void { + const metricsDir = join(this.projectRoot, '.claude-flow', 'metrics'); + if (!existsSync(metricsDir)) mkdirSync(metricsDir, { recursive: true }); + + // Filename mirrors the local-mode worker writes (security-audit.json, + // performance.json, test-gaps.json) so a downstream reader doesn't + // care which mode produced the data. + const filenameMap: Partial> = { + audit: 'security-audit.json', + optimize: 'performance.json', + testgaps: 'test-gaps.json', + document: 'documentation.json', + refactor: 'refactor.json', + deepdive: 'deepdive.json', + ultralearn: 'ultralearn.json', + predict: 'predictions.json', + }; + const filename = filenameMap[workerType] ?? `${workerType}.json`; + const metricsFile = join(metricsDir, filename); + + const persisted = { + timestamp: result.timestamp instanceof Date ? result.timestamp.toISOString() : new Date().toISOString(), + mode: 'headless' as const, + workerType, + model: result.model, + durationMs: result.durationMs, + tokensUsed: result.tokensUsed, + executionId: result.executionId, + success: result.success, + // Structured findings live here when the worker emits JSON (e.g. the + // audit worker's vulnerability list). Fall back to a raw-output + // pointer so consumers can still locate the full log. + findings: result.parsedOutput ?? null, + rawOutputPreview: typeof result.output === 'string' ? result.output.slice(0, 2000) : undefined, + rawOutputLength: typeof result.output === 'string' ? result.output.length : 0, + }; + + writeFileSync(metricsFile, JSON.stringify(persisted, null, 2)); + } + // Worker implementations private async runMapWorker(): Promise { diff --git a/v3/@claude-flow/guidance/package.json b/v3/@claude-flow/guidance/package.json index 711db727c1..7ad0d90929 100644 --- a/v3/@claude-flow/guidance/package.json +++ b/v3/@claude-flow/guidance/package.json @@ -1,6 +1,6 @@ { "name": "@claude-flow/guidance", - "version": "3.0.0-alpha.2", + "version": "3.0.0-alpha.3", "description": "Guidance Control Plane - Compiles, retrieves, enforces, and evolves guidance rules for Claude Code sessions", "type": "module", "main": "./dist/index.js", diff --git a/v3/@claude-flow/guidance/src/analyzer.ts b/v3/@claude-flow/guidance/src/analyzer.ts index 117a862453..e60d7b908a 100644 --- a/v3/@claude-flow/guidance/src/analyzer.ts +++ b/v3/@claude-flow/guidance/src/analyzer.ts @@ -3131,6 +3131,18 @@ export async function abBenchmark( const contentAware = isContentAwareExecutor(executor); + // #1652: a non-content-aware executor reads CLAUDE.md from disk for both + // configs, so the delta is architecturally guaranteed to be zero — yet + // the verdict implies the user's CLAUDE.md is ineffective. Detect and + // abort with a clear, actionable message before spending ~$23 in tokens + // on a meaningless run. The default executor IS content-aware, so this + // only triggers when callers inject a bare IHeadlessExecutor. + if (!contentAware) { + throw new Error( + 'abBenchmark requires a content-aware executor. The provided IHeadlessExecutor lacks `setContext()`, so Config A and Config B will both read the same on-disk CLAUDE.md and the delta is guaranteed to be zero. Either use the DefaultHeadlessExecutor (content-aware as of @claude-flow/guidance@3.0.0-alpha.2) or implement IContentAwareExecutor on your custom executor.', + ); + } + // ── Config A: No control plane ────────────────────────────────────── // For content-aware executors, set empty context (simulating no guidance) if (contentAware) executor.setContext('');