import type { Clock } from "../platform/clock"; import type { FsPort } from "../platform/fs"; import type { EntriesPort } from "../platform/ports"; import type { ModelKey, Tier } from "../episode/types"; export const REVIEW_ENTRY_TYPE = "fallback-review-index" as const; export type ReviewStatus = "active" | "reverted" | "suspended-by-user" | "given-up"; /** R16: `tier` is the role the writing model held WHEN the file was touched, copied off the segment and * never re-derived — an operator who later re-roles that model must not rewrite what the record says. * Optional because records written before this field existed carry none; absent means "unknown, from an * older build", not "tier 1". Kept in sync with the duplicate declaration in `flagging.ts`. */ export interface FlaggedFileRecord { path: string; model: ModelKey; timestamp: string; tier?: Tier; } export interface ShellActivityRecord { command: string; toolCallId: string; timestamp: string; } export interface FallbackReviewIndex { version: 1; episodeId: string; primary: ModelKey; status: ReviewStatus; reviewed: boolean; flaggedFiles: readonly FlaggedFileRecord[]; shellActivity: readonly ShellActivityRecord[]; } export type ReviewIndexEntry = FallbackReviewIndex; export interface ReviewScheduleMetadata { substate: "discriminating" | "hourly-probing" | "awaiting-resets_at" | "outage-pacing"; probeCount: number; consecutiveOutage: number; resetsAt: number | null; lastProbeAt: number; nextDueAt?: number; segmentDepth: number; segments: readonly ModelKey[]; } export interface ReviewMirrorEpisode { index: FallbackReviewIndex; schedule: ReviewScheduleMetadata; } export interface ReviewMirror { version: 1; updatedAt: string; episodes: Record; } export type RebuildPhase = "session-start" | "session-tree" | "session_start" | "session_tree"; export interface ReviewRebuildResult { index?: FallbackReviewIndex; schedule?: ReviewScheduleMetadata; malformedEntries: number; mirrorCorrupt: boolean; mirrorVersionAhead: boolean; staleSeed: boolean; seeded: boolean; } export interface ReviewIndexStoreOptions { cwd: string; entries: EntriesPort; fs: FsPort; clock?: Clock; }