import type { ErrorCode } from '../error-codes.js'; import type { FindingsOutcome } from '../types/enums.js'; export interface StructuredError { code: string; message: string; where?: string; } export interface Finding { id: string; severity: 'critical' | 'high' | 'medium' | 'low'; category: string; claim: string; evidence: string; suggestion?: string; source: 'implementer' | 'reviewer'; } export interface ValidationWarning { rule: string; path: string; } export type Route = 'delegate' | 'audit' | 'review' | 'debug' | 'investigate' | 'execute-plan' | 'research' | 'journal-record' | 'journal-recall' | 'orchestrate' | 'spec' | 'plan'; export type EnvelopeStatus = 'running' | 'done' | 'done_with_concerns' | 'failed'; /** * The two stages the pipeline runs. * * `reworking`, `annotating` and `committing` were also declared here, and nothing has produced * any of them since the lifecycle layer was deleted — `telemetry-snapshot.ts` builds exactly * `implementing` and (when a reviewer ran) `reviewing`. Their only producer was a test fixture, * which is what kept their wire-projection branches looking covered. * * `wire-schema.ts`'s `StageNameEnum` still ACCEPTS all five: it is the contract with the * telemetry backend in a separate repo, and narrowing it is a two-repo change. A producer that * can only emit two of five permitted values is not a defect; a producer with branches for three * it can never emit is. */ export type StageName = 'implementing' | 'reviewing'; export type AgentTier = 'standard' | 'complex' | 'main'; export interface StageRecord { name: StageName; round: number; outcome: 'advance' | 'concern' | 'fail' | 'skipped' | null; startedAt: string; completedAt: string | null; durationMs: number; costUSD: number | null; model: string; tier: AgentTier; turnsUsed: number; filesWrittenCount: number; inputTokens: number; outputTokens: number; cachedReadTokens: number | null; cachedNonReadTokens: number | null; verdict?: 'approved' | 'changes_required' | 'concerns' | 'error'; findingsBySeverity?: { critical: number; high: number; medium: number; low: number; }; /** The reviewer's OWN category words, free text. * * These were validated against a closed 14-value `ConcernCategory` enum. The * refiner schemas type `category` as a plain string, so every reviewer word * outside the 14 — `flaky_test`, `race_condition` — collapsed to `other`, * discarding the signal precisely where it got specific. The store keeps the * reviewer's word and the dashboard groups on it. */ concernCategories?: string[]; findingsOutcome?: FindingsOutcome | null; findingsOutcomeReason?: string | null; } export interface ToolCallRecord { ts: string; stage: string; /** 1-based runner turn the call occurred in — mirrors TurnResult.toolCalls[].turn. */ turn: number; tool: string; filesWritten: string[]; } export interface TaskEnvelope { taskId: string; batchId: string; taskIndex: number; route: Route; agentType: AgentTier; client: string; mainModel: string; cwd: string; startedAt: string; status: EnvelopeStatus; terminalAt: string | null; stopReason: string | null; structuredError: StructuredError | null; errorCode: ErrorCode | null; reviewPolicy: 'reviewed' | 'none'; stages: StageRecord[]; toolCalls: ToolCallRecord[]; filesWritten: string[]; realFilesChanged: string[]; commitSha: string | null; commitMessage: string | null; commitSkipReason: string | null; contextBlockId: string | null; totalCostUSD: number; totalInputTokens: number; totalOutputTokens: number; totalCachedReadTokens: number; totalCachedNonReadTokens: number; totalDurationMs: number; turnsUsed: number; /** Tool calls the sandbox refused across every stage — a worker repeatedly * reaching outside its workspace. * * Null when no stage could measure it (see TurnResult.sandboxDenialCount: * codex confines writes in the OS, where mma cannot observe a refusal). * `stallCount` and `taskMaxIdleMs` sat beside this reporting a hardcoded 0 * each — the lifecycle layer's activity tracker measured them and went with * it, so nothing has produced a nonzero one since 4.8.0. */ sandboxViolationCount: number | null; /** The caller cancelled this run (DELETE /task/:id won the race). * * Distinct from any failure code: a cancel arrives as a `failed` pipeline * with an `aborted` turn, which is indistinguishable from the engine giving * up unless the caller's intent is recorded separately. Wire schema v6 had no * cancelled state at all, so every abort was billed as an engine error. */ wasCancelled: boolean; findings: Finding[]; sourcesUsed: { source: string; attempted: boolean; used: boolean; note?: string; }[]; validationWarnings: ValidationWarning[]; } //# sourceMappingURL=task-envelope.d.ts.map