feat(store): set_schema_linking validates then writes the F4 artifact
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
from datetime import UTC, datetime
|
||||
@@ -158,6 +159,28 @@ def set_question(
|
||||
return path
|
||||
|
||||
|
||||
def set_schema_linking(
|
||||
session_id: str,
|
||||
data: dict,
|
||||
sessions_root: Path,
|
||||
) -> Path:
|
||||
"""Valida e scrive schema_linking.json (Fase 4) in modo deterministico.
|
||||
|
||||
Valida `data` contro il modello SchemaLinking (ValidationError se invalido) PRIMA
|
||||
di scrivere, così un artefatto malformato non tocca mai il disco. Ritorna il path.
|
||||
"""
|
||||
from tht.session.models import SchemaLinking
|
||||
|
||||
load_session(session_id, sessions_root)
|
||||
model = SchemaLinking.model_validate(data)
|
||||
path = sessions_root / session_id / "schema_linking.json"
|
||||
path.write_text(
|
||||
json.dumps(model.model_dump(by_alias=True), indent=2, ensure_ascii=False)
|
||||
)
|
||||
touch_manifest(session_id, sessions_root)
|
||||
return path
|
||||
|
||||
|
||||
def load_session(session_id: str, sessions_root: Path) -> SessionManifest:
|
||||
path = sessions_root / session_id / MANIFEST
|
||||
if not path.exists():
|
||||
|
||||
Reference in New Issue
Block a user