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>
44 lines
1.8 KiB
Python
44 lines
1.8 KiB
Python
"""D6 §5.2: the manifest's new fields are actually written (not just declared).
|
|
|
|
The reference bug: author/summary/updated_at/updated_by/schema_version existed on the
|
|
model but no code ever populated them. These tests pin that create_session fills them
|
|
and that mutations (set_question, touch_manifest) bump updated_at/updated_by.
|
|
"""
|
|
from tht.config import DatabaseConfig
|
|
from tht.session.store import create_session, load_session, set_question, touch_manifest
|
|
|
|
|
|
def _db() -> DatabaseConfig:
|
|
return DatabaseConfig(host="h", port=5432, database="dw", user="u", password="p", schema="dwh")
|
|
|
|
|
|
def test_create_session_populates_new_fields(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("THT_AUTHOR", "alice@psd")
|
|
m = create_session("Quanti ricoveri per ablazione nel 2024?", _db(), tmp_path)
|
|
assert m.author == "alice@psd"
|
|
assert m.updated_by == "alice@psd"
|
|
assert m.summary and m.summary.startswith("Quanti ricoveri")
|
|
assert m.created_at is not None
|
|
assert m.updated_at == m.created_at
|
|
assert m.schema_version is not None # from workflow.yaml
|
|
|
|
|
|
def test_default_author_when_env_absent(tmp_path, monkeypatch):
|
|
monkeypatch.delenv("THT_AUTHOR", raising=False)
|
|
m = create_session("x", _db(), tmp_path)
|
|
assert m.author == "dev@local"
|
|
|
|
|
|
def test_touch_manifest_bumps_updated(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("THT_AUTHOR", "alice@psd")
|
|
m = create_session("domanda", _db(), tmp_path)
|
|
created = m.updated_at
|
|
monkeypatch.setenv("THT_AUTHOR", "bob@psd")
|
|
set_question(m.id, "domanda riscritta", [], tmp_path)
|
|
reloaded = load_session(m.id, tmp_path)
|
|
assert reloaded.updated_by == "bob@psd"
|
|
assert reloaded.updated_at >= created
|
|
# touch_manifest helper is reachable and updates the field
|
|
touch_manifest(m.id, tmp_path, updated_by="carol@psd")
|
|
assert load_session(m.id, tmp_path).updated_by == "carol@psd"
|