Full flow run by Main/main.py on every round: fetches the pending errors from
tb_jobs_test, loads the diagnostic manual as the priority knowledge
base, isolates the actual procedure that failed (never an orchestrating "Parent Procedure"),
reproduces and tests hypotheses always inside a TRANSACTION + ROLLBACK, rebuilds
the execution context up to 3 levels deep, uses AI to confirm the root cause and generate the SQL
patch, saves the result and notifies Teams — continuing through all remaining candidates for
the same error, not just the first one.
Inputtb_jobs_test
Knowledge basemanual_diagnostico_ia.docx
OutputTB_ANALISE_IA + Teams card (per finding)
Isolated failurelogs it and moves to the next candidate/JOB
How to read the diagram
Phase 1 — select procedure
Phase 2 — manual + locate the block
Phase 3 — context + AI diagnosis
Phase 4 — log and notify
Decision point
Runs in sandbox (always ROLLBACK)
Exception / fallback path
Retry or bypass
Center column: normal flow of an analysis. Right column: branches (orchestrating Parent Procedure
excluded, next candidate, static block fallback, no patch). The longest dashed line loops around
the entire diagram when no candidate procedure reproduces any error at all — it jumps straight to
"more errors in the list?", without entering the diagnosis phase.