refactor(harness): route workflow persistence through repositories
This commit is contained in:
@@ -99,7 +99,10 @@ def load_cte_tests(session_dir: Path) -> list[CteTestRecord]:
|
||||
path = session_dir / CTE_TESTS_FILE
|
||||
if not path.exists():
|
||||
return []
|
||||
text = path.read_text()
|
||||
return load_cte_tests_text(path.read_text())
|
||||
|
||||
|
||||
def load_cte_tests_text(text: str) -> list[CteTestRecord]:
|
||||
try:
|
||||
objs = list(_iter_json_objects(text))
|
||||
except json.JSONDecodeError as e:
|
||||
@@ -107,6 +110,11 @@ def load_cte_tests(session_dir: Path) -> list[CteTestRecord]:
|
||||
return [CteTestRecord.model_validate(o) for o in objs]
|
||||
|
||||
|
||||
def append_cte_test_snapshot(repository, snapshot, record: CteTestRecord) -> None:
|
||||
previous = snapshot.artifacts.get("cte_tests", "")
|
||||
repository.write_artifact(snapshot.manifest.id, "cte_tests", previous + record.model_dump_json() + "\n")
|
||||
|
||||
|
||||
def append_cte_test(session_dir: Path, record: CteTestRecord) -> None:
|
||||
"""Append atomico (una riga JSON per esito): scritture concorrenti sulla
|
||||
stessa sessione non si sovrascrivono, a differenza del rewrite dell'array."""
|
||||
|
||||
Reference in New Issue
Block a user