ЮИ - Упростить карточки автопрогонов до названия даты id режима и типа
This commit is contained in:
@@ -3,15 +3,21 @@ import path from "path";
|
||||
import { Router } from "express";
|
||||
import iconv from "iconv-lite";
|
||||
import {
|
||||
ARTIFACTS_DIR,
|
||||
ASSISTANT_SESSIONS_DIR,
|
||||
AUTORUN_ANNOTATIONS_FILE,
|
||||
AUTORUN_GENERATOR_HISTORY_FILE,
|
||||
EVAL_CASES_DIR,
|
||||
EVAL_DATASETS_DIR,
|
||||
MANUAL_CASE_DECISION_SCHEMA_FILE,
|
||||
PROJECT_ROOT,
|
||||
REPORTS_DIR
|
||||
} from "../config";
|
||||
import type { AppServices } from "../serverContext";
|
||||
import {
|
||||
findLatestAgentSemanticAcceptanceSummary,
|
||||
readAgentSemanticSpecSummaryFromFile
|
||||
} from "../services/agentSemanticRunRegistry";
|
||||
import { ApiError, ok } from "../utils/http";
|
||||
import { loadCapabilitiesRegistry, resolveNearestCapabilityGroup, type CapabilityGroup } from "../services/capabilitiesRegistry";
|
||||
import { OpenAIResponsesClient } from "../services/openaiResponsesClient";
|
||||
@@ -197,6 +203,34 @@ interface AutoGenHistoryRecord {
|
||||
agent_focus?: string | null;
|
||||
architecture_phase?: string | null;
|
||||
source_spec_file?: string | null;
|
||||
scenario_id?: string | null;
|
||||
semantic_tags?: string[] | null;
|
||||
latest_acceptance?: {
|
||||
scenario_id: string;
|
||||
output_dir: string;
|
||||
relative_output_dir: string;
|
||||
final_status: string | null;
|
||||
final_status_reason: string | null;
|
||||
review_overall_status: string | null;
|
||||
acceptance_gate_passed: boolean | null;
|
||||
critical_path_green: boolean | null;
|
||||
unresolved_p0_count: number | null;
|
||||
unresolved_p1_count: number | null;
|
||||
unresolved_p2_count: number | null;
|
||||
steps_total: number | null;
|
||||
steps_passed: number | null;
|
||||
steps_with_warning: number | null;
|
||||
steps_failed: number | null;
|
||||
updated_at: string | null;
|
||||
invariants: {
|
||||
direct_answer_ok: boolean | null;
|
||||
temporal_honesty_ok: boolean | null;
|
||||
selected_object_continuity_ok: boolean | null;
|
||||
truth_gate_ok: boolean | null;
|
||||
human_answer_quality_ok: boolean | null;
|
||||
meta_context_integrity_ok: boolean | null;
|
||||
};
|
||||
} | null;
|
||||
} | null;
|
||||
}
|
||||
|
||||
@@ -375,7 +409,18 @@ function readAutoGenHistory(): AutoGenHistoryRecord[] {
|
||||
? repairAutogenMojibake(String(toRecord(item.context)?.agent_focus))
|
||||
: null,
|
||||
architecture_phase: toStringSafe(toRecord(item.context)?.architecture_phase),
|
||||
source_spec_file: toStringSafe(toRecord(item.context)?.source_spec_file)
|
||||
source_spec_file: toStringSafe(toRecord(item.context)?.source_spec_file),
|
||||
scenario_id: toStringSafe(toRecord(item.context)?.scenario_id),
|
||||
semantic_tags: Array.isArray(toRecord(item.context)?.semantic_tags)
|
||||
? Array.from(
|
||||
new Set(
|
||||
(toRecord(item.context)?.semantic_tags as unknown[])
|
||||
.map((tag) => toStringSafe(tag))
|
||||
.filter((tag): tag is string => Boolean(tag))
|
||||
)
|
||||
)
|
||||
: null,
|
||||
latest_acceptance: null
|
||||
}
|
||||
: null
|
||||
}))
|
||||
@@ -394,6 +439,81 @@ function writeAutoGenHistory(records: AutoGenHistoryRecord[]): void {
|
||||
fs.writeFileSync(AUTORUN_GENERATOR_HISTORY_FILE, JSON.stringify(records, null, 2), "utf-8");
|
||||
}
|
||||
|
||||
function isAgentSemanticHistoryRecord(record: AutoGenHistoryRecord): boolean {
|
||||
if (record.context?.agent_run === true) {
|
||||
return true;
|
||||
}
|
||||
if (record.context?.saved_case_set_kind === "agent_semantic_scenario") {
|
||||
return true;
|
||||
}
|
||||
return typeof record.title === "string" && record.title.trim().toUpperCase().startsWith("AGENT");
|
||||
}
|
||||
|
||||
function hydrateAutoGenHistoryForApi(records: AutoGenHistoryRecord[]): AutoGenHistoryRecord[] {
|
||||
const specSummaryCache = new Map<string, ReturnType<typeof readAgentSemanticSpecSummaryFromFile>>();
|
||||
const acceptanceCache = new Map<string, ReturnType<typeof findLatestAgentSemanticAcceptanceSummary>>();
|
||||
|
||||
const readSpecSummary = (sourceSpecFile: string | null | undefined) => {
|
||||
const normalizedPath = toStringSafe(sourceSpecFile);
|
||||
if (!normalizedPath) {
|
||||
return null;
|
||||
}
|
||||
if (specSummaryCache.has(normalizedPath)) {
|
||||
return specSummaryCache.get(normalizedPath) ?? null;
|
||||
}
|
||||
const summary = readAgentSemanticSpecSummaryFromFile(normalizedPath);
|
||||
specSummaryCache.set(normalizedPath, summary);
|
||||
return summary;
|
||||
};
|
||||
|
||||
const readAcceptanceSummary = (scenarioId: string | null | undefined) => {
|
||||
const normalizedScenarioId = toStringSafe(scenarioId);
|
||||
if (!normalizedScenarioId) {
|
||||
return null;
|
||||
}
|
||||
if (acceptanceCache.has(normalizedScenarioId)) {
|
||||
return acceptanceCache.get(normalizedScenarioId) ?? null;
|
||||
}
|
||||
const summary = findLatestAgentSemanticAcceptanceSummary({
|
||||
artifactsRootDir: path.resolve(ARTIFACTS_DIR, "domain_runs"),
|
||||
repoRootDir: PROJECT_ROOT,
|
||||
scenarioId: normalizedScenarioId
|
||||
});
|
||||
acceptanceCache.set(normalizedScenarioId, summary);
|
||||
return summary;
|
||||
};
|
||||
|
||||
return records.map((record) => {
|
||||
if (!isAgentSemanticHistoryRecord(record)) {
|
||||
return record;
|
||||
}
|
||||
const specSummary = readSpecSummary(record.context?.source_spec_file);
|
||||
const scenarioId = toStringSafe(record.context?.scenario_id) ?? specSummary?.scenario_id ?? null;
|
||||
const semanticTags =
|
||||
Array.isArray(record.context?.semantic_tags) && record.context?.semantic_tags.length > 0
|
||||
? Array.from(new Set(record.context?.semantic_tags.map((item) => String(item).trim()).filter((item) => item.length > 0)))
|
||||
: specSummary?.semantic_tags ?? [];
|
||||
const latestAcceptance = readAcceptanceSummary(scenarioId);
|
||||
return {
|
||||
...record,
|
||||
context: {
|
||||
...(record.context ?? {
|
||||
llm_provider: null,
|
||||
model: null,
|
||||
assistant_prompt_version: null,
|
||||
decomposition_prompt_version: null,
|
||||
prompt_fingerprint: null,
|
||||
autogen_personality_id: null,
|
||||
autogen_personality_prompt: null
|
||||
}),
|
||||
scenario_id: scenarioId,
|
||||
semantic_tags: semanticTags,
|
||||
latest_acceptance: latestAcceptance
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function readEvalDatasetCases(filePath: string): Array<Record<string, unknown>> {
|
||||
try {
|
||||
const parsed = JSON.parse(fs.readFileSync(filePath, "utf-8")) as unknown;
|
||||
@@ -2416,9 +2536,11 @@ export function buildAutoRunsRouter(services: AppServices, openaiClient = new Op
|
||||
const rawMode = toStringSafe((req.query as Record<string, unknown>).mode);
|
||||
const includeAllModes = !rawMode || !isAutoGenMode(rawMode);
|
||||
const modeFilter = (rawMode as AutoGenMode | null) ?? "codex_creative";
|
||||
const items = readAutoGenHistory()
|
||||
const items = hydrateAutoGenHistoryForApi(
|
||||
readAutoGenHistory()
|
||||
.filter((item) => (includeAllModes ? true : item.mode === modeFilter))
|
||||
.slice(0, limit);
|
||||
.slice(0, limit)
|
||||
);
|
||||
|
||||
ok(res, {
|
||||
ok: true,
|
||||
|
||||
Reference in New Issue
Block a user