π 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): oia-audit composite worker β Phase 2 worker #13 (iter 7)
ruv88bff4759f03
diff --git a/plugins/ruflo-metaharness/agents/metaharness-architect.md b/plugins/ruflo-metaharness/agents/metaharness-architect.mdindex 8953120933..431043e75c 100644--- a/plugins/ruflo-metaharness/agents/metaharness-architect.md+++ b/plugins/ruflo-metaharness/agents/metaharness-architect.md@@ -25,7 +25,7 @@ keeping ruflo independently operational at all times.If a PR breaks any of these four rules, it is a breaking change andneeds its own ADR.-## Skills (5 β what each does, when to invoke)+## Skills (6 β what each does, when to invoke)| Skill | Role | Invoke when ||---|---|---|@@ -33,6 +33,7 @@ needs its own ADR.| `harness-genome` | 7-section categorical report | Pre-mint architecture review; drift detection over time || `harness-mcp-scan` | Static MCP security findings | Every PR; enterprise security review || `harness-threat-model` | Categorized threat report | Pre-launch review; periodic OIA-audit cadence |+| `harness-oia-audit` | Composite weekly audit worker (iter 7) | Cron-scheduled; bundles oia+threat+mcp into one timestamped record in `metaharness-audit` namespace || `harness-mint` | Scaffold a custom harness | User wants to fork; ALWAYS dry-run first, never write to project root |## Tools (subprocess-only, no library imports)diff --git a/plugins/ruflo-metaharness/commands/ruflo-metaharness.md b/plugins/ruflo-metaharness/commands/ruflo-metaharness.mdindex 39c34ff54e..7b2cf4f7f0 100644--- a/plugins/ruflo-metaharness/commands/ruflo-metaharness.md+++ b/plugins/ruflo-metaharness/commands/ruflo-metaharness.md@@ -31,6 +31,13 @@ shared helper; no library imports on ruflo's boot path.3. Output suitable for sharing with security/infosec team4. Will be auto-fired by the Phase-2 oia-audit background worker on a schedule+**`harness oia-audit [--path .] [--dry-run] [--alert-on-worst clean|low|medium|high] [--format table|json]`** -- Phase-2 composite worker (ADR-150). Bundles oia-manifest + threat-model + mcp-scan into one timestamped audit record, stores in `metaharness-audit` memory namespace.+1. Run `node plugins/ruflo-metaharness/scripts/oia-audit.mjs`+2. Composite worst-severity = max(threatModel.worst, mcpScan.findings.severity)+3. `--alert-on-worst high` exits 1 when composite β₯ high β CI weekly drift gate+4. `--dry-run` skips memory persistence β useful for local checks+5. Designed for cron schedule: weekly snapshot enables audit drift tracking via memory diff+**`harness mint --name <id> --template <vertical:coding|minimal|β¦> [--host claude-code|codex|β¦] [--target /abs/path] [--confirm] [--format table|json]`** -- Scaffold a custom AI agent harness. DRY-RUN by default; --confirm required to write.1. Run `node plugins/ruflo-metaharness/scripts/mint.mjs --name <id> --template <id> --host <id>`2. **Safety**: refuses to write to the calling repo root or any path inside it; defaults to `/tmp/ruflo-mint-<ts>-<name>/`diff --git a/plugins/ruflo-metaharness/scripts/oia-audit.mjs b/plugins/ruflo-metaharness/scripts/oia-audit.mjsnew file mode 100755index 0000000000..d25ecd75c4--- /dev/null+++ b/plugins/ruflo-metaharness/scripts/oia-audit.mjs@@ -0,0 +1,156 @@+#!/usr/bin/env node+// oia-audit.mjs β composite Phase-2 worker (ADR-150).+//+// Bundles three MetaHarness static-analysis surfaces into one timestamped+// audit record:+// - harness oia-manifest (Open Infrastructure Architecture L1-L9 alignment)+// - harness threat-model (categorized MCP-surface threat report)+// - harness mcp-scan (per-server/tool policy + permissions + deps)+//+// The combined record is stored in the `metaharness-audit` memory+// namespace, keyed by ISO timestamp. Designed to be invoked on a cron+// schedule (e.g. weekly) so audit drift is visible over time.+//+// USAGE+// node scripts/oia-audit.mjs # run + store+// node scripts/oia-audit.mjs --path <dir> # audit specific dir+// node scripts/oia-audit.mjs --dry-run # don't write to memory+// node scripts/oia-audit.mjs --alert-on-worst high+// # exit 1 if threat-model worst >= high+// node scripts/oia-audit.mjs --format json+//+// EXIT CODES+// 0 audit OK (or degraded)+// 1 --alert-on-worst threshold exceeded+// 2 config error or audit failure++import { spawnSync } from 'node:child_process';+import { runHarness, emitDegradedJsonAndExit } from './_harness.mjs';++const SEVERITY_RANK = { clean: 0, low: 1, medium: 2, high: 3 };+const NS = process.env.OIA_AUDIT_NAMESPACE || 'metaharness-audit';+const CLI_PKG = process.env.CLI_CORE === '1'+ ? '@claude-flow/cli-core@alpha'+ : '@claude-flow/cli@latest';++const ARGS = (() => {+ const a = { path: '.', format: 'json', dryRun: false, alertWorst: null };+ for (let i = 2; i < process.argv.length; i++) {+ const v = process.argv[i];+ if (v === '--path') a.path = process.argv[++i];+ else if (v === '--dry-run') a.dryRun = true;+ else if (v === '--alert-on-worst') a.alertWorst = String(process.argv[++i] || '').toLowerCase();+ else if (v === '--format') a.format = process.argv[++i];+ }+ return a;+})();++function runOne(args, label) {+ const r = runHarness(args);+ return {+ label,+ exitCode: r.exitCode,+ degraded: r.degraded,+ reason: r.degraded ? r.reason : null,+ json: r.json,+ durationMs: r.durationMs,+ stderrTail: r.degraded ? (r.stderr || '').slice(-200) : null,+ };+}++function persist(payload) {+ const key = `audit-${new Date().toISOString().replace(/[:.]/g, '-')}`;+ const r = spawnSync('npx', [+ CLI_PKG, 'memory', 'store',+ '--namespace', NS,+ '--key', key,+ '--value', JSON.stringify(payload),+ ], { stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf-8', shell: process.platform === 'win32' });+ return {+ ok: r.status === 0,+ namespace: NS,+ key,+ error: r.status === 0 ? null : (r.stderr || '').slice(0, 200),+ };+}++function main() {+ if (ARGS.alertWorst !== null && !SEVERITY_RANK.hasOwnProperty(ARGS.alertWorst)) {+ console.error(`oia-audit: --alert-on-worst must be one of clean|low|medium|high; got ${ARGS.alertWorst}`);+ process.exit(2);+ }++ const startedAt = new Date().toISOString();+ const oia = runOne(['oia-manifest', ARGS.path], 'oia-manifest');+ const tm = runOne(['threat-model', ARGS.path], 'threat-model');+ const mcp = runOne(['mcp-scan', ARGS.path], 'mcp-scan');++ // If all three say "metaharness not available", surface the degraded+ // payload exactly once and exit 0 (architectural constraint #3).+ if (oia.degraded && tm.degraded && mcp.degraded) {+ emitDegradedJsonAndExit('metaharness-not-available');+ return;+ }++ // Aggregate the worst-severity signal across mcp-scan + threat-model.+ const tmWorst = String(tm.json?.worst || 'clean').toLowerCase();+ const mcpFindings = Array.isArray(mcp.json?.findings) ? mcp.json.findings : [];+ const mcpWorst = mcpFindings.reduce((acc, f) => {+ const s = String(f.severity || 'low').toLowerCase();+ return SEVERITY_RANK[s] > SEVERITY_RANK[acc] ? s : acc;+ }, 'clean');+ const compositeWorst = SEVERITY_RANK[tmWorst] > SEVERITY_RANK[mcpWorst] ? tmWorst : mcpWorst;++ let alertTriggered = false;+ let alertReason = null;+ if (ARGS.alertWorst !== null) {+ const threshold = SEVERITY_RANK[ARGS.alertWorst];+ if (SEVERITY_RANK[compositeWorst] >= threshold && threshold > 0) {+ alertTriggered = true;+ alertReason = `composite worst=${compositeWorst} β₯ ${ARGS.alertWorst}`;+ }+ }++ const payload = {+ path: ARGS.path,+ startedAt,+ finishedAt: new Date().toISOString(),+ composite: { worst: compositeWorst, threatModelWorst: tmWorst, mcpScanWorst: mcpWorst },+ components: { oiaManifest: oia, threatModel: tm, mcpScan: mcp },+ alert: ARGS.alertWorst !== null ? {+ threshold: ARGS.alertWorst,+ triggered: alertTriggered,+ reason: alertReason || `composite worst=${compositeWorst} < ${ARGS.alertWorst} β OK`,+ } : null,+ persisted: null,+ };++ if (!ARGS.dryRun) {+ payload.persisted = persist(payload);+ }++ if (ARGS.format === 'json') {+ console.log(JSON.stringify(payload, null, 2));+ } else {+ console.log(`# oia-audit β ${ARGS.path}`);+ console.log('');+ console.log(`| Component | Exit | Degraded | Duration |`);+ console.log(`|---|---:|:---:|---:|`);+ console.log(`| oia-manifest | ${oia.exitCode} | ${oia.degraded ? 'β ' : 'β'} | ${oia.durationMs}ms |`);+ console.log(`| threat-model | ${tm.exitCode} | ${tm.degraded ? 'β ' : 'β'} | ${tm.durationMs}ms |`);+ console.log(`| mcp-scan | ${mcp.exitCode} | ${mcp.degraded ? 'β ' : 'β'} | ${mcp.durationMs}ms |`);+ console.log('');+ console.log(`Composite worst severity: **${compositeWorst}** (tm=${tmWorst}, mcp=${mcpWorst})`);+ if (payload.persisted) {+ console.log(`Persisted: ${payload.persisted.ok ? `${payload.persisted.namespace}:${payload.persisted.key}` : `FAILED: ${payload.persisted.error}`}`);+ }+ if (payload.alert) {+ console.log('');+ console.log(payload.alert.triggered ? `β **ALERT**: ${payload.alert.reason}` : `β ${payload.alert.reason}`);+ }+ }++ if (alertTriggered) process.exit(1);+}++main();diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.shindex ceeb90d5eb..ebcc890636 100755--- a/plugins/ruflo-metaharness/scripts/smoke.sh+++ b/plugins/ruflo-metaharness/scripts/smoke.sh@@ -20,9 +20,9 @@ else[[ -z "$miss" ]] && ok || bad "missing keywords:$miss"fi-step "2. all five skills present with valid frontmatter"+step "2. all six skills present with valid frontmatter"miss=""-for s in harness-score harness-genome harness-mint harness-mcp-scan harness-threat-model; do+for s in harness-score harness-genome harness-mint harness-mcp-scan harness-threat-model harness-oia-audit; dof="$ROOT/skills/$s/SKILL.md"[[ -f "$f" ]] || { miss="$miss missing-$s"; continue; }for k in 'name:' 'description:' 'allowed-tools:'; do@@ -170,6 +170,27 @@ if (!od.metaharness) { console.error('missing metaharness in optionalDependencieif (j.dependencies && j.dependencies.metaharness) { console.error('metaharness leaked into dependencies'); process.exit(1); }" 2>/dev/null && ok || bad "ruflo wrapper missing metaharness optionalDep"+step "17c. oia-audit composite worker (Phase 2 β iter 7)"+F="$ROOT/scripts/oia-audit.mjs"+miss=""+[[ -x "$F" ]] || miss="$miss not-executable"+node --check "$F" 2>/dev/null || miss="$miss syntax-error"+grep -q "runHarness" "$F" || miss="$miss no-runner"+# All three component invocations+grep -q "oia-manifest" "$F" || miss="$miss no-oia-manifest"+grep -q "threat-model" "$F" || miss="$miss no-threat-model"+grep -q "mcp-scan" "$F" || miss="$miss no-mcp-scan"+# Composite severity computation+grep -q "compositeWorst\|composite.*Worst" "$F" || miss="$miss no-composite-severity"+grep -q "SEVERITY_RANK" "$F" || miss="$miss no-severity-rank"+# Memory persistence (default behavior, --dry-run to skip)+grep -q "metaharness-audit" "$F" || miss="$miss no-namespace"+grep -q "memory.*store" "$F" || miss="$miss no-memory-store"+# Alert exit code+grep -q "alert-on-worst" "$F" || miss="$miss no-alert-flag"+grep -q "process.exit(1)" "$F" || miss="$miss no-fail-closed"+[[ -z "$miss" ]] && ok || bad "$miss"+step "17b. harness type in plugin registry (Phase 2 β iter 6)"F="$ROOT/../../v3/@claude-flow/cli/src/plugins/store/types.ts"miss=""diff --git a/plugins/ruflo-metaharness/skills/harness-oia-audit/SKILL.md b/plugins/ruflo-metaharness/skills/harness-oia-audit/SKILL.mdnew file mode 100644index 0000000000..7152debec4--- /dev/null+++ b/plugins/ruflo-metaharness/skills/harness-oia-audit/SKILL.md@@ -0,0 +1,79 @@+---+name: harness-oia-audit+description: Composite Phase-2 audit worker (ADR-150). Bundles harness oia-manifest + threat-model + mcp-scan into one timestamped audit record stored in the `metaharness-audit` memory namespace. Designed for cron-scheduled drift detection.+argument-hint: "[--path .] [--dry-run] [--alert-on-worst clean|low|medium|high] [--format table|json]"+allowed-tools: Bash+---++The 13th worker (ADR-150 Phase 2) β runs three MetaHarness static+surfaces in one shot, computes a composite worst-severity signal, and+persists the audit record to memory so drift over time is visible.++## Algorithm++Implementation: [`scripts/oia-audit.mjs`](../../scripts/oia-audit.mjs).++1. Run `harness oia-manifest <path>` β Open Infrastructure Architecture+ layer alignment (L1-L9).+2. Run `harness threat-model <path>` β categorized MCP-surface threat+ report with `worst: clean|low|medium|high`.+3. Run `harness mcp-scan <path>` β per-server/tool policy + permissions+ + dep findings.+4. Composite worst = `max(threatModel.worst, max(mcpScan.findings.severity))`.+5. Persist payload to memory namespace `metaharness-audit` with key+ `audit-<iso-timestamp>` (unless `--dry-run`).+6. `--alert-on-worst <severity>`: exit 1 if composite worst β₯ threshold.++## Graceful degradation++When ALL three components report `metaharness-not-available`, the script+emits the standard degraded payload and exits 0. When only some are+degraded, each individual component carries its own `degraded: true`+flag in the audit record β the audit still runs and persists what it+could gather.++## CI / cron integration++Designed for weekly cron in `.github/workflows/`:++```yaml+on:+ schedule:+ - cron: '17 4 * * 0' # Sundays at 04:17 UTC+jobs:+ oia-audit:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4+ - uses: actions/setup-node@v4+ - run: node plugins/ruflo-metaharness/scripts/oia-audit.mjs --alert-on-worst high+```++`--alert-on-worst high` fails the job on any HIGH-severity finding;+drift below HIGH is logged but doesn't block.++## Memory namespace++Each audit run stores under `metaharness-audit:audit-<iso-ts>`. To list+recent audits:++```bash+npx @claude-flow/cli@latest memory list --namespace metaharness-audit --limit 10+```++To diff two audits (drift detection):++```bash+A=$(npx ... memory retrieve --key audit-2026-06-01... --namespace metaharness-audit)+B=$(npx ... memory retrieve --key audit-2026-06-15... --namespace metaharness-audit)+# Compare composite.worst, components.threatModel.worst, etc.+```++A future ADR can wire this into a dedicated `cost-diff`-style diff+viewer specifically for audit drift.++## Pairs with++- `harness-threat-model` β the underlying threat-model component+- `harness-mcp-scan` β the underlying MCP-scan component+- `harness-score` + `harness-genome` β readiness metrics (orthogonal to audit)