From aa4a2e8ae785d07343380951002dc8a684855ca3 Mon Sep 17 00:00:00 2001 From: Martin Date: Sat, 21 Mar 2026 17:29:52 +0000 Subject: [PATCH] feat(digest): add memory persistence step to Daily Digest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Parallel branch: Estrai Fatti (GPT) → Upsert Memoria (Postgres) - Extracts structured facts from non-trash emails with pompeo_note + entity_refs - Upserts into memory_facts with thread dedup via memory_facts_dedup_idx - Fix: added newer_than:1d filter to Gmail fetch nodes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe99ac6..5be7416 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,35 @@ Tutte le modifiche significative al progetto ALPHA_PROJECT sono documentate qui. --- +## [2026-03-21] Daily Digest — integrazione memoria Postgres + +### Modifiche al workflow `📬 Gmail — Daily Digest [Schedule]` (`1lIKvVJQIcva30YM`) + +Aggiunto branch parallelo di salvataggio fatti in memoria dopo la classificazione GPT: + +``` +Parse risposta GPT-4.1 ──┬──> Telegram - Invia Report (invariato) + ├──> Dividi Email (invariato) + └──> 🧠 Estrai Fatti ──> 🔀 Ha Fatti? ──> 💾 Upsert Memoria +``` + +**`🧠 Estrai Fatti` (Code):** +- Filtra le email con `action != 'trash'` e summary non vuoto +- Chiama GPT-4.1 in batch per estrarre per ogni email: `fact`, `category`, `ttl_days`, `pompeo_note`, `entity_refs` +- Calcola `expires_at` da `ttl_days` (14gg prenotazioni, 45gg bollette, 90gg lavoro/condominio, 30gg default) +- Restituisce un item per ogni fatto da persistere + +**`💾 Upsert Memoria` (Postgres node → `mRqzxhSboGscolqI`):** +- `INSERT INTO memory_facts` con `source='email'`, `source_ref=threadId` +- `ON CONFLICT ON CONSTRAINT memory_facts_dedup_idx DO UPDATE` → aggiorna se lo stesso thread viene riprocessato +- Campi salvati: `category`, `subject`, `detail` (JSONB), `action_required`, `action_text`, `pompeo_note`, `entity_refs`, `expires_at` + +### Fix contestuale + +- Aggiunto `newer_than:1d` alla query Gmail su entrambi i nodi fetch — evitava di rifetchare email vecchie di mesi non marcate `Processed` + +--- + ## [2026-03-21] Schema DB v2 — contacts, memory_facts_archive, entity_refs ### Nuove tabelle