refactor(harness): renaming prodotto tht (Onda -1)

Thoth (tht) è il prodotto, PSD è il cliente. Nessun riferimento al contesto
clinico nel codice.

Rinomine:
- comando+package nsp→tht (dir nsp/→tht/, 46 import, pyproject entry point)
- gate nsp-gate.js→tht-gate.js (+ rewrite token, relayIfNspFails→relayIfThtFails)
- workspace chirone.{example,test}.yaml→tht.{example,test}.yaml (generici)
- env THOTH_→THT_ (19 var) + NSP_ stragglers (NSP_HARNESS_ROOT, NSP_SESSION)
- commenti/docstring chirone/psdwp3/policlinico neutralizzati ('the reference
  implementation', 'the DWH')

Aggiunto [tool.setuptools.packages.find] include=['tht*'] (necessario: l'auto-
discovery rompeva con tht/ + workspaces/ come top-level multipli).

.env operatore aggiornato in-place (prefissi THT_, valori preservati, gitignored).

Verifica: pytest 109 passed, npm test 14 pass, tht phase meta --json OK, zero
residui nsp/THOTH_/NSP_/chirone nel package.
This commit is contained in:
2026-06-27 10:33:16 +02:00
parent 0dcc0246dc
commit fc5fbe6b65
72 changed files with 309 additions and 306 deletions
@@ -1,4 +1,4 @@
"""L2: nsp memory save-one against real pgvector (spec D11, L2).
"""L2: tht memory save-one against real pgvector (spec D11, L2).
Validates D11 end-to-end: a single promoted decision is upserted to the real
pgvector via the WRITER key (not a full resync), and a subsequent search_similar
@@ -13,18 +13,18 @@ from unittest.mock import MagicMock
import pytest
from nsp.memory import MemoryRecord, save_one_memory
from nsp.workspace import load_workspace
from tht.memory import MemoryRecord, save_one_memory
from tht.workspace import load_workspace
pytestmark = [pytest.mark.l2]
WORKSPACE = Path(__file__).resolve().parents[2] / "workspaces" / "chirone-test.yaml"
WORKSPACE = Path(__file__).resolve().parents[2] / "workspaces" / "tht-test.yaml"
def test_save_one_upserts_to_real_pgvector(l2_env):
"""save_one_memory pushes one row to the real pgvector via the writer key, and
a subsequent search_similar retrieves it. Idempotent (re-running upserts >= 0)."""
from nsp.vectorstore.embeddings import OllamaEmbeddings
from nsp.vectorstore.rest_client import VectorRestClient
from tht.vectorstore.embeddings import OllamaEmbeddings
from tht.vectorstore.rest_client import VectorRestClient
ws = load_workspace(WORKSPACE)
if not ws.vector_write_rest or not ws.vector_write_rest.api_key.strip():
+6 -6
View File
@@ -11,8 +11,8 @@ MODES (both manual, non-deterministic, pre-release -- NOT a regression gate):
Altro/value-grounding/rollback paths so specific behaviors assert deterministically.
HOW TO RUN (operator, before release):
1. Populate harness/.env (THOTH_DWH_API_KEY, THOTH_VEC_API_KEY,
THOTH_VEC_WRITE_API_KEY, THOTH_SSL_CA, THOTH_*_REST_URL, THOTH_OLLAMA_URL).
1. Populate harness/.env (THT_DWH_API_KEY, THT_VEC_API_KEY,
THT_VEC_WRITE_API_KEY, THT_SSL_CA, THT_*_REST_URL, THT_OLLAMA_URL).
2. Connect VPN. Ensure Pi is configured locally with GLM 5.2.
3. Run: pytest -m l2 tests/l2/test_session_ablazione.py -s
@@ -30,13 +30,13 @@ import pytest
pytestmark = [pytest.mark.l2]
WORKSPACE = Path(__file__).resolve().parents[2] / "workspaces" / "chirone-test.yaml"
WORKSPACE = Path(__file__).resolve().parents[2] / "workspaces" / "tht-test.yaml"
QUESTION = "dammi la lista dei pazienti che hanno fatto un'ablazione nel 2025"
def test_workspace_chirone_test_loads(l2_env):
"""The L2 workspace YAML loads and expands ${THOTH_*} from .env."""
from nsp.workspace import load_workspace
"""The L2 workspace YAML loads and expands ${THT_*} from .env."""
from tht.workspace import load_workspace
ws = load_workspace(WORKSPACE)
# secrets must be expanded (not the literal ${...} token)
@@ -68,7 +68,7 @@ def test_ablazione_session_manual(l2_env, tmp_path):
# assertion. We surface the run instructions and assert only that the launch
# context is ready; the operator drives the conversation and inspects the outcome.
env_ok = all(os.environ.get(v, "").strip() for v in
["THOTH_DWH_API_KEY", "THOTH_VEC_API_KEY", "THOTH_VEC_WRITE_API_KEY"])
["THT_DWH_API_KEY", "THT_VEC_API_KEY", "THT_VEC_WRITE_API_KEY"])
assert env_ok
assert WORKSPACE.exists()
print(f"\n[L2 manual] launch: pi --mode rpc (cwd=harness/)")
+10 -10
View File
@@ -10,31 +10,31 @@ from pathlib import Path
import pytest
from nsp.workspace import load_workspace
from tht.workspace import load_workspace
pytestmark = [pytest.mark.l2]
WORKSPACE = Path(__file__).resolve().parents[2] / "workspaces" / "chirone-test.yaml"
WORKSPACE = Path(__file__).resolve().parents[2] / "workspaces" / "tht-test.yaml"
def test_ablazione_returns_multiple_columns(l2_env):
"""On the real schema, 'ablazione' should ground to more than one column (e.g.
a flag and a free-text patologia field) -- the whole point of D14a's
non-collapsing aggregation. Requires a built LSH index (nsp lsh build)."""
from nsp.config import LshConfig
non-collapsing aggregation. Requires a built LSH index (tht lsh build)."""
from tht.config import LshConfig
try:
from nsp.lshindex import load_index, query_index # ported with the lsh build path
from tht.lshindex import load_index, query_index # ported with the lsh build path
except ModuleNotFoundError:
pytest.skip("nsp.lshindex not yet ported (deferred from B3; lands with nsp lsh build)")
from nsp.search import aggregate_lsh_multi
pytest.skip("tht.lshindex not yet ported (deferred from B3; lands with tht lsh build)")
from tht.search import aggregate_lsh_multi
# NOTE: this test assumes the LSH index was built (nsp lsh build --workspace
# chirone-test). If absent, build it first. The index path comes from the config.
# NOTE: this test assumes the LSH index was built (tht lsh build --workspace
# tht-test). If absent, build it first. The index path comes from the config.
ws = load_workspace(WORKSPACE)
index_dir = ws.paths.indexes
try:
lsh, minhashes, meta = load_index(index_dir, "datawarehouse")
except Exception as e:
pytest.skip(f"LSH index not built yet (run nsp lsh build): {e}")
pytest.skip(f"LSH index not built yet (run tht lsh build): {e}")
hits = query_index(lsh, minhashes, "ablazione", meta, top_n=20)
grouped = aggregate_lsh_multi(