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
+41
View File
@@ -0,0 +1,41 @@
"""tht CLI -- Typer app `tht`.
Minimal skeleton for now: registers `phase_app` (the gate needs `tht phase meta --json`).
Other command groups (db, schema, lsh, vector, memory, session, decision, sql, cte,
evidence, search) are wired in their porting tasks, once their backend deps land
(A9 ports db/mschema/_guards; B1 ports vectorstore; B3 ports search/lshindex/sampling).
"""
from __future__ import annotations
import typer
from tht import __version__
app = typer.Typer(
help="tht (Thoth) -- kit operativo per generazione SQL assistito da Pi",
no_args_is_help=True,
)
def _version_callback(value: bool) -> None:
if value:
typer.echo(__version__)
raise typer.Exit()
@app.callback()
def main(
version: bool = typer.Option(
False,
"--version",
callback=_version_callback,
is_eager=True,
help="Mostra la versione ed esce.",
),
) -> None:
pass
from tht.cli.phase_cmd import phase_app # noqa: E402
app.add_typer(phase_app, name="phase")
+40
View File
@@ -0,0 +1,40 @@
import typer
def require_server_profile(cfg, command: str) -> None:
"""Rifiuta i comandi di scrittura vectordb sul profilo workstation (exit 4).
Va chiamata subito dopo il caricamento della config e PRIMA di aprire qualunque
connessione, cosi' su workstation non si tenta mai la connessione diretta al vectordb.
"""
if cfg.profile == "workstation":
typer.secho(
f"ERRORE: `{command}` e' un comando solo-server (scrive nel vectordb centrale). "
f"Sulla postazione locale (profile: workstation) il vectordb si LEGGE via REST, "
f"non si ricostruisce. Esegui questo comando sul server di produzione "
f"(profile: server).",
fg=typer.colors.RED, err=True,
)
raise typer.Exit(code=4)
def has_vector_write_rest(cfg) -> bool:
return cfg.vector_write_rest is not None and bool(cfg.vector_write_rest.api_key.strip())
def require_vector_write_allowed(cfg, command: str) -> None:
"""Permette scritture vectordb da workstation solo con API key REST writer.
Senza `vector_write_rest`, la workstation resta read-only e i comandi di indexing sono
eseguibili solo sul server con connessione diretta al vectordb.
"""
if cfg.profile == "workstation" and not has_vector_write_rest(cfg):
typer.secho(
f"ERRORE: `{command}` e' un comando solo-server se manca `vector_write_rest`: "
f"scrive nel vectordb centrale. Sulla postazione locale serve la sezione "
f"`vector_write_rest` con una API key di upsert; in alternativa esegui il "
f"comando sul server di produzione (profile: server).",
fg=typer.colors.RED, err=True,
)
raise typer.Exit(code=4)
+51
View File
@@ -0,0 +1,51 @@
"""tht phase -- workflow HITL gate commands.
`meta` is the single source the gate (tht-gate.js) reads workflow facts from,
killing the JS/Python PHASE_NAMES drift (F2). advance/reopen/show land with the
session/db ports (A9) -- they need current_phase + load_session_or_exit which
depend on the not-yet-ported session store helpers.
"""
from __future__ import annotations
import json
import typer
from tht.workflow import load_workflow
phase_app = typer.Typer(help="Fase del workflow HITL (gate di avanzamento/ritorno)")
@phase_app.command("meta")
def meta_cmd(
as_json: bool = typer.Option(
False,
"--json",
help="Emette i metadati del workflow come JSON (usato dall'estensione gate).",
),
) -> None:
"""Stampa i metadati del workflow derivati da workflow.yaml (F2)."""
wf = load_workflow()
if not as_json:
typer.echo(f"max_phase: {wf.max_phase}")
for p in wf.phases:
typer.echo(f" {p.id} ({p.num}/{wf.max_phase}) {p.name} advance={p.advance}")
return
typer.echo(
json.dumps(
{
"schema_version": wf.schema_version,
"max_phase": wf.max_phase,
"phases": [
{
"num": p.num,
"id": p.id,
"name": p.name,
"advance": p.advance,
"artifacts_out": p.artifacts_out,
}
for p in wf.phases
],
}
)
)