Files
ruvnet--RuView/harness/wifi-densepose-sar/__tests__/router.test.ts
T
ruv 1b220c8d53 feat(harness): scaffold wifi-densepose-sar-harness with darwin, router, flywheel
Mints a real MetaHarness (via vendor/metaharness's published `npx
metaharness analyze --scaffold`, template vertical:coding, host
claude-code) for the wifi-densepose-sar crate: architect/implementer/
reviewer/test-writer agents, doctor/review-diff commands, MCP server,
Claude Code plugin -- following the same pattern as harness/ruview/
(ADR-182) and harness/homecore/ (ADR-285).

Adds real wiring for the three pieces this was scoped around:
- Darwin Mode (@metaharness/darwin) -- wired by the scaffold itself
  (npm run evolve / evolve:dry).
- Router (@metaharness/router) -- src/router.ts, a real k-NN
  cost-optimal Router over two example model tiers. Its labelled
  examples are illustrative seed data (see the file's honesty note),
  not measured eval-log observations; the routing mechanism itself is
  real and tested.
- Flywheel (@metaharness/flywheel) -- src/flywheel.ts, the real
  propose/evaluate/gate/promote loop wired with a SYNTHETIC proposer
  and evaluator (dataSource: 'SYNTHETIC', no model call). Proves the
  wiring end-to-end: a real signed, independently-replayable lineage,
  promoting each generation once the evaluator's noopRate actually
  moves (the default gate requires it to strictly improve -- a
  constant noopRate, even a "good" one, blocks every promotion
  forever, which the first version of this evaluator hit and the
  final version fixes).

14/14 tests pass (5 router + 5 flywheel + 4 install-smoke), `npm run
build` clean under strict TypeScript, CLI commands (route, flywheel)
verified manually. `.harness/manifest.json` is stale relative to the
router/flywheel additions -- this scaffold has no manifest:update
script (unlike harness/homecore/); documented as a known gap in the
harness's own README.
2026-07-31 00:36:38 -04:00

37 lines
1.4 KiB
TypeScript

// SPDX-License-Identifier: MIT
import { describe, it, expect } from 'vitest';
import { sarTaskRouter, routeSarQuery, SAR_ROUTER_CANDIDATES } from '../src/router.js';
describe('sarTaskRouter — @metaharness/router wiring', () => {
it('has both a cheap and a frontier candidate', () => {
const ids = SAR_ROUTER_CANDIDATES.map((c) => c.id);
expect(ids).toContain('cheap-tier');
expect(ids).toContain('frontier-tier');
});
it('routes a physics-explanation-shaped query to the cheap tier', () => {
const pick = routeSarQuery([1, 0, 0, 0]);
expect(pick.id).toBe('cheap-tier');
expect(pick.metBar).toBe(true);
});
it('routes a code-review-shaped query to the frontier tier (cheap tier misses the quality bar)', () => {
const pick = routeSarQuery([0, 1, 0, 0]);
expect(pick.id).toBe('frontier-tier');
});
it('always returns a candidate with a nonnegative predicted quality and a positive cost', () => {
for (const q of [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]] as const) {
const pick = routeSarQuery(q);
expect(pick.predictedQuality).toBeGreaterThanOrEqual(0);
expect(pick.costPerMTok).toBeGreaterThan(0);
}
});
it('sarTaskRouter.route and routeSarQuery agree (same underlying router)', () => {
const a = sarTaskRouter.route([1, 0, 0, 0]);
const b = routeSarQuery([1, 0, 0, 0]);
expect(a).toEqual(b);
});
});