fix: render registry workspaces for harness
This commit is contained in:
@@ -6,6 +6,7 @@ from tht.config import (
|
||||
PostgresDwhConfig,
|
||||
ThothRestDwhConfig,
|
||||
ThothVectorHttpConfig,
|
||||
workspace_id_for_config,
|
||||
load_config,
|
||||
)
|
||||
from tht.adapters.evidence import FilesystemEvidenceSource, HttpManifestEvidenceSource
|
||||
@@ -86,6 +87,65 @@ roots:
|
||||
assert cfg.roots.sessions.as_posix() == "build/sessions"
|
||||
|
||||
|
||||
def test_runtime_handoff_preserves_canonical_identity_and_durable_roots(monkeypatch, tmp_path):
|
||||
data_root = tmp_path / "data"
|
||||
runtime_root = data_root / "sessions" / "psd-clinical"
|
||||
workspace = tmp_path / "runtime-random-uuid.yaml"
|
||||
workspace.write_text(f"""
|
||||
runtime_identity:
|
||||
workspace_id: psd-clinical
|
||||
workspace_revision: {'a' * 40}
|
||||
dwh:
|
||||
type: postgres_direct
|
||||
connection: {{database: analytics, schema: mart, user: reader, password: secret}}
|
||||
vectors:
|
||||
type: pgvector_direct
|
||||
connection: {{database: analytics, schema: vectors, user: vector, password: secret}}
|
||||
roots:
|
||||
sessions: {runtime_root / 'sessions'}
|
||||
artifacts: {runtime_root / 'artifacts'}
|
||||
indexes: {runtime_root / 'indexes'}
|
||||
embeddings: {{base_url: http://embedding.invalid, model: embed, dim: 768}}
|
||||
""")
|
||||
monkeypatch.setenv("THT_DATA_ROOT", str(data_root))
|
||||
|
||||
cfg = load_config(workspace)
|
||||
|
||||
assert cfg._workspace_id == "psd-clinical"
|
||||
assert cfg._workspace_revision == "a" * 40
|
||||
assert cfg.paths.sessions == runtime_root / "sessions"
|
||||
assert cfg.paths.artifacts == runtime_root / "artifacts"
|
||||
assert cfg.paths.indexes == runtime_root / "indexes"
|
||||
|
||||
|
||||
def test_runtime_identity_is_authoritative_over_runtime_filename(tmp_path):
|
||||
workspace = tmp_path / "runtime-random-uuid.yaml"
|
||||
workspace.write_text(f"""
|
||||
runtime_identity:
|
||||
workspace_id: psd-clinical
|
||||
workspace_revision: {'a' * 40}
|
||||
dwh:
|
||||
type: postgres_direct
|
||||
connection: {{database: analytics, schema: mart, user: reader, password: secret}}
|
||||
roots: {{sessions: sessions, artifacts: artifacts, indexes: indexes}}
|
||||
""")
|
||||
|
||||
cfg = load_config(workspace)
|
||||
|
||||
assert workspace_id_for_config(cfg, workspace) == "psd-clinical"
|
||||
|
||||
|
||||
def test_load_config_rejects_executable_yaml_tags_without_running_them(tmp_path):
|
||||
marker = tmp_path / "must-not-exist"
|
||||
workspace = tmp_path / "workspace.yaml"
|
||||
workspace.write_text(f"dwh: !command touch {marker}\n")
|
||||
|
||||
with pytest.raises(ConfigError, match="YAML|configurazione"):
|
||||
load_config(workspace)
|
||||
|
||||
assert not marker.exists()
|
||||
|
||||
|
||||
def test_loads_direct_discriminated_resources(tmp_path):
|
||||
workspace = tmp_path / "workspace.yaml"
|
||||
workspace.write_text(
|
||||
|
||||
Reference in New Issue
Block a user