feat: add P2 harness machine contracts
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
from typer.testing import CliRunner
|
||||
@@ -51,9 +52,10 @@ def test_preprocess_failed_job_report_is_sanitized_json_and_nonzero(monkeypatch,
|
||||
|
||||
|
||||
def test_preprocess_real_failed_stage_result_exits_nonzero(monkeypatch, tmp_path):
|
||||
import tht.cli.preprocess_cmd as command
|
||||
from test_corpus_pipeline import Source, item, pipeline
|
||||
|
||||
import tht.cli.preprocess_cmd as command
|
||||
|
||||
result = pipeline(
|
||||
tmp_path, Source([(item("one", "a"), RuntimeError("SENSITIVE EVIDENCE secret"))])
|
||||
).run_as_job(
|
||||
@@ -129,3 +131,32 @@ def test_preprocess_evidence_gc_json_is_pristine(monkeypatch, tmp_path):
|
||||
)
|
||||
assert response.exit_code == 0, response.output
|
||||
assert json.loads(response.output)["dry_run"] is True
|
||||
|
||||
|
||||
def test_preprocess_evidence_uses_runtime_identity_for_dev_fd_config(monkeypatch, tmp_path):
|
||||
import tht.cli.preprocess_cmd as command
|
||||
|
||||
cfg = SimpleNamespace(
|
||||
runtime_identity=SimpleNamespace(workspace_id="runtime-workspace"),
|
||||
embeddings=SimpleNamespace(model="m", dim=4),
|
||||
vector=SimpleNamespace(max_chunk_chars=10, retain_published_generations=1),
|
||||
paths=SimpleNamespace(artifacts=tmp_path / "artifacts"),
|
||||
model_dump_json=lambda: "{}",
|
||||
)
|
||||
captured = {}
|
||||
|
||||
class FakePipeline:
|
||||
def __init__(self, **kwargs):
|
||||
captured.update(kwargs)
|
||||
|
||||
def run_as_job(self, **kwargs):
|
||||
captured.update(kwargs)
|
||||
return SimpleNamespace(model_dump=lambda mode=None: {"status": "succeeded"})
|
||||
|
||||
monkeypatch.setattr(command, "_load_config_or_exit", lambda _: cfg)
|
||||
monkeypatch.setattr("tht.adapters.factory.build_evidence_sources", lambda _: [])
|
||||
monkeypatch.setattr("tht.adapters.factory.build_vector_store", lambda *_args, **_kwargs: object())
|
||||
monkeypatch.setattr("tht.cli.vector_cmd.make_embedder", lambda _: object())
|
||||
monkeypatch.setattr("tht.corpus.pipeline.CorpusPipeline", FakePipeline)
|
||||
command.run_from_config(Path("/dev/fd/3"))
|
||||
assert captured["workspace_id"] == "runtime-workspace"
|
||||
|
||||
Reference in New Issue
Block a user