Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,32 @@ jobs:
EVO_TEST_DATABASE_URL: postgresql://postgres:evoforge-ci-only@localhost:5432/postgres
api:
runs-on: ubuntu-latest
# Leave time to upload diagnostics after the bounded test step fails.
timeout-minutes: 75
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: '3.12' }
- run: pip install -r services/api/requirements.txt
- run: pytest -q services/api/tests
- name: API regression tests
timeout-minutes: 60
shell: bash
run: |
set -o pipefail
mkdir -p artifacts
python -u -m pytest services/api/tests -vv --durations=25 \
-o faulthandler_timeout=120 --junitxml=artifacts/api-junit.xml \
2>&1 | tee artifacts/api-pytest.log
- name: Save API test diagnostics
if: always()
uses: actions/upload-artifact@v4
with:
name: api-test-diagnostics
path: |
artifacts/api-pytest.log
artifacts/api-junit.xml
if-no-files-found: warn
retention-days: 7
- run: python -c "from main import app; from fastapi.testclient import TestClient; c=TestClient(app); assert c.get('/healthz').status_code==200"
working-directory: services/api
web:
Expand Down
23 changes: 19 additions & 4 deletions apps/web/app/[locale]/arena/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,21 @@ import { SandboxedPreview } from "../../../components/SandboxedPreview";
import { PromptBar } from "../../../components/PromptBar";
import { shareUrl } from "../../../lib/share";

