import type { Pool } from "pg"; import type { Project } from "../config.js"; import { type RunAdmission } from "../db/admission.js"; import { type RunRecord } from "../domain.js"; import { type ApprovalGate, type ApprovalRecord, type WorkDecision, type WorkItem, type WorkSource } from "./schema.js"; export interface WorkInspection { work: WorkItem; approvals: ApprovalRecord[]; decision: WorkDecision; /** The issue comment an allowed approver posts for the awaiting gate. */ approvalComment?: string; } export declare class WorkStore { private readonly scope; private readonly redact; private readonly admission; private readonly db; constructor(pool: Pool, scope: string, redact: (text: string) => string, admission: RunAdmission); private predicate; private event; private contract; /** * Intake is idempotent on the source identity: an existing item keeps its * contract and observes the given source, which can change its revision. */ create(projectId: string, inputSource: WorkSource, input: unknown): Promise; get(id: string): Promise; list(projectId?: string): Promise; approvals(id: string): Promise; private approvalsIn; inspect(id: string, project: Project): Promise; propose(id: string, expectedRevision: string, input: unknown): Promise; refreshSource(id: string, source: WorkSource): Promise; /** * Bind the Work Item to the issue that `effect` publishes its contract to, * then mark the contract assessed against that issue revision. The row stays * locked during the effect, so competing publications cannot create a second * issue. A changed source revision invalidates earlier approvals. */ publish(id: string, expectedRevision: string, project: Project, effect: (work: WorkItem) => Promise): Promise; approve(id: string, expectedRevision: string, gate: ApprovalGate, operator: { approvedBy: string; source: ApprovalRecord["source"]; evidence?: string; }, project: Project): Promise; /** * Admit the exact revision as a Run. Replaying an admitted revision returns * its latest attempt. A blocked project is admitted only with `recovery`, * whose safety check runs under the project lock and must not write. */ submit(id: string, expectedRevision: string, project: Project, recovery?: { checkSafety: (related: RunRecord[]) => Promise; }): Promise; }