mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
fix(3.7.0-alpha.13): persist headless results + ab-test guard
Closes #1793, #1652. #1793 — services/worker-daemon.ts: headless worker runs now persist their parsedOutput / output to the same metrics files the local fallback workers write to (.claude-flow/metrics/<name>.json). Previously the AI-mode branch returned the result and exited, leaving rich findings trapped in `.claude-flow/logs/headless/*_result.log` and invisible to `npx ruflo memory stats` and downstream consumers. Mapping mirrors the *Local methods: audit→security-audit.json, optimize→performance.json, testgaps→test-gaps.json, document→documentation.json, etc. Persisted record schema: { timestamp, mode:'headless', workerType, model, durationMs, tokensUsed, executionId, success, findings (= parsedOutput), rawOutputPreview (first 2KB), rawOutputLength }. Persistence is wrapped in try/catch so a write failure logs a warning but doesn't break the worker. #1652 — @claude-flow/guidance/src/analyzer.ts: abBenchmark now throws an actionable error when the provided executor is not content-aware instead of silently producing a guaranteed zero-delta verdict that costs ~$23 per run. The DefaultHeadlessExecutor IS content-aware as of @claude-flow/guidance@3.0.0-alpha.2 (it has `setContext` and physically swaps CLAUDE.md with backup/restore), so the guard only fires for caller-injected bare IHeadlessExecutor implementations. Verification: - @claude-flow/cli: 1963 tests pass / 0 fail / 46 skipped - @claude-flow/guidance: 1331 tests pass / 0 fail - Builds clean for both packages Published @claude-flow/cli@3.7.0-alpha.13, claude-flow@3.7.0-alpha.13, ruflo@3.7.0-alpha.13, and @claude-flow/guidance@3.0.0-alpha.3 with all dist-tags. Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
1 parent
1884ed1010
commit
c67fa393de
6 files changed
+79
-4
No files matched your search
+1
-1
@@ -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",
|
||||
|
||||
+1
-1
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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/<name>.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<Record<HeadlessWorkerType, string>> = {
|
||||
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<unknown> {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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('');
|
||||
|
||||
Reference in new issue
Block a user