import type { FindingRecord } from '../domain/finding'; import { gpoWorkSettingIdentity } from '../features/results-browser/work-record-lookup'; /** * Cross-timeslot key of a GPO Work record: its scope and technical identity, the same key the comparison * uses (`identityKey`). Read from the record's Raw Data fields like the Core report projection, because a * rolled-up setting's record ID does not always carry them; the setting ID form is the fallback. */ export function gpoRecordSettingKey(record: FindingRecord): string | undefined { const field = (label: string) => record.fields.find(item => item.label === label)?.value; const scope = field('Scope'); const identity = field('Technical Identity'); if (scope && identity) return JSON.stringify([scope, identity]); const fromId = gpoWorkSettingIdentity(record.id); return fromId ? JSON.stringify([fromId.scope, fromId.settingId]) : undefined; }