fix(harness): record postgres decision phases

This commit is contained in:
User
2026-07-16 18:08:17 +02:00
parent c1cddaa667
commit 72db6b823d
2 changed files with 37 additions and 1 deletions
+15 -1
View File
@@ -352,6 +352,20 @@ class PostgresSessionRepository:
with self._transaction() as connection:
self._lock_session(connection, session_id)
self._require_session(connection, session_id)
from tht.phase import current_phase
manifest = SessionManifest.model_validate(connection.execute(
text("SELECT manifest FROM thoth_sessions.sessions WHERE id = :id"), {"id": session_id}
).scalar_one())
ledger = [
DecisionRecord.model_validate(dict(item))
for item in connection.execute(
text("SELECT seq, ts, phase, type, subject, detail, rationale, retracts "
"FROM thoth_sessions.review_decisions WHERE session_id = :id ORDER BY seq"),
{"id": session_id},
).mappings()
]
phase = current_phase(SessionSnapshot(manifest=manifest, decisions=ledger))
next_seq = connection.execute(
text(
"SELECT COALESCE(MAX(seq), 0) + 1 FROM thoth_sessions.review_decisions "
@@ -361,7 +375,7 @@ class PostgresSessionRepository:
).scalar_one()
now = datetime.now(UTC)
records = [
DecisionRecord(seq=next_seq + offset, ts=now, phase=None, **item.model_dump())
DecisionRecord(seq=next_seq + offset, ts=now, phase=phase, **item.model_dump())
for offset, item in enumerate(inputs)
]
connection.execute(