feat(v2): add safe AI fallback and cache/reanalysis decision

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Gustavo
2026-08-24 15:15:50 -03:00
co-authored by Claude Sonnet 5
parent c445e00fc5
commit efba7792fa
4 changed files with 68 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
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' };
}
module.exports = { needsReanalysis };