refactor(evidence): migrate runtime consumption (#29)

This commit is contained in:
2026-08-24 02:10:06 +02:00
parent 8b63715b56
commit d5e78febd3
8 changed files with 128 additions and 58 deletions
+7 -11
View File
@@ -54,18 +54,16 @@ def search_cmd(
from rich.table import Table
from tht.cli.vector_cmd import make_embedder, open_searcher, require_vector_cfg
from tht.evidence import active_searcher, validate_corpus_workspace
from tht.lshindex import LshIndexError, load_index, query_index
from tht.search import combined_search
cfg = _load_config_or_exit(config)
from tht.search.evidence import validate_corpus_workspace
workspace_id = workspace_id_for_config(cfg, config)
validate_corpus_workspace(cfg, workspace_id)
dwh_snapshot = _leased_dwh_snapshot(cfg, ctx)
require_vector_cfg(cfg)
from tht.search.evidence import active_searcher
runtime_searcher = active_searcher(
cfg, open_searcher(cfg),
workspace_id=workspace_id,
@@ -255,13 +253,17 @@ def pack_cmd(
from sqlalchemy.exc import OperationalError
from tht.cli.vector_cmd import make_embedder, open_searcher, require_vector_cfg
from tht.evidence import (
active_searcher,
build_retrieval_entries,
validate_corpus_workspace,
)
from tht.ports.vector import VectorReadUnavailable, VectorStoreError
from tht.search import combined_search, schema_tables
from tht.memory import SOLVED_KIND
from tht.vectorstore.embeddings import EmbeddingsError
cfg = _load_config_or_exit(config)
from tht.search.evidence import validate_corpus_workspace
workspace_id = workspace_id_for_config(cfg, config)
validate_corpus_workspace(cfg, workspace_id)
@@ -277,8 +279,6 @@ def pack_cmd(
vec = None
searcher = embedder = None
try:
from tht.search.evidence import active_searcher
searcher = active_searcher(
cfg, open_searcher(cfg),
workspace_id=workspace_id,
@@ -314,11 +314,7 @@ def pack_cmd(
top=PACK_EVIDENCE_TOP, rrf_k=cfg.search.rrf_k,
kinds=KIND_MAP["evidence"], query_vec=vec,
)
evidence = [
{"title": r.label, "status": r.status,
"excerpt": r.content[:PACK_EXCERPT_CHARS]}
for r in ev
]
evidence = build_retrieval_entries(ev, excerpt_chars=PACK_EXCERPT_CHARS)
except degrade as e:
warnings.append(f"ricerca evidence fallita ({e})")
try:
+2 -2
View File
@@ -518,7 +518,7 @@ def finalize_cmd(session_id: str = typer.Argument(...), config: Path = CONFIG_OP
from tht.execute import ExecutionError
from tht.execute.warnings import plan_warnings, runtime_warnings, static_warnings
from tht.report import extract_reviewer_notes, render_validation_report
from tht.session.artifacts import build_evidence_entries
from tht.evidence import project_session
from tht.phase import cte_plan as effective_cte_plan
from tht.phase import effective_decisions
from tht.session.models import SchemaLinking
@@ -614,7 +614,7 @@ def finalize_cmd(session_id: str = typer.Argument(...), config: Path = CONFIG_OP
linking = SchemaLinking.model_validate(
json.loads(snapshot.artifacts["schema_linking"])
)
entries = build_evidence_entries(decisions, linking, cfg.paths.artifacts / "evidence")
entries = project_session(decisions, linking, cfg.paths.artifacts / "evidence")
evidence = json.dumps(entries, ensure_ascii=False, indent=2)
# --- manifest + riepilogo ---