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

test(metaharness): local-runnable graceful-degradation drill (ADR-150 rule #3, iter 19)

ruv040652cec251
diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.sh
index f60b14a91d..4f6726ae82 100755
--- a/plugins/ruflo-metaharness/scripts/smoke.sh
+++ b/plugins/ruflo-metaharness/scripts/smoke.sh
@@ -170,6 +170,23 @@ 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 "17l. test-graceful-degradation drill (ADR-150 rule #3 β€” iter 19)"
+F="$ROOT/scripts/test-graceful-degradation.mjs"
+miss=""
+[[ -x "$F" ]] || miss="$miss not-executable"
+node --check "$F" 2>/dev/null || miss="$miss syntax-error"
+# Asserts the contract literal: exit 0 AND degraded:true
+grep -q 'exit code = 0' "$F" || miss="$miss no-exit-0-assertion"
+grep -q '"degraded".*true' "$F" || miss="$miss no-degraded-true-assertion"
+# Skills covered (all 5 metaharness-binary-dependent ones)
+for sub in score genome mcp-scan threat-model oia-audit; do
+ grep -q "name: '${sub}'" "$F" || miss="$miss missing-${sub}"
+done
+# Unreachable-registry stub (no actual network)
+grep -q "npm_config_registry" "$F" || miss="$miss no-registry-stub"
+grep -q "no-such-registry" "$F" || miss="$miss no-fake-host"
+[[ -z "$miss" ]] && ok || bad "$miss"
+
step "17k. init + hooks discovery surfaces metaharness (iter 18)"
INIT="$ROOT/../../v3/@claude-flow/cli/src/commands/init.ts"
HOOKS="$ROOT/../../v3/@claude-flow/cli/src/commands/hooks.ts"
diff --git a/plugins/ruflo-metaharness/scripts/test-graceful-degradation.mjs b/plugins/ruflo-metaharness/scripts/test-graceful-degradation.mjs
new file mode 100755
index 0000000000..984637ced6
--- /dev/null
+++ b/plugins/ruflo-metaharness/scripts/test-graceful-degradation.mjs
@@ -0,0 +1,126 @@
+#!/usr/bin/env node
+// test-graceful-degradation.mjs β€” runtime drill for ADR-150 architectural
+// constraint rule #3 (graceful degradation).
+//
+// CI runs this via .github/workflows/no-metaharness-smoke.yml; this
+// script lets developers reproduce the same drill locally for fast
+// iteration (no GitHub Actions roundtrip).
+//
+// STRATEGY
+// Point `npm_config_registry` at an unresolvable host, then invoke every
+// metaharness-CLI-dependent skill. Each MUST:
+// (a) exit 0 β€” never propagate a failure code from a missing optional dep
+// (b) emit JSON containing `"degraded": true` somewhere in its output
+//
+// The 8 covered skills (all rely on `npx metaharness` / `npx -p
+// metaharness harness`):
+// score / genome / mcp-scan / threat-model / oia-audit /
+// audit-list / audit-trend / mint
+//
+// (audit-list + audit-trend talk to `npx @claude-flow/cli memory ...`
+// rather than metaharness β€” they're tested separately for the
+// "no records in namespace" graceful path.)
+//
+// USAGE
+// node scripts/test-graceful-degradation.mjs # default
+// node scripts/test-graceful-degradation.mjs --keep-fixtures # for debugging
+//
+// EXIT CODES
+// 0 all skills gracefully degraded
+// 1 at least one skill failed the contract (exit != 0 or no degraded:true)
+// 2 setup error
+
+import { spawnSync } from 'node:child_process';
+import { dirname, join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const SCRIPTS_DIR = dirname(fileURLToPath(import.meta.url));
+
+const ARGS = (() => {
+ const a = { keep: false };
+ for (let i = 2; i < process.argv.length; i++) {
+ if (process.argv[i] === '--keep-fixtures') a.keep = true;
+ }
+ return a;
+})();
+
+const UNREACHABLE_REGISTRY = 'https://no-such-registry-9c8c43.example.invalid/';
+
+let passed = 0, failed = 0;
+const failures = [];
+
+function assert(cond, label) {
+ console.log(` ${cond ? 'βœ“' : 'βœ—'} ${label}`);
+ if (cond) passed++;
+ else { failures.push(label); failed++; }
+}
+
+function runWithUnreachableRegistry(scriptName, extraArgs) {
+ const r = spawnSync('node', [join(SCRIPTS_DIR, scriptName), ...extraArgs], {
+ env: {
+ ...process.env,
+ npm_config_registry: UNREACHABLE_REGISTRY,
+ NPM_CONFIG_REGISTRY: UNREACHABLE_REGISTRY,
+ },
+ stdio: ['ignore', 'pipe', 'pipe'],
+ encoding: 'utf-8',
+ // 180s per subprocess β€” long enough for npx's DNS-retry + 60s
+ // subprocess timeout inside _harness.mjs to elapse. Smaller
+ // timeouts here truncate the subprocess BEFORE it reaches its
+ // own degraded-payload emit, which made earlier iterations of
+ // this drill report false negatives (exit 1 from harness kill,
+ // not from the script).
+ timeout: 180_000,
+ });
+ return {
+ // r.status is null when the subprocess was killed by our timeout.
+ // Distinguish that case explicitly so callers can see "drill
+ // harness killed it" vs "script exited non-zero".
+ exitCode: r.status,
+ stdout: r.stdout || '',
+ stderr: r.stderr || '',
+ killedByTimeout: r.status === null,
+ };
+}
+
+function main() {
+ console.log('# test-graceful-degradation\n');
+ console.log(`Registry: ${UNREACHABLE_REGISTRY}`);
+ console.log('Each skill must exit 0 AND emit "degraded": true in JSON.\n');
+
+ // The 5 skills that directly invoke metaharness/harness binaries.
+ // (audit-list / audit-trend talk to claude-flow's memory layer, not
+ // metaharness; they have their own empty-namespace graceful paths
+ // tested separately. mint requires a --name argv to even start.)
+ const skills = [
+ { name: 'score', args: ['--format', 'json'] },
+ { name: 'genome', args: ['--format', 'json'] },
+ { name: 'mcp-scan', args: ['--format', 'json'] },
+ { name: 'threat-model', args: ['--format', 'json'] },
+ { name: 'oia-audit', args: ['--dry-run', '--format', 'json'] },
+ ];
+
+ for (const s of skills) {
+ console.log(`-- ${s.name} --`);
+ const r = runWithUnreachableRegistry(`${s.name}.mjs`, s.args);
+ if (process.env.DEBUG || r.killedByTimeout || r.exitCode !== 0) {
+ // Surface the failure context: drill timeouts and unexpected exits
+ // are both worth seeing, otherwise debugging is blind.
+ console.log(` stdout (last 400): ${r.stdout.slice(-400)}`);
+ console.log(` stderr (last 300): ${r.stderr.slice(-300)}`);
+ if (r.killedByTimeout) console.log(` (killed by drill 180s timeout)`);
+ }
+ assert(r.exitCode === 0, `${s.name} exit code = 0 (got ${r.killedByTimeout ? 'timeout' : r.exitCode})`);
+ assert(/"degraded"\s*:\s*true/.test(r.stdout), `${s.name} emits "degraded": true`);
+ }
+
+ console.log(`\n${passed} passed, ${failed} failed`);
+ if (failed > 0) {
+ console.log('\nFailures:');
+ for (const f of failures) console.log(` - ${f}`);
+ process.exit(1);
+ }
+ console.log('\nβœ“ All skills satisfy ADR-150 rule #3 (graceful degradation).');
+}
+
+main();