import { z } from "zod"; import type { Questions } from "../exp-J-expansion/schema"; export const levels = [ "Work has barely begun.", "Early exploration; most of the work remains.", "Approach is taking shape; less than half is finished.", "Substantial work exists; important work remains.", "Nearly done; verification or final packaging remains.", "Delivered and verified against the task.", ]; export const questions: Questions = { whole_progress: { type: "score", instructions: "Estimate completion of the WHOLE workflow, not just the current step. Use workflow and completed_codons_observed plus recent evidence; no future result is supplied.", criteria: levels, }, step_progress: { type: "score", instructions: "Estimate completion of the CURRENT codon task from recent evidence, without mistaking intention or a completion claim for a checked deliverable.", criteria: levels, }, remaining_work: { type: "score", instructions: "How much substantive work remains before this workflow can finish? Judge the actual work still needed, not only how long the worker has already spent.", criteria: [ "Almost none; a checked deliverable is ready to hand off.", "A little; only final checks or packaging remain.", "Some; the main artifact exists but important checks or corrections remain.", "A substantial amount; an approach exists but important implementation or investigation remains.", "Most; the task is still being understood or the main approach has not worked.", ], }, time_remaining: { type: "choice", instructions: "Estimate the additional wall-clock time until this recorded workflow finishes its remaining work. Use observed_clock, the declared workflow, worker model, and current evidence. Do not confuse elapsed time with remaining time. Select the most plausible interval.", criteria: { under_30s: "Less than 30 seconds", s30_m1: "30 seconds to 1 minute", m1_3: "1 to 3 minutes", m3_10: "3 to 10 minutes", m10_30: "10 to 30 minutes", m30_90: "30 to 90 minutes", m90_240: "90 minutes to 4 hours", over_4h: "More than 4 hours", }, }, phase: { type: "choice", instructions: "Which activity best describes the current event in context?", criteria: { exploring: "Reading or searching to understand.", planning: "Choosing an approach or updating a plan.", building: "Writing or changing the deliverable.", checking: "Testing or inspecting whether work is correct.", recovering: "Diagnosing or fixing a failure.", reporting: "Explaining results or handing off.", }, }, deliverable_exists: { type: "noul", instructions: "Does the observed prefix show that the main requested deliverable actually exists, rather than only an intention or unsupported claim?", }, verified: { type: "noul", instructions: "Does the observed prefix show substantive verification of the current deliverable against its requirements?", }, blocked: { type: "noul", instructions: "Does current evidence show that the worker is blocked or repeating unsuccessful actions, rather than steadily carrying out a known plan?", }, }; export const timeSeconds: Record = { under_30s: 15, s30_m1: 45, m1_3: 120, m3_10: 390, m10_30: 1200, m30_90: 3600, m90_240: 9900, over_4h: 21600, }; export const Point = z.object({ id: z.string(), eventId: z.string(), line: z.number(), seconds: z.number(), stepSeconds: z.number(), cost: z.number(), completed: z.number(), planned: z.number(), codon: z.string(), state: z.record(z.unknown()), reading: z .object({ whole: z.number(), step: z.number(), remaining: z.number(), directSeconds: z.number(), phase: z.string(), exists: z.number(), verified: z.number(), blocked: z.number(), confidence: z.number(), requestHash: z.string(), }) .optional(), }); export const Trace = z.object({ id: z.string(), project: z.string(), family: z.string(), workItem: z.string(), source: z.string(), runId: z.string(), sourceSha256: z.string(), hankSha256: z.string(), seconds: z.number(), stateFinalCost: z.number().nullable(), eventFinalCost: z.number().nullable(), costBasis: z.string(), costReconciles: z.boolean(), workflow: z.array(z.object({ id: z.string(), name: z.string(), model: z.string() })), points: z.array(Point), allEvents: z.number(), workEvents: z.number(), warnings: z.array(z.string()), }); export type TraceData = z.infer; export const WorkItems = z.object({ groups: z.number(), method: z.string(), identities: z.array( z.object({ id: z.string(), canonicalWorkItem: z.string(), originalWorkItem: z.string(), launchPath: z.string(), launchSha256: z.string(), keys: z.array(z.string()), }), ), });