import type { StopAdapter } from "./result-service.js"; import type { Clock, KernelPaths, TaskRecord, V2TypedEvent } from "./types.js"; export interface GithubIssueSnapshot { readonly number: number; readonly node_id: string; readonly title: string; readonly body: string; readonly labels: readonly string[]; readonly state: "open" | "closed"; readonly updated_at: string; } export interface GithubPullRequestSnapshot { readonly number: number; readonly node_id: string; readonly title: string; readonly state: "open" | "closed" | "merged"; readonly head_sha: string; readonly updated_at: string; } export interface GithubCheckSnapshot { readonly check_id: string; readonly name: string; readonly status: string; readonly conclusion: string | null; readonly head_sha: string; readonly updated_at: string; } export interface GithubPollSuccess { readonly ok: true; readonly repository: string; readonly inventory_complete: true; readonly streams_complete: { readonly issues: true; readonly pull_requests: true; readonly checks: true; }; readonly ready_issue_count: number; readonly issues: readonly GithubIssueSnapshot[]; readonly pull_requests: readonly GithubPullRequestSnapshot[]; readonly checks: readonly GithubCheckSnapshot[]; } export interface GithubPollFailure { readonly ok: false; readonly reason: string; } export type GithubPollResult = GithubPollSuccess | GithubPollFailure; export interface GithubPollAdapter { readonly poll: () => GithubPollResult; } export interface ApplyGithubPollOutcome { readonly events: readonly V2TypedEvent[]; readonly eventsCreated: number; readonly successfulEmpty: boolean; readonly pollFailed: boolean; readonly admitted: number; readonly updated: number; readonly cancelled: number; readonly stale: boolean; readonly physicalWakeEventIds: readonly string[]; } export interface GithubCancellationTerminalInspection { readonly status: "non_terminal" | "done" | "blocked"; readonly task_id: string; readonly version: number; } export interface GithubWorkerCancellationRequest { readonly operation_id: string; readonly reason: "source_removed" | "source_changed"; readonly task_id: string; readonly task_version: number; readonly due_at: string; readonly batch_digest: string; readonly event_id: string; } export interface NormalizedGithubInventory { readonly repository: string; readonly issues: readonly Readonly>[]; readonly pull_requests: readonly Readonly>[]; readonly checks: readonly Readonly>[]; readonly ready_issue_count: number; } declare function normalizeIssue(raw: GithubIssueSnapshot): Readonly<{ number: number; node_id: string; state: "open" | "closed"; body_digest: string; label_digest: string; title_digest: string; snapshot_digest: string; labels: readonly string[]; updated_at: string; assignment: import("./assignment.js").GithubIssueAssignmentSnapshot; observation_key: `issue:${number}`; }>; declare function normalizePr(raw: GithubPullRequestSnapshot): Readonly<{ number: number; node_id: string; state: "open" | "closed" | "merged"; head_sha: string; title_digest: string; snapshot_digest: string; updated_at: string; observation_key: `pr:${number}`; }>; declare function normalizeCheck(raw: GithubCheckSnapshot): Readonly<{ check_id: string; name: string; status: string; conclusion: string | null; head_sha: string; snapshot_digest: string; updated_at: string; observation_key: `check:${string}`; }>; /** Strict normalize of a proven-complete poll success. */ export declare function normalizeCompleteGithubInventory(batch: GithubPollSuccess, readyLabel: string): NormalizedGithubInventory; export declare function githubSlotIntentId(runId: string, dueAt: string): string; export declare function githubSlotCompletionId(runId: string, dueAt: string): string; export type GithubDueSlotPhase = "none" | "intent" | "complete"; export interface GithubDueSlotView { readonly phase: GithubDueSlotPhase; readonly batch_digest: string | null; readonly outcome: "success" | "failure" | null; /** Sanitized inventory stored on success intent for offline resume. */ readonly inventory: NormalizedGithubInventory | null; readonly failure_reason: string | null; readonly completion: ApplyGithubPollOutcome | null; } /** Inspect durable due-slot journal before external GitHub I/O. */ export declare function inspectGithubDueSlot(paths: KernelPaths, runId: string, dueAt: string): GithubDueSlotView; /** Count prior removed edges for observation_key → next edge generation. */ export declare function edgeGenerationForKey(paths: KernelPaths, runId: string, observationKey: string): number; /** Canonical batch digest — inventory keys sorted so ordering is not identity. */ export declare function githubSuccessBatchDigest(inventory: NormalizedGithubInventory): string; export declare function normalizeGithubFailureReason(raw: unknown): { readonly code: string; readonly digest: string; /** Canonical bounded journal value: `${code}:${digest}` (≤ 80 chars). */ readonly reason: string; }; export declare function applyGithubPollObservations(input: { readonly paths: KernelPaths; readonly clock: Clock; readonly batch?: GithubPollSuccess; readonly inventory?: NormalizedGithubInventory; readonly expectedRunId: string; readonly expectedMonitorGeneration: number; readonly expectedOwner: string; readonly expectedDueGithubAt: string | null; readonly resumeFromIntent?: boolean; }): ApplyGithubPollOutcome; export declare function applyGithubPollObservationsUnlocked(input: { readonly paths: KernelPaths; readonly clock: Clock; /** Required for new slots; optional when resuming from intent inventory. */ readonly batch?: GithubPollSuccess; readonly inventory?: NormalizedGithubInventory; readonly expectedRunId: string; readonly expectedMonitorGeneration: number; readonly expectedOwner: string; readonly expectedDueGithubAt: string | null; /** When true, resume intent-without-completion without requiring a live batch. */ readonly resumeFromIntent?: boolean; }): ApplyGithubPollOutcome; export declare function recordGithubPollFailureUnlocked(input: { readonly paths: KernelPaths; readonly clock: Clock; readonly expectedRunId: string; readonly expectedMonitorGeneration: number; readonly expectedOwner: string; readonly expectedDueGithubAt: string | null; readonly reason?: string; }): { readonly ok: boolean; readonly stale: boolean; }; /** * Rebuild last-known inventory from journal typed events (latest per observation_key). * Retention of removal tombstones is required so a later identical terminal/absent * snapshot does not re-emit removed edges/wakes. */ export interface GithubInventoryPrior { /** Latest payload per observation_key (present or last removed snapshot). */ readonly byKey: Map>>; /** Keys whose latest edge is a removal tombstone. */ readonly removedKeys: ReadonlySet; } export declare function loadGithubInventoryFromJournal(paths: KernelPaths, runId: string): GithubInventoryPrior; export declare function inspectGithubWorkerCancellationRequest(input: { readonly paths: KernelPaths; readonly runId: string; readonly taskId: string; }): GithubWorkerCancellationRequest | null; export declare function completeGithubWorkerCancellation(input: { readonly paths: KernelPaths; readonly clock: Clock; readonly expectedRunId: string; readonly expectedRunVersion: number; readonly taskId: string; readonly expectedTaskVersion: number; readonly reason: "source_removed" | "source_changed"; readonly stopAdapter?: StopAdapter; }): TaskRecord; /** * Read-only certification for GitHub source-cancellation terminals. */ export declare function inspectGithubCancellationTerminal(input: { readonly paths: KernelPaths; readonly runId: string; readonly taskId: string; }): GithubCancellationTerminalInspection; export {};