Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 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

feat(metaharness): audit-list β€” enumerate metaharness-audit records (iter 16)

ruv011a8f9bc42c
diff --git a/plugins/ruflo-metaharness/scripts/audit-list.mjs b/plugins/ruflo-metaharness/scripts/audit-list.mjs
new file mode 100755
index 0000000000..88a3a41d90
--- /dev/null
+++ b/plugins/ruflo-metaharness/scripts/audit-list.mjs
@@ -0,0 +1,158 @@
+#!/usr/bin/env node
+// audit-list.mjs β€” list timestamped oia-audit records from the
+// `metaharness-audit` memory namespace.
+//
+// The iter-7 oia-audit worker writes one record per run (keyed by ISO
+// timestamp). This script enumerates them so operators can see audit
+// cadence, spot gaps, and pick keys to feed into audit-trend.mjs.
+//
+// USAGE
+// node scripts/audit-list.mjs # most recent 20
+// node scripts/audit-list.mjs --limit 50
+// node scripts/audit-list.mjs --format json
+// node scripts/audit-list.mjs --since 30d # last N days
+//
+// EXIT CODES
+// 0 ok
+// 2 config error
+
+import { spawnSync } from 'node:child_process';
+
+const NS = process.env.AUDIT_LIST_NAMESPACE || 'metaharness-audit';
+const CLI_PKG = process.env.CLI_CORE === '1'
+ ? '@claude-flow/cli-core@alpha'
+ : '@claude-flow/cli@latest';
+
+const ARGS = (() => {
+ const a = { limit: 20, since: null, format: 'table' };
+ for (let i = 2; i < process.argv.length; i++) {
+ const v = process.argv[i];
+ if (v === '--limit') a.limit = parseInt(process.argv[++i], 10);
+ else if (v === '--since') a.since = process.argv[++i];
+ else if (v === '--format') a.format = process.argv[++i];
+ }
+ return a;
+})();
+
+function parseDurationMs(spec) {
+ const m = /^(\d+)([hdwm])$/.exec(spec);
+ if (!m) return null;
+ const n = parseInt(m[1], 10);
+ const unit = { h: 3600_000, d: 86400_000, w: 7 * 86400_000, m: 30 * 86400_000 }[m[2]];
+ return unit ? n * unit : null;
+}
+
+function memList() {
+ const r = spawnSync('npx', [
+ CLI_PKG, 'memory', 'list',
+ '--namespace', NS, '--format', 'json',
+ ], { stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf-8', shell: process.platform === 'win32' });
+ if (r.status !== 0) return [];
+ const m = /\[[\s\S]*\]/.exec(r.stdout || '');
+ if (!m) return [];
+ try { return JSON.parse(m[0]); } catch { return []; }
+}
+
+function memRetrieve(key) {
+ const r = spawnSync('npx', [
+ CLI_PKG, 'memory', 'retrieve',
+ '--namespace', NS, '--key', key,
+ ], { stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf-8', shell: process.platform === 'win32' });
+ if (r.status !== 0) return null;
+ const m = /\{[\s\S]*\}/.exec(r.stdout || '');
+ if (!m) return null;
+ try { return JSON.parse(m[0]); } catch { return null; }
+}
+
+function main() {
+ if (!Number.isInteger(ARGS.limit) || ARGS.limit < 1) {
+ console.error(`audit-list: --limit must be a positive integer`);
+ process.exit(2);
+ }
+ let cutoffMs = null;
+ if (ARGS.since) {
+ const ms = parseDurationMs(ARGS.since);
+ if (!ms) {
+ console.error(`audit-list: --since must be N(h|d|w|m); got ${ARGS.since}`);
+ process.exit(2);
+ }
+ cutoffMs = Date.now() - ms;
+ }
+
+ const entries = memList()
+ .map((e) => e.key)
+ .filter((k) => typeof k === 'string' && k.startsWith('audit-'))
+ .sort()
+ .reverse(); // newest first (ISO keys sort lexicographically by time)
+
+ // Apply --since by parsing the timestamp out of the key.
+ const filtered = entries.filter((k) => {
+ if (!cutoffMs) return true;
+ // key shape: audit-2026-06-16T15-30-00-000Z
+ const m = /^audit-(.+)$/.exec(k);
+ if (!m) return true;
+ const isoLike = m[1].replace(/-/g, ':').replace(/^(\d{4}):(\d{2}):(\d{2})/, '$1-$2-$3');
+ const ts = Date.parse(isoLike);
+ return Number.isFinite(ts) && ts >= cutoffMs;
+ });
+
+ const slice = filtered.slice(0, ARGS.limit);
+
+ // Pull just enough fields from each record to render a compact line.
+ const rows = [];
+ for (const key of slice) {
+ const rec = memRetrieve(key);
+ if (!rec) continue;
+ rows.push({
+ key,
+ startedAt: rec.startedAt || null,
+ finishedAt: rec.finishedAt || null,
+ worst: rec.composite?.worst || null,
+ tmWorst: rec.composite?.threatModelWorst || null,
+ mcpWorst: rec.composite?.mcpScanWorst || null,
+ degraded: !!(rec.components?.oiaManifest?.degraded
+ || rec.components?.threatModel?.degraded
+ || rec.components?.mcpScan?.degraded),
+ });
+ }
+
+ const payload = {
+ namespace: NS,
+ filters: { limit: ARGS.limit, since: ARGS.since },
+ totalInNamespace: entries.length,
+ matchedSinceFilter: filtered.length,
+ returned: rows.length,
+ records: rows,
+ generatedAt: new Date().toISOString(),
+ };
+
+ if (ARGS.format === 'json') {
+ console.log(JSON.stringify(payload, null, 2));
+ return;
+ }
+
+ console.log(`# audit-list`);
+ console.log('');
+ console.log(`| Field | Value |`);
+ console.log(`|---|---:|`);
+ console.log(`| Namespace | \`${NS}\` |`);
+ console.log(`| Total records | ${entries.length} |`);
+ console.log(`| Matched filter | ${filtered.length} |`);
+ console.log(`| Showing | ${rows.length} (newest first) |`);
+ console.log('');
+ if (rows.length === 0) {
+ console.log(`_No audit records found. Run \`harness oia-audit\` to create one._`);
+ return;
+ }
+ console.log(`| Key | Started | Composite worst | Threat | MCP | Degraded |`);
+ console.log(`|---|---|:---:|:---:|:---:|:---:|`);
+ for (const r of rows) {
+ const shortKey = r.key.slice(0, 32) + (r.key.length > 32 ? '…' : '');
+ const started = r.startedAt ? r.startedAt.slice(0, 19).replace('T', ' ') : 'β€”';
+ console.log(`| \`${shortKey}\` | ${started} | ${r.worst || 'β€”'} | ${r.tmWorst || 'β€”'} | ${r.mcpWorst || 'β€”'} | ${r.degraded ? '⚠' : 'βœ“'} |`);
+ }
+ console.log('');
+ console.log(`_Use \`audit-trend --baseline-key <a> --current-key <b>\` to diff two records._`);
+}
+
+main();
diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.sh
index aafd0b58d1..d6e5fa3db2 100755
--- a/plugins/ruflo-metaharness/scripts/smoke.sh
+++ b/plugins/ruflo-metaharness/scripts/smoke.sh
@@ -170,6 +170,17 @@ if (!od.metaharness) { console.error('missing metaharness in optionalDependencie
if (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 "17j. audit-list β€” enumerate metaharness-audit records (iter 16)"
+F="$ROOT/scripts/audit-list.mjs"
+miss=""
+[[ -x "$F" ]] || miss="$miss not-executable"
+node --check "$F" 2>/dev/null || miss="$miss syntax-error"
+grep -q "metaharness-audit" "$F" || miss="$miss no-namespace"
+grep -q "audit-trend" "$F" || miss="$miss no-trend-pointer"
+grep -q "limit\|since" "$F" || miss="$miss no-filters"
+grep -q "newest first" "$F" || miss="$miss no-sort-doc"
+[[ -z "$miss" ]] && ok || bad "$miss"
+
step "17i. audit-trend β€” diff two oia-audit snapshots (iter 15)"
F="$ROOT/scripts/audit-trend.mjs"
miss=""