import type { AssessorRepository } from '../persistence/assessor-repository'; import type { RegulatoryMappingBatchRun, RegulatoryMappingDecision, RegulatoryMappingRun } from './regulatory-mapping'; import type { AiOverviewRun } from './ai-overview'; /** * The only Core reads the Compliance Engine performs (AGENTS.md, "Core Engine and engines"). The engine * never receives a repository method that writes Core data. */ export type ComplianceReadPort = Pick; export function complianceReadPortFrom(repository: ComplianceReadPort): ComplianceReadPort { return { getUnifiedResultById: (resultProjectionId, projectId) => repository.getUnifiedResultById(resultProjectionId, projectId), queryUnifiedResults: query => repository.queryUnifiedResults(query), getProject: projectId => repository.getProject(projectId), listProjects: () => repository.listProjects(), listAssessments: projectId => repository.listAssessments(projectId), listProjectScanRuns: projectId => repository.listProjectScanRuns(projectId) }; } /** The engine's project data, delivered beside the Core project export. */ export interface ComplianceProjectExport { regulatoryMappingBatchRuns: RegulatoryMappingBatchRun[]; /** Mappings and decisions are global and keyed by scanner rule, not by project. */ regulatoryMappingRuns: RegulatoryMappingRun[]; regulatoryMappingDecisions: RegulatoryMappingDecision[]; /** Succeeded AI overview runs of the project (table of migration 025, owned by the engine). */ aiOverviewRuns: AiOverviewRun[]; } /** The engine's own storage: mapping runs, accept/reject decisions, batches and AI overview runs. */ export interface ComplianceStore { createAiOverviewRun(run: AiOverviewRun): Promise; updateAiOverviewRun(run: AiOverviewRun): Promise; listAiOverviewRuns(projectId: string, scopeKey?: string): Promise; /** Removes runs of a project; the engine prunes runs whose timeslot no longer exists in the Core. */ deleteAiOverviewRuns(projectId: string, runIds: string[]): Promise; getRegulatoryMappingRun(id: string): Promise; claimRegulatoryMappingRun(run: RegulatoryMappingRun, forceRegeneration: boolean): Promise<{ run: RegulatoryMappingRun; claimed: boolean }>; saveRegulatoryMappingRun(run: RegulatoryMappingRun): Promise; listRegulatoryMappingRuns(): Promise; createRegulatoryMappingBatchRun(run: RegulatoryMappingBatchRun): Promise; updateRegulatoryMappingBatchRun(run: RegulatoryMappingBatchRun): Promise; listRegulatoryMappingBatchRuns(projectId: string, scopeKey?: string): Promise; createRegulatoryMappingDecision(decision: RegulatoryMappingDecision, expectedLatestDecisionId?: string): Promise; listRegulatoryMappingDecisions(ruleKey: string): Promise; exportProject(projectId: string): Promise; }