test(harness): L1 characterization tests per Onda 0 (sqlcheck, ctetest, execute)

44 test L1 sui 3 moduli backend con logica non banale (opzione 2 della user review):

- sqlcheck.validate_sql (16 test): parse/single-statement, read-only enforcement
  (INSERT/UPDATE/DELETE/CREATE/DROP/ALTER/TRUNCATE/GRANT rifiutati, WITH/UNION ok),
  forbidden functions (dblink default blacklist, custom set, allowed not flagged),
  object-existence (tabella inesistente, CTE non flaggata, perimetro promoted warning,
  colonna inesistente con alias). Documenta una limitazione reale: le funzioni
  aggregate specializzate (count/sum/coalesce) NON sono catturate dal name-matcher
  perche' sqlglot modella .name come argomento, non come nome funzione.

- ctetest (14 test): has_trailing_select (semantica controintuitiva: True = violazione),
  last_cte_name, build_test_sql, ledger I/O (load/append roundtrip, JSON-array e
  JSONL tolleranti, corrupt-ledger raise).

- execute._inject_limit (6 test): LIMIT iniettato quando assente (limit+1 per
  troncamento), rispettato quando presente, non iniettato su non-query, UNION/WITH ok.

Suite: 153 passed (109 + 44). Bonus: __psd_probe__ -> __tht_probe__ (riferimento
cliente neutralizzato in ctetest).
This commit is contained in:
2026-06-27 13:04:34 +02:00
parent d857004f47
commit 31552782c0
4 changed files with 358 additions and 1 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ from pydantic import BaseModel
from sqlglot import exp
CTE_TESTS_FILE = "cte_tests.json"
PROBE = "\nSELECT * FROM __psd_probe__"
PROBE = "\nSELECT * FROM __tht_probe__"
class CteError(Exception):