fix(metaharness): close no-policy HIGH finding — ruflo gets an mcp-policy.json (iter 30)

The iter-27 npx-argv fix surfaced a real, previously-hidden HIGH-severity
finding from `harness threat-model .`:

  [high] no-policy: MCP server with no policy

Ruflo's .claude/settings.json declares the `claude-flow` MCP server,
but had no .harness/mcp-policy.json — the threat model correctly
flagged that as ungoverned execution.

THE POLICY (.harness/mcp-policy.json — new file, 32 lines)
- defaultDeny: true             (ADR-022 posture — refuse ungranted capabilities)
- allowShell: false             (claude-flow MCP server does NOT expose shell; Bash is native CC)
- allowNetwork: false           (network access via memory/embeddings is internal, not raw fetch)
- allowFileWrite: false         (file I/O via AgentDB abstraction, not raw write)
- requireApprovalForDangerous: true
- auditLog: true                (enterprise trust signal)
- toolTimeoutMs: 600_000        (10 min per tool call, bounded)
- maxToolCallsPerTurn: 200      (bounds runaway loops)
- dangerousPatterns: regex list for Bash(rm/sudo/curl-pipe-sh/etc.)
- approvedServers: ["claude-flow"]
- $comment, rationale, references: cross-linked to ADR-150 + upstream

MEASURED IMPROVEMENT (verified end-to-end against metaharness@0.1.13)
                          BEFORE iter 30        AFTER iter 30
  threat-model worst      HIGH                  LOW (just unpinned-deps)
  threat-model verdict    HIGH                  CLEAN
  L7 governance alignment partial               FULL ★
  L8 audit signal         off                   auditLog: true
  MCP policyPath          null                  .harness/mcp-policy.json

★ Major OIA layer transition. Ruflo went from "partial" L7 governance
  to "full" by introducing one 32-line JSON file.

ARCHITECTURAL NOTES
The policy reflects ruflo's REAL posture, not an aspirational one. The
claude-flow MCP server doesn't actually expose shell/network/file-write
primitives — those operations happen at the native Claude Code tool
layer (Bash / Write / Edit / WebFetch), governed by Claude Code's own
permission system. The MCP layer trades in higher-level abstractions
(memory_*, hooks_*, agentdb_*, embeddings_*). So denying the three
elevation flags at the MCP layer is honest — there's nothing in the
MCP server's tool surface that needs them.

The HIGH finding's deeper meaning was "this surface is ungoverned".
With the policy file present + default-deny + audit-log, the surface
is now governed at the right layer.

SMOKE STEP 17t (anti-regression)
- File must exist + parse as JSON
- defaultDeny, auditLog, requireApprovalForDangerous all === true
- toolTimeoutMs + maxToolCallsPerTurn both positive numbers
- ADR-150 anchor present in policy contents

Smoke: 35 → 36. Fleet: 33/33. Three audits clean. tsc clean.

The audit pipeline drove its own remediation: iter-7's oia-audit found
the HIGH, iter-30 fixed the underlying cause. The system can now
self-improve based on its own static-analysis output.

Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
ruv committed 2026-06-16 15:51:12 -04:00
1 parent d98dac3f65
commit 8d3900a93b
2 files changed
+68

No files matched your search

@@ -191,6 +191,33 @@ 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 "17t. .harness/mcp-policy.json present + default-deny (iter 30 — closes no-policy HIGH)"
F="$ROOT/../../.harness/mcp-policy.json"
miss=""
[[ -f "$F" ]] || miss="$miss missing-policy-file"
node -e "JSON.parse(require('fs').readFileSync('$F','utf-8'))" 2>/dev/null || miss="$miss invalid-json"
# Required fields per metaharness mcp-scan source
node -e "
const j = JSON.parse(require('fs').readFileSync('$F','utf-8'));
const must = { defaultDeny: true, auditLog: true, requireApprovalForDangerous: true };
for (const [k, v] of Object.entries(must)) {
if (j[k] !== v) { console.error('missing or wrong:', k, '=', j[k]); process.exit(1); }
}
// toolTimeoutMs must be positive
if (!Number.isFinite(j.toolTimeoutMs) || j.toolTimeoutMs <= 0) {
console.error('toolTimeoutMs not positive'); process.exit(1);
}
// maxToolCallsPerTurn must be positive (clears 'no-call-budget' finding)
if (!Number.isFinite(j.maxToolCallsPerTurn) || j.maxToolCallsPerTurn <= 0) {
console.error('maxToolCallsPerTurn not positive'); process.exit(1);
}
// ADR-150 anchor present
if (!JSON.stringify(j).includes('ADR-150')) {
console.error('no ADR-150 anchor in policy'); process.exit(1);
}
" 2>/dev/null || miss="$miss policy-shape-invalid"
[[ -z "$miss" ]] && ok || bad "$miss"
step "17s. mint.mjs cwd-based scaffolding (iter 27 fix for upstream --target bug)"
F="$ROOT/scripts/mint.mjs"
miss=""