import type { Signal, SignalAdapter } from '../types.ts' export const frictionAdapter: SignalAdapter = { id: 'friction', displayName: 'Friction log', normalize(raw, ctx) { const rec = (raw && typeof raw === 'object' ? raw : {}) as Record const title = String(rec.title ?? 'Friction') const repo = rec.repo ? String(rec.repo) : null const externalId = String(rec.issueNumber ?? rec.id ?? title) const signal: Signal = { id: `sig_${crypto.randomUUID().replace(/-/g, '').slice(0, 12)}`, projectId: ctx.projectId, source: 'friction', externalId, fingerprint: `friction:${repo ?? 'none'}:${title.toLowerCase()}`, title, body: String(rec.body ?? rec.preliminaryInvestigation ?? ''), severity: 'medium', labels: ['friction', ...(Array.isArray(rec.labels) ? rec.labels.map(String) : [])], links: [], repoRef: repo, receivedAt: new Date().toISOString(), } return [signal] }, }