fix(final-phase): finalize dataset review audit blockers

This commit is contained in:
2026-03-17 18:23:02 +03:00
parent 2dbef02f81
commit 2095d96b16
3 changed files with 19 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
# [DEF:SessionEventLogger:Module]
# [DEF:SessionEventLoggerModule:Module]
# @COMPLEXITY: 4
# @SEMANTICS: dataset_review, audit, session_events, persistence, observability
# @PURPOSE: Persist explicit session mutation events for dataset-review audit trails without weakening ownership or approval invariants.
@@ -8,10 +8,11 @@
# @PRE: Caller provides an owned session scope and an authenticated actor identifier for each persisted mutation event.
# @POST: Every logged event is committed as an explicit, queryable audit record with deterministic event metadata.
# @SIDE_EFFECT: Inserts persisted session event rows and emits runtime belief-state logs for audit-sensitive mutations.
# @DATA_CONTRACT: Input[SessionEventPayload] -> Output[SessionEvent]
from __future__ import annotations
# [DEF:SessionEventLogger.imports:Block]
# [DEF:SessionEventLoggerImports:Block]
from dataclasses import dataclass, field
from typing import Any, Dict, Optional
@@ -19,7 +20,7 @@ from sqlalchemy.orm import Session
from src.core.logger import belief_scope, logger
from src.models.dataset_review import DatasetReviewSession, SessionEvent
# [/DEF:SessionEventLogger.imports:Block]
# [/DEF:SessionEventLoggerImports:Block]
# [DEF:SessionEventPayload:Class]
@@ -41,10 +42,11 @@ class SessionEventPayload:
# @COMPLEXITY: 4
# @PURPOSE: Persist explicit dataset-review session audit events with meaningful runtime reasoning logs.
# @RELATION: [DEPENDS_ON] ->[SessionEvent]
# @RELATION: [DEPENDS_ON] ->[sqlalchemy.orm.Session]
# @RELATION: [DEPENDS_ON] ->[SessionEventPayload]
# @PRE: The database session is live and payload identifiers are non-empty.
# @POST: Returns the committed session event row with a stable identifier and stored detail payload.
# @SIDE_EFFECT: Writes one audit row to persistence and emits logger.reason/logger.reflect traces.
# @DATA_CONTRACT: Input[SessionEventPayload] -> Output[SessionEvent]
class SessionEventLogger:
# [DEF:SessionEventLogger.__init__:Function]
# @COMPLEXITY: 2
@@ -153,4 +155,4 @@ class SessionEventLogger:
# [/DEF:SessionEventLogger.log_for_session:Function]
# [/DEF:SessionEventLogger:Class]
# [/DEF:SessionEventLogger:Module]
# [/DEF:SessionEventLoggerModule:Module]