test(metaharness): MCP-tool runScript() refs point at existing scripts (iter 90)

Companion to iter-89's SUBCOMMANDS check. metaharness-tools.ts has 9
MCP-tool handlers, each calling runScript('<name>.mjs', args). If a
future iter renames a script but forgets to update its handler, the
agent-callable MCP surface fails at runtime with "Script not found".

THE THREE-WAY CONTRACT (post-iter-90, fully anchored)

   CLI dispatcher: SUBCOMMANDS['X'] = 'X.mjs'       (iter 73 description ↔ key)
                              │                     (iter 89 value ↔ file)
                              v
              scripts/X.mjs   ← file exists
                              ^
                              │
   MCP handler:  runScript('X.mjs', args)            (iter 90 ref ↔ file)

   Every reference from BOTH the CLI dispatcher AND the MCP wrapper
   now has its target verified at smoke-time.

WHAT SHIPPED — smoke step 17z53

Parses every runScript('foo.mjs', ...) call site in metaharness-tools.ts
via regex:
   /runScript\('([a-z-]+\.mjs)'/

For each unique reference: asserts the .mjs file exists in
plugins/ruflo-metaharness/scripts/. Locks count at 9 (one per MCP
tool; mint deliberately excluded per ADR-150 §Sandboxing).

If a future iter:
   - Renames a script         → "mcp-script-foo.mjs-missing"
   - Adds a 10th MCP tool     → "mcp-script-count-stale:10-expected-9"
   - Removes a tool           → "mcp-script-count-stale:8-expected-9"

GATES THIS ITER
   smoke:    92 → 93 (step 17z53 green)
   contract: 9 MCP runScript() refs × 9 file-existence checks all pass

ITER 73 + 84 + 89 + 90 CROSS-REFERENCE INTEGRITY MATRIX

| Reference source            | Reference target | Iter |
|-----------------------------|------------------|------|
| description string          | SUBCOMMANDS keys | 73   |
| SUBCOMMANDS values          | scripts/*.mjs    | 89   |
| MCP handler runScript()     | scripts/*.mjs    | 90   |
| CLI workflow run commands   | tripwire scripts | 84   |

Four cross-references now produce specific failure messages when
the references drift.

PATTERN: SAME REGEX, DIFFERENT SOURCE

Iters 89 + 90 both:
   1. Parse a regex match from a source file (the reference list)
   2. For each match, assert a target file exists
   3. Assert the count matches the documented contract

Future iters that add new cross-reference surfaces (e.g., a third
MCP-tool registry, a SKILL.md → script-path mapping) can adopt this
3-step shape. The pattern is now self-documenting.

Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
ruv committed 2026-06-16 23:29:54 -04:00
1 parent c6ecf14236
commit 0212ec9690
1 file changed
+21
@@ -191,6 +191,27 @@ 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 "17z53. MCP-tool runScript() references point at existing scripts (iter 90)"
miss=""
# Companion to iter-89's SUBCOMMANDS check. metaharness-tools.ts has 9
# handlers, each calling runScript('<name>.mjs', args). If a future iter
# renames a script but forgets the MCP-tool handler, the agent-callable
# surface fails at runtime with "Script not found".
WRAPPER="$ROOT/../../v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts"
SCRIPTS_DIR="$ROOT/scripts"
# Extract `runScript('foo.mjs', ...)` references.
REFS=$(grep -oE "runScript\('[a-z-]+\.mjs'" "$WRAPPER" 2>/dev/null \
| sed -E "s/runScript\('([a-z-]+\.mjs)'/\1/" \
| sort -u)
COUNT=0
for f in $REFS; do
COUNT=$((COUNT + 1))
[[ -f "$SCRIPTS_DIR/$f" ]] || miss="$miss mcp-script-${f}-missing"
done
# Should be 9 unique scripts (one per MCP tool; mint deliberately excluded)
[[ "$COUNT" == "9" ]] || miss="$miss mcp-script-count-stale:$COUNT-expected-9"
[[ -z "$miss" ]] && ok || bad "$miss"
step "17z52. SUBCOMMANDS map entries point at existing script files (iter 89)"
miss=""
# CLI dispatcher (metaharness.ts) has a SUBCOMMANDS map that routes