chore: snapshot main sync
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import type { FastifyBaseLogger, FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
|
||||
import type { Sql } from '../db.js';
|
||||
import type { FleetState } from '../services/fleet-state.js';
|
||||
import type { DeltaEmitter } from '../index.js';
|
||||
import type { DeltaEmitter } from '../services/delta-emitter.js';
|
||||
import { publishJob } from '../services/publish-job.js';
|
||||
import { acquireHostAccess } from '../services/host-access.js';
|
||||
import type { BenchSuite, BenchRunProgress } from '../services/bench-engine.js';
|
||||
import { runBenchSuite } from '../services/bench-engine.js';
|
||||
import { runBenchSuite, type BenchSuite, type BenchRunProgress } from "../services/bench-engine.js";
|
||||
import { resolveProviderBaseUrl } from '../services/llama-providers.js';
|
||||
import { jsonbNumberArray, jsonbObject } from '../services/jsonb.js';
|
||||
import type { AppContext } from '../app-context.js';
|
||||
|
||||
/**
|
||||
* Register bench routes.
|
||||
@@ -22,11 +22,9 @@ import { jsonbNumberArray, jsonbObject } from '../services/jsonb.js';
|
||||
*/
|
||||
export function registerBenchRoutes(
|
||||
app: FastifyInstance,
|
||||
sql: Sql,
|
||||
fleet: FleetState,
|
||||
emitter: DeltaEmitter,
|
||||
ctx: AppContext,
|
||||
): void {
|
||||
// ─── suite CRUD ──────────────────────────────────────────────────────────
|
||||
const { sql, fleet, emitter } = ctx;
|
||||
|
||||
app.post('/api/bench/suite', async (req: FastifyRequest, reply: FastifyReply) => {
|
||||
const body = req.body as Record<string, unknown>;
|
||||
@@ -136,8 +134,6 @@ export function registerBenchRoutes(
|
||||
});
|
||||
});
|
||||
|
||||
// ─── run launcher (P3.3: safety gates + P3.4: acquireHostAccess) ─────────
|
||||
|
||||
app.post('/api/bench/run', async (req: FastifyRequest, reply: FastifyReply) => {
|
||||
const body = req.body as Record<string, unknown>;
|
||||
const suiteId = body.suiteId as string;
|
||||
@@ -148,7 +144,6 @@ export function registerBenchRoutes(
|
||||
return reply.status(400).send({ error: 'suiteId is required' });
|
||||
}
|
||||
|
||||
// Load suite.
|
||||
const suiteRows = await sql<{
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -200,7 +195,6 @@ export function registerBenchRoutes(
|
||||
return reply.status(400).send({ error: `no base URL configured for provider ${suite.providerId}` });
|
||||
}
|
||||
|
||||
// Get seq for the host.
|
||||
const seq = hostState?.seq ?? 0;
|
||||
|
||||
// Run the bench suite asynchronously (non-blocking HTTP response).
|
||||
@@ -219,8 +213,6 @@ export function registerBenchRoutes(
|
||||
});
|
||||
});
|
||||
|
||||
// ─── runs listing ────────────────────────────────────────────────────────
|
||||
|
||||
app.get('/api/bench/runs', async (req: FastifyRequest, reply: FastifyReply) => {
|
||||
const query = req.query as Record<string, string | undefined>;
|
||||
const suiteId = query.suiteId;
|
||||
@@ -353,8 +345,6 @@ export function registerBenchRoutes(
|
||||
});
|
||||
});
|
||||
|
||||
// ─── baselines ───────────────────────────────────────────────────────────
|
||||
|
||||
app.get('/api/bench/baselines', async (_req: FastifyRequest, reply: FastifyReply) => {
|
||||
const rows = await sql<{
|
||||
provider_id: string;
|
||||
@@ -471,12 +461,11 @@ async function runBenchAsync(
|
||||
WHERE id = ${runId}
|
||||
`;
|
||||
|
||||
emitter.publish({
|
||||
type: 'control_job' as const,
|
||||
publishJob(emitter, {
|
||||
seq,
|
||||
jobType: 'bench' as const,
|
||||
jobType: 'bench',
|
||||
jobId: runId,
|
||||
status: 'failed' as const,
|
||||
status: 'failed',
|
||||
detail: { error: msg },
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user