import type { AssessorRepository } from '../../src/persistence/assessor-repository'; export async function seedReferenceScan(repository: AssessorRepository, prefix = 'synthetic-reference') { const at = '2026-09-26T00:00:00.000Z'; const project = { id: `${prefix}-project`, name: 'Synthetic reference client', createdAt: at, updatedAt: at, attributes: {} }; const assessment = { id: `${prefix}-assessment`, projectId: project.id, name: 'Synthetic timeslot', createdAt: at, updatedAt: at }; const scan = { id: `${prefix}-scan`, assessmentId: assessment.id, sequence: 1, label: 'Synthetic scan', tool: { id: 'generic', name: 'Synthetic scanner' }, importedAt: at }; const provenance = { decisionSource: 'source-native' as const, confidence: { level: 'high' as const, score: 1, reasons: ['synthetic'] }, mappingVersion: '1.0.0' }; await repository.saveProject(project); await repository.saveAssessment(assessment); const session = await repository.beginImport({ sessionId: prefix, projectId: project.id, assessmentId: assessment.id, scanRun: scan }); await session.stage({ importFiles: [{ id: `${prefix}-file`, scanRunId: scan.id, fileName: 'synthetic.csv', format: 'CSV', sizeBytes: 100, sha256: 'a'.repeat(64), importedAt: at, detectedTool: scan.tool, detection: provenance.confidence, processedWith: { parserId: 'csv', parserVersion: '1.0.0', profileId: 'generic', profileVersion: '1.0.0', mappingVersion: '1.0.0' }, sourceArtifact: { kind: 'not-retained', reason: 'Synthetic' } }], findingDefinitions: [{ id: `${prefix}-definition`, canonicalKey: `${prefix}:RULE1`, title: 'Synthetic reference finding', frameworkReferences: [], createdAt: at, updatedAt: at }], findingOccurrences: [{ id: `${prefix}-occurrence`, definitionId: `${prefix}-definition`, scanRunId: scan.id, importFileId: `${prefix}-file`, sourceIdentity: { tool: scan.tool, originalRuleId: 'RULE1' }, sourcePosition: { rowIndex: 1 }, originalFields: [{ key: 'attack', label: 'MITRE ATT&CK', value: 'T1059.001' }, { key: 'defense', label: 'MITRE D3FEND', value: 'D3-CH' }, { key: 'text', label: 'Description', value: 'Consider T1003; unknown T9999.' }], fieldMappings: [], severity: { originalValue: 'high', normalizedValue: 'high', provenance }, status: { originalValue: 'Open', normalizedValue: 'open', provenance } }] }); await session.commit(); return { project, assessment, scan, model: (await repository.loadAssessmentModel(assessment.id))! }; }