const BENCHMARK_TASKS: Record<"v1" | "v2" | "v3" | "v4" | "v5", { id: string; goal: string }[]> = {
const BENCHMARK_TASKS: Record<"v1" | "v2" | "v3" | "v4" | "v5" | "v6", { id: string; goal: string }[]> = {
v6: [
{ id: "SV6-AO-01", goal: "In semver_range.py, check if a version satisfies an npm-style range" },
{ id: "SV6-AO-02", goal: "In intervals.py, merge labelled half-open intervals by priority" },
{ id: "SV6-CD-01", goal: "In reassemble.py, rebuild chat messages from out-of-order chunks" },
{ id: "SV6-CD-02", goal: "In retry.py, compute backoff waits with cap, jitter and budget" },
{ id: "SV6-CI-01", goal: "In shard_plan.py, split CI tests across shards with pinning" },
{ id: "SV6-CI-02", goal: "In junit_merge.py, merge CI attempts into final suite results" },
{ id: "SV6-PM-01", goal: "In tokens.py and calc.py, tokenize and evaluate expressions" },
{ id: "SV6-PM-02", goal: "In money.py and invoice.py, price invoice lines with tax" },
{ id: "SV6-SEC-01", goal: "In path_guard.py, join user paths safely under a root" },
{ id: "SV6-SEC-02", goal: "In jwt_lite.py, verify HS256 JWTs and return payload" },
{ id: "SV6-SS-01", goal: "In duration.py, parse and format durations like 1h30m" },
{ id: "SV6-SS-02", goal: "In slugify.py, make URL slugs like cafe-au-lait" },
],
v5: [
{ id: "SV5-AO-01", goal: "In semver_range.py, check if a version satisfies an npm-style range" },
{ id: "SV5-AO-02", goal: "In intervals.py, merge labelled half-open intervals by priority" },
Expand Down Expand Up @@ -102,8 +116,8 @@ export default function ArenaPage() {
const t = useTranslations("arena");
const locale = useLocale();
const tp = useTranslations("plan");
const [suiteVersion, setSuiteVersion] = useState<"v1" | "v2" | "v3" | "v4" | "v5">("v5");
const [selectedTaskId, setSelectedTaskId] = useState<string>("SV5-AO-01");
const [suiteVersion, setSuiteVersion] = useState<"v1" | "v2" | "v3" | "v4" | "v5" | "v6">("v6");
const [selectedTaskId, setSelectedTaskId] = useState<string>("SV6-AO-01");
const [customTaskId, setCustomTaskId] = useState<string>("");
const [feedback, setFeedback] = useState<"heldout" | "critic">("critic");
const [starting, setStarting] = useState(false);
Expand Down Expand Up @@ -383,13 +397,14 @@ export default function ArenaPage() {
<select
value={suiteVersion}
onChange={(e) => {
const sv = e.target.value as "v1" | "v2" | "v3" | "v4" | "v5";
const sv = e.target.value as "v1" | "v2" | "v3" | "v4" | "v5" | "v6";
setSuiteVersion(sv);
setSelectedTaskId(BENCHMARK_TASKS[sv]?.[0]?.id || "");
}}
className="bg-background-tertiary border border-border text-xs rounded px-2 py-1 text-text-primary flex-1 min-w-0 sm:flex-none"
disabled={running}
>
<option value="v6">Sealed v6 (12 hard tasks, 129 hidden tests)</option>
<option value="v5">Sealed v5 (12 hard tasks)</option>
<option value="v4">Sealed v4 (12 tasks)</option>
<option value="v3">Sealed v3 (48 tasks)</option>
Expand Down
3 changes: 2 additions & 1 deletion apps/web/app/[locale]/share/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getArena, getArenaProof, type ArenaDoc, type ArenaLane } from "../../..
import { manifestView, previewView } from "../../../../lib/arenaStatus";
import { shareText } from "../../../../lib/share";
import { SandboxedPreview } from "../../../../components/SandboxedPreview";
import { ShareComparisonBadge } from "../../../../components/ShareComparisonBadge";

type Side = "evoforge" | "single";

Expand Down Expand Up @@ -79,7 +80,7 @@ function ShareDetails({ doc, certificateId }: { doc: ArenaDoc; certificateId: st
<LaneScore side="single" lane={singleLane} leading={winner === "single"} />
</div>
<ul className="share-trust">
<li>{t("same-model", { model: doc.model || "—" })}</li>
<ShareComparisonBadge doc={doc}/>
<li>{t("same-tests")}</li>
{certificateId && <li>{t("signed")}</li>}
</ul>
Expand Down
5 changes: 4 additions & 1 deletion apps/web/app/api/evoforge/[...path]/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cookies } from "next/headers";
import { NextRequest, NextResponse } from "next/server";
import crypto from "node:crypto";
import { resolveApiPath } from "@/lib/proxyPolicy";
import { isApiMethodAllowed, resolveApiPath } from "@/lib/proxyPolicy";

const COOKIE_NAME = "__Host-evoforge-session";
const METADATA_BASE = "http://metadata.google.internal";
Expand Down Expand Up @@ -117,6 +117,9 @@ async function handle(req: NextRequest, params: { path?: string[] }) {
if (apiPath === null) {
return NextResponse.json({ error: "not found" }, { status: 404 });
}
if (!isApiMethodAllowed(apiPath, req.method)) {
return NextResponse.json({ error: "method not allowed" }, { status: 405, headers: { Allow: "GET, HEAD" } });
}

if (noAuth && req.method === "POST") {
if (isPostRateLimited(clientIp(req), postLimitPerMin())) {
Expand Down
3 changes: 2 additions & 1 deletion apps/web/components/CanvasWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { shareText, shareUrl } from '../lib/share';
import { laneView, manifestView, type ArenaAgentRow, type PreviewSource } from '../lib/arenaStatus';
import { StudioIcon } from './StudioIcon';
import { StudioHistory, StudioPeople } from './StudioViews';
import { DefaultModelsCard } from './DefaultModelsCard';

// Usage not reported -> priced at the reservation cap; the label says so in words (no "estimate").
const costKey = (state: string) => state === 'estimated' ? 'cost-reservation-cap' : `cost-${state}`;
Expand Down Expand Up @@ -177,7 +178,7 @@ export function CanvasWorkspace(props: Props) {
</>}
{panel === 'history' && <StudioHistory records={props.history ?? []} available={props.history !== null} loading={props.loading}/>}
{panel === 'metrics' && <>{props.overview}<section className="canvas-conditions"><h3>{t('conditions')}</h3><p>{props.doc?.prompt || props.doc?.goal || '—'}</p><code>{props.doc?.arena_id ?? '—'}</code>{manifest && <><dl><dt>{t('spec')}</dt><dd>{manifest.spec ?? '—'}</dd><dt>{t('base')}</dt><dd>{manifest.baseTree ?? '—'}</dd></dl><p>{manifest.disclosure ?? '—'}</p></>}{(['evoforge', 'single'] as const).map(side => <p key={side}>{side === 'evoforge' ? 'EvoForge' : t('single')} · {ts(costKey(laneView(props.doc?.lanes?.[side]).costState))}</p>)}</section></>}
{panel === 'admin' && props.management}
{panel === 'admin' && <><DefaultModelsCard/>{props.management}</>}
</div>
</dialog>
</main>;
Expand Down
49 changes: 49 additions & 0 deletions apps/web/components/DefaultModelsCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use client';

import { useCallback, useEffect, useRef, useState } from 'react';
import { useTranslations } from 'next-intl';
import { getModelDefaults } from '../lib/api';
import { modelDefaultsView, modelName, type ModelDefaultsView } from '../lib/modelDefaults';

export function DefaultModelsStatus({ view, loading, onRetry }: {
view: ModelDefaultsView;
loading: boolean;
onRetry: () => void;
}) {
const t = useTranslations('models');
return <section className="canvas-model-defaults" aria-labelledby="default-models-title" aria-busy={loading}>
<header>
<h3 id="default-models-title">{t(view.profile === 'collaborative' ? 'title' : 'setup')}</h3>
<span className={view.status === 'ready' ? 'is-ready' : ''} role="status">{t(loading ? 'loading' : view.status)}</span>
</header>
{view.status === 'ready' && !loading && <p>{t('keyless')}</p>}
{view.participants.length > 0 && <ul>{view.participants.map(item => <li key={`${item.role}:${item.model}`}>
<span><strong>{modelName(item.model)}</strong><small>{t(item.role)}</small></span>
<small>{t(item.configured ? 'connected' : 'missing')}</small>
</li>)}</ul>}
{!loading && view.status !== 'ready' && <p className="canvas-model-note">{t(view.status === 'unknown' ? 'unavailable' : 'incomplete')}<button type="button" onClick={onRetry}>{t('retry')}</button></p>}
</section>;
}

export function DefaultModelsCard() {
const [view, setView] = useState<ModelDefaultsView>({status: 'unknown', profile: null, participants: []});
const [loading, setLoading] = useState(true);
const generation = useRef(0);
const refresh = useCallback(async () => {
const current = ++generation.current;
setLoading(true);
try {
const result = await getModelDefaults();
if (current === generation.current) setView(modelDefaultsView(result));
} catch {
if (current === generation.current) setView({status: 'unknown', profile: null, participants: []});
} finally {
if (current === generation.current) setLoading(false);
}
}, []);
useEffect(() => {
void refresh();
return () => { generation.current++; };
}, [refresh]);
return <DefaultModelsStatus view={view} loading={loading} onRetry={() => { void refresh(); }}/>;
}
13 changes: 13 additions & 0 deletions apps/web/components/ShareComparisonBadge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use client';

import { useTranslations } from 'next-intl';
import type { ArenaDoc } from '../lib/api';
import { shareComparison } from '../lib/share';

export function ShareComparisonBadge({ doc }: { doc: ArenaDoc }) {
const t = useTranslations('share');
const comparison = shareComparison(doc);
return <li>{comparison.kind === 'multi_model' ? t('multi-model')
: comparison.kind === 'same_builder' ? t('same-model', {model: comparison.model ?? '—'})
: t('model-unconfirmed')}</li>;
}
23 changes: 22 additions & 1 deletion apps/web/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
// to the client at runtime.
export const API_BASE = "/api/evoforge";

export interface ModelDefaults {
profile: "collaborative" | "legacy";
ready: boolean;
requires_api_key: false;
default_builder: string;
default_critic: string;
participants: Array<{
role: "builder" | "planner" | "critic";
provider: "meta" | "openai" | "google" | "anthropic";
model: string;
configured: boolean;
}>;
blocked_reason: string | null;
}

export function getModelDefaults() {
return req<ModelDefaults>("/v1/models/defaults", { cache: "no-store" });
}

export type GateResult = "PASS" | "FAIL" | "INCONCLUSIVE";

export interface GateVerdict {
Expand Down Expand Up @@ -688,6 +707,8 @@ export interface ArenaLaneManifest {

export interface ArenaManifest {
comparison_mode?: string;
comparison_scope?: string;
collaboration?: ModelDefaults | null;
suite_version?: string;
task_id?: string;
task_spec_hash?: string;
Expand Down Expand Up @@ -756,7 +777,7 @@ export interface ArenaDoc {

export function postArena(
task_id: string,
suite_version: "v1" | "v2" | "v3" | "v4" | "v5" = "v2",
suite_version: "v1" | "v2" | "v3" | "v4" | "v5" | "v6" = "v2",
feedback: "heldout" | "critic" = "critic",
model = "muse-spark-1.3",
single_apply: "tolerant" | "strict" = "tolerant",
Expand Down
54 changes: 54 additions & 0 deletions apps/web/lib/modelDefaults.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type { ModelDefaults } from './api';

const MODELS = {
'muse-spark-1.3': { provider: 'meta', name: 'Muse Spark 1.3' },
'gpt-6.1-sol': { provider: 'openai', name: 'GPT-6.1 Sol' },
'gemini-4-argon': { provider: 'google', name: 'Gemini 4 Argon' },
'claude-opus-5-5': { provider: 'anthropic', name: 'Claude Opus 5.5' },
} as const;

export type ModelDefaultsView = {
status: 'ready' | 'blocked' | 'unknown';
profile: ModelDefaults['profile'] | null;
participants: ModelDefaults['participants'];
};

export function modelName(model: string): string {
return Object.prototype.hasOwnProperty.call(MODELS, model) ? MODELS[model as keyof typeof MODELS].name : '';
}

// A ready badge requires a complete, consistent server response. Missing or
// contradictory readiness must never become a client-side "ready" default.
export function modelDefaultsView(input: unknown): ModelDefaultsView {
const unknown: ModelDefaultsView = { status: 'unknown', profile: null, participants: [] };
if (!input || typeof input !== 'object' || Array.isArray(input)) return unknown;
const doc = input as Partial<ModelDefaults>;
if ((doc.profile !== 'collaborative' && doc.profile !== 'legacy') ||
typeof doc.ready !== 'boolean' || doc.requires_api_key !== false ||
doc.default_builder !== 'muse-spark-1.3' || !Array.isArray(doc.participants) ||
doc.participants.length === 0 || doc.participants.length > 4) return unknown;
const participants: ModelDefaults['participants'] = [];
const identities = new Set<string>();
for (const item of doc.participants) {
if (!item || typeof item !== 'object' ||
!['builder', 'planner', 'critic'].includes(item.role) ||
typeof item.model !== 'string' || typeof item.configured !== 'boolean') return unknown;
if (!Object.prototype.hasOwnProperty.call(MODELS, item.model)) return unknown;
const model = MODELS[item.model as keyof typeof MODELS];
if (!model || item.provider !== model.provider) return unknown;
const identity = `${item.role}:${item.model}`;
if (identities.has(identity)) return unknown;
identities.add(identity);
participants.push({role: item.role, provider: item.provider, model: item.model, configured: item.configured});
}
const expected = doc.profile === 'collaborative'
? ['builder:muse-spark-1.3', 'planner:gpt-6.1-sol', 'planner:gemini-4-argon', 'critic:claude-opus-5-5']
: ['builder:muse-spark-1.3', 'critic:muse-spark-1.3'];
const critic = doc.profile === 'collaborative' ? 'claude-opus-5-5' : 'muse-spark-1.3';
const complete = doc.default_critic === critic && identities.size === expected.length && expected.every(id => identities.has(id));
return {
profile: doc.profile,
participants,
status: doc.ready && complete && participants.every(item => item.configured) ? 'ready' : 'blocked',
};
}
16 changes: 16 additions & 0 deletions apps/web/lib/proxyPolicy.cases.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
[
{
"expected": "/v1/models/defaults",
"path_segments": ["v1", "models", "defaults"]
},
{
"expected": null,
"path_segments": ["v1", "models", "keys"]
},
{
"expected": null,
"path_segments": ["v1", "models", "defaults", "keys"]
},
{
"expected": null,
"path_segments": ["v1", "models", "..", "kernel"]
},
{
"expected": "/v1/participants",
"path_segments": [
Expand Down
5 changes: 5 additions & 0 deletions apps/web/lib/proxyPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const EXACT_ALLOW = new Set([
"/v1/outcomes",
"/v1/performance",
"/v1/participants",
"/v1/models/defaults",
"/v1/eval/suites",
"/v1/eval/baseline",
"/v1/eval/pipeline",
Expand All @@ -38,6 +39,10 @@ const EXACT_ALLOW = new Set([
const SEGMENT_RE = /^[A-Za-z0-9._~-]+$/;
const CONTROL_RE = /[\x00-\x1f\x7f]/;

export function isApiMethodAllowed(apiPath: string, method: string): boolean {
return apiPath !== '/v1/models/defaults' || method === 'GET' || method === 'HEAD';
}

export function resolveApiPath(segments: string[]): string | null {
if (!Array.isArray(segments) || segments.length === 0) return null;
for (const seg of segments) {
Expand Down
19 changes: 19 additions & 0 deletions apps/web/lib/share.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
import type { ArenaDoc } from "./api";

export function shareComparison(doc: ArenaDoc | null | undefined): {
kind: 'multi_model' | 'same_builder' | 'unconfirmed'; model: string | null;
} {
const manifest = doc?.manifest;
if (manifest?.comparison_scope === 'multi_model_system_vs_single_model' ||
manifest?.collaboration?.profile === 'collaborative') {
return {kind: 'multi_model', model: null};
}
const single = manifest?.lanes?.single?.model;
const evoforge = manifest?.lanes?.evoforge?.model;
if (typeof single === 'string' && single && typeof evoforge === 'string' && evoforge) {
return single === evoforge ? {kind: 'same_builder', model: single} : {kind: 'unconfirmed', model: null};
}
// Historical records have the common Builder model at the document root.
return typeof doc?.model === 'string' && doc.model
? {kind: 'same_builder', model: doc.model}
: {kind: 'unconfirmed', model: null};
}

export function shareUrl(origin: string, locale: string, arenaId: string): string {
const base = (origin ?? "").replace(/\/+$/, "");
const prefix = locale === "ko" ? "/ko" : "";
Expand Down
Loading
Loading