mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 06:06:02 +09:00
test(metaharness): MCP runtime contract enrolls similarity tool (iter 37)
Iter 36 wired metaharness_similarity into the MCP TOOL_REGISTRY at the
type/registration layer. This iter proves the tool actually EXECUTES
through the registry path — not just compiles — by enrolling it in the
iter-23 runtime contract test.
WHAT CHANGED
1. plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs
- Phase 1 assertion: tools.length === 7 → 8
- expectedNames adds 'metaharness_similarity'
- Phase 3 input table: similarity handler gets {aKey, bKey} with
fake mem keys — exercises the graceful not-found path, mirroring
the audit_trend convention from iter 23
- Summary line: "All 7 MCP tools" → "All 8 MCP tools"
2. plugins/ruflo-metaharness/scripts/smoke.sh (step 17o)
- Tool-name loop expanded: 7 → 8 (similarity added)
- New literal guard: grep "tools.length === 8" so a future contributor
who adds a tool without bumping the count fails smoke immediately
VERIFIED END-TO-END
$ npm run build && node scripts/test-mcp-tools.mjs
Phase 1 — module shape: 4 assertions pass (8 names, 8 tools)
Phase 2 — per-tool shape: 16 assertions pass (8 tools × 2 invariants)
Phase 3 — handler invocations: 54 assertions pass (8 tools × 6 contracts +
6 don't-throw assertions)
Total: 74 passed, 0 failed
metaharness_similarity invokes the not-found path cleanly:
- handler did not throw ✓
- returns object ✓
- shape {success, data, degraded, exitCode} ✓
GATES THIS ITER
smoke 41/41 (step 17o updated)
fleet 33/33 contracts
runtime 74/74 contract assertions
tsc CLI compiles clean
ARCHITECTURAL CONSTRAINT REINFORCEMENT
The graceful-degradation path (constraint #3 from ADR-150) was previously
only ASSERTED via grep on the source. Now every CI run actually invokes
the handler with synthetic missing inputs and confirms it returns
{degraded:true, …} instead of throwing — a stronger guarantee that the
contract is preserved across future edits.
Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
1 parent
0b6ac8ff90
commit
15afefbe03
2 files changed
+13
-4
No files matched your search
@@ -425,10 +425,12 @@ grep -q "result has 'success'" "$F" || miss="$miss no-success-assertion"
|
||||
grep -q "result has 'data'" "$F" || miss="$miss no-data-assertion"
|
||||
grep -q "result has 'degraded'" "$F" || miss="$miss no-degraded-assertion"
|
||||
grep -q "result has 'exitCode'" "$F" || miss="$miss no-exitcode-assertion"
|
||||
# All 7 tool names enumerated
|
||||
for tool in metaharness_score metaharness_genome metaharness_mcp_scan metaharness_threat_model metaharness_oia_audit metaharness_audit_list metaharness_audit_trend; do
|
||||
# All 8 tool names enumerated (similarity added in iter 36, runtime-tested iter 37)
|
||||
for tool in metaharness_score metaharness_genome metaharness_mcp_scan metaharness_threat_model metaharness_oia_audit metaharness_audit_list metaharness_audit_trend metaharness_similarity; do
|
||||
grep -q "${tool}" "$F" || miss="$miss missing-${tool}"
|
||||
done
|
||||
# Count assertion must match the iter-36 expansion (7 → 8)
|
||||
grep -q "tools.length === 8" "$F" || miss="$miss tool-count-assertion-stale"
|
||||
# Graceful skip when dist absent (so the script is smoke-runnable pre-build)
|
||||
grep -q "SKIPPED" "$F" || miss="$miss no-skip-doc"
|
||||
[[ -z "$miss" ]] && ok || bad "$miss"
|
||||
|
||||
@@ -74,7 +74,7 @@ async function main() {
|
||||
// ──────────────────────────────────────────────────────────────────
|
||||
console.log('Phase 1 — module shape');
|
||||
assert(Array.isArray(tools), 'metaharnessTools is an array');
|
||||
assert(tools.length === 7, `7 tools registered (got ${tools.length})`);
|
||||
assert(tools.length === 8, `8 tools registered (got ${tools.length})`);
|
||||
|
||||
const expectedNames = new Set([
|
||||
'metaharness_score',
|
||||
@@ -84,6 +84,8 @@ async function main() {
|
||||
'metaharness_oia_audit',
|
||||
'metaharness_audit_list',
|
||||
'metaharness_audit_trend',
|
||||
// iter 36 — ADR-152 §3.1 production
|
||||
'metaharness_similarity',
|
||||
]);
|
||||
const actualNames = new Set(tools.map((t) => t.name));
|
||||
for (const name of expectedNames) {
|
||||
@@ -121,6 +123,11 @@ async function main() {
|
||||
// resolve so we exercise the not-found path.
|
||||
input = { baselineKey: 'audit-fake-base', currentKey: 'audit-fake-curr' };
|
||||
}
|
||||
if (tool.name === 'metaharness_similarity') {
|
||||
// Needs --a/--b OR --a-key/--b-key. Use fake mem keys to exercise
|
||||
// the graceful not-found path (matches audit_trend convention).
|
||||
input = { aKey: 'harness-fake-a', bKey: 'harness-fake-b' };
|
||||
}
|
||||
|
||||
// 30s budget per tool — slow path is npx warmup
|
||||
const handlerPromise = tool.handler(input);
|
||||
@@ -152,7 +159,7 @@ async function main() {
|
||||
for (const f of failures) console.log(` - ${f}`);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('\n✓ All 7 MCP tools satisfy the runtime contract.');
|
||||
console.log('\n✓ All 8 MCP tools satisfy the runtime contract.');
|
||||
}
|
||||
|
||||
main().catch((e) => {
|
||||
|
||||
Reference in new issue
Block a user