import { repoDb } from "./scoped-db";
import { randomId, sha256Hex } from "./crypto";
import { onCommitStatus } from "./merge-automation";
import { withStore } from "./git/store";
import { readWorkflowFiles } from "./ci/scheduler";
import { parseWorkflow } from "./ci/spec";
import type { RepoRow, StatusState } from "~/lib/types";
const decoder = new TextDecoder();
/** `ci`: written by gitfor Actions (bound to a workflow file); `api`: posted by an external integration. */
export type StatusSource = "ci" | "api";
export type CommitStatusRow = {
id: string;
repo_id: string;
sha: string;
context: string;
state: StatusState;
description: string | null;
target_url: string | null;
workflow_path: string | null;
workflow_hash: string | null;
source: StatusSource | null;
created_at: number;
updated_at: number;
};
export async function setCommitStatus(input: {
repoId: string;
sha: string;
context: string;
state: StatusState;
description: string | null;
targetUrl: string | null;
/** Workflow file that produced the status; its content hash lets branch protection verify the definition. */
workflowPath?: string | null;
workflowSource?: string | null;
source: StatusSource;
}): Promise<void> {