feat: visible per-product enrichment status, flagged re-evaluation (panel/Reprocessar/Sincronizar/KB decision), operator NCM decision, deterministic name-only match, stale-write guard; 1.3.5

This commit is contained in:
gti
2026-09-26 14:37:37 -03:00
parent ab65ddd679
commit 1333ac1bc4
34 changed files with 804 additions and 42 deletions
+13
View File
@@ -30,6 +30,9 @@ def create_job(session, agent, kind, payload=None):
(no duplicates, never two full jobs at once)."""
if kind not in _VALID_KINDS:
raise ValueError(f"unsupported job kind: {kind}")
if kind in ("REPROCESS_ALL", "REPROCESS_PRODUCTS", "SYNC_INCREMENTAL"):
_flag_enrichment_reevaluation(session, agent) # "Reprocessar"/"Sincronizar" also re-evaluate the tracked, not-yet-enriched products (KB/cache first), even when an equivalent job is already queued
session.commit()
if kind in SYNC_KINDS:
# A full job subsumes an incremental one, not the other way round: asking for a
# full reprocess while only an incremental is queued must still queue the full.
@@ -43,6 +46,16 @@ def create_job(session, agent, kind, payload=None):
return job
def _flag_enrichment_reevaluation(session, agent):
try:
installation = session.scalar(select(Installation).where(Installation.agent_id == agent.id))
if installation is not None and installation.features_configured and installation.enrichment_mode != "DISABLED":
from .enrichment.status import mark_for_reevaluation
mark_for_reevaluation(session, installation.id)
except Exception: # noqa: BLE001 - never let the enrichment bookkeeping break job creation
pass
def recover_stale_running(session, agent, now=None):
now = now or datetime.now(timezone.utc)
cutoff = now - STALE_RUNNING_AFTER