Implementazione del piano di remediation progressiva sui difetti emersi dall'analisi dell'harness. Tutto verificato: 214 test Python (incl. L0 su Postgres reale), 14 test JS del gate, ruff pulito. Blocco 1 (CRITICA, integrazione gate↔CLI): - phase advance: gate usa --auto + exit 6; reviewer_confirm kind:phase fa advance esplicito che applica i prerequisiti (prima non avanzava per le fasi a conferma umana). - cte plan riceve i --name dal gate (param names); set-question con id posizionale; skill `tht search find`; nuovo comando `tht memory save-one` con dedup hash client-side in save_one_memory. Blocco 2 (D15, stato post-rollback): - campo `phase` su DecisionRecord + effective_decisions phase-aware per i subject "a nome" (cte_approved ecc.); _compute_promotions e finalize sulla vista effective; finalize confronta col piano CTE effettivo, non glob; `decision add --retracts` + comando `decision retract`. Blocco 3 (D7 read-only + D6 manifest): - assert_read_only su tutti e quattro i codepath (direct + REST); - manifest author/summary/updated_at/updated_by/schema_version popolati + helper touch_manifest sulle mutazioni. Blocco 4-5 (D14a/D14b): - decision_min_phase data-driven via `emits:` in workflow.yaml; - formula evidence: status auto, search_formulas, gruppo CLI `tht formula`, `search find --kind formula`, load_evidence_dir salta i .sql.md. Blocco 6 (robustezza): - taskdoc slice promoted_tables + bound enforced; report escaping/bound + rsplit note; filtro kind reader REST/direct; conteggio upserted robusto; guard REST run_query non-list; LSH disallineato -> LshIndexError. Blocco 7 (pulizia): - dead code gate e KIND_TO_TABLE morto rimossi; doc Postgres-only (README + connection.py). Blocco 0 (parziale): test di compatibilità firma gate↔CLI (tests/integration). Rinviati: fake-Pi runtime completo, artifact-gate da disco (#23), parità eligibility REST/direct (#28), unificazione reserved-labels (#30), memory_rejected da deselezione (#33). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
38 lines
1.7 KiB
Python
38 lines
1.7 KiB
Python
"""D14b wiring: status=auto, search_formulas, and evidence loader skips formula files.
|
|
|
|
Completes the formula layer beyond the store: the `auto` status the spec requires
|
|
(§4.7.2), the concept-substring retrieval that `tht search find --kind formula` uses,
|
|
and the guarantee that load_evidence_dir does NOT choke on *.sql.md formula files when
|
|
they live under the evidence root.
|
|
"""
|
|
from tht.evidence.formula_store import ConceptFormula, save_formula, search_formulas
|
|
from tht.evidence.model import EvidenceDoc, load_evidence_dir
|
|
|
|
|
|
def test_status_auto_is_valid():
|
|
f = ConceptFormula(concept="x", sql="SELECT 1", status="auto")
|
|
assert f.status == "auto"
|
|
# round-trips through parse/dump
|
|
assert ConceptFormula.parse(f.dump()).status == "auto"
|
|
|
|
|
|
def test_search_formulas_substring_case_insensitive(tmp_path):
|
|
save_formula(tmp_path, ConceptFormula(concept="fascia pediatrica", sql="SELECT 1"))
|
|
save_formula(tmp_path, ConceptFormula(concept="indice di Charlson", sql="SELECT 2"))
|
|
hits = search_formulas(tmp_path, "PEDIATRICA")
|
|
assert len(hits) == 1
|
|
assert hits[0].concept == "fascia pediatrica"
|
|
assert search_formulas(tmp_path, "charlson")[0].concept == "indice di Charlson"
|
|
|
|
|
|
def test_load_evidence_dir_skips_formula_files(tmp_path):
|
|
# a real evidence doc + a formula file under the same root
|
|
(tmp_path / "ev1.md").write_text(
|
|
"---\nid: ev1\ntitle: T\n---\nbody text\n"
|
|
)
|
|
save_formula(tmp_path, ConceptFormula(concept="ablazione", sql="SELECT 1"))
|
|
docs = load_evidence_dir(tmp_path)
|
|
ids = [d.id for d in docs]
|
|
assert ids == ["ev1"] # the .sql.md formula file is skipped, no crash
|
|
assert all(isinstance(d, EvidenceDoc) for d in docs)
|