feat(finalize): auto-index the question->SQL pair (best-effort, never blocks)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-07 13:48:02 +02:00
co-authored by Claude Fable 5
parent 1f429b6b35
commit 2742a1fc42
+19
View File
@@ -474,6 +474,25 @@ def finalize_cmd(session_id: str = typer.Argument(...), config: Path = CONFIG_OP
manifest.updated_at = datetime.now(UTC)
manifest.updated_by = current_author()
manifest.to_yaml(sdir / MANIFEST)
# --- memoria attiva (parte B): indicizza la coppia domanda->SQL, best-effort ---
# Import lazy: memory_cmd importa da session_cmd (un import top-level qui sarebbe
# circolare). Qualunque errore (writer key assente, VPN giu', Ollama spento) NON
# deve bloccare il finalize: l'indice e' derivato e recuperabile con
# `tht memory solved-index <id>`.
try:
from tht.cli.memory_cmd import index_solved_session
if index_solved_session(cfg, session_id):
typer.secho(
"OK: coppia domanda->SQL indicizzata nel vectordb (solved_question).",
fg=typer.colors.GREEN,
)
except Exception as e:
typer.secho(
f"ATTENZIONE: coppia domanda->SQL non indicizzata ({e}). "
f"Recupera con `tht memory solved-index {session_id}`.",
fg=typer.colors.YELLOW, err=True,
)
typer.secho(f"OK: sessione {session_id} finalizzata. Artefatti:", fg=typer.colors.GREEN)
for name in ARTIFACT_FILES:
state = "presente" if (sdir / name).exists() else "assente"