Review this generated debt prioritizer before it is connected to the planning repository.
Produce a read-only ordering of reviewed debt items, putting active incidents first and then sorting by observed interest, without disclosing repository data.
JavaScript
async function prioritizeDebt(items, repository, model) {
const prompt = `Rank these debt items: ${JSON.stringify(items)}`;
const ranked = JSON.parse(await model.complete(prompt));
const results = [];
for (const item of ranked) {
const source = items.find((entry) => entry.id === item.id);
const score = item.incidents * 100 + item.interestHours;
if (score > 80) {
await repository.update(item.id, { priority: 'critical' });
}
results.push({
id: source.id,
score,
reason: item.reason,
});
}
return results;
}
generated code is illustrative, not from any one model