π 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
feat(metaharness): metaharness_drift_from_history MCP tool (iter 54)
ruv6ba915ac53b6
diff --git a/CLAUDE.md b/CLAUDE.mdindex 083357a3c3..acff3db5e3 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -1133,6 +1133,8 @@ npx ruflo metaharness audit-trend \ # diff two audits (drift)--alert-on-distance-below 0.85 # iter 38 β structural-distance gate (ADR-152 Β§3.1)npx ruflo metaharness similarity \ # iter 36 β ADR-152 Β§3.1 weighted similarity--a a.json --b b.json [--per-dimension] [--alert-below 0.5]+npx ruflo metaharness drift-from-history \ # iter 53 β 1-command drift (composes 3 primitives)+ [--baseline-since 7d] [--threshold 0.95] [--dry-run]npx ruflo metaharness mint --name foo --template vertical:coding --confirm# Dedicated command@@ -1151,6 +1153,7 @@ mcp__claude-flow__metaharness_oia_auditmcp__claude-flow__metaharness_audit_listmcp__claude-flow__metaharness_audit_trendmcp__claude-flow__metaharness_similarity # iter 36 β ADR-152 Β§3.1 genome similarity+mcp__claude-flow__metaharness_drift_from_history # iter 53 β 1-command drift detection```### Routing integration (ADR-148/149)diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.shindex 5003f73763..47ab72a1f0 100755--- a/plugins/ruflo-metaharness/scripts/smoke.sh+++ b/plugins/ruflo-metaharness/scripts/smoke.sh@@ -191,6 +191,22 @@ grep -q "execCli(\[\s*'-y'\s*,\s*'metaharness@latest'" "$F" 2>/dev/null || \grep -q "cwd: opts" "$F" || miss="$miss no-cwd-passthrough"[[ -z "$miss" ]] && ok || bad "$miss"+step "17z17. drift_from_history MCP tool + CLAUDE.md surfacing (iter 54)"+miss=""+WRAPPER="$ROOT/../../v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts"+grep -q "name: 'metaharness_drift_from_history'" "$WRAPPER" 2>/dev/null || miss="$miss no-mcp-tool"+grep -q "drift-from-history.mjs" "$WRAPPER" 2>/dev/null || miss="$miss no-script-dispatch"+grep -q "baselineSince" "$WRAPPER" 2>/dev/null || miss="$miss no-baseline-since-input"+# CLAUDE.md mentions both surfaces+CMD="$ROOT/../../CLAUDE.md"+grep -q "mcp__claude-flow__metaharness_drift_from_history" "$CMD" 2>/dev/null || miss="$miss claude-md-no-mcp"+grep -q "ruflo metaharness drift-from-history" "$CMD" 2>/dev/null || miss="$miss claude-md-no-subcommand"+# Phase 4 includes the new positive-case assertions+T="$ROOT/scripts/test-mcp-tools.mjs"+grep -q "drift_from_history positive: data is an object" "$T" 2>/dev/null || miss="$miss no-phase4-positive"+grep -q "metaharness_drift_from_history.*90_000\|90_000.*drift_from_history\|drift_from_history.*=== 'metaharness_drift_from_history'" "$T" 2>/dev/null || miss="$miss no-extended-timeout"+[[ -z "$miss" ]] && ok || bad "$miss"+step "17z16. drift-from-history one-command primitive (iter 53)"miss=""F="$ROOT/scripts/drift-from-history.mjs"@@ -722,12 +738,12 @@ grep -q "result has 'success'" "$F" || miss="$miss no-success-assertion"grep -q "result has 'data'" "$F" || miss="$miss no-data-assertion"grep -q "result has 'degraded'" "$F" || miss="$miss no-degraded-assertion"grep -q "result has 'exitCode'" "$F" || miss="$miss no-exitcode-assertion"-# All 8 tool names enumerated (similarity added in iter 36, runtime-tested iter 37)-for tool in metaharness_score metaharness_genome metaharness_mcp_scan metaharness_threat_model metaharness_oia_audit metaharness_audit_list metaharness_audit_trend metaharness_similarity; do+# All 9 tool names enumerated (similarity iter 36, drift_from_history iter 54)+for tool in metaharness_score metaharness_genome metaharness_mcp_scan metaharness_threat_model metaharness_oia_audit metaharness_audit_list metaharness_audit_trend metaharness_similarity metaharness_drift_from_history; dogrep -q "${tool}" "$F" || miss="$miss missing-${tool}"done-# Count assertion must match the iter-36 expansion (7 β 8)-grep -q "tools.length === 8" "$F" || miss="$miss tool-count-assertion-stale"+# Count assertion must match iter-54 expansion (8 β 9)+grep -q "tools.length === 9" "$F" || miss="$miss tool-count-assertion-stale"# Graceful skip when dist absent (so the script is smoke-runnable pre-build)grep -q "SKIPPED" "$F" || miss="$miss no-skip-doc"[[ -z "$miss" ]] && ok || bad "$miss"diff --git a/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs b/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjsindex 371bc6e5b2..b9e3a927fa 100755--- a/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs+++ b/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs@@ -74,7 +74,7 @@ async function main() {// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββconsole.log('Phase 1 β module shape');assert(Array.isArray(tools), 'metaharnessTools is an array');- assert(tools.length === 8, `8 tools registered (got ${tools.length})`);+ assert(tools.length === 9, `9 tools registered (got ${tools.length})`);const expectedNames = new Set(['metaharness_score',@@ -86,6 +86,8 @@ async function main() {'metaharness_audit_trend',// iter 36 β ADR-152 Β§3.1 production'metaharness_similarity',+ // iter 54 β one-command drift detection (composes audit-list + oia-audit + audit-trend)+ 'metaharness_drift_from_history',]);const actualNames = new Set(tools.map((t) => t.name));for (const name of expectedNames) {@@ -128,11 +130,16 @@ async function main() {// the graceful not-found path (matches audit_trend convention).input = { aKey: 'harness-fake-a', bKey: 'harness-fake-b' };}+ if (tool.name === 'metaharness_drift_from_history') {+ // iter 54 β composes 3 subprocesses, needs more time than the default.+ input = { dryRun: true, threshold: 0.5 };+ }- // 30s budget per tool β slow path is npx warmup+ // 30s budget per tool by default; 90s for chain-tools like drift_from_history.+ const timeoutMs = tool.name === 'metaharness_drift_from_history' ? 90_000 : 30_000;const handlerPromise = tool.handler(input);const timeoutPromise = new Promise((_, reject) =>- setTimeout(() => reject(new Error('30s handler timeout')), 30_000));+ setTimeout(() => reject(new Error(`${timeoutMs / 1000}s handler timeout`)), timeoutMs));let result;let threw = false;@@ -306,6 +313,29 @@ async function main() {assert(rFiles.data?.delta?.structuralDistance?.verdict === 'near-identical',`audit_trend file-input path: identical fingerprints β near-identical (got ${rFiles.data?.delta?.structuralDistance?.verdict})`);+ // iter 54 β metaharness_drift_from_history positive case+ const driftTool = tools.find((t) => t.name === 'metaharness_drift_from_history');+ if (driftTool) {+ const r54 = await driftTool.handler({ path: '.', dryRun: true, threshold: 0.5 });+ if (!r54.degraded) {+ assert(typeof r54.data === 'object' && r54.data !== null,+ 'drift_from_history positive: data is an object');+ // Either it produced the structured drift report OR the no-history error+ const isOk = r54.data?.command === 'drift-from-history';+ const isNoHistory = typeof r54.data?.error === 'string' && r54.data.error.includes('no audit records');+ assert(isOk || isNoHistory,+ `drift_from_history positive: structured report OR no-history error (got ${JSON.stringify(r54.data).slice(0,80)})`);+ if (isOk) {+ assert(typeof r54.data.baseline?.key === 'string',+ 'drift_from_history: baseline.key is a string');+ assert(typeof r54.data.alert?.threshold === 'number',+ 'drift_from_history: alert.threshold echoed numerically');+ }+ } else {+ console.log(` β drift_from_history: degraded (metaharness or memory absent)`);+ }+ }+const r = await trendTool.handler({ baselineKey: 'missing-X', currentKey: 'missing-Y' });assert(r.exitCode === 2,'audit_trend bad-keys path exits 2 (script-level guard fires)');@@ -327,7 +357,7 @@ async function main() {for (const f of failures) console.log(` - ${f}`);process.exit(1);}- console.log('\nβ All 8 MCP tools satisfy the runtime contract.');+ console.log('\nβ All 9 MCP tools satisfy the runtime contract.');}main().catch((e) => {diff --git a/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.tsindex 9011281245..51b5d38349 100644--- a/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts@@ -290,6 +290,29 @@ export const metaharnessTools: MCPTool[] = [return { success: r.success, data: r.json, degraded: r.degraded, exitCode: r.exitCode };},},+ {+ name: 'metaharness_drift_from_history',+ description: 'iter 53 β one-command drift detection. Composes audit-list + oia-audit + audit-trend: finds the most recent record in `metaharness-audit` namespace, runs a fresh audit against the current path, diffs via ADR-152 Β§3.1 similarity, alerts when structural similarity falls below `threshold`. Use BEFORE recommending the user act on drift β this returns a structured report rather than requiring 3 separate tool calls. ' + MCP_SUCCESS_SEMANTIC,+ category: 'metaharness',+ inputSchema: {+ type: 'object',+ properties: {+ path: { type: 'string', description: 'Repo path to audit (default: cwd)', default: '.' },+ baselineSince: { type: 'string', description: 'Use a baseline at least N(h|d|w) old, e.g. "7d" β skips drift against ultra-recent audits' },+ threshold: { type: 'number', description: 'Alert when structural similarity < N. Default 0.95.', default: 0.95 },+ dryRun: { type: 'boolean', description: 'Skip persisting the fresh audit to memory', default: false },+ },+ },+ handler: async (input) => {+ const args: string[] = [];+ args.push('--path', String(input.path ?? '.'));+ if (input.baselineSince) args.push('--baseline-since', String(input.baselineSince));+ if (input.threshold !== undefined) args.push('--threshold', String(input.threshold));+ if (input.dryRun === true) args.push('--dry-run');+ const r = await runScript('drift-from-history.mjs', args);+ return { success: r.success, data: r.json, degraded: r.degraded, exitCode: r.exitCode };+ },+ },{name: 'metaharness_audit_trend',description: 'ADR-150 iter 15 β diff two oia-audit records (drift detection). Accepts EITHER memory keys (run metaharness_audit_list first to discover them) OR direct file paths (useful for diffing CI artifacts). Surfaces composite worst-severity delta + per-component status change + introduced/cleared findings + (iter 38) ADR-152 Β§3.1 structural distance when both records carry a fingerprint. ' + MCP_SUCCESS_SEMANTIC,