Files
ruvnet__ruflo/plugins/ruflo-metaharness/README.md
T
rUv ae9bba523e feat(metaharness): learn + gepa integration — metaharness@0.3.0 / darwin@0.8.0 (15 MCP tools) (#2540)
* fix(mcp-bridge): streamable-HTTP session cleanup — DELETE + Mcp-Session-Id + 202 (#2425)

Closes #2425. Cherry-picked from djimit's commit b905c09f4 with
extensions: applied symmetrically to BOTH bridges (per ADR-166's
"both bridges move together" rule), and added regression coverage
in the ADR-166 security lock so this can't silently regress.

Streamable-HTTP clients (Codex/RMCP) send `DELETE /mcp` with an
`Mcp-Session-Id` header at shutdown. Previously the bridge returned
`Cannot DELETE /mcp` which surfaced as noisy client-side cleanup
failures after otherwise-successful MCP calls.

Changes (both bridges — ruflo/src/mcp-bridge/index.js AND
ruflo/src/ruvocal/mcp-bridge/index.js):

- Stable per-process `MCP_SESSION_ID = randomUUID()` echoed as the
  `Mcp-Session-Id` header on every `/mcp*` response
- `DELETE /mcp` and `DELETE /mcp/:group` → 204 No Content (idempotent)
- `DELETE` added to `Access-Control-Allow-Methods`; `Mcp-Session-Id`
  added to `Access-Control-Allow-Headers` (both compatible with the
  ADR-166 CORS allowlist wiring — allowlist controls Origin, not
  Method/Header)
- `notifications/initialized` responses now `202 Accepted` with empty
  body per the MCP streamable-HTTP spec (was returning a jsonrpc
  envelope which some clients rejected as unexpected)

Regression locks (extends ADR-166 §6 acceptance):
- test-security-lock.js — 2 new static checks (#7 delete handler,
  #8 Mcp-Session-Id header) × 2 bridges = 16/16
- test-runtime-security.mjs — 2 new runtime checks per bridge (R6
  DELETE→204 + header echoed; R7 notifications/initialized→202 empty)
  = 20/20 total green

Interaction with ADR-166 auth: DELETE flows through `app.use(requireAuth)`
same as the rest of `/mcp*`. When `MCP_AUTH_TOKEN` is set, DELETE without
Bearer returns 401 (verified in R2 by contrast; DELETE with Bearer
returns 204 verified in R6). Local-only deployments with no token remain
zero-friction (the middleware is a no-op).

Credit: @djimit for the original patch (branch
fix/mcp-session-cleanup-forkbase on djimit/claude-code-flow, commit
b905c09f42).

Co-Authored-By: djimit <djimit@users.noreply.github.com>
Co-Authored-By: RuFlo <ruv@ruv.net>

* feat(metaharness): learn + gepa integration — metaharness@0.3.0 / darwin@0.8.0

Version pins (optionalDependencies, both @claude-flow/cli + ruflo wrapper):
- @metaharness/darwin  ~0.3.1 → ~0.8.0  (GEPA engine + cand-6 genome)
- metaharness          ~0.2.6 → ~0.2.8
- @metaharness/redblue ~0.1.1 → ~0.1.4  (+ versioned cache dir — pin bumps
  now invalidate stale installs instead of serving 0.1.1 forever)
- @metaharness/kernel  ~0.1.0 → ~0.1.2

New surfaces (13 → 15 MCP tools, 11 → 13 CLI subcommands):
- metaharness_learn / `ruflo metaharness learn` — upstream ADR-235 GEPA
  learning run; $0 dry-run default, --run to spend, structured
  checkout-required payload when the metaharness clone is absent
- metaharness_gepa / `ruflo metaharness gepa` — darwin GEPA library
  surface (genome|validate|render|analyze); gepaOptimize stays
  library-only (in-process evaluator can't cross subprocess boundary)
- skills: harness-learn, harness-gepa

Fixes found during validation:
- gepa.mjs treats ERR_PACKAGE_PATH_NOT_EXPORTED (stale pre-0.8.0 darwin
  in ancestor node_modules) as recoverable → falls back to versioned cache
- smoke.sh contract counts advanced (scripts 13→15, tools 13→15,
  subcommands 11→13, CLAUDE.md doc counts)

Validated: tsc clean; test-mcp-tools 171/171 across all 15 tools; darwin
0.8.0 evolve/bench/security-bench verbs proven through wrappers; redblue
0.1.4 attack preview proven via new cache path.

Co-Authored-By: RuFlo <ruv@ruv.net>

---------

Co-authored-by: djimit <djimit@users.noreply.github.com>
2026-07-03 14:17:09 -04:00

5.0 KiB

ruflo-metaharness

MetaHarness integration plugin for ruflo. Surfaces the upstream metaharness / harness / @metaharness/darwin CLIs through eleven ruflo skills, honoring ADR-150's architectural constraint that MetaHarness must remain a removable augmentation — never a required runtime dependency.

ADR-150 architectural constraint (load-bearing)

Ruflo remains operational if every MetaHarness package is removed. Every code path in this plugin satisfies four rules:

  1. Removable — no static import '@metaharness/*' outside the optional-router path in v3/@claude-flow/cli/src/ruvector/neural-router.ts.
  2. Optional in package.jsonmetaharness is in optionalDependencies, never dependencies.
  3. Graceful degradation — every script catches MODULE_NOT_FOUND/network failure and emits { degraded: true, reason: 'metaharness-not-available' } JSON, exits 0. The graceful path is the default behavior, not a special case.
  4. CI gateno-metaharness-smoke.yml runs the plugin smoke with npm install --no-optional and asserts the contract still passes.

Skills

Skill Usage Description
harness-score /harness-score [--path .] [--alert-on-fit-below 70] 5-dim readiness scorecard (harnessFit/compile/coverage/safety/memory + cost)
harness-genome /harness-genome [--path .] [--alert-on-risk-above 0.5] 7-section categorical report (repo_type/topology/risk/mcp/test/publish)
harness-mcp-scan /harness-mcp-scan [--path .] [--fail-on high] Static MCP security findings — pure-read, no dispatch
harness-threat-model /harness-threat-model [--path .] [--fail-on high] Enterprise-grade threat model (clean/low/medium/high + findings)
harness-mint /harness-mint --name <id> --template <id> [--confirm] Scaffold a custom harness; DRY-RUN by default; refuses project-root writes
harness-similarity /harness-similarity --a a.json --b b.json [--per-dimension] [--alert-below 0.5] ADR-152 §3.1 weighted similarity between two harness fingerprints (cosine + categorical + jaccard)
harness-oia-audit /harness-oia-audit [--path .] [--alert-on-worst high] [--dry-run] Composite Phase-2 audit (oia-manifest + threat-model + mcp-scan) into metaharness-audit namespace
harness-drift-from-history /harness-drift-from-history [--baseline-since 7d] [--threshold 0.95] 1-command drift detection — composes audit-list + oia-audit + audit-trend
harness-bench /harness-bench --op create|verify --repo <path> Manage @metaharness/darwin bench suites — fixed evaluation corpora for harness-evolve
harness-evolve /harness-evolve --repo <path> [--generations 3] [--sandbox real|mock|agent] Run @metaharness/darwin evolve — mutate seven policy surfaces, sandbox-score variants, promote measured wins
harness-security-bench /harness-security-bench [--population 2] [--cycles 1] [--alert-on-fail] "Darwin Shield" / ADR-155 — evolve a security-detection harness against a 10-vuln corpus
harness-learn /harness-learn --host <h> --model <m> --slice <manifest> [--repo <checkout>] [--run] metaharness@0.3.0 / upstream ADR-235 — GEPA learning run; $0 dry-run default, --run to spend; needs a metaharness repo checkout
harness-gepa /harness-gepa --op genome|validate|render|analyze [--path <genome.json>] darwin@0.8.0 GEPA library surface — genome load/validate/render + transcript failure analysis; gepaOptimize stays library-only

Phase-0 baseline (ruflo itself, 2026-06-16)

{
  "harnessFit": 82,
  "compileConfidence": 100,
  "taskCoverage": 79,
  "toolSafety": 100,
  "memoryUsefulness": 40,
  "estCostPerRunUsd": 0.048,
  "recommendedMode": "CLI + MCP",
  "archetype": "typescript-sdk-harness",
  "template": "vertical:coding",
  "scaffoldReady": true,
  "risk_score": 0.27,
  "publish_readiness": 0.9
}

Architecture

All skills use subprocess invocation through the _harness.mjs shared helper:

skills/X/SKILL.md → scripts/X.mjs → scripts/_harness.mjs → spawnSync('npx', ['metaharness', …])
                                                  ↘ on MODULE_NOT_FOUND → emit degraded JSON, exit 0

This means:

  • No library import overhead on ruflo's boot path
  • 60s hard timeout per subprocess (bounded blast radius)
  • --json flag forced for structured parsing
  • Graceful degradation is a single helper used by every skill
  • ADR-150 — decision + architectural constraint
  • Issue #2399 — phase rollout tracker
  • Research dossier — full graded-evidence sourcing
  • Upstreammetaharness source
  • ADR-148/149 — @metaharness/router cost-optimal routing (sibling integration)