Files
ruflo/v3/@claude-flow
ruv bbbea9df43 feat(metaharness): SelfEvolvingRouter recorder primitive (iter 11)
ADR-150 Phase 2 SelfEvolvingRouter parallel-logging — RECORDING SIDE.
Iter 10 shipped the analyzer; this iter ships the producer primitive.

v3/@claude-flow/cli/src/ruvector/router-parallel-recorder.ts exports:

  recordPair({task, bandit, ser}) → {recorded, taskHash}
  recordPairOutcome({task, outcome}) → {recorded, taskHash}
  parallelRecorderStatus() → {enabled, path, includeTaskText, ...}

ARCHITECTURAL CONSTRAINTS (all satisfied)
  #1 Removable: pure-shape TS module; no static @metaharness/* import.
     The caller is responsible for dynamic-importing kernel and
     computing the SER pick BEFORE calling recordPair(). The recorder
     deliberately knows NOTHING about how either arm was computed.
  #2 Optional: every write gated behind CLAUDE_FLOW_ROUTER_PARALLEL_LOG=1.
     When unset (default), recordPair/recordPairOutcome are no-ops
     that return without touching the filesystem.
  #3 Graceful degradation: every appendFileSync wrapped in try/catch.
     Failed writes log to stderr only when DEBUG is set; the routing
     path NEVER throws or blocks. Mirrors router-trajectory.ts pattern.
  #4 CI gate: smoke step 17e verifies env-gating, no-throw doc,
     all three exports, schema fields, default path alignment with
     the iter-10 analyzer's --input default.

DESIGN
- Reuses `taskHash` from router-trajectory.ts (FNV-1a-32) so
  pair rows can be joined to existing trajectory rows by task fingerprint.
- 10MB rotation (env-configurable via CLAUDE_FLOW_ROUTER_PARALLEL_LOG_MAX_BYTES).
- Default output path .swarm/router-parallel.jsonl matches the
  iter-10 analyzer's --input default — wire-up is config-free.
- Schema versioned (v: 1); additive fields don't bump the version.
- Task text inclusion gated by SEPARATE env flag
  CLAUDE_FLOW_ROUTER_PARALLEL_LOG_TASK=1 (PII/retention concern).
- recordPairOutcome writes a separate row of type 'pair-outcome';
  analyzer joins client-side by task_hash, same pattern as the
  existing trajectory recorder.

WHAT REMAINS (deferred to a follow-up ADR — one-line edit)
  The model-router.ts hot path needs ONE LINE added inside route()
  alongside the bandit pick: `recordPair({task, bandit, ser})`. That
  isolated edit is now the only outstanding work, blast radius
  minimal because the recorder primitive is independently TS-typed
  and smoke-tested.

ADR-150 updated: Phase-2 SelfEvolvingRouter line marked ✅ (both
halves landed); model-router.ts dispatch edit explicitly called out
as the one-line follow-up.

Smoke: 20 → 21. Fleet: 33/33. tsc clean.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-16 14:06:28 -04:00
..
…