Pin durable AI source text and requirements across retries

This commit is contained in:
2026-09-06 12:42:16 +03:00
parent 801d4fca8d
commit ca0ed73242
6 changed files with 86 additions and 15 deletions
+14
View File
@@ -0,0 +1,14 @@
import {createHash} from 'node:crypto';
export async function resolveAiJobInput(job,resolve,pin,signal,captureRequirements) {
signal?.throwIfAborted();
if(job.sourcePinned)return job.input;
const source=await resolve(job.input.ikn,job.input.text,job.input.tender?.aciklama);
signal?.throwIfAborted();
if(typeof source?.text!=='string')throw new Error('Kaynak metni okunamadı.');
const input={...job.input,...(captureRequirements ? {gereklilikler:captureRequirements(job.input)} : {}),text:source.text,resolvedSource:{text:source.text,kaynak:source.kaynak,
hash:createHash('sha256').update(source.text).digest('hex'),capturedAt:new Date().toISOString()}};
// An empty resolution is also pinned, so a retry cannot silently acquire a new source.
if(!pin(job.id,job.runId,input))throw new Error('İş artık etkin değil; kaynak kaydedilemedi.');
return input;
}