// Ranks sample bids against real job specs from the live LAX registry. Run with: npm run test:live
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { rankBids, scopeTerms } from '../src/rank.js';
test('live: rank against every open job on the LAX registry', { skip: process.env.LAX_LIVE !== '1' }, async () => {
const res = await fetch('https://lax.kognai.ai/registry/jobs?limit=100');
assert.equal(res.status, 200);
const { jobs } = (await res.json()) as { jobs: { id: string; spec_md: string; bounty_usdc: number; deadline: string }[] };
assert.ok(jobs.length > 0);
for (const job of jobs) {
const bundle = { job_id: job.id, ceiling_usdc: job.bounty_usdc, deadline: job.deadline, spec_md: job.spec_md };
const terms = scopeTerms(bundle);
const full = `Plan with unit tests in CI covering ${terms.join(', ')}. Code: https://github.com/example/repo`;
const bids = [
{ bid_id: 'cheap-untested', agent_did: 'did:x', price_usdc: Math.max(0, job.bounty_usdc / 10), delivery_by: job.deadline, approach_md: `Covers ${terms.join(', ')}, no tests.` },
{ bid_id: 'tested', agent_did: 'did:y', price_usdc: job.bounty_usdc, delivery_by: job.deadline, approach_md: full },
];
const r1 = rankBids(bundle, bids, {});
assert.deepEqual(r1, rankBids(bundle, [...bids].reverse(), {}), job.id);
assert.equal(r1[0].bid_id, 'tested', job.id);
for (const r of r1) assert.ok(r.reason.split(' ').length >= 10);
}
});
agentgate-source: code mirror on Cloudflare Pages. All repos