Assessor_2.0/src/compliance/compliance-store.ts

43 lines
2.6 KiB
TypeScript

import type { AssessorRepository } from '../persistence/assessor-repository';
import type { RegulatoryMappingBatchRun, RegulatoryMappingDecision, RegulatoryMappingRun } from './regulatory-mapping';
/**
* 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<AssessorRepository,
'getUnifiedResultById' | 'queryUnifiedResults' | 'getProject' | 'listProjects' | 'listAssessments' | 'listProjectScanRuns'>;
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[];
}
/** The engine's own storage: mapping runs, accept/reject decisions and batches. */
export interface ComplianceStore {
getRegulatoryMappingRun(id: string): Promise<RegulatoryMappingRun | null>;
claimRegulatoryMappingRun(run: RegulatoryMappingRun, forceRegeneration: boolean): Promise<{ run: RegulatoryMappingRun; claimed: boolean }>;
saveRegulatoryMappingRun(run: RegulatoryMappingRun): Promise<RegulatoryMappingRun>;
listRegulatoryMappingRuns(): Promise<RegulatoryMappingRun[]>;
createRegulatoryMappingBatchRun(run: RegulatoryMappingBatchRun): Promise<RegulatoryMappingBatchRun>;
updateRegulatoryMappingBatchRun(run: RegulatoryMappingBatchRun): Promise<RegulatoryMappingBatchRun>;
listRegulatoryMappingBatchRuns(projectId: string, scopeKey?: string): Promise<RegulatoryMappingBatchRun[]>;
createRegulatoryMappingDecision(decision: RegulatoryMappingDecision, expectedLatestDecisionId?: string): Promise<RegulatoryMappingDecision>;
listRegulatoryMappingDecisions(ruleKey: string): Promise<RegulatoryMappingDecision[]>;
exportProject(projectId: string): Promise<ComplianceProjectExport>;
}