git-subtree-dir: coordenador git-subtree-mainline:facbe2e340git-subtree-split:ce7af94d55
18 lines
1015 B
JavaScript
18 lines
1015 B
JavaScript
function needsReanalysis({ memory, currentHash, now }) {
|
|
if (!memory) return { needsAi: true, reason: 'no_cache' };
|
|
if (memory.last_context_hash !== currentHash) return { needsAi: true, reason: 'context_changed' };
|
|
if (memory.next_review_at != null && now >= memory.next_review_at) return { needsAi: true, reason: 'review_due' };
|
|
return { needsAi: false, reason: 'cache_valid' };
|
|
}
|
|
|
|
// Chave de cache composta (conteudo do chamado + versao do classificador). Guardada no MESMO
|
|
// campo last_context_hash que ja existia -- sem migracao de schema na Data Table. Uma classe
|
|
// derivada e valida SE E SOMENTE SE contextHash bate E classifierVersion bate: bump de versao
|
|
// (logic/classification.js -> AI_CLASSIFIER_VERSION) forca cache miss em todo chamado, sem
|
|
// precisar apagar a Data Table na mao (missao "finalizacao para producao", secao 12).
|
|
function buildCacheKey(contextHash, classifierVersion) {
|
|
return `${contextHash}:v${classifierVersion}`;
|
|
}
|
|
|
|
module.exports = { needsReanalysis, buildCacheKey };
|